song-ui-u
Version:
vue3 + js的PC前端组件库
118 lines (104 loc) • 3.97 kB
JavaScript
'use strict';
var vue = require('vue');
var index = require('../../../hook/use-namespace/index.cjs');
require('song-ui-pro-icon');
require('../../../hook/use-zindex/index.cjs');
var checkbox = require('./checkbox.vue.cjs');
var checkboxGroup = require('./checkboxGroup.vue.cjs');
var constant = require('./constant.cjs');
var _pluginVue_exportHelper = require('../../../_virtual/_plugin-vue_export-helper.cjs');
const __default__ = { name: "x-checkbox-all" };
const _sfc_main = /*#__PURE__*/Object.assign(__default__, {
props: /*#__PURE__*/vue.mergeModels({
size: {
type: String,
default: "default",
},
label: {
type: String,
default: "全选",
},
inline: Boolean,
}, {
"modelValue": { type: Array, default: () => [] },
"modelModifiers": {},
}),
emits: /*#__PURE__*/vue.mergeModels(["change"], ["update:modelValue"]),
setup(__props, { expose: __expose, emit: __emit }) {
__expose();
const ns = index.useNamespace("checkbox-all");
// defineModel
const allModel = vue.useModel(__props, "modelValue");
const checkAll = vue.ref(false);
const indeterminate = vue.ref(false);
/** emit */
const emit = __emit;
/** props */
const props = __props;
const list = vue.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;
};
vue.provide(constant.CHECKBOX_ALL_KEY, {
...vue.toRefs(props),
allModel,
changeEvent,
setValuesEvent,
});
const __returned__ = { ns, allModel, checkAll, indeterminate, emit, props, list, setValuesEvent, changeEvent, handleAll, changeAllEvent, toRefs: vue.toRefs, ref: vue.ref, provide: vue.provide, get useNamespace() { return index.useNamespace }, Checkbox: checkbox, CheckboxGroup: checkboxGroup, get CHECKBOX_ALL_KEY() { return constant.CHECKBOX_ALL_KEY } };
Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true });
return __returned__
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return (vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([$setup.ns.b(), $setup.ns.is('inline', $props.inline)])
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass($setup.ns.e('label'))
}, [
vue.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: vue.withCtx(() => [
vue.createTextVNode(vue.toDisplayString($props.label), 1 /* TEXT */)
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["modelValue", "indeterminate", "size"])
], 2 /* CLASS */),
vue.createElementVNode("div", {
class: vue.normalizeClass($setup.ns.e('wrapper'))
}, [
vue.createVNode($setup["CheckboxGroup"], {
modelValue: $setup.allModel,
"onUpdate:modelValue": _cache[1] || (_cache[1] = $event => (($setup.allModel) = $event)),
size: $props.size
}, {
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "default")
]),
_: 3 /* FORWARDED */
}, 8 /* PROPS */, ["modelValue", "size"])
], 2 /* CLASS */)
], 2 /* CLASS */))
}
var CheckboxAll = /*#__PURE__*/_pluginVue_exportHelper(_sfc_main, [['render',_sfc_render],['__file',"E:\\code\\my-code\\song-ui-ultra\\packages\\components\\checkbox\\src\\checkboxAll.vue"]]);
module.exports = CheckboxAll;
//# sourceMappingURL=checkboxAll.vue.cjs.map