element-plus
Version:
A Component Library for Vue 3
67 lines (62 loc) • 2.34 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../constants/index2.js');
require('../../../utils/index2.js');
require('../../../hooks/index2.js');
var checkbox = require('./checkbox3.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var event = require('../../../constants/event2.js');
var index = require('../../../hooks/use-common-props/index2.js');
var index$1 = require('../../../hooks/use-namespace/index2.js');
var error = require('../../../utils/error2.js');
const _sfc_main = vue.defineComponent({
name: "ElCheckboxGroup",
props: checkbox.useCheckboxGroupProps,
emits: [event.UPDATE_MODEL_EVENT, "change"],
setup(props, { emit, slots }) {
const { elFormItem } = checkbox.useCheckboxGroup();
const { groupId, isLabeledByFormItem } = checkbox.useCheckboxGroupId(props, {
elFormItem
});
const checkboxGroupSize = index.useSize();
const ns = index$1.useNamespace("checkbox");
const changeEvent = (value) => {
emit(event.UPDATE_MODEL_EVENT, value);
vue.nextTick(() => {
emit("change", value);
});
};
const modelValue = vue.computed({
get() {
return props.modelValue;
},
set(val) {
changeEvent(val);
}
});
vue.provide("CheckboxGroup", {
name: "ElCheckboxGroup",
modelValue,
...vue.toRefs(props),
checkboxGroupSize,
changeEvent
});
vue.watch(() => props.modelValue, () => {
var _a;
(_a = elFormItem.validate) == null ? void 0 : _a.call(elFormItem, "change").catch((err) => error.debugWarn(err));
});
return () => {
return vue.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
}, [vue.renderSlot(slots, "default")]);
};
}
});
var CheckboxGroup = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/checkbox/src/checkbox-group.vue"]]);
exports["default"] = CheckboxGroup;
//# sourceMappingURL=checkbox-group2.js.map