@react-stately/combobox 3.8.4-nightly.4624 → 3.8.4

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.
@@ -29,7 +29,7 @@ $parcel$export(module.exports, "useComboBoxState", () => $e563f9c9469ad14c$expor
29
29
 
30
30
  function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
31
31
  var _collection_getItem, _collection_getItem1;
32
- let { defaultFilter: defaultFilter, menuTrigger: menuTrigger = "input", allowsEmptyCollection: allowsEmptyCollection = false, allowsCustomValue: allowsCustomValue, shouldCloseOnBlur: shouldCloseOnBlur = true } = props;
32
+ let { defaultFilter: defaultFilter, menuTrigger: menuTrigger = 'input', allowsEmptyCollection: allowsEmptyCollection = false, allowsCustomValue: allowsCustomValue, shouldCloseOnBlur: shouldCloseOnBlur = true } = props;
33
33
  let [showAllItems, setShowAllItems] = (0, $2KOLe$react.useState)(false);
34
34
  let [isFocused, setFocusedState] = (0, $2KOLe$react.useState)(false);
35
35
  let [focusStrategy, setFocusStrategy] = (0, $2KOLe$react.useState)(null);
@@ -49,7 +49,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
49
49
  items: (_props_items = props.items) !== null && _props_items !== void 0 ? _props_items : props.defaultItems
50
50
  });
51
51
  var _props_defaultInputValue, _ref;
52
- let [inputValue, setInputValue] = (0, $2KOLe$reactstatelyutils.useControlledState)(props.inputValue, (_ref = (_props_defaultInputValue = props.defaultInputValue) !== null && _props_defaultInputValue !== void 0 ? _props_defaultInputValue : (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _ref !== void 0 ? _ref : "", props.onInputChange);
52
+ let [inputValue, setInputValue] = (0, $2KOLe$reactstatelyutils.useControlledState)(props.inputValue, (_ref = (_props_defaultInputValue = props.defaultInputValue) !== null && _props_defaultInputValue !== void 0 ? _props_defaultInputValue : (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _ref !== void 0 ? _ref : '', props.onInputChange);
53
53
  // Preserve original collection so we can show all items on demand
54
54
  let originalCollection = collection;
55
55
  let filteredCollection = (0, $2KOLe$react.useMemo)(()=>// No default filter if items are controlled.
@@ -61,7 +61,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
61
61
  ]);
62
62
  let [lastCollection, setLastCollection] = (0, $2KOLe$react.useState)(filteredCollection);
63
63
  // Track what action is attempting to open the menu
64
- let menuOpenTrigger = (0, $2KOLe$react.useRef)("focus");
64
+ let menuOpenTrigger = (0, $2KOLe$react.useRef)('focus');
65
65
  let onOpenChange = (open)=>{
66
66
  if (props.onOpenChange) props.onOpenChange(open, open ? menuOpenTrigger.current : undefined);
67
67
  selectionManager.setFocused(open);
@@ -74,7 +74,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
74
74
  defaultOpen: undefined
75
75
  });
76
76
  let open = (focusStrategy = null, trigger)=>{
77
- let displayAllItems = trigger === "manual" || trigger === "focus" && menuTrigger === "focus";
77
+ let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus';
78
78
  // Prevent open operations from triggering if there is nothing to display
79
79
  // Also prevent open operations from triggering if items are uncontrolled but defaultItems is empty, even if displayAllItems is true.
80
80
  // 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)
@@ -87,7 +87,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
87
87
  }
88
88
  };
89
89
  let toggle = (focusStrategy = null, trigger)=>{
90
- let displayAllItems = trigger === "manual" || trigger === "focus" && menuTrigger === "focus";
90
+ let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus';
91
91
  // If the menu is closed and there is nothing to display, early return so toggle isn't called to prevent extraneous onOpenChange
92
92
  if (!(allowsEmptyCollection || filteredCollection.size > 0 || displayAllItems && originalCollection.size > 0 || props.items) && !triggerState.isOpen) return;
93
93
  if (displayAllItems && !triggerState.isOpen && props.items === undefined) // Show all items if menu is toggled open. Only care about this if items are undefined
@@ -126,21 +126,21 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
126
126
  let resetInputValue = ()=>{
127
127
  var _collection_getItem;
128
128
  var _collection_getItem_textValue;
129
- let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
129
+ let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
130
130
  setLastValue(itemText);
131
131
  setInputValue(itemText);
132
132
  };
133
133
  var _props_selectedKey, _ref1;
134
134
  let lastSelectedKey = (0, $2KOLe$react.useRef)((_ref1 = (_props_selectedKey = props.selectedKey) !== null && _props_selectedKey !== void 0 ? _props_selectedKey : props.defaultSelectedKey) !== null && _ref1 !== void 0 ? _ref1 : null);
135
135
  var _collection_getItem_textValue;
136
- let lastSelectedKeyText = (0, $2KOLe$react.useRef)((_collection_getItem_textValue = (_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : _collection_getItem1.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "");
136
+ let lastSelectedKeyText = (0, $2KOLe$react.useRef)((_collection_getItem_textValue = (_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : _collection_getItem1.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '');
137
137
  // intentional omit dependency array, want this to happen on every render
138
138
  // eslint-disable-next-line react-hooks/exhaustive-deps
139
139
  (0, $2KOLe$react.useEffect)(()=>{
140
140
  var _collection_getItem;
141
141
  // Open and close menu automatically when the input value changes if the input is focused,
142
142
  // and there are items in the collection or allowEmptyCollection is true.
143
- if (isFocused && (filteredCollection.size > 0 || allowsEmptyCollection) && !triggerState.isOpen && inputValue !== lastValue && menuTrigger !== "manual") open(null, "input");
143
+ if (isFocused && (filteredCollection.size > 0 || allowsEmptyCollection) && !triggerState.isOpen && inputValue !== lastValue && menuTrigger !== 'manual') open(null, 'input');
144
144
  // Close the menu if the collection is empty. Don't close menu if filtered collection size is 0
145
145
  // but we are currently showing all items via button press
146
146
  if (!showAllItems && !allowsEmptyCollection && triggerState.isOpen && filteredCollection.size === 0) closeMenu();
@@ -152,7 +152,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
152
152
  setShowAllItems(false);
153
153
  // Set selectedKey to null when the user clears the input.
154
154
  // If controlled, this is the application developer's responsibility.
155
- if (inputValue === "" && (props.inputValue === undefined || props.selectedKey === undefined)) setSelectedKey(null);
155
+ if (inputValue === '' && (props.inputValue === undefined || props.selectedKey === undefined)) setSelectedKey(null);
156
156
  }
157
157
  // If the selectedKey changed, update the input value.
158
158
  // Do nothing if both inputValue and selectedKey are controlled.
@@ -164,7 +164,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
164
164
  // 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.
165
165
  // Only reset if the user isn't currently within the field so we don't erroneously modify user input.
166
166
  // If inputValue is controlled, it is the user's responsibility to update the inputValue when items change.
167
- let selectedItemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
167
+ let selectedItemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
168
168
  if (!isFocused && selectedKey != null && props.inputValue === undefined && selectedKey === lastSelectedKey.current) {
169
169
  if (lastSelectedKeyText.current !== selectedItemText) {
170
170
  setLastValue(selectedItemText);
@@ -201,7 +201,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
201
201
  props.onSelectionChange(selectedKey);
202
202
  var _collection_getItem_textValue;
203
203
  // Stop menu from reopening from useEffect
204
- let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
204
+ let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
205
205
  setLastValue(itemText);
206
206
  closeMenu();
207
207
  } else {
@@ -214,7 +214,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
214
214
  if (allowsCustomValue) {
215
215
  var _collection_getItem;
216
216
  var _collection_getItem_textValue;
217
- const itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
217
+ const itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
218
218
  inputValue === itemText ? commitSelection() : commitCustomValue();
219
219
  } else // Reset inputValue and close menu
220
220
  commitSelection();
@@ -231,7 +231,7 @@ function $e563f9c9469ad14c$export$b453a3bfd4a5fa9e(props) {
231
231
  let setFocused = (isFocused)=>{
232
232
  if (isFocused) {
233
233
  valueOnFocus.current = inputValue;
234
- if (menuTrigger === "focus") open(null, "focus");
234
+ if (menuTrigger === 'focus') open(null, 'focus');
235
235
  } else {
236
236
  if (shouldCloseOnBlur) commitValue();
237
237
  if (inputValue !== valueOnFocus.current) validation.commitValidation();
@@ -277,18 +277,18 @@ function $e563f9c9469ad14c$var$filterCollection(collection, inputValue, filter)
277
277
  function $e563f9c9469ad14c$var$filterNodes(collection, nodes, inputValue, filter) {
278
278
  let filteredNode = [];
279
279
  for (let node of nodes){
280
- if (node.type === "section" && node.hasChildNodes) {
280
+ if (node.type === 'section' && node.hasChildNodes) {
281
281
  let filtered = $e563f9c9469ad14c$var$filterNodes(collection, (0, $2KOLe$reactstatelycollections.getChildNodes)(node, collection), inputValue, filter);
282
282
  if ([
283
283
  ...filtered
284
- ].some((node)=>node.type === "item")) filteredNode.push({
284
+ ].some((node)=>node.type === 'item')) filteredNode.push({
285
285
  ...node,
286
286
  childNodes: filtered
287
287
  });
288
- } else if (node.type === "item" && filter(node.textValue, inputValue)) filteredNode.push({
288
+ } else if (node.type === 'item' && filter(node.textValue, inputValue)) filteredNode.push({
289
289
  ...node
290
290
  });
291
- else if (node.type !== "item") filteredNode.push({
291
+ else if (node.type !== 'item') filteredNode.push({
292
292
  ...node
293
293
  });
294
294
  }
@@ -23,7 +23,7 @@ import {useOverlayTriggerState as $49BJP$useOverlayTriggerState} from "@react-st
23
23
 
24
24
  function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
25
25
  var _collection_getItem, _collection_getItem1;
26
- let { defaultFilter: defaultFilter, menuTrigger: menuTrigger = "input", allowsEmptyCollection: allowsEmptyCollection = false, allowsCustomValue: allowsCustomValue, shouldCloseOnBlur: shouldCloseOnBlur = true } = props;
26
+ let { defaultFilter: defaultFilter, menuTrigger: menuTrigger = 'input', allowsEmptyCollection: allowsEmptyCollection = false, allowsCustomValue: allowsCustomValue, shouldCloseOnBlur: shouldCloseOnBlur = true } = props;
27
27
  let [showAllItems, setShowAllItems] = (0, $49BJP$useState)(false);
28
28
  let [isFocused, setFocusedState] = (0, $49BJP$useState)(false);
29
29
  let [focusStrategy, setFocusStrategy] = (0, $49BJP$useState)(null);
@@ -43,7 +43,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
43
43
  items: (_props_items = props.items) !== null && _props_items !== void 0 ? _props_items : props.defaultItems
44
44
  });
45
45
  var _props_defaultInputValue, _ref;
46
- let [inputValue, setInputValue] = (0, $49BJP$useControlledState)(props.inputValue, (_ref = (_props_defaultInputValue = props.defaultInputValue) !== null && _props_defaultInputValue !== void 0 ? _props_defaultInputValue : (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _ref !== void 0 ? _ref : "", props.onInputChange);
46
+ let [inputValue, setInputValue] = (0, $49BJP$useControlledState)(props.inputValue, (_ref = (_props_defaultInputValue = props.defaultInputValue) !== null && _props_defaultInputValue !== void 0 ? _props_defaultInputValue : (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _ref !== void 0 ? _ref : '', props.onInputChange);
47
47
  // Preserve original collection so we can show all items on demand
48
48
  let originalCollection = collection;
49
49
  let filteredCollection = (0, $49BJP$useMemo)(()=>// No default filter if items are controlled.
@@ -55,7 +55,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
55
55
  ]);
56
56
  let [lastCollection, setLastCollection] = (0, $49BJP$useState)(filteredCollection);
57
57
  // Track what action is attempting to open the menu
58
- let menuOpenTrigger = (0, $49BJP$useRef)("focus");
58
+ let menuOpenTrigger = (0, $49BJP$useRef)('focus');
59
59
  let onOpenChange = (open)=>{
60
60
  if (props.onOpenChange) props.onOpenChange(open, open ? menuOpenTrigger.current : undefined);
61
61
  selectionManager.setFocused(open);
@@ -68,7 +68,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
68
68
  defaultOpen: undefined
69
69
  });
70
70
  let open = (focusStrategy = null, trigger)=>{
71
- let displayAllItems = trigger === "manual" || trigger === "focus" && menuTrigger === "focus";
71
+ let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus';
72
72
  // Prevent open operations from triggering if there is nothing to display
73
73
  // Also prevent open operations from triggering if items are uncontrolled but defaultItems is empty, even if displayAllItems is true.
74
74
  // 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)
@@ -81,7 +81,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
81
81
  }
82
82
  };
83
83
  let toggle = (focusStrategy = null, trigger)=>{
84
- let displayAllItems = trigger === "manual" || trigger === "focus" && menuTrigger === "focus";
84
+ let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus';
85
85
  // If the menu is closed and there is nothing to display, early return so toggle isn't called to prevent extraneous onOpenChange
86
86
  if (!(allowsEmptyCollection || filteredCollection.size > 0 || displayAllItems && originalCollection.size > 0 || props.items) && !triggerState.isOpen) return;
87
87
  if (displayAllItems && !triggerState.isOpen && props.items === undefined) // Show all items if menu is toggled open. Only care about this if items are undefined
@@ -120,21 +120,21 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
120
120
  let resetInputValue = ()=>{
121
121
  var _collection_getItem;
122
122
  var _collection_getItem_textValue;
123
- let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
123
+ let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
124
124
  setLastValue(itemText);
125
125
  setInputValue(itemText);
126
126
  };
127
127
  var _props_selectedKey, _ref1;
128
128
  let lastSelectedKey = (0, $49BJP$useRef)((_ref1 = (_props_selectedKey = props.selectedKey) !== null && _props_selectedKey !== void 0 ? _props_selectedKey : props.defaultSelectedKey) !== null && _ref1 !== void 0 ? _ref1 : null);
129
129
  var _collection_getItem_textValue;
130
- let lastSelectedKeyText = (0, $49BJP$useRef)((_collection_getItem_textValue = (_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : _collection_getItem1.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "");
130
+ let lastSelectedKeyText = (0, $49BJP$useRef)((_collection_getItem_textValue = (_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : _collection_getItem1.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '');
131
131
  // intentional omit dependency array, want this to happen on every render
132
132
  // eslint-disable-next-line react-hooks/exhaustive-deps
133
133
  (0, $49BJP$useEffect)(()=>{
134
134
  var _collection_getItem;
135
135
  // Open and close menu automatically when the input value changes if the input is focused,
136
136
  // and there are items in the collection or allowEmptyCollection is true.
137
- if (isFocused && (filteredCollection.size > 0 || allowsEmptyCollection) && !triggerState.isOpen && inputValue !== lastValue && menuTrigger !== "manual") open(null, "input");
137
+ if (isFocused && (filteredCollection.size > 0 || allowsEmptyCollection) && !triggerState.isOpen && inputValue !== lastValue && menuTrigger !== 'manual') open(null, 'input');
138
138
  // Close the menu if the collection is empty. Don't close menu if filtered collection size is 0
139
139
  // but we are currently showing all items via button press
140
140
  if (!showAllItems && !allowsEmptyCollection && triggerState.isOpen && filteredCollection.size === 0) closeMenu();
@@ -146,7 +146,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
146
146
  setShowAllItems(false);
147
147
  // Set selectedKey to null when the user clears the input.
148
148
  // If controlled, this is the application developer's responsibility.
149
- if (inputValue === "" && (props.inputValue === undefined || props.selectedKey === undefined)) setSelectedKey(null);
149
+ if (inputValue === '' && (props.inputValue === undefined || props.selectedKey === undefined)) setSelectedKey(null);
150
150
  }
151
151
  // If the selectedKey changed, update the input value.
152
152
  // Do nothing if both inputValue and selectedKey are controlled.
@@ -158,7 +158,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
158
158
  // 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.
159
159
  // Only reset if the user isn't currently within the field so we don't erroneously modify user input.
160
160
  // If inputValue is controlled, it is the user's responsibility to update the inputValue when items change.
161
- let selectedItemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
161
+ let selectedItemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
162
162
  if (!isFocused && selectedKey != null && props.inputValue === undefined && selectedKey === lastSelectedKey.current) {
163
163
  if (lastSelectedKeyText.current !== selectedItemText) {
164
164
  setLastValue(selectedItemText);
@@ -195,7 +195,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
195
195
  props.onSelectionChange(selectedKey);
196
196
  var _collection_getItem_textValue;
197
197
  // Stop menu from reopening from useEffect
198
- let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
198
+ let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
199
199
  setLastValue(itemText);
200
200
  closeMenu();
201
201
  } else {
@@ -208,7 +208,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
208
208
  if (allowsCustomValue) {
209
209
  var _collection_getItem;
210
210
  var _collection_getItem_textValue;
211
- const itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
211
+ const itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
212
212
  inputValue === itemText ? commitSelection() : commitCustomValue();
213
213
  } else // Reset inputValue and close menu
214
214
  commitSelection();
@@ -225,7 +225,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
225
225
  let setFocused = (isFocused)=>{
226
226
  if (isFocused) {
227
227
  valueOnFocus.current = inputValue;
228
- if (menuTrigger === "focus") open(null, "focus");
228
+ if (menuTrigger === 'focus') open(null, 'focus');
229
229
  } else {
230
230
  if (shouldCloseOnBlur) commitValue();
231
231
  if (inputValue !== valueOnFocus.current) validation.commitValidation();
@@ -271,18 +271,18 @@ function $a9e7382a7d111cb5$var$filterCollection(collection, inputValue, filter)
271
271
  function $a9e7382a7d111cb5$var$filterNodes(collection, nodes, inputValue, filter) {
272
272
  let filteredNode = [];
273
273
  for (let node of nodes){
274
- if (node.type === "section" && node.hasChildNodes) {
274
+ if (node.type === 'section' && node.hasChildNodes) {
275
275
  let filtered = $a9e7382a7d111cb5$var$filterNodes(collection, (0, $49BJP$getChildNodes)(node, collection), inputValue, filter);
276
276
  if ([
277
277
  ...filtered
278
- ].some((node)=>node.type === "item")) filteredNode.push({
278
+ ].some((node)=>node.type === 'item')) filteredNode.push({
279
279
  ...node,
280
280
  childNodes: filtered
281
281
  });
282
- } else if (node.type === "item" && filter(node.textValue, inputValue)) filteredNode.push({
282
+ } else if (node.type === 'item' && filter(node.textValue, inputValue)) filteredNode.push({
283
283
  ...node
284
284
  });
285
- else if (node.type !== "item") filteredNode.push({
285
+ else if (node.type !== 'item') filteredNode.push({
286
286
  ...node
287
287
  });
288
288
  }
@@ -23,7 +23,7 @@ import {useOverlayTriggerState as $49BJP$useOverlayTriggerState} from "@react-st
23
23
 
24
24
  function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
25
25
  var _collection_getItem, _collection_getItem1;
26
- let { defaultFilter: defaultFilter, menuTrigger: menuTrigger = "input", allowsEmptyCollection: allowsEmptyCollection = false, allowsCustomValue: allowsCustomValue, shouldCloseOnBlur: shouldCloseOnBlur = true } = props;
26
+ let { defaultFilter: defaultFilter, menuTrigger: menuTrigger = 'input', allowsEmptyCollection: allowsEmptyCollection = false, allowsCustomValue: allowsCustomValue, shouldCloseOnBlur: shouldCloseOnBlur = true } = props;
27
27
  let [showAllItems, setShowAllItems] = (0, $49BJP$useState)(false);
28
28
  let [isFocused, setFocusedState] = (0, $49BJP$useState)(false);
29
29
  let [focusStrategy, setFocusStrategy] = (0, $49BJP$useState)(null);
@@ -43,7 +43,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
43
43
  items: (_props_items = props.items) !== null && _props_items !== void 0 ? _props_items : props.defaultItems
44
44
  });
45
45
  var _props_defaultInputValue, _ref;
46
- let [inputValue, setInputValue] = (0, $49BJP$useControlledState)(props.inputValue, (_ref = (_props_defaultInputValue = props.defaultInputValue) !== null && _props_defaultInputValue !== void 0 ? _props_defaultInputValue : (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _ref !== void 0 ? _ref : "", props.onInputChange);
46
+ let [inputValue, setInputValue] = (0, $49BJP$useControlledState)(props.inputValue, (_ref = (_props_defaultInputValue = props.defaultInputValue) !== null && _props_defaultInputValue !== void 0 ? _props_defaultInputValue : (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _ref !== void 0 ? _ref : '', props.onInputChange);
47
47
  // Preserve original collection so we can show all items on demand
48
48
  let originalCollection = collection;
49
49
  let filteredCollection = (0, $49BJP$useMemo)(()=>// No default filter if items are controlled.
@@ -55,7 +55,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
55
55
  ]);
56
56
  let [lastCollection, setLastCollection] = (0, $49BJP$useState)(filteredCollection);
57
57
  // Track what action is attempting to open the menu
58
- let menuOpenTrigger = (0, $49BJP$useRef)("focus");
58
+ let menuOpenTrigger = (0, $49BJP$useRef)('focus');
59
59
  let onOpenChange = (open)=>{
60
60
  if (props.onOpenChange) props.onOpenChange(open, open ? menuOpenTrigger.current : undefined);
61
61
  selectionManager.setFocused(open);
@@ -68,7 +68,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
68
68
  defaultOpen: undefined
69
69
  });
70
70
  let open = (focusStrategy = null, trigger)=>{
71
- let displayAllItems = trigger === "manual" || trigger === "focus" && menuTrigger === "focus";
71
+ let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus';
72
72
  // Prevent open operations from triggering if there is nothing to display
73
73
  // Also prevent open operations from triggering if items are uncontrolled but defaultItems is empty, even if displayAllItems is true.
74
74
  // 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)
@@ -81,7 +81,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
81
81
  }
82
82
  };
83
83
  let toggle = (focusStrategy = null, trigger)=>{
84
- let displayAllItems = trigger === "manual" || trigger === "focus" && menuTrigger === "focus";
84
+ let displayAllItems = trigger === 'manual' || trigger === 'focus' && menuTrigger === 'focus';
85
85
  // If the menu is closed and there is nothing to display, early return so toggle isn't called to prevent extraneous onOpenChange
86
86
  if (!(allowsEmptyCollection || filteredCollection.size > 0 || displayAllItems && originalCollection.size > 0 || props.items) && !triggerState.isOpen) return;
87
87
  if (displayAllItems && !triggerState.isOpen && props.items === undefined) // Show all items if menu is toggled open. Only care about this if items are undefined
@@ -120,21 +120,21 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
120
120
  let resetInputValue = ()=>{
121
121
  var _collection_getItem;
122
122
  var _collection_getItem_textValue;
123
- let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
123
+ let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
124
124
  setLastValue(itemText);
125
125
  setInputValue(itemText);
126
126
  };
127
127
  var _props_selectedKey, _ref1;
128
128
  let lastSelectedKey = (0, $49BJP$useRef)((_ref1 = (_props_selectedKey = props.selectedKey) !== null && _props_selectedKey !== void 0 ? _props_selectedKey : props.defaultSelectedKey) !== null && _ref1 !== void 0 ? _ref1 : null);
129
129
  var _collection_getItem_textValue;
130
- let lastSelectedKeyText = (0, $49BJP$useRef)((_collection_getItem_textValue = (_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : _collection_getItem1.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "");
130
+ let lastSelectedKeyText = (0, $49BJP$useRef)((_collection_getItem_textValue = (_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : _collection_getItem1.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '');
131
131
  // intentional omit dependency array, want this to happen on every render
132
132
  // eslint-disable-next-line react-hooks/exhaustive-deps
133
133
  (0, $49BJP$useEffect)(()=>{
134
134
  var _collection_getItem;
135
135
  // Open and close menu automatically when the input value changes if the input is focused,
136
136
  // and there are items in the collection or allowEmptyCollection is true.
137
- if (isFocused && (filteredCollection.size > 0 || allowsEmptyCollection) && !triggerState.isOpen && inputValue !== lastValue && menuTrigger !== "manual") open(null, "input");
137
+ if (isFocused && (filteredCollection.size > 0 || allowsEmptyCollection) && !triggerState.isOpen && inputValue !== lastValue && menuTrigger !== 'manual') open(null, 'input');
138
138
  // Close the menu if the collection is empty. Don't close menu if filtered collection size is 0
139
139
  // but we are currently showing all items via button press
140
140
  if (!showAllItems && !allowsEmptyCollection && triggerState.isOpen && filteredCollection.size === 0) closeMenu();
@@ -146,7 +146,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
146
146
  setShowAllItems(false);
147
147
  // Set selectedKey to null when the user clears the input.
148
148
  // If controlled, this is the application developer's responsibility.
149
- if (inputValue === "" && (props.inputValue === undefined || props.selectedKey === undefined)) setSelectedKey(null);
149
+ if (inputValue === '' && (props.inputValue === undefined || props.selectedKey === undefined)) setSelectedKey(null);
150
150
  }
151
151
  // If the selectedKey changed, update the input value.
152
152
  // Do nothing if both inputValue and selectedKey are controlled.
@@ -158,7 +158,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
158
158
  // 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.
159
159
  // Only reset if the user isn't currently within the field so we don't erroneously modify user input.
160
160
  // If inputValue is controlled, it is the user's responsibility to update the inputValue when items change.
161
- let selectedItemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
161
+ let selectedItemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
162
162
  if (!isFocused && selectedKey != null && props.inputValue === undefined && selectedKey === lastSelectedKey.current) {
163
163
  if (lastSelectedKeyText.current !== selectedItemText) {
164
164
  setLastValue(selectedItemText);
@@ -195,7 +195,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
195
195
  props.onSelectionChange(selectedKey);
196
196
  var _collection_getItem_textValue;
197
197
  // Stop menu from reopening from useEffect
198
- let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
198
+ let itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
199
199
  setLastValue(itemText);
200
200
  closeMenu();
201
201
  } else {
@@ -208,7 +208,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
208
208
  if (allowsCustomValue) {
209
209
  var _collection_getItem;
210
210
  var _collection_getItem_textValue;
211
- const itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : "";
211
+ const itemText = (_collection_getItem_textValue = (_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _collection_getItem_textValue !== void 0 ? _collection_getItem_textValue : '';
212
212
  inputValue === itemText ? commitSelection() : commitCustomValue();
213
213
  } else // Reset inputValue and close menu
214
214
  commitSelection();
@@ -225,7 +225,7 @@ function $a9e7382a7d111cb5$export$b453a3bfd4a5fa9e(props) {
225
225
  let setFocused = (isFocused)=>{
226
226
  if (isFocused) {
227
227
  valueOnFocus.current = inputValue;
228
- if (menuTrigger === "focus") open(null, "focus");
228
+ if (menuTrigger === 'focus') open(null, 'focus');
229
229
  } else {
230
230
  if (shouldCloseOnBlur) commitValue();
231
231
  if (inputValue !== valueOnFocus.current) validation.commitValidation();
@@ -271,18 +271,18 @@ function $a9e7382a7d111cb5$var$filterCollection(collection, inputValue, filter)
271
271
  function $a9e7382a7d111cb5$var$filterNodes(collection, nodes, inputValue, filter) {
272
272
  let filteredNode = [];
273
273
  for (let node of nodes){
274
- if (node.type === "section" && node.hasChildNodes) {
274
+ if (node.type === 'section' && node.hasChildNodes) {
275
275
  let filtered = $a9e7382a7d111cb5$var$filterNodes(collection, (0, $49BJP$getChildNodes)(node, collection), inputValue, filter);
276
276
  if ([
277
277
  ...filtered
278
- ].some((node)=>node.type === "item")) filteredNode.push({
278
+ ].some((node)=>node.type === 'item')) filteredNode.push({
279
279
  ...node,
280
280
  childNodes: filtered
281
281
  });
282
- } else if (node.type === "item" && filter(node.textValue, inputValue)) filteredNode.push({
282
+ } else if (node.type === 'item' && filter(node.textValue, inputValue)) filteredNode.push({
283
283
  ...node
284
284
  });
285
- else if (node.type !== "item") filteredNode.push({
285
+ else if (node.type !== 'item') filteredNode.push({
286
286
  ...node
287
287
  });
288
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/combobox",
3
- "version": "3.8.4-nightly.4624+d80999e89",
3
+ "version": "3.8.4",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,14 +22,14 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/collections": "3.0.0-nightly.2912+d80999e89",
26
- "@react-stately/form": "3.0.3-nightly.4624+d80999e89",
27
- "@react-stately/list": "3.10.5-nightly.4624+d80999e89",
28
- "@react-stately/overlays": "3.6.7-nightly.4624+d80999e89",
29
- "@react-stately/select": "3.6.4-nightly.4624+d80999e89",
30
- "@react-stately/utils": "3.0.0-nightly.2912+d80999e89",
31
- "@react-types/combobox": "3.11.1-nightly.4624+d80999e89",
32
- "@react-types/shared": "3.0.0-nightly.2912+d80999e89",
25
+ "@react-stately/collections": "^3.10.7",
26
+ "@react-stately/form": "^3.0.3",
27
+ "@react-stately/list": "^3.10.5",
28
+ "@react-stately/overlays": "^3.6.7",
29
+ "@react-stately/select": "^3.6.4",
30
+ "@react-stately/utils": "^3.10.1",
31
+ "@react-types/combobox": "^3.11.1",
32
+ "@react-types/shared": "^3.23.1",
33
33
  "@swc/helpers": "^0.5.0"
34
34
  },
35
35
  "peerDependencies": {
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "d80999e897b4d4db9fcfb4e9b8fcdc9fdd700882"
41
+ "gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
42
42
  }