@react-stately/combobox 3.0.0-beta.1 → 3.0.0-nightly-641446f65-240905

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.
@@ -0,0 +1,17 @@
1
+ import {useComboBoxState as $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e} from "./useComboBoxState.mjs";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+ export {$a9e7382a7d111cb5$export$b453a3bfd4a5fa9e as useComboBoxState};
17
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,330 +1,22 @@
1
- var {
2
- useMenuTriggerState
3
- } = require("@react-stately/menu");
1
+ var $e563f9c9469ad14c$exports = require("./useComboBoxState.main.js");
4
2
 
5
- var {
6
- useEffect,
7
- useMemo,
8
- useRef,
9
- useState
10
- } = require("react");
11
3
 
12
- var {
13
- useControlledState
14
- } = require("@react-stately/utils");
15
-
16
- var {
17
- ListCollection,
18
- useSingleSelectListState
19
- } = require("@react-stately/list");
20
-
21
- var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
22
-
23
- function $parcel$interopDefault(a) {
24
- return a && a.__esModule ? a.default : a;
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
25
6
  }
26
7
 
27
- /**
28
- * Provides state management for a combo box component. Handles building a collection
29
- * of items from props and manages the option selection state of the combo box. In addition, it tracks the input value,
30
- * focus state, and other properties of the combo box.
31
- */
32
- function useComboBoxState(props) {
33
- var _props$defaultInputVa, _props$items, _ref, _props$selectedKey, _collection$getItem$t2, _collection$getItem2;
34
-
35
- let {
36
- defaultFilter,
37
- menuTrigger = 'input',
38
- allowsEmptyCollection = false,
39
- allowsCustomValue,
40
- shouldCloseOnBlur = true
41
- } = props;
42
- let [showAllItems, setShowAllItems] = useState(false);
43
- let [isFocused, setFocusedState] = useState(false);
44
- let [inputValue, setInputValue] = useControlledState(props.inputValue, (_props$defaultInputVa = props.defaultInputValue) != null ? _props$defaultInputVa : '', props.onInputChange);
45
-
46
- let onSelectionChange = key => {
47
- if (props.onSelectionChange) {
48
- props.onSelectionChange(key);
49
- } // If open state or selectedKey is uncontrolled and key is the same, reset the inputValue and close the menu
50
- // (scenario: user clicks on already selected option)
51
-
52
-
53
- if (props.isOpen === undefined || props.selectedKey === undefined) {
54
- if (key === selectedKey) {
55
- resetInputValue();
56
- triggerState.close();
57
- }
58
- }
59
- };
60
-
61
- let {
62
- collection,
63
- selectionManager,
64
- selectedKey,
65
- setSelectedKey,
66
- selectedItem,
67
- disabledKeys
68
- } = useSingleSelectListState(_babelRuntimeHelpersExtends({}, props, {
69
- onSelectionChange,
70
- items: (_props$items = props.items) != null ? _props$items : props.defaultItems
71
- })); // Preserve original collection so we can show all items on demand
72
-
73
- let originalCollection = collection;
74
- let filteredCollection = useMemo(() => // No default filter if items are controlled.
75
- props.items != null || !defaultFilter ? collection : $a21047c5b4305a7d5e80cc48828d4cd$var$filterCollection(collection, inputValue, defaultFilter), [collection, inputValue, defaultFilter, props.items]); // Track what action is attempting to open the menu
76
-
77
- let menuOpenTrigger = useRef('focus');
78
-
79
- let onOpenChange = open => {
80
- if (props.onOpenChange) {
81
- props.onOpenChange(open, open ? menuOpenTrigger.current : undefined);
82
- }
83
- };
84
-
85
- let triggerState = useMenuTriggerState(_babelRuntimeHelpersExtends({}, props, {
86
- onOpenChange
87
- }));
88
-
89
- let open = (focusStrategy, trigger) => {
90
- let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus'; // Prevent open operations from triggering if there is nothing to display
91
- // Also prevent open operations from triggering if items are uncontrolled but defaultItems is empty, even if displayAllItems is true.
92
- // This is to prevent comboboxes with empty defaultItems from opening but allow controlled items comboboxes to open even if the inital list is empty (assumption is user will provide swap the empty list with a base list via onOpenChange returning `menuTrigger` manual)
93
-
94
- if (allowsEmptyCollection || filteredCollection.size > 0 || displayAllItems && originalCollection.size > 0 || props.items) {
95
- if (displayAllItems && !triggerState.isOpen && props.items === undefined) {
96
- // Show all items if menu is manually opened. Only care about this if items are undefined
97
- setShowAllItems(true);
98
- }
99
-
100
- menuOpenTrigger.current = trigger;
101
- triggerState.open(focusStrategy);
102
- }
103
- };
104
-
105
- let toggle = (focusStrategy, trigger) => {
106
- let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus'; // If the menu is closed and there is nothing to display, early return so toggle isn't called to prevent extraneous onOpenChange
107
-
108
- if (!(allowsEmptyCollection || filteredCollection.size > 0 || displayAllItems && originalCollection.size > 0 || props.items) && !triggerState.isOpen) {
109
- return;
110
- }
111
-
112
- if (displayAllItems && !triggerState.isOpen && props.items === undefined) {
113
- // Show all items if menu is toggled open. Only care about this if items are undefined
114
- setShowAllItems(true);
115
- } // Only update the menuOpenTrigger if menu is currently closed
116
-
117
-
118
- if (!triggerState.isOpen) {
119
- menuOpenTrigger.current = trigger;
120
- }
121
-
122
- triggerState.toggle(focusStrategy);
123
- };
124
-
125
- let lastValue = useRef(inputValue);
126
-
127
- let resetInputValue = () => {
128
- var _collection$getItem$t, _collection$getItem;
129
-
130
- let itemText = (_collection$getItem$t = (_collection$getItem = collection.getItem(selectedKey)) == null ? void 0 : _collection$getItem.textValue) != null ? _collection$getItem$t : '';
131
- lastValue.current = itemText;
132
- setInputValue(itemText);
133
- };
134
-
135
- let isInitialRender = useRef(true);
136
- let lastSelectedKey = useRef((_ref = (_props$selectedKey = props.selectedKey) != null ? _props$selectedKey : props.defaultSelectedKey) != null ? _ref : null);
137
- let lastSelectedKeyText = useRef((_collection$getItem$t2 = (_collection$getItem2 = collection.getItem(selectedKey)) == null ? void 0 : _collection$getItem2.textValue) != null ? _collection$getItem$t2 : ''); // intentional omit dependency array, want this to happen on every render
138
- // eslint-disable-next-line react-hooks/exhaustive-deps
139
-
140
- useEffect(() => {
141
- var _collection$getItem$t3, _collection$getItem3;
142
-
143
- // If open state or inputValue is uncontrolled, open and close automatically when the input value changes,
144
- // the input is if focused, and there are items in the collection or allowEmptyCollection is true.
145
- if (isFocused && (filteredCollection.size > 0 || allowsEmptyCollection) && !triggerState.isOpen && inputValue !== lastValue.current && menuTrigger !== 'manual' && (props.isOpen === undefined || props.inputValue === undefined)) {
146
- open(null, 'input');
147
- } // Close the menu if the collection is empty and either open state or items are uncontrolled.
148
- // Don't close menu if filtered collection size is 0 but we are currently showing all items via button press (only applies to uncontrolled items)
149
-
150
-
151
- if (!showAllItems && !allowsEmptyCollection && triggerState.isOpen && filteredCollection.size === 0 && (props.isOpen === undefined || props.items === undefined)) {
152
- triggerState.close();
153
- } // Close when an item is selected, if open state or selectedKey is uncontrolled.
154
-
155
-
156
- if (selectedKey != null && selectedKey !== lastSelectedKey.current && (props.isOpen === undefined || props.selectedKey === undefined)) {
157
- triggerState.close();
158
- } // Clear focused key when input value changes and display filtered collection again.
159
-
160
-
161
- if (inputValue !== lastValue.current) {
162
- selectionManager.setFocusedKey(null);
163
- setShowAllItems(false); // Set selectedKey to null when the user clears the input.
164
- // If controlled, this is the application developer's responsibility.
8
+ $parcel$export(module.exports, "useComboBoxState", () => $e563f9c9469ad14c$exports.useComboBoxState);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
165
20
 
166
- if (inputValue === '' && (props.inputValue === undefined || props.selectedKey === undefined)) {
167
- setSelectedKey(null);
168
- }
169
- } // If it is the intial render and inputValue isn't controlled nor has an intial value, set input to match current selected key if any
170
21
 
171
-
172
- if (isInitialRender.current && props.inputValue === undefined && props.defaultInputValue === undefined) {
173
- resetInputValue();
174
- } // If the selectedKey changed, update the input value.
175
- // Do nothing if both inputValue and selectedKey are controlled.
176
- // In this case, it's the user's responsibility to update inputValue in onSelectionChange.
177
-
178
-
179
- if (selectedKey !== lastSelectedKey.current && (props.inputValue === undefined || props.selectedKey === undefined)) {
180
- resetInputValue();
181
- } else {
182
- lastValue.current = inputValue;
183
- } // Update the inputValue if the selected item's text changes from its last tracked value.
184
- // This is to handle cases where a selectedKey is specified but the items aren't available (async loading) or the selected item's text value updates.
185
- // Only reset if the user isn't currently within the field so we don't erroneously modify user input.
186
- // If inputValue is controlled, it is the user's responsibility to update the inputValue when items change.
187
-
188
-
189
- let selectedItemText = (_collection$getItem$t3 = (_collection$getItem3 = collection.getItem(selectedKey)) == null ? void 0 : _collection$getItem3.textValue) != null ? _collection$getItem$t3 : '';
190
-
191
- if (!isFocused && selectedKey != null && props.inputValue === undefined && selectedKey === lastSelectedKey.current) {
192
- if (lastSelectedKeyText.current !== selectedItemText) {
193
- lastValue.current = selectedItemText;
194
- setInputValue(selectedItemText);
195
- }
196
- }
197
-
198
- isInitialRender.current = false;
199
- lastSelectedKey.current = selectedKey;
200
- lastSelectedKeyText.current = selectedItemText;
201
- });
202
- useEffect(() => {
203
- // Reset focused key when the menu closes
204
- if (!triggerState.isOpen) {
205
- selectionManager.setFocusedKey(null);
206
- }
207
- }, [triggerState.isOpen, selectionManager]);
208
-
209
- let commitCustomValue = () => {
210
- let shouldClose = false;
211
- lastSelectedKey.current = null;
212
- setSelectedKey(null); // If previous key was already null, need to manually call onSelectionChange since it won't be triggered by a setSelectedKey call
213
- // This allows the application to control whether or not to close the menu on custom value commit
214
-
215
- if (selectedKey === null && props.onSelectionChange) {
216
- props.onSelectionChange(null);
217
- } // Should close menu ourselves if component open state or selected key is uncontrolled and therefore won't be closed by a user defined event handler
218
-
219
-
220
- shouldClose = props.isOpen == null || props.selectedKey === undefined; // Close if no other event will be fired. Otherwise, allow the
221
- // application to control this based on that event.
222
-
223
- if (shouldClose) {
224
- triggerState.close();
225
- }
226
- };
227
-
228
- let commitSelection = () => {
229
- // If multiple things are controlled, call onSelectionChange
230
- // Note that users who control open state and input value MUST also have a onSelectionChange handler to properly close the menu and reset input value
231
- if (props.selectedKey !== undefined && props.inputValue !== undefined || props.inputValue !== undefined && props.isOpen !== undefined || props.selectedKey !== undefined && props.isOpen !== undefined) {
232
- props.onSelectionChange(selectedKey); // If multiple things are controlled but inputValue isn't, reset the input value for the user
233
-
234
- if (props.inputValue === undefined) {
235
- resetInputValue();
236
- } // If multiple things are controlled but isOpen isn't, close the menu for the user
237
-
238
-
239
- if (props.isOpen === undefined) {
240
- var _collection$getItem$t4, _collection$getItem4;
241
-
242
- // Stop menu from reopening from useEffect
243
- let itemText = (_collection$getItem$t4 = (_collection$getItem4 = collection.getItem(selectedKey)) == null ? void 0 : _collection$getItem4.textValue) != null ? _collection$getItem$t4 : '';
244
- lastValue.current = itemText;
245
- triggerState.close();
246
- }
247
- } else {
248
- // If only a single aspect of combobox is controlled, reset input value and close menu for the user
249
- resetInputValue();
250
- triggerState.close();
251
- }
252
- };
253
-
254
- let commit = () => {
255
- if (triggerState.isOpen && selectionManager.focusedKey != null) {
256
- // Reset inputValue and close menu here if the selected key is already the focused key. Otherwise
257
- // fire onSelectionChange to allow the application to control the closing.
258
- if (selectedKey === selectionManager.focusedKey) {
259
- commitSelection();
260
- } else {
261
- setSelectedKey(selectionManager.focusedKey);
262
- }
263
- } else if (allowsCustomValue) {
264
- commitCustomValue();
265
- }
266
- };
267
-
268
- let setFocused = isFocused => {
269
- if (isFocused) {
270
- if (menuTrigger === 'focus') {
271
- open(null, 'focus');
272
- }
273
- } else if (shouldCloseOnBlur) {
274
- var _collection$getItem$t5, _collection$getItem5;
275
-
276
- let itemText = (_collection$getItem$t5 = (_collection$getItem5 = collection.getItem(selectedKey)) == null ? void 0 : _collection$getItem5.textValue) != null ? _collection$getItem$t5 : '';
277
-
278
- if (allowsCustomValue && inputValue !== itemText) {
279
- commitCustomValue();
280
- } else {
281
- commitSelection();
282
- }
283
- }
284
-
285
- setFocusedState(isFocused);
286
- };
287
-
288
- return _babelRuntimeHelpersExtends({}, triggerState, {
289
- toggle,
290
- open,
291
- selectionManager,
292
- selectedKey,
293
- setSelectedKey,
294
- disabledKeys,
295
- isFocused,
296
- setFocused,
297
- selectedItem,
298
- collection: showAllItems ? originalCollection : filteredCollection,
299
- inputValue,
300
- setInputValue,
301
- commit
302
- });
303
- }
304
-
305
- exports.useComboBoxState = useComboBoxState;
306
-
307
- function $a21047c5b4305a7d5e80cc48828d4cd$var$filterCollection(collection, inputValue, filter) {
308
- return new ListCollection($a21047c5b4305a7d5e80cc48828d4cd$var$filterNodes(collection, inputValue, filter));
309
- }
310
-
311
- function $a21047c5b4305a7d5e80cc48828d4cd$var$filterNodes(nodes, inputValue, filter) {
312
- let filteredNode = [];
313
-
314
- for (let node of nodes) {
315
- if (node.type === 'section' && node.hasChildNodes) {
316
- let filtered = $a21047c5b4305a7d5e80cc48828d4cd$var$filterNodes(node.childNodes, inputValue, filter);
317
-
318
- if ([...filtered].length > 0) {
319
- filteredNode.push(_babelRuntimeHelpersExtends({}, node, {
320
- childNodes: filtered
321
- }));
322
- }
323
- } else if (node.type !== 'section' && filter(node.textValue, inputValue)) {
324
- filteredNode.push(_babelRuntimeHelpersExtends({}, node));
325
- }
326
- }
327
-
328
- return filteredNode;
329
- }
330
22
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
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AAM,CAACK,IAAI,CAACnB,SAAN,EAAiBvC,UAAjB,CAArC,EAAmE;AACxEyD,MAAAA,YAAY,CAACO,IAAb,iCAAsBN,IAAtB;AACD;AACF;;AACD,SAAOD,YAAP;AACD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-stately/combobox/src/useComboBoxState.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, FocusStrategy, Node} from '@react-types/shared';\nimport {ComboBoxProps, MenuTriggerAction} from '@react-types/combobox';\nimport {ListCollection, useSingleSelectListState} from '@react-stately/list';\nimport {SelectState} from '@react-stately/select';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {useMenuTriggerState} from '@react-stately/menu';\n\nexport interface ComboBoxState<T> extends SelectState<T> {\n /** The current value of the combo box input. */\n inputValue: string,\n /** Sets the value of the combo box input. */\n setInputValue(value: string): void,\n /** Selects the currently focused item and updates the input value. */\n commit(): void,\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void,\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void\n}\n\ntype FilterFn = (textValue: string, inputValue: string) => boolean;\ninterface ComboBoxStateProps<T> extends ComboBoxProps<T> {\n /** The filter function used to determine if a option should be included in the combo box list. */\n defaultFilter?: FilterFn,\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean,\n /** Whether the combo box menu should close on blur. */\n shouldCloseOnBlur?: boolean\n}\n\n/**\n * Provides state management for a combo box component. Handles building a collection\n * of items from props and manages the option selection state of the combo box. In addition, it tracks the input value,\n * focus state, and other properties of the combo box.\n */\nexport function useComboBoxState<T extends object>(props: ComboBoxStateProps<T>): ComboBoxState<T> {\n let {\n defaultFilter,\n menuTrigger = 'input',\n allowsEmptyCollection = false,\n allowsCustomValue,\n shouldCloseOnBlur = true\n } = props;\n\n let [showAllItems, setShowAllItems] = useState(false);\n let [isFocused, setFocusedState] = useState(false);\n let [inputValue, setInputValue] = useControlledState(\n props.inputValue,\n props.defaultInputValue ?? '',\n props.onInputChange\n );\n\n let onSelectionChange = (key) => {\n if (props.onSelectionChange) {\n props.onSelectionChange(key);\n }\n\n // If open state or selectedKey is uncontrolled and key is the same, reset the inputValue and close the menu\n // (scenario: user clicks on already selected option)\n if (props.isOpen === undefined || props.selectedKey === undefined) {\n if (key === selectedKey) {\n resetInputValue();\n triggerState.close();\n }\n }\n };\n\n let {collection, selectionManager, selectedKey, setSelectedKey, selectedItem, disabledKeys} = useSingleSelectListState({\n ...props,\n onSelectionChange,\n items: props.items ?? props.defaultItems\n });\n\n // Preserve original collection so we can show all items on demand\n let originalCollection = collection;\n let filteredCollection = useMemo(() => (\n // No default filter if items are controlled.\n props.items != null || !defaultFilter\n ? collection\n : filterCollection(collection, inputValue, defaultFilter)\n ), [collection, inputValue, defaultFilter, props.items]);\n\n // Track what action is attempting to open the menu\n let menuOpenTrigger = useRef('focus' as MenuTriggerAction);\n let onOpenChange = (open: boolean) => {\n if (props.onOpenChange) {\n props.onOpenChange(open, open ? menuOpenTrigger.current : undefined);\n }\n };\n\n let triggerState = useMenuTriggerState({...props, onOpenChange});\n let open = (focusStrategy?: FocusStrategy, trigger?: MenuTriggerAction) => {\n let displayAllItems = (trigger === 'manual' || (trigger === 'focus' && menuTrigger === 'focus'));\n // Prevent open operations from triggering if there is nothing to display\n // Also prevent open operations from triggering if items are uncontrolled but defaultItems is empty, even if displayAllItems is true.\n // This is to prevent comboboxes with empty defaultItems from opening but allow controlled items comboboxes to open even if the inital list is empty (assumption is user will provide swap the empty list with a base list via onOpenChange returning `menuTrigger` manual)\n if (allowsEmptyCollection || filteredCollection.size > 0 || (displayAllItems && originalCollection.size > 0) || props.items) {\n if (displayAllItems && !triggerState.isOpen && props.items === undefined) {\n // Show all items if menu is manually opened. Only care about this if items are undefined\n setShowAllItems(true);\n }\n\n menuOpenTrigger.current = trigger;\n triggerState.open(focusStrategy);\n }\n };\n\n let toggle = (focusStrategy?: FocusStrategy, trigger?: MenuTriggerAction) => {\n let displayAllItems = (trigger === 'manual' || (trigger === 'focus' && menuTrigger === 'focus'));\n // If the menu is closed and there is nothing to display, early return so toggle isn't called to prevent extraneous onOpenChange\n if (!(allowsEmptyCollection || filteredCollection.size > 0 || (displayAllItems && originalCollection.size > 0) || props.items) && !triggerState.isOpen) {\n return;\n }\n\n if (displayAllItems && !triggerState.isOpen && props.items === undefined) {\n // Show all items if menu is toggled open. Only care about this if items are undefined\n setShowAllItems(true);\n }\n\n // Only update the menuOpenTrigger if menu is currently closed\n if (!triggerState.isOpen) {\n menuOpenTrigger.current = trigger;\n }\n\n triggerState.toggle(focusStrategy);\n };\n\n let lastValue = useRef(inputValue);\n let resetInputValue = () => {\n let itemText = collection.getItem(selectedKey)?.textValue ?? '';\n lastValue.current = itemText;\n setInputValue(itemText);\n };\n\n let isInitialRender = useRef(true);\n let lastSelectedKey = useRef(props.selectedKey ?? props.defaultSelectedKey ?? null);\n let lastSelectedKeyText = useRef(collection.getItem(selectedKey)?.textValue ?? '');\n // intentional omit dependency array, want this to happen on every render\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(() => {\n // If open state or inputValue is uncontrolled, open and close automatically when the input value changes,\n // the input is if focused, and there are items in the collection or allowEmptyCollection is true.\n if (\n isFocused &&\n (filteredCollection.size > 0 || allowsEmptyCollection) &&\n !triggerState.isOpen &&\n inputValue !== lastValue.current &&\n menuTrigger !== 'manual' &&\n (props.isOpen === undefined || props.inputValue === undefined)\n ) {\n open(null, 'input');\n }\n\n // Close the menu if the collection is empty and either open state or items are uncontrolled.\n // Don't close menu if filtered collection size is 0 but we are currently showing all items via button press (only applies to uncontrolled items)\n if (\n !showAllItems &&\n !allowsEmptyCollection &&\n triggerState.isOpen &&\n filteredCollection.size === 0 &&\n (props.isOpen === undefined || props.items === undefined)\n ) {\n triggerState.close();\n }\n\n // Close when an item is selected, if open state or selectedKey is uncontrolled.\n if (\n selectedKey != null &&\n selectedKey !== lastSelectedKey.current &&\n (props.isOpen === undefined || props.selectedKey === undefined)\n ) {\n triggerState.close();\n }\n\n // Clear focused key when input value changes and display filtered collection again.\n if (inputValue !== lastValue.current) {\n selectionManager.setFocusedKey(null);\n setShowAllItems(false);\n\n // Set selectedKey to null when the user clears the input.\n // If controlled, this is the application developer's responsibility.\n if (inputValue === '' && (props.inputValue === undefined || props.selectedKey === undefined)) {\n setSelectedKey(null);\n }\n }\n\n // If it is the intial render and inputValue isn't controlled nor has an intial value, set input to match current selected key if any\n if (isInitialRender.current && (props.inputValue === undefined && props.defaultInputValue === undefined)) {\n resetInputValue();\n }\n\n // If the selectedKey changed, update the input value.\n // Do nothing if both inputValue and selectedKey are controlled.\n // In this case, it's the user's responsibility to update inputValue in onSelectionChange.\n if (\n selectedKey !== lastSelectedKey.current &&\n (props.inputValue === undefined || props.selectedKey === undefined)\n ) {\n resetInputValue();\n } else {\n lastValue.current = inputValue;\n }\n\n // Update the inputValue if the selected item's text changes from its last tracked value.\n // This is to handle cases where a selectedKey is specified but the items aren't available (async loading) or the selected item's text value updates.\n // Only reset if the user isn't currently within the field so we don't erroneously modify user input.\n // If inputValue is controlled, it is the user's responsibility to update the inputValue when items change.\n let selectedItemText = collection.getItem(selectedKey)?.textValue ?? '';\n if (!isFocused && selectedKey != null && props.inputValue === undefined && selectedKey === lastSelectedKey.current) {\n if (lastSelectedKeyText.current !== selectedItemText) {\n lastValue.current = selectedItemText;\n setInputValue(selectedItemText);\n }\n }\n\n isInitialRender.current = false;\n lastSelectedKey.current = selectedKey;\n lastSelectedKeyText.current = selectedItemText;\n });\n\n useEffect(() => {\n // Reset focused key when the menu closes\n if (!triggerState.isOpen) {\n selectionManager.setFocusedKey(null);\n }\n }, [triggerState.isOpen, selectionManager]);\n\n let commitCustomValue = () => {\n let shouldClose = false;\n lastSelectedKey.current = null;\n setSelectedKey(null);\n\n // If previous key was already null, need to manually call onSelectionChange since it won't be triggered by a setSelectedKey call\n // This allows the application to control whether or not to close the menu on custom value commit\n if (selectedKey === null && props.onSelectionChange) {\n props.onSelectionChange(null);\n }\n\n // Should close menu ourselves if component open state or selected key is uncontrolled and therefore won't be closed by a user defined event handler\n shouldClose = props.isOpen == null || props.selectedKey === undefined;\n\n // Close if no other event will be fired. Otherwise, allow the\n // application to control this based on that event.\n if (shouldClose) {\n triggerState.close();\n }\n };\n\n let commitSelection = () => {\n // If multiple things are controlled, call onSelectionChange\n // Note that users who control open state and input value MUST also have a onSelectionChange handler to properly close the menu and reset input value\n if (\n (props.selectedKey !== undefined && props.inputValue !== undefined) ||\n (props.inputValue !== undefined && props.isOpen !== undefined) ||\n (props.selectedKey !== undefined && props.isOpen !== undefined)\n ) {\n props.onSelectionChange(selectedKey);\n\n // If multiple things are controlled but inputValue isn't, reset the input value for the user\n if (props.inputValue === undefined) {\n resetInputValue();\n }\n\n // If multiple things are controlled but isOpen isn't, close the menu for the user\n if (props.isOpen === undefined) {\n // Stop menu from reopening from useEffect\n let itemText = collection.getItem(selectedKey)?.textValue ?? '';\n lastValue.current = itemText;\n triggerState.close();\n }\n } else {\n // If only a single aspect of combobox is controlled, reset input value and close menu for the user\n resetInputValue();\n triggerState.close();\n }\n };\n\n let commit = () => {\n if (triggerState.isOpen && selectionManager.focusedKey != null) {\n // Reset inputValue and close menu here if the selected key is already the focused key. Otherwise\n // fire onSelectionChange to allow the application to control the closing.\n if (selectedKey === selectionManager.focusedKey) {\n commitSelection();\n } else {\n setSelectedKey(selectionManager.focusedKey);\n }\n } else if (allowsCustomValue) {\n commitCustomValue();\n }\n };\n\n let setFocused = (isFocused: boolean) => {\n if (isFocused) {\n if (menuTrigger === 'focus') {\n open(null, 'focus');\n }\n } else if (shouldCloseOnBlur) {\n let itemText = collection.getItem(selectedKey)?.textValue ?? '';\n if (allowsCustomValue && inputValue !== itemText) {\n commitCustomValue();\n } else {\n commitSelection();\n }\n }\n\n setFocusedState(isFocused);\n };\n\n return {\n ...triggerState,\n toggle,\n open,\n selectionManager,\n selectedKey,\n setSelectedKey,\n disabledKeys,\n isFocused,\n setFocused,\n selectedItem,\n collection: showAllItems ? originalCollection : filteredCollection,\n inputValue,\n setInputValue,\n commit\n };\n}\n\nfunction filterCollection<T extends object>(collection: Collection<Node<T>>, inputValue: string, filter: FilterFn): Collection<Node<T>> {\n return new ListCollection(filterNodes(collection, inputValue, filter));\n}\n\nfunction filterNodes<T>(nodes: Iterable<Node<T>>, inputValue: string, filter: FilterFn): Iterable<Node<T>> {\n let filteredNode = [];\n for (let node of nodes) {\n if (node.type === 'section' && node.hasChildNodes) {\n let filtered = filterNodes(node.childNodes, inputValue, filter);\n if ([...filtered].length > 0) {\n filteredNode.push({...node, childNodes: filtered});\n }\n } else if (node.type !== 'section' && filter(node.textValue, inputValue)) {\n filteredNode.push({...node});\n }\n }\n return filteredNode;\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useComboBoxState","props","defaultFilter","menuTrigger","allowsEmptyCollection","allowsCustomValue","shouldCloseOnBlur","showAllItems","setShowAllItems","useState","isFocused","setFocusedState","inputValue","setInputValue","useControlledState","defaultInputValue","onInputChange","onSelectionChange","key","isOpen","undefined","selectedKey","resetInputValue","triggerState","close","collection","selectionManager","setSelectedKey","selectedItem","disabledKeys","useSingleSelectListState","items","defaultItems","originalCollection","filteredCollection","useMemo","filterCollection","menuOpenTrigger","useRef","onOpenChange","open","current","useMenuTriggerState","focusStrategy","trigger","displayAllItems","size","toggle","lastValue","itemText","getItem","textValue","isInitialRender","lastSelectedKey","defaultSelectedKey","lastSelectedKeyText","useEffect","setFocusedKey","selectedItemText","commitCustomValue","shouldClose","commitSelection","commit","focusedKey","setFocused","filter","ListCollection","filterNodes","nodes","filteredNode","node","type","hasChildNodes","filtered","childNodes","length","push"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/combobox/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useComboBoxState} from './useComboBoxState';\n\nexport type {ComboBoxStateOptions, ComboBoxState} from './useComboBoxState';\n"],"names":[],"version":3,"file":"main.js.map"}