@wix/site-ui 1.30.0 → 1.32.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/1268.js +99 -0
- package/dist/1279.js +7 -0
- package/dist/1457.js +10 -0
- package/dist/1477.js +106 -0
- package/dist/1500.js +111 -0
- package/dist/167.js +6 -0
- package/dist/2274.js +34 -0
- package/dist/2287.js +17 -0
- package/dist/2418.js +31 -0
- package/dist/2801.js +20 -0
- package/dist/285.js +86 -0
- package/dist/2861.js +6 -0
- package/dist/3020.js +7 -0
- package/dist/3021.js +72 -0
- package/dist/3056.js +229 -0
- package/dist/3140.js +4 -0
- package/dist/3248.js +307 -0
- package/dist/3296.js +4 -0
- package/dist/3319.js +400 -0
- package/dist/3395.js +4 -0
- package/dist/3485.js +854 -0
- package/dist/353.js +14 -0
- package/dist/3670.js +418 -0
- package/dist/3829.js +113 -0
- package/dist/4026.js +12 -0
- package/dist/4143.js +46 -0
- package/dist/42.js +32 -0
- package/dist/4281.js +30 -0
- package/dist/4346.js +2 -0
- package/dist/4388.js +418 -0
- package/dist/4490.js +32 -0
- package/dist/4495.js +9 -0
- package/dist/4549.js +24 -0
- package/dist/4586.js +41 -0
- package/dist/4586.js.LICENSE.txt +19 -0
- package/dist/4707.js +19 -0
- package/dist/4723.js +7 -0
- package/dist/4745.js +7 -0
- package/dist/4768.js +35 -0
- package/dist/4922.js +15 -0
- package/dist/5036.js +17 -0
- package/dist/5085.js +20 -0
- package/dist/5299.js +597 -0
- package/dist/5659.js +4 -0
- package/dist/5778.js +10 -0
- package/dist/5864.js +86 -0
- package/dist/5992.js +913 -0
- package/dist/5992.js.LICENSE.txt +19 -0
- package/dist/6003.js +10 -0
- package/dist/6046.js +29 -0
- package/dist/6089.js +2355 -0
- package/dist/6107.js +10 -0
- package/dist/6247.js +20 -0
- package/dist/6270.js +487 -0
- package/dist/6329.js +32 -0
- package/dist/6330.js +30 -0
- package/dist/6499.js +7 -0
- package/dist/6535.js +71 -0
- package/dist/6588.js +382 -0
- package/dist/6706.js +16 -0
- package/dist/6825.js +7 -0
- package/dist/6882.js +1562 -0
- package/dist/6914.js +30 -0
- package/dist/7021.js +13 -0
- package/dist/7366.js +83 -0
- package/dist/7373.js +25 -0
- package/dist/7541.js +25 -0
- package/dist/7564.js +10 -0
- package/dist/7642.js +20 -0
- package/dist/7725.js +10 -0
- package/dist/7871.js +38 -0
- package/dist/8052.js +352 -0
- package/dist/8106.js +238 -0
- package/dist/8171.js +346 -0
- package/dist/8225.js +21 -0
- package/dist/8272.js +333 -0
- package/dist/8527.js +58 -0
- package/dist/8724.js +10 -0
- package/dist/8750.js +1920 -0
- package/dist/8758.js +43 -0
- package/dist/880.js +149 -0
- package/dist/8935.js +8 -0
- package/dist/8960.js +22 -0
- package/dist/8971.js +40 -0
- package/dist/8979.js +10 -0
- package/dist/8996.js +71 -0
- package/dist/904.js +121 -0
- package/dist/9048.js +52 -0
- package/dist/9087.js +256 -0
- package/dist/9189.js +158 -0
- package/dist/9255.js +136 -0
- package/dist/9352.js +148 -0
- package/dist/951.js +22 -0
- package/dist/9635.js +22 -0
- package/dist/9829.js +4 -0
- package/dist/9863.js +8 -0
- package/dist/Accordion/index.d.ts +569 -12
- package/dist/Accordion/index.js +423 -8
- package/dist/AlertDialog/index.d.ts +1417 -18
- package/dist/AlertDialog/index.js +34 -14
- package/dist/Autocomplete/index.d.ts +1861 -38
- package/dist/Autocomplete/index.js +98 -24
- package/dist/Avatar/index.d.ts +129 -7
- package/dist/Avatar/index.js +149 -6
- package/dist/Breadcrumbs/index.d.ts +960 -7
- package/dist/Breadcrumbs/index.js +5 -5
- package/dist/Button/index.d.ts +88 -6
- package/dist/Button/index.js +27 -3
- package/dist/Checkbox/index.d.ts +425 -5
- package/dist/Checkbox/index.js +45 -5
- package/dist/CheckboxGroup/index.d.ts +318 -3
- package/dist/CheckboxGroup/index.js +166 -3
- package/dist/Collapsible/index.d.ts +377 -7
- package/dist/Collapsible/index.js +160 -6
- package/dist/Combobox/index.d.ts +1984 -48
- package/dist/Combobox/index.js +352 -29
- package/dist/ContextMenu/index.d.ts +2340 -36
- package/dist/ContextMenu/index.js +197 -22
- package/dist/Dialog/index.d.ts +1355 -18
- package/dist/Dialog/index.js +16 -14
- package/dist/Drawer/index.d.ts +1653 -18
- package/dist/Drawer/index.js +2797 -20
- package/dist/Field/index.d.ts +655 -15
- package/dist/Field/index.js +677 -10
- package/dist/Fieldset/index.d.ts +94 -5
- package/dist/Fieldset/index.js +68 -5
- package/dist/Form/index.d.ts +331 -2
- package/dist/Form/index.js +106 -3
- package/dist/Input/index.d.ts +692 -3
- package/dist/Input/index.js +10 -3
- package/dist/Menu/index.d.ts +2301 -36
- package/dist/Menu/index.js +365 -26
- package/dist/Menubar/index.d.ts +2301 -3
- package/dist/Menubar/index.js +105 -3
- package/dist/Meter/index.d.ts +175 -11
- package/dist/Meter/index.js +129 -9
- package/dist/NavigationMenu/index.d.ts +978 -28
- package/dist/NavigationMenu/index.js +1034 -17
- package/dist/NumberField/index.d.ts +612 -15
- package/dist/NumberField/index.js +1409 -11
- package/dist/Popover/index.d.ts +1655 -20
- package/dist/Popover/index.js +792 -17
- package/dist/PreviewCard/index.d.ts +1523 -14
- package/dist/PreviewCard/index.js +679 -14
- package/dist/Progress/index.d.ts +183 -11
- package/dist/Progress/index.js +181 -9
- package/dist/Radio/index.d.ts +185 -6
- package/dist/Radio/index.js +253 -6
- package/dist/RadioGroup/index.d.ts +341 -2
- package/dist/RadioGroup/index.js +154 -3
- package/dist/ScrollArea/index.d.ts +265 -13
- package/dist/ScrollArea/index.js +892 -10
- package/dist/Select/index.d.ts +1493 -38
- package/dist/Select/index.js +1824 -23
- package/dist/Separator/index.d.ts +80 -6
- package/dist/Separator/index.js +3 -3
- package/dist/Slider/index.d.ts +678 -16
- package/dist/Slider/index.js +1199 -11
- package/dist/Switch/index.d.ts +393 -5
- package/dist/Switch/index.js +208 -6
- package/dist/Tabs/index.d.ts +523 -12
- package/dist/Tabs/index.js +685 -9
- package/dist/Toggle/index.d.ts +305 -2
- package/dist/Toggle/index.js +76 -3
- package/dist/ToggleGroup/index.d.ts +316 -2
- package/dist/ToggleGroup/index.js +102 -3
- package/dist/Toolbar/index.d.ts +282 -13
- package/dist/Toolbar/index.js +230 -9
- package/dist/Tooltip/index.d.ts +1572 -14
- package/dist/Tooltip/index.js +965 -14
- package/dist/index.d.ts +12749 -652
- package/dist/rslib-runtime.js +18 -0
- package/package.json +3 -3
package/dist/6089.js
ADDED
|
@@ -0,0 +1,2355 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { esm_formatErrorMessage, EMPTY_OBJECT, EMPTY_ARRAY, useMergedRefs, useRefWithInit, mergeProps, useRenderElement, NOOP } from "./8272.js";
|
|
3
|
+
import { Store, createSelector, useStore, useDismiss } from "./5992.js";
|
|
4
|
+
import { defaultItemEquality, findItemIndex, stringifyAsLabel, hasNullItemLabel, stringifyAsValue, compareItemEquality, isGroupedItems, selectedValueIncludes, removeItem } from "./7366.js";
|
|
5
|
+
import { DROPDOWN_COLLISION_AVOIDANCE, triggerOpenStateMapping, FloatingPortal_FloatingPortal, popupStateMapping, pressableTriggerOpenStateMapping } from "./4388.js";
|
|
6
|
+
import { FieldRootContext, DEFAULT_FIELD_STATE_ATTRIBUTES, DEFAULT_FIELD_ROOT_CONTEXT, useLabelableContext, fieldValidityMapping, useFieldRootContext } from "./1477.js";
|
|
7
|
+
import { getTarget, contains as shadowDom_contains } from "./4549.js";
|
|
8
|
+
import { isElement } from "./3829.js";
|
|
9
|
+
import { isInteractiveElement } from "./8758.js";
|
|
10
|
+
import { createGenericEventDetails, createChangeEventDetails } from "./4768.js";
|
|
11
|
+
import { itemPress, outsidePress, inputClear, closePress, focusOut, inputChange, listNavigation as reason_parts_listNavigation, inputPress, clearPress, escapeKey } from "./2418.js";
|
|
12
|
+
import { useStableCallback } from "./7541.js";
|
|
13
|
+
import { useCompositeListItem, useCompositeListItem_IndexGuessBehavior } from "./3021.js";
|
|
14
|
+
import { useIsoLayoutEffect } from "./6499.js";
|
|
15
|
+
import { useButton } from "./9189.js";
|
|
16
|
+
import { visuallyHiddenInput, visuallyHidden } from "./8225.js";
|
|
17
|
+
import { useDirection } from "./9863.js";
|
|
18
|
+
import { useBaseUiId } from "./6046.js";
|
|
19
|
+
import { resolveAriaLabelledBy } from "./6825.js";
|
|
20
|
+
import { isAndroid, isFirefox, isIOS } from "./8971.js";
|
|
21
|
+
import { stopEvent } from "./6330.js";
|
|
22
|
+
import { transitionStatusMapping, useOpenChangeComplete, useTransitionStatus } from "./880.js";
|
|
23
|
+
import { CompositeList } from "./9255.js";
|
|
24
|
+
import { useTimeout } from "./42.js";
|
|
25
|
+
import { usePositioner, useFloatingRootContext, useAnchorPositioning, getDisabledMountTransitionStyles } from "./8750.js";
|
|
26
|
+
import { useAnchoredPopupScrollLock } from "./6247.js";
|
|
27
|
+
import { useOpenInteractionType, FloatingFocusManager, InternalBackdrop_InternalBackdrop } from "./3485.js";
|
|
28
|
+
import { inertValue } from "./167.js";
|
|
29
|
+
import { useLabelableId } from "./9048.js";
|
|
30
|
+
import { useListNavigation, useTypeahead } from "./5299.js";
|
|
31
|
+
import { useClick } from "./5864.js";
|
|
32
|
+
import { ownerDocument } from "./9829.js";
|
|
33
|
+
import { getPseudoElementBounds } from "./7373.js";
|
|
34
|
+
import { useFormContext } from "./5085.js";
|
|
35
|
+
import { useControlled } from "./8527.js";
|
|
36
|
+
import { useValueAsRef } from "./4707.js";
|
|
37
|
+
import { useRegisterFieldControl } from "./4281.js";
|
|
38
|
+
import { useValueChanged } from "./2801.js";
|
|
39
|
+
import { FOCUSABLE_POPUP_PROPS, useOnFirstRender } from "./8106.js";
|
|
40
|
+
import * as __rspack_external_react from "react";
|
|
41
|
+
import * as __rspack_external_react_dom_7136dc57 from "react-dom";
|
|
42
|
+
const ComboboxRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
43
|
+
if ("production" !== process.env.NODE_ENV) ComboboxRootContext.displayName = "ComboboxRootContext";
|
|
44
|
+
const ComboboxFloatingContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
45
|
+
if ("production" !== process.env.NODE_ENV) ComboboxFloatingContext.displayName = "ComboboxFloatingContext";
|
|
46
|
+
const ComboboxDerivedItemsContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
47
|
+
if ("production" !== process.env.NODE_ENV) ComboboxDerivedItemsContext.displayName = "ComboboxDerivedItemsContext";
|
|
48
|
+
const ComboboxInputValueContext = /*#__PURE__*/ __rspack_external_react.createContext('');
|
|
49
|
+
if ("production" !== process.env.NODE_ENV) ComboboxInputValueContext.displayName = "ComboboxInputValueContext";
|
|
50
|
+
function useComboboxRootContext() {
|
|
51
|
+
const context = __rspack_external_react.useContext(ComboboxRootContext);
|
|
52
|
+
if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: ComboboxRootContext is missing. Combobox parts must be placed within <Combobox.Root>.' : esm_formatErrorMessage(22));
|
|
53
|
+
return context;
|
|
54
|
+
}
|
|
55
|
+
function useComboboxFloatingContext() {
|
|
56
|
+
const context = __rspack_external_react.useContext(ComboboxFloatingContext);
|
|
57
|
+
if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: ComboboxFloatingContext is missing. Combobox parts must be placed within <Combobox.Root>.' : esm_formatErrorMessage(23));
|
|
58
|
+
return context;
|
|
59
|
+
}
|
|
60
|
+
function useComboboxDerivedItemsContext() {
|
|
61
|
+
const context = __rspack_external_react.useContext(ComboboxDerivedItemsContext);
|
|
62
|
+
if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: ComboboxItemsContext is missing. Combobox parts must be placed within <Combobox.Root>.' : esm_formatErrorMessage(24));
|
|
63
|
+
return context;
|
|
64
|
+
}
|
|
65
|
+
function useComboboxInputValueContext() {
|
|
66
|
+
return __rspack_external_react.useContext(ComboboxInputValueContext);
|
|
67
|
+
}
|
|
68
|
+
const selectors = {
|
|
69
|
+
id: createSelector((state)=>state.id),
|
|
70
|
+
labelId: createSelector((state)=>state.labelId),
|
|
71
|
+
items: createSelector((state)=>state.items),
|
|
72
|
+
selectedValue: createSelector((state)=>state.selectedValue),
|
|
73
|
+
hasSelectionChips: createSelector((state)=>{
|
|
74
|
+
const selectedValue = state.selectedValue;
|
|
75
|
+
return Array.isArray(selectedValue) && selectedValue.length > 0;
|
|
76
|
+
}),
|
|
77
|
+
hasSelectedValue: createSelector((state)=>{
|
|
78
|
+
const { selectedValue, selectionMode } = state;
|
|
79
|
+
if (null == selectedValue) return false;
|
|
80
|
+
if ('multiple' === selectionMode && Array.isArray(selectedValue)) return selectedValue.length > 0;
|
|
81
|
+
return true;
|
|
82
|
+
}),
|
|
83
|
+
hasNullItemLabel: createSelector((state, enabled)=>enabled ? hasNullItemLabel(state.items) : false),
|
|
84
|
+
open: createSelector((state)=>state.open),
|
|
85
|
+
mounted: createSelector((state)=>state.mounted),
|
|
86
|
+
forceMounted: createSelector((state)=>state.forceMounted),
|
|
87
|
+
inline: createSelector((state)=>state.inline),
|
|
88
|
+
activeIndex: createSelector((state)=>state.activeIndex),
|
|
89
|
+
selectedIndex: createSelector((state)=>state.selectedIndex),
|
|
90
|
+
isActive: createSelector((state, index)=>state.activeIndex === index),
|
|
91
|
+
isSelected: createSelector((state, itemValue)=>{
|
|
92
|
+
const comparer = state.isItemEqualToValue;
|
|
93
|
+
const selectedValue = state.selectedValue;
|
|
94
|
+
if (Array.isArray(selectedValue)) return selectedValue.some((selectedItem)=>compareItemEquality(itemValue, selectedItem, comparer));
|
|
95
|
+
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
96
|
+
}),
|
|
97
|
+
transitionStatus: createSelector((state)=>state.transitionStatus),
|
|
98
|
+
popupProps: createSelector((state)=>state.popupProps),
|
|
99
|
+
inputProps: createSelector((state)=>state.inputProps),
|
|
100
|
+
triggerProps: createSelector((state)=>state.triggerProps),
|
|
101
|
+
itemProps: createSelector((state)=>state.itemProps),
|
|
102
|
+
positionerElement: createSelector((state)=>state.positionerElement),
|
|
103
|
+
listElement: createSelector((state)=>state.listElement),
|
|
104
|
+
triggerElement: createSelector((state)=>state.triggerElement),
|
|
105
|
+
inputElement: createSelector((state)=>state.inputElement),
|
|
106
|
+
inputGroupElement: createSelector((state)=>state.inputGroupElement),
|
|
107
|
+
popupSide: createSelector((state)=>state.popupSide),
|
|
108
|
+
openMethod: createSelector((state)=>state.openMethod),
|
|
109
|
+
inputInsidePopup: createSelector((state)=>state.inputInsidePopup),
|
|
110
|
+
inputOwnsFormValue: createSelector((state)=>state.inputOwnsFormValue),
|
|
111
|
+
selectionMode: createSelector((state)=>state.selectionMode),
|
|
112
|
+
name: createSelector((state)=>state.name),
|
|
113
|
+
form: createSelector((state)=>state.form),
|
|
114
|
+
disabled: createSelector((state)=>state.disabled),
|
|
115
|
+
readOnly: createSelector((state)=>state.readOnly),
|
|
116
|
+
required: createSelector((state)=>state.required),
|
|
117
|
+
grid: createSelector((state)=>state.grid),
|
|
118
|
+
virtualized: createSelector((state)=>state.virtualized),
|
|
119
|
+
itemToStringLabel: createSelector((state)=>state.itemToStringLabel),
|
|
120
|
+
isItemEqualToValue: createSelector((state)=>state.isItemEqualToValue),
|
|
121
|
+
modal: createSelector((state)=>state.modal),
|
|
122
|
+
autoHighlight: createSelector((state)=>state.autoHighlight),
|
|
123
|
+
submitOnItemClick: createSelector((state)=>state.submitOnItemClick)
|
|
124
|
+
};
|
|
125
|
+
const triggerStateAttributesMapping = {
|
|
126
|
+
...pressableTriggerOpenStateMapping,
|
|
127
|
+
...fieldValidityMapping,
|
|
128
|
+
popupSide: (side)=>side ? {
|
|
129
|
+
'data-popup-side': side
|
|
130
|
+
} : null,
|
|
131
|
+
listEmpty: (empty)=>empty ? {
|
|
132
|
+
'data-list-empty': ''
|
|
133
|
+
} : null
|
|
134
|
+
};
|
|
135
|
+
function handleInputPress(event, store, disabled, readOnly, shouldIgnoreTarget) {
|
|
136
|
+
if (event.baseUIHandlerPrevented || readOnly) return;
|
|
137
|
+
const target = getTarget(event.nativeEvent);
|
|
138
|
+
const targetElement = isElement(target) ? target : null;
|
|
139
|
+
if (targetElement !== event.currentTarget && (shouldIgnoreTarget?.(targetElement) || isInteractiveElement(targetElement))) return;
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
if (disabled) return;
|
|
142
|
+
store.state.inputRef.current?.focus();
|
|
143
|
+
if (store.state.openOnInputClick) store.state.setOpen(true, createChangeEventDetails(inputPress, event.nativeEvent));
|
|
144
|
+
}
|
|
145
|
+
const ComboboxInputGroup_ComboboxInputGroup = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
146
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
147
|
+
const { state: fieldState } = useFieldRootContext();
|
|
148
|
+
const store = useComboboxRootContext();
|
|
149
|
+
const { filteredItems } = useComboboxDerivedItemsContext();
|
|
150
|
+
const open = useStore(store, selectors.open);
|
|
151
|
+
const mounted = useStore(store, selectors.mounted);
|
|
152
|
+
const popupSideValue = useStore(store, selectors.popupSide);
|
|
153
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
154
|
+
const comboboxDisabled = useStore(store, selectors.disabled);
|
|
155
|
+
const readOnly = useStore(store, selectors.readOnly);
|
|
156
|
+
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
|
|
157
|
+
const selectionMode = useStore(store, selectors.selectionMode);
|
|
158
|
+
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
159
|
+
const disabled = comboboxDisabled;
|
|
160
|
+
const listEmpty = 0 === filteredItems.length;
|
|
161
|
+
const placeholder = 'none' === selectionMode ? false : !hasSelectedValue;
|
|
162
|
+
const state = {
|
|
163
|
+
...fieldState,
|
|
164
|
+
open,
|
|
165
|
+
disabled,
|
|
166
|
+
readOnly,
|
|
167
|
+
popupSide,
|
|
168
|
+
listEmpty,
|
|
169
|
+
placeholder
|
|
170
|
+
};
|
|
171
|
+
const setInputGroupElement = useStableCallback((element)=>{
|
|
172
|
+
store.set('inputGroupElement', element);
|
|
173
|
+
});
|
|
174
|
+
return useRenderElement('div', componentProps, {
|
|
175
|
+
ref: [
|
|
176
|
+
forwardedRef,
|
|
177
|
+
setInputGroupElement
|
|
178
|
+
],
|
|
179
|
+
props: [
|
|
180
|
+
{
|
|
181
|
+
role: 'group',
|
|
182
|
+
onMouseDown (event) {
|
|
183
|
+
handleInputPress(event, store, disabled, readOnly, (target)=>shadowDom_contains(store.state.chipsContainerRef.current, target));
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
elementProps
|
|
187
|
+
],
|
|
188
|
+
state,
|
|
189
|
+
stateAttributesMapping: triggerStateAttributesMapping
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
if ("production" !== process.env.NODE_ENV) ComboboxInputGroup_ComboboxInputGroup.displayName = "ComboboxInputGroup";
|
|
193
|
+
const ComboboxItemContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
194
|
+
if ("production" !== process.env.NODE_ENV) ComboboxItemContext.displayName = "ComboboxItemContext";
|
|
195
|
+
function useComboboxItemContext() {
|
|
196
|
+
const context = __rspack_external_react.useContext(ComboboxItemContext);
|
|
197
|
+
if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: ComboboxItemContext is missing. ComboboxItem parts must be placed within <Combobox.Item>.' : esm_formatErrorMessage(19));
|
|
198
|
+
return context;
|
|
199
|
+
}
|
|
200
|
+
const ComboboxRowContext = /*#__PURE__*/ __rspack_external_react.createContext(false);
|
|
201
|
+
if ("production" !== process.env.NODE_ENV) ComboboxRowContext.displayName = "ComboboxRowContext";
|
|
202
|
+
function useComboboxRowContext() {
|
|
203
|
+
return __rspack_external_react.useContext(ComboboxRowContext);
|
|
204
|
+
}
|
|
205
|
+
const ComboboxItem_ComboboxItem = /*#__PURE__*/ __rspack_external_react.memo(/*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
206
|
+
const { render, className, style, value: itemValue = null, index: indexProp, disabled = false, nativeButton = false, ...elementProps } = componentProps;
|
|
207
|
+
const didPointerDownRef = __rspack_external_react.useRef(false);
|
|
208
|
+
const textRef = __rspack_external_react.useRef(null);
|
|
209
|
+
const listItem = useCompositeListItem({
|
|
210
|
+
index: indexProp,
|
|
211
|
+
textRef,
|
|
212
|
+
indexGuessBehavior: useCompositeListItem_IndexGuessBehavior.GuessFromOrder
|
|
213
|
+
});
|
|
214
|
+
const store = useComboboxRootContext();
|
|
215
|
+
const isRow = useComboboxRowContext();
|
|
216
|
+
const { flatFilteredItems, hasItems } = useComboboxDerivedItemsContext();
|
|
217
|
+
const open = useStore(store, selectors.open);
|
|
218
|
+
const selectionMode = useStore(store, selectors.selectionMode);
|
|
219
|
+
const readOnly = useStore(store, selectors.readOnly);
|
|
220
|
+
const virtualized = useStore(store, selectors.virtualized);
|
|
221
|
+
const isItemEqualToValue = useStore(store, selectors.isItemEqualToValue);
|
|
222
|
+
const selectable = 'none' !== selectionMode;
|
|
223
|
+
const index = indexProp ?? (virtualized ? findItemIndex(flatFilteredItems, itemValue, isItemEqualToValue) : listItem.index);
|
|
224
|
+
const hasRegistered = -1 !== listItem.index;
|
|
225
|
+
const rootId = useStore(store, selectors.id);
|
|
226
|
+
const highlighted = useStore(store, selectors.isActive, index);
|
|
227
|
+
const matchesSelectedValue = useStore(store, selectors.isSelected, itemValue);
|
|
228
|
+
const itemProps = useStore(store, selectors.itemProps);
|
|
229
|
+
const itemRef = __rspack_external_react.useRef(null);
|
|
230
|
+
const id = null != rootId && hasRegistered ? `${rootId}-${index}` : void 0;
|
|
231
|
+
const selected = matchesSelectedValue && selectable;
|
|
232
|
+
useIsoLayoutEffect(()=>{
|
|
233
|
+
const shouldRun = hasRegistered && (virtualized || null != indexProp);
|
|
234
|
+
if (!shouldRun) return;
|
|
235
|
+
const list = store.state.listRef.current;
|
|
236
|
+
list[index] = itemRef.current;
|
|
237
|
+
return ()=>{
|
|
238
|
+
delete list[index];
|
|
239
|
+
};
|
|
240
|
+
}, [
|
|
241
|
+
hasRegistered,
|
|
242
|
+
virtualized,
|
|
243
|
+
index,
|
|
244
|
+
indexProp,
|
|
245
|
+
store
|
|
246
|
+
]);
|
|
247
|
+
useIsoLayoutEffect(()=>{
|
|
248
|
+
if (!hasRegistered || hasItems) return;
|
|
249
|
+
const visibleMap = store.state.valuesRef.current;
|
|
250
|
+
visibleMap[index] = itemValue;
|
|
251
|
+
if ('none' !== selectionMode) store.state.allValuesRef.current.push(itemValue);
|
|
252
|
+
return ()=>{
|
|
253
|
+
delete visibleMap[index];
|
|
254
|
+
};
|
|
255
|
+
}, [
|
|
256
|
+
hasRegistered,
|
|
257
|
+
hasItems,
|
|
258
|
+
index,
|
|
259
|
+
itemValue,
|
|
260
|
+
store,
|
|
261
|
+
selectionMode
|
|
262
|
+
]);
|
|
263
|
+
useIsoLayoutEffect(()=>{
|
|
264
|
+
if (!open) {
|
|
265
|
+
didPointerDownRef.current = false;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (!hasRegistered || hasItems) return;
|
|
269
|
+
const selectedValue = store.state.selectedValue;
|
|
270
|
+
const lastSelectedValue = Array.isArray(selectedValue) ? selectedValue[selectedValue.length - 1] : selectedValue;
|
|
271
|
+
if (compareItemEquality(itemValue, lastSelectedValue, isItemEqualToValue)) store.set('selectedIndex', index);
|
|
272
|
+
}, [
|
|
273
|
+
hasRegistered,
|
|
274
|
+
hasItems,
|
|
275
|
+
open,
|
|
276
|
+
store,
|
|
277
|
+
index,
|
|
278
|
+
itemValue,
|
|
279
|
+
isItemEqualToValue
|
|
280
|
+
]);
|
|
281
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
282
|
+
disabled,
|
|
283
|
+
focusableWhenDisabled: true,
|
|
284
|
+
native: nativeButton,
|
|
285
|
+
composite: true
|
|
286
|
+
});
|
|
287
|
+
const state = {
|
|
288
|
+
disabled,
|
|
289
|
+
selected,
|
|
290
|
+
highlighted
|
|
291
|
+
};
|
|
292
|
+
function commitSelection(nativeEvent) {
|
|
293
|
+
function selectItem() {
|
|
294
|
+
store.state.handleSelection(nativeEvent, itemValue);
|
|
295
|
+
}
|
|
296
|
+
if (store.state.submitOnItemClick) {
|
|
297
|
+
__rspack_external_react_dom_7136dc57.flushSync(selectItem);
|
|
298
|
+
store.state.requestSubmit();
|
|
299
|
+
} else selectItem();
|
|
300
|
+
}
|
|
301
|
+
const defaultProps = {
|
|
302
|
+
id,
|
|
303
|
+
role: isRow ? 'gridcell' : 'option',
|
|
304
|
+
'aria-selected': selectable ? selected : void 0,
|
|
305
|
+
tabIndex: void 0,
|
|
306
|
+
onPointerDownCapture (event) {
|
|
307
|
+
didPointerDownRef.current = true;
|
|
308
|
+
event.preventDefault();
|
|
309
|
+
},
|
|
310
|
+
onMouseDown (event) {
|
|
311
|
+
event.preventDefault();
|
|
312
|
+
},
|
|
313
|
+
onClick (event) {
|
|
314
|
+
if (disabled || readOnly) return;
|
|
315
|
+
commitSelection(event.nativeEvent);
|
|
316
|
+
},
|
|
317
|
+
onMouseUp (event) {
|
|
318
|
+
const pointerStartedOnItem = didPointerDownRef.current;
|
|
319
|
+
didPointerDownRef.current = false;
|
|
320
|
+
if (disabled || readOnly || 0 !== event.button || pointerStartedOnItem || !highlighted) return;
|
|
321
|
+
commitSelection(event.nativeEvent);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
const element = useRenderElement('div', componentProps, {
|
|
325
|
+
ref: [
|
|
326
|
+
buttonRef,
|
|
327
|
+
forwardedRef,
|
|
328
|
+
listItem.ref,
|
|
329
|
+
itemRef
|
|
330
|
+
],
|
|
331
|
+
state,
|
|
332
|
+
props: [
|
|
333
|
+
itemProps,
|
|
334
|
+
defaultProps,
|
|
335
|
+
elementProps,
|
|
336
|
+
getButtonProps
|
|
337
|
+
]
|
|
338
|
+
});
|
|
339
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
340
|
+
selected,
|
|
341
|
+
textRef
|
|
342
|
+
}), [
|
|
343
|
+
selected,
|
|
344
|
+
textRef
|
|
345
|
+
]);
|
|
346
|
+
return /*#__PURE__*/ jsx(ComboboxItemContext.Provider, {
|
|
347
|
+
value: contextValue,
|
|
348
|
+
children: element
|
|
349
|
+
});
|
|
350
|
+
}));
|
|
351
|
+
if ("production" !== process.env.NODE_ENV) ComboboxItem_ComboboxItem.displayName = "ComboboxItem";
|
|
352
|
+
const ComboboxChipsContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
353
|
+
if ("production" !== process.env.NODE_ENV) ComboboxChipsContext.displayName = "ComboboxChipsContext";
|
|
354
|
+
function useComboboxChipsContext() {
|
|
355
|
+
return __rspack_external_react.useContext(ComboboxChipsContext);
|
|
356
|
+
}
|
|
357
|
+
const ComboboxPositionerContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
358
|
+
if ("production" !== process.env.NODE_ENV) ComboboxPositionerContext.displayName = "ComboboxPositionerContext";
|
|
359
|
+
function useComboboxPositionerContext(optional) {
|
|
360
|
+
const context = __rspack_external_react.useContext(ComboboxPositionerContext);
|
|
361
|
+
if (void 0 === context && !optional) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: <Combobox.Popup> and <Combobox.Arrow> must be used within the <Combobox.Positioner> component' : esm_formatErrorMessage(21));
|
|
362
|
+
return context;
|
|
363
|
+
}
|
|
364
|
+
const ComboboxInternalDismissButton_ComboboxInternalDismissButton = /*#__PURE__*/ __rspack_external_react.forwardRef(function(_, forwardedRef) {
|
|
365
|
+
const store = useComboboxRootContext();
|
|
366
|
+
const { buttonRef, getButtonProps } = useButton({
|
|
367
|
+
native: false
|
|
368
|
+
});
|
|
369
|
+
const mergedRef = useMergedRefs(forwardedRef, buttonRef);
|
|
370
|
+
function handleDismiss(event) {
|
|
371
|
+
store.state.setOpen(false, createChangeEventDetails(closePress, event.nativeEvent, event.currentTarget));
|
|
372
|
+
}
|
|
373
|
+
const dismissProps = getButtonProps({
|
|
374
|
+
onClick: handleDismiss
|
|
375
|
+
});
|
|
376
|
+
return /*#__PURE__*/ jsx("span", {
|
|
377
|
+
ref: mergedRef,
|
|
378
|
+
...dismissProps,
|
|
379
|
+
"aria-label": "Dismiss",
|
|
380
|
+
tabIndex: void 0,
|
|
381
|
+
style: visuallyHiddenInput
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
if ("production" !== process.env.NODE_ENV) ComboboxInternalDismissButton_ComboboxInternalDismissButton.displayName = "ComboboxInternalDismissButton";
|
|
385
|
+
const ComboboxInput_ComboboxInput = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
386
|
+
const { render, className, disabled: disabledProp = false, id: idProp, style, ...elementProps } = componentProps;
|
|
387
|
+
const { state: fieldState, disabled: fieldDisabled, setTouched, setFocused, validationMode, validation } = useFieldRootContext();
|
|
388
|
+
const { labelId: fieldLabelId } = useLabelableContext();
|
|
389
|
+
const comboboxChipsContext = useComboboxChipsContext();
|
|
390
|
+
const positioning = useComboboxPositionerContext(true);
|
|
391
|
+
const hasPositionerParent = Boolean(positioning);
|
|
392
|
+
const store = useComboboxRootContext();
|
|
393
|
+
const { filteredItems } = useComboboxDerivedItemsContext();
|
|
394
|
+
const inputValue = useComboboxInputValueContext();
|
|
395
|
+
const direction = useDirection();
|
|
396
|
+
const required = useStore(store, selectors.required);
|
|
397
|
+
const comboboxDisabled = useStore(store, selectors.disabled);
|
|
398
|
+
const readOnly = useStore(store, selectors.readOnly);
|
|
399
|
+
const name = useStore(store, selectors.name);
|
|
400
|
+
const form = useStore(store, selectors.form);
|
|
401
|
+
const selectionMode = useStore(store, selectors.selectionMode);
|
|
402
|
+
const autoHighlightMode = useStore(store, selectors.autoHighlight);
|
|
403
|
+
const inputProps = useStore(store, selectors.inputProps);
|
|
404
|
+
const triggerProps = useStore(store, selectors.triggerProps);
|
|
405
|
+
const open = useStore(store, selectors.open);
|
|
406
|
+
const mounted = useStore(store, selectors.mounted);
|
|
407
|
+
const selectedValue = useStore(store, selectors.selectedValue);
|
|
408
|
+
const popupSideValue = useStore(store, selectors.popupSide);
|
|
409
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
410
|
+
const rootId = useStore(store, selectors.id);
|
|
411
|
+
const inline = useStore(store, selectors.inline);
|
|
412
|
+
const modal = useStore(store, selectors.modal);
|
|
413
|
+
const autoHighlightEnabled = Boolean(autoHighlightMode);
|
|
414
|
+
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
415
|
+
const disabled = fieldDisabled || comboboxDisabled || disabledProp;
|
|
416
|
+
const listEmpty = 0 === filteredItems.length;
|
|
417
|
+
const isInsidePopup = hasPositionerParent || inline;
|
|
418
|
+
const focusManagerModal = !isInsidePopup || modal;
|
|
419
|
+
const id = useBaseUiId(idProp ?? (isInsidePopup ? void 0 : rootId));
|
|
420
|
+
const ariaLabelledBy = resolveAriaLabelledBy(fieldLabelId, void 0);
|
|
421
|
+
const fieldStateForInput = hasPositionerParent ? DEFAULT_FIELD_STATE_ATTRIBUTES : fieldState;
|
|
422
|
+
const [composingValue, setComposingValue] = __rspack_external_react.useState(null);
|
|
423
|
+
const isComposingRef = __rspack_external_react.useRef(false);
|
|
424
|
+
const lastActiveIndexRef = __rspack_external_react.useRef(null);
|
|
425
|
+
const shouldRestoreActiveIndexRef = __rspack_external_react.useRef(false);
|
|
426
|
+
const inputOwnsFormValue = 'none' === selectionMode && !hasPositionerParent;
|
|
427
|
+
const setInputElement = useStableCallback((element)=>{
|
|
428
|
+
const nextIsInsidePopup = hasPositionerParent || store.state.inline;
|
|
429
|
+
if (nextIsInsidePopup && !store.state.hasInputValue) store.state.setInputValue('', createChangeEventDetails("none"));
|
|
430
|
+
store.update({
|
|
431
|
+
inputElement: element,
|
|
432
|
+
inputInsidePopup: nextIsInsidePopup,
|
|
433
|
+
inputOwnsFormValue
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
const validationProps = hasPositionerParent || !validation ? elementProps : validation.getValidationProps(elementProps);
|
|
437
|
+
const state = {
|
|
438
|
+
...fieldStateForInput,
|
|
439
|
+
open,
|
|
440
|
+
disabled,
|
|
441
|
+
readOnly,
|
|
442
|
+
popupSide,
|
|
443
|
+
listEmpty
|
|
444
|
+
};
|
|
445
|
+
function handleKeyDown(event) {
|
|
446
|
+
if (!comboboxChipsContext) return;
|
|
447
|
+
let nextIndex;
|
|
448
|
+
const { highlightedChipIndex } = comboboxChipsContext;
|
|
449
|
+
const renderedChipsCount = comboboxChipsContext.chipsRef.current.length;
|
|
450
|
+
const isRtl = 'rtl' === direction;
|
|
451
|
+
const previousChipKey = isRtl ? 'ArrowRight' : 'ArrowLeft';
|
|
452
|
+
const nextChipKey = isRtl ? 'ArrowLeft' : 'ArrowRight';
|
|
453
|
+
if (void 0 !== highlightedChipIndex) {
|
|
454
|
+
if (event.key === previousChipKey) {
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
nextIndex = highlightedChipIndex > 0 ? highlightedChipIndex - 1 : void 0;
|
|
457
|
+
} else if (event.key === nextChipKey) {
|
|
458
|
+
event.preventDefault();
|
|
459
|
+
nextIndex = highlightedChipIndex < renderedChipsCount - 1 ? highlightedChipIndex + 1 : void 0;
|
|
460
|
+
} else if ('Backspace' === event.key || 'Delete' === event.key) {
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
const computedNextIndex = highlightedChipIndex >= selectedValue.length - 1 ? selectedValue.length - 2 : highlightedChipIndex;
|
|
463
|
+
nextIndex = computedNextIndex >= 0 ? computedNextIndex : void 0;
|
|
464
|
+
store.state.setIndices({
|
|
465
|
+
activeIndex: null,
|
|
466
|
+
selectedIndex: null,
|
|
467
|
+
type: 'keyboard'
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return nextIndex;
|
|
471
|
+
}
|
|
472
|
+
if (event.key === previousChipKey && (event.currentTarget.selectionStart ?? 0) === 0 && selectedValue.length > 0) {
|
|
473
|
+
event.preventDefault();
|
|
474
|
+
nextIndex = renderedChipsCount > 0 ? renderedChipsCount - 1 : void 0;
|
|
475
|
+
} else if ('Backspace' === event.key && '' === event.currentTarget.value && selectedValue.length > 0) {
|
|
476
|
+
store.state.setIndices({
|
|
477
|
+
activeIndex: null,
|
|
478
|
+
selectedIndex: null,
|
|
479
|
+
type: 'keyboard'
|
|
480
|
+
});
|
|
481
|
+
event.preventDefault();
|
|
482
|
+
}
|
|
483
|
+
return nextIndex;
|
|
484
|
+
}
|
|
485
|
+
const element = useRenderElement('input', componentProps, {
|
|
486
|
+
state,
|
|
487
|
+
ref: [
|
|
488
|
+
forwardedRef,
|
|
489
|
+
store.state.inputRef,
|
|
490
|
+
setInputElement
|
|
491
|
+
],
|
|
492
|
+
props: [
|
|
493
|
+
inputProps,
|
|
494
|
+
triggerProps,
|
|
495
|
+
{
|
|
496
|
+
type: 'text',
|
|
497
|
+
value: componentProps.value ?? composingValue ?? inputValue,
|
|
498
|
+
'aria-readonly': readOnly || void 0,
|
|
499
|
+
'aria-required': required || void 0,
|
|
500
|
+
'aria-labelledby': ariaLabelledBy,
|
|
501
|
+
disabled,
|
|
502
|
+
readOnly,
|
|
503
|
+
required: 'none' === selectionMode ? required : void 0,
|
|
504
|
+
form,
|
|
505
|
+
...inputOwnsFormValue && name && {
|
|
506
|
+
name
|
|
507
|
+
},
|
|
508
|
+
id,
|
|
509
|
+
onFocus () {
|
|
510
|
+
setFocused(true);
|
|
511
|
+
if (!inline || !shouldRestoreActiveIndexRef.current) return;
|
|
512
|
+
shouldRestoreActiveIndexRef.current = false;
|
|
513
|
+
const nextActiveIndex = lastActiveIndexRef.current;
|
|
514
|
+
if (null == nextActiveIndex || !Object.hasOwn(store.state.valuesRef.current, nextActiveIndex)) return;
|
|
515
|
+
store.state.setIndices({
|
|
516
|
+
activeIndex: nextActiveIndex
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
onBlur () {
|
|
520
|
+
setTouched(true);
|
|
521
|
+
setFocused(false);
|
|
522
|
+
const activeIndex = store.state.activeIndex;
|
|
523
|
+
if (inline && null !== activeIndex && 'always' !== autoHighlightMode) {
|
|
524
|
+
lastActiveIndexRef.current = activeIndex;
|
|
525
|
+
shouldRestoreActiveIndexRef.current = true;
|
|
526
|
+
store.state.setIndices({
|
|
527
|
+
activeIndex: null
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
if ('onBlur' === validationMode) {
|
|
531
|
+
const valueToValidate = 'none' === selectionMode ? inputValue : selectedValue;
|
|
532
|
+
validation.commit(valueToValidate);
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
onCompositionStart (event) {
|
|
536
|
+
if (isAndroid) return;
|
|
537
|
+
isComposingRef.current = true;
|
|
538
|
+
setComposingValue(event.currentTarget.value);
|
|
539
|
+
},
|
|
540
|
+
onCompositionEnd (event) {
|
|
541
|
+
isComposingRef.current = false;
|
|
542
|
+
const next = event.currentTarget.value;
|
|
543
|
+
setComposingValue(null);
|
|
544
|
+
store.state.setInputValue(next, createChangeEventDetails(inputChange, event.nativeEvent));
|
|
545
|
+
},
|
|
546
|
+
onChange (event) {
|
|
547
|
+
const inputType = event.nativeEvent.inputType;
|
|
548
|
+
const autofillLikeInput = !inputType || 'insertReplacementText' === inputType;
|
|
549
|
+
const shouldOpenOnInput = isComposingRef.current || !autofillLikeInput;
|
|
550
|
+
if (isComposingRef.current) {
|
|
551
|
+
const nextVal = event.currentTarget.value;
|
|
552
|
+
setComposingValue(nextVal);
|
|
553
|
+
if ('' === nextVal && !store.state.openOnInputClick && !store.state.inputInsidePopup) store.state.setOpen(false, createChangeEventDetails(inputClear, event.nativeEvent));
|
|
554
|
+
const trimmed = nextVal.trim();
|
|
555
|
+
const shouldMaintainHighlight = autoHighlightEnabled && '' !== trimmed;
|
|
556
|
+
if (!readOnly && !disabled && trimmed) {
|
|
557
|
+
if (shouldOpenOnInput) {
|
|
558
|
+
store.state.setOpen(true, createChangeEventDetails(inputChange, event.nativeEvent));
|
|
559
|
+
if (!autoHighlightEnabled) store.state.setIndices({
|
|
560
|
+
activeIndex: null,
|
|
561
|
+
selectedIndex: null,
|
|
562
|
+
type: store.state.keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (open && null !== store.state.activeIndex && !shouldMaintainHighlight) store.state.setIndices({
|
|
567
|
+
activeIndex: null,
|
|
568
|
+
selectedIndex: null,
|
|
569
|
+
type: store.state.keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
570
|
+
});
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
store.state.setInputValue(event.currentTarget.value, createChangeEventDetails(inputChange, event.nativeEvent));
|
|
574
|
+
const empty = '' === event.currentTarget.value;
|
|
575
|
+
const clearDetails = createChangeEventDetails(inputClear, event.nativeEvent);
|
|
576
|
+
if (empty && !store.state.inputInsidePopup) {
|
|
577
|
+
if ('single' === selectionMode) store.state.setSelectedValue(null, clearDetails);
|
|
578
|
+
if (!store.state.openOnInputClick) store.state.setOpen(false, clearDetails);
|
|
579
|
+
}
|
|
580
|
+
const trimmed = event.currentTarget.value.trim();
|
|
581
|
+
if (!readOnly && !disabled && trimmed) {
|
|
582
|
+
if (shouldOpenOnInput) {
|
|
583
|
+
store.state.setOpen(true, createChangeEventDetails(inputChange, event.nativeEvent));
|
|
584
|
+
if (!autoHighlightEnabled) store.state.setIndices({
|
|
585
|
+
activeIndex: null,
|
|
586
|
+
selectedIndex: null,
|
|
587
|
+
type: store.state.keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (open && null !== store.state.activeIndex && !autoHighlightEnabled) store.state.setIndices({
|
|
592
|
+
activeIndex: null,
|
|
593
|
+
selectedIndex: null,
|
|
594
|
+
type: store.state.keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
595
|
+
});
|
|
596
|
+
},
|
|
597
|
+
onKeyDown (event) {
|
|
598
|
+
if (disabled || readOnly) return;
|
|
599
|
+
if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) return;
|
|
600
|
+
store.state.keyboardActiveRef.current = true;
|
|
601
|
+
const input = event.currentTarget;
|
|
602
|
+
const scrollAmount = input.scrollWidth - input.clientWidth;
|
|
603
|
+
const isRTL = 'rtl' === direction;
|
|
604
|
+
if ('Home' === event.key) {
|
|
605
|
+
stopEvent(event);
|
|
606
|
+
const cursor = isFirefox && isRTL ? input.value.length : 0;
|
|
607
|
+
input.setSelectionRange(cursor, cursor);
|
|
608
|
+
input.scrollLeft = 0;
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if ('End' === event.key) {
|
|
612
|
+
stopEvent(event);
|
|
613
|
+
const cursor = isFirefox && isRTL ? 0 : input.value.length;
|
|
614
|
+
input.setSelectionRange(cursor, cursor);
|
|
615
|
+
input.scrollLeft = isRTL ? -scrollAmount : scrollAmount;
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (!mounted && 'Escape' === event.key) {
|
|
619
|
+
const isClear = 'multiple' === selectionMode && Array.isArray(selectedValue) ? 0 === selectedValue.length : null === selectedValue;
|
|
620
|
+
const details = createChangeEventDetails(escapeKey, event.nativeEvent);
|
|
621
|
+
const value = 'multiple' === selectionMode ? [] : null;
|
|
622
|
+
store.state.setInputValue('', details);
|
|
623
|
+
store.state.setSelectedValue(value, details);
|
|
624
|
+
if (!isClear && !store.state.inline && !details.isPropagationAllowed) event.stopPropagation();
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (comboboxChipsContext && 'Backspace' === event.key && '' === input.value && void 0 === comboboxChipsContext.highlightedChipIndex && Array.isArray(selectedValue) && selectedValue.length > 0) {
|
|
628
|
+
const renderedChipsCount = comboboxChipsContext.chipsRef.current.length;
|
|
629
|
+
const removalIndex = renderedChipsCount > 0 ? renderedChipsCount - 1 : selectedValue.length - 1;
|
|
630
|
+
const newValue = selectedValue.filter((_, index)=>index !== removalIndex);
|
|
631
|
+
store.state.setIndices({
|
|
632
|
+
activeIndex: null,
|
|
633
|
+
selectedIndex: null,
|
|
634
|
+
type: store.state.keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
635
|
+
});
|
|
636
|
+
store.state.setSelectedValue(newValue, createChangeEventDetails("none", event.nativeEvent));
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
const hadHighlightedChip = comboboxChipsContext?.highlightedChipIndex !== void 0;
|
|
640
|
+
const nextIndex = handleKeyDown(event);
|
|
641
|
+
comboboxChipsContext?.setHighlightedChipIndex(nextIndex);
|
|
642
|
+
if (void 0 !== nextIndex) comboboxChipsContext?.chipsRef.current[nextIndex]?.focus();
|
|
643
|
+
else if (hadHighlightedChip) store.state.inputRef.current?.focus();
|
|
644
|
+
if (229 === event.which) return;
|
|
645
|
+
if ('Enter' === event.key && open) {
|
|
646
|
+
const activeIndex = store.state.activeIndex;
|
|
647
|
+
const nativeEvent = event.nativeEvent;
|
|
648
|
+
if (null === activeIndex) {
|
|
649
|
+
if (inline) return;
|
|
650
|
+
store.state.setOpen(false, createChangeEventDetails("none", nativeEvent));
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
stopEvent(event);
|
|
654
|
+
const listItem = store.state.listRef.current[activeIndex];
|
|
655
|
+
if (listItem) {
|
|
656
|
+
store.state.selectionEventRef.current = nativeEvent;
|
|
657
|
+
listItem.click();
|
|
658
|
+
store.state.selectionEventRef.current = null;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
onPointerMove () {
|
|
663
|
+
store.state.keyboardActiveRef.current = false;
|
|
664
|
+
},
|
|
665
|
+
onPointerDown () {
|
|
666
|
+
store.state.keyboardActiveRef.current = false;
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
validationProps
|
|
670
|
+
],
|
|
671
|
+
stateAttributesMapping: triggerStateAttributesMapping
|
|
672
|
+
});
|
|
673
|
+
const renderedInput = hasPositionerParent ? /*#__PURE__*/ jsx(FieldRootContext.Provider, {
|
|
674
|
+
value: DEFAULT_FIELD_ROOT_CONTEXT,
|
|
675
|
+
children: element
|
|
676
|
+
}) : element;
|
|
677
|
+
return /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
678
|
+
children: [
|
|
679
|
+
open && focusManagerModal && /*#__PURE__*/ jsx(ComboboxInternalDismissButton_ComboboxInternalDismissButton, {
|
|
680
|
+
ref: store.state.startDismissRef
|
|
681
|
+
}),
|
|
682
|
+
renderedInput
|
|
683
|
+
]
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
if ("production" !== process.env.NODE_ENV) ComboboxInput_ComboboxInput.displayName = "ComboboxInput";
|
|
687
|
+
const ComboboxIcon_ComboboxIcon = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
688
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
689
|
+
const element = useRenderElement('span', componentProps, {
|
|
690
|
+
ref: forwardedRef,
|
|
691
|
+
props: [
|
|
692
|
+
{
|
|
693
|
+
'aria-hidden': true,
|
|
694
|
+
children: '▼'
|
|
695
|
+
},
|
|
696
|
+
elementProps
|
|
697
|
+
]
|
|
698
|
+
});
|
|
699
|
+
return element;
|
|
700
|
+
});
|
|
701
|
+
if ("production" !== process.env.NODE_ENV) ComboboxIcon_ComboboxIcon.displayName = "ComboboxIcon";
|
|
702
|
+
const stateAttributesMapping = {
|
|
703
|
+
...transitionStatusMapping,
|
|
704
|
+
...triggerOpenStateMapping
|
|
705
|
+
};
|
|
706
|
+
const ComboboxClear_ComboboxClear = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
707
|
+
const { render, className, disabled: disabledProp = false, nativeButton = true, keepMounted = false, style, ...elementProps } = componentProps;
|
|
708
|
+
const { disabled: fieldDisabled } = useFieldRootContext();
|
|
709
|
+
const store = useComboboxRootContext();
|
|
710
|
+
const selectionMode = useStore(store, selectors.selectionMode);
|
|
711
|
+
const comboboxDisabled = useStore(store, selectors.disabled);
|
|
712
|
+
const readOnly = useStore(store, selectors.readOnly);
|
|
713
|
+
const open = useStore(store, selectors.open);
|
|
714
|
+
const selectedValue = useStore(store, selectors.selectedValue);
|
|
715
|
+
const hasSelectionChips = useStore(store, selectors.hasSelectionChips);
|
|
716
|
+
const inputValue = useComboboxInputValueContext();
|
|
717
|
+
let visible = false;
|
|
718
|
+
visible = 'none' === selectionMode ? '' !== inputValue : 'single' === selectionMode ? null != selectedValue : hasSelectionChips;
|
|
719
|
+
const disabled = fieldDisabled || comboboxDisabled || disabledProp;
|
|
720
|
+
const { buttonRef, getButtonProps } = useButton({
|
|
721
|
+
native: nativeButton,
|
|
722
|
+
disabled
|
|
723
|
+
});
|
|
724
|
+
const { mounted, transitionStatus, setMounted } = useTransitionStatus(visible);
|
|
725
|
+
const state = {
|
|
726
|
+
disabled,
|
|
727
|
+
visible,
|
|
728
|
+
open,
|
|
729
|
+
transitionStatus
|
|
730
|
+
};
|
|
731
|
+
useOpenChangeComplete({
|
|
732
|
+
open: visible,
|
|
733
|
+
ref: store.state.clearRef,
|
|
734
|
+
onComplete () {
|
|
735
|
+
if (!visible) setMounted(false);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
const element = useRenderElement('button', componentProps, {
|
|
739
|
+
state,
|
|
740
|
+
ref: [
|
|
741
|
+
forwardedRef,
|
|
742
|
+
buttonRef,
|
|
743
|
+
store.state.clearRef
|
|
744
|
+
],
|
|
745
|
+
props: [
|
|
746
|
+
{
|
|
747
|
+
tabIndex: -1,
|
|
748
|
+
children: 'x',
|
|
749
|
+
onMouseDown (event) {
|
|
750
|
+
event.preventDefault();
|
|
751
|
+
},
|
|
752
|
+
onClick (event) {
|
|
753
|
+
if (disabled || readOnly) return;
|
|
754
|
+
const keyboardActiveRef = store.state.keyboardActiveRef;
|
|
755
|
+
store.state.setInputValue('', createChangeEventDetails(clearPress, event.nativeEvent));
|
|
756
|
+
if ('none' !== selectionMode) {
|
|
757
|
+
store.state.setSelectedValue(Array.isArray(selectedValue) ? [] : null, createChangeEventDetails(clearPress, event.nativeEvent));
|
|
758
|
+
store.state.setIndices({
|
|
759
|
+
activeIndex: null,
|
|
760
|
+
selectedIndex: null,
|
|
761
|
+
type: keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
762
|
+
});
|
|
763
|
+
} else store.state.setIndices({
|
|
764
|
+
activeIndex: null,
|
|
765
|
+
type: keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
766
|
+
});
|
|
767
|
+
store.state.inputRef.current?.focus();
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
elementProps,
|
|
771
|
+
getButtonProps
|
|
772
|
+
],
|
|
773
|
+
stateAttributesMapping: stateAttributesMapping
|
|
774
|
+
});
|
|
775
|
+
const shouldRender = keepMounted || mounted;
|
|
776
|
+
if (!shouldRender) return null;
|
|
777
|
+
return element;
|
|
778
|
+
});
|
|
779
|
+
if ("production" !== process.env.NODE_ENV) ComboboxClear_ComboboxClear.displayName = "ComboboxClear";
|
|
780
|
+
const GroupCollectionContext = /*#__PURE__*/ __rspack_external_react.createContext(null);
|
|
781
|
+
if ("production" !== process.env.NODE_ENV) GroupCollectionContext.displayName = "GroupCollectionContext";
|
|
782
|
+
function useGroupCollectionContext() {
|
|
783
|
+
return __rspack_external_react.useContext(GroupCollectionContext);
|
|
784
|
+
}
|
|
785
|
+
function GroupCollectionProvider(props) {
|
|
786
|
+
const { children, items } = props;
|
|
787
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
788
|
+
items
|
|
789
|
+
}), [
|
|
790
|
+
items
|
|
791
|
+
]);
|
|
792
|
+
return /*#__PURE__*/ jsx(GroupCollectionContext.Provider, {
|
|
793
|
+
value: contextValue,
|
|
794
|
+
children: children
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
function ComboboxCollection(props) {
|
|
798
|
+
const { children } = props;
|
|
799
|
+
const { filteredItems } = useComboboxDerivedItemsContext();
|
|
800
|
+
const groupContext = useGroupCollectionContext();
|
|
801
|
+
const itemsToRender = groupContext ? groupContext.items : filteredItems;
|
|
802
|
+
if (!itemsToRender) return null;
|
|
803
|
+
return /*#__PURE__*/ jsx(__rspack_external_react.Fragment, {
|
|
804
|
+
children: itemsToRender.map(children)
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
const ComboboxList_ComboboxList = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
808
|
+
var _ComboboxCollection;
|
|
809
|
+
const { render, className, style, children, ...elementProps } = componentProps;
|
|
810
|
+
const store = useComboboxRootContext();
|
|
811
|
+
const floatingRootContext = useComboboxFloatingContext();
|
|
812
|
+
const hasPositionerContext = Boolean(useComboboxPositionerContext(true));
|
|
813
|
+
const { filteredItems, hasItems } = useComboboxDerivedItemsContext();
|
|
814
|
+
const selectionMode = useStore(store, selectors.selectionMode);
|
|
815
|
+
const grid = useStore(store, selectors.grid);
|
|
816
|
+
const popupProps = useStore(store, selectors.popupProps);
|
|
817
|
+
const virtualized = useStore(store, selectors.virtualized);
|
|
818
|
+
const multiple = 'multiple' === selectionMode;
|
|
819
|
+
const empty = 0 === filteredItems.length;
|
|
820
|
+
const setPositionerElement = useStableCallback((element)=>{
|
|
821
|
+
store.set('positionerElement', element);
|
|
822
|
+
});
|
|
823
|
+
const setListElement = useStableCallback((element)=>{
|
|
824
|
+
store.set('listElement', element);
|
|
825
|
+
});
|
|
826
|
+
const resolvedChildren = __rspack_external_react.useMemo(()=>{
|
|
827
|
+
if ('function' == typeof children) return _ComboboxCollection || (_ComboboxCollection = /*#__PURE__*/ jsx(ComboboxCollection, {
|
|
828
|
+
children: children
|
|
829
|
+
}));
|
|
830
|
+
return children;
|
|
831
|
+
}, [
|
|
832
|
+
children
|
|
833
|
+
]);
|
|
834
|
+
const state = {
|
|
835
|
+
empty
|
|
836
|
+
};
|
|
837
|
+
const floatingId = floatingRootContext.useState('floatingId');
|
|
838
|
+
const element = useRenderElement('div', componentProps, {
|
|
839
|
+
state,
|
|
840
|
+
ref: [
|
|
841
|
+
forwardedRef,
|
|
842
|
+
setListElement,
|
|
843
|
+
hasPositionerContext ? null : setPositionerElement
|
|
844
|
+
],
|
|
845
|
+
props: [
|
|
846
|
+
popupProps,
|
|
847
|
+
{
|
|
848
|
+
children: resolvedChildren,
|
|
849
|
+
tabIndex: -1,
|
|
850
|
+
id: floatingId,
|
|
851
|
+
role: grid ? 'grid' : 'listbox',
|
|
852
|
+
'aria-multiselectable': multiple ? 'true' : void 0,
|
|
853
|
+
onKeyDown (event) {
|
|
854
|
+
if (store.state.disabled || store.state.readOnly) return;
|
|
855
|
+
if ('Enter' === event.key) {
|
|
856
|
+
const activeIndex = store.state.activeIndex;
|
|
857
|
+
if (null == activeIndex) return;
|
|
858
|
+
stopEvent(event);
|
|
859
|
+
const nativeEvent = event.nativeEvent;
|
|
860
|
+
const listItem = store.state.listRef.current[activeIndex];
|
|
861
|
+
if (listItem) {
|
|
862
|
+
store.state.selectionEventRef.current = nativeEvent;
|
|
863
|
+
listItem.click();
|
|
864
|
+
store.state.selectionEventRef.current = null;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
onKeyDownCapture () {
|
|
869
|
+
store.state.keyboardActiveRef.current = true;
|
|
870
|
+
},
|
|
871
|
+
onPointerMoveCapture () {
|
|
872
|
+
store.state.keyboardActiveRef.current = false;
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
elementProps
|
|
876
|
+
]
|
|
877
|
+
});
|
|
878
|
+
if (virtualized) return element;
|
|
879
|
+
return /*#__PURE__*/ jsx(CompositeList, {
|
|
880
|
+
elementsRef: store.state.listRef,
|
|
881
|
+
labelsRef: hasItems ? void 0 : store.state.labelsRef,
|
|
882
|
+
children: element
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
if ("production" !== process.env.NODE_ENV) ComboboxList_ComboboxList.displayName = "ComboboxList";
|
|
886
|
+
const LIVE_REGION_MARKER = '\u2060';
|
|
887
|
+
const INITIAL_LIVE_REGION_TEXT_MUTATION_RESET_DELAY = 200;
|
|
888
|
+
function findLastTextNode(root) {
|
|
889
|
+
const walker = root.ownerDocument.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
890
|
+
let lastTextNode = null;
|
|
891
|
+
while(walker.nextNode()){
|
|
892
|
+
const textNode = walker.currentNode;
|
|
893
|
+
if ('' !== textNode.nodeValue) lastTextNode = textNode;
|
|
894
|
+
}
|
|
895
|
+
return lastTextNode;
|
|
896
|
+
}
|
|
897
|
+
function useInitialLiveRegionTextMutation() {
|
|
898
|
+
const timeout = useTimeout();
|
|
899
|
+
const rootRef = __rspack_external_react.useRef(null);
|
|
900
|
+
__rspack_external_react.useEffect(()=>{
|
|
901
|
+
if (isIOS) return;
|
|
902
|
+
const root = rootRef.current;
|
|
903
|
+
if (null == root) return;
|
|
904
|
+
const textNode = findLastTextNode(root);
|
|
905
|
+
if (null == textNode) return;
|
|
906
|
+
const originalValue = textNode.nodeValue ?? '';
|
|
907
|
+
const markedValue = `${originalValue}${LIVE_REGION_MARKER}`;
|
|
908
|
+
textNode.nodeValue = markedValue;
|
|
909
|
+
timeout.start(INITIAL_LIVE_REGION_TEXT_MUTATION_RESET_DELAY, ()=>{
|
|
910
|
+
if (textNode.nodeValue === markedValue) textNode.nodeValue = originalValue;
|
|
911
|
+
});
|
|
912
|
+
return ()=>{
|
|
913
|
+
timeout.clear();
|
|
914
|
+
if (textNode.nodeValue === markedValue) textNode.nodeValue = originalValue;
|
|
915
|
+
};
|
|
916
|
+
}, [
|
|
917
|
+
rootRef,
|
|
918
|
+
timeout
|
|
919
|
+
]);
|
|
920
|
+
return rootRef;
|
|
921
|
+
}
|
|
922
|
+
const ComboboxStatus_ComboboxStatus = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
923
|
+
const { render, className, style, children: childrenProp, ...elementProps } = componentProps;
|
|
924
|
+
const statusRef = useInitialLiveRegionTextMutation();
|
|
925
|
+
return useRenderElement('div', componentProps, {
|
|
926
|
+
ref: [
|
|
927
|
+
forwardedRef,
|
|
928
|
+
statusRef
|
|
929
|
+
],
|
|
930
|
+
props: [
|
|
931
|
+
{
|
|
932
|
+
children: childrenProp,
|
|
933
|
+
role: 'status',
|
|
934
|
+
'aria-live': 'polite',
|
|
935
|
+
'aria-atomic': true
|
|
936
|
+
},
|
|
937
|
+
elementProps
|
|
938
|
+
]
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
if ("production" !== process.env.NODE_ENV) ComboboxStatus_ComboboxStatus.displayName = "ComboboxStatus";
|
|
942
|
+
const ComboboxBackdrop_stateAttributesMapping = {
|
|
943
|
+
...popupStateMapping,
|
|
944
|
+
...transitionStatusMapping
|
|
945
|
+
};
|
|
946
|
+
const ComboboxBackdrop_ComboboxBackdrop = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
947
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
948
|
+
const store = useComboboxRootContext();
|
|
949
|
+
const open = useStore(store, selectors.open);
|
|
950
|
+
const mounted = useStore(store, selectors.mounted);
|
|
951
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
952
|
+
const state = {
|
|
953
|
+
open,
|
|
954
|
+
transitionStatus
|
|
955
|
+
};
|
|
956
|
+
return useRenderElement('div', componentProps, {
|
|
957
|
+
state,
|
|
958
|
+
ref: forwardedRef,
|
|
959
|
+
stateAttributesMapping: ComboboxBackdrop_stateAttributesMapping,
|
|
960
|
+
props: [
|
|
961
|
+
{
|
|
962
|
+
role: 'presentation',
|
|
963
|
+
hidden: !mounted,
|
|
964
|
+
style: {
|
|
965
|
+
userSelect: 'none',
|
|
966
|
+
WebkitUserSelect: 'none'
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
elementProps
|
|
970
|
+
]
|
|
971
|
+
});
|
|
972
|
+
});
|
|
973
|
+
if ("production" !== process.env.NODE_ENV) ComboboxBackdrop_ComboboxBackdrop.displayName = "ComboboxBackdrop";
|
|
974
|
+
const ComboboxPortalContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
975
|
+
if ("production" !== process.env.NODE_ENV) ComboboxPortalContext.displayName = "ComboboxPortalContext";
|
|
976
|
+
function useComboboxPortalContext() {
|
|
977
|
+
const context = __rspack_external_react.useContext(ComboboxPortalContext);
|
|
978
|
+
if (void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: <Combobox.Portal> is missing.' : esm_formatErrorMessage(20));
|
|
979
|
+
return context;
|
|
980
|
+
}
|
|
981
|
+
const ComboboxPositioner_ComboboxPositioner = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
982
|
+
const { render, className, anchor, positionMethod = 'absolute', side = 'bottom', align = 'center', sideOffset = 0, alignOffset = 0, collisionBoundary = 'clipping-ancestors', collisionPadding = 5, arrowPadding = 5, sticky = false, disableAnchorTracking = false, collisionAvoidance = DROPDOWN_COLLISION_AVOIDANCE, style: styleProp, ...elementProps } = componentProps;
|
|
983
|
+
const store = useComboboxRootContext();
|
|
984
|
+
const { filteredItems } = useComboboxDerivedItemsContext();
|
|
985
|
+
const floatingRootContext = useComboboxFloatingContext();
|
|
986
|
+
const keepMounted = useComboboxPortalContext();
|
|
987
|
+
const modal = useStore(store, selectors.modal);
|
|
988
|
+
const open = useStore(store, selectors.open);
|
|
989
|
+
const mounted = useStore(store, selectors.mounted);
|
|
990
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
991
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
992
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
993
|
+
const inputElement = useStore(store, selectors.inputElement);
|
|
994
|
+
const inputGroupElement = useStore(store, selectors.inputGroupElement);
|
|
995
|
+
const inputInsidePopup = useStore(store, selectors.inputInsidePopup);
|
|
996
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
997
|
+
const empty = 0 === filteredItems.length;
|
|
998
|
+
const resolvedAnchor = anchor ?? (inputInsidePopup ? triggerElement : inputGroupElement ?? inputElement);
|
|
999
|
+
const positioning = useAnchorPositioning({
|
|
1000
|
+
anchor: resolvedAnchor,
|
|
1001
|
+
floatingRootContext,
|
|
1002
|
+
positionMethod,
|
|
1003
|
+
mounted,
|
|
1004
|
+
side,
|
|
1005
|
+
sideOffset,
|
|
1006
|
+
align,
|
|
1007
|
+
alignOffset,
|
|
1008
|
+
arrowPadding,
|
|
1009
|
+
collisionBoundary,
|
|
1010
|
+
collisionPadding,
|
|
1011
|
+
sticky,
|
|
1012
|
+
disableAnchorTracking,
|
|
1013
|
+
keepMounted,
|
|
1014
|
+
collisionAvoidance,
|
|
1015
|
+
lazyFlip: true
|
|
1016
|
+
});
|
|
1017
|
+
useAnchoredPopupScrollLock(open && modal, 'touch' === openMethod, positionerElement, triggerElement);
|
|
1018
|
+
const state = {
|
|
1019
|
+
open,
|
|
1020
|
+
side: positioning.side,
|
|
1021
|
+
align: positioning.align,
|
|
1022
|
+
anchorHidden: positioning.anchorHidden,
|
|
1023
|
+
empty
|
|
1024
|
+
};
|
|
1025
|
+
useIsoLayoutEffect(()=>{
|
|
1026
|
+
store.set('popupSide', positioning.side);
|
|
1027
|
+
}, [
|
|
1028
|
+
store,
|
|
1029
|
+
positioning.side
|
|
1030
|
+
]);
|
|
1031
|
+
const setPositionerElement = useStableCallback((element)=>{
|
|
1032
|
+
store.set('positionerElement', element);
|
|
1033
|
+
});
|
|
1034
|
+
const element = usePositioner(componentProps, state, {
|
|
1035
|
+
styles: positioning.positionerStyles,
|
|
1036
|
+
transitionStatus,
|
|
1037
|
+
props: elementProps,
|
|
1038
|
+
refs: [
|
|
1039
|
+
forwardedRef,
|
|
1040
|
+
setPositionerElement
|
|
1041
|
+
],
|
|
1042
|
+
hidden: !mounted,
|
|
1043
|
+
inert: !open
|
|
1044
|
+
});
|
|
1045
|
+
return /*#__PURE__*/ jsxs(ComboboxPositionerContext.Provider, {
|
|
1046
|
+
value: positioning,
|
|
1047
|
+
children: [
|
|
1048
|
+
mounted && modal && /*#__PURE__*/ jsx(InternalBackdrop_InternalBackdrop, {
|
|
1049
|
+
inert: inertValue(!open),
|
|
1050
|
+
cutout: inputGroupElement ?? inputElement ?? triggerElement
|
|
1051
|
+
}),
|
|
1052
|
+
element
|
|
1053
|
+
]
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
if ("production" !== process.env.NODE_ENV) ComboboxPositioner_ComboboxPositioner.displayName = "ComboboxPositioner";
|
|
1057
|
+
const ComboboxPopup_stateAttributesMapping = {
|
|
1058
|
+
...popupStateMapping,
|
|
1059
|
+
...transitionStatusMapping
|
|
1060
|
+
};
|
|
1061
|
+
const ComboboxPopup_ComboboxPopup = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1062
|
+
const { render, className, style, initialFocus, finalFocus, ...elementProps } = componentProps;
|
|
1063
|
+
const store = useComboboxRootContext();
|
|
1064
|
+
const positioning = useComboboxPositionerContext();
|
|
1065
|
+
const floatingRootContext = useComboboxFloatingContext();
|
|
1066
|
+
const { filteredItems } = useComboboxDerivedItemsContext();
|
|
1067
|
+
const mounted = useStore(store, selectors.mounted);
|
|
1068
|
+
const open = useStore(store, selectors.open);
|
|
1069
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
1070
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
1071
|
+
const inputInsidePopup = useStore(store, selectors.inputInsidePopup);
|
|
1072
|
+
const inputElement = useStore(store, selectors.inputElement);
|
|
1073
|
+
const modal = useStore(store, selectors.modal);
|
|
1074
|
+
const empty = 0 === filteredItems.length;
|
|
1075
|
+
useOpenChangeComplete({
|
|
1076
|
+
open,
|
|
1077
|
+
ref: store.state.popupRef,
|
|
1078
|
+
onComplete () {
|
|
1079
|
+
if (open) store.state.onOpenChangeComplete(true);
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
const state = {
|
|
1083
|
+
open,
|
|
1084
|
+
side: positioning.side,
|
|
1085
|
+
align: positioning.align,
|
|
1086
|
+
anchorHidden: positioning.anchorHidden,
|
|
1087
|
+
transitionStatus,
|
|
1088
|
+
empty
|
|
1089
|
+
};
|
|
1090
|
+
const element = useRenderElement('div', componentProps, {
|
|
1091
|
+
state,
|
|
1092
|
+
ref: [
|
|
1093
|
+
forwardedRef,
|
|
1094
|
+
store.state.popupRef
|
|
1095
|
+
],
|
|
1096
|
+
props: [
|
|
1097
|
+
{
|
|
1098
|
+
role: inputInsidePopup ? 'dialog' : 'presentation',
|
|
1099
|
+
tabIndex: -1,
|
|
1100
|
+
onFocus (event) {
|
|
1101
|
+
const target = getTarget(event.nativeEvent);
|
|
1102
|
+
if ('touch' !== openMethod && (shadowDom_contains(store.state.listElement, target) || target === event.currentTarget)) store.state.inputRef.current?.focus();
|
|
1103
|
+
}
|
|
1104
|
+
},
|
|
1105
|
+
getDisabledMountTransitionStyles(transitionStatus),
|
|
1106
|
+
elementProps
|
|
1107
|
+
],
|
|
1108
|
+
stateAttributesMapping: ComboboxPopup_stateAttributesMapping
|
|
1109
|
+
});
|
|
1110
|
+
const computedDefaultInitialFocus = inputInsidePopup ? (interactionType)=>'touch' === interactionType ? store.state.popupRef.current : inputElement : false;
|
|
1111
|
+
const resolvedInitialFocus = void 0 === initialFocus ? computedDefaultInitialFocus : initialFocus;
|
|
1112
|
+
let resolvedFinalFocus;
|
|
1113
|
+
resolvedFinalFocus = null != finalFocus ? finalFocus : inputInsidePopup ? void 0 : false;
|
|
1114
|
+
const focusManagerModal = !inputInsidePopup || modal;
|
|
1115
|
+
return /*#__PURE__*/ jsx(FloatingFocusManager, {
|
|
1116
|
+
context: floatingRootContext,
|
|
1117
|
+
disabled: !mounted,
|
|
1118
|
+
modal: focusManagerModal,
|
|
1119
|
+
openInteractionType: openMethod,
|
|
1120
|
+
initialFocus: resolvedInitialFocus,
|
|
1121
|
+
returnFocus: resolvedFinalFocus,
|
|
1122
|
+
getInsideElements: ()=>[
|
|
1123
|
+
store.state.startDismissRef.current,
|
|
1124
|
+
store.state.endDismissRef.current
|
|
1125
|
+
],
|
|
1126
|
+
children: /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
1127
|
+
children: [
|
|
1128
|
+
element,
|
|
1129
|
+
focusManagerModal && /*#__PURE__*/ jsx(ComboboxInternalDismissButton_ComboboxInternalDismissButton, {
|
|
1130
|
+
ref: store.state.endDismissRef
|
|
1131
|
+
})
|
|
1132
|
+
]
|
|
1133
|
+
})
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
if ("production" !== process.env.NODE_ENV) ComboboxPopup_ComboboxPopup.displayName = "ComboboxPopup";
|
|
1137
|
+
const ComboboxArrow_ComboboxArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1138
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
1139
|
+
const store = useComboboxRootContext();
|
|
1140
|
+
const { arrowRef, side, align, arrowUncentered, arrowStyles } = useComboboxPositionerContext();
|
|
1141
|
+
const open = useStore(store, selectors.open);
|
|
1142
|
+
const state = {
|
|
1143
|
+
open,
|
|
1144
|
+
side,
|
|
1145
|
+
align,
|
|
1146
|
+
uncentered: arrowUncentered
|
|
1147
|
+
};
|
|
1148
|
+
return useRenderElement('div', componentProps, {
|
|
1149
|
+
ref: [
|
|
1150
|
+
arrowRef,
|
|
1151
|
+
forwardedRef
|
|
1152
|
+
],
|
|
1153
|
+
stateAttributesMapping: popupStateMapping,
|
|
1154
|
+
state,
|
|
1155
|
+
props: {
|
|
1156
|
+
style: arrowStyles,
|
|
1157
|
+
'aria-hidden': true,
|
|
1158
|
+
...elementProps
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
if ("production" !== process.env.NODE_ENV) ComboboxArrow_ComboboxArrow.displayName = "ComboboxArrow";
|
|
1163
|
+
const ComboboxGroupContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
1164
|
+
if ("production" !== process.env.NODE_ENV) ComboboxGroupContext.displayName = "ComboboxGroupContext";
|
|
1165
|
+
function useComboboxGroupContext() {
|
|
1166
|
+
const context = __rspack_external_react.useContext(ComboboxGroupContext);
|
|
1167
|
+
if (void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: ComboboxGroupContext is missing. ComboboxGroup parts must be placed within <Combobox.Group>.' : esm_formatErrorMessage(18));
|
|
1168
|
+
return context;
|
|
1169
|
+
}
|
|
1170
|
+
const ComboboxGroup_ComboboxGroup = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1171
|
+
const { render, className, style, items, ...elementProps } = componentProps;
|
|
1172
|
+
const [labelId, setLabelId] = __rspack_external_react.useState();
|
|
1173
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
1174
|
+
labelId,
|
|
1175
|
+
setLabelId,
|
|
1176
|
+
items
|
|
1177
|
+
}), [
|
|
1178
|
+
labelId,
|
|
1179
|
+
setLabelId,
|
|
1180
|
+
items
|
|
1181
|
+
]);
|
|
1182
|
+
const element = useRenderElement('div', componentProps, {
|
|
1183
|
+
ref: forwardedRef,
|
|
1184
|
+
props: [
|
|
1185
|
+
{
|
|
1186
|
+
role: 'group',
|
|
1187
|
+
'aria-labelledby': labelId
|
|
1188
|
+
},
|
|
1189
|
+
elementProps
|
|
1190
|
+
]
|
|
1191
|
+
});
|
|
1192
|
+
const wrappedElement = /*#__PURE__*/ jsx(ComboboxGroupContext.Provider, {
|
|
1193
|
+
value: contextValue,
|
|
1194
|
+
children: element
|
|
1195
|
+
});
|
|
1196
|
+
if (items) return /*#__PURE__*/ jsx(GroupCollectionProvider, {
|
|
1197
|
+
items: items,
|
|
1198
|
+
children: wrappedElement
|
|
1199
|
+
});
|
|
1200
|
+
return wrappedElement;
|
|
1201
|
+
});
|
|
1202
|
+
if ("production" !== process.env.NODE_ENV) ComboboxGroup_ComboboxGroup.displayName = "ComboboxGroup";
|
|
1203
|
+
const ComboboxGroupLabel_ComboboxGroupLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1204
|
+
const { render, className, style, id: idProp, ...elementProps } = componentProps;
|
|
1205
|
+
const { setLabelId } = useComboboxGroupContext();
|
|
1206
|
+
const id = useBaseUiId(idProp);
|
|
1207
|
+
useIsoLayoutEffect(()=>{
|
|
1208
|
+
setLabelId(id);
|
|
1209
|
+
return ()=>{
|
|
1210
|
+
setLabelId(void 0);
|
|
1211
|
+
};
|
|
1212
|
+
}, [
|
|
1213
|
+
id,
|
|
1214
|
+
setLabelId
|
|
1215
|
+
]);
|
|
1216
|
+
const element = useRenderElement('div', componentProps, {
|
|
1217
|
+
ref: forwardedRef,
|
|
1218
|
+
props: [
|
|
1219
|
+
{
|
|
1220
|
+
id
|
|
1221
|
+
},
|
|
1222
|
+
elementProps
|
|
1223
|
+
]
|
|
1224
|
+
});
|
|
1225
|
+
return element;
|
|
1226
|
+
});
|
|
1227
|
+
if ("production" !== process.env.NODE_ENV) ComboboxGroupLabel_ComboboxGroupLabel.displayName = "ComboboxGroupLabel";
|
|
1228
|
+
const ComboboxRow_ComboboxRow = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1229
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
1230
|
+
const element = useRenderElement('div', componentProps, {
|
|
1231
|
+
ref: forwardedRef,
|
|
1232
|
+
props: [
|
|
1233
|
+
{
|
|
1234
|
+
role: 'row'
|
|
1235
|
+
},
|
|
1236
|
+
elementProps
|
|
1237
|
+
]
|
|
1238
|
+
});
|
|
1239
|
+
return /*#__PURE__*/ jsx(ComboboxRowContext.Provider, {
|
|
1240
|
+
value: true,
|
|
1241
|
+
children: element
|
|
1242
|
+
});
|
|
1243
|
+
});
|
|
1244
|
+
if ("production" !== process.env.NODE_ENV) ComboboxRow_ComboboxRow.displayName = "ComboboxRow";
|
|
1245
|
+
const ComboboxEmpty_ComboboxEmpty = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1246
|
+
const { render, className, style, children: childrenProp, ...elementProps } = componentProps;
|
|
1247
|
+
const { filteredItems } = useComboboxDerivedItemsContext();
|
|
1248
|
+
const store = useComboboxRootContext();
|
|
1249
|
+
const emptyRef = useInitialLiveRegionTextMutation();
|
|
1250
|
+
const children = 0 === filteredItems.length ? childrenProp : null;
|
|
1251
|
+
return useRenderElement('div', componentProps, {
|
|
1252
|
+
ref: [
|
|
1253
|
+
forwardedRef,
|
|
1254
|
+
store.state.emptyRef,
|
|
1255
|
+
emptyRef
|
|
1256
|
+
],
|
|
1257
|
+
props: [
|
|
1258
|
+
{
|
|
1259
|
+
children,
|
|
1260
|
+
role: 'status',
|
|
1261
|
+
'aria-live': 'polite',
|
|
1262
|
+
'aria-atomic': true
|
|
1263
|
+
},
|
|
1264
|
+
elementProps
|
|
1265
|
+
]
|
|
1266
|
+
});
|
|
1267
|
+
});
|
|
1268
|
+
if ("production" !== process.env.NODE_ENV) ComboboxEmpty_ComboboxEmpty.displayName = "ComboboxEmpty";
|
|
1269
|
+
const BOUNDARY_OFFSET = 2;
|
|
1270
|
+
const ComboboxTrigger_ComboboxTrigger = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1271
|
+
const { render, className, nativeButton = true, disabled: disabledProp = false, id: idProp, style, ...elementProps } = componentProps;
|
|
1272
|
+
const { state: fieldState, disabled: fieldDisabled, setTouched, setFocused, validationMode, validation } = useFieldRootContext();
|
|
1273
|
+
const { labelId: fieldLabelId } = useLabelableContext();
|
|
1274
|
+
const store = useComboboxRootContext();
|
|
1275
|
+
const { filteredItems } = useComboboxDerivedItemsContext();
|
|
1276
|
+
const selectionMode = useStore(store, selectors.selectionMode);
|
|
1277
|
+
const comboboxDisabled = useStore(store, selectors.disabled);
|
|
1278
|
+
const readOnly = useStore(store, selectors.readOnly);
|
|
1279
|
+
const required = useStore(store, selectors.required);
|
|
1280
|
+
const mounted = useStore(store, selectors.mounted);
|
|
1281
|
+
const popupSideValue = useStore(store, selectors.popupSide);
|
|
1282
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
1283
|
+
const listElement = useStore(store, selectors.listElement);
|
|
1284
|
+
const triggerProps = useStore(store, selectors.triggerProps);
|
|
1285
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
1286
|
+
const inputInsidePopup = useStore(store, selectors.inputInsidePopup);
|
|
1287
|
+
const rootId = useStore(store, selectors.id);
|
|
1288
|
+
const comboboxLabelId = useStore(store, selectors.labelId);
|
|
1289
|
+
const open = useStore(store, selectors.open);
|
|
1290
|
+
const selectedValue = useStore(store, selectors.selectedValue);
|
|
1291
|
+
const activeIndex = useStore(store, selectors.activeIndex);
|
|
1292
|
+
const selectedIndex = useStore(store, selectors.selectedIndex);
|
|
1293
|
+
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
|
|
1294
|
+
const floatingRootContext = useComboboxFloatingContext();
|
|
1295
|
+
const inputValue = useComboboxInputValueContext();
|
|
1296
|
+
const focusTimeout = useTimeout();
|
|
1297
|
+
const disabled = fieldDisabled || comboboxDisabled || disabledProp;
|
|
1298
|
+
const listEmpty = 0 === filteredItems.length;
|
|
1299
|
+
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
1300
|
+
useLabelableId({
|
|
1301
|
+
id: inputInsidePopup ? idProp : void 0
|
|
1302
|
+
});
|
|
1303
|
+
const id = inputInsidePopup ? idProp ?? rootId : idProp;
|
|
1304
|
+
const ariaLabelledBy = resolveAriaLabelledBy(fieldLabelId, comboboxLabelId);
|
|
1305
|
+
const currentPointerTypeRef = __rspack_external_react.useRef('');
|
|
1306
|
+
function trackPointerType(event) {
|
|
1307
|
+
currentPointerTypeRef.current = event.pointerType;
|
|
1308
|
+
}
|
|
1309
|
+
const domReference = floatingRootContext.useState('domReferenceElement');
|
|
1310
|
+
__rspack_external_react.useEffect(()=>{
|
|
1311
|
+
if (!inputInsidePopup) return;
|
|
1312
|
+
if (triggerElement && triggerElement !== domReference) floatingRootContext.set('domReferenceElement', triggerElement);
|
|
1313
|
+
}, [
|
|
1314
|
+
triggerElement,
|
|
1315
|
+
domReference,
|
|
1316
|
+
floatingRootContext,
|
|
1317
|
+
inputInsidePopup
|
|
1318
|
+
]);
|
|
1319
|
+
const { reference: triggerTypeaheadProps } = useTypeahead(floatingRootContext, {
|
|
1320
|
+
enabled: !open && !readOnly && !comboboxDisabled && 'single' === selectionMode,
|
|
1321
|
+
listRef: store.state.labelsRef,
|
|
1322
|
+
activeIndex,
|
|
1323
|
+
selectedIndex,
|
|
1324
|
+
onMatch (index) {
|
|
1325
|
+
const nextSelectedValue = store.state.valuesRef.current[index];
|
|
1326
|
+
if (void 0 !== nextSelectedValue) store.state.setSelectedValue(nextSelectedValue, createChangeEventDetails('none'));
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
const { reference: triggerClickProps } = useClick(floatingRootContext, {
|
|
1330
|
+
enabled: !readOnly && !comboboxDisabled,
|
|
1331
|
+
event: 'mousedown'
|
|
1332
|
+
});
|
|
1333
|
+
const { buttonRef, getButtonProps } = useButton({
|
|
1334
|
+
native: nativeButton,
|
|
1335
|
+
disabled
|
|
1336
|
+
});
|
|
1337
|
+
const state = {
|
|
1338
|
+
...fieldState,
|
|
1339
|
+
open,
|
|
1340
|
+
disabled,
|
|
1341
|
+
popupSide,
|
|
1342
|
+
listEmpty,
|
|
1343
|
+
placeholder: 'none' === selectionMode ? false : !hasSelectedValue
|
|
1344
|
+
};
|
|
1345
|
+
const setTriggerElement = useStableCallback((element)=>{
|
|
1346
|
+
store.set('triggerElement', element);
|
|
1347
|
+
});
|
|
1348
|
+
const element = useRenderElement('button', componentProps, {
|
|
1349
|
+
ref: [
|
|
1350
|
+
forwardedRef,
|
|
1351
|
+
buttonRef,
|
|
1352
|
+
setTriggerElement
|
|
1353
|
+
],
|
|
1354
|
+
state,
|
|
1355
|
+
props: [
|
|
1356
|
+
triggerProps,
|
|
1357
|
+
triggerClickProps,
|
|
1358
|
+
triggerTypeaheadProps,
|
|
1359
|
+
{
|
|
1360
|
+
id,
|
|
1361
|
+
tabIndex: inputInsidePopup ? 0 : -1,
|
|
1362
|
+
role: inputInsidePopup ? 'combobox' : void 0,
|
|
1363
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
1364
|
+
'aria-haspopup': inputInsidePopup ? 'dialog' : 'listbox',
|
|
1365
|
+
'aria-controls': open ? listElement?.id : void 0,
|
|
1366
|
+
'aria-required': inputInsidePopup ? required || void 0 : void 0,
|
|
1367
|
+
'aria-labelledby': ariaLabelledBy,
|
|
1368
|
+
onPointerDown: trackPointerType,
|
|
1369
|
+
onPointerEnter: trackPointerType,
|
|
1370
|
+
onFocus () {
|
|
1371
|
+
setFocused(true);
|
|
1372
|
+
if (disabled || readOnly) return;
|
|
1373
|
+
focusTimeout.start(0, store.state.forceMount);
|
|
1374
|
+
},
|
|
1375
|
+
onBlur (event) {
|
|
1376
|
+
if (shadowDom_contains(positionerElement, event.relatedTarget)) return;
|
|
1377
|
+
setTouched(true);
|
|
1378
|
+
setFocused(false);
|
|
1379
|
+
if ('onBlur' === validationMode) {
|
|
1380
|
+
const valueToValidate = 'none' === selectionMode ? inputValue : selectedValue;
|
|
1381
|
+
validation.commit(valueToValidate);
|
|
1382
|
+
}
|
|
1383
|
+
},
|
|
1384
|
+
onMouseDown (event) {
|
|
1385
|
+
if (disabled || readOnly) return;
|
|
1386
|
+
if (!inputInsidePopup) floatingRootContext.set('domReferenceElement', event.currentTarget);
|
|
1387
|
+
store.state.forceMount();
|
|
1388
|
+
if ('touch' !== currentPointerTypeRef.current) {
|
|
1389
|
+
store.state.inputRef.current?.focus();
|
|
1390
|
+
if (!inputInsidePopup) event.preventDefault();
|
|
1391
|
+
}
|
|
1392
|
+
if (open) return;
|
|
1393
|
+
const doc = ownerDocument(event.currentTarget);
|
|
1394
|
+
function handleMouseUp(mouseEvent) {
|
|
1395
|
+
if (!triggerElement) return;
|
|
1396
|
+
const mouseUpTarget = getTarget(mouseEvent);
|
|
1397
|
+
const positioner = store.state.positionerElement;
|
|
1398
|
+
const list = store.state.listElement;
|
|
1399
|
+
if (shadowDom_contains(triggerElement, mouseUpTarget) || shadowDom_contains(positioner, mouseUpTarget) || shadowDom_contains(list, mouseUpTarget) || mouseUpTarget === triggerElement) return;
|
|
1400
|
+
const bounds = getPseudoElementBounds(triggerElement);
|
|
1401
|
+
const withinHorizontal = mouseEvent.clientX >= bounds.left - BOUNDARY_OFFSET && mouseEvent.clientX <= bounds.right + BOUNDARY_OFFSET;
|
|
1402
|
+
const withinVertical = mouseEvent.clientY >= bounds.top - BOUNDARY_OFFSET && mouseEvent.clientY <= bounds.bottom + BOUNDARY_OFFSET;
|
|
1403
|
+
if (withinHorizontal && withinVertical) return;
|
|
1404
|
+
store.state.setOpen(false, createChangeEventDetails('cancel-open', mouseEvent));
|
|
1405
|
+
}
|
|
1406
|
+
if (inputInsidePopup) doc.addEventListener('mouseup', handleMouseUp, {
|
|
1407
|
+
once: true
|
|
1408
|
+
});
|
|
1409
|
+
},
|
|
1410
|
+
onKeyDown (event) {
|
|
1411
|
+
if (disabled || readOnly) return;
|
|
1412
|
+
if ('ArrowDown' === event.key || 'ArrowUp' === event.key) {
|
|
1413
|
+
stopEvent(event);
|
|
1414
|
+
store.state.setOpen(true, createChangeEventDetails(reason_parts_listNavigation, event.nativeEvent));
|
|
1415
|
+
store.state.inputRef.current?.focus();
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1419
|
+
validation ? validation.getValidationProps(elementProps) : elementProps,
|
|
1420
|
+
getButtonProps
|
|
1421
|
+
],
|
|
1422
|
+
stateAttributesMapping: triggerStateAttributesMapping
|
|
1423
|
+
});
|
|
1424
|
+
return element;
|
|
1425
|
+
});
|
|
1426
|
+
if ("production" !== process.env.NODE_ENV) ComboboxTrigger_ComboboxTrigger.displayName = "ComboboxTrigger";
|
|
1427
|
+
function utils_createCollatorItemFilter(collatorFilter, itemToStringLabel) {
|
|
1428
|
+
return (item, query)=>{
|
|
1429
|
+
if (null == item) return false;
|
|
1430
|
+
const itemString = stringifyAsLabel(item, itemToStringLabel);
|
|
1431
|
+
return collatorFilter.contains(itemString, query);
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
function utils_createSingleSelectionCollatorFilter(collatorFilter, itemToStringLabel, selectedValue) {
|
|
1435
|
+
return (item, query)=>{
|
|
1436
|
+
if (null == item) return false;
|
|
1437
|
+
if (!query) return true;
|
|
1438
|
+
const itemString = stringifyAsLabel(item, itemToStringLabel);
|
|
1439
|
+
const selectedString = null != selectedValue ? stringifyAsLabel(selectedValue, itemToStringLabel) : '';
|
|
1440
|
+
if (selectedString && collatorFilter.contains(selectedString, query) && selectedString.length === query.length) return true;
|
|
1441
|
+
return collatorFilter.contains(itemString, query);
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
const filterCache = new Map();
|
|
1445
|
+
function filter_getFilter(options = {}) {
|
|
1446
|
+
const mergedOptions = {
|
|
1447
|
+
usage: 'search',
|
|
1448
|
+
sensitivity: 'base',
|
|
1449
|
+
ignorePunctuation: true,
|
|
1450
|
+
...options
|
|
1451
|
+
};
|
|
1452
|
+
const cacheKey = `${stringifyLocale(options.locale)}|${JSON.stringify(mergedOptions)}`;
|
|
1453
|
+
const cachedFilter = filterCache.get(cacheKey);
|
|
1454
|
+
if (cachedFilter) return cachedFilter;
|
|
1455
|
+
const collator = new Intl.Collator(options.locale, mergedOptions);
|
|
1456
|
+
const filter = {
|
|
1457
|
+
contains (item, query, itemToString) {
|
|
1458
|
+
if (!query) return true;
|
|
1459
|
+
const itemString = stringifyAsLabel(item, itemToString);
|
|
1460
|
+
for(let i = 0; i <= itemString.length - query.length; i += 1)if (0 === collator.compare(itemString.slice(i, i + query.length), query)) return true;
|
|
1461
|
+
return false;
|
|
1462
|
+
},
|
|
1463
|
+
startsWith (item, query, itemToString) {
|
|
1464
|
+
if (!query) return true;
|
|
1465
|
+
const itemString = stringifyAsLabel(item, itemToString);
|
|
1466
|
+
return 0 === collator.compare(itemString.slice(0, query.length), query);
|
|
1467
|
+
},
|
|
1468
|
+
endsWith (item, query, itemToString) {
|
|
1469
|
+
if (!query) return true;
|
|
1470
|
+
const itemString = stringifyAsLabel(item, itemToString);
|
|
1471
|
+
const queryLength = query.length;
|
|
1472
|
+
return itemString.length >= queryLength && 0 === collator.compare(itemString.slice(itemString.length - queryLength), query);
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
filterCache.set(cacheKey, filter);
|
|
1476
|
+
return filter;
|
|
1477
|
+
}
|
|
1478
|
+
function stringifyLocale(locale) {
|
|
1479
|
+
if (Array.isArray(locale)) return locale.map((value)=>stringifyLocale(value)).join(',');
|
|
1480
|
+
if (null == locale) return '';
|
|
1481
|
+
return String(locale);
|
|
1482
|
+
}
|
|
1483
|
+
const useCoreFilter = filter_getFilter;
|
|
1484
|
+
const NO_ACTIVE_VALUE = Symbol('none');
|
|
1485
|
+
const INITIAL_LAST_HIGHLIGHT = {
|
|
1486
|
+
value: NO_ACTIVE_VALUE,
|
|
1487
|
+
index: -1
|
|
1488
|
+
};
|
|
1489
|
+
function AriaCombobox(props) {
|
|
1490
|
+
const { id: idProp, onOpenChangeComplete: onOpenChangeCompleteProp, defaultSelectedValue = null, selectedValue: selectedValueProp, onSelectedValueChange, defaultInputValue: defaultInputValueProp, inputValue: inputValueProp, open: openProp, defaultOpen = false, selectionMode = 'none', onItemHighlighted: onItemHighlightedProp, name: nameProp, form, disabled: disabledProp = false, readOnly = false, required = false, inputRef: inputRefProp, grid = false, items, filteredItems: filteredItemsProp, filter: filterProp, openOnInputClick = true, autoHighlight = false, keepHighlight = false, highlightItemOnHover = true, loopFocus = true, itemToStringLabel, itemToStringValue, isItemEqualToValue = defaultItemEquality, virtualized = false, inline: inlineProp = false, fillInputOnItemPress = true, modal = false, limit = -1, autoComplete = 'list', formAutoComplete, locale, submitOnItemClick = false } = props;
|
|
1491
|
+
const { clearErrors } = useFormContext();
|
|
1492
|
+
const { setDirty, validityData, shouldValidateOnChange, setFilled, name: fieldName, disabled: fieldDisabled, setTouched, setFocused, validationMode, validation } = useFieldRootContext();
|
|
1493
|
+
const direction = useDirection();
|
|
1494
|
+
const id = useLabelableId({
|
|
1495
|
+
id: idProp
|
|
1496
|
+
});
|
|
1497
|
+
const collatorFilter = useCoreFilter({
|
|
1498
|
+
locale
|
|
1499
|
+
});
|
|
1500
|
+
const [queryChangedAfterOpen, setQueryChangedAfterOpen] = __rspack_external_react.useState(false);
|
|
1501
|
+
const [closeQuery, setCloseQuery] = __rspack_external_react.useState(null);
|
|
1502
|
+
const listRef = __rspack_external_react.useRef([]);
|
|
1503
|
+
const labelsRef = __rspack_external_react.useRef([]);
|
|
1504
|
+
const popupRef = __rspack_external_react.useRef(null);
|
|
1505
|
+
const inputRef = __rspack_external_react.useRef(null);
|
|
1506
|
+
const startDismissRef = __rspack_external_react.useRef(null);
|
|
1507
|
+
const endDismissRef = __rspack_external_react.useRef(null);
|
|
1508
|
+
const emptyRef = __rspack_external_react.useRef(null);
|
|
1509
|
+
const keyboardActiveRef = __rspack_external_react.useRef(true);
|
|
1510
|
+
const hadInputClearRef = __rspack_external_react.useRef(false);
|
|
1511
|
+
const chipsContainerRef = __rspack_external_react.useRef(null);
|
|
1512
|
+
const clearRef = __rspack_external_react.useRef(null);
|
|
1513
|
+
const selectionEventRef = __rspack_external_react.useRef(null);
|
|
1514
|
+
const lastHighlightRef = __rspack_external_react.useRef(INITIAL_LAST_HIGHLIGHT);
|
|
1515
|
+
const pendingQueryHighlightRef = __rspack_external_react.useRef(null);
|
|
1516
|
+
const valuesRef = __rspack_external_react.useRef([]);
|
|
1517
|
+
const allValuesRef = __rspack_external_react.useRef([]);
|
|
1518
|
+
const disabled = fieldDisabled || disabledProp;
|
|
1519
|
+
const name = fieldName ?? nameProp;
|
|
1520
|
+
const multiple = 'multiple' === selectionMode;
|
|
1521
|
+
const single = 'single' === selectionMode;
|
|
1522
|
+
const hasInputValue = void 0 !== inputValueProp || void 0 !== defaultInputValueProp;
|
|
1523
|
+
const hasItems = void 0 !== items;
|
|
1524
|
+
const hasFilteredItemsProp = void 0 !== filteredItemsProp;
|
|
1525
|
+
let autoHighlightMode;
|
|
1526
|
+
autoHighlightMode = 'always' === autoHighlight ? 'always' : autoHighlight ? 'input-change' : false;
|
|
1527
|
+
const [selectedValue, setSelectedValueUnwrapped] = useControlled({
|
|
1528
|
+
controlled: selectedValueProp,
|
|
1529
|
+
default: multiple ? defaultSelectedValue ?? EMPTY_ARRAY : defaultSelectedValue,
|
|
1530
|
+
name: 'Combobox',
|
|
1531
|
+
state: 'selectedValue'
|
|
1532
|
+
});
|
|
1533
|
+
const filter = __rspack_external_react.useMemo(()=>{
|
|
1534
|
+
if (null === filterProp) return ()=>true;
|
|
1535
|
+
if (void 0 !== filterProp) return filterProp;
|
|
1536
|
+
if (single && !queryChangedAfterOpen) return utils_createSingleSelectionCollatorFilter(collatorFilter, itemToStringLabel, selectedValue);
|
|
1537
|
+
return utils_createCollatorItemFilter(collatorFilter, itemToStringLabel);
|
|
1538
|
+
}, [
|
|
1539
|
+
filterProp,
|
|
1540
|
+
single,
|
|
1541
|
+
selectedValue,
|
|
1542
|
+
queryChangedAfterOpen,
|
|
1543
|
+
collatorFilter,
|
|
1544
|
+
itemToStringLabel
|
|
1545
|
+
]);
|
|
1546
|
+
const initialDefaultInputValue = useRefWithInit(()=>{
|
|
1547
|
+
if (hasInputValue) return defaultInputValueProp ?? '';
|
|
1548
|
+
if (single) return stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
1549
|
+
return '';
|
|
1550
|
+
}).current;
|
|
1551
|
+
const [inputValue, setInputValueUnwrapped] = useControlled({
|
|
1552
|
+
controlled: inputValueProp,
|
|
1553
|
+
default: initialDefaultInputValue,
|
|
1554
|
+
name: 'Combobox',
|
|
1555
|
+
state: 'inputValue'
|
|
1556
|
+
});
|
|
1557
|
+
const [open, setOpenUnwrapped] = useControlled({
|
|
1558
|
+
controlled: openProp,
|
|
1559
|
+
default: defaultOpen,
|
|
1560
|
+
name: 'Combobox',
|
|
1561
|
+
state: 'open'
|
|
1562
|
+
});
|
|
1563
|
+
const isGrouped = isGroupedItems(items);
|
|
1564
|
+
const query = closeQuery ?? ('' === inputValue ? '' : String(inputValue).trim());
|
|
1565
|
+
const selectedLabelString = single ? stringifyAsLabel(selectedValue, itemToStringLabel) : '';
|
|
1566
|
+
const shouldBypassFiltering = single && !queryChangedAfterOpen && '' !== query && '' !== selectedLabelString && selectedLabelString.length === query.length && collatorFilter.contains(selectedLabelString, query);
|
|
1567
|
+
const filterQuery = shouldBypassFiltering ? '' : query;
|
|
1568
|
+
const shouldIgnoreExternalFiltering = hasItems && hasFilteredItemsProp && shouldBypassFiltering;
|
|
1569
|
+
const flatItems = __rspack_external_react.useMemo(()=>{
|
|
1570
|
+
if (!items) return EMPTY_ARRAY;
|
|
1571
|
+
if (isGrouped) return items.flatMap((group)=>group.items);
|
|
1572
|
+
return items;
|
|
1573
|
+
}, [
|
|
1574
|
+
items,
|
|
1575
|
+
isGrouped
|
|
1576
|
+
]);
|
|
1577
|
+
const filteredItems = __rspack_external_react.useMemo(()=>{
|
|
1578
|
+
if (filteredItemsProp && !shouldIgnoreExternalFiltering) return filteredItemsProp;
|
|
1579
|
+
if (!items) return EMPTY_ARRAY;
|
|
1580
|
+
if (isGrouped) {
|
|
1581
|
+
const groupedItems = items;
|
|
1582
|
+
const resultingGroups = [];
|
|
1583
|
+
let currentCount = 0;
|
|
1584
|
+
for (const group of groupedItems){
|
|
1585
|
+
if (limit > -1 && currentCount >= limit) break;
|
|
1586
|
+
const candidateItems = '' === filterQuery ? group.items : group.items.filter((item)=>filter(item, filterQuery, itemToStringLabel));
|
|
1587
|
+
if (0 === candidateItems.length) continue;
|
|
1588
|
+
const remainingLimit = limit > -1 ? limit - currentCount : 1 / 0;
|
|
1589
|
+
const itemsToTake = candidateItems.slice(0, remainingLimit);
|
|
1590
|
+
if (itemsToTake.length > 0) {
|
|
1591
|
+
const newGroup = {
|
|
1592
|
+
...group,
|
|
1593
|
+
items: itemsToTake
|
|
1594
|
+
};
|
|
1595
|
+
resultingGroups.push(newGroup);
|
|
1596
|
+
currentCount += itemsToTake.length;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
return resultingGroups;
|
|
1600
|
+
}
|
|
1601
|
+
if ('' === filterQuery) return limit > -1 ? flatItems.slice(0, limit) : flatItems;
|
|
1602
|
+
const limitedItems = [];
|
|
1603
|
+
for (const item of flatItems){
|
|
1604
|
+
if (limit > -1 && limitedItems.length >= limit) break;
|
|
1605
|
+
if (filter(item, filterQuery, itemToStringLabel)) limitedItems.push(item);
|
|
1606
|
+
}
|
|
1607
|
+
return limitedItems;
|
|
1608
|
+
}, [
|
|
1609
|
+
filteredItemsProp,
|
|
1610
|
+
shouldIgnoreExternalFiltering,
|
|
1611
|
+
items,
|
|
1612
|
+
isGrouped,
|
|
1613
|
+
filterQuery,
|
|
1614
|
+
limit,
|
|
1615
|
+
filter,
|
|
1616
|
+
itemToStringLabel,
|
|
1617
|
+
flatItems
|
|
1618
|
+
]);
|
|
1619
|
+
const flatFilteredItems = __rspack_external_react.useMemo(()=>{
|
|
1620
|
+
if (isGrouped) {
|
|
1621
|
+
const groups = filteredItems;
|
|
1622
|
+
return groups.flatMap((g)=>g.items);
|
|
1623
|
+
}
|
|
1624
|
+
return filteredItems;
|
|
1625
|
+
}, [
|
|
1626
|
+
filteredItems,
|
|
1627
|
+
isGrouped
|
|
1628
|
+
]);
|
|
1629
|
+
const store = useRefWithInit(()=>new Store({
|
|
1630
|
+
id,
|
|
1631
|
+
labelId: void 0,
|
|
1632
|
+
selectedValue,
|
|
1633
|
+
open,
|
|
1634
|
+
filter,
|
|
1635
|
+
query,
|
|
1636
|
+
items,
|
|
1637
|
+
selectionMode,
|
|
1638
|
+
listRef,
|
|
1639
|
+
labelsRef,
|
|
1640
|
+
popupRef,
|
|
1641
|
+
emptyRef,
|
|
1642
|
+
inputRef,
|
|
1643
|
+
startDismissRef,
|
|
1644
|
+
endDismissRef,
|
|
1645
|
+
keyboardActiveRef,
|
|
1646
|
+
chipsContainerRef,
|
|
1647
|
+
clearRef,
|
|
1648
|
+
valuesRef,
|
|
1649
|
+
allValuesRef,
|
|
1650
|
+
selectionEventRef,
|
|
1651
|
+
name,
|
|
1652
|
+
form,
|
|
1653
|
+
disabled,
|
|
1654
|
+
readOnly,
|
|
1655
|
+
required,
|
|
1656
|
+
grid,
|
|
1657
|
+
isGrouped,
|
|
1658
|
+
virtualized,
|
|
1659
|
+
openOnInputClick,
|
|
1660
|
+
itemToStringLabel,
|
|
1661
|
+
isItemEqualToValue,
|
|
1662
|
+
modal,
|
|
1663
|
+
autoHighlight: autoHighlightMode,
|
|
1664
|
+
submitOnItemClick,
|
|
1665
|
+
hasInputValue,
|
|
1666
|
+
mounted: false,
|
|
1667
|
+
forceMounted: false,
|
|
1668
|
+
transitionStatus: 'idle',
|
|
1669
|
+
inline: inlineProp,
|
|
1670
|
+
activeIndex: null,
|
|
1671
|
+
selectedIndex: null,
|
|
1672
|
+
popupProps: {},
|
|
1673
|
+
inputProps: {},
|
|
1674
|
+
triggerProps: {},
|
|
1675
|
+
itemProps: EMPTY_OBJECT,
|
|
1676
|
+
positionerElement: null,
|
|
1677
|
+
listElement: null,
|
|
1678
|
+
triggerElement: null,
|
|
1679
|
+
inputElement: null,
|
|
1680
|
+
inputGroupElement: null,
|
|
1681
|
+
popupSide: null,
|
|
1682
|
+
openMethod: null,
|
|
1683
|
+
inputInsidePopup: true,
|
|
1684
|
+
inputOwnsFormValue: 'none' === selectionMode,
|
|
1685
|
+
onOpenChangeComplete: onOpenChangeCompleteProp || NOOP,
|
|
1686
|
+
setOpen: NOOP,
|
|
1687
|
+
setInputValue: NOOP,
|
|
1688
|
+
setSelectedValue: NOOP,
|
|
1689
|
+
setIndices: NOOP,
|
|
1690
|
+
onItemHighlighted: NOOP,
|
|
1691
|
+
handleSelection: NOOP,
|
|
1692
|
+
forceMount: NOOP,
|
|
1693
|
+
requestSubmit: NOOP
|
|
1694
|
+
})).current;
|
|
1695
|
+
const fieldRawValue = 'none' === selectionMode ? inputValue : selectedValue;
|
|
1696
|
+
const fieldStringValue = __rspack_external_react.useMemo(()=>{
|
|
1697
|
+
if ('none' === selectionMode) return fieldRawValue;
|
|
1698
|
+
if (Array.isArray(selectedValue)) return selectedValue.map((value)=>stringifyAsValue(value, itemToStringValue));
|
|
1699
|
+
return stringifyAsValue(selectedValue, itemToStringValue);
|
|
1700
|
+
}, [
|
|
1701
|
+
fieldRawValue,
|
|
1702
|
+
itemToStringValue,
|
|
1703
|
+
selectionMode,
|
|
1704
|
+
selectedValue
|
|
1705
|
+
]);
|
|
1706
|
+
const onItemHighlighted = useStableCallback(onItemHighlightedProp);
|
|
1707
|
+
const onOpenChangeComplete = useStableCallback(onOpenChangeCompleteProp);
|
|
1708
|
+
const activeIndex = useStore(store, selectors.activeIndex);
|
|
1709
|
+
const selectedIndex = useStore(store, selectors.selectedIndex);
|
|
1710
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
1711
|
+
const listElement = useStore(store, selectors.listElement);
|
|
1712
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
1713
|
+
const inputElement = useStore(store, selectors.inputElement);
|
|
1714
|
+
const inputGroupElement = useStore(store, selectors.inputGroupElement);
|
|
1715
|
+
const inline = useStore(store, selectors.inline);
|
|
1716
|
+
const inputInsidePopup = useStore(store, selectors.inputInsidePopup);
|
|
1717
|
+
const inputOwnsFormValue = useStore(store, selectors.inputOwnsFormValue);
|
|
1718
|
+
const triggerRef = useValueAsRef(triggerElement);
|
|
1719
|
+
const { mounted, setMounted, transitionStatus } = useTransitionStatus(open);
|
|
1720
|
+
const { openMethod, triggerProps } = useOpenInteractionType(open);
|
|
1721
|
+
const getStringifiedValueForForm = useStableCallback(()=>fieldStringValue);
|
|
1722
|
+
useRegisterFieldControl(inputInsidePopup ? triggerRef : inputRef, id, fieldRawValue, getStringifiedValueForForm);
|
|
1723
|
+
const forceMount = useStableCallback(()=>{
|
|
1724
|
+
if (items) labelsRef.current = flatFilteredItems.map((item)=>stringifyAsLabel(item, itemToStringLabel));
|
|
1725
|
+
else store.set('forceMounted', true);
|
|
1726
|
+
});
|
|
1727
|
+
const initialSelectedValueRef = __rspack_external_react.useRef(selectedValue);
|
|
1728
|
+
useIsoLayoutEffect(()=>{
|
|
1729
|
+
if (selectedValue !== initialSelectedValueRef.current) forceMount();
|
|
1730
|
+
}, [
|
|
1731
|
+
forceMount,
|
|
1732
|
+
selectedValue
|
|
1733
|
+
]);
|
|
1734
|
+
const setIndices = useStableCallback((options)=>{
|
|
1735
|
+
store.update(options);
|
|
1736
|
+
const type = options.type || 'none';
|
|
1737
|
+
if (void 0 === options.activeIndex) return;
|
|
1738
|
+
if (null === options.activeIndex) {
|
|
1739
|
+
if (lastHighlightRef.current !== INITIAL_LAST_HIGHLIGHT) {
|
|
1740
|
+
lastHighlightRef.current = INITIAL_LAST_HIGHLIGHT;
|
|
1741
|
+
onItemHighlighted(void 0, createGenericEventDetails(type, void 0, {
|
|
1742
|
+
index: -1
|
|
1743
|
+
}));
|
|
1744
|
+
}
|
|
1745
|
+
} else {
|
|
1746
|
+
const activeValue = valuesRef.current[options.activeIndex];
|
|
1747
|
+
lastHighlightRef.current = {
|
|
1748
|
+
value: activeValue,
|
|
1749
|
+
index: options.activeIndex
|
|
1750
|
+
};
|
|
1751
|
+
onItemHighlighted(activeValue, createGenericEventDetails(type, void 0, {
|
|
1752
|
+
index: options.activeIndex
|
|
1753
|
+
}));
|
|
1754
|
+
}
|
|
1755
|
+
});
|
|
1756
|
+
const setInputValue = useStableCallback((next, eventDetails)=>{
|
|
1757
|
+
hadInputClearRef.current = eventDetails.reason === inputClear;
|
|
1758
|
+
props.onInputValueChange?.(next, eventDetails);
|
|
1759
|
+
if (eventDetails.isCanceled) return;
|
|
1760
|
+
if (eventDetails.reason === inputChange) {
|
|
1761
|
+
const event = eventDetails.event;
|
|
1762
|
+
const inputType = event.inputType;
|
|
1763
|
+
const isTypedInput = 'compositionend' === event.type || null != inputType && '' !== inputType && 'insertReplacementText' !== inputType;
|
|
1764
|
+
if (isTypedInput) {
|
|
1765
|
+
const hasQuery = '' !== next.trim();
|
|
1766
|
+
if (hasQuery) setQueryChangedAfterOpen(true);
|
|
1767
|
+
pendingQueryHighlightRef.current = {
|
|
1768
|
+
hasQuery
|
|
1769
|
+
};
|
|
1770
|
+
if (hasQuery && autoHighlightMode && null == store.state.activeIndex) store.set('activeIndex', 0);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
setInputValueUnwrapped(next);
|
|
1774
|
+
});
|
|
1775
|
+
const setOpen = useStableCallback((nextOpen, eventDetails)=>{
|
|
1776
|
+
if (open === nextOpen) return;
|
|
1777
|
+
if ('escape-key' === eventDetails.reason && hasItems && 0 === flatFilteredItems.length && !store.state.emptyRef.current) eventDetails.allowPropagation();
|
|
1778
|
+
props.onOpenChange?.(nextOpen, eventDetails);
|
|
1779
|
+
if (eventDetails.isCanceled) return;
|
|
1780
|
+
if (nextOpen && multiple && inputInsidePopup && !inline && null !== closeQuery) {
|
|
1781
|
+
setQueryChangedAfterOpen(false);
|
|
1782
|
+
setCloseQuery(null);
|
|
1783
|
+
if ('' !== inputValue) setInputValue('', createChangeEventDetails(inputClear, eventDetails.event));
|
|
1784
|
+
}
|
|
1785
|
+
if (!nextOpen && queryChangedAfterOpen) {
|
|
1786
|
+
if (single) {
|
|
1787
|
+
if (!inline) setCloseQuery(query);
|
|
1788
|
+
if ('' === query) setQueryChangedAfterOpen(false);
|
|
1789
|
+
} else if (multiple) {
|
|
1790
|
+
if (!inline) setCloseQuery(query);
|
|
1791
|
+
if (inputInsidePopup) setIndices({
|
|
1792
|
+
activeIndex: null
|
|
1793
|
+
});
|
|
1794
|
+
if (!inputInsidePopup || inline) setInputValue('', createChangeEventDetails(inputClear, eventDetails.event));
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
setOpenUnwrapped(nextOpen);
|
|
1798
|
+
if (!nextOpen && inputInsidePopup && (eventDetails.reason === focusOut || eventDetails.reason === outsidePress)) {
|
|
1799
|
+
setTouched(true);
|
|
1800
|
+
setFocused(false);
|
|
1801
|
+
if ('onBlur' === validationMode) {
|
|
1802
|
+
const valueToValidate = 'none' === selectionMode ? inputValue : selectedValue;
|
|
1803
|
+
validation.commit(valueToValidate);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1807
|
+
const setSelectedValue = useStableCallback((nextValue, eventDetails)=>{
|
|
1808
|
+
onSelectedValueChange?.(nextValue, eventDetails);
|
|
1809
|
+
if (eventDetails.isCanceled) return;
|
|
1810
|
+
setSelectedValueUnwrapped(nextValue);
|
|
1811
|
+
const shouldFillInput = 'none' === selectionMode && popupRef.current && fillInputOnItemPress || single && !store.state.inputInsidePopup;
|
|
1812
|
+
if (shouldFillInput) setInputValue(stringifyAsLabel(nextValue, itemToStringLabel), createChangeEventDetails(eventDetails.reason, eventDetails.event));
|
|
1813
|
+
if (single && null != nextValue && eventDetails.reason !== inputChange && queryChangedAfterOpen && !inline) setCloseQuery(query);
|
|
1814
|
+
});
|
|
1815
|
+
const handleSelection = useStableCallback((event, passedValue)=>{
|
|
1816
|
+
let itemValue = passedValue;
|
|
1817
|
+
if (void 0 === itemValue) {
|
|
1818
|
+
if (null === activeIndex) return;
|
|
1819
|
+
itemValue = valuesRef.current[activeIndex];
|
|
1820
|
+
}
|
|
1821
|
+
const targetEl = getTarget(event);
|
|
1822
|
+
const overrideEvent = selectionEventRef.current ?? event;
|
|
1823
|
+
selectionEventRef.current = null;
|
|
1824
|
+
const eventDetails = createChangeEventDetails(itemPress, overrideEvent);
|
|
1825
|
+
const href = targetEl?.closest('a')?.getAttribute('href');
|
|
1826
|
+
if (href) {
|
|
1827
|
+
if (href.startsWith('#')) setOpen(false, eventDetails);
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
if (multiple) {
|
|
1831
|
+
const currentSelectedValue = Array.isArray(selectedValue) ? selectedValue : [];
|
|
1832
|
+
const isCurrentlySelected = selectedValueIncludes(currentSelectedValue, itemValue, store.state.isItemEqualToValue);
|
|
1833
|
+
const nextValue = isCurrentlySelected ? removeItem(currentSelectedValue, itemValue, store.state.isItemEqualToValue) : [
|
|
1834
|
+
...currentSelectedValue,
|
|
1835
|
+
itemValue
|
|
1836
|
+
];
|
|
1837
|
+
setSelectedValue(nextValue, eventDetails);
|
|
1838
|
+
const wasFiltering = inputRef.current ? '' !== inputRef.current.value.trim() : false;
|
|
1839
|
+
if (!wasFiltering) return;
|
|
1840
|
+
if (store.state.inputInsidePopup) setInputValue('', createChangeEventDetails(inputClear, eventDetails.event));
|
|
1841
|
+
else setOpen(false, eventDetails);
|
|
1842
|
+
} else {
|
|
1843
|
+
setSelectedValue(itemValue, eventDetails);
|
|
1844
|
+
setOpen(false, eventDetails);
|
|
1845
|
+
}
|
|
1846
|
+
});
|
|
1847
|
+
const requestSubmit = useStableCallback(()=>{
|
|
1848
|
+
if (!store.state.submitOnItemClick) return;
|
|
1849
|
+
const formElement = validation.inputRef.current?.form ?? store.state.inputElement?.form;
|
|
1850
|
+
if (formElement && 'function' == typeof formElement.requestSubmit) formElement.requestSubmit();
|
|
1851
|
+
});
|
|
1852
|
+
const handleUnmount = useStableCallback(()=>{
|
|
1853
|
+
setMounted(false);
|
|
1854
|
+
onOpenChangeComplete?.(false);
|
|
1855
|
+
setQueryChangedAfterOpen(false);
|
|
1856
|
+
setCloseQuery(null);
|
|
1857
|
+
'none' === selectionMode ? setIndices({
|
|
1858
|
+
activeIndex: null,
|
|
1859
|
+
selectedIndex: null
|
|
1860
|
+
}) : setIndices({
|
|
1861
|
+
activeIndex: null
|
|
1862
|
+
});
|
|
1863
|
+
if (multiple && inputRef.current && '' !== inputRef.current.value && !hadInputClearRef.current) setInputValue('', createChangeEventDetails(inputClear));
|
|
1864
|
+
if (single) if (store.state.inputInsidePopup) {
|
|
1865
|
+
if (inputRef.current && '' !== inputRef.current.value) setInputValue('', createChangeEventDetails(inputClear));
|
|
1866
|
+
} else {
|
|
1867
|
+
const stringVal = stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
1868
|
+
if (inputRef.current && inputRef.current.value !== stringVal) {
|
|
1869
|
+
const reason = '' === stringVal ? inputClear : "none";
|
|
1870
|
+
setInputValue(stringVal, createChangeEventDetails(reason));
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
});
|
|
1874
|
+
const resolvedPopupRef = __rspack_external_react.useMemo(()=>{
|
|
1875
|
+
if (inline && positionerElement) return {
|
|
1876
|
+
current: positionerElement.closest('[role="dialog"]')
|
|
1877
|
+
};
|
|
1878
|
+
return popupRef;
|
|
1879
|
+
}, [
|
|
1880
|
+
inline,
|
|
1881
|
+
positionerElement
|
|
1882
|
+
]);
|
|
1883
|
+
useOpenChangeComplete({
|
|
1884
|
+
enabled: !props.actionsRef,
|
|
1885
|
+
open,
|
|
1886
|
+
ref: resolvedPopupRef,
|
|
1887
|
+
onComplete () {
|
|
1888
|
+
if (!open) handleUnmount();
|
|
1889
|
+
}
|
|
1890
|
+
});
|
|
1891
|
+
__rspack_external_react.useImperativeHandle(props.actionsRef, ()=>({
|
|
1892
|
+
unmount: handleUnmount
|
|
1893
|
+
}), [
|
|
1894
|
+
handleUnmount
|
|
1895
|
+
]);
|
|
1896
|
+
useIsoLayoutEffect(function() {
|
|
1897
|
+
if (open || 'none' === selectionMode) return;
|
|
1898
|
+
const registry = items ? flatItems : allValuesRef.current;
|
|
1899
|
+
if (multiple) {
|
|
1900
|
+
const currentValue = Array.isArray(selectedValue) ? selectedValue : [];
|
|
1901
|
+
const lastValue = currentValue[currentValue.length - 1];
|
|
1902
|
+
const lastIndex = findItemIndex(registry, lastValue, isItemEqualToValue);
|
|
1903
|
+
setIndices({
|
|
1904
|
+
selectedIndex: -1 === lastIndex ? null : lastIndex
|
|
1905
|
+
});
|
|
1906
|
+
} else {
|
|
1907
|
+
const index = findItemIndex(registry, selectedValue, isItemEqualToValue);
|
|
1908
|
+
setIndices({
|
|
1909
|
+
selectedIndex: -1 === index ? null : index
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
}, [
|
|
1913
|
+
open,
|
|
1914
|
+
selectedValue,
|
|
1915
|
+
items,
|
|
1916
|
+
selectionMode,
|
|
1917
|
+
flatItems,
|
|
1918
|
+
multiple,
|
|
1919
|
+
isItemEqualToValue,
|
|
1920
|
+
setIndices
|
|
1921
|
+
]);
|
|
1922
|
+
useIsoLayoutEffect(()=>{
|
|
1923
|
+
if (items) {
|
|
1924
|
+
valuesRef.current = flatFilteredItems;
|
|
1925
|
+
listRef.current.length = flatFilteredItems.length;
|
|
1926
|
+
}
|
|
1927
|
+
}, [
|
|
1928
|
+
items,
|
|
1929
|
+
flatFilteredItems
|
|
1930
|
+
]);
|
|
1931
|
+
useIsoLayoutEffect(()=>{
|
|
1932
|
+
const pendingHighlight = pendingQueryHighlightRef.current;
|
|
1933
|
+
if (pendingHighlight) {
|
|
1934
|
+
if (pendingHighlight.hasQuery) {
|
|
1935
|
+
if (autoHighlightMode) store.set('activeIndex', 0);
|
|
1936
|
+
} else if ('always' === autoHighlightMode) store.set('activeIndex', 0);
|
|
1937
|
+
pendingQueryHighlightRef.current = null;
|
|
1938
|
+
}
|
|
1939
|
+
if (!open && !inline) return;
|
|
1940
|
+
const shouldUseFlatFilteredItems = hasItems || hasFilteredItemsProp;
|
|
1941
|
+
const candidateItems = shouldUseFlatFilteredItems ? flatFilteredItems : valuesRef.current;
|
|
1942
|
+
const storeActiveIndex = store.state.activeIndex;
|
|
1943
|
+
if (null == storeActiveIndex) {
|
|
1944
|
+
if ('always' === autoHighlightMode && candidateItems.length > 0) return void store.set('activeIndex', 0);
|
|
1945
|
+
if (lastHighlightRef.current !== INITIAL_LAST_HIGHLIGHT) {
|
|
1946
|
+
lastHighlightRef.current = INITIAL_LAST_HIGHLIGHT;
|
|
1947
|
+
store.state.onItemHighlighted(void 0, createGenericEventDetails("none", void 0, {
|
|
1948
|
+
index: -1
|
|
1949
|
+
}));
|
|
1950
|
+
}
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
if (storeActiveIndex >= candidateItems.length) {
|
|
1954
|
+
if (lastHighlightRef.current !== INITIAL_LAST_HIGHLIGHT) {
|
|
1955
|
+
lastHighlightRef.current = INITIAL_LAST_HIGHLIGHT;
|
|
1956
|
+
store.state.onItemHighlighted(void 0, createGenericEventDetails("none", void 0, {
|
|
1957
|
+
index: -1
|
|
1958
|
+
}));
|
|
1959
|
+
}
|
|
1960
|
+
store.set('activeIndex', null);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
const itemValue = candidateItems[storeActiveIndex];
|
|
1964
|
+
const previouslyHighlightedItemValue = lastHighlightRef.current.value;
|
|
1965
|
+
const isSameItem = previouslyHighlightedItemValue !== NO_ACTIVE_VALUE && compareItemEquality(itemValue, previouslyHighlightedItemValue, store.state.isItemEqualToValue);
|
|
1966
|
+
if (lastHighlightRef.current.index !== storeActiveIndex || !isSameItem) {
|
|
1967
|
+
lastHighlightRef.current = {
|
|
1968
|
+
value: itemValue,
|
|
1969
|
+
index: storeActiveIndex
|
|
1970
|
+
};
|
|
1971
|
+
store.state.onItemHighlighted(itemValue, createGenericEventDetails("none", void 0, {
|
|
1972
|
+
index: storeActiveIndex
|
|
1973
|
+
}));
|
|
1974
|
+
}
|
|
1975
|
+
}, [
|
|
1976
|
+
activeIndex,
|
|
1977
|
+
autoHighlightMode,
|
|
1978
|
+
hasFilteredItemsProp,
|
|
1979
|
+
hasItems,
|
|
1980
|
+
flatFilteredItems,
|
|
1981
|
+
inline,
|
|
1982
|
+
open,
|
|
1983
|
+
store
|
|
1984
|
+
]);
|
|
1985
|
+
useIsoLayoutEffect(()=>{
|
|
1986
|
+
if ('none' === selectionMode) return void setFilled('' !== String(inputValue));
|
|
1987
|
+
setFilled(multiple ? Array.isArray(selectedValue) && selectedValue.length > 0 : null != selectedValue);
|
|
1988
|
+
}, [
|
|
1989
|
+
setFilled,
|
|
1990
|
+
selectionMode,
|
|
1991
|
+
inputValue,
|
|
1992
|
+
selectedValue,
|
|
1993
|
+
multiple
|
|
1994
|
+
]);
|
|
1995
|
+
__rspack_external_react.useEffect(()=>{
|
|
1996
|
+
if (hasItems && autoHighlightMode && 0 === flatFilteredItems.length) setIndices({
|
|
1997
|
+
activeIndex: null
|
|
1998
|
+
});
|
|
1999
|
+
}, [
|
|
2000
|
+
hasItems,
|
|
2001
|
+
autoHighlightMode,
|
|
2002
|
+
flatFilteredItems.length,
|
|
2003
|
+
setIndices
|
|
2004
|
+
]);
|
|
2005
|
+
useValueChanged(query, ()=>{
|
|
2006
|
+
if (!open || '' === query || query === String(initialDefaultInputValue)) return;
|
|
2007
|
+
setQueryChangedAfterOpen(true);
|
|
2008
|
+
});
|
|
2009
|
+
useValueChanged(selectedValue, ()=>{
|
|
2010
|
+
if ('none' === selectionMode) return;
|
|
2011
|
+
clearErrors(name);
|
|
2012
|
+
setDirty(selectedValue !== validityData.initialValue);
|
|
2013
|
+
if (shouldValidateOnChange()) validation.commit(selectedValue);
|
|
2014
|
+
else validation.commit(selectedValue, true);
|
|
2015
|
+
if (single && !hasInputValue && !inputInsidePopup) {
|
|
2016
|
+
const nextInputValue = stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
2017
|
+
if (inputValue !== nextInputValue) setInputValue(nextInputValue, createChangeEventDetails("none"));
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
useValueChanged(inputValue, ()=>{
|
|
2021
|
+
if ('none' !== selectionMode) return;
|
|
2022
|
+
clearErrors(name);
|
|
2023
|
+
setDirty(inputValue !== validityData.initialValue);
|
|
2024
|
+
if (shouldValidateOnChange()) validation.commit(inputValue);
|
|
2025
|
+
else validation.commit(inputValue, true);
|
|
2026
|
+
});
|
|
2027
|
+
useValueChanged(items, ()=>{
|
|
2028
|
+
if (!single || hasInputValue || inputInsidePopup || queryChangedAfterOpen) return;
|
|
2029
|
+
const nextInputValue = stringifyAsLabel(selectedValue, itemToStringLabel);
|
|
2030
|
+
if (inputValue !== nextInputValue) setInputValue(nextInputValue, createChangeEventDetails("none"));
|
|
2031
|
+
});
|
|
2032
|
+
const floatingRootContext = useFloatingRootContext({
|
|
2033
|
+
open: inline ? true : open,
|
|
2034
|
+
onOpenChange: setOpen,
|
|
2035
|
+
elements: {
|
|
2036
|
+
reference: inputInsidePopup ? triggerElement : inputElement,
|
|
2037
|
+
floating: positionerElement
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
2040
|
+
let ariaHasPopup;
|
|
2041
|
+
let ariaExpanded;
|
|
2042
|
+
if (!inline) {
|
|
2043
|
+
ariaHasPopup = grid ? 'grid' : 'listbox';
|
|
2044
|
+
ariaExpanded = open ? 'true' : 'false';
|
|
2045
|
+
}
|
|
2046
|
+
const role = __rspack_external_react.useMemo(()=>{
|
|
2047
|
+
const isPlainInput = inputElement?.tagName === 'INPUT';
|
|
2048
|
+
const shouldTreatAsInput = null == inputElement || isPlainInput;
|
|
2049
|
+
const shouldApplyAria = shouldTreatAsInput || open;
|
|
2050
|
+
const reference = shouldTreatAsInput ? {
|
|
2051
|
+
autoComplete: 'off',
|
|
2052
|
+
spellCheck: 'false',
|
|
2053
|
+
autoCorrect: 'off',
|
|
2054
|
+
autoCapitalize: 'none'
|
|
2055
|
+
} : {};
|
|
2056
|
+
if (shouldApplyAria) {
|
|
2057
|
+
reference.role = 'combobox';
|
|
2058
|
+
reference['aria-expanded'] = ariaExpanded;
|
|
2059
|
+
reference['aria-haspopup'] = ariaHasPopup;
|
|
2060
|
+
reference['aria-controls'] = open ? listElement?.id : void 0;
|
|
2061
|
+
reference['aria-autocomplete'] = autoComplete;
|
|
2062
|
+
}
|
|
2063
|
+
return {
|
|
2064
|
+
reference,
|
|
2065
|
+
floating: {
|
|
2066
|
+
role: 'presentation'
|
|
2067
|
+
}
|
|
2068
|
+
};
|
|
2069
|
+
}, [
|
|
2070
|
+
inputElement,
|
|
2071
|
+
open,
|
|
2072
|
+
ariaExpanded,
|
|
2073
|
+
ariaHasPopup,
|
|
2074
|
+
listElement?.id,
|
|
2075
|
+
autoComplete
|
|
2076
|
+
]);
|
|
2077
|
+
const click = useClick(floatingRootContext, {
|
|
2078
|
+
enabled: !readOnly && !disabled && openOnInputClick,
|
|
2079
|
+
event: 'mousedown-only',
|
|
2080
|
+
toggle: false,
|
|
2081
|
+
touchOpenDelay: inputInsidePopup ? 0 : 100,
|
|
2082
|
+
reason: inputPress
|
|
2083
|
+
});
|
|
2084
|
+
const dismiss = useDismiss(floatingRootContext, {
|
|
2085
|
+
enabled: !readOnly && !disabled && !inline,
|
|
2086
|
+
outsidePressEvent: {
|
|
2087
|
+
mouse: 'sloppy',
|
|
2088
|
+
touch: 'intentional'
|
|
2089
|
+
},
|
|
2090
|
+
bubbles: inline ? true : void 0,
|
|
2091
|
+
outsidePress (event) {
|
|
2092
|
+
const target = getTarget(event);
|
|
2093
|
+
return !shadowDom_contains(triggerElement, target) && !shadowDom_contains(clearRef.current, target) && !shadowDom_contains(chipsContainerRef.current, target) && !shadowDom_contains(inputGroupElement, target);
|
|
2094
|
+
}
|
|
2095
|
+
});
|
|
2096
|
+
const listNavigation = useListNavigation(floatingRootContext, {
|
|
2097
|
+
enabled: !readOnly && !disabled,
|
|
2098
|
+
id,
|
|
2099
|
+
listRef,
|
|
2100
|
+
activeIndex,
|
|
2101
|
+
selectedIndex,
|
|
2102
|
+
virtual: true,
|
|
2103
|
+
loopFocus,
|
|
2104
|
+
allowEscape: loopFocus && !autoHighlightMode,
|
|
2105
|
+
focusItemOnOpen: queryChangedAfterOpen || 'none' === selectionMode && !autoHighlightMode ? false : 'auto',
|
|
2106
|
+
focusItemOnHover: highlightItemOnHover,
|
|
2107
|
+
resetOnPointerLeave: !keepHighlight,
|
|
2108
|
+
cols: grid ? 2 : 1,
|
|
2109
|
+
orientation: grid ? 'horizontal' : void 0,
|
|
2110
|
+
rtl: 'rtl' === direction,
|
|
2111
|
+
disabledIndices: EMPTY_ARRAY,
|
|
2112
|
+
onNavigate (nextActiveIndex, event) {
|
|
2113
|
+
if (!event && !open || 'ending' === transitionStatus) return;
|
|
2114
|
+
event ? setIndices({
|
|
2115
|
+
activeIndex: nextActiveIndex,
|
|
2116
|
+
type: keyboardActiveRef.current ? 'keyboard' : 'pointer'
|
|
2117
|
+
}) : setIndices({
|
|
2118
|
+
activeIndex: nextActiveIndex
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
});
|
|
2122
|
+
const inputProps = __rspack_external_react.useMemo(()=>mergeProps(listNavigation.reference, dismiss.reference, click.reference, role.reference), [
|
|
2123
|
+
listNavigation.reference,
|
|
2124
|
+
dismiss.reference,
|
|
2125
|
+
click.reference,
|
|
2126
|
+
role.reference
|
|
2127
|
+
]);
|
|
2128
|
+
const popupProps = __rspack_external_react.useMemo(()=>mergeProps(FOCUSABLE_POPUP_PROPS, listNavigation.floating, dismiss.floating, role.floating), [
|
|
2129
|
+
listNavigation.floating,
|
|
2130
|
+
dismiss.floating,
|
|
2131
|
+
role.floating
|
|
2132
|
+
]);
|
|
2133
|
+
const itemProps = __rspack_external_react.useMemo(()=>{
|
|
2134
|
+
const listNavigationItemProps = listNavigation.item;
|
|
2135
|
+
if (!listNavigationItemProps) return EMPTY_OBJECT;
|
|
2136
|
+
return {
|
|
2137
|
+
...listNavigationItemProps,
|
|
2138
|
+
onFocus: void 0
|
|
2139
|
+
};
|
|
2140
|
+
}, [
|
|
2141
|
+
listNavigation.item
|
|
2142
|
+
]);
|
|
2143
|
+
useOnFirstRender(()=>{
|
|
2144
|
+
store.update({
|
|
2145
|
+
inline: inlineProp,
|
|
2146
|
+
popupProps,
|
|
2147
|
+
inputProps,
|
|
2148
|
+
triggerProps,
|
|
2149
|
+
itemProps,
|
|
2150
|
+
setOpen,
|
|
2151
|
+
setInputValue,
|
|
2152
|
+
setSelectedValue,
|
|
2153
|
+
setIndices,
|
|
2154
|
+
onItemHighlighted,
|
|
2155
|
+
handleSelection,
|
|
2156
|
+
forceMount,
|
|
2157
|
+
requestSubmit
|
|
2158
|
+
});
|
|
2159
|
+
});
|
|
2160
|
+
useIsoLayoutEffect(()=>{
|
|
2161
|
+
store.update({
|
|
2162
|
+
id,
|
|
2163
|
+
selectedValue,
|
|
2164
|
+
open,
|
|
2165
|
+
mounted,
|
|
2166
|
+
transitionStatus,
|
|
2167
|
+
items,
|
|
2168
|
+
inline: inlineProp,
|
|
2169
|
+
popupProps,
|
|
2170
|
+
inputProps,
|
|
2171
|
+
triggerProps,
|
|
2172
|
+
openMethod,
|
|
2173
|
+
itemProps,
|
|
2174
|
+
selectionMode,
|
|
2175
|
+
name,
|
|
2176
|
+
form,
|
|
2177
|
+
disabled,
|
|
2178
|
+
readOnly,
|
|
2179
|
+
required,
|
|
2180
|
+
grid,
|
|
2181
|
+
isGrouped,
|
|
2182
|
+
virtualized,
|
|
2183
|
+
onOpenChangeComplete,
|
|
2184
|
+
openOnInputClick,
|
|
2185
|
+
itemToStringLabel,
|
|
2186
|
+
modal,
|
|
2187
|
+
autoHighlight: autoHighlightMode,
|
|
2188
|
+
isItemEqualToValue,
|
|
2189
|
+
submitOnItemClick,
|
|
2190
|
+
hasInputValue,
|
|
2191
|
+
requestSubmit,
|
|
2192
|
+
inputOwnsFormValue: 'none' === selectionMode && (inlineProp || !store.state.inputInsidePopup)
|
|
2193
|
+
});
|
|
2194
|
+
}, [
|
|
2195
|
+
store,
|
|
2196
|
+
id,
|
|
2197
|
+
selectedValue,
|
|
2198
|
+
open,
|
|
2199
|
+
mounted,
|
|
2200
|
+
transitionStatus,
|
|
2201
|
+
items,
|
|
2202
|
+
popupProps,
|
|
2203
|
+
inputProps,
|
|
2204
|
+
itemProps,
|
|
2205
|
+
openMethod,
|
|
2206
|
+
triggerProps,
|
|
2207
|
+
selectionMode,
|
|
2208
|
+
name,
|
|
2209
|
+
disabled,
|
|
2210
|
+
readOnly,
|
|
2211
|
+
required,
|
|
2212
|
+
validation,
|
|
2213
|
+
grid,
|
|
2214
|
+
isGrouped,
|
|
2215
|
+
virtualized,
|
|
2216
|
+
onOpenChangeComplete,
|
|
2217
|
+
openOnInputClick,
|
|
2218
|
+
itemToStringLabel,
|
|
2219
|
+
modal,
|
|
2220
|
+
isItemEqualToValue,
|
|
2221
|
+
submitOnItemClick,
|
|
2222
|
+
hasInputValue,
|
|
2223
|
+
inlineProp,
|
|
2224
|
+
requestSubmit,
|
|
2225
|
+
autoHighlightMode,
|
|
2226
|
+
form
|
|
2227
|
+
]);
|
|
2228
|
+
const hiddenInputRef = useMergedRefs(inputRefProp, validation.inputRef);
|
|
2229
|
+
const itemsContextValue = __rspack_external_react.useMemo(()=>({
|
|
2230
|
+
query,
|
|
2231
|
+
hasItems,
|
|
2232
|
+
filteredItems,
|
|
2233
|
+
flatFilteredItems
|
|
2234
|
+
}), [
|
|
2235
|
+
query,
|
|
2236
|
+
hasItems,
|
|
2237
|
+
filteredItems,
|
|
2238
|
+
flatFilteredItems
|
|
2239
|
+
]);
|
|
2240
|
+
const serializedValue = __rspack_external_react.useMemo(()=>{
|
|
2241
|
+
if (Array.isArray(fieldRawValue)) return '';
|
|
2242
|
+
return stringifyAsValue(fieldRawValue, itemToStringValue);
|
|
2243
|
+
}, [
|
|
2244
|
+
fieldRawValue,
|
|
2245
|
+
itemToStringValue
|
|
2246
|
+
]);
|
|
2247
|
+
const hasMultipleSelection = multiple && Array.isArray(selectedValue) && selectedValue.length > 0;
|
|
2248
|
+
const hiddenInputName = multiple || 'none' === selectionMode && inputOwnsFormValue ? void 0 : name;
|
|
2249
|
+
const hiddenInputs = __rspack_external_react.useMemo(()=>{
|
|
2250
|
+
if (!multiple || !Array.isArray(selectedValue) || !name) return null;
|
|
2251
|
+
return selectedValue.map((value)=>{
|
|
2252
|
+
const currentSerializedValue = stringifyAsValue(value, itemToStringValue);
|
|
2253
|
+
return /*#__PURE__*/ jsx("input", {
|
|
2254
|
+
type: "hidden",
|
|
2255
|
+
form: form,
|
|
2256
|
+
name: name,
|
|
2257
|
+
value: currentSerializedValue
|
|
2258
|
+
}, currentSerializedValue);
|
|
2259
|
+
});
|
|
2260
|
+
}, [
|
|
2261
|
+
multiple,
|
|
2262
|
+
selectedValue,
|
|
2263
|
+
form,
|
|
2264
|
+
name,
|
|
2265
|
+
itemToStringValue
|
|
2266
|
+
]);
|
|
2267
|
+
const children = /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
2268
|
+
children: [
|
|
2269
|
+
props.children,
|
|
2270
|
+
/*#__PURE__*/ jsx("input", {
|
|
2271
|
+
...validation.getInputValidationProps({
|
|
2272
|
+
onFocus () {
|
|
2273
|
+
if (inputInsidePopup) return void triggerElement?.focus();
|
|
2274
|
+
(inputRef.current || triggerElement)?.focus();
|
|
2275
|
+
},
|
|
2276
|
+
onChange (event) {
|
|
2277
|
+
if (event.nativeEvent.defaultPrevented || disabled || readOnly) return void event.preventBaseUIHandler?.();
|
|
2278
|
+
const nextValue = event.currentTarget.value;
|
|
2279
|
+
const details = createChangeEventDetails("none", event.nativeEvent);
|
|
2280
|
+
function handleChange() {
|
|
2281
|
+
if (multiple) return;
|
|
2282
|
+
if ('none' === selectionMode) {
|
|
2283
|
+
setDirty(nextValue !== validityData.initialValue);
|
|
2284
|
+
setInputValue(nextValue, details);
|
|
2285
|
+
if (shouldValidateOnChange()) validation.commit(nextValue);
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2288
|
+
const matchingValue = valuesRef.current.find((v)=>{
|
|
2289
|
+
const candidateValue = stringifyAsValue(v, itemToStringValue);
|
|
2290
|
+
if (candidateValue.toLowerCase() === nextValue.toLowerCase()) return true;
|
|
2291
|
+
const candidateLabel = stringifyAsLabel(v, itemToStringLabel);
|
|
2292
|
+
if (candidateLabel.toLowerCase() === nextValue.toLowerCase()) return true;
|
|
2293
|
+
return false;
|
|
2294
|
+
});
|
|
2295
|
+
if (null != matchingValue) {
|
|
2296
|
+
setDirty(matchingValue !== validityData.initialValue);
|
|
2297
|
+
setSelectedValue?.(matchingValue, details);
|
|
2298
|
+
if (shouldValidateOnChange()) validation.commit(matchingValue);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
if (items) handleChange();
|
|
2302
|
+
else {
|
|
2303
|
+
forceMount();
|
|
2304
|
+
queueMicrotask(handleChange);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}),
|
|
2308
|
+
id: id && null == hiddenInputName ? `${id}-hidden-input` : void 0,
|
|
2309
|
+
form: form,
|
|
2310
|
+
name: hiddenInputName,
|
|
2311
|
+
autoComplete: formAutoComplete,
|
|
2312
|
+
disabled: disabled,
|
|
2313
|
+
required: required && !hasMultipleSelection,
|
|
2314
|
+
readOnly: readOnly,
|
|
2315
|
+
value: serializedValue,
|
|
2316
|
+
ref: hiddenInputRef,
|
|
2317
|
+
style: hiddenInputName ? visuallyHiddenInput : visuallyHidden,
|
|
2318
|
+
tabIndex: -1,
|
|
2319
|
+
"aria-hidden": true,
|
|
2320
|
+
suppressHydrationWarning: true
|
|
2321
|
+
}),
|
|
2322
|
+
hiddenInputs
|
|
2323
|
+
]
|
|
2324
|
+
});
|
|
2325
|
+
return /*#__PURE__*/ jsx(ComboboxRootContext.Provider, {
|
|
2326
|
+
value: store,
|
|
2327
|
+
children: /*#__PURE__*/ jsx(ComboboxFloatingContext.Provider, {
|
|
2328
|
+
value: floatingRootContext,
|
|
2329
|
+
children: /*#__PURE__*/ jsx(ComboboxDerivedItemsContext.Provider, {
|
|
2330
|
+
value: itemsContextValue,
|
|
2331
|
+
children: /*#__PURE__*/ jsx(ComboboxInputValueContext.Provider, {
|
|
2332
|
+
value: inputValue,
|
|
2333
|
+
children: children
|
|
2334
|
+
})
|
|
2335
|
+
})
|
|
2336
|
+
})
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
const ComboboxPortal_ComboboxPortal = /*#__PURE__*/ __rspack_external_react.forwardRef(function(props, forwardedRef) {
|
|
2340
|
+
const { keepMounted = false, ...portalProps } = props;
|
|
2341
|
+
const store = useComboboxRootContext();
|
|
2342
|
+
const mounted = useStore(store, selectors.mounted);
|
|
2343
|
+
const forceMounted = useStore(store, selectors.forceMounted);
|
|
2344
|
+
const shouldRender = mounted || keepMounted || forceMounted;
|
|
2345
|
+
if (!shouldRender) return null;
|
|
2346
|
+
return /*#__PURE__*/ jsx(ComboboxPortalContext.Provider, {
|
|
2347
|
+
value: keepMounted,
|
|
2348
|
+
children: /*#__PURE__*/ jsx(FloatingPortal_FloatingPortal, {
|
|
2349
|
+
ref: forwardedRef,
|
|
2350
|
+
...portalProps
|
|
2351
|
+
})
|
|
2352
|
+
});
|
|
2353
|
+
});
|
|
2354
|
+
if ("production" !== process.env.NODE_ENV) ComboboxPortal_ComboboxPortal.displayName = "ComboboxPortal";
|
|
2355
|
+
export { AriaCombobox, ComboboxArrow_ComboboxArrow, ComboboxBackdrop_ComboboxBackdrop, ComboboxChipsContext, ComboboxClear_ComboboxClear, ComboboxCollection, ComboboxEmpty_ComboboxEmpty, ComboboxGroupLabel_ComboboxGroupLabel, ComboboxGroup_ComboboxGroup, ComboboxIcon_ComboboxIcon, ComboboxInputGroup_ComboboxInputGroup, ComboboxInput_ComboboxInput, ComboboxItem_ComboboxItem, ComboboxList_ComboboxList, ComboboxPopup_ComboboxPopup, ComboboxPortal_ComboboxPortal, ComboboxPositioner_ComboboxPositioner, ComboboxRow_ComboboxRow, ComboboxStatus_ComboboxStatus, ComboboxTrigger_ComboboxTrigger, handleInputPress, selectors, useComboboxChipsContext, useComboboxInputValueContext, useComboboxItemContext, useComboboxRootContext, useCoreFilter };
|