@colisweb/rescript-toolkit 2.71.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/cache/@colisweb-restorative-npm-1.0.0-5eac899f0c-6e80ecc641.zip +0 -0
- package/.yarn/cache/@rescript-react-npm-0.11.0-687f8fa3b5-c399d114f7.zip +0 -0
- package/.yarn/cache/{rescript-npm-10.0.1-c064c63c72-59ae153c7f.zip → rescript-npm-10.1.2-eb312a329e-e70ae09da1.zip} +0 -0
- package/.yarn/install-state.gz +0 -0
- package/bsconfig.json +2 -2
- package/locale/fr.json +5 -0
- package/package.json +4 -5
- package/playground/PlaygroundApp.res +12 -0
- package/playground/PlaygroundBindings.res +106 -0
- package/playground/PlaygroundHooks.res +4 -4
- package/playground/PlaygroundRouter.res +18 -0
- package/playground/bindings/Playground_Bindings_Reach.res +143 -0
- package/playground/components/Playground_Form.res +56 -3
- package/playground/components/Playground_Modal.res +20 -5
- package/playground/components/Playground_Select.res +14 -4
- package/playground/hooks/{Playground_Clipboard.res → Playground_Hooks_Clipboard.res} +1 -1
- package/playground/hooks/{Playground_Disclosure.res → Playground_Hooks_Disclosure.res} +1 -1
- package/playground/hooks/{Playground_LazyLoad.res → Playground_Hooks_LazyLoad.res} +1 -1
- package/playground/hooks/{Playground_MediaQueries.res → Playground_Hooks_MediaQueries.res} +1 -1
- package/src/decoders/Toolkit__Decoders.res +1 -1
- package/src/form/Reform.res +8 -36
- package/src/form/Toolkit__Form.res +114 -55
- package/src/hooks/Toolkit__Hooks.res +1 -1
- package/src/intl/Toolkit__Intl.res +1 -1
- package/src/intl/Toolkit__Intl.resi +1 -1
- package/src/logger/Toolkit__NativeLogger.res +1 -1
- package/src/router/Toolkit__Router.res +0 -6
- package/src/ui/Toolkit__Ui.res +0 -2
- package/src/ui/Toolkit__Ui_Dropdown.res +13 -7
- package/src/ui/Toolkit__Ui_Dropdown.resi +2 -0
- package/src/ui/Toolkit__Ui_Layout.res +1 -6
- package/src/ui/Toolkit__Ui_MultiSelect.res +10 -4
- package/src/ui/Toolkit__Ui_MultiSelect.resi +5 -1
- package/src/ui/Toolkit__Ui_NativeDatePicker.res +2 -2
- package/src/ui/Toolkit__Ui_Select.res +22 -5
- package/src/ui/Toolkit__Ui_Select.resi +13 -2
- package/src/ui/Toolkit__Ui_SelectPolyvariant.res +45 -0
- package/src/ui/Toolkit__Ui_Table.res +11 -6
- package/src/ui/Toolkit__Ui_TextInput.res +2 -2
- package/src/ui/Toolkit__Ui_WeekDateFilter.res +16 -16
- package/src/utils/Toolkit__Utils_UnitMeasure.res +4 -4
- package/src/vendors/{BsCopyToClipboard.res → CopyToClipboard.res} +0 -0
- package/src/vendors/{BsDateFns.res → DateFns.res} +0 -0
- package/src/vendors/{BsJsCookie.res → JsCookie.res} +0 -0
- package/src/vendors/{BsReactDayPicker.res → ReactDayPicker.res} +0 -1
- package/src/vendors/{BsReactGoogleMaps.res → ReactGoogleMaps.res} +0 -0
- package/src/vendors/ReactIcons.res +5 -0
- package/src/vendors/{BsReactSelect.res → ReactSelect.res} +58 -58
- package/src/vendors/{BsSentryReactNative.res → SentryReactNative.res} +0 -0
- package/src/vendors/reach-ui/ReachUi_Accordion.res +12 -14
- package/src/vendors/reach-ui/ReachUi_AlertDialog.res +8 -34
- package/src/vendors/reach-ui/ReachUi_Dialog.res +7 -10
- package/src/vendors/reach-ui/ReachUi_Listbox.res +8 -9
- package/src/vendors/reach-ui/ReachUi_MenuButton.res +7 -30
- package/src/vendors/reach-ui/ReachUi_Popover.res +0 -6
- package/src/vendors/reach-ui/ReachUi_Tabs.res +18 -27
- package/.yarn/cache/@colisweb-restorative-npm-0.5.1-2ffe068813-cd8332a7eb.zip +0 -0
- package/.yarn/cache/@rescript-react-npm-0.10.3-26bd5d697f-8561282f78.zip +0 -0
- package/.yarn/cache/compute-scroll-into-view-npm-1.0.16-a8a68c1929-4334db6397.zip +0 -0
- package/.yarn/cache/downshift-npm-5.2.5-14bb33ffd8-498b4764a8.zip +0 -0
- package/src/mock/MockOverlay.resi +0 -4
- package/src/ui/Toolkit__Ui_Listbox.res +0 -123
- package/src/ui/Toolkit__Ui_ListboxInput.res +0 -673
- package/src/vendors/BsAnalytics.res +0 -34
- package/src/vendors/BsDownshift.res +0 -596
|
@@ -1,596 +0,0 @@
|
|
|
1
|
-
type t
|
|
2
|
-
|
|
3
|
-
external castEvent: 'event => ReactEvent.Synthetic.t = "%identity"
|
|
4
|
-
|
|
5
|
-
let preventDownshiftDefault: ReactEvent.Synthetic.t => unit = %raw(`
|
|
6
|
-
function (event) {
|
|
7
|
-
event.nativeEvent.preventDownshiftDefault = true;
|
|
8
|
-
}
|
|
9
|
-
`)
|
|
10
|
-
|
|
11
|
-
module Select = {
|
|
12
|
-
type state<'item> = {
|
|
13
|
-
isOpen: bool,
|
|
14
|
-
selectedItem: Js.Nullable.t<'item>,
|
|
15
|
-
inputValue: string,
|
|
16
|
-
highlightedIndex: int,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type actionString
|
|
20
|
-
|
|
21
|
-
type actionAndChanges<'item> = {
|
|
22
|
-
@as("type")
|
|
23
|
-
action: actionString,
|
|
24
|
-
changes: state<'item>,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type selectedItem<'item> = {
|
|
28
|
-
@as("type")
|
|
29
|
-
action: actionString,
|
|
30
|
-
selectedItem: 'item,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type selectOptions
|
|
34
|
-
|
|
35
|
-
@obj
|
|
36
|
-
external // See more at https://github.com/downshift-js/downshift/tree/master/src/hooks/useSelect
|
|
37
|
-
selectOptions: (
|
|
38
|
-
~items: array<'item>,
|
|
39
|
-
~itemToString: Js.Nullable.t<'item> => string,
|
|
40
|
-
~stateReducer: (state<'item>, actionAndChanges<'item>) => state<'item>=?,
|
|
41
|
-
~onStateChange: actionAndChanges<'item> => unit=?,
|
|
42
|
-
~onSelectedItemChange: selectedItem<'item> => unit=?,
|
|
43
|
-
~defaultIsOpen: bool=?,
|
|
44
|
-
~isOpen: bool=?,
|
|
45
|
-
~initialHighlightedIndex: int=?,
|
|
46
|
-
~defaultHighlightedIndex: int=?,
|
|
47
|
-
~initialSelectedItem: Js.Nullable.t<'item>=?,
|
|
48
|
-
~defaultSelectedItem: Js.Nullable.t<'item>=?,
|
|
49
|
-
~selectedItem: Js.Nullable.t<'item>=?,
|
|
50
|
-
unit,
|
|
51
|
-
) => selectOptions = ""
|
|
52
|
-
|
|
53
|
-
type toggleButtonPropsOptions
|
|
54
|
-
@obj
|
|
55
|
-
external toggleButtonPropsOptions: (
|
|
56
|
-
~id: string=?,
|
|
57
|
-
~onClick: ReactEvent.Mouse.t => unit=?,
|
|
58
|
-
~onKeyDown: ReactEvent.Keyboard.t => unit=?,
|
|
59
|
-
~disabled: bool=?,
|
|
60
|
-
~ref: option<ReactDOM.domRef>=?,
|
|
61
|
-
unit,
|
|
62
|
-
) => toggleButtonPropsOptions = ""
|
|
63
|
-
|
|
64
|
-
type toggleButtonProps = {
|
|
65
|
-
ref: ReactDOM.Ref.callbackDomRef,
|
|
66
|
-
id: string,
|
|
67
|
-
onClick: ReactEvent.Mouse.t => unit,
|
|
68
|
-
disabled: bool,
|
|
69
|
-
@as("aria-labelledby")
|
|
70
|
-
ariaLabelledby: string,
|
|
71
|
-
@as("aria-haspopup")
|
|
72
|
-
ariaHaspopup: string,
|
|
73
|
-
@as("aria-expanded")
|
|
74
|
-
ariaExpanded: bool,
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
type itemPropsOptions
|
|
78
|
-
@obj
|
|
79
|
-
external itemPropsOptions: (
|
|
80
|
-
~item: 'item,
|
|
81
|
-
~index: int,
|
|
82
|
-
~onClick: ReactEvent.Mouse.t => unit=?,
|
|
83
|
-
~onMouseMove: ReactEvent.Mouse.t => unit=?,
|
|
84
|
-
~disabled: bool=?,
|
|
85
|
-
~id: string=?,
|
|
86
|
-
unit,
|
|
87
|
-
) => itemPropsOptions = ""
|
|
88
|
-
|
|
89
|
-
type itemProps = {
|
|
90
|
-
id: string,
|
|
91
|
-
role: string,
|
|
92
|
-
disabled: bool,
|
|
93
|
-
@as("aria-selected")
|
|
94
|
-
ariaSelected: string,
|
|
95
|
-
onClick: ReactEvent.Mouse.t => unit,
|
|
96
|
-
onMouseMove: ReactEvent.Mouse.t => unit,
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
type labelPropsOptions
|
|
100
|
-
@obj
|
|
101
|
-
external labelPropsOptions: (~id: string=?, ~htmlFor: string=?, unit) => labelPropsOptions = ""
|
|
102
|
-
type labelProps = {
|
|
103
|
-
id: string,
|
|
104
|
-
htmlFor: string,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
type menuPropsOptions
|
|
108
|
-
|
|
109
|
-
@obj
|
|
110
|
-
external menuPropsOptions: (
|
|
111
|
-
~onMouseLeave: ReactEvent.Mouse.t => unit=?,
|
|
112
|
-
~onKeyDown: ReactEvent.Keyboard.t => unit=?,
|
|
113
|
-
~onBlur: ReactEvent.Focus.t => unit=?,
|
|
114
|
-
~ref: option<ReactDOM.domRef>=?,
|
|
115
|
-
~id: string=?,
|
|
116
|
-
unit,
|
|
117
|
-
) => menuPropsOptions = ""
|
|
118
|
-
|
|
119
|
-
type menuProps = {
|
|
120
|
-
ref: ReactDOM.Ref.callbackDomRef,
|
|
121
|
-
id: string,
|
|
122
|
-
role: string,
|
|
123
|
-
tabIndex: int,
|
|
124
|
-
@as("aria-labelledby")
|
|
125
|
-
ariaLabelledby: string,
|
|
126
|
-
@as("aria-activedescendant")
|
|
127
|
-
ariaActivedescendant: string,
|
|
128
|
-
onKeyDown: ReactEvent.Keyboard.t => unit,
|
|
129
|
-
onBlur: ReactEvent.Focus.t => unit,
|
|
130
|
-
onMouseLeave: ReactEvent.Mouse.t => unit,
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
type t<'item> = {
|
|
134
|
-
// prop getters.
|
|
135
|
-
getToggleButtonProps: toggleButtonPropsOptions => toggleButtonProps,
|
|
136
|
-
getLabelProps: labelPropsOptions => labelProps,
|
|
137
|
-
getMenuProps: menuPropsOptions => menuProps,
|
|
138
|
-
getItemProps: itemPropsOptions => itemProps,
|
|
139
|
-
// actions.
|
|
140
|
-
toggleMenu: unit => unit,
|
|
141
|
-
openMenu: unit => unit,
|
|
142
|
-
closeMenu: unit => unit,
|
|
143
|
-
setHighlightedIndex: int => unit,
|
|
144
|
-
setInputValue: string => unit,
|
|
145
|
-
selectItem: Js.Nullable.t<'item> => unit,
|
|
146
|
-
reset: unit => unit,
|
|
147
|
-
// state.
|
|
148
|
-
highlightedIndex: int,
|
|
149
|
-
isOpen: bool,
|
|
150
|
-
selectedItem: Js.Nullable.t<'item>,
|
|
151
|
-
inputValue: string,
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
@module("downshift")
|
|
155
|
-
external useSelect: selectOptions => t<'item> = "useSelect"
|
|
156
|
-
|
|
157
|
-
/* State changes and types */
|
|
158
|
-
|
|
159
|
-
type instance
|
|
160
|
-
@module("downshift") external useSelectIntance: instance = "useSelect"
|
|
161
|
-
|
|
162
|
-
@get @scope("stateChangeTypes")
|
|
163
|
-
external menuKeyDownArrowDown: instance => actionString = "MenuKeyDownArrowDown"
|
|
164
|
-
|
|
165
|
-
@get @scope("stateChangeTypes")
|
|
166
|
-
external menuKeyDownArrowUp: instance => actionString = "MenuKeyDownArrowUp"
|
|
167
|
-
|
|
168
|
-
@get @scope("stateChangeTypes")
|
|
169
|
-
external menuKeyDownEscape: instance => actionString = "MenuKeyDownEscape"
|
|
170
|
-
|
|
171
|
-
@get @scope("stateChangeTypes")
|
|
172
|
-
external menuKeyDownHome: instance => actionString = "MenuKeyDownHome"
|
|
173
|
-
|
|
174
|
-
@get @scope("stateChangeTypes")
|
|
175
|
-
external menuKeyDownEnd: instance => actionString = "MenuKeyDownEnd"
|
|
176
|
-
|
|
177
|
-
@get @scope("stateChangeTypes")
|
|
178
|
-
external menuKeyDownEnter: instance => actionString = "MenuKeyDownEnter"
|
|
179
|
-
|
|
180
|
-
@get @scope("stateChangeTypes")
|
|
181
|
-
external menuKeyDownSpaceButton: instance => actionString = "MenuKeyDownSpaceButton"
|
|
182
|
-
|
|
183
|
-
@get @scope("stateChangeTypes")
|
|
184
|
-
external menuKeyDownCharacter: instance => actionString = "MenuKeyDownCharacter"
|
|
185
|
-
|
|
186
|
-
@get @scope("stateChangeTypes")
|
|
187
|
-
external menuBlur: instance => actionString = "MenuBlur"
|
|
188
|
-
|
|
189
|
-
@get @scope("stateChangeTypes")
|
|
190
|
-
external menuMouseLeave: instance => actionString = "MenuMouseLeave"
|
|
191
|
-
|
|
192
|
-
@get @scope("stateChangeTypes")
|
|
193
|
-
external itemMouseMove: instance => actionString = "ItemMouseMove"
|
|
194
|
-
|
|
195
|
-
@get @scope("stateChangeTypes")
|
|
196
|
-
external itemClick: instance => actionString = "ItemClick"
|
|
197
|
-
|
|
198
|
-
@get @scope("stateChangeTypes")
|
|
199
|
-
external toggleButtonClick: instance => actionString = "ToggleButtonClick"
|
|
200
|
-
|
|
201
|
-
@get @scope("stateChangeTypes")
|
|
202
|
-
external toggleButtonKeyDownArrowDown: instance => actionString = "ToggleButtonKeyDownArrowDown"
|
|
203
|
-
|
|
204
|
-
@get @scope("stateChangeTypes")
|
|
205
|
-
external toggleButtonKeyDownArrowUp: instance => actionString = "ToggleButtonKeyDownArrowUp"
|
|
206
|
-
|
|
207
|
-
@get @scope("stateChangeTypes")
|
|
208
|
-
external toggleButtonKeyDownCharacter: instance => actionString = "ToggleButtonKeyDownCharacter"
|
|
209
|
-
|
|
210
|
-
@get @scope("stateChangeTypes")
|
|
211
|
-
external functionToggleMenu: instance => actionString = "FunctionToggleMenu"
|
|
212
|
-
|
|
213
|
-
@get @scope("stateChangeTypes")
|
|
214
|
-
external functionOpenMenu: instance => actionString = "FunctionOpenMenu"
|
|
215
|
-
|
|
216
|
-
@get @scope("stateChangeTypes")
|
|
217
|
-
external functionCloseMenu: instance => actionString = "FunctionCloseMenu"
|
|
218
|
-
|
|
219
|
-
@get @scope("stateChangeTypes")
|
|
220
|
-
external functionSetHighlightedIndex: instance => actionString = "FunctionSetHighlightedIndex"
|
|
221
|
-
|
|
222
|
-
@get @scope("stateChangeTypes")
|
|
223
|
-
external functionSelectItem: instance => actionString = "FunctionSelectItem"
|
|
224
|
-
|
|
225
|
-
@get @scope("stateChangeTypes")
|
|
226
|
-
external functionSetInputValue: instance => actionString = "FunctionSetInputValue"
|
|
227
|
-
|
|
228
|
-
@get @scope("stateChangeTypes")
|
|
229
|
-
external functionReset: instance => actionString = "FunctionReset"
|
|
230
|
-
|
|
231
|
-
type action =
|
|
232
|
-
| MenuKeyDownArrowDown
|
|
233
|
-
| MenuKeyDownArrowUp
|
|
234
|
-
| MenuKeyDownEscape
|
|
235
|
-
| MenuKeyDownHome
|
|
236
|
-
| MenuKeyDownEnd
|
|
237
|
-
| MenuKeyDownEnter
|
|
238
|
-
| MenuKeyDownSpaceButton
|
|
239
|
-
| MenuKeyDownCharacter
|
|
240
|
-
| MenuBlur
|
|
241
|
-
| MenuMouseLeave
|
|
242
|
-
| ItemMouseMove
|
|
243
|
-
| ItemClick
|
|
244
|
-
| ToggleButtonClick
|
|
245
|
-
| ToggleButtonKeyDownArrowDown
|
|
246
|
-
| ToggleButtonKeyDownArrowUp
|
|
247
|
-
| ToggleButtonKeyDownCharacter
|
|
248
|
-
| FunctionToggleMenu
|
|
249
|
-
| FunctionOpenMenu
|
|
250
|
-
| FunctionCloseMenu
|
|
251
|
-
| FunctionSetHighlightedIndex
|
|
252
|
-
| FunctionSelectItem
|
|
253
|
-
| FunctionSetInputValue
|
|
254
|
-
| FunctionReset
|
|
255
|
-
|
|
256
|
-
let action = actionString =>
|
|
257
|
-
switch actionString {
|
|
258
|
-
| action if action === useSelectIntance->menuKeyDownArrowDown => MenuKeyDownArrowDown
|
|
259
|
-
| action if action === useSelectIntance->menuKeyDownArrowUp => MenuKeyDownArrowUp
|
|
260
|
-
| action if action === useSelectIntance->menuKeyDownEscape => MenuKeyDownEscape
|
|
261
|
-
| action if action === useSelectIntance->menuKeyDownHome => MenuKeyDownHome
|
|
262
|
-
| action if action === useSelectIntance->menuKeyDownEnd => MenuKeyDownEnd
|
|
263
|
-
| action if action === useSelectIntance->menuKeyDownEnter => MenuKeyDownEnter
|
|
264
|
-
| action if action === useSelectIntance->menuKeyDownSpaceButton => MenuKeyDownSpaceButton
|
|
265
|
-
| action if action === useSelectIntance->menuKeyDownCharacter => MenuKeyDownCharacter
|
|
266
|
-
| action if action === useSelectIntance->menuBlur => MenuBlur
|
|
267
|
-
| action if action === useSelectIntance->menuMouseLeave => MenuMouseLeave
|
|
268
|
-
| action if action === useSelectIntance->itemMouseMove => ItemMouseMove
|
|
269
|
-
| action if action === useSelectIntance->itemClick => ItemClick
|
|
270
|
-
| action if action === useSelectIntance->toggleButtonClick => ToggleButtonClick
|
|
271
|
-
| action if action === useSelectIntance->toggleButtonKeyDownArrowDown =>
|
|
272
|
-
ToggleButtonKeyDownArrowDown
|
|
273
|
-
| action if action === useSelectIntance->toggleButtonKeyDownArrowUp =>
|
|
274
|
-
ToggleButtonKeyDownArrowUp
|
|
275
|
-
| action if action === useSelectIntance->toggleButtonKeyDownCharacter =>
|
|
276
|
-
ToggleButtonKeyDownCharacter
|
|
277
|
-
| action if action === useSelectIntance->functionToggleMenu => FunctionToggleMenu
|
|
278
|
-
| action if action === useSelectIntance->functionOpenMenu => FunctionOpenMenu
|
|
279
|
-
| action if action === useSelectIntance->functionCloseMenu => FunctionCloseMenu
|
|
280
|
-
| action if action === useSelectIntance->functionSetHighlightedIndex =>
|
|
281
|
-
FunctionSetHighlightedIndex
|
|
282
|
-
| action if action === useSelectIntance->functionSelectItem => FunctionSelectItem
|
|
283
|
-
| action if action === useSelectIntance->functionSetInputValue => FunctionSetInputValue
|
|
284
|
-
| action if action === useSelectIntance->functionReset => FunctionReset
|
|
285
|
-
| _ => Js.Exn.raiseError("unhandled BsDownShift actionString")
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
module Combobox = {
|
|
290
|
-
type state<'item> = {
|
|
291
|
-
isOpen: bool,
|
|
292
|
-
selectedItem: Js.Nullable.t<'item>,
|
|
293
|
-
inputValue: string,
|
|
294
|
-
highlightedIndex: int,
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
type actionString
|
|
298
|
-
|
|
299
|
-
type actionAndChanges<'item> = {
|
|
300
|
-
@as("type")
|
|
301
|
-
action: actionString,
|
|
302
|
-
changes: state<'item>,
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
type selectedItem<'item> = {
|
|
306
|
-
@as("type")
|
|
307
|
-
action: actionString,
|
|
308
|
-
selectedItem: 'item,
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
type comboboxOptions
|
|
312
|
-
|
|
313
|
-
@obj
|
|
314
|
-
external // See more at https://github.com/downshift-js/downshift/tree/master/src/hooks/useCombobox
|
|
315
|
-
comboboxOptions: (
|
|
316
|
-
~items: array<'item>,
|
|
317
|
-
~itemToString: Js.Nullable.t<'item> => string,
|
|
318
|
-
~stateReducer: (state<'item>, actionAndChanges<'item>) => state<'item>=?,
|
|
319
|
-
~onStateChange: actionAndChanges<'item> => unit=?,
|
|
320
|
-
~onSelectedItemChange: selectedItem<'item> => unit=?,
|
|
321
|
-
~defaultIsOpen: bool=?,
|
|
322
|
-
~isOpen: bool=?,
|
|
323
|
-
~initialInputValue: string=?,
|
|
324
|
-
~inputValue: string=?,
|
|
325
|
-
~initialSelectedItem: 'item=?,
|
|
326
|
-
~highlightedIndex: int=?,
|
|
327
|
-
~initialHighlightedIndex: int=?,
|
|
328
|
-
~defaultHighlightedIndex: int=?,
|
|
329
|
-
~initialSelectedItem: Js.Nullable.t<'item>=?,
|
|
330
|
-
~defaultSelectedItem: Js.Nullable.t<'item>=?,
|
|
331
|
-
~selectedItem: Js.Null.t<'item>=?,
|
|
332
|
-
unit,
|
|
333
|
-
) => comboboxOptions = ""
|
|
334
|
-
|
|
335
|
-
type comboboxPropsOptions
|
|
336
|
-
@obj
|
|
337
|
-
external comboboxPropsOptions: (
|
|
338
|
-
~id: string=?,
|
|
339
|
-
~ref: option<ReactDOM.domRef>=?,
|
|
340
|
-
unit,
|
|
341
|
-
) => comboboxPropsOptions = ""
|
|
342
|
-
|
|
343
|
-
type comboboxProps = {
|
|
344
|
-
ref: ReactDOM.Ref.callbackDomRef,
|
|
345
|
-
role: string,
|
|
346
|
-
@as("aria-haspopup")
|
|
347
|
-
ariaHaspopup: string,
|
|
348
|
-
@as("aria-expanded")
|
|
349
|
-
ariaExpanded: bool,
|
|
350
|
-
@as("aria-owns")
|
|
351
|
-
ariaOwns: string,
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
type toggleButtonPropsOptions
|
|
355
|
-
@obj
|
|
356
|
-
external toggleButtonPropsOptions: (
|
|
357
|
-
~id: string=?,
|
|
358
|
-
~onClick: ReactEvent.Mouse.t => unit=?,
|
|
359
|
-
~disabled: bool=?,
|
|
360
|
-
~ref: option<ReactDOM.domRef>=?,
|
|
361
|
-
unit,
|
|
362
|
-
) => toggleButtonPropsOptions = ""
|
|
363
|
-
|
|
364
|
-
type toggleButtonProps = {
|
|
365
|
-
ref: ReactDOM.Ref.callbackDomRef,
|
|
366
|
-
id: string,
|
|
367
|
-
onClick: ReactEvent.Mouse.t => unit,
|
|
368
|
-
disabled: bool,
|
|
369
|
-
tabIndex: int,
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
type itemPropsOptions
|
|
373
|
-
@obj
|
|
374
|
-
external itemPropsOptions: (
|
|
375
|
-
~item: 'item,
|
|
376
|
-
~index: int,
|
|
377
|
-
~id: string=?,
|
|
378
|
-
~onClick: ReactEvent.Mouse.t => unit=?,
|
|
379
|
-
~onMouseMove: ReactEvent.Mouse.t => unit=?,
|
|
380
|
-
~disabled: bool=?,
|
|
381
|
-
~ref: option<ReactDOM.domRef>=?,
|
|
382
|
-
unit,
|
|
383
|
-
) => itemPropsOptions = ""
|
|
384
|
-
|
|
385
|
-
type itemProps = {
|
|
386
|
-
ref: ReactDOM.Ref.callbackDomRef,
|
|
387
|
-
id: string,
|
|
388
|
-
role: string,
|
|
389
|
-
disabled: bool,
|
|
390
|
-
@as("aria-selected")
|
|
391
|
-
ariaSelected: string,
|
|
392
|
-
onClick: ReactEvent.Mouse.t => unit,
|
|
393
|
-
onMouseMove: ReactEvent.Mouse.t => unit,
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
type labelPropsOptions
|
|
397
|
-
@obj
|
|
398
|
-
external labelPropsOptions: (~id: string=?, ~htmlFor: string=?, unit) => labelPropsOptions = ""
|
|
399
|
-
|
|
400
|
-
type labelProps = {
|
|
401
|
-
id: string,
|
|
402
|
-
htmlFor: string,
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
type menuPropsOptions
|
|
406
|
-
|
|
407
|
-
@obj
|
|
408
|
-
external menuPropsOptions: (
|
|
409
|
-
~onMouseLeave: ReactEvent.Mouse.t => unit=?,
|
|
410
|
-
~ref: option<ReactDOM.domRef>=?,
|
|
411
|
-
~id: string=?,
|
|
412
|
-
unit,
|
|
413
|
-
) => menuPropsOptions = ""
|
|
414
|
-
|
|
415
|
-
type menuProps = {
|
|
416
|
-
ref: ReactDOM.Ref.callbackDomRef,
|
|
417
|
-
id: string,
|
|
418
|
-
role: string,
|
|
419
|
-
@as("aria-labelledby")
|
|
420
|
-
ariaLabelledby: string,
|
|
421
|
-
onMouseLeave: ReactEvent.Mouse.t => unit,
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
type inputPropsOptions
|
|
425
|
-
@obj
|
|
426
|
-
external inputPropsOptions: (
|
|
427
|
-
~ref: option<ReactDOM.domRef>=?,
|
|
428
|
-
~id: string=?,
|
|
429
|
-
~onBlur: ReactEvent.Focus.t => unit=?,
|
|
430
|
-
~onKeyDown: ReactEvent.Keyboard.t => unit=?,
|
|
431
|
-
~onChange: ReactEvent.Form.t => unit=?,
|
|
432
|
-
~disabled: bool=?,
|
|
433
|
-
unit,
|
|
434
|
-
) => inputPropsOptions = ""
|
|
435
|
-
|
|
436
|
-
type inputProps = {
|
|
437
|
-
ref: ReactDOM.Ref.callbackDomRef,
|
|
438
|
-
id: string,
|
|
439
|
-
@as("aria-controls")
|
|
440
|
-
ariaControls: string,
|
|
441
|
-
@as("aria-activedescendant")
|
|
442
|
-
ariaActivedescendant: string,
|
|
443
|
-
@as("aria-labelledby")
|
|
444
|
-
ariaLabelledby: string,
|
|
445
|
-
@as("aria-autocomplete")
|
|
446
|
-
ariaAutocomplete: string,
|
|
447
|
-
disabled: bool,
|
|
448
|
-
value: string,
|
|
449
|
-
autoComplete: string,
|
|
450
|
-
onBlur: ReactEvent.Focus.t => unit,
|
|
451
|
-
onKeyDown: ReactEvent.Keyboard.t => unit,
|
|
452
|
-
onChange: ReactEvent.Form.t => unit,
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
type t<'item> = {
|
|
456
|
-
// prop getters.
|
|
457
|
-
getToggleButtonProps: toggleButtonPropsOptions => toggleButtonProps,
|
|
458
|
-
getLabelProps: labelPropsOptions => labelProps,
|
|
459
|
-
getMenuProps: menuPropsOptions => menuProps,
|
|
460
|
-
getItemProps: itemPropsOptions => itemProps,
|
|
461
|
-
getInputProps: inputPropsOptions => inputProps,
|
|
462
|
-
getComboboxProps: comboboxPropsOptions => comboboxProps,
|
|
463
|
-
// actions.
|
|
464
|
-
toggleMenu: unit => unit,
|
|
465
|
-
openMenu: unit => unit,
|
|
466
|
-
closeMenu: unit => unit,
|
|
467
|
-
setHighlightedIndex: int => unit,
|
|
468
|
-
setInputValue: string => unit,
|
|
469
|
-
selectItem: Js.Nullable.t<'item> => unit,
|
|
470
|
-
reset: unit => unit,
|
|
471
|
-
// state.
|
|
472
|
-
highlightedIndex: int,
|
|
473
|
-
isOpen: bool,
|
|
474
|
-
selectedItem: Js.Nullable.t<'item>,
|
|
475
|
-
inputValue: string,
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
@module("downshift")
|
|
479
|
-
external useCombobox: comboboxOptions => t<'item> = "useCombobox"
|
|
480
|
-
|
|
481
|
-
/* State changes and types */
|
|
482
|
-
|
|
483
|
-
type instance
|
|
484
|
-
@module("downshift")
|
|
485
|
-
external useComboboxIntance: instance = "useCombobox"
|
|
486
|
-
|
|
487
|
-
@get @scope("stateChangeTypes")
|
|
488
|
-
external inputKeyDownArrowDown: instance => actionString = "InputKeyDownArrowDown"
|
|
489
|
-
|
|
490
|
-
@get @scope("stateChangeTypes")
|
|
491
|
-
external inputKeyDownArrowUp: instance => actionString = "InputKeyDownArrowUp"
|
|
492
|
-
|
|
493
|
-
@get @scope("stateChangeTypes")
|
|
494
|
-
external inputKeyDownEscape: instance => actionString = "InputKeyDownEscape"
|
|
495
|
-
|
|
496
|
-
@get @scope("stateChangeTypes")
|
|
497
|
-
external inputKeyDownHome: instance => actionString = "InputKeyDownHome"
|
|
498
|
-
|
|
499
|
-
@get @scope("stateChangeTypes")
|
|
500
|
-
external inputKeyDownEnd: instance => actionString = "InputKeyDownEnd"
|
|
501
|
-
|
|
502
|
-
@get @scope("stateChangeTypes")
|
|
503
|
-
external inputKeyDownEnter: instance => actionString = "InputKeyDownEnter"
|
|
504
|
-
|
|
505
|
-
@get @scope("stateChangeTypes")
|
|
506
|
-
external inputChange: instance => actionString = "InputChange"
|
|
507
|
-
|
|
508
|
-
@get @scope("stateChangeTypes")
|
|
509
|
-
external inputBlur: instance => actionString = "InputBlur"
|
|
510
|
-
|
|
511
|
-
@get @scope("stateChangeTypes")
|
|
512
|
-
external menuMouseLeave: instance => actionString = "MenuMouseLeave"
|
|
513
|
-
|
|
514
|
-
@get @scope("stateChangeTypes")
|
|
515
|
-
external itemMouseMove: instance => actionString = "ItemMouseMove"
|
|
516
|
-
|
|
517
|
-
@get @scope("stateChangeTypes")
|
|
518
|
-
external itemClick: instance => actionString = "ItemClick"
|
|
519
|
-
|
|
520
|
-
@get @scope("stateChangeTypes")
|
|
521
|
-
external toggleButtonClick: instance => actionString = "ToggleButtonClick"
|
|
522
|
-
|
|
523
|
-
@get @scope("stateChangeTypes")
|
|
524
|
-
external functionToggleMenu: instance => actionString = "FunctionToggleMenu"
|
|
525
|
-
|
|
526
|
-
@get @scope("stateChangeTypes")
|
|
527
|
-
external functionOpenMenu: instance => actionString = "FunctionOpenMenu"
|
|
528
|
-
|
|
529
|
-
@get @scope("stateChangeTypes")
|
|
530
|
-
external functionCloseMenu: instance => actionString = "FunctionCloseMenu"
|
|
531
|
-
|
|
532
|
-
@get @scope("stateChangeTypes")
|
|
533
|
-
external functionSetHighlightedIndex: instance => actionString = "FunctionSetHighlightedIndex"
|
|
534
|
-
|
|
535
|
-
@get @scope("stateChangeTypes")
|
|
536
|
-
external functionSelectItem: instance => actionString = "FunctionSelectItem"
|
|
537
|
-
|
|
538
|
-
@get @scope("stateChangeTypes")
|
|
539
|
-
external functionSetInputValue: instance => actionString = "FunctionSetInputValue"
|
|
540
|
-
|
|
541
|
-
@get @scope("stateChangeTypes")
|
|
542
|
-
external functionReset: instance => actionString = "FunctionReset"
|
|
543
|
-
|
|
544
|
-
@get @scope("stateChangeTypes")
|
|
545
|
-
external controlledPropUpdatedSelectedItem: instance => actionString =
|
|
546
|
-
"ControlledPropUpdatedSelectedItem"
|
|
547
|
-
|
|
548
|
-
type action =
|
|
549
|
-
| InputKeyDownArrowDown
|
|
550
|
-
| InputKeyDownArrowUp
|
|
551
|
-
| InputKeyDownEscape
|
|
552
|
-
| InputKeyDownHome
|
|
553
|
-
| InputKeyDownEnd
|
|
554
|
-
| InputKeyDownEnter
|
|
555
|
-
| InputChange
|
|
556
|
-
| InputBlur
|
|
557
|
-
| MenuMouseLeave
|
|
558
|
-
| ItemMouseMove
|
|
559
|
-
| ItemClick
|
|
560
|
-
| ToggleButtonClick
|
|
561
|
-
| FunctionToggleMenu
|
|
562
|
-
| FunctionOpenMenu
|
|
563
|
-
| FunctionCloseMenu
|
|
564
|
-
| FunctionSetHighlightedIndex
|
|
565
|
-
| FunctionSelectItem
|
|
566
|
-
| FunctionSetInputValue
|
|
567
|
-
| FunctionReset
|
|
568
|
-
| ControlledPropUpdatedSelectedItem
|
|
569
|
-
|
|
570
|
-
let action = actionString =>
|
|
571
|
-
switch actionString {
|
|
572
|
-
| action if action === useComboboxIntance->inputKeyDownArrowDown => InputKeyDownArrowDown
|
|
573
|
-
| action if action === useComboboxIntance->inputKeyDownArrowUp => InputKeyDownArrowUp
|
|
574
|
-
| action if action === useComboboxIntance->inputKeyDownEscape => InputKeyDownEscape
|
|
575
|
-
| action if action === useComboboxIntance->inputKeyDownHome => InputKeyDownHome
|
|
576
|
-
| action if action === useComboboxIntance->inputKeyDownEnd => InputKeyDownEnd
|
|
577
|
-
| action if action === useComboboxIntance->inputKeyDownEnter => InputKeyDownEnter
|
|
578
|
-
| action if action === useComboboxIntance->inputChange => InputChange
|
|
579
|
-
| action if action === useComboboxIntance->inputBlur => InputBlur
|
|
580
|
-
| action if action === useComboboxIntance->menuMouseLeave => MenuMouseLeave
|
|
581
|
-
| action if action === useComboboxIntance->itemMouseMove => ItemMouseMove
|
|
582
|
-
| action if action === useComboboxIntance->itemClick => ItemClick
|
|
583
|
-
| action if action === useComboboxIntance->toggleButtonClick => ToggleButtonClick
|
|
584
|
-
| action if action === useComboboxIntance->functionToggleMenu => FunctionToggleMenu
|
|
585
|
-
| action if action === useComboboxIntance->functionOpenMenu => FunctionOpenMenu
|
|
586
|
-
| action if action === useComboboxIntance->functionCloseMenu => FunctionCloseMenu
|
|
587
|
-
| action if action === useComboboxIntance->functionSetHighlightedIndex =>
|
|
588
|
-
FunctionSetHighlightedIndex
|
|
589
|
-
| action if action === useComboboxIntance->functionSelectItem => FunctionSelectItem
|
|
590
|
-
| action if action === useComboboxIntance->functionSetInputValue => FunctionSetInputValue
|
|
591
|
-
| action if action === useComboboxIntance->functionReset => FunctionReset
|
|
592
|
-
| action if action === useComboboxIntance->controlledPropUpdatedSelectedItem =>
|
|
593
|
-
ControlledPropUpdatedSelectedItem
|
|
594
|
-
| _ => Js.Exn.raiseError("unhandled BsDownShift actionString")
|
|
595
|
-
}
|
|
596
|
-
}
|