UNPKG

tdesign-vue

Version:
128 lines (124 loc) 4.13 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; import { defineComponent, toRefs, computed, h } from '@vue/composition-api'; import { isFunction } from 'lodash-es'; import { usePrefixClass } from '../hooks/useConfig.js'; import props from './check-tag-group-props.js'; import _CheckTag from './check-tag.js'; import { useVModel } from '../hooks/useVModel.js'; import '../config-provider/useConfig.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-ba613a02.js'; import '@babel/runtime/helpers/typeof'; import '../_chunks/dep-fdb1b253.js'; import 'dayjs'; import '../_common/js/global-config/t.js'; import '../_chunks/dep-6a4dc7bb.js'; import '@babel/runtime/helpers/defineProperty'; import './check-tag-props.js'; import './tag.js'; import 'tdesign-icons-vue'; import 'tinycolor2'; import './props.js'; import '../utils/mixins.js'; import 'vue'; import '../config-provider/config-receiver.js'; import '../utils/render-tnode.js'; import '@babel/runtime/helpers/readOnlyError'; import '../utils/event.js'; import '../utils/helper.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import '../_common/js/common.js'; var _CheckTagGroup = defineComponent({ name: "TCheckTagGroup", props: props, setup: function setup(props2, context) { var _toRefs = toRefs(props2), value = _toRefs.value; var componentName = usePrefixClass("check-tag-group"); var checkTagGroupClasses = computed(function () { return [componentName.value]; }); var _useVModel = useVModel(value, props2.defaultValue, props2.onChange), _useVModel2 = _slicedToArray(_useVModel, 2), innerValue = _useVModel2[0], setInnerValue = _useVModel2[1]; var onCheckTagChange = function onCheckTagChange(checked, ctx) { var value2 = ctx.value; if (checked) { if (props2.multiple) { setInnerValue(innerValue.value.concat(value2), { e: ctx.e, type: "check", value: value2 }); } else { setInnerValue([value2], { e: ctx.e, type: "check", value: value2 }); } } else { var newValue = []; if (props2.multiple) { newValue = innerValue.value.filter(function (t) { return t !== value2; }); } setInnerValue(newValue, { e: ctx.e, type: "uncheck", value: value2 }); } }; var getTagContent = function getTagContent(option) { if (context.slots.option) return context.slots.option(option); if (context.slots.label) return context.slots.label(option); if (option.label) { return isFunction(option.label) ? option.label(h) : option.label; } if (option.content && isFunction(option.content)) return option.content(h); if (option["default"] && isFunction(option["default"])) return option["default"](h); return option.value; }; return { innerValue: innerValue, checkTagGroupClasses: checkTagGroupClasses, onCheckTagChange: onCheckTagChange, getTagContent: getTagContent }; }, render: function render() { var _this = this; var h = arguments[0]; return h("div", { "class": this.checkTagGroupClasses }, [(this.options || []).map(function (option) { return h(_CheckTag, { "key": option.value, "attrs": { "value": option.value, "checkedProps": _this.checkedProps, "uncheckedProps": _this.uncheckedProps, "checked": _this.innerValue.includes(option.value), "disabled": option.disabled, "size": option.size, "data-value": option.value }, "on": { "change": _this.onCheckTagChange } }, [_this.getTagContent(option)]); })]); } }); export { _CheckTagGroup as default }; //# sourceMappingURL=check-tag-group.js.map