layui-vue/es/checkboxGroup/index.js
2022-11-14 11:59:26 +08:00

39 lines
1.3 KiB
JavaScript

import { w as withInstall } from "../badge/index2.js";
import { defineComponent, ref, provide, watch, openBlock, createElementBlock, normalizeClass, renderSlot } from "vue";
const __default__ = {
name: "LayCheckboxGroup"
};
const _sfc_main = defineComponent({
...__default__,
props: {
modelValue: { default: () => [] },
disabled: { type: Boolean, default: false }
},
emits: ["update:modelValue", "change"],
setup(__props, { emit }) {
const props = __props;
const modelValue = ref(props.modelValue);
const disabled = ref(props.disabled);
provide("checkboxGroup", {
name: "LayCheckboxGroup",
modelValue,
disabled
});
watch(() => modelValue, (val) => {
emit("change", modelValue.value);
emit("update:modelValue", modelValue.value);
}, { deep: true });
watch(() => props.modelValue, (val) => modelValue.value = val);
watch(() => props.disabled, (val) => disabled.value = val);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
class: normalizeClass(["layui-checkbox-group", { "layui-checkbox-group-disabled": disabled.value }])
}, [
renderSlot(_ctx.$slots, "default")
], 2);
};
}
});
const component = withInstall(_sfc_main);
export { component as default };