1 | import { SetupContext, RenderFunction, ComponentPublicInstance, Ref } from 'vue'
|
2 | import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf, VNodeStyle } from './component'
|
3 | import { VxeGlobalRendererHandles } from './v-x-e-table'
|
4 | import { VxeOptgroupProps } from './optgroup'
|
5 | import { VxeOptionProps, VxeOptionPropTypes } from './option'
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export const VxeSelect: VXEComponent<VxeSelectProps, VxeSelectEventProps, VxeSelectSlots>
|
14 |
|
15 |
|
16 |
|
17 | export const Select: typeof VxeSelect
|
18 |
|
19 | export type VxeSelectInstance = ComponentPublicInstance<VxeSelectProps, VxeSelectConstructor>
|
20 |
|
21 | export interface VxeSelectConstructor extends VxeComponentBase, VxeSelectMethods {
|
22 | props: VxeSelectProps
|
23 | context: SetupContext<VxeSelectEmits>
|
24 | reactData: SelectReactData
|
25 | getRefMaps(): SelectPrivateRef
|
26 | renderVN: RenderFunction
|
27 | }
|
28 |
|
29 | export interface SelectPrivateRef {
|
30 | refElem: Ref<HTMLDivElement>
|
31 | }
|
32 | export interface VxeSelectPrivateRef extends SelectPrivateRef { }
|
33 |
|
34 | export interface SelectReactData {
|
35 | inited: boolean
|
36 | staticOptions: VxeSelectDefines.OptionInfo[]
|
37 | fullGroupList: any[]
|
38 | fullOptionList: any[]
|
39 | visibleGroupList: any[]
|
40 | visibleOptionList: any[]
|
41 | remoteValueList: {
|
42 | key: string
|
43 | result: any
|
44 | }[]
|
45 | panelIndex: number
|
46 | panelStyle: VNodeStyle
|
47 | panelPlacement: any
|
48 | currentOption: any
|
49 | currentValue: any
|
50 | visiblePanel: boolean
|
51 | animatVisible: boolean
|
52 | isActivated: boolean
|
53 | searchValue: string,
|
54 | searchLoading: boolean
|
55 | }
|
56 |
|
57 | export type VxeSelectProps = {
|
58 | size?: VxeSelectPropTypes.Size
|
59 | modelValue?: VxeSelectPropTypes.ModelValue
|
60 | clearable?: VxeSelectPropTypes.Clearable
|
61 | placeholder?: VxeSelectPropTypes.Placeholder
|
62 | loading?: VxeSelectPropTypes.Loading
|
63 | disabled?: VxeSelectPropTypes.Disabled
|
64 | className?: VxeSelectPropTypes.ClassName
|
65 | popupClassName?: VxeSelectPropTypes.PopupClassName
|
66 | multiple?: VxeSelectPropTypes.Multiple
|
67 | multiCharOverflow?: VxeSelectPropTypes.MultiCharOverflow
|
68 | prefixIcon?: VxeSelectPropTypes.PrefixIcon
|
69 | placement?: VxeSelectPropTypes.Placement
|
70 | options?: VxeSelectPropTypes.Options
|
71 | optionProps?: VxeSelectPropTypes.OptionProps
|
72 | optionGroups?: VxeSelectPropTypes.OptionGroups
|
73 | optionGroupProps?: VxeSelectPropTypes.OptionGroupProps
|
74 | optionConfig?: VxeSelectPropTypes.OptionConfig
|
75 | emptyText?: VxeSelectPropTypes.EmptyText
|
76 | filterable?: VxeSelectPropTypes.Filterable
|
77 | filterMethod?: VxeSelectPropTypes.FilterMethod
|
78 | remote?: VxeSelectPropTypes.Remote
|
79 | remoteMethod?: VxeSelectPropTypes.RemoteMethod
|
80 | max?: VxeSelectPropTypes.Max
|
81 | |
82 |
|
83 |
|
84 |
|
85 | optionId?: VxeSelectPropTypes.OptionId
|
86 | |
87 |
|
88 |
|
89 |
|
90 | optionKey?: VxeSelectPropTypes.OptionKey
|
91 | transfer?: VxeSelectPropTypes.Transfer
|
92 | }
|
93 |
|
94 | export namespace VxeSelectPropTypes {
|
95 | export type Size = SizeType
|
96 | export type ModelValue = any
|
97 | export type Clearable = boolean
|
98 | export type Placeholder = string
|
99 | export type Loading = boolean
|
100 | export type Disabled = boolean
|
101 | export type ClassName = string | ((params: { $select: VxeSelectConstructor }) => string)
|
102 | export type PopupClassName = string | ((params: { $select: VxeSelectConstructor }) => string)
|
103 | export type Multiple = boolean
|
104 | export type MultiCharOverflow = number | string
|
105 | export type PrefixIcon = string
|
106 | export type Placement = string
|
107 | export type Options = VxeSelectDefines.SelectOptions[]
|
108 | export type OptionProps = VxeGlobalRendererHandles.RenderOptionProps
|
109 | export type OptionGroups = VxeSelectDefines.SelectOptgroups[]
|
110 | export type OptionGroupProps = VxeGlobalRendererHandles.RenderOptionGroupProps
|
111 | export type Filterable = boolean
|
112 | export type FilterMethod = (params: { group: any, option: any, searchValue: string }) => boolean
|
113 | export type Remote = boolean
|
114 | export type RemoteMethod = (params: { searchValue: string }) => Promise<void> | void
|
115 | export type Max = number | string
|
116 | |
117 |
|
118 |
|
119 | export interface OptionConfig {
|
120 | useKey?: boolean
|
121 | keyField?: string
|
122 | }
|
123 | export type EmptyText = string
|
124 | export type OptionId = string
|
125 | export type OptionKey = boolean
|
126 | export type Transfer = boolean
|
127 | }
|
128 |
|
129 | export interface SelectMethods {
|
130 | dispatchEvent(type: ValueOf<VxeSelectEmits>, params: any, evnt?: Event): void
|
131 | |
132 |
|
133 |
|
134 | isPanelVisible(): boolean
|
135 | |
136 |
|
137 |
|
138 | togglePanel(): Promise<any>
|
139 | |
140 |
|
141 |
|
142 | showPanel(): Promise<any>
|
143 | |
144 |
|
145 |
|
146 | hidePanel(): Promise<any>
|
147 | |
148 |
|
149 |
|
150 | refreshOption(): Promise<any>
|
151 | |
152 |
|
153 |
|
154 | focus(): Promise<any>
|
155 | |
156 |
|
157 |
|
158 | blur(): Promise<any>
|
159 | }
|
160 | export interface VxeSelectMethods extends SelectMethods { }
|
161 |
|
162 | export interface SelectPrivateMethods { }
|
163 | export interface VxeSelectPrivateMethods extends SelectPrivateMethods { }
|
164 |
|
165 | export type VxeSelectEmits = [
|
166 | 'update:modelValue',
|
167 | 'change',
|
168 | 'clear',
|
169 | 'blur',
|
170 | 'focus'
|
171 | ]
|
172 |
|
173 | export namespace VxeSelectDefines {
|
174 | export class OptionInfo {
|
175 | id: string
|
176 |
|
177 | value: any
|
178 | label: VxeOptionPropTypes.Label
|
179 | visible: VxeOptionPropTypes.Visible
|
180 | className: VxeOptionPropTypes.ClassName
|
181 | disabled: VxeOptionPropTypes.Disabled
|
182 |
|
183 | options: OptionInfo[]
|
184 | }
|
185 |
|
186 | export interface SelectOptions extends VxeOptionProps {
|
187 | slots?: VxeOptionPropTypes.Slots
|
188 | }
|
189 |
|
190 | export interface SelectOptgroups extends VxeOptgroupProps {
|
191 | options?: VxeOptionProps[]
|
192 | slots?: VxeOptionPropTypes.Slots
|
193 | }
|
194 |
|
195 | interface SelectEventParams extends VxeEvent {
|
196 | $select: VxeSelectConstructor
|
197 | }
|
198 |
|
199 | export interface ChangeParams {
|
200 | value: any
|
201 | }
|
202 | export interface ChangeEventParams extends SelectEventParams, ChangeParams { }
|
203 |
|
204 | export interface ClearParams {
|
205 | value: any
|
206 | }
|
207 | export interface ClearEventParams extends SelectEventParams, ClearParams { }
|
208 |
|
209 | export interface FocusEventParams extends SelectEventParams { }
|
210 | export interface BlurEventParams extends SelectEventParams { }
|
211 | }
|
212 |
|
213 | export type VxeSelectEventProps = {
|
214 | onChange?: VxeSelectEvents.Change
|
215 | onClear?: VxeSelectEvents.Clear
|
216 | onFocus?: VxeSelectEvents.Focus
|
217 | onBlur?: VxeSelectEvents.Blur
|
218 | }
|
219 |
|
220 | export interface VxeSelectListeners {
|
221 | change?: VxeSelectEvents.Change
|
222 | clear?: VxeSelectEvents.Clear
|
223 | focus?: VxeSelectEvents.Focus
|
224 | blur?: VxeSelectEvents.Blur
|
225 | }
|
226 |
|
227 | export namespace VxeSelectEvents {
|
228 | export type Change = (params: VxeSelectDefines.ChangeEventParams) => void
|
229 | export type Clear = (params: VxeSelectDefines.ClearEventParams) => void
|
230 | export type Focus = (params: VxeSelectDefines.FocusEventParams) => void
|
231 | export type Blur = (params: VxeSelectDefines.BlurEventParams) => void
|
232 | }
|
233 |
|
234 | export interface VxeSelectSlots {
|
235 | |
236 |
|
237 |
|
238 | prefix: (params: {
|
239 | [key: string]: any
|
240 | }) => any
|
241 | |
242 |
|
243 |
|
244 | header: (params: {
|
245 | [key: string]: any
|
246 | }) => any
|
247 | |
248 |
|
249 |
|
250 | option: ((params: {
|
251 | option: any
|
252 | group: any
|
253 | [key: string]: any
|
254 | }) => any) | undefined
|
255 | |
256 |
|
257 |
|
258 | footer: ((params: {
|
259 | [key: string]: any
|
260 | }) => any) | undefined
|
261 |
|
262 | |
263 |
|
264 |
|
265 | [key: string]: ((params: {
|
266 | option: any
|
267 | group: any
|
268 | [key: string]: any
|
269 | }) => any) | undefined
|
270 | }
|