layui-vue/es/index2.js
2024-09-24 17:04:44 +08:00

47 lines
1.2 KiB
JavaScript

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);
};
}
});
export { _sfc_main as _ };