@td-design/react-native
Version:
react-native UI组件库
75 lines • 2.27 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 from 'react';
import Box from '../box';
import { ONE_PIXEL, px } from '../helpers/normalize';
import CheckboxItem from './CheckboxItem';
import useCheckbox from './useCheckbox';
const CheckboxList = _ref => {
let {
value,
disabledValue,
defaultValue,
containerStyle,
options,
showCheckAll = true,
size = px(24),
onChange,
itemStyle,
activeOpacity = 0.6,
...restProps
} = _ref;
const {
transformedOptions = [],
checkedAllStatus,
handleAllChange,
handleChange
} = useCheckbox({
options,
disabledValue,
defaultValue,
onChange,
value,
showCheckAll
});
return /*#__PURE__*/React.createElement(Box, {
style: containerStyle
}, showCheckAll && /*#__PURE__*/React.createElement(Box, {
key: "checkbox-select-all",
style: itemStyle,
justifyContent: "center",
alignItems: "flex-start",
paddingLeft: "x1",
paddingVertical: 'x2',
borderBottomWidth: ONE_PIXEL,
borderBottomColor: "border"
}, /*#__PURE__*/React.createElement(CheckboxItem, _extends({
mode: "list",
disabled: false,
label: "\u5168\u9009",
value: "checkbox-select-all",
status: checkedAllStatus,
size: size,
onChange: handleAllChange,
activeOpacity
}, restProps))), transformedOptions.map(option => {
return /*#__PURE__*/React.createElement(Box, {
key: option.value,
style: itemStyle,
justifyContent: "center",
alignItems: "flex-start",
paddingLeft: "x1",
paddingVertical: 'x2',
borderBottomWidth: ONE_PIXEL,
borderBottomColor: "border"
}, /*#__PURE__*/React.createElement(CheckboxItem, _extends({
mode: "list"
}, option, {
size: size,
onChange: handleChange,
activeOpacity
}, restProps)));
}));
};
CheckboxList.displayName = 'CheckboxList';
export default CheckboxList;
//# sourceMappingURL=CheckboxList.js.map