@td-design/react-native
Version:
react-native UI组件库
60 lines • 1.9 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 CheckboxItem from './CheckboxItem';
import useCheckbox from './useCheckbox';
const Checkbox = /*#__PURE__*/forwardRef((_ref2,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_ref) => {
let {
value,
disabledValue,
defaultValue,
containerStyle,
options,
showCheckAll = true,
size = px(24),
onChange,
activeOpacity = 0.6,
...restProps
} = _ref2;
const {
transformedOptions = [],
checkedAllStatus,
handleAllChange,
handleChange
} = useCheckbox({
options,
disabledValue,
defaultValue,
onChange,
value,
showCheckAll
});
return /*#__PURE__*/React.createElement(Flex, {
flexWrap: "wrap",
style: containerStyle
}, showCheckAll && /*#__PURE__*/React.createElement(CheckboxItem, _extends({
disabled: false,
label: "\u5168\u9009",
value: "checkbox-select-all",
status: checkedAllStatus,
size: size,
onChange: handleAllChange,
activeOpacity
}, restProps)), transformedOptions.map((option, index, array) => {
return /*#__PURE__*/React.createElement(CheckboxItem, _extends({
key: option.value
}, option, {
size: size,
isLast: index === array.length - 1,
onChange: handleChange,
activeOpacity
}, restProps));
}));
});
Checkbox.displayName = 'Checkbox';
export { Checkbox };
export { default as CheckboxList } from './CheckboxList';
//# sourceMappingURL=index.js.map