UNPKG

element-plus

Version:

A Component Library for Vue 3

63 lines (60 loc) 2.29 kB
import { defineComponent, nextTick, computed, provide, toRefs, watch, h, renderSlot } from 'vue'; import '../../../constants/index2.mjs'; import '../../../utils/index2.mjs'; import '../../../hooks/index2.mjs'; import { useCheckboxGroupProps, useCheckboxGroup, useCheckboxGroupId } from './checkbox3.mjs'; import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs'; import { UPDATE_MODEL_EVENT } from '../../../constants/event2.mjs'; import { useSize } from '../../../hooks/use-common-props/index2.mjs'; import { useNamespace } from '../../../hooks/use-namespace/index2.mjs'; import { debugWarn } from '../../../utils/error2.mjs'; const _sfc_main = defineComponent({ name: "ElCheckboxGroup", props: useCheckboxGroupProps, emits: [UPDATE_MODEL_EVENT, "change"], setup(props, { emit, slots }) { const { elFormItem } = useCheckboxGroup(); const { groupId, isLabeledByFormItem } = useCheckboxGroupId(props, { elFormItem }); const checkboxGroupSize = useSize(); const ns = useNamespace("checkbox"); const changeEvent = (value) => { emit(UPDATE_MODEL_EVENT, value); nextTick(() => { emit("change", value); }); }; const modelValue = computed({ get() { return props.modelValue; }, set(val) { changeEvent(val); } }); provide("CheckboxGroup", { name: "ElCheckboxGroup", modelValue, ...toRefs(props), checkboxGroupSize, changeEvent }); watch(() => props.modelValue, () => { var _a; (_a = elFormItem.validate) == null ? void 0 : _a.call(elFormItem, "change").catch((err) => debugWarn(err)); }); return () => { return h(props.tag, { id: groupId.value, class: ns.b("group"), role: "group", "aria-label": !isLabeledByFormItem.value ? props.label || "checkbox-group" : void 0, "aria-labelledby": isLabeledByFormItem.value ? elFormItem.labelId : void 0 }, [renderSlot(slots, "default")]); }; } }); var CheckboxGroup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/checkbox/src/checkbox-group.vue"]]); export { CheckboxGroup as default }; //# sourceMappingURL=checkbox-group2.mjs.map