yanzhen-design-vue
Version:
50 lines (49 loc) • 1.45 kB
JavaScript
import { ref, useAttrs, useSlots, computed, mergeProps, withCtx, h } from "vue";
import { useOptions, useProxyProps, unref } from "@yanzhen-libs/utils-vue";
import { pick, isFunction } from "lodash-es";
import { CheckboxGroup } from "ant-design-vue";
import { AntCheckboxGroup } from "./checkbox-group.mjs";
function useCheckboxGroup(props, emit) {
const _ref = ref(null);
const attrs = useAttrs();
const slots = useSlots();
const optionsRef = useOptions();
const config = computed(() => {
return pick(props, ...Object.keys(AntCheckboxGroup.props));
});
const proxyProps = useProxyProps(config, AntCheckboxGroup.emits, {
emit,
exclude: ["options"],
filter: true
});
const propsRef = computed(() => {
return mergeProps(unref(attrs), unref(proxyProps), {
options: unref(optionsRef)
});
});
return [
{
_ref,
proxyProps,
propsRef,
optionsRef
},
(props2) => {
const children = isFunction(slots == null ? void 0 : slots.default) ? {
...slots,
default: withCtx(() => {
var _a;
return [
(_a = slots == null ? void 0 : slots.default) == null ? void 0 : _a.call(slots, {
options: unref(optionsRef)
})
];
})
} : slots;
return h(CheckboxGroup, mergeProps(attrs, unref(proxyProps), props2, { ref: _ref }), children);
}
];
}
export {
useCheckboxGroup
};