@td-design/react-native
Version:
react-native UI组件库
48 lines • 1.51 kB
JavaScript
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React, { forwardRef } from 'react';
import Flex from '../flex';
import { px } from '../helpers/normalize';
import RadioItem from './RadioItem';
import useRadio from './useRadio';
const Radio = /*#__PURE__*/forwardRef((_ref2,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_ref) => {
let {
value,
disabledValue,
defaultValue,
containerStyle,
options,
size = px(24),
onChange,
activeOpacity = 0.6,
...restProps
} = _ref2;
const {
transformedOptions = [],
handleChange
} = useRadio({
options,
disabledValue,
defaultValue,
onChange,
value
});
return /*#__PURE__*/React.createElement(Flex, {
flexWrap: "wrap",
style: containerStyle
}, transformedOptions.map((option, index, array) => {
return /*#__PURE__*/React.createElement(RadioItem, _extends({
key: option.value
}, option, {
size: size,
onChange: handleChange,
isLast: index === array.length - 1,
activeOpacity
}, restProps));
}));
});
Radio.displayName = 'Radio';
export { Radio };
export { default as RadioList } from './RadioList';
//# sourceMappingURL=index.js.map