UNPKG

various-ui

Version:

This is a test version of the Vue 3 component library

52 lines (48 loc) 1.63 kB
'use strict'; var vue = require('vue'); var index = require('../../default-group/index.js'); const useComposable = (define, emits) => { const checkboxGroup = vue.inject(index.UiCheckboxGroupInjectionKey, void 0); const methods = { switchData: (ev) => { const el = ev.target; emits("update:modelValue", el.checked || false); emits("change", ev); checkboxGroup && checkboxGroup.change(define.value); } }; const computeds = { //* 是否已被选中 checked: vue.computed(() => { if (checkboxGroup == null ? void 0 : checkboxGroup.define.modelValue.includes(define.value)) return true; else return define.modelValue; }), //* 是否禁用 disabled: vue.computed(() => { if (define.disabled) return true; if (checkboxGroup) { if (checkboxGroup.define.modelValue.includes(define.value)) { if (checkboxGroup.define.min && checkboxGroup.define.modelValue.length <= checkboxGroup.define.min) { return true; } } else { if (checkboxGroup.define.max && checkboxGroup.define.modelValue.length >= checkboxGroup.define.max) { return true; } } } else { return false; } }), //* 主体类名 className: vue.computed(() => { const result = []; if (computeds.disabled.value) result.push("ui-disabled-status"); if (computeds.checked.value) result.push("ui-active"); return result.join(" "); }) }; return { methods, computeds }; }; exports.useComposable = useComposable; //# sourceMappingURL=composable.js.map