@jobber/components 9.4.0 → 9.5.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/dist/Autocomplete/index.cjs +0 -1
- package/dist/Autocomplete/index.mjs +0 -1
- package/dist/Card/index.cjs +7 -7
- package/dist/Card/index.mjs +7 -7
- package/dist/Chip/index.cjs +0 -1
- package/dist/Chip/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.mjs +0 -1
- package/dist/Chips/index.cjs +0 -1
- package/dist/Chips/index.mjs +0 -1
- package/dist/ComboboxChipRemove-cjs.js +181 -184
- package/dist/ComboboxChipRemove-es.js +4 -7
- package/dist/ConfirmationModal/index.cjs +0 -1
- package/dist/ConfirmationModal/index.mjs +0 -1
- package/dist/DataDump/index.cjs +7 -7
- package/dist/DataDump/index.mjs +7 -7
- package/dist/DataList/components/DataListActions/index.cjs +0 -1
- package/dist/DataList/components/DataListActions/index.mjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.cjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/index.mjs +0 -1
- package/dist/DataList/components/DataListHeader/index.cjs +0 -1
- package/dist/DataList/components/DataListHeader/index.mjs +0 -1
- package/dist/DataList/components/DataListItem/index.cjs +0 -1
- package/dist/DataList/components/DataListItem/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +0 -1
- package/dist/DataList/components/DataListItems/index.cjs +0 -1
- package/dist/DataList/components/DataListItems/index.mjs +0 -1
- package/dist/DataList/components/DataListLayout/index.cjs +0 -1
- package/dist/DataList/components/DataListLayout/index.mjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.cjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.mjs +0 -1
- package/dist/DataList/index.cjs +0 -1
- package/dist/DataList/index.mjs +0 -1
- package/dist/DatePicker/index.cjs +0 -2
- package/dist/DatePicker/index.mjs +0 -2
- package/dist/DatePicker-cjs.js +19 -18
- package/dist/DatePicker-es.js +2 -1
- package/dist/Dialog/index.cjs +11 -6
- package/dist/Dialog/index.mjs +11 -6
- package/dist/DrawerDescription-cjs.js +7 -8
- package/dist/DrawerDescription-es.js +1 -2
- package/dist/DrawerTitle-cjs.js +4 -4
- package/dist/DrawerTitle-es.js +1 -1
- package/dist/FieldDescription-cjs.js +49 -49
- package/dist/FieldDescription-es.js +2 -2
- package/dist/FilterPicker/components/FilterPickerActivator/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerActivator/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.mjs +0 -1
- package/dist/FilterPicker/index.cjs +0 -1
- package/dist/FilterPicker/index.mjs +0 -1
- package/dist/FormatFile/index.cjs +0 -1
- package/dist/FormatFile/index.mjs +0 -1
- package/dist/Gallery/index.cjs +0 -1
- package/dist/Gallery/index.mjs +0 -1
- package/dist/HelperText-cjs.js +3 -2
- package/dist/HelperText-es.js +3 -2
- package/dist/InputDate/index.cjs +0 -2
- package/dist/InputDate/index.mjs +0 -2
- package/dist/InputNumber/InputNumber.d.ts +75 -5
- package/dist/InputNumber/index.cjs +27 -3
- package/dist/InputNumber/index.d.ts +2 -2
- package/dist/InputNumber/index.mjs +27 -3
- package/dist/{primitives/InputNumberExperimental → InputNumber}/types.d.ts +48 -35
- package/dist/InputNumber-cjs.js +267 -4986
- package/dist/InputNumber-es.js +268 -4987
- package/dist/LightBox/index.cjs +0 -1
- package/dist/LightBox/index.mjs +0 -1
- package/dist/Menu/index.cjs +7 -7
- package/dist/Menu/index.mjs +7 -7
- package/dist/Menu-cjs.js +4 -1
- package/dist/Menu-es.js +4 -1
- package/dist/MenuSubmenuTrigger-cjs.js +142 -143
- package/dist/MenuSubmenuTrigger-es.js +5 -6
- package/dist/Modal/index.cjs +0 -1
- package/dist/Modal/index.mjs +0 -1
- package/dist/NumberFieldInput-cjs.js +63 -63
- package/dist/NumberFieldInput-es.js +5 -5
- package/dist/Page/index.cjs +7 -8
- package/dist/Page/index.mjs +7 -8
- package/dist/Popover/index.cjs +0 -1
- package/dist/Popover/index.mjs +0 -1
- package/dist/ScrollAreaViewport-cjs.js +119 -121
- package/dist/ScrollAreaViewport-es.js +3 -5
- package/dist/Select/index.cjs +3 -9
- package/dist/Select/index.mjs +3 -9
- package/dist/SelectGroupLabel-cjs.js +117 -107
- package/dist/SelectGroupLabel-es.js +20 -12
- package/dist/Tooltip/index.cjs +0 -1
- package/dist/Tooltip/index.mjs +0 -1
- package/dist/dialogReturnFocus-cjs.js +4 -1
- package/dist/dialogReturnFocus-es.js +4 -1
- package/dist/docs/InputNumber/InputNumber.md +564 -56
- package/dist/docs/index.md +0 -1
- package/dist/floating-ui.react-cjs.js +34 -35
- package/dist/floating-ui.react-dom-cjs.js +64 -65
- package/dist/floating-ui.react-dom-es.js +1 -2
- package/dist/floating-ui.react-es.js +1 -2
- package/dist/floating-ui.utils-cjs.js +183 -0
- package/dist/floating-ui.utils-es.js +165 -1
- package/dist/index.cjs +10 -15
- package/dist/index.mjs +10 -15
- package/dist/primitives/BottomSheet/index.cjs +2 -5
- package/dist/primitives/BottomSheet/index.mjs +2 -5
- package/dist/primitives/ComboboxPrimitive/index.cjs +3 -7
- package/dist/primitives/ComboboxPrimitive/index.mjs +3 -7
- package/dist/primitives/HelperText/HelperText.d.ts +4 -1
- package/dist/primitives/HelperText/index.cjs +1 -1
- package/dist/primitives/HelperText/index.mjs +1 -1
- package/dist/primitives/SelectPrimitive/index.cjs +3 -9
- package/dist/primitives/SelectPrimitive/index.mjs +3 -9
- package/dist/primitives/index.cjs +2 -16
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.mjs +2 -15
- package/dist/scrollEdges-cjs.js +6 -2
- package/dist/scrollEdges-es.js +5 -2
- package/dist/styles.css +573 -902
- package/dist/unstyledPrimitives/index.cjs +105 -111
- package/dist/unstyledPrimitives/index.mjs +5 -11
- package/dist/useCompositeListItem-cjs.js +516 -90
- package/dist/useCompositeListItem-es.js +407 -6
- package/dist/useLabel-cjs.js +10 -10
- package/dist/useLabel-es.js +3 -3
- package/dist/useRenderElement-es.js +1 -1
- package/dist/useScrollLock-cjs.js +1332 -203
- package/dist/useScrollLock-es.js +1068 -5
- package/dist/utils/meta/meta.json +12 -0
- package/package.json +2 -3
- package/dist/InputNumber/InputNumber.types.d.ts +0 -20
- package/dist/InputNumberExperimental-cjs.js +0 -277
- package/dist/InputNumberExperimental-es.js +0 -275
- package/dist/clamp-cjs.js +0 -7
- package/dist/clamp-es.js +0 -5
- package/dist/clsx-cjs.js +0 -5
- package/dist/clsx-es.js +0 -3
- package/dist/docs/InputNumberExperimental/InputNumberExperimental.md +0 -578
- package/dist/floating-ui.utils.dom-cjs.js +0 -185
- package/dist/floating-ui.utils.dom-es.js +0 -165
- package/dist/isElementDisabled-cjs.js +0 -40
- package/dist/isElementDisabled-es.js +0 -18
- package/dist/primitives/InputNumberExperimental/InputNumberExperimental.d.ts +0 -77
- package/dist/primitives/InputNumberExperimental/index.cjs +0 -30
- package/dist/primitives/InputNumberExperimental/index.d.ts +0 -2
- package/dist/primitives/InputNumberExperimental/index.mjs +0 -24
- package/dist/resolveAriaLabelledBy-cjs.js +0 -200
- package/dist/resolveAriaLabelledBy-es.js +0 -166
- package/dist/useButton-cjs.js +0 -1164
- package/dist/useButton-es.js +0 -1071
- package/dist/useLabelableId-cjs.js +0 -278
- package/dist/useLabelableId-es.js +0 -247
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
4
|
+
var useScrollLock = require('./useScrollLock-cjs.js');
|
|
5
5
|
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
6
|
-
var useLabelableId = require('./useLabelableId-cjs.js');
|
|
7
6
|
var useCompositeListItem = require('./useCompositeListItem-cjs.js');
|
|
8
|
-
var resolveAriaLabelledBy = require('./resolveAriaLabelledBy-cjs.js');
|
|
9
|
-
var useScrollLock = require('./useScrollLock-cjs.js');
|
|
10
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
8
|
var ReactDOM = require('react-dom');
|
|
12
9
|
var stringifyLocale = require('./stringifyLocale-cjs.js');
|
|
13
10
|
var useLabel = require('./useLabel-cjs.js');
|
|
14
|
-
var
|
|
11
|
+
var floatingUi_utils = require('./floating-ui.utils-cjs.js');
|
|
15
12
|
|
|
16
13
|
function _interopNamespaceDefault(e) {
|
|
17
14
|
var n = Object.create(null);
|
|
@@ -129,7 +126,7 @@ const selectors = {
|
|
|
129
126
|
return true;
|
|
130
127
|
}),
|
|
131
128
|
hasNullItemLabel: useScrollLock.createSelector((state, enabled) => {
|
|
132
|
-
return enabled ?
|
|
129
|
+
return enabled ? useCompositeListItem.hasNullItemLabel(state.items) : false;
|
|
133
130
|
}),
|
|
134
131
|
open: useScrollLock.createSelector(state => state.open),
|
|
135
132
|
mounted: useScrollLock.createSelector(state => state.mounted),
|
|
@@ -142,9 +139,9 @@ const selectors = {
|
|
|
142
139
|
const comparer = state.isItemEqualToValue;
|
|
143
140
|
const selectedValue = state.selectedValue;
|
|
144
141
|
if (Array.isArray(selectedValue)) {
|
|
145
|
-
return selectedValue.some(selectedItem =>
|
|
142
|
+
return selectedValue.some(selectedItem => useCompositeListItem.compareItemEquality(itemValue, selectedItem, comparer));
|
|
146
143
|
}
|
|
147
|
-
return
|
|
144
|
+
return useCompositeListItem.compareItemEquality(itemValue, selectedValue, comparer);
|
|
148
145
|
}),
|
|
149
146
|
transitionStatus: useScrollLock.createSelector(state => state.transitionStatus),
|
|
150
147
|
popupProps: useScrollLock.createSelector(state => state.popupProps),
|
|
@@ -196,7 +193,7 @@ function createCollatorItemFilter(collatorFilter, itemToStringLabel) {
|
|
|
196
193
|
if (item == null) {
|
|
197
194
|
return false;
|
|
198
195
|
}
|
|
199
|
-
const itemString =
|
|
196
|
+
const itemString = useCompositeListItem.stringifyAsLabel(item, itemToStringLabel);
|
|
200
197
|
return collatorFilter.contains(itemString, query);
|
|
201
198
|
};
|
|
202
199
|
}
|
|
@@ -213,8 +210,8 @@ function createSingleSelectionCollatorFilter(collatorFilter, itemToStringLabel,
|
|
|
213
210
|
if (!query) {
|
|
214
211
|
return true;
|
|
215
212
|
}
|
|
216
|
-
const itemString =
|
|
217
|
-
const selectedString = selectedValue != null ?
|
|
213
|
+
const itemString = useCompositeListItem.stringifyAsLabel(item, itemToStringLabel);
|
|
214
|
+
const selectedString = selectedValue != null ? useCompositeListItem.stringifyAsLabel(selectedValue, itemToStringLabel) : '';
|
|
218
215
|
|
|
219
216
|
// Handle case-insensitive matching consistently
|
|
220
217
|
if (selectedString && collatorFilter.contains(selectedString, query) && selectedString.length === query.length) {
|
|
@@ -243,7 +240,7 @@ function getFilter(options = {}) {
|
|
|
243
240
|
if (!query) {
|
|
244
241
|
return true;
|
|
245
242
|
}
|
|
246
|
-
const itemString =
|
|
243
|
+
const itemString = useCompositeListItem.stringifyAsLabel(item, itemToString);
|
|
247
244
|
for (let i = 0; i <= itemString.length - query.length; i += 1) {
|
|
248
245
|
if (collator.compare(itemString.slice(i, i + query.length), query) === 0) {
|
|
249
246
|
return true;
|
|
@@ -255,14 +252,14 @@ function getFilter(options = {}) {
|
|
|
255
252
|
if (!query) {
|
|
256
253
|
return true;
|
|
257
254
|
}
|
|
258
|
-
const itemString =
|
|
255
|
+
const itemString = useCompositeListItem.stringifyAsLabel(item, itemToString);
|
|
259
256
|
return collator.compare(itemString.slice(0, query.length), query) === 0;
|
|
260
257
|
},
|
|
261
258
|
endsWith(item, query, itemToString) {
|
|
262
259
|
if (!query) {
|
|
263
260
|
return true;
|
|
264
261
|
}
|
|
265
|
-
const itemString =
|
|
262
|
+
const itemString = useCompositeListItem.stringifyAsLabel(item, itemToString);
|
|
266
263
|
const queryLength = query.length;
|
|
267
264
|
return itemString.length >= queryLength && collator.compare(itemString.slice(itemString.length - queryLength), query) === 0;
|
|
268
265
|
}
|
|
@@ -334,7 +331,7 @@ function AriaCombobox(props) {
|
|
|
334
331
|
loopFocus = true,
|
|
335
332
|
itemToStringLabel,
|
|
336
333
|
itemToStringValue,
|
|
337
|
-
isItemEqualToValue =
|
|
334
|
+
isItemEqualToValue = useCompositeListItem.defaultItemEquality,
|
|
338
335
|
virtualized = false,
|
|
339
336
|
inline: inlineProp = false,
|
|
340
337
|
fillInputOnItemPress = true,
|
|
@@ -347,7 +344,7 @@ function AriaCombobox(props) {
|
|
|
347
344
|
} = props;
|
|
348
345
|
const {
|
|
349
346
|
clearErrors
|
|
350
|
-
} =
|
|
347
|
+
} = useCompositeListItem.useFormContext();
|
|
351
348
|
const {
|
|
352
349
|
setDirty,
|
|
353
350
|
validityData,
|
|
@@ -358,9 +355,9 @@ function AriaCombobox(props) {
|
|
|
358
355
|
setFocused,
|
|
359
356
|
validationMode,
|
|
360
357
|
validation
|
|
361
|
-
} =
|
|
358
|
+
} = useCompositeListItem.useFieldRootContext();
|
|
362
359
|
const direction = useScrollLock.useDirection();
|
|
363
|
-
const id =
|
|
360
|
+
const id = useCompositeListItem.useLabelableId({
|
|
364
361
|
id: idProp
|
|
365
362
|
});
|
|
366
363
|
const collatorFilter = useCoreFilter({
|
|
@@ -407,7 +404,7 @@ function AriaCombobox(props) {
|
|
|
407
404
|
} else {
|
|
408
405
|
autoHighlightMode = autoHighlight ? 'input-change' : false;
|
|
409
406
|
}
|
|
410
|
-
const [selectedValue, setSelectedValueUnwrapped] =
|
|
407
|
+
const [selectedValue, setSelectedValueUnwrapped] = useScrollLock.useControlled({
|
|
411
408
|
controlled: selectedValueProp,
|
|
412
409
|
default: multiple ? defaultSelectedValue ?? useRenderElement.EMPTY_ARRAY : defaultSelectedValue,
|
|
413
410
|
name: 'Combobox',
|
|
@@ -433,25 +430,25 @@ function AriaCombobox(props) {
|
|
|
433
430
|
return defaultInputValueProp ?? '';
|
|
434
431
|
}
|
|
435
432
|
if (single) {
|
|
436
|
-
return
|
|
433
|
+
return useCompositeListItem.stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
437
434
|
}
|
|
438
435
|
return '';
|
|
439
436
|
}).current;
|
|
440
|
-
const [inputValue, setInputValueUnwrapped] =
|
|
437
|
+
const [inputValue, setInputValueUnwrapped] = useScrollLock.useControlled({
|
|
441
438
|
controlled: inputValueProp,
|
|
442
439
|
default: initialDefaultInputValue,
|
|
443
440
|
name: 'Combobox',
|
|
444
441
|
state: 'inputValue'
|
|
445
442
|
});
|
|
446
|
-
const [open, setOpenUnwrapped] =
|
|
443
|
+
const [open, setOpenUnwrapped] = useScrollLock.useControlled({
|
|
447
444
|
controlled: openProp,
|
|
448
445
|
default: defaultOpen,
|
|
449
446
|
name: 'Combobox',
|
|
450
447
|
state: 'open'
|
|
451
448
|
});
|
|
452
|
-
const isGrouped =
|
|
449
|
+
const isGrouped = useCompositeListItem.isGroupedItems(items);
|
|
453
450
|
const query = closeQuery ?? (inputValue === '' ? '' : String(inputValue).trim());
|
|
454
|
-
const selectedLabelString = single ?
|
|
451
|
+
const selectedLabelString = single ? useCompositeListItem.stringifyAsLabel(selectedValue, itemToStringLabel) : '';
|
|
455
452
|
const shouldBypassFiltering = single && !queryChangedAfterOpen && query !== '' && selectedLabelString !== '' && selectedLabelString.length === query.length && collatorFilter.contains(selectedLabelString, query);
|
|
456
453
|
const filterQuery = shouldBypassFiltering ? '' : query;
|
|
457
454
|
const shouldIgnoreExternalFiltering = hasItems && hasFilteredItemsProp && shouldBypassFiltering;
|
|
@@ -600,12 +597,12 @@ function AriaCombobox(props) {
|
|
|
600
597
|
return fieldRawValue;
|
|
601
598
|
}
|
|
602
599
|
if (Array.isArray(selectedValue)) {
|
|
603
|
-
return selectedValue.map(value =>
|
|
600
|
+
return selectedValue.map(value => useCompositeListItem.stringifyAsValue(value, itemToStringValue));
|
|
604
601
|
}
|
|
605
|
-
return
|
|
602
|
+
return useCompositeListItem.stringifyAsValue(selectedValue, itemToStringValue);
|
|
606
603
|
}, [fieldRawValue, itemToStringValue, selectionMode, selectedValue]);
|
|
607
|
-
const onItemHighlighted =
|
|
608
|
-
const onOpenChangeComplete =
|
|
604
|
+
const onItemHighlighted = useScrollLock.useStableCallback(onItemHighlightedProp);
|
|
605
|
+
const onOpenChangeComplete = useScrollLock.useStableCallback(onOpenChangeCompleteProp);
|
|
609
606
|
const activeIndex = useScrollLock.useStore(store, selectors.activeIndex);
|
|
610
607
|
const selectedIndex = useScrollLock.useStore(store, selectors.selectedIndex);
|
|
611
608
|
const positionerElement = useScrollLock.useStore(store, selectors.positionerElement);
|
|
@@ -616,34 +613,34 @@ function AriaCombobox(props) {
|
|
|
616
613
|
const inline = useScrollLock.useStore(store, selectors.inline);
|
|
617
614
|
const inputInsidePopup = useScrollLock.useStore(store, selectors.inputInsidePopup);
|
|
618
615
|
const inputOwnsFormValue = useScrollLock.useStore(store, selectors.inputOwnsFormValue);
|
|
619
|
-
const triggerRef =
|
|
616
|
+
const triggerRef = useScrollLock.useValueAsRef(triggerElement);
|
|
620
617
|
const {
|
|
621
618
|
mounted,
|
|
622
619
|
setMounted,
|
|
623
620
|
transitionStatus
|
|
624
|
-
} =
|
|
621
|
+
} = useScrollLock.useTransitionStatus(open);
|
|
625
622
|
const {
|
|
626
623
|
openMethod,
|
|
627
624
|
triggerProps
|
|
628
625
|
} = useScrollLock.useOpenInteractionType(open);
|
|
629
|
-
const getStringifiedValueForForm =
|
|
630
|
-
|
|
631
|
-
const forceMount =
|
|
626
|
+
const getStringifiedValueForForm = useScrollLock.useStableCallback(() => fieldStringValue);
|
|
627
|
+
useCompositeListItem.useRegisterFieldControl(inputInsidePopup ? triggerRef : inputRef, id, fieldRawValue, getStringifiedValueForForm, !disabled, nameProp);
|
|
628
|
+
const forceMount = useScrollLock.useStableCallback(() => {
|
|
632
629
|
if (items) {
|
|
633
630
|
// Ensure typeahead works on a closed list.
|
|
634
|
-
labelsRef.current = flatFilteredItems.map(item =>
|
|
631
|
+
labelsRef.current = flatFilteredItems.map(item => useCompositeListItem.stringifyAsLabel(item, itemToStringLabel));
|
|
635
632
|
} else {
|
|
636
633
|
store.set('forceMounted', true);
|
|
637
634
|
}
|
|
638
635
|
});
|
|
639
636
|
const initialSelectedValueRef = React__namespace.useRef(selectedValue);
|
|
640
|
-
|
|
637
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
641
638
|
// Ensure the values and labels are registered for programmatic value changes.
|
|
642
639
|
if (selectedValue !== initialSelectedValueRef.current) {
|
|
643
640
|
forceMount();
|
|
644
641
|
}
|
|
645
642
|
}, [forceMount, selectedValue]);
|
|
646
|
-
const setIndices =
|
|
643
|
+
const setIndices = useScrollLock.useStableCallback(options => {
|
|
647
644
|
store.update(options);
|
|
648
645
|
const type = options.type || 'none';
|
|
649
646
|
if (options.activeIndex === undefined) {
|
|
@@ -652,7 +649,7 @@ function AriaCombobox(props) {
|
|
|
652
649
|
if (options.activeIndex === null) {
|
|
653
650
|
if (lastHighlightRef.current !== INITIAL_LAST_HIGHLIGHT) {
|
|
654
651
|
lastHighlightRef.current = INITIAL_LAST_HIGHLIGHT;
|
|
655
|
-
onItemHighlighted(undefined,
|
|
652
|
+
onItemHighlighted(undefined, useScrollLock.createGenericEventDetails(type, undefined, {
|
|
656
653
|
index: -1
|
|
657
654
|
}));
|
|
658
655
|
}
|
|
@@ -662,13 +659,13 @@ function AriaCombobox(props) {
|
|
|
662
659
|
value: activeValue,
|
|
663
660
|
index: options.activeIndex
|
|
664
661
|
};
|
|
665
|
-
onItemHighlighted(activeValue,
|
|
662
|
+
onItemHighlighted(activeValue, useScrollLock.createGenericEventDetails(type, undefined, {
|
|
666
663
|
index: options.activeIndex
|
|
667
664
|
}));
|
|
668
665
|
}
|
|
669
666
|
});
|
|
670
|
-
const setInputValue =
|
|
671
|
-
hadInputClearRef.current = eventDetails.reason ===
|
|
667
|
+
const setInputValue = useScrollLock.useStableCallback((next, eventDetails) => {
|
|
668
|
+
hadInputClearRef.current = eventDetails.reason === useScrollLock.inputClear;
|
|
672
669
|
props.onInputValueChange?.(next, eventDetails);
|
|
673
670
|
if (eventDetails.isCanceled) {
|
|
674
671
|
return;
|
|
@@ -676,7 +673,7 @@ function AriaCombobox(props) {
|
|
|
676
673
|
|
|
677
674
|
// If user is typing, ensure we don't auto-highlight on open due to a race
|
|
678
675
|
// with the post-open effect that sets this flag.
|
|
679
|
-
if (eventDetails.reason ===
|
|
676
|
+
if (eventDetails.reason === useScrollLock.inputChange) {
|
|
680
677
|
const event = eventDetails.event;
|
|
681
678
|
const inputType = event.inputType;
|
|
682
679
|
// Treat composition commits as typed input; autofill may omit `inputType` or
|
|
@@ -699,7 +696,7 @@ function AriaCombobox(props) {
|
|
|
699
696
|
}
|
|
700
697
|
setInputValueUnwrapped(next);
|
|
701
698
|
});
|
|
702
|
-
const setOpen =
|
|
699
|
+
const setOpen = useScrollLock.useStableCallback((nextOpen, eventDetails) => {
|
|
703
700
|
if (open === nextOpen) {
|
|
704
701
|
return;
|
|
705
702
|
}
|
|
@@ -721,7 +718,7 @@ function AriaCombobox(props) {
|
|
|
721
718
|
setQueryChangedAfterOpen(false);
|
|
722
719
|
setCloseQuery(null);
|
|
723
720
|
if (inputValue !== '') {
|
|
724
|
-
setInputValue('',
|
|
721
|
+
setInputValue('', useScrollLock.createChangeEventDetails(useScrollLock.inputClear, eventDetails.event));
|
|
725
722
|
}
|
|
726
723
|
}
|
|
727
724
|
if (!nextOpen && queryChangedAfterOpen) {
|
|
@@ -748,12 +745,12 @@ function AriaCombobox(props) {
|
|
|
748
745
|
// if the input is outside the popup. When the input is inside the popup, defer the clear until
|
|
749
746
|
// unmount so the filtered list doesn't flash to unfiltered during the exit animation.
|
|
750
747
|
if (!inputInsidePopup || inline) {
|
|
751
|
-
setInputValue('',
|
|
748
|
+
setInputValue('', useScrollLock.createChangeEventDetails(useScrollLock.inputClear, eventDetails.event));
|
|
752
749
|
}
|
|
753
750
|
}
|
|
754
751
|
}
|
|
755
752
|
setOpenUnwrapped(nextOpen);
|
|
756
|
-
if (!nextOpen && inputInsidePopup && (eventDetails.reason ===
|
|
753
|
+
if (!nextOpen && inputInsidePopup && (eventDetails.reason === useScrollLock.focusOut || eventDetails.reason === useScrollLock.outsidePress)) {
|
|
757
754
|
setTouched(true);
|
|
758
755
|
setFocused(false);
|
|
759
756
|
if (validationMode === 'onBlur') {
|
|
@@ -762,7 +759,7 @@ function AriaCombobox(props) {
|
|
|
762
759
|
}
|
|
763
760
|
}
|
|
764
761
|
});
|
|
765
|
-
const setSelectedValue =
|
|
762
|
+
const setSelectedValue = useScrollLock.useStableCallback((nextValue, eventDetails) => {
|
|
766
763
|
// Cast to `any` due to conditional value type (single vs. multiple).
|
|
767
764
|
// The runtime implementation already ensures the correct value shape.
|
|
768
765
|
onSelectedValueChange?.(nextValue, eventDetails);
|
|
@@ -772,13 +769,13 @@ function AriaCombobox(props) {
|
|
|
772
769
|
setSelectedValueUnwrapped(nextValue);
|
|
773
770
|
const shouldFillInput = selectionMode === 'none' && popupRef.current && fillInputOnItemPress || single && !store.state.inputInsidePopup;
|
|
774
771
|
if (shouldFillInput) {
|
|
775
|
-
setInputValue(
|
|
772
|
+
setInputValue(useCompositeListItem.stringifyAsLabel(nextValue, itemToStringLabel), useScrollLock.createChangeEventDetails(eventDetails.reason, eventDetails.event));
|
|
776
773
|
}
|
|
777
|
-
if (single && nextValue != null && eventDetails.reason !==
|
|
774
|
+
if (single && nextValue != null && eventDetails.reason !== useScrollLock.inputChange && queryChangedAfterOpen && !inline) {
|
|
778
775
|
setCloseQuery(query);
|
|
779
776
|
}
|
|
780
777
|
});
|
|
781
|
-
const handleSelection =
|
|
778
|
+
const handleSelection = useScrollLock.useStableCallback((event, passedValue) => {
|
|
782
779
|
let itemValue = passedValue;
|
|
783
780
|
if (itemValue === undefined) {
|
|
784
781
|
if (activeIndex === null) {
|
|
@@ -786,10 +783,10 @@ function AriaCombobox(props) {
|
|
|
786
783
|
}
|
|
787
784
|
itemValue = valuesRef.current[activeIndex];
|
|
788
785
|
}
|
|
789
|
-
const targetEl =
|
|
786
|
+
const targetEl = useScrollLock.getTarget(event);
|
|
790
787
|
const overrideEvent = selectionEventRef.current ?? event;
|
|
791
788
|
selectionEventRef.current = null;
|
|
792
|
-
const eventDetails =
|
|
789
|
+
const eventDetails = useScrollLock.createChangeEventDetails(useScrollLock.itemPress, overrideEvent);
|
|
793
790
|
|
|
794
791
|
// Let the link handle the click.
|
|
795
792
|
const href = targetEl?.closest('a')?.getAttribute('href');
|
|
@@ -801,8 +798,8 @@ function AriaCombobox(props) {
|
|
|
801
798
|
}
|
|
802
799
|
if (multiple) {
|
|
803
800
|
const currentSelectedValue = Array.isArray(selectedValue) ? selectedValue : [];
|
|
804
|
-
const isCurrentlySelected =
|
|
805
|
-
const nextValue = isCurrentlySelected ?
|
|
801
|
+
const isCurrentlySelected = useCompositeListItem.selectedValueIncludes(currentSelectedValue, itemValue, store.state.isItemEqualToValue);
|
|
802
|
+
const nextValue = isCurrentlySelected ? useCompositeListItem.removeItem(currentSelectedValue, itemValue, store.state.isItemEqualToValue) : [...currentSelectedValue, itemValue];
|
|
806
803
|
setSelectedValue(nextValue, eventDetails);
|
|
807
804
|
if (eventDetails.isCanceled) {
|
|
808
805
|
return;
|
|
@@ -812,7 +809,7 @@ function AriaCombobox(props) {
|
|
|
812
809
|
return;
|
|
813
810
|
}
|
|
814
811
|
if (store.state.inputInsidePopup) {
|
|
815
|
-
setInputValue('',
|
|
812
|
+
setInputValue('', useScrollLock.createChangeEventDetails(useScrollLock.inputClear, eventDetails.event));
|
|
816
813
|
} else {
|
|
817
814
|
setOpen(false, eventDetails);
|
|
818
815
|
}
|
|
@@ -824,7 +821,7 @@ function AriaCombobox(props) {
|
|
|
824
821
|
setOpen(false, eventDetails);
|
|
825
822
|
}
|
|
826
823
|
});
|
|
827
|
-
const requestSubmit =
|
|
824
|
+
const requestSubmit = useScrollLock.useStableCallback(() => {
|
|
828
825
|
if (!store.state.submitOnItemClick) {
|
|
829
826
|
return;
|
|
830
827
|
}
|
|
@@ -833,7 +830,7 @@ function AriaCombobox(props) {
|
|
|
833
830
|
formElement.requestSubmit();
|
|
834
831
|
}
|
|
835
832
|
});
|
|
836
|
-
const handleUnmount =
|
|
833
|
+
const handleUnmount = useScrollLock.useStableCallback(() => {
|
|
837
834
|
setMounted(false);
|
|
838
835
|
onOpenChangeComplete?.(false);
|
|
839
836
|
setQueryChangedAfterOpen(false);
|
|
@@ -853,7 +850,7 @@ function AriaCombobox(props) {
|
|
|
853
850
|
// If the user typed a filter and didn't select in multiple mode, clear the input
|
|
854
851
|
// after close completes to avoid mid-exit flicker and start fresh on next open.
|
|
855
852
|
if (multiple && inputRef.current && inputRef.current.value !== '' && !hadInputClearRef.current) {
|
|
856
|
-
setInputValue('',
|
|
853
|
+
setInputValue('', useScrollLock.createChangeEventDetails(useScrollLock.inputClear));
|
|
857
854
|
}
|
|
858
855
|
|
|
859
856
|
// Single selection mode:
|
|
@@ -862,14 +859,14 @@ function AriaCombobox(props) {
|
|
|
862
859
|
if (single) {
|
|
863
860
|
if (store.state.inputInsidePopup) {
|
|
864
861
|
if (inputRef.current && inputRef.current.value !== '') {
|
|
865
|
-
setInputValue('',
|
|
862
|
+
setInputValue('', useScrollLock.createChangeEventDetails(useScrollLock.inputClear));
|
|
866
863
|
}
|
|
867
864
|
} else {
|
|
868
|
-
const stringVal =
|
|
865
|
+
const stringVal = useCompositeListItem.stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
869
866
|
if (inputRef.current && inputRef.current.value !== stringVal) {
|
|
870
867
|
// If no selection was made, treat this as clearing the typed filter.
|
|
871
|
-
const reason = stringVal === '' ?
|
|
872
|
-
setInputValue(stringVal,
|
|
868
|
+
const reason = stringVal === '' ? useScrollLock.inputClear : useScrollLock.none;
|
|
869
|
+
setInputValue(stringVal, useScrollLock.createChangeEventDetails(reason));
|
|
873
870
|
}
|
|
874
871
|
}
|
|
875
872
|
}
|
|
@@ -887,7 +884,7 @@ function AriaCombobox(props) {
|
|
|
887
884
|
}
|
|
888
885
|
return popupRef;
|
|
889
886
|
}, [inline, positionerElement]);
|
|
890
|
-
|
|
887
|
+
useScrollLock.useOpenChangeComplete({
|
|
891
888
|
enabled: !props.actionsRef,
|
|
892
889
|
open,
|
|
893
890
|
ref: resolvedPopupRef,
|
|
@@ -900,7 +897,7 @@ function AriaCombobox(props) {
|
|
|
900
897
|
React__namespace.useImperativeHandle(props.actionsRef, () => ({
|
|
901
898
|
unmount: handleUnmount
|
|
902
899
|
}), [handleUnmount]);
|
|
903
|
-
|
|
900
|
+
useScrollLock.useIsoLayoutEffect(function syncSelectedIndex() {
|
|
904
901
|
if (open || selectionMode === 'none') {
|
|
905
902
|
return;
|
|
906
903
|
}
|
|
@@ -908,24 +905,24 @@ function AriaCombobox(props) {
|
|
|
908
905
|
if (multiple) {
|
|
909
906
|
const currentValue = Array.isArray(selectedValue) ? selectedValue : [];
|
|
910
907
|
const lastValue = currentValue[currentValue.length - 1];
|
|
911
|
-
const lastIndex =
|
|
908
|
+
const lastIndex = useCompositeListItem.findItemIndex(registry, lastValue, isItemEqualToValue);
|
|
912
909
|
setIndices({
|
|
913
910
|
selectedIndex: lastIndex === -1 ? null : lastIndex
|
|
914
911
|
});
|
|
915
912
|
} else {
|
|
916
|
-
const index =
|
|
913
|
+
const index = useCompositeListItem.findItemIndex(registry, selectedValue, isItemEqualToValue);
|
|
917
914
|
setIndices({
|
|
918
915
|
selectedIndex: index === -1 ? null : index
|
|
919
916
|
});
|
|
920
917
|
}
|
|
921
918
|
}, [open, selectedValue, items, selectionMode, flatItems, multiple, isItemEqualToValue, setIndices]);
|
|
922
|
-
|
|
919
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
923
920
|
if (items) {
|
|
924
921
|
valuesRef.current = flatFilteredItems;
|
|
925
922
|
listRef.current.length = flatFilteredItems.length;
|
|
926
923
|
}
|
|
927
924
|
}, [items, flatFilteredItems]);
|
|
928
|
-
|
|
925
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
929
926
|
const pendingHighlight = pendingQueryHighlightRef.current;
|
|
930
927
|
if (pendingHighlight) {
|
|
931
928
|
if (pendingHighlight.hasQuery) {
|
|
@@ -950,7 +947,7 @@ function AriaCombobox(props) {
|
|
|
950
947
|
}
|
|
951
948
|
if (lastHighlightRef.current !== INITIAL_LAST_HIGHLIGHT) {
|
|
952
949
|
lastHighlightRef.current = INITIAL_LAST_HIGHLIGHT;
|
|
953
|
-
store.state.onItemHighlighted(undefined,
|
|
950
|
+
store.state.onItemHighlighted(undefined, useScrollLock.createGenericEventDetails(useScrollLock.none, undefined, {
|
|
954
951
|
index: -1
|
|
955
952
|
}));
|
|
956
953
|
}
|
|
@@ -959,7 +956,7 @@ function AriaCombobox(props) {
|
|
|
959
956
|
if (storeActiveIndex >= candidateItems.length) {
|
|
960
957
|
if (lastHighlightRef.current !== INITIAL_LAST_HIGHLIGHT) {
|
|
961
958
|
lastHighlightRef.current = INITIAL_LAST_HIGHLIGHT;
|
|
962
|
-
store.state.onItemHighlighted(undefined,
|
|
959
|
+
store.state.onItemHighlighted(undefined, useScrollLock.createGenericEventDetails(useScrollLock.none, undefined, {
|
|
963
960
|
index: -1
|
|
964
961
|
}));
|
|
965
962
|
}
|
|
@@ -968,18 +965,18 @@ function AriaCombobox(props) {
|
|
|
968
965
|
}
|
|
969
966
|
const itemValue = candidateItems[storeActiveIndex];
|
|
970
967
|
const previouslyHighlightedItemValue = lastHighlightRef.current.value;
|
|
971
|
-
const isSameItem = previouslyHighlightedItemValue !== NO_ACTIVE_VALUE &&
|
|
968
|
+
const isSameItem = previouslyHighlightedItemValue !== NO_ACTIVE_VALUE && useCompositeListItem.compareItemEquality(itemValue, previouslyHighlightedItemValue, store.state.isItemEqualToValue);
|
|
972
969
|
if (lastHighlightRef.current.index !== storeActiveIndex || !isSameItem) {
|
|
973
970
|
lastHighlightRef.current = {
|
|
974
971
|
value: itemValue,
|
|
975
972
|
index: storeActiveIndex
|
|
976
973
|
};
|
|
977
|
-
store.state.onItemHighlighted(itemValue,
|
|
974
|
+
store.state.onItemHighlighted(itemValue, useScrollLock.createGenericEventDetails(useScrollLock.none, undefined, {
|
|
978
975
|
index: storeActiveIndex
|
|
979
976
|
}));
|
|
980
977
|
}
|
|
981
978
|
}, [activeIndex, autoHighlightMode, hasFilteredItemsProp, hasItems, flatFilteredItems, inline, open, store]);
|
|
982
|
-
|
|
979
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
983
980
|
if (selectionMode === 'none') {
|
|
984
981
|
setFilled(String(inputValue) !== '');
|
|
985
982
|
return;
|
|
@@ -999,17 +996,17 @@ function AriaCombobox(props) {
|
|
|
999
996
|
function isSelectedValueDirty(value) {
|
|
1000
997
|
const initialValue = validityData.initialValue;
|
|
1001
998
|
if (Array.isArray(value) && Array.isArray(initialValue)) {
|
|
1002
|
-
return !
|
|
999
|
+
return !useCompositeListItem.areArraysEqual(value, initialValue, (itemValue, initialItemValue) => useCompositeListItem.compareItemEquality(itemValue, initialItemValue, isItemEqualToValue));
|
|
1003
1000
|
}
|
|
1004
1001
|
return value !== initialValue;
|
|
1005
1002
|
}
|
|
1006
|
-
|
|
1003
|
+
useScrollLock.useValueChanged(query, () => {
|
|
1007
1004
|
if (!open || query === '' || query === String(initialDefaultInputValue)) {
|
|
1008
1005
|
return;
|
|
1009
1006
|
}
|
|
1010
1007
|
setQueryChangedAfterOpen(true);
|
|
1011
1008
|
});
|
|
1012
|
-
|
|
1009
|
+
useScrollLock.useValueChanged(selectedValue, () => {
|
|
1013
1010
|
if (selectionMode === 'none') {
|
|
1014
1011
|
return;
|
|
1015
1012
|
}
|
|
@@ -1017,13 +1014,13 @@ function AriaCombobox(props) {
|
|
|
1017
1014
|
setDirty(isSelectedValueDirty(selectedValue));
|
|
1018
1015
|
validation.change(selectedValue);
|
|
1019
1016
|
if (single && !hasInputValue && !inputInsidePopup) {
|
|
1020
|
-
const nextInputValue =
|
|
1017
|
+
const nextInputValue = useCompositeListItem.stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
1021
1018
|
if (inputValue !== nextInputValue) {
|
|
1022
|
-
setInputValue(nextInputValue,
|
|
1019
|
+
setInputValue(nextInputValue, useScrollLock.createChangeEventDetails(useScrollLock.none));
|
|
1023
1020
|
}
|
|
1024
1021
|
}
|
|
1025
1022
|
});
|
|
1026
|
-
|
|
1023
|
+
useScrollLock.useValueChanged(inputValue, () => {
|
|
1027
1024
|
if (selectionMode !== 'none') {
|
|
1028
1025
|
return;
|
|
1029
1026
|
}
|
|
@@ -1031,13 +1028,13 @@ function AriaCombobox(props) {
|
|
|
1031
1028
|
setDirty(inputValue !== validityData.initialValue);
|
|
1032
1029
|
validation.change(inputValue);
|
|
1033
1030
|
});
|
|
1034
|
-
|
|
1031
|
+
useScrollLock.useValueChanged(items, () => {
|
|
1035
1032
|
if (!single || hasInputValue || inputInsidePopup || queryChangedAfterOpen) {
|
|
1036
1033
|
return;
|
|
1037
1034
|
}
|
|
1038
|
-
const nextInputValue =
|
|
1035
|
+
const nextInputValue = useCompositeListItem.stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
1039
1036
|
if (inputValue !== nextInputValue) {
|
|
1040
|
-
setInputValue(nextInputValue,
|
|
1037
|
+
setInputValue(nextInputValue, useScrollLock.createChangeEventDetails(useScrollLock.none));
|
|
1041
1038
|
}
|
|
1042
1039
|
});
|
|
1043
1040
|
const floatingRootContext = useCompositeListItem.useFloatingRootContext({
|
|
@@ -1087,7 +1084,7 @@ function AriaCombobox(props) {
|
|
|
1087
1084
|
// Apply a small delay for touch to let mobile viewport/keyboard positioning settle.
|
|
1088
1085
|
// This avoids top-bottom flip flickers if the preferred position is "top" when first tapping.
|
|
1089
1086
|
touchOpenDelay: inputInsidePopup ? 0 : 100,
|
|
1090
|
-
reason:
|
|
1087
|
+
reason: useScrollLock.inputPress
|
|
1091
1088
|
});
|
|
1092
1089
|
const dismiss = useScrollLock.useDismiss(floatingRootContext, {
|
|
1093
1090
|
enabled: !readOnly && !disabled && !inline,
|
|
@@ -1101,8 +1098,8 @@ function AriaCombobox(props) {
|
|
|
1101
1098
|
// Without a popup, let the Escape key bubble the event up to other popups' handlers.
|
|
1102
1099
|
bubbles: inline ? true : undefined,
|
|
1103
1100
|
outsidePress(event) {
|
|
1104
|
-
const target =
|
|
1105
|
-
return !
|
|
1101
|
+
const target = useScrollLock.getTarget(event);
|
|
1102
|
+
return !useScrollLock.contains(triggerElement, target) && !useScrollLock.contains(clearRef.current, target) && !useScrollLock.contains(chipsContainerRef.current, target) && !useScrollLock.contains(inputGroupElement, target);
|
|
1106
1103
|
}
|
|
1107
1104
|
});
|
|
1108
1105
|
const listNavigation = useCompositeListItem.useListNavigation(floatingRootContext, {
|
|
@@ -1179,7 +1176,7 @@ function AriaCombobox(props) {
|
|
|
1179
1176
|
requestSubmit
|
|
1180
1177
|
});
|
|
1181
1178
|
});
|
|
1182
|
-
|
|
1179
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
1183
1180
|
store.update({
|
|
1184
1181
|
id,
|
|
1185
1182
|
selectedValue,
|
|
@@ -1225,7 +1222,7 @@ function AriaCombobox(props) {
|
|
|
1225
1222
|
if (Array.isArray(fieldRawValue)) {
|
|
1226
1223
|
return '';
|
|
1227
1224
|
}
|
|
1228
|
-
return
|
|
1225
|
+
return useCompositeListItem.stringifyAsValue(fieldRawValue, itemToStringValue);
|
|
1229
1226
|
}, [fieldRawValue, itemToStringValue]);
|
|
1230
1227
|
const hasMultipleSelection = multiple && Array.isArray(selectedValue) && selectedValue.length > 0;
|
|
1231
1228
|
const hiddenInputName = multiple || selectionMode === 'none' && inputOwnsFormValue ? undefined : name;
|
|
@@ -1234,7 +1231,7 @@ function AriaCombobox(props) {
|
|
|
1234
1231
|
return null;
|
|
1235
1232
|
}
|
|
1236
1233
|
return selectedValue.map(value => {
|
|
1237
|
-
const currentSerializedValue =
|
|
1234
|
+
const currentSerializedValue = useCompositeListItem.stringifyAsValue(value, itemToStringValue);
|
|
1238
1235
|
return /*#__PURE__*/jsxRuntime.jsx("input", {
|
|
1239
1236
|
type: "hidden",
|
|
1240
1237
|
form: form,
|
|
@@ -1263,8 +1260,8 @@ function AriaCombobox(props) {
|
|
|
1263
1260
|
}
|
|
1264
1261
|
const nextValue = event.currentTarget.value;
|
|
1265
1262
|
const nextValueLower = nextValue.toLowerCase();
|
|
1266
|
-
const details =
|
|
1267
|
-
const findSerializedMatchIndex = () => valuesRef.current.findIndex(candidate =>
|
|
1263
|
+
const details = useScrollLock.createChangeEventDetails(useScrollLock.none, event.nativeEvent);
|
|
1264
|
+
const findSerializedMatchIndex = () => valuesRef.current.findIndex(candidate => useCompositeListItem.stringifyAsValue(candidate, itemToStringValue).toLowerCase() === nextValueLower || useCompositeListItem.stringifyAsLabel(candidate, itemToStringLabel).toLowerCase() === nextValueLower);
|
|
1268
1265
|
function handleChange() {
|
|
1269
1266
|
// Browser autofill only writes a single scalar value.
|
|
1270
1267
|
if (multiple) {
|
|
@@ -1317,7 +1314,7 @@ function AriaCombobox(props) {
|
|
|
1317
1314
|
readOnly: readOnly,
|
|
1318
1315
|
value: serializedValue,
|
|
1319
1316
|
ref: hiddenInputRef,
|
|
1320
|
-
style: hiddenInputName ?
|
|
1317
|
+
style: hiddenInputName ? useScrollLock.visuallyHiddenInput : useScrollLock.visuallyHidden,
|
|
1321
1318
|
tabIndex: -1,
|
|
1322
1319
|
"aria-hidden": true,
|
|
1323
1320
|
suppressHydrationWarning: true
|
|
@@ -1343,7 +1340,7 @@ function AriaCombobox(props) {
|
|
|
1343
1340
|
|
|
1344
1341
|
const triggerStateAttributesMapping = {
|
|
1345
1342
|
...useScrollLock.pressableTriggerOpenStateMapping,
|
|
1346
|
-
...
|
|
1343
|
+
...useCompositeListItem.fieldValidityMapping,
|
|
1347
1344
|
popupSide: side => side ? {
|
|
1348
1345
|
'data-popup-side': side
|
|
1349
1346
|
} : null,
|
|
@@ -1377,10 +1374,10 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1377
1374
|
setFocused,
|
|
1378
1375
|
validationMode,
|
|
1379
1376
|
validation
|
|
1380
|
-
} =
|
|
1377
|
+
} = useCompositeListItem.useFieldRootContext();
|
|
1381
1378
|
const {
|
|
1382
1379
|
labelId: fieldLabelId
|
|
1383
|
-
} =
|
|
1380
|
+
} = useCompositeListItem.useLabelableContext();
|
|
1384
1381
|
const store = useComboboxRootContext();
|
|
1385
1382
|
const {
|
|
1386
1383
|
filteredItems
|
|
@@ -1406,15 +1403,15 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1406
1403
|
const hasSelectedValue = useScrollLock.useStore(store, selectors.hasSelectedValue);
|
|
1407
1404
|
const floatingRootContext = useComboboxFloatingContext();
|
|
1408
1405
|
const inputValue = useComboboxInputValueContext();
|
|
1409
|
-
const focusTimeout =
|
|
1406
|
+
const focusTimeout = useScrollLock.useTimeout();
|
|
1410
1407
|
const disabled = fieldDisabled || comboboxDisabled || disabledProp;
|
|
1411
1408
|
const listEmpty = filteredItems.length === 0;
|
|
1412
1409
|
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
1413
|
-
|
|
1410
|
+
useCompositeListItem.useLabelableId({
|
|
1414
1411
|
id: inputInsidePopup ? idProp : undefined
|
|
1415
1412
|
});
|
|
1416
1413
|
const id = inputInsidePopup ? idProp ?? rootId : idProp;
|
|
1417
|
-
const ariaLabelledBy =
|
|
1414
|
+
const ariaLabelledBy = useCompositeListItem.resolveAriaLabelledBy(fieldLabelId, comboboxLabelId);
|
|
1418
1415
|
let ariaControls;
|
|
1419
1416
|
if (open && inputInsidePopup) {
|
|
1420
1417
|
// Fall back to the default id while the popup registers its own (custom ids are stored once the
|
|
@@ -1449,7 +1446,7 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1449
1446
|
onMatch(index) {
|
|
1450
1447
|
const nextSelectedValue = store.state.valuesRef.current[index];
|
|
1451
1448
|
if (nextSelectedValue !== undefined) {
|
|
1452
|
-
store.state.setSelectedValue(nextSelectedValue,
|
|
1449
|
+
store.state.setSelectedValue(nextSelectedValue, useScrollLock.createChangeEventDetails('none'));
|
|
1453
1450
|
}
|
|
1454
1451
|
}
|
|
1455
1452
|
});
|
|
@@ -1462,7 +1459,7 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1462
1459
|
const {
|
|
1463
1460
|
buttonRef,
|
|
1464
1461
|
getButtonProps
|
|
1465
|
-
} =
|
|
1462
|
+
} = useScrollLock.useButton({
|
|
1466
1463
|
native: nativeButton,
|
|
1467
1464
|
disabled
|
|
1468
1465
|
});
|
|
@@ -1474,7 +1471,7 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1474
1471
|
listEmpty,
|
|
1475
1472
|
placeholder: selectionMode === 'none' ? false : !hasSelectedValue
|
|
1476
1473
|
};
|
|
1477
|
-
const setTriggerElement =
|
|
1474
|
+
const setTriggerElement = useScrollLock.useStableCallback(element => {
|
|
1478
1475
|
store.set('triggerElement', element);
|
|
1479
1476
|
});
|
|
1480
1477
|
const element = useRenderElement.useRenderElement('button', componentProps, {
|
|
@@ -1500,7 +1497,7 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1500
1497
|
},
|
|
1501
1498
|
onBlur(event) {
|
|
1502
1499
|
// If focus is moving into the popup, don't count it as a blur.
|
|
1503
|
-
if (
|
|
1500
|
+
if (useScrollLock.contains(positionerElement, event.relatedTarget)) {
|
|
1504
1501
|
return;
|
|
1505
1502
|
}
|
|
1506
1503
|
setTouched(true);
|
|
@@ -1529,15 +1526,15 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1529
1526
|
if (open) {
|
|
1530
1527
|
return;
|
|
1531
1528
|
}
|
|
1532
|
-
const doc =
|
|
1529
|
+
const doc = useScrollLock.ownerDocument(event.currentTarget);
|
|
1533
1530
|
function handleMouseUp(mouseEvent) {
|
|
1534
1531
|
if (!triggerElement) {
|
|
1535
1532
|
return;
|
|
1536
1533
|
}
|
|
1537
|
-
const mouseUpTarget =
|
|
1534
|
+
const mouseUpTarget = useScrollLock.getTarget(mouseEvent);
|
|
1538
1535
|
const positioner = store.state.positionerElement;
|
|
1539
1536
|
const list = store.state.listElement;
|
|
1540
|
-
if (
|
|
1537
|
+
if (useScrollLock.contains(triggerElement, mouseUpTarget) || useScrollLock.contains(positioner, mouseUpTarget) || useScrollLock.contains(list, mouseUpTarget) || mouseUpTarget === triggerElement) {
|
|
1541
1538
|
return;
|
|
1542
1539
|
}
|
|
1543
1540
|
const bounds = useCompositeListItem.getPseudoElementBounds(triggerElement);
|
|
@@ -1546,7 +1543,7 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1546
1543
|
if (withinHorizontal && withinVertical) {
|
|
1547
1544
|
return;
|
|
1548
1545
|
}
|
|
1549
|
-
store.state.setOpen(false,
|
|
1546
|
+
store.state.setOpen(false, useScrollLock.createChangeEventDetails('cancel-open', mouseEvent));
|
|
1550
1547
|
}
|
|
1551
1548
|
if (inputInsidePopup) {
|
|
1552
1549
|
doc.addEventListener('mouseup', handleMouseUp, {
|
|
@@ -1559,8 +1556,8 @@ const ComboboxTrigger = /*#__PURE__*/React__namespace.forwardRef(function Combob
|
|
|
1559
1556
|
return;
|
|
1560
1557
|
}
|
|
1561
1558
|
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
1562
|
-
|
|
1563
|
-
store.state.setOpen(true,
|
|
1559
|
+
useScrollLock.stopEvent(event);
|
|
1560
|
+
store.state.setOpen(true, useScrollLock.createChangeEventDetails(useScrollLock.listNavigation, event.nativeEvent));
|
|
1564
1561
|
store.state.inputRef.current?.focus();
|
|
1565
1562
|
}
|
|
1566
1563
|
}
|
|
@@ -1595,12 +1592,12 @@ const ComboboxInternalDismissButton = /*#__PURE__*/React__namespace.forwardRef(f
|
|
|
1595
1592
|
const {
|
|
1596
1593
|
buttonRef,
|
|
1597
1594
|
getButtonProps
|
|
1598
|
-
} =
|
|
1595
|
+
} = useScrollLock.useButton({
|
|
1599
1596
|
native: false
|
|
1600
1597
|
});
|
|
1601
1598
|
const mergedRef = useRenderElement.useMergedRefs(forwardedRef, buttonRef);
|
|
1602
1599
|
function handleDismiss(event) {
|
|
1603
|
-
store.state.setOpen(false,
|
|
1600
|
+
store.state.setOpen(false, useScrollLock.createChangeEventDetails(useScrollLock.closePress, event.nativeEvent, event.currentTarget));
|
|
1604
1601
|
}
|
|
1605
1602
|
const dismissProps = getButtonProps({
|
|
1606
1603
|
onClick: handleDismiss
|
|
@@ -1610,7 +1607,7 @@ const ComboboxInternalDismissButton = /*#__PURE__*/React__namespace.forwardRef(f
|
|
|
1610
1607
|
...dismissProps,
|
|
1611
1608
|
"aria-label": "Dismiss",
|
|
1612
1609
|
tabIndex: undefined,
|
|
1613
|
-
style:
|
|
1610
|
+
style: useScrollLock.visuallyHiddenInput
|
|
1614
1611
|
});
|
|
1615
1612
|
});
|
|
1616
1613
|
if (process.env.NODE_ENV !== "production") ComboboxInternalDismissButton.displayName = "ComboboxInternalDismissButton";
|
|
@@ -1631,10 +1628,10 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1631
1628
|
setFocused,
|
|
1632
1629
|
validationMode,
|
|
1633
1630
|
validation
|
|
1634
|
-
} =
|
|
1631
|
+
} = useCompositeListItem.useFieldRootContext();
|
|
1635
1632
|
const {
|
|
1636
1633
|
labelId: fieldLabelId
|
|
1637
|
-
} =
|
|
1634
|
+
} = useCompositeListItem.useLabelableContext();
|
|
1638
1635
|
const comboboxChipsContext = useComboboxChipsContext();
|
|
1639
1636
|
const positioning = useComboboxPositionerContext(true);
|
|
1640
1637
|
const hasPositionerParent = Boolean(positioning);
|
|
@@ -1669,18 +1666,18 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1669
1666
|
const listEmpty = filteredItems.length === 0;
|
|
1670
1667
|
const isInsidePopup = hasPositionerParent || inline;
|
|
1671
1668
|
const focusManagerModal = !isInsidePopup || modal;
|
|
1672
|
-
const id =
|
|
1673
|
-
const ariaLabelledBy =
|
|
1674
|
-
const fieldStateForInput = hasPositionerParent ?
|
|
1669
|
+
const id = useScrollLock.useBaseUiId(idProp ?? (!isInsidePopup ? rootId : undefined));
|
|
1670
|
+
const ariaLabelledBy = useCompositeListItem.resolveAriaLabelledBy(fieldLabelId, undefined);
|
|
1671
|
+
const fieldStateForInput = hasPositionerParent ? useCompositeListItem.DEFAULT_FIELD_STATE_ATTRIBUTES : fieldState;
|
|
1675
1672
|
const [composingValue, setComposingValue] = React__namespace.useState(null);
|
|
1676
1673
|
const isComposingRef = React__namespace.useRef(false);
|
|
1677
1674
|
const lastActiveIndexRef = React__namespace.useRef(null);
|
|
1678
1675
|
const shouldRestoreActiveIndexRef = React__namespace.useRef(false);
|
|
1679
1676
|
const inputOwnsFormValue = selectionMode === 'none' && !hasPositionerParent;
|
|
1680
|
-
const setInputElement =
|
|
1677
|
+
const setInputElement = useScrollLock.useStableCallback(element => {
|
|
1681
1678
|
const nextIsInsidePopup = hasPositionerParent || store.state.inline;
|
|
1682
1679
|
if (nextIsInsidePopup && !store.state.hasInputValue) {
|
|
1683
|
-
store.state.setInputValue('',
|
|
1680
|
+
store.state.setInputValue('', useScrollLock.createChangeEventDetails(useScrollLock.none));
|
|
1684
1681
|
}
|
|
1685
1682
|
store.update({
|
|
1686
1683
|
inputElement: element,
|
|
@@ -1803,7 +1800,7 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1803
1800
|
}
|
|
1804
1801
|
},
|
|
1805
1802
|
onCompositionStart(event) {
|
|
1806
|
-
if (
|
|
1803
|
+
if (useScrollLock.android) {
|
|
1807
1804
|
return;
|
|
1808
1805
|
}
|
|
1809
1806
|
isComposingRef.current = true;
|
|
@@ -1813,7 +1810,7 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1813
1810
|
isComposingRef.current = false;
|
|
1814
1811
|
const next = event.currentTarget.value;
|
|
1815
1812
|
setComposingValue(null);
|
|
1816
|
-
store.state.setInputValue(next,
|
|
1813
|
+
store.state.setInputValue(next, useScrollLock.createChangeEventDetails(useScrollLock.inputChange, event.nativeEvent));
|
|
1817
1814
|
},
|
|
1818
1815
|
onChange(event) {
|
|
1819
1816
|
// Autofill may not provide `inputType` (Chrome) or may report
|
|
@@ -1832,13 +1829,13 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1832
1829
|
const nextVal = event.currentTarget.value;
|
|
1833
1830
|
setComposingValue(nextVal);
|
|
1834
1831
|
if (nextVal === '' && !store.state.openOnInputClick && !store.state.inputInsidePopup) {
|
|
1835
|
-
store.state.setOpen(false,
|
|
1832
|
+
store.state.setOpen(false, useScrollLock.createChangeEventDetails(useScrollLock.inputClear, event.nativeEvent));
|
|
1836
1833
|
}
|
|
1837
1834
|
const trimmed = nextVal.trim();
|
|
1838
1835
|
const shouldMaintainHighlight = autoHighlightEnabled && trimmed !== '';
|
|
1839
1836
|
if (!readOnly && !disabled && trimmed) {
|
|
1840
1837
|
if (shouldOpenOnInput) {
|
|
1841
|
-
store.state.setOpen(true,
|
|
1838
|
+
store.state.setOpen(true, useScrollLock.createChangeEventDetails(useScrollLock.inputChange, event.nativeEvent));
|
|
1842
1839
|
if (!autoHighlightEnabled) {
|
|
1843
1840
|
store.state.setIndices({
|
|
1844
1841
|
activeIndex: null,
|
|
@@ -1857,13 +1854,13 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1857
1854
|
}
|
|
1858
1855
|
return;
|
|
1859
1856
|
}
|
|
1860
|
-
const inputChangeDetails =
|
|
1857
|
+
const inputChangeDetails = useScrollLock.createChangeEventDetails(useScrollLock.inputChange, event.nativeEvent);
|
|
1861
1858
|
store.state.setInputValue(event.currentTarget.value, inputChangeDetails);
|
|
1862
1859
|
if (inputChangeDetails.isCanceled) {
|
|
1863
1860
|
return;
|
|
1864
1861
|
}
|
|
1865
1862
|
const empty = event.currentTarget.value === '';
|
|
1866
|
-
const clearDetails =
|
|
1863
|
+
const clearDetails = useScrollLock.createChangeEventDetails(useScrollLock.inputClear, event.nativeEvent);
|
|
1867
1864
|
if (empty && !store.state.inputInsidePopup) {
|
|
1868
1865
|
if (selectionMode === 'single') {
|
|
1869
1866
|
store.state.setSelectedValue(null, clearDetails);
|
|
@@ -1875,7 +1872,7 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1875
1872
|
const trimmed = event.currentTarget.value.trim();
|
|
1876
1873
|
if (!readOnly && !disabled && trimmed) {
|
|
1877
1874
|
if (shouldOpenOnInput) {
|
|
1878
|
-
store.state.setOpen(true,
|
|
1875
|
+
store.state.setOpen(true, useScrollLock.createChangeEventDetails(useScrollLock.inputChange, event.nativeEvent));
|
|
1879
1876
|
// When autoHighlight is enabled, keep the highlight (will be set to 0 in root).
|
|
1880
1877
|
if (!autoHighlightEnabled) {
|
|
1881
1878
|
store.state.setIndices({
|
|
@@ -1910,14 +1907,14 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1910
1907
|
const scrollAmount = input.scrollWidth - input.clientWidth;
|
|
1911
1908
|
const isRTL = direction === 'rtl';
|
|
1912
1909
|
if (event.key === 'Home') {
|
|
1913
|
-
|
|
1910
|
+
useScrollLock.stopEvent(event);
|
|
1914
1911
|
const cursor = useScrollLock.gecko && isRTL ? input.value.length : 0;
|
|
1915
1912
|
input.setSelectionRange(cursor, cursor);
|
|
1916
1913
|
input.scrollLeft = 0;
|
|
1917
1914
|
return;
|
|
1918
1915
|
}
|
|
1919
1916
|
if (event.key === 'End') {
|
|
1920
|
-
|
|
1917
|
+
useScrollLock.stopEvent(event);
|
|
1921
1918
|
const cursor = useScrollLock.gecko && isRTL ? 0 : input.value.length;
|
|
1922
1919
|
input.setSelectionRange(cursor, cursor);
|
|
1923
1920
|
input.scrollLeft = isRTL ? -scrollAmount : scrollAmount;
|
|
@@ -1925,7 +1922,7 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1925
1922
|
}
|
|
1926
1923
|
if (!mounted && event.key === 'Escape') {
|
|
1927
1924
|
const isClear = selectionMode === 'multiple' && Array.isArray(selectedValue) ? selectedValue.length === 0 : selectedValue === null;
|
|
1928
|
-
const details =
|
|
1925
|
+
const details = useScrollLock.createChangeEventDetails(useScrollLock.escapeKey, event.nativeEvent);
|
|
1929
1926
|
const value = selectionMode === 'multiple' ? [] : null;
|
|
1930
1927
|
store.state.setInputValue('', details);
|
|
1931
1928
|
store.state.setSelectedValue(value, details);
|
|
@@ -1946,7 +1943,7 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1946
1943
|
selectedIndex: null,
|
|
1947
1944
|
type: store.state.keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
1948
1945
|
});
|
|
1949
|
-
store.state.setSelectedValue(newValue,
|
|
1946
|
+
store.state.setSelectedValue(newValue, useScrollLock.createChangeEventDetails(useScrollLock.none, event.nativeEvent));
|
|
1950
1947
|
return;
|
|
1951
1948
|
}
|
|
1952
1949
|
const hadHighlightedChip = comboboxChipsContext?.highlightedChipIndex !== undefined;
|
|
@@ -1971,10 +1968,10 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1971
1968
|
}
|
|
1972
1969
|
|
|
1973
1970
|
// Allow form submission when no item is highlighted.
|
|
1974
|
-
store.state.setOpen(false,
|
|
1971
|
+
store.state.setOpen(false, useScrollLock.createChangeEventDetails(useScrollLock.none, nativeEvent));
|
|
1975
1972
|
return;
|
|
1976
1973
|
}
|
|
1977
|
-
|
|
1974
|
+
useScrollLock.stopEvent(event);
|
|
1978
1975
|
const listItem = store.state.listRef.current[activeIndex];
|
|
1979
1976
|
if (listItem) {
|
|
1980
1977
|
store.state.selectionEventRef.current = nativeEvent;
|
|
@@ -1992,8 +1989,8 @@ const ComboboxInput = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
1992
1989
|
}, validationProps],
|
|
1993
1990
|
stateAttributesMapping: triggerStateAttributesMapping
|
|
1994
1991
|
});
|
|
1995
|
-
const renderedInput = hasPositionerParent ? /*#__PURE__*/jsxRuntime.jsx(
|
|
1996
|
-
value:
|
|
1992
|
+
const renderedInput = hasPositionerParent ? /*#__PURE__*/jsxRuntime.jsx(useCompositeListItem.FieldRootContext.Provider, {
|
|
1993
|
+
value: useCompositeListItem.DEFAULT_FIELD_ROOT_CONTEXT,
|
|
1997
1994
|
children: element
|
|
1998
1995
|
}) : element;
|
|
1999
1996
|
return /*#__PURE__*/jsxRuntime.jsxs(React__namespace.Fragment, {
|
|
@@ -2008,8 +2005,8 @@ function handleInputPress(event, store, disabled, readOnly, shouldIgnoreTarget)
|
|
|
2008
2005
|
if (event.baseUIHandlerPrevented || readOnly) {
|
|
2009
2006
|
return;
|
|
2010
2007
|
}
|
|
2011
|
-
const target =
|
|
2012
|
-
const targetElement =
|
|
2008
|
+
const target = useScrollLock.getTarget(event.nativeEvent);
|
|
2009
|
+
const targetElement = floatingUi_utils.isElement(target) ? target : null;
|
|
2013
2010
|
if (targetElement !== event.currentTarget && (shouldIgnoreTarget?.(targetElement) || useScrollLock.isInteractiveElement(targetElement))) {
|
|
2014
2011
|
return;
|
|
2015
2012
|
}
|
|
@@ -2019,7 +2016,7 @@ function handleInputPress(event, store, disabled, readOnly, shouldIgnoreTarget)
|
|
|
2019
2016
|
}
|
|
2020
2017
|
store.state.inputRef.current?.focus();
|
|
2021
2018
|
if (store.state.openOnInputClick) {
|
|
2022
|
-
store.state.setOpen(true,
|
|
2019
|
+
store.state.setOpen(true, useScrollLock.createChangeEventDetails(useScrollLock.inputPress, event.nativeEvent));
|
|
2023
2020
|
}
|
|
2024
2021
|
}
|
|
2025
2022
|
|
|
@@ -2038,7 +2035,7 @@ const ComboboxInputGroup = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
2038
2035
|
} = componentProps;
|
|
2039
2036
|
const {
|
|
2040
2037
|
state: fieldState
|
|
2041
|
-
} =
|
|
2038
|
+
} = useCompositeListItem.useFieldRootContext();
|
|
2042
2039
|
const store = useComboboxRootContext();
|
|
2043
2040
|
const {
|
|
2044
2041
|
filteredItems
|
|
@@ -2064,7 +2061,7 @@ const ComboboxInputGroup = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
2064
2061
|
listEmpty,
|
|
2065
2062
|
placeholder
|
|
2066
2063
|
};
|
|
2067
|
-
const setInputGroupElement =
|
|
2064
|
+
const setInputGroupElement = useScrollLock.useStableCallback(element => {
|
|
2068
2065
|
store.set('inputGroupElement', element);
|
|
2069
2066
|
});
|
|
2070
2067
|
return useRenderElement.useRenderElement('div', componentProps, {
|
|
@@ -2073,7 +2070,7 @@ const ComboboxInputGroup = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
2073
2070
|
role: 'group',
|
|
2074
2071
|
onMouseDown(event) {
|
|
2075
2072
|
handleInputPress(event, store, disabled, readOnly, target => {
|
|
2076
|
-
return
|
|
2073
|
+
return useScrollLock.contains(store.state.chipsContainerRef.current, target);
|
|
2077
2074
|
});
|
|
2078
2075
|
}
|
|
2079
2076
|
}, elementProps],
|
|
@@ -2108,7 +2105,7 @@ const ComboboxIcon = /*#__PURE__*/React__namespace.forwardRef(function ComboboxI
|
|
|
2108
2105
|
if (process.env.NODE_ENV !== "production") ComboboxIcon.displayName = "ComboboxIcon";
|
|
2109
2106
|
|
|
2110
2107
|
const stateAttributesMapping$2 = {
|
|
2111
|
-
...
|
|
2108
|
+
...useScrollLock.transitionStatusMapping,
|
|
2112
2109
|
...useScrollLock.triggerOpenStateMapping
|
|
2113
2110
|
};
|
|
2114
2111
|
|
|
@@ -2130,7 +2127,7 @@ const ComboboxClear = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
2130
2127
|
} = componentProps;
|
|
2131
2128
|
const {
|
|
2132
2129
|
disabled: fieldDisabled
|
|
2133
|
-
} =
|
|
2130
|
+
} = useCompositeListItem.useFieldRootContext();
|
|
2134
2131
|
const store = useComboboxRootContext();
|
|
2135
2132
|
const selectionMode = useScrollLock.useStore(store, selectors.selectionMode);
|
|
2136
2133
|
const comboboxDisabled = useScrollLock.useStore(store, selectors.disabled);
|
|
@@ -2151,7 +2148,7 @@ const ComboboxClear = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
2151
2148
|
const {
|
|
2152
2149
|
buttonRef,
|
|
2153
2150
|
getButtonProps
|
|
2154
|
-
} =
|
|
2151
|
+
} = useScrollLock.useButton({
|
|
2155
2152
|
native: nativeButton,
|
|
2156
2153
|
disabled
|
|
2157
2154
|
});
|
|
@@ -2159,14 +2156,14 @@ const ComboboxClear = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
2159
2156
|
mounted,
|
|
2160
2157
|
transitionStatus,
|
|
2161
2158
|
setMounted
|
|
2162
|
-
} =
|
|
2159
|
+
} = useScrollLock.useTransitionStatus(visible);
|
|
2163
2160
|
const state = {
|
|
2164
2161
|
disabled,
|
|
2165
2162
|
visible,
|
|
2166
2163
|
open,
|
|
2167
2164
|
transitionStatus
|
|
2168
2165
|
};
|
|
2169
|
-
|
|
2166
|
+
useScrollLock.useOpenChangeComplete({
|
|
2170
2167
|
open: visible,
|
|
2171
2168
|
ref: store.state.clearRef,
|
|
2172
2169
|
onComplete() {
|
|
@@ -2190,9 +2187,9 @@ const ComboboxClear = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
2190
2187
|
return;
|
|
2191
2188
|
}
|
|
2192
2189
|
const keyboardActiveRef = store.state.keyboardActiveRef;
|
|
2193
|
-
store.state.setInputValue('',
|
|
2190
|
+
store.state.setInputValue('', useScrollLock.createChangeEventDetails(useScrollLock.clearPress, event.nativeEvent));
|
|
2194
2191
|
if (selectionMode !== 'none') {
|
|
2195
|
-
store.state.setSelectedValue(Array.isArray(selectedValue) ? [] : null,
|
|
2192
|
+
store.state.setSelectedValue(Array.isArray(selectedValue) ? [] : null, useScrollLock.createChangeEventDetails(useScrollLock.clearPress, event.nativeEvent));
|
|
2196
2193
|
store.state.setIndices({
|
|
2197
2194
|
activeIndex: null,
|
|
2198
2195
|
selectedIndex: null,
|
|
@@ -2276,10 +2273,10 @@ const ComboboxList = /*#__PURE__*/React__namespace.forwardRef(function ComboboxL
|
|
|
2276
2273
|
const forceMounted = useScrollLock.useStore(store, selectors.forceMounted);
|
|
2277
2274
|
const multiple = selectionMode === 'multiple';
|
|
2278
2275
|
const empty = filteredItems.length === 0;
|
|
2279
|
-
const setPositionerElement =
|
|
2276
|
+
const setPositionerElement = useScrollLock.useStableCallback(element => {
|
|
2280
2277
|
store.set('positionerElement', element);
|
|
2281
2278
|
});
|
|
2282
|
-
const setListElement =
|
|
2279
|
+
const setListElement = useScrollLock.useStableCallback(element => {
|
|
2283
2280
|
store.set('listElement', element);
|
|
2284
2281
|
});
|
|
2285
2282
|
|
|
@@ -2318,7 +2315,7 @@ const ComboboxList = /*#__PURE__*/React__namespace.forwardRef(function ComboboxL
|
|
|
2318
2315
|
// Allow form submission when no item is highlighted.
|
|
2319
2316
|
return;
|
|
2320
2317
|
}
|
|
2321
|
-
|
|
2318
|
+
useScrollLock.stopEvent(event);
|
|
2322
2319
|
const nativeEvent = event.nativeEvent;
|
|
2323
2320
|
const listItem = store.state.listRef.current[activeIndex];
|
|
2324
2321
|
if (listItem) {
|
|
@@ -2368,12 +2365,12 @@ function findLastTextNode(root) {
|
|
|
2368
2365
|
return lastTextNode;
|
|
2369
2366
|
}
|
|
2370
2367
|
function useInitialLiveRegionTextMutation() {
|
|
2371
|
-
const timeout =
|
|
2368
|
+
const timeout = useScrollLock.useTimeout();
|
|
2372
2369
|
const rootRef = React__namespace.useRef(null);
|
|
2373
2370
|
|
|
2374
2371
|
// Only the initial mounted announcement needs the marker; later text updates announce naturally.
|
|
2375
2372
|
React__namespace.useEffect(() => {
|
|
2376
|
-
if (
|
|
2373
|
+
if (useScrollLock.ios) {
|
|
2377
2374
|
return undefined;
|
|
2378
2375
|
}
|
|
2379
2376
|
const root = rootRef.current;
|
|
@@ -2468,7 +2465,7 @@ if (process.env.NODE_ENV !== "production") ComboboxPortal.displayName = "Combobo
|
|
|
2468
2465
|
|
|
2469
2466
|
const stateAttributesMapping$1 = {
|
|
2470
2467
|
...useScrollLock.popupStateMapping,
|
|
2471
|
-
...
|
|
2468
|
+
...useScrollLock.transitionStatusMapping
|
|
2472
2469
|
};
|
|
2473
2470
|
|
|
2474
2471
|
/**
|
|
@@ -2571,10 +2568,10 @@ const ComboboxPositioner = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
2571
2568
|
anchorHidden: positioning.anchorHidden,
|
|
2572
2569
|
empty
|
|
2573
2570
|
};
|
|
2574
|
-
|
|
2571
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
2575
2572
|
store.set('popupSide', positioning.side);
|
|
2576
2573
|
}, [store, positioning.side]);
|
|
2577
|
-
const setPositionerElement =
|
|
2574
|
+
const setPositionerElement = useScrollLock.useStableCallback(element => {
|
|
2578
2575
|
store.set('positionerElement', element);
|
|
2579
2576
|
});
|
|
2580
2577
|
const element = useCompositeListItem.usePositioner(componentProps, state, {
|
|
@@ -2597,7 +2594,7 @@ if (process.env.NODE_ENV !== "production") ComboboxPositioner.displayName = "Com
|
|
|
2597
2594
|
|
|
2598
2595
|
const stateAttributesMapping = {
|
|
2599
2596
|
...useScrollLock.popupStateMapping,
|
|
2600
|
-
...
|
|
2597
|
+
...useScrollLock.transitionStatusMapping
|
|
2601
2598
|
};
|
|
2602
2599
|
|
|
2603
2600
|
/**
|
|
@@ -2631,14 +2628,14 @@ const ComboboxPopup = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
2631
2628
|
const rootId = useScrollLock.useStore(store, selectors.id);
|
|
2632
2629
|
const empty = filteredItems.length === 0;
|
|
2633
2630
|
const popupId = elementProps.id ?? (inputInsidePopup ? getComboboxPopupId(rootId) : undefined);
|
|
2634
|
-
|
|
2631
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
2635
2632
|
// Prefer the rendered DOM id, which a `render` prop element or function may override.
|
|
2636
2633
|
store.set('popupId', store.state.popupRef.current?.id || popupId);
|
|
2637
2634
|
return () => {
|
|
2638
2635
|
store.set('popupId', undefined);
|
|
2639
2636
|
};
|
|
2640
2637
|
}, [store, popupId]);
|
|
2641
|
-
|
|
2638
|
+
useScrollLock.useOpenChangeComplete({
|
|
2642
2639
|
open,
|
|
2643
2640
|
ref: store.state.popupRef,
|
|
2644
2641
|
onComplete() {
|
|
@@ -2663,8 +2660,8 @@ const ComboboxPopup = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
2663
2660
|
role: inputInsidePopup ? 'dialog' : 'presentation',
|
|
2664
2661
|
tabIndex: -1,
|
|
2665
2662
|
onFocus(event) {
|
|
2666
|
-
const target =
|
|
2667
|
-
if (openMethod !== 'touch' && (
|
|
2663
|
+
const target = useScrollLock.getTarget(event.nativeEvent);
|
|
2664
|
+
if (openMethod !== 'touch' && (useScrollLock.contains(store.state.listElement, target) || target === event.currentTarget)) {
|
|
2668
2665
|
store.state.inputRef.current?.focus();
|
|
2669
2666
|
}
|
|
2670
2667
|
}
|
|
@@ -2804,8 +2801,8 @@ const ComboboxGroupLabel = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
2804
2801
|
const {
|
|
2805
2802
|
setLabelId
|
|
2806
2803
|
} = useComboboxGroupContext();
|
|
2807
|
-
const id =
|
|
2808
|
-
|
|
2804
|
+
const id = useScrollLock.useBaseUiId(idProp);
|
|
2805
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
2809
2806
|
setLabelId(id);
|
|
2810
2807
|
return () => {
|
|
2811
2808
|
setLabelId(undefined);
|
|
@@ -2878,7 +2875,7 @@ function ComboboxItemInner(props) {
|
|
|
2878
2875
|
const itemRef = React__namespace.useRef(null);
|
|
2879
2876
|
const id = rootId != null && hasRegistered ? `${rootId}-${index}` : undefined;
|
|
2880
2877
|
const selected = matchesSelectedValue && selectable;
|
|
2881
|
-
|
|
2878
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
2882
2879
|
const shouldRun = hasRegistered && (virtualized || indexProp != null);
|
|
2883
2880
|
if (!shouldRun) {
|
|
2884
2881
|
return undefined;
|
|
@@ -2889,7 +2886,7 @@ function ComboboxItemInner(props) {
|
|
|
2889
2886
|
delete list[index];
|
|
2890
2887
|
};
|
|
2891
2888
|
}, [hasRegistered, virtualized, index, indexProp, store]);
|
|
2892
|
-
|
|
2889
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
2893
2890
|
if (!hasRegistered || hasItems) {
|
|
2894
2891
|
return undefined;
|
|
2895
2892
|
}
|
|
@@ -2906,7 +2903,7 @@ function ComboboxItemInner(props) {
|
|
|
2906
2903
|
delete visibleMap[index];
|
|
2907
2904
|
};
|
|
2908
2905
|
}, [hasRegistered, hasItems, index, itemValue, store, selectionMode]);
|
|
2909
|
-
|
|
2906
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
2910
2907
|
if (!open) {
|
|
2911
2908
|
didPointerDownRef.current = false;
|
|
2912
2909
|
return;
|
|
@@ -2916,14 +2913,14 @@ function ComboboxItemInner(props) {
|
|
|
2916
2913
|
}
|
|
2917
2914
|
const selectedValue = store.state.selectedValue;
|
|
2918
2915
|
const lastSelectedValue = Array.isArray(selectedValue) ? selectedValue[selectedValue.length - 1] : selectedValue;
|
|
2919
|
-
if (
|
|
2916
|
+
if (useCompositeListItem.compareItemEquality(itemValue, lastSelectedValue, isItemEqualToValue)) {
|
|
2920
2917
|
store.set('selectedIndex', index);
|
|
2921
2918
|
}
|
|
2922
2919
|
}, [hasRegistered, hasItems, open, store, index, itemValue, isItemEqualToValue]);
|
|
2923
2920
|
const {
|
|
2924
2921
|
getButtonProps,
|
|
2925
2922
|
buttonRef
|
|
2926
|
-
} =
|
|
2923
|
+
} = useScrollLock.useButton({
|
|
2927
2924
|
disabled,
|
|
2928
2925
|
focusableWhenDisabled: true,
|
|
2929
2926
|
native: nativeButton,
|
|
@@ -3009,7 +3006,7 @@ function ComboboxItemVirtualizedIndex(props) {
|
|
|
3009
3006
|
const {
|
|
3010
3007
|
flatFilteredItems
|
|
3011
3008
|
} = useComboboxDerivedItemsContext();
|
|
3012
|
-
const indexFromFilter =
|
|
3009
|
+
const indexFromFilter = useCompositeListItem.findItemIndex(flatFilteredItems, componentProps.value ?? null, isItemEqualToValue);
|
|
3013
3010
|
|
|
3014
3011
|
// Only reached when `virtualized` is true (see the wrapper below).
|
|
3015
3012
|
return /*#__PURE__*/jsxRuntime.jsx(ComboboxItemInner, {
|
|
@@ -3149,13 +3146,13 @@ const ComboboxLabel = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
3149
3146
|
// Keep label id derived from the root and ignore runtime `id` overrides from untyped consumers.
|
|
3150
3147
|
const elementPropsWithoutId = elementProps;
|
|
3151
3148
|
delete elementPropsWithoutId.id;
|
|
3152
|
-
const fieldRootContext =
|
|
3149
|
+
const fieldRootContext = useCompositeListItem.useFieldRootContext();
|
|
3153
3150
|
const store = useComboboxRootContext();
|
|
3154
3151
|
const inputInsidePopup = useScrollLock.useStore(store, selectors.inputInsidePopup);
|
|
3155
3152
|
const triggerElement = useScrollLock.useStore(store, selectors.triggerElement);
|
|
3156
3153
|
const inputElement = useScrollLock.useStore(store, selectors.inputElement);
|
|
3157
3154
|
const rootId = useScrollLock.useStore(store, selectors.id);
|
|
3158
|
-
const defaultLabelId =
|
|
3155
|
+
const defaultLabelId = useCompositeListItem.getDefaultLabelId(rootId);
|
|
3159
3156
|
const localControlId = triggerElement?.id ?? (inputInsidePopup ? rootId : undefined);
|
|
3160
3157
|
if (process.env.NODE_ENV !== 'production') {
|
|
3161
3158
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -3163,9 +3160,9 @@ const ComboboxLabel = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
3163
3160
|
if (!inputElement || inputInsidePopup) {
|
|
3164
3161
|
return;
|
|
3165
3162
|
}
|
|
3166
|
-
const ownerStackMessage =
|
|
3163
|
+
const ownerStackMessage = useScrollLock.SafeReact.captureOwnerStack?.() || '';
|
|
3167
3164
|
const message = '<Combobox.Label> labels <Combobox.Trigger> only. ' + 'When <Combobox.Input> is the form control, use a native <label> or <Field.Label> instead.';
|
|
3168
|
-
|
|
3165
|
+
useScrollLock.error(`${message}${ownerStackMessage}`);
|
|
3169
3166
|
}, [inputElement, inputInsidePopup]);
|
|
3170
3167
|
}
|
|
3171
3168
|
const labelProps = useLabel.useLabel({
|
|
@@ -3179,7 +3176,7 @@ const ComboboxLabel = /*#__PURE__*/React__namespace.forwardRef(function Combobox
|
|
|
3179
3176
|
ref: forwardedRef,
|
|
3180
3177
|
state: fieldRootContext.state,
|
|
3181
3178
|
props: [labelProps, elementProps],
|
|
3182
|
-
stateAttributesMapping:
|
|
3179
|
+
stateAttributesMapping: useCompositeListItem.fieldValidityMapping
|
|
3183
3180
|
});
|
|
3184
3181
|
});
|
|
3185
3182
|
if (process.env.NODE_ENV !== "production") ComboboxLabel.displayName = "ComboboxLabel";
|
|
@@ -3205,9 +3202,9 @@ function ComboboxValue(props) {
|
|
|
3205
3202
|
} else if (!hasSelectedValue && placeholder != null && !hasNullLabel) {
|
|
3206
3203
|
children = placeholder;
|
|
3207
3204
|
} else if (multiple && Array.isArray(selectedValue)) {
|
|
3208
|
-
children =
|
|
3205
|
+
children = useCompositeListItem.resolveMultipleLabels(selectedValue, items, itemToStringLabel);
|
|
3209
3206
|
} else {
|
|
3210
|
-
children =
|
|
3207
|
+
children = useCompositeListItem.resolveSelectedLabel(selectedValue, items, itemToStringLabel);
|
|
3211
3208
|
}
|
|
3212
3209
|
return /*#__PURE__*/jsxRuntime.jsx(React__namespace.Fragment, {
|
|
3213
3210
|
children: children
|
|
@@ -3248,7 +3245,7 @@ const Inner = /*#__PURE__*/React__namespace.memo(/*#__PURE__*/React__namespace.f
|
|
|
3248
3245
|
const {
|
|
3249
3246
|
transitionStatus,
|
|
3250
3247
|
setMounted
|
|
3251
|
-
} =
|
|
3248
|
+
} = useScrollLock.useTransitionStatus(selected);
|
|
3252
3249
|
const state = {
|
|
3253
3250
|
selected,
|
|
3254
3251
|
transitionStatus
|
|
@@ -3260,9 +3257,9 @@ const Inner = /*#__PURE__*/React__namespace.memo(/*#__PURE__*/React__namespace.f
|
|
|
3260
3257
|
'aria-hidden': true,
|
|
3261
3258
|
children: '✔️'
|
|
3262
3259
|
}, elementProps],
|
|
3263
|
-
stateAttributesMapping:
|
|
3260
|
+
stateAttributesMapping: useScrollLock.transitionStatusMapping
|
|
3264
3261
|
});
|
|
3265
|
-
|
|
3262
|
+
useScrollLock.useOpenChangeComplete({
|
|
3266
3263
|
open: selected,
|
|
3267
3264
|
ref: indicatorRef,
|
|
3268
3265
|
onComplete() {
|
|
@@ -3369,19 +3366,19 @@ const ComboboxChip = /*#__PURE__*/React__namespace.forwardRef(function ComboboxC
|
|
|
3369
3366
|
} else if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
3370
3367
|
const computedNextIndex = index >= selectedValue.length - 1 ? selectedValue.length - 2 : index;
|
|
3371
3368
|
nextIndex = computedNextIndex >= 0 ? computedNextIndex : undefined;
|
|
3372
|
-
|
|
3369
|
+
useScrollLock.stopEvent(event);
|
|
3373
3370
|
store.state.setIndices({
|
|
3374
3371
|
activeIndex: null,
|
|
3375
3372
|
selectedIndex: null,
|
|
3376
3373
|
type: 'keyboard'
|
|
3377
3374
|
});
|
|
3378
|
-
store.state.setSelectedValue(selectedValue.filter((_, i) => i !== index),
|
|
3375
|
+
store.state.setSelectedValue(selectedValue.filter((_, i) => i !== index), useScrollLock.createChangeEventDetails(useScrollLock.none, event.nativeEvent));
|
|
3379
3376
|
} else if (event.key === 'Enter' || event.key === ' ') {
|
|
3380
|
-
|
|
3377
|
+
useScrollLock.stopEvent(event);
|
|
3381
3378
|
nextIndex = undefined;
|
|
3382
3379
|
} else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
3383
|
-
|
|
3384
|
-
store.state.setOpen(true,
|
|
3380
|
+
useScrollLock.stopEvent(event);
|
|
3381
|
+
store.state.setOpen(true, useScrollLock.createChangeEventDetails(useScrollLock.listNavigation, event.nativeEvent));
|
|
3385
3382
|
nextIndex = undefined;
|
|
3386
3383
|
} else if (
|
|
3387
3384
|
// Check for printable characters (letters, numbers, symbols)
|
|
@@ -3453,7 +3450,7 @@ const ComboboxChipRemove = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
3453
3450
|
const {
|
|
3454
3451
|
buttonRef,
|
|
3455
3452
|
getButtonProps
|
|
3456
|
-
} =
|
|
3453
|
+
} = useScrollLock.useButton({
|
|
3457
3454
|
native: nativeButton,
|
|
3458
3455
|
disabled: disabled || readOnly,
|
|
3459
3456
|
focusableWhenDisabled: true
|
|
@@ -3469,7 +3466,7 @@ const ComboboxChipRemove = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
3469
3466
|
|
|
3470
3467
|
// Try current visible list first; if not found, it's filtered out.
|
|
3471
3468
|
// No need to clear highlight in that case since it can't equal activeIndex.
|
|
3472
|
-
const removedIndex =
|
|
3469
|
+
const removedIndex = useCompositeListItem.findItemIndex(store.state.valuesRef.current, removedItem, isItemEqualToValue);
|
|
3473
3470
|
if (removedIndex !== -1 && activeIndex === removedIndex) {
|
|
3474
3471
|
store.state.setIndices({
|
|
3475
3472
|
activeIndex: null,
|
|
@@ -3478,7 +3475,7 @@ const ComboboxChipRemove = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
3478
3475
|
}
|
|
3479
3476
|
}
|
|
3480
3477
|
function removeChip(event) {
|
|
3481
|
-
const eventDetails =
|
|
3478
|
+
const eventDetails = useScrollLock.createChangeEventDetails(useScrollLock.chipRemovePress, event.nativeEvent);
|
|
3482
3479
|
const removedItem = selectedValue[index];
|
|
3483
3480
|
clearActiveIndexForRemovedItem(removedItem);
|
|
3484
3481
|
store.state.setSelectedValue(selectedValue.filter((_, i) => i !== index), eventDetails);
|
|
@@ -3509,7 +3506,7 @@ const ComboboxChipRemove = /*#__PURE__*/React__namespace.forwardRef(function Com
|
|
|
3509
3506
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
3510
3507
|
const eventDetails = removeChip(event);
|
|
3511
3508
|
if (!eventDetails.isPropagationAllowed) {
|
|
3512
|
-
|
|
3509
|
+
useScrollLock.stopEvent(event);
|
|
3513
3510
|
}
|
|
3514
3511
|
}
|
|
3515
3512
|
}
|