-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
37 lines (30 loc) · 1.16 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { SetupContext, ExtractPropTypes } from "vue-demi";
import { defineComponent } from "vue-demi";
import { basicProps, basicEmits, selectRestEmits, useListeners } from "~/constants";
import { h, dynamicComponent } from "~/utils";
import { useDict } from "~/composables";
export type SelectProps = ExtractPropTypes<typeof selectProps>;
export type SelectEmits = typeof selectEmits;
export type SelectEmitFn = SetupContext<SelectEmits>["emit"];
export type SelectInstance = InstanceType<typeof VDictSelect>;
export const selectProps = basicProps;
export const selectEmits = { ...basicEmits, ...selectRestEmits };
export const VDictSelect = defineComponent({
name: "VDictSelect",
props: selectProps,
emits: selectEmits,
setup(props, { emit, attrs }) {
const ElSelect = dynamicComponent("el-select");
const ElOption = dynamicComponent("el-option");
const { data } = useDict(props.data, props.option, props.cache);
return () =>
h(
ElSelect,
{
props: { ...props, ...attrs },
on: useListeners(emit, selectEmits)
},
() => data.value?.map(item => h(ElOption, { props: item }))
);
}
});