@opensig/opendesign
Version:
<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>
59 lines (58 loc) • 1.92 kB
JavaScript
;
const vue = require("vue");
const types = require("./types.js");
const provide$1 = require("./provide.js");
const is = require("../_utils/is.js");
const provide = require("../form/provide.js");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "OCheckboxGroup",
props: types.checkboxGroupProps,
emits: ["update:modelValue", "change"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const realValue = vue.ref(is.isArray(props.modelValue) ? props.modelValue : props.defaultValue);
const formItemInjection = vue.inject(provide.formItemInjectKey, null);
vue.watch(
() => props.modelValue,
(val) => {
if (is.isArray(val)) {
realValue.value = val;
}
}
);
const isMinimum = vue.computed(() => is.isUndefined(props.min) ? false : realValue.value.length <= props.min);
const isMaximum = vue.computed(() => is.isUndefined(props.max) ? false : realValue.value.length >= props.max);
const updateModelValue = (val) => {
realValue.value = val;
emits("update:modelValue", val);
};
const onChange = (val, ev) => {
var _a, _b;
emits("change", val, ev);
(_b = formItemInjection == null ? void 0 : (_a = formItemInjection.fieldHandlers).onChange) == null ? void 0 : _b.call(_a);
};
vue.provide(provide$1.checkboxGroupInjectKey, {
realValue,
disabled: vue.toRef(props, "disabled"),
isMinimum,
isMaximum,
updateModelValue,
onChange
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock(
"div",
{
class: vue.normalizeClass(["o-checkbox-group", `o-checkbox-group-${props.direction}`])
},
[
vue.renderSlot(_ctx.$slots, "default")
],
2
/* CLASS */
);
};
}
});
module.exports = _sfc_main;