yanzhen-design-vue
Version:
70 lines (69 loc) • 2.52 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const utilsVue = require("@yanzhen-libs/utils-vue");
const lodashEs = require("lodash-es");
const _switch = require("./switch.cjs");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{ name: _switch.switchName },
__name: "switch",
props: _switch.switchProps,
emits: _switch.switchEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const { ns } = _switch.switchOptions;
const props = __props;
const emit = __emit;
const props1 = utilsVue.useDynamicProps({ update: true });
const checked = props1.includes("checked") ? utilsVue.useModelValue(props, "checked", emit) : utilsVue.useModelValue(props, null, emit);
const styleRef = vue.computed(() => {
return checked.value ? { backgroundColor: props.activeColor } : {};
});
const config = vue.computed(() => lodashEs.pick(props, ...Object.keys(_switch.AntSwitchProps.props)));
const proxyProps = utilsVue.useProxyProps(config, _switch.AntSwitchProps.emits, {
emit,
exclude: ["checked", "value"],
filter: (key) => {
switch (key) {
case "onUpdate:checked":
case "onUpdate:value":
return false;
}
return true;
}
});
const propsRef = vue.computed(() => {
return vue.mergeProps(
{
style: [utilsVue.unref(styleRef)]
},
utilsVue.unref(proxyProps)
);
});
const slots = vue.useSlots();
const slotKeys = Object.keys(slots);
const _ref = vue.ref();
__expose({
ref: _ref
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Switch), vue.mergeProps({
ref_key: "_ref",
ref: _ref,
checked: vue.unref(checked),
"onUpdate:checked": _cache[0] || (_cache[0] = ($event) => vue.isRef(checked) ? checked.value = $event : null),
class: [vue.unref(ns).b()]
}, propsRef.value), vue.createSlots({ _: 2 }, [
vue.renderList(vue.unref(slotKeys), (slot) => {
return {
name: slot,
fn: vue.withCtx((slotItem) => [
vue.renderSlot(_ctx.$slots, slot, vue.normalizeProps(vue.guardReactiveProps(slotItem)))
])
};
})
]), 1040, ["checked", "class"]);
};
}
});
exports.default = _sfc_main;