UNPKG

@ray-js/components

Version:

Ray basic components

46 lines 1.66 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; const _excluded = ["options", "name", "disabled", "onChange", "children", "style"]; import "core-js/modules/esnext.iterator.constructor.js"; import "core-js/modules/esnext.iterator.map.js"; import * as React from 'react'; import { RadioGroup as RemaxRadioGroup } from '@ray-js/adapter'; import Radio from '../Radio'; import Label from '../Label'; import { inlineStyle } from '@ray-js/framework-shared'; const RadioGroup = props => { const { options, name, disabled, onChange, children, style } = props, restProps = _objectWithoutProperties(props, _excluded); return ( /*#__PURE__*/ // @ts-ignore React.createElement(RemaxRadioGroup, _extends({ style: inlineStyle(style), name: name, onChange: e => { !disabled && (onChange === null || onChange === void 0 ? void 0 : onChange(e)); } }, restProps), (() => children)() || (() => { if (!options || !Array.isArray(options)) return null; return options.map((item, index) => { var _item$checked; return /*#__PURE__*/React.createElement(Label, { key: index + '_' + item.value }, /*#__PURE__*/React.createElement(Radio, { value: item.value, checked: (_item$checked = item.checked) !== null && _item$checked !== void 0 ? _item$checked : false, disabled: disabled || item.disabled || false, color: item.color }), item.label); }); })()) ); }; export default RadioGroup;