UNPKG

tdesign-react

Version:
93 lines (89 loc) 3.04 kB
/** * tdesign v1.15.1 * (c) 2025 tdesign * @license MIT */ import { _ as _slicedToArray } from '../_chunks/dep-48805ab8.js'; import React from 'react'; import useControlled from '../hooks/useControlled.js'; import { checkTagGroupDefaultProps } from './defaultProps.js'; import useConfig from '../hooks/useConfig.js'; import CheckTag from './CheckTag.js'; import useDefaultProps from '../hooks/useDefaultProps.js'; import '../_chunks/dep-026a4c6b.js'; import 'lodash-es'; import '../_util/noop.js'; import '../config-provider/ConfigContext.js'; import '../_chunks/dep-cb0a3966.js'; import '../_chunks/dep-eca3a3de.js'; import '../_chunks/dep-f97636ce.js'; import '../_chunks/dep-9dbbf468.js'; import 'dayjs'; import '../_chunks/dep-6b660ef0.js'; import 'classnames'; import '../_chunks/dep-dbcf7b24.js'; import './Tag.js'; import 'tdesign-icons-react'; import '../_chunks/dep-3c3d29db.js'; import '../hooks/useGlobalIcon.js'; var CheckTagGroup = function CheckTagGroup(originalProps) { var props = useDefaultProps(originalProps, checkTagGroupDefaultProps); var options = props.options, onChange = props.onChange; var _useConfig = useConfig(), classPrefix = _useConfig.classPrefix; var componentName = "".concat(classPrefix, "-check-tag-group"); var _useControlled = useControlled(props, "value", onChange), _useControlled2 = _slicedToArray(_useControlled, 2), innerValue = _useControlled2[0], setInnerValue = _useControlled2[1]; var onCheckTagChange = function onCheckTagChange(checked, ctx) { var value = ctx.value; if (checked) { if (props.multiple) { setInnerValue(innerValue.concat(value), { e: ctx.e, type: "check", value: value }); } else { setInnerValue([value], { e: ctx.e, type: "check", value: value }); } } else { var newValue = []; if (props.multiple) { newValue = innerValue.filter(function (t) { return t !== value; }); } setInnerValue(newValue, { e: ctx.e, type: "uncheck", value: value }); } }; return /* @__PURE__ */React.createElement("div", { className: componentName }, options === null || options === void 0 ? void 0 : options.map(function (option) { var _ref, _option$content; return /* @__PURE__ */React.createElement(CheckTag, { key: option.value, value: option.value, "data-value": option.value, checkedProps: props.checkedProps, uncheckedProps: props.uncheckedProps, checked: innerValue.includes(option.value), onChange: onCheckTagChange, disabled: option.disabled, size: option.size }, (_ref = (_option$content = option.content) !== null && _option$content !== void 0 ? _option$content : option.children) !== null && _ref !== void 0 ? _ref : option.label); })); }; CheckTagGroup.displayName = "CheckTagGroup"; export { CheckTagGroup as default }; //# sourceMappingURL=CheckTagGroup.js.map