@oiij/naive-ui
Version:
Some Composable Functions And Components for Vue 3
88 lines (86 loc) • 2.55 kB
JavaScript
import SearchInput_default from "../search-input/SearchInput.js";
import "../search-input/index.js";
import { createBlock, defineComponent, h, openBlock, resolveDynamicComponent } from "vue";
import { NButton, NCheckbox, NCheckboxGroup, NColorPicker, NDatePicker, NDivider, NDynamicTags, NInput, NInputNumber, NRadio, NRadioGroup, NRate, NSelect, NSlider, NSwitch, NTimePicker } from "naive-ui";
//#region src/components/preset-input/PresetInput.vue
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "PresetInput",
props: {
value: {},
options: {}
},
emits: ["update:value"],
setup(__props, { emit: __emit }) {
const emit = __emit;
const components = {
"button": NButton,
"color-picker": NColorPicker,
"checkbox": NCheckboxGroup,
"divider": NDivider,
"date-picker": NDatePicker,
"dynamic-tags": NDynamicTags,
"input": NInput,
"input-number": NInputNumber,
"search": SearchInput_default,
"radio": NRadioGroup,
"rate": NRate,
"select": NSelect,
"slider": NSlider,
"switch": NSwitch,
"time-picker": NTimePicker
};
function packageComponent() {
const { type, props, slots } = __props.options ?? {};
if (type === "button") {
const { label, ..._props } = props ?? {};
return h(components[type], { ..._props }, {
default: () => label,
...slots
});
}
if (type === "checkbox") {
const { options, ..._props } = props ?? {};
return h(components[type], {
"value": __props.value,
"onUpdate:value": (val) => {
emit("update:value", val);
},
..._props
}, {
default: () => options?.map((m) => h(NCheckbox, { ...m })),
...slots
});
}
if (type === "divider") {
const { ..._props } = props ?? {};
return h(components[type], { ..._props }, { ...slots });
}
if (type === "radio") {
const { options, ..._props } = props ?? {};
return h(components[type], {
"value": __props.value,
"onUpdate:value": (val) => {
emit("update:value", val);
},
..._props
}, {
default: () => options?.map((m) => h(NRadio, { ...m })),
...slots
});
}
if (type && components[type]) return h(components[type], {
"value": __props.value,
"onUpdate:value": (val) => {
emit("update:value", val);
},
...props
}, { ...slots });
}
return (_ctx, _cache) => {
return openBlock(), createBlock(resolveDynamicComponent(packageComponent()));
};
}
});
var PresetInput_default = _sfc_main;
//#endregion
export { PresetInput_default as default };