hongluan-ui
Version:
Hongluan Component Library for Vue 3
100 lines (95 loc) • 3.49 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var lodashUnified = require('lodash-unified');
require('../../../constants/index.js');
require('../../../tokens/index.js');
require('../../../hooks/index.js');
var index$3 = require('../../group/index.js');
require('../../../utils/index.js');
var checkboxGroup = require('./checkbox-group2.js');
var index = require('../../../hooks/use-form-item/index.js');
var index$1 = require('../../../hooks/use-consistent-prop/index.js');
var event = require('../../../constants/event.js');
var checkbox = require('../../../tokens/checkbox.js');
var form = require('../../../tokens/form.js');
var error = require('../../../utils/error.js');
var index$2 = require('../../../hooks/use-namespace/index.js');
const __default__ = vue.defineComponent({
name: "CheckboxGroup"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: checkboxGroup.checkboxGroupProps,
emits: checkboxGroup.checkboxGroupEmits,
setup(__props, { emit }) {
const props = __props;
const { formItem } = index.useFormItem();
const { inputId: groupId, isLabeledByFormItem } = index.useFormItemInputId(props, {
formItemContext: formItem
});
const { size: checkboxGroupSize, disabled: checkboxGroupDisabled, fill: checkboxGroupFill } = index$1.useConsistentProp();
const changeEvent = async (value) => {
emit(event.UPDATE_MODEL_EVENT, value);
await vue.nextTick();
emit("change", value);
};
const modelValue = vue.computed({
get() {
return props.modelValue;
},
set(val) {
changeEvent(val);
}
});
vue.provide(checkbox.checkboxGroupContextKey, {
...lodashUnified.pick(vue.toRefs(props), [
"min",
"max",
"validateEvent",
"round",
"type",
"custom"
]),
size: checkboxGroupSize,
disabled: checkboxGroupDisabled,
fill: checkboxGroupFill,
modelValue,
changeEvent
});
vue.watch(() => props.modelValue, () => {
var _a;
if (props.validateEvent) {
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, form.FormItemEvents.change).catch((err) => error.debugWarn(err));
}
});
const { namespace } = index$2.useNamespace("checkbox-group");
return (_ctx, _cache) => {
var _a;
return vue.openBlock(), vue.createBlock(vue.unref(index$3.HlGroup), {
id: vue.unref(groupId),
class: vue.normalizeClass([vue.unref(namespace)]),
dir: _ctx.dir,
merge: _ctx.merge,
indent: _ctx.indent,
gap: _ctx.gap,
"gap-x": _ctx.gapX,
"gap-y": _ctx.gapY,
full: _ctx.full,
wrap: _ctx.wrap,
align: _ctx.align,
block: _ctx.block,
role: "group",
"aria-label": !vue.unref(isLabeledByFormItem) ? _ctx.ariaLabel || _ctx.label || "checkbox-group" : void 0,
"aria-labelledby": vue.unref(isLabeledByFormItem) ? (_a = vue.unref(formItem)) == null ? void 0 : _a.labelId : void 0
}, {
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["id", "class", "dir", "merge", "indent", "gap", "gap-x", "gap-y", "full", "wrap", "align", "block", "aria-label", "aria-labelledby"]);
};
}
});
exports["default"] = _sfc_main;
//# sourceMappingURL=checkbox-group.js.map