forked from howard-tzw/vue3-select
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.d.ts
241 lines (223 loc) · 6.52 KB
/
index.d.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import {
Component,
PropType,
EmitsOptions,
ComputedOptions,
Slots,
SlotProps,
VNodeProps,
} from 'vue'
export type CalculatePositionGeometry = {
width: string
top: string
left: string
}
export type CalculatePositionFunction = (
dropdownList: HTMLUListElement,
component: Component,
geometry: CalculatePositionGeometry,
) => (() => void) | void
export type ClearSearchOnBlurFunctionProperty = {
clearSearchOnSelect: boolean
multiple: boolean
}
export type ClearSearchOnBlurFunction = (
props: ClearSearchOnBlurFunctionProperty,
) => boolean
export type CreateOptionFunction = (
option: string | number,
) => object | string | number
export type DropdownShouldOpenFunction = (component: Component) => boolean
export type FilterFunction = (
options: [],
search: string,
component: Component,
) => boolean
export type FilterByFunction = (
option: object | string,
label: string,
search: string,
component: Component,
) => boolean
export type GetOptionKeyFunction = (option: object | string) => string
export type GetOptionLabelFunction = (option: object | string) => string
export type ReduceFunction = (option: object | string) => object | string
export type ResetOnOptionsChangeFunction = (
newOption: object | string,
oldOption: object | string,
selectedValue: object | string,
) => boolean
export type SelectableFunction = (option?: object | string) => boolean
export type OptionSelectingHandler = (option: string | object) => void
export type OptionSelectedHandler = (option: string | object) => void
export type OptionDeselectingHandler = (option: string | object) => void
export type OptionDeselectedHandler = (option: string | object) => void
export type OptionCreatedHandler = (option: string | object) => void
export type ToggleLoadingFunction = (toggle: boolean | null) => boolean
export type MapKeydownFunction = (map: object, component?: Component) => object
export type SearchHandler = (
search: string,
toggleFunction: ToggleLoadingFunction,
) => void
export interface VSelectProps {
ariaLabel?: PropType<string>
appendToBody?: PropType<boolean>
autocomplete?: PropType<
| 'off'
| 'on'
| 'name'
| 'email'
| 'username'
| 'new-password'
| 'one-time-code'
| 'organization-title'
| 'organization'
| 'country'
| 'country-name'
| 'postal-code'
| 'language'
| 'sex'
| 'url'
>
autoscroll?: PropType<boolean>
autoSelect?: PropType<boolean>
calculatePosition?: PropType<CalculatePositionFunction>
clearable?: PropType<boolean>
clearSearchOnBlur?: PropType<ClearSearchOnBlurFunction>
clearSearchOnSelect?: PropType<boolean>
closeOnSelect?: PropType<boolean>
completeSearch?: PropType<boolean>
components?: PropType<{
Deselect: Component
OpenIndicator: Component
}>
createOption?: PropType<CreateOptionFunction>
deselectFromDropdown?: PropType<boolean>
dir?: PropType<'ltr' | 'rtl' | 'auto'>
disabled?: PropType<boolean>
dropdownShouldOpen?: PropType<DropdownShouldOpenFunction>
filter?: PropType<FilterFunction>
filterable?: PropType<boolean>
filterBy?: PropType<FilterByFunction>
getOptionKey?: PropType<GetOptionKeyFunction>
getOptionLabel?: PropType<GetOptionLabelFunction>
inputId?: PropType<string>
label?: PropType<string>
loading?: PropType<boolean>
mapKeydown?: PropType<MapKeydownFunction>
multiple?: PropType<boolean>
noDrop?: PropType<boolean>
options?: PropType<[]>
optgroups?: PropType<[]>
pasteSeparator?: PropType<string>
pasteTrim?: PropType<boolean>
placeholder?: PropType<string>
pushTags?: PropType<boolean>
reduce?: PropType<ReduceFunction>
resetOnOptionsChange?: PropType<boolean | ResetOnOptionsChangeFunction>
searchable?: PropType<boolean>
selectable?: PropType<SelectableFunction>
tabindex?: PropType<number>
taggable?: PropType<boolean>
transition?: PropType<string>
uid?: PropType<string | number>
value?: PropType<[] | object | string | number | null>
modelValue?: PropType<[] | object | string | null>
}
export interface VSelectEvents {
open: () => void
close: () => void
'option:selecting': OptionSelectingHandler
'option:selected': OptionSelectedHandler
'option:deselecting': OptionDeselectingHandler
'option:deselected': OptionDeselectedHandler
'option:created': OptionCreatedHandler
search: SearchHandler
'search:blur': () => void
'search:focus': () => void
}
export interface FooterSlotProps {
search: string
loading: boolean
searching: boolean
filteredOptions: []
deselect: DeselectFunction
}
export type DeselectFunction = (option: object | number) => void
export interface HeaderSlotProps {
search: string
loading: boolean
searching: boolean
filteredOptions: []
deselect: DeselectFunction
inputId: string
selectedValue: []
open: boolean
}
export interface ListFooterSlotProps {
search: string
loading: boolean
searching: boolean
filteredOptions: []
}
export interface ListHeaderSlotProps {
search: string
loading: boolean
searching: boolean
filteredOptions: []
}
export interface NoOptionsSlotProps {
search: string
loading: boolean
searching: boolean
}
export interface OpenIndicatorSlotProps extends VNodeProps {
attributes: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any
}
}
export interface SearchSlotProps extends VNodeProps {
attributes: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any
}
events: {
compositionstart: () => void
compositionend: () => void
keydown: (event: KeyboardEvent) => void
blur: (event: FocusEvent) => void
focus: (event: FocusEvent) => void
input: (event: InputEvent) => void
}
}
export interface SelectedOptionContainerSlotProps {
option: object | string
deselect: DeselectFunction
disabled: boolean
multiple: boolean
}
export interface SpinnerSlotProps {
loading: boolean
}
export interface VSelectSlots extends Slots {
footer?: SlotProps<FooterSlotProps>
header?: SlotProps<HeaderSlotProps>
'list-footer'?: SlotProps<ListFooterSlotProps>
'list-header'?: SlotProps<ListHeaderSlotProps>
'no-options'?: SlotProps<NoOptionsSlotProps>
'open-indicator'?: SlotProps<OpenIndicatorSlotProps>
option?: SlotProps<object | string>
search?: SlotProps<SearchSlotProps>
'selected-option'?: SlotProps<object | string>
'selected-option-container'?: SlotProps<SelectedOptionContainerSlotProps>
spinner?: SlotProps<SpinnerSlotProps>
}
const vSelect: Component<
VSelectProps,
VSelectEvents,
VSelectSlots,
ComputedOptions,
EmitsOptions
>
export default vSelect