UNPKG

song-ui-u

Version:

vue3 + js的PC前端组件库

116 lines (103 loc) 3.94 kB
import { mergeModels, useModel, ref, provide, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, withCtx, createTextVNode, toDisplayString, renderSlot } from 'vue'; import { useNamespace } from '../../../hook/use-namespace/index.mjs'; import 'song-ui-pro-icon'; import '../../../hook/use-zindex/index.mjs'; import Checkbox from './checkbox.vue.mjs'; import CheckboxGroup from './checkboxGroup.vue.mjs'; import { CHECKBOX_ALL_KEY } from './constant.mjs'; import _export_sfc from '../../../_virtual/_plugin-vue_export-helper.mjs'; const __default__ = { name: "x-checkbox-all" }; const _sfc_main = /*#__PURE__*/Object.assign(__default__, { props: /*#__PURE__*/mergeModels({ size: { type: String, default: "default", }, label: { type: String, default: "全选", }, inline: Boolean, }, { "modelValue": { type: Array, default: () => [] }, "modelModifiers": {}, }), emits: /*#__PURE__*/mergeModels(["change"], ["update:modelValue"]), setup(__props, { expose: __expose, emit: __emit }) { __expose(); const ns = useNamespace("checkbox-all"); // defineModel const allModel = useModel(__props, "modelValue"); const checkAll = ref(false); const indeterminate = ref(false); /** emit */ const emit = __emit; /** props */ const props = __props; const list = ref([]); const setValuesEvent = (val) => list.value.push(val); const changeEvent = async (val) => { allModel.value = val; changeAllEvent(val); emit("change", val); }; const handleAll = (val) => { allModel.value = val ? list.value : []; indeterminate.value = false; }; const changeAllEvent = (val) => { const checkedCount = val.length; checkAll.value = checkedCount === list.value.length; indeterminate.value = checkedCount > 0 && checkedCount !== list.value.length; }; provide(CHECKBOX_ALL_KEY, { ...toRefs(props), allModel, changeEvent, setValuesEvent, }); const __returned__ = { ns, allModel, checkAll, indeterminate, emit, props, list, setValuesEvent, changeEvent, handleAll, changeAllEvent, toRefs, ref, provide, get useNamespace() { return useNamespace }, Checkbox, CheckboxGroup, get CHECKBOX_ALL_KEY() { return CHECKBOX_ALL_KEY } }; Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true }); return __returned__ } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return (openBlock(), createElementBlock("div", { class: normalizeClass([$setup.ns.b(), $setup.ns.is('inline', $props.inline)]) }, [ createElementVNode("div", { class: normalizeClass($setup.ns.e('label')) }, [ createVNode($setup["Checkbox"], { all: "", modelValue: $setup.checkAll, "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => (($setup.checkAll) = $event)), indeterminate: $setup.indeterminate, onChange: $setup.handleAll, size: $props.size }, { default: withCtx(() => [ createTextVNode(toDisplayString($props.label), 1 /* TEXT */) ]), _: 1 /* STABLE */ }, 8 /* PROPS */, ["modelValue", "indeterminate", "size"]) ], 2 /* CLASS */), createElementVNode("div", { class: normalizeClass($setup.ns.e('wrapper')) }, [ createVNode($setup["CheckboxGroup"], { modelValue: $setup.allModel, "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => (($setup.allModel) = $event)), size: $props.size }, { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 /* FORWARDED */ }, 8 /* PROPS */, ["modelValue", "size"]) ], 2 /* CLASS */) ], 2 /* CLASS */)) } var CheckboxAll = /*#__PURE__*/_export_sfc(_sfc_main, [['render',_sfc_render],['__file',"E:\\code\\my-code\\song-ui-ultra\\packages\\components\\checkbox\\src\\checkboxAll.vue"]]); export { CheckboxAll as default }; //# sourceMappingURL=checkboxAll.vue.mjs.map