@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/Select/index.js
CHANGED
|
@@ -1,7 +1,1808 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Select } from "@base-ui/react/select";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import clsx from "clsx";
|
|
3
|
+
import { EMPTY_ARRAY, useRefWithInit, EMPTY_OBJECT, mergeProps, useMergedRefs, useRenderElement, esm_formatErrorMessage } from "../8272.js";
|
|
4
|
+
import { Store, createSelector, useStore, useDismiss } from "../5992.js";
|
|
5
|
+
import { defaultItemEquality, removeItem, findItemIndex, stringifyAsLabel, stringifyAsValue, hasNullItemLabel, compareItemEquality, selectedValueIncludes, resolveMultipleLabels, resolveSelectedLabel } from "../7366.js";
|
|
6
|
+
import { useLabelableContext, useFieldRootContext, fieldValidityMapping } from "../1477.js";
|
|
7
|
+
import { getDefaultLabelId, resolveAriaLabelledBy } from "../6825.js";
|
|
8
|
+
import { useLabel } from "../4143.js";
|
|
9
|
+
import { DROPDOWN_COLLISION_AVOIDANCE, triggerOpenStateMapping, FloatingPortal_FloatingPortal, popupStateMapping, pressableTriggerOpenStateMapping } from "../4388.js";
|
|
10
|
+
import { useLabelableId } from "../9048.js";
|
|
11
|
+
import { useValueAsRef } from "../4707.js";
|
|
12
|
+
import { useButton } from "../9189.js";
|
|
13
|
+
import { useStableCallback } from "../7541.js";
|
|
14
|
+
import { useTimeout } from "../42.js";
|
|
15
|
+
import { getFloatingFocusElement } from "../8758.js";
|
|
16
|
+
import { createChangeEventDetails } from "../4768.js";
|
|
17
|
+
import { contains } from "../4549.js";
|
|
18
|
+
import { ownerDocument } from "../9829.js";
|
|
19
|
+
import { getPseudoElementBounds } from "../7373.js";
|
|
20
|
+
import { itemPress, focusOut, outsidePress, cancelOpen, windowResize } from "../2418.js";
|
|
21
|
+
import { transitionStatusMapping, useTransitionStatus, useOpenChangeComplete } from "../880.js";
|
|
22
|
+
import { useIsoLayoutEffect } from "../6499.js";
|
|
23
|
+
import { useAnchoredPopupScrollLock } from "../6247.js";
|
|
24
|
+
import { usePositioner, floating_ui_dom_platform, useAnchorPositioning, getDisabledMountTransitionStyles, useFloatingRootContext } from "../8750.js";
|
|
25
|
+
import { CompositeList } from "../9255.js";
|
|
26
|
+
import { useOpenInteractionType, FloatingFocusManager, InternalBackdrop_InternalBackdrop } from "../3485.js";
|
|
27
|
+
import { inertValue } from "../167.js";
|
|
28
|
+
import { useToolbarRootContext } from "../6107.js";
|
|
29
|
+
import { useDirection } from "../9863.js";
|
|
30
|
+
import { useCSPContext } from "../6003.js";
|
|
31
|
+
import { useAnimationFrame } from "../8996.js";
|
|
32
|
+
import { clamp } from "../3296.js";
|
|
33
|
+
import { getWindow } from "../3829.js";
|
|
34
|
+
import { isWebKit } from "../8971.js";
|
|
35
|
+
import { addEventListener } from "../4723.js";
|
|
36
|
+
import { COMPOSITE_KEYS } from "../1500.js";
|
|
37
|
+
import { styleDisableScrollbar, normalizeScrollOffset, getMaxScrollOffset } from "../6329.js";
|
|
38
|
+
import { rectToClientRect } from "../3319.js";
|
|
39
|
+
import { useCompositeListItem, useCompositeListItem_IndexGuessBehavior } from "../3021.js";
|
|
40
|
+
import { isVirtualClick } from "../6330.js";
|
|
41
|
+
import { useBaseUiId } from "../6046.js";
|
|
42
|
+
import { useFormContext } from "../5085.js";
|
|
43
|
+
import { useControlled } from "../8527.js";
|
|
44
|
+
import { usePreviousValue } from "../7021.js";
|
|
45
|
+
import { useRegisterFieldControl } from "../4281.js";
|
|
46
|
+
import { useValueChanged } from "../2801.js";
|
|
47
|
+
import { useClick } from "../5864.js";
|
|
48
|
+
import { useListNavigation, useTypeahead } from "../5299.js";
|
|
49
|
+
import { FOCUSABLE_POPUP_PROPS, useOnFirstRender } from "../8106.js";
|
|
50
|
+
import { visuallyHiddenInput, visuallyHidden } from "../8225.js";
|
|
51
|
+
import { Separator } from "../9635.js";
|
|
4
52
|
import * as __rspack_external_react from "react";
|
|
53
|
+
const SelectRootContext = /*#__PURE__*/ __rspack_external_react.createContext(null);
|
|
54
|
+
if ("production" !== process.env.NODE_ENV) SelectRootContext.displayName = "SelectRootContext";
|
|
55
|
+
const SelectFloatingContext = /*#__PURE__*/ __rspack_external_react.createContext(null);
|
|
56
|
+
if ("production" !== process.env.NODE_ENV) SelectFloatingContext.displayName = "SelectFloatingContext";
|
|
57
|
+
function useSelectRootContext() {
|
|
58
|
+
const context = __rspack_external_react.useContext(SelectRootContext);
|
|
59
|
+
if (null === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SelectRootContext is missing. Select parts must be placed within <Select.Root>.' : esm_formatErrorMessage(60));
|
|
60
|
+
return context;
|
|
61
|
+
}
|
|
62
|
+
function useSelectFloatingContext() {
|
|
63
|
+
const context = __rspack_external_react.useContext(SelectFloatingContext);
|
|
64
|
+
if (null === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SelectFloatingContext is missing. Select parts must be placed within <Select.Root>.' : esm_formatErrorMessage(61));
|
|
65
|
+
return context;
|
|
66
|
+
}
|
|
67
|
+
const selectors = {
|
|
68
|
+
id: createSelector((state)=>state.id),
|
|
69
|
+
labelId: createSelector((state)=>state.labelId),
|
|
70
|
+
modal: createSelector((state)=>state.modal),
|
|
71
|
+
multiple: createSelector((state)=>state.multiple),
|
|
72
|
+
items: createSelector((state)=>state.items),
|
|
73
|
+
itemToStringLabel: createSelector((state)=>state.itemToStringLabel),
|
|
74
|
+
itemToStringValue: createSelector((state)=>state.itemToStringValue),
|
|
75
|
+
isItemEqualToValue: createSelector((state)=>state.isItemEqualToValue),
|
|
76
|
+
value: createSelector((state)=>state.value),
|
|
77
|
+
hasSelectedValue: createSelector((state)=>{
|
|
78
|
+
const { value, multiple, itemToStringValue } = state;
|
|
79
|
+
if (null == value) return false;
|
|
80
|
+
if (multiple && Array.isArray(value)) return value.length > 0;
|
|
81
|
+
return '' !== stringifyAsValue(value, itemToStringValue);
|
|
82
|
+
}),
|
|
83
|
+
hasNullItemLabel: createSelector((state, enabled)=>enabled ? hasNullItemLabel(state.items) : false),
|
|
84
|
+
open: createSelector((state)=>state.open),
|
|
85
|
+
mounted: createSelector((state)=>state.mounted),
|
|
86
|
+
forceMount: createSelector((state)=>state.forceMount),
|
|
87
|
+
transitionStatus: createSelector((state)=>state.transitionStatus),
|
|
88
|
+
openMethod: createSelector((state)=>state.openMethod),
|
|
89
|
+
activeIndex: createSelector((state)=>state.activeIndex),
|
|
90
|
+
selectedIndex: createSelector((state)=>state.selectedIndex),
|
|
91
|
+
isActive: createSelector((state, index)=>state.activeIndex === index),
|
|
92
|
+
isSelected: createSelector((state, index, itemValue)=>{
|
|
93
|
+
const comparer = state.isItemEqualToValue;
|
|
94
|
+
const storeValue = state.value;
|
|
95
|
+
if (state.multiple) return Array.isArray(storeValue) && storeValue.some((selectedItem)=>compareItemEquality(itemValue, selectedItem, comparer));
|
|
96
|
+
if (state.selectedIndex === index && null !== state.selectedIndex) return true;
|
|
97
|
+
return compareItemEquality(itemValue, storeValue, comparer);
|
|
98
|
+
}),
|
|
99
|
+
isSelectedByFocus: createSelector((state, index)=>state.selectedIndex === index),
|
|
100
|
+
popupProps: createSelector((state)=>state.popupProps),
|
|
101
|
+
triggerProps: createSelector((state)=>state.triggerProps),
|
|
102
|
+
triggerElement: createSelector((state)=>state.triggerElement),
|
|
103
|
+
positionerElement: createSelector((state)=>state.positionerElement),
|
|
104
|
+
listElement: createSelector((state)=>state.listElement),
|
|
105
|
+
popupSide: createSelector((state)=>state.popupSide),
|
|
106
|
+
scrollUpArrowVisible: createSelector((state)=>state.scrollUpArrowVisible),
|
|
107
|
+
scrollDownArrowVisible: createSelector((state)=>state.scrollDownArrowVisible),
|
|
108
|
+
hasScrollArrows: createSelector((state)=>state.hasScrollArrows)
|
|
109
|
+
};
|
|
110
|
+
const SelectLabel_SelectLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
111
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
112
|
+
const elementPropsWithoutId = elementProps;
|
|
113
|
+
delete elementPropsWithoutId.id;
|
|
114
|
+
const fieldRootContext = useFieldRootContext();
|
|
115
|
+
const { store } = useSelectRootContext();
|
|
116
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
117
|
+
const rootId = useStore(store, selectors.id);
|
|
118
|
+
const defaultLabelId = getDefaultLabelId(rootId);
|
|
119
|
+
const labelProps = useLabel({
|
|
120
|
+
id: defaultLabelId,
|
|
121
|
+
fallbackControlId: triggerElement?.id ?? rootId,
|
|
122
|
+
setLabelId (nextLabelId) {
|
|
123
|
+
store.set('labelId', nextLabelId);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return useRenderElement('div', componentProps, {
|
|
127
|
+
ref: forwardedRef,
|
|
128
|
+
state: fieldRootContext.state,
|
|
129
|
+
props: [
|
|
130
|
+
labelProps,
|
|
131
|
+
elementProps
|
|
132
|
+
],
|
|
133
|
+
stateAttributesMapping: fieldValidityMapping
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
if ("production" !== process.env.NODE_ENV) SelectLabel_SelectLabel.displayName = "SelectLabel";
|
|
137
|
+
const BOUNDARY_OFFSET = 2;
|
|
138
|
+
const SELECTED_DELAY = 400;
|
|
139
|
+
const stateAttributesMapping = {
|
|
140
|
+
...pressableTriggerOpenStateMapping,
|
|
141
|
+
...fieldValidityMapping,
|
|
142
|
+
popupSide: (side)=>side ? {
|
|
143
|
+
'data-popup-side': side
|
|
144
|
+
} : null,
|
|
145
|
+
value: ()=>null
|
|
146
|
+
};
|
|
147
|
+
const SelectTrigger_SelectTrigger = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
148
|
+
const { render, className, id: idProp, disabled: disabledProp = false, nativeButton = true, style, ...elementProps } = componentProps;
|
|
149
|
+
const { setTouched, setFocused, validationMode, state: fieldState, disabled: fieldDisabled } = useFieldRootContext();
|
|
150
|
+
const { labelId: fieldLabelId } = useLabelableContext();
|
|
151
|
+
const { store, setOpen, selectionRef, validation, readOnly, required, alignItemWithTriggerActiveRef, disabled: selectDisabled, keyboardActiveRef } = useSelectRootContext();
|
|
152
|
+
const disabled = fieldDisabled || selectDisabled || disabledProp;
|
|
153
|
+
const open = useStore(store, selectors.open);
|
|
154
|
+
const mounted = useStore(store, selectors.mounted);
|
|
155
|
+
const value = useStore(store, selectors.value);
|
|
156
|
+
const triggerProps = useStore(store, selectors.triggerProps);
|
|
157
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
158
|
+
const listElement = useStore(store, selectors.listElement);
|
|
159
|
+
const popupSideValue = useStore(store, selectors.popupSide);
|
|
160
|
+
const rootId = useStore(store, selectors.id);
|
|
161
|
+
const selectLabelId = useStore(store, selectors.labelId);
|
|
162
|
+
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
|
|
163
|
+
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
164
|
+
const id = idProp ?? rootId;
|
|
165
|
+
const ariaLabelledBy = resolveAriaLabelledBy(fieldLabelId, selectLabelId);
|
|
166
|
+
useLabelableId({
|
|
167
|
+
id
|
|
168
|
+
});
|
|
169
|
+
const positionerRef = useValueAsRef(positionerElement);
|
|
170
|
+
const triggerRef = __rspack_external_react.useRef(null);
|
|
171
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
172
|
+
disabled,
|
|
173
|
+
native: nativeButton
|
|
174
|
+
});
|
|
175
|
+
const setTriggerElement = useStableCallback((element)=>{
|
|
176
|
+
store.set('triggerElement', element);
|
|
177
|
+
});
|
|
178
|
+
const mergedRef = useMergedRefs(forwardedRef, triggerRef, buttonRef, setTriggerElement);
|
|
179
|
+
const timeoutFocus = useTimeout();
|
|
180
|
+
const timeoutMouseDown = useTimeout();
|
|
181
|
+
const selectedDelayTimeout = useTimeout();
|
|
182
|
+
__rspack_external_react.useEffect(()=>{
|
|
183
|
+
if (open) {
|
|
184
|
+
selectedDelayTimeout.start(SELECTED_DELAY, ()=>{
|
|
185
|
+
selectionRef.current.allowUnselectedMouseUp = true;
|
|
186
|
+
selectionRef.current.allowSelectedMouseUp = true;
|
|
187
|
+
});
|
|
188
|
+
return ()=>{
|
|
189
|
+
selectedDelayTimeout.clear();
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
selectionRef.current = {
|
|
193
|
+
allowSelectedMouseUp: false,
|
|
194
|
+
allowUnselectedMouseUp: false,
|
|
195
|
+
dragY: 0
|
|
196
|
+
};
|
|
197
|
+
timeoutMouseDown.clear();
|
|
198
|
+
}, [
|
|
199
|
+
open,
|
|
200
|
+
selectionRef,
|
|
201
|
+
timeoutMouseDown,
|
|
202
|
+
selectedDelayTimeout
|
|
203
|
+
]);
|
|
204
|
+
const props = mergeProps(triggerProps, {
|
|
205
|
+
id,
|
|
206
|
+
role: 'combobox',
|
|
207
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
208
|
+
'aria-haspopup': 'listbox',
|
|
209
|
+
'aria-controls': open ? listElement?.id ?? getFloatingFocusElement(positionerElement)?.id : void 0,
|
|
210
|
+
'aria-labelledby': ariaLabelledBy,
|
|
211
|
+
'aria-readonly': readOnly || void 0,
|
|
212
|
+
'aria-required': required || void 0,
|
|
213
|
+
tabIndex: disabled ? -1 : 0,
|
|
214
|
+
ref: mergedRef,
|
|
215
|
+
onFocus (event) {
|
|
216
|
+
setFocused(true);
|
|
217
|
+
if (open && alignItemWithTriggerActiveRef.current) setOpen(false, createChangeEventDetails("none", event.nativeEvent));
|
|
218
|
+
timeoutFocus.start(0, ()=>{
|
|
219
|
+
store.set('forceMount', true);
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
onBlur (event) {
|
|
223
|
+
if (contains(positionerElement, event.relatedTarget)) return;
|
|
224
|
+
setTouched(true);
|
|
225
|
+
setFocused(false);
|
|
226
|
+
if ('onBlur' === validationMode) validation.commit(value);
|
|
227
|
+
},
|
|
228
|
+
onPointerMove () {
|
|
229
|
+
keyboardActiveRef.current = false;
|
|
230
|
+
},
|
|
231
|
+
onKeyDown () {
|
|
232
|
+
keyboardActiveRef.current = true;
|
|
233
|
+
},
|
|
234
|
+
onMouseDown (event) {
|
|
235
|
+
if (open) return;
|
|
236
|
+
const doc = ownerDocument(event.currentTarget);
|
|
237
|
+
function handleMouseUp(mouseEvent) {
|
|
238
|
+
if (!triggerRef.current) return;
|
|
239
|
+
const mouseUpTarget = mouseEvent.target;
|
|
240
|
+
if (contains(triggerRef.current, mouseUpTarget) || contains(positionerRef.current, mouseUpTarget) || mouseUpTarget === triggerRef.current) return;
|
|
241
|
+
const bounds = getPseudoElementBounds(triggerRef.current);
|
|
242
|
+
if (mouseEvent.clientX >= bounds.left - BOUNDARY_OFFSET && mouseEvent.clientX <= bounds.right + BOUNDARY_OFFSET && mouseEvent.clientY >= bounds.top - BOUNDARY_OFFSET && mouseEvent.clientY <= bounds.bottom + BOUNDARY_OFFSET) return;
|
|
243
|
+
setOpen(false, createChangeEventDetails(cancelOpen, mouseEvent));
|
|
244
|
+
}
|
|
245
|
+
timeoutMouseDown.start(0, ()=>{
|
|
246
|
+
doc.addEventListener('mouseup', handleMouseUp, {
|
|
247
|
+
once: true
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}, validation.getValidationProps, elementProps, getButtonProps);
|
|
252
|
+
props.role = 'combobox';
|
|
253
|
+
const state = {
|
|
254
|
+
...fieldState,
|
|
255
|
+
open,
|
|
256
|
+
disabled,
|
|
257
|
+
value,
|
|
258
|
+
readOnly,
|
|
259
|
+
popupSide,
|
|
260
|
+
placeholder: !hasSelectedValue
|
|
261
|
+
};
|
|
262
|
+
return useRenderElement('button', componentProps, {
|
|
263
|
+
ref: [
|
|
264
|
+
forwardedRef,
|
|
265
|
+
triggerRef
|
|
266
|
+
],
|
|
267
|
+
state,
|
|
268
|
+
stateAttributesMapping: stateAttributesMapping,
|
|
269
|
+
props
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
if ("production" !== process.env.NODE_ENV) SelectTrigger_SelectTrigger.displayName = "SelectTrigger";
|
|
273
|
+
const SelectValue_stateAttributesMapping = {
|
|
274
|
+
value: ()=>null
|
|
275
|
+
};
|
|
276
|
+
const SelectValue_SelectValue = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
277
|
+
const { className, render, children: childrenProp, placeholder, style, ...elementProps } = componentProps;
|
|
278
|
+
const { store, valueRef } = useSelectRootContext();
|
|
279
|
+
const value = useStore(store, selectors.value);
|
|
280
|
+
const items = useStore(store, selectors.items);
|
|
281
|
+
const itemToStringLabel = useStore(store, selectors.itemToStringLabel);
|
|
282
|
+
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
|
|
283
|
+
const shouldCheckNullItemLabel = !hasSelectedValue && null != placeholder && null == childrenProp;
|
|
284
|
+
const hasNullLabel = useStore(store, selectors.hasNullItemLabel, shouldCheckNullItemLabel);
|
|
285
|
+
const state = {
|
|
286
|
+
value,
|
|
287
|
+
placeholder: !hasSelectedValue
|
|
288
|
+
};
|
|
289
|
+
let children = null;
|
|
290
|
+
children = 'function' == typeof childrenProp ? childrenProp(value) : null != childrenProp ? childrenProp : hasSelectedValue || null == placeholder || hasNullLabel ? Array.isArray(value) ? resolveMultipleLabels(value, items, itemToStringLabel) : resolveSelectedLabel(value, items, itemToStringLabel) : placeholder;
|
|
291
|
+
const element = useRenderElement('span', componentProps, {
|
|
292
|
+
state,
|
|
293
|
+
ref: [
|
|
294
|
+
forwardedRef,
|
|
295
|
+
valueRef
|
|
296
|
+
],
|
|
297
|
+
props: [
|
|
298
|
+
{
|
|
299
|
+
children
|
|
300
|
+
},
|
|
301
|
+
elementProps
|
|
302
|
+
],
|
|
303
|
+
stateAttributesMapping: SelectValue_stateAttributesMapping
|
|
304
|
+
});
|
|
305
|
+
return element;
|
|
306
|
+
});
|
|
307
|
+
if ("production" !== process.env.NODE_ENV) SelectValue_SelectValue.displayName = "SelectValue";
|
|
308
|
+
const SelectIcon_SelectIcon = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
309
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
310
|
+
const { store } = useSelectRootContext();
|
|
311
|
+
const open = useStore(store, selectors.open);
|
|
312
|
+
const state = {
|
|
313
|
+
open
|
|
314
|
+
};
|
|
315
|
+
const element = useRenderElement('span', componentProps, {
|
|
316
|
+
state,
|
|
317
|
+
ref: forwardedRef,
|
|
318
|
+
props: [
|
|
319
|
+
{
|
|
320
|
+
'aria-hidden': true,
|
|
321
|
+
children: '▼'
|
|
322
|
+
},
|
|
323
|
+
elementProps
|
|
324
|
+
],
|
|
325
|
+
stateAttributesMapping: triggerOpenStateMapping
|
|
326
|
+
});
|
|
327
|
+
return element;
|
|
328
|
+
});
|
|
329
|
+
if ("production" !== process.env.NODE_ENV) SelectIcon_SelectIcon.displayName = "SelectIcon";
|
|
330
|
+
const SelectBackdrop_stateAttributesMapping = {
|
|
331
|
+
...popupStateMapping,
|
|
332
|
+
...transitionStatusMapping
|
|
333
|
+
};
|
|
334
|
+
const SelectBackdrop_SelectBackdrop = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
335
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
336
|
+
const { store } = useSelectRootContext();
|
|
337
|
+
const open = useStore(store, selectors.open);
|
|
338
|
+
const mounted = useStore(store, selectors.mounted);
|
|
339
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
340
|
+
const state = {
|
|
341
|
+
open,
|
|
342
|
+
transitionStatus
|
|
343
|
+
};
|
|
344
|
+
const element = useRenderElement('div', componentProps, {
|
|
345
|
+
state,
|
|
346
|
+
ref: forwardedRef,
|
|
347
|
+
props: [
|
|
348
|
+
{
|
|
349
|
+
role: 'presentation',
|
|
350
|
+
hidden: !mounted,
|
|
351
|
+
style: {
|
|
352
|
+
userSelect: 'none',
|
|
353
|
+
WebkitUserSelect: 'none'
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
elementProps
|
|
357
|
+
],
|
|
358
|
+
stateAttributesMapping: SelectBackdrop_stateAttributesMapping
|
|
359
|
+
});
|
|
360
|
+
return element;
|
|
361
|
+
});
|
|
362
|
+
if ("production" !== process.env.NODE_ENV) SelectBackdrop_SelectBackdrop.displayName = "SelectBackdrop";
|
|
363
|
+
const SelectPositionerContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
364
|
+
if ("production" !== process.env.NODE_ENV) SelectPositionerContext.displayName = "SelectPositionerContext";
|
|
365
|
+
function useSelectPositionerContext() {
|
|
366
|
+
const context = __rspack_external_react.useContext(SelectPositionerContext);
|
|
367
|
+
if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SelectPositionerContext is missing. SelectPositioner parts must be placed within <Select.Positioner>.' : esm_formatErrorMessage(59));
|
|
368
|
+
return context;
|
|
369
|
+
}
|
|
370
|
+
function clearStyles(element, originalStyles) {
|
|
371
|
+
if (element) Object.assign(element.style, originalStyles);
|
|
372
|
+
}
|
|
373
|
+
const LIST_FUNCTIONAL_STYLES = {
|
|
374
|
+
position: 'relative',
|
|
375
|
+
maxHeight: '100%',
|
|
376
|
+
overflowX: 'hidden',
|
|
377
|
+
overflowY: 'auto'
|
|
378
|
+
};
|
|
379
|
+
const FIXED = {
|
|
380
|
+
position: 'fixed'
|
|
381
|
+
};
|
|
382
|
+
const SelectPositioner_SelectPositioner = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
383
|
+
const { anchor, positionMethod = 'absolute', className, render, side = 'bottom', align = 'center', sideOffset = 0, alignOffset = 0, collisionBoundary = 'clipping-ancestors', collisionPadding, arrowPadding = 5, sticky = false, disableAnchorTracking, alignItemWithTrigger = true, collisionAvoidance = DROPDOWN_COLLISION_AVOIDANCE, style, ...elementProps } = componentProps;
|
|
384
|
+
const { store, listRef, labelsRef, alignItemWithTriggerActiveRef, selectedItemTextRef, valuesRef, initialValueRef, popupRef, setValue } = useSelectRootContext();
|
|
385
|
+
const floatingRootContext = useSelectFloatingContext();
|
|
386
|
+
const open = useStore(store, selectors.open);
|
|
387
|
+
const mounted = useStore(store, selectors.mounted);
|
|
388
|
+
const modal = useStore(store, selectors.modal);
|
|
389
|
+
const value = useStore(store, selectors.value);
|
|
390
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
391
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
392
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
393
|
+
const isItemEqualToValue = useStore(store, selectors.isItemEqualToValue);
|
|
394
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
395
|
+
const scrollUpArrowRef = __rspack_external_react.useRef(null);
|
|
396
|
+
const scrollDownArrowRef = __rspack_external_react.useRef(null);
|
|
397
|
+
const [controlledAlignItemWithTrigger, setControlledAlignItemWithTrigger] = __rspack_external_react.useState(alignItemWithTrigger);
|
|
398
|
+
const alignItemWithTriggerActive = mounted && controlledAlignItemWithTrigger && 'touch' !== openMethod;
|
|
399
|
+
if (!mounted && controlledAlignItemWithTrigger !== alignItemWithTrigger) setControlledAlignItemWithTrigger(alignItemWithTrigger);
|
|
400
|
+
useIsoLayoutEffect(()=>{
|
|
401
|
+
if (!mounted) {
|
|
402
|
+
if (selectors.scrollUpArrowVisible(store.state)) store.set('scrollUpArrowVisible', false);
|
|
403
|
+
if (selectors.scrollDownArrowVisible(store.state)) store.set('scrollDownArrowVisible', false);
|
|
404
|
+
}
|
|
405
|
+
}, [
|
|
406
|
+
store,
|
|
407
|
+
mounted
|
|
408
|
+
]);
|
|
409
|
+
__rspack_external_react.useImperativeHandle(alignItemWithTriggerActiveRef, ()=>alignItemWithTriggerActive);
|
|
410
|
+
useAnchoredPopupScrollLock((alignItemWithTriggerActive || modal) && open, 'touch' === openMethod, positionerElement, triggerElement);
|
|
411
|
+
const positioning = useAnchorPositioning({
|
|
412
|
+
anchor,
|
|
413
|
+
floatingRootContext,
|
|
414
|
+
positionMethod,
|
|
415
|
+
mounted,
|
|
416
|
+
side,
|
|
417
|
+
sideOffset,
|
|
418
|
+
align,
|
|
419
|
+
alignOffset,
|
|
420
|
+
arrowPadding,
|
|
421
|
+
collisionBoundary,
|
|
422
|
+
collisionPadding,
|
|
423
|
+
sticky,
|
|
424
|
+
disableAnchorTracking: disableAnchorTracking ?? alignItemWithTriggerActive,
|
|
425
|
+
collisionAvoidance,
|
|
426
|
+
keepMounted: true
|
|
427
|
+
});
|
|
428
|
+
const renderedSide = alignItemWithTriggerActive ? 'none' : positioning.side;
|
|
429
|
+
const positionerStyles = alignItemWithTriggerActive ? FIXED : positioning.positionerStyles;
|
|
430
|
+
const state = {
|
|
431
|
+
open,
|
|
432
|
+
side: renderedSide,
|
|
433
|
+
align: positioning.align,
|
|
434
|
+
anchorHidden: positioning.anchorHidden
|
|
435
|
+
};
|
|
436
|
+
useIsoLayoutEffect(()=>{
|
|
437
|
+
store.set('popupSide', positioning.side);
|
|
438
|
+
}, [
|
|
439
|
+
store,
|
|
440
|
+
positioning.side
|
|
441
|
+
]);
|
|
442
|
+
const setPositionerElement = useStableCallback((element)=>{
|
|
443
|
+
store.set('positionerElement', element);
|
|
444
|
+
});
|
|
445
|
+
const element = usePositioner(componentProps, state, {
|
|
446
|
+
styles: positionerStyles,
|
|
447
|
+
transitionStatus,
|
|
448
|
+
props: elementProps,
|
|
449
|
+
refs: [
|
|
450
|
+
forwardedRef,
|
|
451
|
+
setPositionerElement
|
|
452
|
+
],
|
|
453
|
+
hidden: !mounted,
|
|
454
|
+
inert: !open
|
|
455
|
+
});
|
|
456
|
+
const prevMapSizeRef = __rspack_external_react.useRef(0);
|
|
457
|
+
const onMapChange = useStableCallback((map)=>{
|
|
458
|
+
if (0 === map.size && 0 === prevMapSizeRef.current) return;
|
|
459
|
+
if (0 === valuesRef.current.length) return;
|
|
460
|
+
const prevSize = prevMapSizeRef.current;
|
|
461
|
+
prevMapSizeRef.current = map.size;
|
|
462
|
+
if (map.size === prevSize) return;
|
|
463
|
+
const eventDetails = createChangeEventDetails("none");
|
|
464
|
+
if (0 !== prevSize && !store.state.multiple && null !== value) {
|
|
465
|
+
const selectedValueIndex = findItemIndex(valuesRef.current, value, isItemEqualToValue);
|
|
466
|
+
if (-1 === selectedValueIndex) {
|
|
467
|
+
const initialSelectedValue = initialValueRef.current;
|
|
468
|
+
const hasInitial = null != initialSelectedValue && -1 !== findItemIndex(valuesRef.current, initialSelectedValue, isItemEqualToValue);
|
|
469
|
+
const nextValue = hasInitial ? initialSelectedValue : null;
|
|
470
|
+
setValue(nextValue, eventDetails);
|
|
471
|
+
if (null === nextValue) {
|
|
472
|
+
store.set('selectedIndex', null);
|
|
473
|
+
selectedItemTextRef.current = null;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (0 !== prevSize && store.state.multiple && Array.isArray(value)) {
|
|
478
|
+
const hasVisibleItem = (selectedItemValue)=>-1 !== findItemIndex(valuesRef.current, selectedItemValue, isItemEqualToValue);
|
|
479
|
+
const nextValue = value.filter((selectedItemValue)=>hasVisibleItem(selectedItemValue));
|
|
480
|
+
if (nextValue.length !== value.length || nextValue.some((selectedItemValue)=>!selectedValueIncludes(value, selectedItemValue, isItemEqualToValue))) {
|
|
481
|
+
setValue(nextValue, eventDetails);
|
|
482
|
+
if (0 === nextValue.length) {
|
|
483
|
+
store.set('selectedIndex', null);
|
|
484
|
+
selectedItemTextRef.current = null;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (open && alignItemWithTriggerActive) {
|
|
489
|
+
store.update({
|
|
490
|
+
scrollUpArrowVisible: false,
|
|
491
|
+
scrollDownArrowVisible: false
|
|
492
|
+
});
|
|
493
|
+
const stylesToClear = {
|
|
494
|
+
height: ''
|
|
495
|
+
};
|
|
496
|
+
clearStyles(positionerElement, stylesToClear);
|
|
497
|
+
clearStyles(popupRef.current, stylesToClear);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
501
|
+
...positioning,
|
|
502
|
+
side: renderedSide,
|
|
503
|
+
alignItemWithTriggerActive,
|
|
504
|
+
setControlledAlignItemWithTrigger,
|
|
505
|
+
scrollUpArrowRef,
|
|
506
|
+
scrollDownArrowRef
|
|
507
|
+
}), [
|
|
508
|
+
positioning,
|
|
509
|
+
renderedSide,
|
|
510
|
+
alignItemWithTriggerActive,
|
|
511
|
+
setControlledAlignItemWithTrigger
|
|
512
|
+
]);
|
|
513
|
+
return /*#__PURE__*/ jsx(CompositeList, {
|
|
514
|
+
elementsRef: listRef,
|
|
515
|
+
labelsRef: labelsRef,
|
|
516
|
+
onMapChange: onMapChange,
|
|
517
|
+
children: /*#__PURE__*/ jsxs(SelectPositionerContext.Provider, {
|
|
518
|
+
value: contextValue,
|
|
519
|
+
children: [
|
|
520
|
+
mounted && modal && /*#__PURE__*/ jsx(InternalBackdrop_InternalBackdrop, {
|
|
521
|
+
inert: inertValue(!open),
|
|
522
|
+
cutout: triggerElement
|
|
523
|
+
}),
|
|
524
|
+
element
|
|
525
|
+
]
|
|
526
|
+
})
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
if ("production" !== process.env.NODE_ENV) SelectPositioner_SelectPositioner.displayName = "SelectPositioner";
|
|
530
|
+
const SelectPopup_stateAttributesMapping = {
|
|
531
|
+
...popupStateMapping,
|
|
532
|
+
...transitionStatusMapping
|
|
533
|
+
};
|
|
534
|
+
const SelectPopup_SelectPopup = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
535
|
+
const { render, className, style, finalFocus, ...elementProps } = componentProps;
|
|
536
|
+
const { store, popupRef, onOpenChangeComplete, setOpen, valueRef, firstItemTextRef, selectedItemTextRef, keyboardActiveRef, multiple, handleScrollArrowVisibility, scrollHandlerRef, listRef, highlightItemOnHover } = useSelectRootContext();
|
|
537
|
+
const { side, align, alignItemWithTriggerActive, isPositioned, setControlledAlignItemWithTrigger, scrollDownArrowRef, scrollUpArrowRef } = useSelectPositionerContext();
|
|
538
|
+
const insideToolbar = null != useToolbarRootContext(true);
|
|
539
|
+
const floatingRootContext = useSelectFloatingContext();
|
|
540
|
+
const direction = useDirection();
|
|
541
|
+
const { nonce, disableStyleElements } = useCSPContext();
|
|
542
|
+
const id = useStore(store, selectors.id);
|
|
543
|
+
const open = useStore(store, selectors.open);
|
|
544
|
+
const mounted = useStore(store, selectors.mounted);
|
|
545
|
+
const popupProps = useStore(store, selectors.popupProps);
|
|
546
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
547
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
548
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
549
|
+
const listElement = useStore(store, selectors.listElement);
|
|
550
|
+
const reachedMaxHeightRef = __rspack_external_react.useRef(false);
|
|
551
|
+
const initialPlacedRef = __rspack_external_react.useRef(false);
|
|
552
|
+
const originalPositionerStylesRef = __rspack_external_react.useRef({});
|
|
553
|
+
const scrollArrowFrame = useAnimationFrame();
|
|
554
|
+
const handleScroll = useStableCallback((scroller)=>{
|
|
555
|
+
if (!positionerElement || !popupRef.current || !initialPlacedRef.current) return;
|
|
556
|
+
if (reachedMaxHeightRef.current || !alignItemWithTriggerActive) return void handleScrollArrowVisibility();
|
|
557
|
+
const isTopPositioned = '0px' === positionerElement.style.top;
|
|
558
|
+
const isBottomPositioned = '0px' === positionerElement.style.bottom;
|
|
559
|
+
if (!isTopPositioned && !isBottomPositioned) return void handleScrollArrowVisibility();
|
|
560
|
+
const scale = getScale(positionerElement);
|
|
561
|
+
const currentHeight = normalizeSize(positionerElement.getBoundingClientRect().height, 'y', scale);
|
|
562
|
+
const doc = ownerDocument(positionerElement);
|
|
563
|
+
const positionerStyles = getComputedStyle(positionerElement);
|
|
564
|
+
const marginTop = parseFloat(positionerStyles.marginTop);
|
|
565
|
+
const marginBottom = parseFloat(positionerStyles.marginBottom);
|
|
566
|
+
const maxPopupHeight = getMaxPopupHeight(getComputedStyle(popupRef.current));
|
|
567
|
+
const maxAvailableHeight = Math.min(doc.documentElement.clientHeight - marginTop - marginBottom, maxPopupHeight);
|
|
568
|
+
const scrollTop = scroller.scrollTop;
|
|
569
|
+
const maxScrollTop = getMaxScrollTop(scroller);
|
|
570
|
+
let nextPositionerHeight = 0;
|
|
571
|
+
let nextScrollTop = null;
|
|
572
|
+
let setReachedMax = false;
|
|
573
|
+
let scrollToMax = false;
|
|
574
|
+
const setHeight = (height)=>{
|
|
575
|
+
positionerElement.style.height = `${height}px`;
|
|
576
|
+
};
|
|
577
|
+
const handleSmallDiff = (diff, targetScrollTop)=>{
|
|
578
|
+
const heightDelta = clamp(diff, 0, maxAvailableHeight - currentHeight);
|
|
579
|
+
if (heightDelta > 0) setHeight(currentHeight + heightDelta);
|
|
580
|
+
scroller.scrollTop = targetScrollTop;
|
|
581
|
+
if (maxAvailableHeight - (currentHeight + heightDelta) <= 1) reachedMaxHeightRef.current = true;
|
|
582
|
+
handleScrollArrowVisibility();
|
|
583
|
+
};
|
|
584
|
+
const diff = isTopPositioned ? maxScrollTop - scrollTop : scrollTop;
|
|
585
|
+
const nextHeight = Math.min(currentHeight + diff, maxAvailableHeight);
|
|
586
|
+
nextPositionerHeight = nextHeight;
|
|
587
|
+
if (diff <= 1) return void handleSmallDiff(diff, isTopPositioned ? maxScrollTop : 0);
|
|
588
|
+
if (maxAvailableHeight - nextHeight > 1) if (isTopPositioned) scrollToMax = true;
|
|
589
|
+
else nextScrollTop = 0;
|
|
590
|
+
else {
|
|
591
|
+
setReachedMax = true;
|
|
592
|
+
if (isBottomPositioned && scrollTop < maxScrollTop) {
|
|
593
|
+
const overshoot = currentHeight + diff - maxAvailableHeight;
|
|
594
|
+
nextScrollTop = scrollTop - (diff - overshoot);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
nextPositionerHeight = Math.ceil(nextPositionerHeight);
|
|
598
|
+
if (0 !== nextPositionerHeight) setHeight(nextPositionerHeight);
|
|
599
|
+
if (scrollToMax || null != nextScrollTop) {
|
|
600
|
+
const nextMaxScrollTop = getMaxScrollTop(scroller);
|
|
601
|
+
const target = scrollToMax ? nextMaxScrollTop : clamp(nextScrollTop, 0, nextMaxScrollTop);
|
|
602
|
+
if (Math.abs(scroller.scrollTop - target) > 1) scroller.scrollTop = target;
|
|
603
|
+
}
|
|
604
|
+
if (setReachedMax || nextPositionerHeight >= maxAvailableHeight - 1) reachedMaxHeightRef.current = true;
|
|
605
|
+
handleScrollArrowVisibility();
|
|
606
|
+
});
|
|
607
|
+
__rspack_external_react.useImperativeHandle(scrollHandlerRef, ()=>handleScroll, [
|
|
608
|
+
handleScroll
|
|
609
|
+
]);
|
|
610
|
+
useOpenChangeComplete({
|
|
611
|
+
open,
|
|
612
|
+
ref: popupRef,
|
|
613
|
+
onComplete () {
|
|
614
|
+
if (open) onOpenChangeComplete?.(true);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
const state = {
|
|
618
|
+
open,
|
|
619
|
+
transitionStatus,
|
|
620
|
+
side,
|
|
621
|
+
align
|
|
622
|
+
};
|
|
623
|
+
useIsoLayoutEffect(()=>{
|
|
624
|
+
if (!positionerElement || !popupRef.current || Object.keys(originalPositionerStylesRef.current).length) return;
|
|
625
|
+
originalPositionerStylesRef.current = {
|
|
626
|
+
top: positionerElement.style.top || '0',
|
|
627
|
+
left: positionerElement.style.left || '0',
|
|
628
|
+
right: positionerElement.style.right,
|
|
629
|
+
height: positionerElement.style.height,
|
|
630
|
+
bottom: positionerElement.style.bottom,
|
|
631
|
+
minHeight: positionerElement.style.minHeight,
|
|
632
|
+
maxHeight: positionerElement.style.maxHeight,
|
|
633
|
+
marginTop: positionerElement.style.marginTop,
|
|
634
|
+
marginBottom: positionerElement.style.marginBottom
|
|
635
|
+
};
|
|
636
|
+
}, [
|
|
637
|
+
popupRef,
|
|
638
|
+
positionerElement
|
|
639
|
+
]);
|
|
640
|
+
useIsoLayoutEffect(()=>{
|
|
641
|
+
if (open || alignItemWithTriggerActive) return;
|
|
642
|
+
initialPlacedRef.current = false;
|
|
643
|
+
reachedMaxHeightRef.current = false;
|
|
644
|
+
clearStyles(positionerElement, originalPositionerStylesRef.current);
|
|
645
|
+
}, [
|
|
646
|
+
open,
|
|
647
|
+
alignItemWithTriggerActive,
|
|
648
|
+
positionerElement,
|
|
649
|
+
popupRef
|
|
650
|
+
]);
|
|
651
|
+
useIsoLayoutEffect(()=>{
|
|
652
|
+
const popupElement = popupRef.current;
|
|
653
|
+
if (!open || !triggerElement || !positionerElement || !popupElement || alignItemWithTriggerActive && !isPositioned || 'ending' === store.state.transitionStatus) return;
|
|
654
|
+
if (!alignItemWithTriggerActive) {
|
|
655
|
+
initialPlacedRef.current = true;
|
|
656
|
+
scrollArrowFrame.request(handleScrollArrowVisibility);
|
|
657
|
+
popupElement.style.removeProperty('--transform-origin');
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
const restoreTransformStyles = unsetTransformStyles(popupElement);
|
|
661
|
+
popupElement.style.removeProperty('--transform-origin');
|
|
662
|
+
try {
|
|
663
|
+
let textElement = selectedItemTextRef.current;
|
|
664
|
+
if (!textElement?.isConnected) {
|
|
665
|
+
const hasSelectedValue = selectors.hasSelectedValue(store.state);
|
|
666
|
+
textElement = !hasSelectedValue && firstItemTextRef.current?.isConnected ? firstItemTextRef.current : null;
|
|
667
|
+
}
|
|
668
|
+
const valueElement = valueRef.current;
|
|
669
|
+
const positionerStyles = getComputedStyle(positionerElement);
|
|
670
|
+
const popupStyles = getComputedStyle(popupElement);
|
|
671
|
+
const doc = ownerDocument(triggerElement);
|
|
672
|
+
const win = getWindow(positionerElement);
|
|
673
|
+
const scale = getScale(triggerElement);
|
|
674
|
+
const triggerRect = normalizeRect(triggerElement.getBoundingClientRect(), scale);
|
|
675
|
+
const positionerRect = normalizeRect(positionerElement.getBoundingClientRect(), scale);
|
|
676
|
+
const triggerHeight = triggerRect.height;
|
|
677
|
+
const scroller = listElement || popupElement;
|
|
678
|
+
const scrollHeight = scroller.scrollHeight;
|
|
679
|
+
const borderBottom = parseFloat(popupStyles.borderBottomWidth);
|
|
680
|
+
const marginTop = parseFloat(positionerStyles.marginTop) || 10;
|
|
681
|
+
const marginBottom = parseFloat(positionerStyles.marginBottom) || 10;
|
|
682
|
+
const minHeight = parseFloat(positionerStyles.minHeight) || 100;
|
|
683
|
+
const maxPopupHeight = getMaxPopupHeight(popupStyles);
|
|
684
|
+
const paddingLeft = 5;
|
|
685
|
+
const paddingRight = 5;
|
|
686
|
+
const triggerCollisionThreshold = 20;
|
|
687
|
+
const viewportHeight = doc.documentElement.clientHeight - marginTop - marginBottom;
|
|
688
|
+
const viewportWidth = doc.documentElement.clientWidth;
|
|
689
|
+
const availableSpaceBeneathTrigger = viewportHeight - triggerRect.bottom + triggerHeight;
|
|
690
|
+
let textRect;
|
|
691
|
+
let alignedLeft = 'rtl' === direction ? triggerRect.right - positionerRect.width : triggerRect.left;
|
|
692
|
+
let offsetY = 0;
|
|
693
|
+
if (textElement && valueElement) {
|
|
694
|
+
const valueRect = normalizeRect(valueElement.getBoundingClientRect(), scale);
|
|
695
|
+
textRect = normalizeRect(textElement.getBoundingClientRect(), scale);
|
|
696
|
+
alignedLeft = positionerRect.left + ('rtl' === direction ? valueRect.right - textRect.right : valueRect.left - textRect.left);
|
|
697
|
+
const valueCenterFromTriggerTop = valueRect.top - triggerRect.top + valueRect.height / 2;
|
|
698
|
+
const textCenterFromPositionerTop = textRect.top - positionerRect.top + textRect.height / 2;
|
|
699
|
+
offsetY = textCenterFromPositionerTop - valueCenterFromTriggerTop;
|
|
700
|
+
}
|
|
701
|
+
const idealHeight = availableSpaceBeneathTrigger + offsetY + marginBottom + borderBottom;
|
|
702
|
+
let height = Math.min(viewportHeight, idealHeight);
|
|
703
|
+
const maxHeight = viewportHeight - marginTop - marginBottom;
|
|
704
|
+
const scrollTop = idealHeight - height;
|
|
705
|
+
const maxRight = viewportWidth - paddingRight;
|
|
706
|
+
positionerElement.style.left = `${clamp(alignedLeft, paddingLeft, maxRight - positionerRect.width)}px`;
|
|
707
|
+
positionerElement.style.height = `${height}px`;
|
|
708
|
+
positionerElement.style.maxHeight = 'auto';
|
|
709
|
+
positionerElement.style.marginTop = `${marginTop}px`;
|
|
710
|
+
positionerElement.style.marginBottom = `${marginBottom}px`;
|
|
711
|
+
popupElement.style.height = '100%';
|
|
712
|
+
const maxScrollTop = getMaxScrollTop(scroller);
|
|
713
|
+
const isTopPositioned = scrollTop >= maxScrollTop - 1;
|
|
714
|
+
if (isTopPositioned) height = Math.min(viewportHeight, positionerRect.height) - (scrollTop - maxScrollTop);
|
|
715
|
+
const fallbackToAlignPopupToTrigger = triggerRect.top < triggerCollisionThreshold || triggerRect.bottom > viewportHeight - triggerCollisionThreshold || Math.ceil(height) + 1 < Math.min(scrollHeight, minHeight);
|
|
716
|
+
const isPinchZoomed = (win.visualViewport?.scale ?? 1) !== 1 && isWebKit;
|
|
717
|
+
if (fallbackToAlignPopupToTrigger || isPinchZoomed) {
|
|
718
|
+
initialPlacedRef.current = true;
|
|
719
|
+
clearStyles(positionerElement, originalPositionerStylesRef.current);
|
|
720
|
+
setControlledAlignItemWithTrigger(false);
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
const initialHeight = Math.max(minHeight, height);
|
|
724
|
+
if (isTopPositioned) {
|
|
725
|
+
const topOffset = Math.max(0, viewportHeight - idealHeight);
|
|
726
|
+
positionerElement.style.top = positionerRect.height >= maxHeight ? '0' : `${topOffset}px`;
|
|
727
|
+
positionerElement.style.height = `${height}px`;
|
|
728
|
+
scroller.scrollTop = getMaxScrollTop(scroller);
|
|
729
|
+
} else {
|
|
730
|
+
positionerElement.style.bottom = '0';
|
|
731
|
+
scroller.scrollTop = scrollTop;
|
|
732
|
+
}
|
|
733
|
+
if (textRect) {
|
|
734
|
+
const popupTop = positionerRect.top;
|
|
735
|
+
const popupHeight = positionerRect.height;
|
|
736
|
+
const textCenterY = textRect.top + textRect.height / 2;
|
|
737
|
+
const transformOriginY = popupHeight > 0 ? (textCenterY - popupTop) / popupHeight * 100 : 50;
|
|
738
|
+
const clampedY = clamp(transformOriginY, 0, 100);
|
|
739
|
+
popupElement.style.setProperty('--transform-origin', `50% ${clampedY}%`);
|
|
740
|
+
}
|
|
741
|
+
if (initialHeight === viewportHeight || height >= maxPopupHeight) reachedMaxHeightRef.current = true;
|
|
742
|
+
handleScrollArrowVisibility();
|
|
743
|
+
if (highlightItemOnHover && null === store.state.selectedIndex && null === store.state.activeIndex && null != listRef.current[0]) store.set('activeIndex', 0);
|
|
744
|
+
initialPlacedRef.current = true;
|
|
745
|
+
} finally{
|
|
746
|
+
restoreTransformStyles();
|
|
747
|
+
}
|
|
748
|
+
}, [
|
|
749
|
+
store,
|
|
750
|
+
open,
|
|
751
|
+
positionerElement,
|
|
752
|
+
triggerElement,
|
|
753
|
+
valueRef,
|
|
754
|
+
firstItemTextRef,
|
|
755
|
+
selectedItemTextRef,
|
|
756
|
+
popupRef,
|
|
757
|
+
handleScrollArrowVisibility,
|
|
758
|
+
alignItemWithTriggerActive,
|
|
759
|
+
setControlledAlignItemWithTrigger,
|
|
760
|
+
scrollArrowFrame,
|
|
761
|
+
scrollDownArrowRef,
|
|
762
|
+
scrollUpArrowRef,
|
|
763
|
+
listElement,
|
|
764
|
+
listRef,
|
|
765
|
+
highlightItemOnHover,
|
|
766
|
+
direction,
|
|
767
|
+
isPositioned
|
|
768
|
+
]);
|
|
769
|
+
__rspack_external_react.useEffect(()=>{
|
|
770
|
+
if (!alignItemWithTriggerActive || !positionerElement || !open) return;
|
|
771
|
+
const win = getWindow(positionerElement);
|
|
772
|
+
function handleResize(event) {
|
|
773
|
+
setOpen(false, createChangeEventDetails(windowResize, event));
|
|
774
|
+
}
|
|
775
|
+
return addEventListener(win, 'resize', handleResize);
|
|
776
|
+
}, [
|
|
777
|
+
setOpen,
|
|
778
|
+
alignItemWithTriggerActive,
|
|
779
|
+
positionerElement,
|
|
780
|
+
open
|
|
781
|
+
]);
|
|
782
|
+
const defaultProps = {
|
|
783
|
+
...listElement ? {
|
|
784
|
+
role: 'presentation',
|
|
785
|
+
'aria-orientation': void 0
|
|
786
|
+
} : {
|
|
787
|
+
role: 'listbox',
|
|
788
|
+
'aria-multiselectable': multiple || void 0,
|
|
789
|
+
id: `${id}-list`
|
|
790
|
+
},
|
|
791
|
+
onKeyDown (event) {
|
|
792
|
+
keyboardActiveRef.current = true;
|
|
793
|
+
if (insideToolbar && COMPOSITE_KEYS.has(event.key)) event.stopPropagation();
|
|
794
|
+
},
|
|
795
|
+
onMouseMove () {
|
|
796
|
+
keyboardActiveRef.current = false;
|
|
797
|
+
},
|
|
798
|
+
onScroll (event) {
|
|
799
|
+
if (listElement) return;
|
|
800
|
+
handleScroll(event.currentTarget);
|
|
801
|
+
},
|
|
802
|
+
...alignItemWithTriggerActive && {
|
|
803
|
+
style: listElement ? {
|
|
804
|
+
height: '100%'
|
|
805
|
+
} : LIST_FUNCTIONAL_STYLES
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
const element = useRenderElement('div', componentProps, {
|
|
809
|
+
ref: [
|
|
810
|
+
forwardedRef,
|
|
811
|
+
popupRef
|
|
812
|
+
],
|
|
813
|
+
state,
|
|
814
|
+
stateAttributesMapping: SelectPopup_stateAttributesMapping,
|
|
815
|
+
props: [
|
|
816
|
+
popupProps,
|
|
817
|
+
defaultProps,
|
|
818
|
+
getDisabledMountTransitionStyles(transitionStatus),
|
|
819
|
+
{
|
|
820
|
+
className: !listElement && alignItemWithTriggerActive ? styleDisableScrollbar.className : void 0
|
|
821
|
+
},
|
|
822
|
+
elementProps
|
|
823
|
+
]
|
|
824
|
+
});
|
|
825
|
+
return /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
826
|
+
children: [
|
|
827
|
+
!disableStyleElements && styleDisableScrollbar.getElement(nonce),
|
|
828
|
+
/*#__PURE__*/ jsx(FloatingFocusManager, {
|
|
829
|
+
context: floatingRootContext,
|
|
830
|
+
modal: false,
|
|
831
|
+
disabled: !mounted,
|
|
832
|
+
returnFocus: finalFocus,
|
|
833
|
+
restoreFocus: true,
|
|
834
|
+
children: element
|
|
835
|
+
})
|
|
836
|
+
]
|
|
837
|
+
});
|
|
838
|
+
});
|
|
839
|
+
if ("production" !== process.env.NODE_ENV) SelectPopup_SelectPopup.displayName = "SelectPopup";
|
|
840
|
+
function getMaxPopupHeight(popupStyles) {
|
|
841
|
+
const maxHeightStyle = popupStyles.maxHeight || '';
|
|
842
|
+
return maxHeightStyle.endsWith('px') ? parseFloat(maxHeightStyle) || 1 / 0 : 1 / 0;
|
|
843
|
+
}
|
|
844
|
+
function getMaxScrollTop(scroller) {
|
|
845
|
+
return getMaxScrollOffset(scroller.scrollHeight, scroller.clientHeight);
|
|
846
|
+
}
|
|
847
|
+
function getScale(element) {
|
|
848
|
+
return floating_ui_dom_platform.getScale(element);
|
|
849
|
+
}
|
|
850
|
+
function normalizeSize(size, axis, scale) {
|
|
851
|
+
return size / scale[axis];
|
|
852
|
+
}
|
|
853
|
+
function normalizeRect(rect, scale) {
|
|
854
|
+
return rectToClientRect({
|
|
855
|
+
x: normalizeSize(rect.x, 'x', scale),
|
|
856
|
+
y: normalizeSize(rect.y, 'y', scale),
|
|
857
|
+
width: normalizeSize(rect.width, 'x', scale),
|
|
858
|
+
height: normalizeSize(rect.height, 'y', scale)
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
const TRANSFORM_STYLE_RESETS = [
|
|
862
|
+
[
|
|
863
|
+
'transform',
|
|
864
|
+
'none'
|
|
865
|
+
],
|
|
866
|
+
[
|
|
867
|
+
'scale',
|
|
868
|
+
'1'
|
|
869
|
+
],
|
|
870
|
+
[
|
|
871
|
+
'translate',
|
|
872
|
+
'0 0'
|
|
873
|
+
]
|
|
874
|
+
];
|
|
875
|
+
function unsetTransformStyles(popupElement) {
|
|
876
|
+
const { style } = popupElement;
|
|
877
|
+
const originalStyles = {};
|
|
878
|
+
for (const [property, value] of TRANSFORM_STYLE_RESETS){
|
|
879
|
+
originalStyles[property] = style.getPropertyValue(property);
|
|
880
|
+
style.setProperty(property, value, 'important');
|
|
881
|
+
}
|
|
882
|
+
return ()=>{
|
|
883
|
+
for (const [property] of TRANSFORM_STYLE_RESETS){
|
|
884
|
+
const originalValue = originalStyles[property];
|
|
885
|
+
if (originalValue) style.setProperty(property, originalValue);
|
|
886
|
+
else style.removeProperty(property);
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
const SelectList_SelectList = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
891
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
892
|
+
const { store, scrollHandlerRef } = useSelectRootContext();
|
|
893
|
+
const { alignItemWithTriggerActive } = useSelectPositionerContext();
|
|
894
|
+
const hasScrollArrows = useStore(store, selectors.hasScrollArrows);
|
|
895
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
896
|
+
const multiple = useStore(store, selectors.multiple);
|
|
897
|
+
const id = useStore(store, selectors.id);
|
|
898
|
+
const defaultProps = {
|
|
899
|
+
id: `${id}-list`,
|
|
900
|
+
role: 'listbox',
|
|
901
|
+
'aria-multiselectable': multiple || void 0,
|
|
902
|
+
onScroll (event) {
|
|
903
|
+
scrollHandlerRef.current?.(event.currentTarget);
|
|
904
|
+
},
|
|
905
|
+
...alignItemWithTriggerActive && {
|
|
906
|
+
style: LIST_FUNCTIONAL_STYLES
|
|
907
|
+
},
|
|
908
|
+
className: hasScrollArrows && 'touch' !== openMethod ? styleDisableScrollbar.className : void 0
|
|
909
|
+
};
|
|
910
|
+
const setListElement = useStableCallback((element)=>{
|
|
911
|
+
store.set('listElement', element);
|
|
912
|
+
});
|
|
913
|
+
return useRenderElement('div', componentProps, {
|
|
914
|
+
ref: [
|
|
915
|
+
forwardedRef,
|
|
916
|
+
setListElement
|
|
917
|
+
],
|
|
918
|
+
props: [
|
|
919
|
+
defaultProps,
|
|
920
|
+
elementProps
|
|
921
|
+
]
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
if ("production" !== process.env.NODE_ENV) SelectList_SelectList.displayName = "SelectList";
|
|
925
|
+
const SelectItemContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
926
|
+
if ("production" !== process.env.NODE_ENV) SelectItemContext.displayName = "SelectItemContext";
|
|
927
|
+
function useSelectItemContext() {
|
|
928
|
+
const context = __rspack_external_react.useContext(SelectItemContext);
|
|
929
|
+
if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SelectItemContext is missing. SelectItem parts must be placed within <Select.Item>.' : esm_formatErrorMessage(57));
|
|
930
|
+
return context;
|
|
931
|
+
}
|
|
932
|
+
const SelectItem_SelectItem = /*#__PURE__*/ __rspack_external_react.memo(/*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
933
|
+
const { render, className, style, value: itemValue = null, label, disabled = false, nativeButton = false, ...elementProps } = componentProps;
|
|
934
|
+
const textRef = __rspack_external_react.useRef(null);
|
|
935
|
+
const listItem = useCompositeListItem({
|
|
936
|
+
label,
|
|
937
|
+
textRef,
|
|
938
|
+
indexGuessBehavior: useCompositeListItem_IndexGuessBehavior.GuessFromOrder
|
|
939
|
+
});
|
|
940
|
+
const { store, itemProps, setOpen, setValue, selectionRef, typingRef, valuesRef, multiple, selectedItemTextRef } = useSelectRootContext();
|
|
941
|
+
const highlighted = useStore(store, selectors.isActive, listItem.index);
|
|
942
|
+
const selected = useStore(store, selectors.isSelected, listItem.index, itemValue);
|
|
943
|
+
const selectedByFocus = useStore(store, selectors.isSelectedByFocus, listItem.index);
|
|
944
|
+
const isItemEqualToValue = useStore(store, selectors.isItemEqualToValue);
|
|
945
|
+
const index = listItem.index;
|
|
946
|
+
const hasRegistered = -1 !== index;
|
|
947
|
+
const itemRef = __rspack_external_react.useRef(null);
|
|
948
|
+
useIsoLayoutEffect(()=>{
|
|
949
|
+
if (!hasRegistered) return;
|
|
950
|
+
const values = valuesRef.current;
|
|
951
|
+
values[index] = itemValue;
|
|
952
|
+
return ()=>{
|
|
953
|
+
delete values[index];
|
|
954
|
+
};
|
|
955
|
+
}, [
|
|
956
|
+
hasRegistered,
|
|
957
|
+
index,
|
|
958
|
+
itemValue,
|
|
959
|
+
valuesRef
|
|
960
|
+
]);
|
|
961
|
+
useIsoLayoutEffect(()=>{
|
|
962
|
+
if (!hasRegistered) return;
|
|
963
|
+
const selectedValue = store.state.value;
|
|
964
|
+
let selectedCandidate = selectedValue;
|
|
965
|
+
if (multiple && Array.isArray(selectedValue) && selectedValue.length > 0) selectedCandidate = selectedValue[selectedValue.length - 1];
|
|
966
|
+
if (void 0 !== selectedCandidate && compareItemEquality(itemValue, selectedCandidate, isItemEqualToValue)) {
|
|
967
|
+
store.set('selectedIndex', index);
|
|
968
|
+
if (textRef.current) selectedItemTextRef.current = textRef.current;
|
|
969
|
+
}
|
|
970
|
+
}, [
|
|
971
|
+
hasRegistered,
|
|
972
|
+
index,
|
|
973
|
+
multiple,
|
|
974
|
+
isItemEqualToValue,
|
|
975
|
+
store,
|
|
976
|
+
itemValue,
|
|
977
|
+
selectedItemTextRef
|
|
978
|
+
]);
|
|
979
|
+
const lastKeyRef = __rspack_external_react.useRef(null);
|
|
980
|
+
const pointerTypeRef = __rspack_external_react.useRef('mouse');
|
|
981
|
+
const allowMouseSelectionRef = __rspack_external_react.useRef(false);
|
|
982
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
983
|
+
disabled,
|
|
984
|
+
focusableWhenDisabled: true,
|
|
985
|
+
native: nativeButton,
|
|
986
|
+
composite: true
|
|
987
|
+
});
|
|
988
|
+
const state = {
|
|
989
|
+
disabled,
|
|
990
|
+
selected,
|
|
991
|
+
highlighted
|
|
992
|
+
};
|
|
993
|
+
function commitSelection(event) {
|
|
994
|
+
const selectedValue = store.state.value;
|
|
995
|
+
if (multiple) {
|
|
996
|
+
const currentValue = Array.isArray(selectedValue) ? selectedValue : [];
|
|
997
|
+
const nextValue = selected ? removeItem(currentValue, itemValue, isItemEqualToValue) : [
|
|
998
|
+
...currentValue,
|
|
999
|
+
itemValue
|
|
1000
|
+
];
|
|
1001
|
+
setValue(nextValue, createChangeEventDetails(itemPress, event));
|
|
1002
|
+
} else {
|
|
1003
|
+
setValue(itemValue, createChangeEventDetails(itemPress, event));
|
|
1004
|
+
setOpen(false, createChangeEventDetails(itemPress, event));
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
function resetDragMovement() {
|
|
1008
|
+
selectionRef.current.dragY = 0;
|
|
1009
|
+
}
|
|
1010
|
+
const defaultProps = {
|
|
1011
|
+
role: 'option',
|
|
1012
|
+
'aria-selected': selected,
|
|
1013
|
+
tabIndex: highlighted ? 0 : -1,
|
|
1014
|
+
onKeyDown (event) {
|
|
1015
|
+
lastKeyRef.current = event.key;
|
|
1016
|
+
store.set('activeIndex', index);
|
|
1017
|
+
if (' ' === event.key && typingRef.current) event.preventDefault();
|
|
1018
|
+
},
|
|
1019
|
+
onClick (event) {
|
|
1020
|
+
const isMouseClick = 'click' === event.type && 'touch' !== pointerTypeRef.current;
|
|
1021
|
+
const clickPointerType = event.nativeEvent.pointerType;
|
|
1022
|
+
const isVirtualMouseClick = isMouseClick && isVirtualClick(event.nativeEvent) && (void 0 !== clickPointerType || highlighted);
|
|
1023
|
+
const isInvalidMouseClick = isMouseClick && !isVirtualMouseClick && !allowMouseSelectionRef.current;
|
|
1024
|
+
allowMouseSelectionRef.current = false;
|
|
1025
|
+
if ('keydown' === event.type && null === lastKeyRef.current) return;
|
|
1026
|
+
if (disabled || 'keydown' === event.type && ' ' === lastKeyRef.current && typingRef.current || isInvalidMouseClick) return;
|
|
1027
|
+
lastKeyRef.current = null;
|
|
1028
|
+
commitSelection(event.nativeEvent);
|
|
1029
|
+
},
|
|
1030
|
+
onPointerEnter (event) {
|
|
1031
|
+
pointerTypeRef.current = event.pointerType;
|
|
1032
|
+
},
|
|
1033
|
+
onPointerMove (event) {
|
|
1034
|
+
if ('mouse' === event.pointerType && 1 === event.buttons) {
|
|
1035
|
+
const selection = selectionRef.current;
|
|
1036
|
+
selection.dragY += event.movementY;
|
|
1037
|
+
if (selection.dragY ** 2 >= 64) selection.allowUnselectedMouseUp = true;
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
onPointerDown (event) {
|
|
1041
|
+
pointerTypeRef.current = event.pointerType;
|
|
1042
|
+
allowMouseSelectionRef.current = true;
|
|
1043
|
+
resetDragMovement();
|
|
1044
|
+
},
|
|
1045
|
+
onMouseUp () {
|
|
1046
|
+
resetDragMovement();
|
|
1047
|
+
if (disabled || 'touch' === pointerTypeRef.current) return;
|
|
1048
|
+
if (allowMouseSelectionRef.current) return;
|
|
1049
|
+
const disallowSelectedMouseUp = !selectionRef.current.allowSelectedMouseUp && selected;
|
|
1050
|
+
const disallowUnselectedMouseUp = !selectionRef.current.allowUnselectedMouseUp && !selected;
|
|
1051
|
+
if (disallowSelectedMouseUp || disallowUnselectedMouseUp) return;
|
|
1052
|
+
allowMouseSelectionRef.current = true;
|
|
1053
|
+
itemRef.current?.click();
|
|
1054
|
+
allowMouseSelectionRef.current = false;
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
const element = useRenderElement('div', componentProps, {
|
|
1058
|
+
ref: [
|
|
1059
|
+
buttonRef,
|
|
1060
|
+
forwardedRef,
|
|
1061
|
+
listItem.ref,
|
|
1062
|
+
itemRef
|
|
1063
|
+
],
|
|
1064
|
+
state,
|
|
1065
|
+
props: [
|
|
1066
|
+
itemProps,
|
|
1067
|
+
defaultProps,
|
|
1068
|
+
elementProps,
|
|
1069
|
+
getButtonProps
|
|
1070
|
+
]
|
|
1071
|
+
});
|
|
1072
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
1073
|
+
selected,
|
|
1074
|
+
index,
|
|
1075
|
+
textRef,
|
|
1076
|
+
selectedByFocus,
|
|
1077
|
+
hasRegistered
|
|
1078
|
+
}), [
|
|
1079
|
+
selected,
|
|
1080
|
+
index,
|
|
1081
|
+
textRef,
|
|
1082
|
+
selectedByFocus,
|
|
1083
|
+
hasRegistered
|
|
1084
|
+
]);
|
|
1085
|
+
return /*#__PURE__*/ jsx(SelectItemContext.Provider, {
|
|
1086
|
+
value: contextValue,
|
|
1087
|
+
children: element
|
|
1088
|
+
});
|
|
1089
|
+
}));
|
|
1090
|
+
if ("production" !== process.env.NODE_ENV) SelectItem_SelectItem.displayName = "SelectItem";
|
|
1091
|
+
const SelectItemIndicator_SelectItemIndicator = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1092
|
+
const keepMounted = componentProps.keepMounted ?? false;
|
|
1093
|
+
const { selected } = useSelectItemContext();
|
|
1094
|
+
const shouldRender = keepMounted || selected;
|
|
1095
|
+
if (!shouldRender) return null;
|
|
1096
|
+
return /*#__PURE__*/ jsx(Inner, {
|
|
1097
|
+
...componentProps,
|
|
1098
|
+
ref: forwardedRef
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
1101
|
+
if ("production" !== process.env.NODE_ENV) SelectItemIndicator_SelectItemIndicator.displayName = "SelectItemIndicator";
|
|
1102
|
+
const Inner = /*#__PURE__*/ __rspack_external_react.memo(/*#__PURE__*/ __rspack_external_react.forwardRef((componentProps, forwardedRef)=>{
|
|
1103
|
+
const { render, className, style, keepMounted, ...elementProps } = componentProps;
|
|
1104
|
+
const { selected } = useSelectItemContext();
|
|
1105
|
+
const indicatorRef = __rspack_external_react.useRef(null);
|
|
1106
|
+
const { transitionStatus, setMounted } = useTransitionStatus(selected);
|
|
1107
|
+
const state = {
|
|
1108
|
+
selected,
|
|
1109
|
+
transitionStatus
|
|
1110
|
+
};
|
|
1111
|
+
const element = useRenderElement('span', componentProps, {
|
|
1112
|
+
ref: [
|
|
1113
|
+
forwardedRef,
|
|
1114
|
+
indicatorRef
|
|
1115
|
+
],
|
|
1116
|
+
state,
|
|
1117
|
+
props: [
|
|
1118
|
+
{
|
|
1119
|
+
'aria-hidden': true,
|
|
1120
|
+
children: '✔️'
|
|
1121
|
+
},
|
|
1122
|
+
elementProps
|
|
1123
|
+
],
|
|
1124
|
+
stateAttributesMapping: transitionStatusMapping
|
|
1125
|
+
});
|
|
1126
|
+
useOpenChangeComplete({
|
|
1127
|
+
open: selected,
|
|
1128
|
+
ref: indicatorRef,
|
|
1129
|
+
onComplete () {
|
|
1130
|
+
if (!selected) setMounted(false);
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
return element;
|
|
1134
|
+
}));
|
|
1135
|
+
if ("production" !== process.env.NODE_ENV) Inner.displayName = "Inner";
|
|
1136
|
+
const SelectItemText_SelectItemText = /*#__PURE__*/ __rspack_external_react.memo(/*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1137
|
+
const { index, textRef, selectedByFocus, hasRegistered } = useSelectItemContext();
|
|
1138
|
+
const { firstItemTextRef, selectedItemTextRef } = useSelectRootContext();
|
|
1139
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
1140
|
+
const localRef = __rspack_external_react.useCallback((node)=>{
|
|
1141
|
+
if (!node) return;
|
|
1142
|
+
if (hasRegistered && 0 === index) firstItemTextRef.current = node;
|
|
1143
|
+
if (hasRegistered && selectedByFocus) selectedItemTextRef.current = node;
|
|
1144
|
+
}, [
|
|
1145
|
+
firstItemTextRef,
|
|
1146
|
+
selectedItemTextRef,
|
|
1147
|
+
index,
|
|
1148
|
+
selectedByFocus,
|
|
1149
|
+
hasRegistered
|
|
1150
|
+
]);
|
|
1151
|
+
const element = useRenderElement('div', componentProps, {
|
|
1152
|
+
ref: [
|
|
1153
|
+
localRef,
|
|
1154
|
+
forwardedRef,
|
|
1155
|
+
textRef
|
|
1156
|
+
],
|
|
1157
|
+
props: elementProps
|
|
1158
|
+
});
|
|
1159
|
+
return element;
|
|
1160
|
+
}));
|
|
1161
|
+
if ("production" !== process.env.NODE_ENV) SelectItemText_SelectItemText.displayName = "SelectItemText";
|
|
1162
|
+
const SelectArrow_stateAttributesMapping = {
|
|
1163
|
+
...popupStateMapping,
|
|
1164
|
+
...transitionStatusMapping
|
|
1165
|
+
};
|
|
1166
|
+
const SelectArrow_SelectArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1167
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
1168
|
+
const { store } = useSelectRootContext();
|
|
1169
|
+
const { side, align, arrowRef, arrowStyles, arrowUncentered, alignItemWithTriggerActive } = useSelectPositionerContext();
|
|
1170
|
+
const open = useStore(store, selectors.open, true);
|
|
1171
|
+
const state = {
|
|
1172
|
+
open,
|
|
1173
|
+
side,
|
|
1174
|
+
align,
|
|
1175
|
+
uncentered: arrowUncentered
|
|
1176
|
+
};
|
|
1177
|
+
const element = useRenderElement('div', componentProps, {
|
|
1178
|
+
state,
|
|
1179
|
+
ref: [
|
|
1180
|
+
arrowRef,
|
|
1181
|
+
forwardedRef
|
|
1182
|
+
],
|
|
1183
|
+
props: [
|
|
1184
|
+
{
|
|
1185
|
+
style: arrowStyles,
|
|
1186
|
+
'aria-hidden': true
|
|
1187
|
+
},
|
|
1188
|
+
elementProps
|
|
1189
|
+
],
|
|
1190
|
+
stateAttributesMapping: SelectArrow_stateAttributesMapping
|
|
1191
|
+
});
|
|
1192
|
+
if (alignItemWithTriggerActive) return null;
|
|
1193
|
+
return element;
|
|
1194
|
+
});
|
|
1195
|
+
if ("production" !== process.env.NODE_ENV) SelectArrow_SelectArrow.displayName = "SelectArrow";
|
|
1196
|
+
const SelectScrollArrow_SelectScrollArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1197
|
+
const { render, className, style, direction, keepMounted = false, ...elementProps } = componentProps;
|
|
1198
|
+
const isUp = 'up' === direction;
|
|
1199
|
+
const { store, popupRef, listRef, handleScrollArrowVisibility, scrollArrowsMountedCountRef } = useSelectRootContext();
|
|
1200
|
+
const { side, scrollDownArrowRef, scrollUpArrowRef } = useSelectPositionerContext();
|
|
1201
|
+
const visibleSelector = isUp ? selectors.scrollUpArrowVisible : selectors.scrollDownArrowVisible;
|
|
1202
|
+
const stateVisible = useStore(store, visibleSelector);
|
|
1203
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
1204
|
+
const visible = stateVisible && 'touch' !== openMethod;
|
|
1205
|
+
const timeout = useTimeout();
|
|
1206
|
+
const scrollArrowRef = isUp ? scrollUpArrowRef : scrollDownArrowRef;
|
|
1207
|
+
const { transitionStatus, setMounted } = useTransitionStatus(visible);
|
|
1208
|
+
useIsoLayoutEffect(()=>{
|
|
1209
|
+
scrollArrowsMountedCountRef.current += 1;
|
|
1210
|
+
if (!store.state.hasScrollArrows) store.set('hasScrollArrows', true);
|
|
1211
|
+
return ()=>{
|
|
1212
|
+
scrollArrowsMountedCountRef.current = Math.max(0, scrollArrowsMountedCountRef.current - 1);
|
|
1213
|
+
if (0 === scrollArrowsMountedCountRef.current && store.state.hasScrollArrows) store.set('hasScrollArrows', false);
|
|
1214
|
+
};
|
|
1215
|
+
}, [
|
|
1216
|
+
store,
|
|
1217
|
+
scrollArrowsMountedCountRef
|
|
1218
|
+
]);
|
|
1219
|
+
useOpenChangeComplete({
|
|
1220
|
+
open: visible,
|
|
1221
|
+
ref: scrollArrowRef,
|
|
1222
|
+
onComplete () {
|
|
1223
|
+
if (!visible) setMounted(false);
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
const state = {
|
|
1227
|
+
direction,
|
|
1228
|
+
visible,
|
|
1229
|
+
side,
|
|
1230
|
+
transitionStatus
|
|
1231
|
+
};
|
|
1232
|
+
const defaultProps = {
|
|
1233
|
+
'aria-hidden': true,
|
|
1234
|
+
children: isUp ? '▲' : '▼',
|
|
1235
|
+
style: {
|
|
1236
|
+
position: 'absolute'
|
|
1237
|
+
},
|
|
1238
|
+
onMouseMove (event) {
|
|
1239
|
+
if (0 === event.movementX && 0 === event.movementY || timeout.isStarted()) return;
|
|
1240
|
+
store.set('activeIndex', null);
|
|
1241
|
+
function scrollNextItem() {
|
|
1242
|
+
const scroller = store.state.listElement ?? popupRef.current;
|
|
1243
|
+
if (!scroller) return;
|
|
1244
|
+
store.set('activeIndex', null);
|
|
1245
|
+
handleScrollArrowVisibility();
|
|
1246
|
+
const maxScrollTop = getMaxScrollOffset(scroller.scrollHeight, scroller.clientHeight);
|
|
1247
|
+
const scrollTop = normalizeScrollOffset(scroller.scrollTop, maxScrollTop);
|
|
1248
|
+
const isScrolledToEdge = scrollTop === (isUp ? 0 : maxScrollTop);
|
|
1249
|
+
const items = listRef.current;
|
|
1250
|
+
if (scrollTop !== scroller.scrollTop) scroller.scrollTop = scrollTop;
|
|
1251
|
+
if (0 === items.length) store.set(isUp ? 'scrollUpArrowVisible' : 'scrollDownArrowVisible', !isScrolledToEdge);
|
|
1252
|
+
if (isScrolledToEdge) return void timeout.clear();
|
|
1253
|
+
if (items.length > 0) {
|
|
1254
|
+
const scrollArrowHeight = scrollArrowRef.current?.offsetHeight || 0;
|
|
1255
|
+
scroller.scrollTop = getTargetScrollTop(items, isUp, scrollTop, scroller.clientHeight, scrollArrowHeight, maxScrollTop);
|
|
1256
|
+
}
|
|
1257
|
+
timeout.start(40, scrollNextItem);
|
|
1258
|
+
}
|
|
1259
|
+
timeout.start(40, scrollNextItem);
|
|
1260
|
+
},
|
|
1261
|
+
onMouseLeave () {
|
|
1262
|
+
timeout.clear();
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
const element = useRenderElement('div', componentProps, {
|
|
1266
|
+
ref: [
|
|
1267
|
+
forwardedRef,
|
|
1268
|
+
scrollArrowRef
|
|
1269
|
+
],
|
|
1270
|
+
state,
|
|
1271
|
+
props: [
|
|
1272
|
+
defaultProps,
|
|
1273
|
+
elementProps
|
|
1274
|
+
]
|
|
1275
|
+
});
|
|
1276
|
+
const shouldRender = visible || keepMounted;
|
|
1277
|
+
if (!shouldRender) return null;
|
|
1278
|
+
return element;
|
|
1279
|
+
});
|
|
1280
|
+
if ("production" !== process.env.NODE_ENV) SelectScrollArrow_SelectScrollArrow.displayName = "SelectScrollArrow";
|
|
1281
|
+
function getTargetScrollTop(items, isUp, scrollTop, clientHeight, scrollArrowHeight, maxScrollTop) {
|
|
1282
|
+
if (isUp) {
|
|
1283
|
+
let firstVisibleIndex = 0;
|
|
1284
|
+
const visibleTop = scrollTop + scrollArrowHeight - 1;
|
|
1285
|
+
for(let i = 0; i < items.length; i += 1){
|
|
1286
|
+
const item = items[i];
|
|
1287
|
+
if (item && item.offsetTop >= visibleTop) {
|
|
1288
|
+
firstVisibleIndex = i;
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
const targetIndex = Math.max(0, firstVisibleIndex - 1);
|
|
1293
|
+
const targetItem = items[targetIndex];
|
|
1294
|
+
return targetIndex < firstVisibleIndex && targetItem ? normalizeScrollOffset(targetItem.offsetTop - scrollArrowHeight, maxScrollTop) : 0;
|
|
1295
|
+
}
|
|
1296
|
+
let lastVisibleIndex = items.length - 1;
|
|
1297
|
+
const visibleBottom = scrollTop + clientHeight - scrollArrowHeight + 1;
|
|
1298
|
+
for(let i = 0; i < items.length; i += 1){
|
|
1299
|
+
const item = items[i];
|
|
1300
|
+
if (item && item.offsetTop + item.offsetHeight > visibleBottom) {
|
|
1301
|
+
lastVisibleIndex = Math.max(0, i - 1);
|
|
1302
|
+
break;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
const targetIndex = Math.min(items.length - 1, lastVisibleIndex + 1);
|
|
1306
|
+
const targetItem = items[targetIndex];
|
|
1307
|
+
return targetIndex > lastVisibleIndex && targetItem ? normalizeScrollOffset(targetItem.offsetTop + targetItem.offsetHeight - clientHeight + scrollArrowHeight, maxScrollTop) : maxScrollTop;
|
|
1308
|
+
}
|
|
1309
|
+
const SelectScrollDownArrow_SelectScrollDownArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(function(props, forwardedRef) {
|
|
1310
|
+
return /*#__PURE__*/ jsx(SelectScrollArrow_SelectScrollArrow, {
|
|
1311
|
+
...props,
|
|
1312
|
+
ref: forwardedRef,
|
|
1313
|
+
direction: "down"
|
|
1314
|
+
});
|
|
1315
|
+
});
|
|
1316
|
+
if ("production" !== process.env.NODE_ENV) SelectScrollDownArrow_SelectScrollDownArrow.displayName = "SelectScrollDownArrow";
|
|
1317
|
+
const SelectScrollUpArrow_SelectScrollUpArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(function(props, forwardedRef) {
|
|
1318
|
+
return /*#__PURE__*/ jsx(SelectScrollArrow_SelectScrollArrow, {
|
|
1319
|
+
...props,
|
|
1320
|
+
ref: forwardedRef,
|
|
1321
|
+
direction: "up"
|
|
1322
|
+
});
|
|
1323
|
+
});
|
|
1324
|
+
if ("production" !== process.env.NODE_ENV) SelectScrollUpArrow_SelectScrollUpArrow.displayName = "SelectScrollUpArrow";
|
|
1325
|
+
const SelectGroupContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
1326
|
+
if ("production" !== process.env.NODE_ENV) SelectGroupContext.displayName = "SelectGroupContext";
|
|
1327
|
+
function useSelectGroupContext() {
|
|
1328
|
+
const context = __rspack_external_react.useContext(SelectGroupContext);
|
|
1329
|
+
if (void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SelectGroupContext is missing. SelectGroup parts must be placed within <Select.Group>.' : esm_formatErrorMessage(56));
|
|
1330
|
+
return context;
|
|
1331
|
+
}
|
|
1332
|
+
const SelectGroup_SelectGroup = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1333
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
1334
|
+
const [labelId, setLabelId] = __rspack_external_react.useState();
|
|
1335
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
1336
|
+
labelId,
|
|
1337
|
+
setLabelId
|
|
1338
|
+
}), [
|
|
1339
|
+
labelId,
|
|
1340
|
+
setLabelId
|
|
1341
|
+
]);
|
|
1342
|
+
const element = useRenderElement('div', componentProps, {
|
|
1343
|
+
ref: forwardedRef,
|
|
1344
|
+
props: [
|
|
1345
|
+
{
|
|
1346
|
+
role: 'group',
|
|
1347
|
+
'aria-labelledby': labelId
|
|
1348
|
+
},
|
|
1349
|
+
elementProps
|
|
1350
|
+
]
|
|
1351
|
+
});
|
|
1352
|
+
return /*#__PURE__*/ jsx(SelectGroupContext.Provider, {
|
|
1353
|
+
value: contextValue,
|
|
1354
|
+
children: element
|
|
1355
|
+
});
|
|
1356
|
+
});
|
|
1357
|
+
if ("production" !== process.env.NODE_ENV) SelectGroup_SelectGroup.displayName = "SelectGroup";
|
|
1358
|
+
const SelectGroupLabel_SelectGroupLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
1359
|
+
const { render, className, style, id: idProp, ...elementProps } = componentProps;
|
|
1360
|
+
const { setLabelId } = useSelectGroupContext();
|
|
1361
|
+
const id = useBaseUiId(idProp);
|
|
1362
|
+
useIsoLayoutEffect(()=>{
|
|
1363
|
+
setLabelId(id);
|
|
1364
|
+
}, [
|
|
1365
|
+
id,
|
|
1366
|
+
setLabelId
|
|
1367
|
+
]);
|
|
1368
|
+
const element = useRenderElement('div', componentProps, {
|
|
1369
|
+
ref: forwardedRef,
|
|
1370
|
+
props: [
|
|
1371
|
+
{
|
|
1372
|
+
id
|
|
1373
|
+
},
|
|
1374
|
+
elementProps
|
|
1375
|
+
]
|
|
1376
|
+
});
|
|
1377
|
+
return element;
|
|
1378
|
+
});
|
|
1379
|
+
if ("production" !== process.env.NODE_ENV) SelectGroupLabel_SelectGroupLabel.displayName = "SelectGroupLabel";
|
|
1380
|
+
function SelectRoot(props) {
|
|
1381
|
+
const { id, value: valueProp, defaultValue = null, onValueChange, open: openProp, defaultOpen = false, onOpenChange, name: nameProp, form, autoComplete, disabled: disabledProp = false, readOnly = false, required = false, modal = true, actionsRef, inputRef, onOpenChangeComplete, items, multiple = false, itemToStringLabel, itemToStringValue, isItemEqualToValue = defaultItemEquality, highlightItemOnHover = true, children } = props;
|
|
1382
|
+
const { clearErrors } = useFormContext();
|
|
1383
|
+
const { setDirty, setTouched, setFocused, shouldValidateOnChange, validityData, setFilled, name: fieldName, disabled: fieldDisabled, validation, validationMode } = useFieldRootContext();
|
|
1384
|
+
const generatedId = useLabelableId({
|
|
1385
|
+
id
|
|
1386
|
+
});
|
|
1387
|
+
const disabled = fieldDisabled || disabledProp;
|
|
1388
|
+
const name = fieldName ?? nameProp;
|
|
1389
|
+
const [value, setValueUnwrapped] = useControlled({
|
|
1390
|
+
controlled: valueProp,
|
|
1391
|
+
default: multiple ? defaultValue ?? EMPTY_ARRAY : defaultValue,
|
|
1392
|
+
name: 'Select',
|
|
1393
|
+
state: 'value'
|
|
1394
|
+
});
|
|
1395
|
+
const [open, setOpenUnwrapped] = useControlled({
|
|
1396
|
+
controlled: openProp,
|
|
1397
|
+
default: defaultOpen,
|
|
1398
|
+
name: 'Select',
|
|
1399
|
+
state: 'open'
|
|
1400
|
+
});
|
|
1401
|
+
const listRef = __rspack_external_react.useRef([]);
|
|
1402
|
+
const labelsRef = __rspack_external_react.useRef([]);
|
|
1403
|
+
const popupRef = __rspack_external_react.useRef(null);
|
|
1404
|
+
const scrollHandlerRef = __rspack_external_react.useRef(null);
|
|
1405
|
+
const scrollArrowsMountedCountRef = __rspack_external_react.useRef(0);
|
|
1406
|
+
const valueRef = __rspack_external_react.useRef(null);
|
|
1407
|
+
const valuesRef = __rspack_external_react.useRef([]);
|
|
1408
|
+
const typingRef = __rspack_external_react.useRef(false);
|
|
1409
|
+
const keyboardActiveRef = __rspack_external_react.useRef(false);
|
|
1410
|
+
const firstItemTextRef = __rspack_external_react.useRef(null);
|
|
1411
|
+
const selectedItemTextRef = __rspack_external_react.useRef(null);
|
|
1412
|
+
const selectionRef = __rspack_external_react.useRef({
|
|
1413
|
+
allowSelectedMouseUp: false,
|
|
1414
|
+
allowUnselectedMouseUp: false,
|
|
1415
|
+
dragY: 0
|
|
1416
|
+
});
|
|
1417
|
+
const alignItemWithTriggerActiveRef = __rspack_external_react.useRef(false);
|
|
1418
|
+
const { mounted, setMounted, transitionStatus } = useTransitionStatus(open);
|
|
1419
|
+
const { openMethod, triggerProps: interactionTypeProps } = useOpenInteractionType(open);
|
|
1420
|
+
const store = useRefWithInit(()=>new Store({
|
|
1421
|
+
id: generatedId,
|
|
1422
|
+
labelId: void 0,
|
|
1423
|
+
modal,
|
|
1424
|
+
multiple,
|
|
1425
|
+
itemToStringLabel,
|
|
1426
|
+
itemToStringValue,
|
|
1427
|
+
isItemEqualToValue,
|
|
1428
|
+
value,
|
|
1429
|
+
open,
|
|
1430
|
+
mounted,
|
|
1431
|
+
transitionStatus,
|
|
1432
|
+
items,
|
|
1433
|
+
forceMount: false,
|
|
1434
|
+
openMethod: null,
|
|
1435
|
+
activeIndex: null,
|
|
1436
|
+
selectedIndex: null,
|
|
1437
|
+
popupProps: {},
|
|
1438
|
+
triggerProps: {},
|
|
1439
|
+
triggerElement: null,
|
|
1440
|
+
positionerElement: null,
|
|
1441
|
+
listElement: null,
|
|
1442
|
+
popupSide: null,
|
|
1443
|
+
scrollUpArrowVisible: false,
|
|
1444
|
+
scrollDownArrowVisible: false,
|
|
1445
|
+
hasScrollArrows: false
|
|
1446
|
+
})).current;
|
|
1447
|
+
const activeIndex = useStore(store, selectors.activeIndex);
|
|
1448
|
+
const selectedIndex = useStore(store, selectors.selectedIndex);
|
|
1449
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
1450
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
1451
|
+
const previousOpenMethod = usePreviousValue(openMethod);
|
|
1452
|
+
const renderedOpenMethod = openMethod ?? previousOpenMethod;
|
|
1453
|
+
const serializedValue = __rspack_external_react.useMemo(()=>{
|
|
1454
|
+
if (multiple && Array.isArray(value) && 0 === value.length) return '';
|
|
1455
|
+
return stringifyAsValue(value, itemToStringValue);
|
|
1456
|
+
}, [
|
|
1457
|
+
multiple,
|
|
1458
|
+
value,
|
|
1459
|
+
itemToStringValue
|
|
1460
|
+
]);
|
|
1461
|
+
const fieldStringValue = __rspack_external_react.useMemo(()=>{
|
|
1462
|
+
if (multiple && Array.isArray(value)) return value.map((currentValue)=>stringifyAsValue(currentValue, itemToStringValue));
|
|
1463
|
+
return stringifyAsValue(value, itemToStringValue);
|
|
1464
|
+
}, [
|
|
1465
|
+
multiple,
|
|
1466
|
+
value,
|
|
1467
|
+
itemToStringValue
|
|
1468
|
+
]);
|
|
1469
|
+
const controlRef = useValueAsRef(store.state.triggerElement);
|
|
1470
|
+
const getStringifiedValueForForm = useStableCallback(()=>fieldStringValue);
|
|
1471
|
+
useRegisterFieldControl(controlRef, generatedId, value, getStringifiedValueForForm);
|
|
1472
|
+
const initialValueRef = __rspack_external_react.useRef(value);
|
|
1473
|
+
const hasSelectedValue = multiple ? Array.isArray(value) && value.length > 0 : null != value;
|
|
1474
|
+
useIsoLayoutEffect(()=>{
|
|
1475
|
+
if (value !== initialValueRef.current) store.set('forceMount', true);
|
|
1476
|
+
}, [
|
|
1477
|
+
store,
|
|
1478
|
+
value
|
|
1479
|
+
]);
|
|
1480
|
+
useIsoLayoutEffect(()=>{
|
|
1481
|
+
setFilled(hasSelectedValue);
|
|
1482
|
+
}, [
|
|
1483
|
+
hasSelectedValue,
|
|
1484
|
+
setFilled
|
|
1485
|
+
]);
|
|
1486
|
+
useIsoLayoutEffect(function() {
|
|
1487
|
+
const registry = valuesRef.current;
|
|
1488
|
+
let nextIndex;
|
|
1489
|
+
if (multiple) {
|
|
1490
|
+
const currentValue = Array.isArray(value) ? value : [];
|
|
1491
|
+
if (0 === currentValue.length) nextIndex = null;
|
|
1492
|
+
else {
|
|
1493
|
+
const lastValue = currentValue[currentValue.length - 1];
|
|
1494
|
+
const lastIndex = findItemIndex(registry, lastValue, isItemEqualToValue);
|
|
1495
|
+
nextIndex = -1 === lastIndex ? null : lastIndex;
|
|
1496
|
+
}
|
|
1497
|
+
} else {
|
|
1498
|
+
const index = findItemIndex(registry, value, isItemEqualToValue);
|
|
1499
|
+
nextIndex = -1 === index ? null : index;
|
|
1500
|
+
}
|
|
1501
|
+
if (null === nextIndex) selectedItemTextRef.current = null;
|
|
1502
|
+
if (open) return;
|
|
1503
|
+
store.set('selectedIndex', nextIndex);
|
|
1504
|
+
}, [
|
|
1505
|
+
hasSelectedValue,
|
|
1506
|
+
multiple,
|
|
1507
|
+
open,
|
|
1508
|
+
value,
|
|
1509
|
+
valuesRef,
|
|
1510
|
+
isItemEqualToValue,
|
|
1511
|
+
store,
|
|
1512
|
+
selectedItemTextRef
|
|
1513
|
+
]);
|
|
1514
|
+
useValueChanged(value, ()=>{
|
|
1515
|
+
clearErrors(name);
|
|
1516
|
+
setDirty(value !== validityData.initialValue);
|
|
1517
|
+
if (shouldValidateOnChange()) validation.commit(value);
|
|
1518
|
+
else validation.commit(value, true);
|
|
1519
|
+
});
|
|
1520
|
+
const setOpen = useStableCallback((nextOpen, eventDetails)=>{
|
|
1521
|
+
onOpenChange?.(nextOpen, eventDetails);
|
|
1522
|
+
if (eventDetails.isCanceled) return;
|
|
1523
|
+
setOpenUnwrapped(nextOpen);
|
|
1524
|
+
if (!nextOpen && (eventDetails.reason === focusOut || eventDetails.reason === outsidePress)) {
|
|
1525
|
+
setTouched(true);
|
|
1526
|
+
setFocused(false);
|
|
1527
|
+
if ('onBlur' === validationMode) validation.commit(value);
|
|
1528
|
+
}
|
|
1529
|
+
if (!nextOpen && null !== store.state.activeIndex) {
|
|
1530
|
+
const activeOption = listRef.current[store.state.activeIndex];
|
|
1531
|
+
queueMicrotask(()=>{
|
|
1532
|
+
activeOption?.setAttribute('tabindex', '-1');
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
const handleUnmount = useStableCallback(()=>{
|
|
1537
|
+
setMounted(false);
|
|
1538
|
+
store.update({
|
|
1539
|
+
activeIndex: null,
|
|
1540
|
+
openMethod: null
|
|
1541
|
+
});
|
|
1542
|
+
onOpenChangeComplete?.(false);
|
|
1543
|
+
});
|
|
1544
|
+
useOpenChangeComplete({
|
|
1545
|
+
enabled: !actionsRef,
|
|
1546
|
+
open,
|
|
1547
|
+
ref: popupRef,
|
|
1548
|
+
onComplete () {
|
|
1549
|
+
if (!open) handleUnmount();
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
__rspack_external_react.useImperativeHandle(actionsRef, ()=>({
|
|
1553
|
+
unmount: handleUnmount
|
|
1554
|
+
}), [
|
|
1555
|
+
handleUnmount
|
|
1556
|
+
]);
|
|
1557
|
+
const setValue = useStableCallback((nextValue, eventDetails)=>{
|
|
1558
|
+
onValueChange?.(nextValue, eventDetails);
|
|
1559
|
+
if (eventDetails.isCanceled) return;
|
|
1560
|
+
setValueUnwrapped(nextValue);
|
|
1561
|
+
});
|
|
1562
|
+
const handleScrollArrowVisibility = useStableCallback(()=>{
|
|
1563
|
+
const scroller = store.state.listElement || popupRef.current;
|
|
1564
|
+
if (!scroller) return;
|
|
1565
|
+
const maxScrollTop = getMaxScrollOffset(scroller.scrollHeight, scroller.clientHeight);
|
|
1566
|
+
const scrollTop = normalizeScrollOffset(scroller.scrollTop, maxScrollTop);
|
|
1567
|
+
const shouldShowUp = scrollTop > 0;
|
|
1568
|
+
const shouldShowDown = scrollTop < maxScrollTop;
|
|
1569
|
+
if (store.state.scrollUpArrowVisible !== shouldShowUp) store.set('scrollUpArrowVisible', shouldShowUp);
|
|
1570
|
+
if (store.state.scrollDownArrowVisible !== shouldShowDown) store.set('scrollDownArrowVisible', shouldShowDown);
|
|
1571
|
+
});
|
|
1572
|
+
const floatingContext = useFloatingRootContext({
|
|
1573
|
+
open,
|
|
1574
|
+
onOpenChange: setOpen,
|
|
1575
|
+
elements: {
|
|
1576
|
+
reference: triggerElement,
|
|
1577
|
+
floating: positionerElement
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
const click = useClick(floatingContext, {
|
|
1581
|
+
enabled: !readOnly && !disabled,
|
|
1582
|
+
event: 'mousedown'
|
|
1583
|
+
});
|
|
1584
|
+
const dismiss = useDismiss(floatingContext);
|
|
1585
|
+
const listNavigation = useListNavigation(floatingContext, {
|
|
1586
|
+
enabled: !readOnly && !disabled,
|
|
1587
|
+
listRef,
|
|
1588
|
+
activeIndex,
|
|
1589
|
+
selectedIndex,
|
|
1590
|
+
disabledIndices: EMPTY_ARRAY,
|
|
1591
|
+
onNavigate (nextActiveIndex) {
|
|
1592
|
+
if (null === nextActiveIndex && !open) return;
|
|
1593
|
+
store.set('activeIndex', nextActiveIndex);
|
|
1594
|
+
},
|
|
1595
|
+
focusItemOnHover: highlightItemOnHover
|
|
1596
|
+
});
|
|
1597
|
+
const typeahead = useTypeahead(floatingContext, {
|
|
1598
|
+
enabled: !readOnly && !disabled && (open || !multiple),
|
|
1599
|
+
listRef: labelsRef,
|
|
1600
|
+
activeIndex,
|
|
1601
|
+
selectedIndex,
|
|
1602
|
+
onMatch (index) {
|
|
1603
|
+
if (open) store.set('activeIndex', index);
|
|
1604
|
+
else setValue(valuesRef.current[index], createChangeEventDetails('none'));
|
|
1605
|
+
},
|
|
1606
|
+
onTyping (typing) {
|
|
1607
|
+
typingRef.current = typing;
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
const mergedTriggerProps = __rspack_external_react.useMemo(()=>{
|
|
1611
|
+
const triggerInteractionProps = mergeProps(typeahead.reference, listNavigation.reference, dismiss.reference, click.reference, interactionTypeProps);
|
|
1612
|
+
if (generatedId) triggerInteractionProps.id = generatedId;
|
|
1613
|
+
return triggerInteractionProps;
|
|
1614
|
+
}, [
|
|
1615
|
+
click.reference,
|
|
1616
|
+
typeahead.reference,
|
|
1617
|
+
listNavigation.reference,
|
|
1618
|
+
dismiss.reference,
|
|
1619
|
+
interactionTypeProps,
|
|
1620
|
+
generatedId
|
|
1621
|
+
]);
|
|
1622
|
+
const popupProps = __rspack_external_react.useMemo(()=>mergeProps(FOCUSABLE_POPUP_PROPS, typeahead.floating, listNavigation.floating, dismiss.floating), [
|
|
1623
|
+
typeahead.floating,
|
|
1624
|
+
listNavigation.floating,
|
|
1625
|
+
dismiss.floating
|
|
1626
|
+
]);
|
|
1627
|
+
const itemProps = listNavigation.item ?? EMPTY_OBJECT;
|
|
1628
|
+
useOnFirstRender(()=>{
|
|
1629
|
+
store.update({
|
|
1630
|
+
popupProps,
|
|
1631
|
+
triggerProps: mergedTriggerProps
|
|
1632
|
+
});
|
|
1633
|
+
});
|
|
1634
|
+
useIsoLayoutEffect(()=>{
|
|
1635
|
+
store.update({
|
|
1636
|
+
id: generatedId,
|
|
1637
|
+
modal,
|
|
1638
|
+
multiple,
|
|
1639
|
+
value,
|
|
1640
|
+
open,
|
|
1641
|
+
mounted,
|
|
1642
|
+
transitionStatus,
|
|
1643
|
+
popupProps,
|
|
1644
|
+
triggerProps: mergedTriggerProps,
|
|
1645
|
+
items,
|
|
1646
|
+
itemToStringLabel,
|
|
1647
|
+
itemToStringValue,
|
|
1648
|
+
isItemEqualToValue,
|
|
1649
|
+
openMethod: renderedOpenMethod
|
|
1650
|
+
});
|
|
1651
|
+
}, [
|
|
1652
|
+
store,
|
|
1653
|
+
generatedId,
|
|
1654
|
+
modal,
|
|
1655
|
+
multiple,
|
|
1656
|
+
value,
|
|
1657
|
+
open,
|
|
1658
|
+
mounted,
|
|
1659
|
+
transitionStatus,
|
|
1660
|
+
popupProps,
|
|
1661
|
+
mergedTriggerProps,
|
|
1662
|
+
items,
|
|
1663
|
+
itemToStringLabel,
|
|
1664
|
+
itemToStringValue,
|
|
1665
|
+
isItemEqualToValue,
|
|
1666
|
+
renderedOpenMethod
|
|
1667
|
+
]);
|
|
1668
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
1669
|
+
store,
|
|
1670
|
+
name,
|
|
1671
|
+
required,
|
|
1672
|
+
disabled,
|
|
1673
|
+
readOnly,
|
|
1674
|
+
multiple,
|
|
1675
|
+
highlightItemOnHover,
|
|
1676
|
+
setValue,
|
|
1677
|
+
setOpen,
|
|
1678
|
+
listRef,
|
|
1679
|
+
popupRef,
|
|
1680
|
+
scrollHandlerRef,
|
|
1681
|
+
handleScrollArrowVisibility,
|
|
1682
|
+
scrollArrowsMountedCountRef,
|
|
1683
|
+
itemProps,
|
|
1684
|
+
events: floatingContext.context.events,
|
|
1685
|
+
valueRef,
|
|
1686
|
+
valuesRef,
|
|
1687
|
+
labelsRef,
|
|
1688
|
+
typingRef,
|
|
1689
|
+
selectionRef,
|
|
1690
|
+
firstItemTextRef,
|
|
1691
|
+
selectedItemTextRef,
|
|
1692
|
+
validation,
|
|
1693
|
+
onOpenChangeComplete,
|
|
1694
|
+
keyboardActiveRef,
|
|
1695
|
+
alignItemWithTriggerActiveRef,
|
|
1696
|
+
initialValueRef
|
|
1697
|
+
}), [
|
|
1698
|
+
store,
|
|
1699
|
+
name,
|
|
1700
|
+
required,
|
|
1701
|
+
disabled,
|
|
1702
|
+
readOnly,
|
|
1703
|
+
multiple,
|
|
1704
|
+
highlightItemOnHover,
|
|
1705
|
+
setValue,
|
|
1706
|
+
setOpen,
|
|
1707
|
+
itemProps,
|
|
1708
|
+
floatingContext.context.events,
|
|
1709
|
+
validation,
|
|
1710
|
+
onOpenChangeComplete,
|
|
1711
|
+
handleScrollArrowVisibility
|
|
1712
|
+
]);
|
|
1713
|
+
const ref = useMergedRefs(inputRef, validation.inputRef);
|
|
1714
|
+
const hasMultipleSelection = multiple && Array.isArray(value) && value.length > 0;
|
|
1715
|
+
const hiddenInputName = multiple ? void 0 : name;
|
|
1716
|
+
const hiddenInputs = __rspack_external_react.useMemo(()=>{
|
|
1717
|
+
if (!multiple || !Array.isArray(value) || !name) return null;
|
|
1718
|
+
return value.map((v)=>{
|
|
1719
|
+
const currentSerializedValue = stringifyAsValue(v, itemToStringValue);
|
|
1720
|
+
return /*#__PURE__*/ jsx("input", {
|
|
1721
|
+
type: "hidden",
|
|
1722
|
+
form: form,
|
|
1723
|
+
name: name,
|
|
1724
|
+
value: currentSerializedValue
|
|
1725
|
+
}, currentSerializedValue);
|
|
1726
|
+
});
|
|
1727
|
+
}, [
|
|
1728
|
+
multiple,
|
|
1729
|
+
value,
|
|
1730
|
+
form,
|
|
1731
|
+
name,
|
|
1732
|
+
itemToStringValue
|
|
1733
|
+
]);
|
|
1734
|
+
return /*#__PURE__*/ jsx(SelectRootContext.Provider, {
|
|
1735
|
+
value: contextValue,
|
|
1736
|
+
children: /*#__PURE__*/ jsxs(SelectFloatingContext.Provider, {
|
|
1737
|
+
value: floatingContext,
|
|
1738
|
+
children: [
|
|
1739
|
+
children,
|
|
1740
|
+
/*#__PURE__*/ jsx("input", {
|
|
1741
|
+
...validation.getInputValidationProps({
|
|
1742
|
+
onFocus () {
|
|
1743
|
+
store.state.triggerElement?.focus({
|
|
1744
|
+
focusVisible: true
|
|
1745
|
+
});
|
|
1746
|
+
},
|
|
1747
|
+
onChange (event) {
|
|
1748
|
+
if (event.nativeEvent.defaultPrevented || disabled || readOnly) return void event.preventBaseUIHandler?.();
|
|
1749
|
+
const nextValue = event.currentTarget.value;
|
|
1750
|
+
const details = createChangeEventDetails("none", event.nativeEvent);
|
|
1751
|
+
function handleChange() {
|
|
1752
|
+
if (multiple) return;
|
|
1753
|
+
const matchingValue = valuesRef.current.find((v)=>{
|
|
1754
|
+
const candidateValue = stringifyAsValue(v, itemToStringValue);
|
|
1755
|
+
if (candidateValue.toLowerCase() === nextValue.toLowerCase()) return true;
|
|
1756
|
+
const candidateLabel = stringifyAsLabel(v, itemToStringLabel);
|
|
1757
|
+
if (candidateLabel.toLowerCase() === nextValue.toLowerCase()) return true;
|
|
1758
|
+
return false;
|
|
1759
|
+
});
|
|
1760
|
+
if (null != matchingValue) {
|
|
1761
|
+
setDirty(matchingValue !== validityData.initialValue);
|
|
1762
|
+
setValue(matchingValue, details);
|
|
1763
|
+
if (shouldValidateOnChange()) validation.commit(matchingValue);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
store.set('forceMount', true);
|
|
1767
|
+
queueMicrotask(handleChange);
|
|
1768
|
+
}
|
|
1769
|
+
}),
|
|
1770
|
+
id: generatedId && null == hiddenInputName ? `${generatedId}-hidden-input` : void 0,
|
|
1771
|
+
form: form,
|
|
1772
|
+
name: hiddenInputName,
|
|
1773
|
+
autoComplete: autoComplete,
|
|
1774
|
+
value: serializedValue,
|
|
1775
|
+
disabled: disabled,
|
|
1776
|
+
required: required && !hasMultipleSelection,
|
|
1777
|
+
readOnly: readOnly,
|
|
1778
|
+
ref: ref,
|
|
1779
|
+
style: name ? visuallyHiddenInput : visuallyHidden,
|
|
1780
|
+
tabIndex: -1,
|
|
1781
|
+
"aria-hidden": true,
|
|
1782
|
+
suppressHydrationWarning: true
|
|
1783
|
+
}),
|
|
1784
|
+
hiddenInputs
|
|
1785
|
+
]
|
|
1786
|
+
})
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
const SelectPortalContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
1790
|
+
if ("production" !== process.env.NODE_ENV) SelectPortalContext.displayName = "SelectPortalContext";
|
|
1791
|
+
const SelectPortal_SelectPortal = /*#__PURE__*/ __rspack_external_react.forwardRef(function(portalProps, forwardedRef) {
|
|
1792
|
+
const { store } = useSelectRootContext();
|
|
1793
|
+
const mounted = useStore(store, selectors.mounted);
|
|
1794
|
+
const forceMount = useStore(store, selectors.forceMount);
|
|
1795
|
+
const shouldRender = mounted || forceMount;
|
|
1796
|
+
if (!shouldRender) return null;
|
|
1797
|
+
return /*#__PURE__*/ jsx(SelectPortalContext.Provider, {
|
|
1798
|
+
value: true,
|
|
1799
|
+
children: /*#__PURE__*/ jsx(FloatingPortal_FloatingPortal, {
|
|
1800
|
+
ref: forwardedRef,
|
|
1801
|
+
...portalProps
|
|
1802
|
+
})
|
|
1803
|
+
});
|
|
1804
|
+
});
|
|
1805
|
+
if ("production" !== process.env.NODE_ENV) SelectPortal_SelectPortal.displayName = "SelectPortal";
|
|
5
1806
|
const Select_module = {
|
|
6
1807
|
label: "label-UrIm_f",
|
|
7
1808
|
trigger: "trigger-UPubf5",
|
|
@@ -17,87 +1818,87 @@ const Select_module = {
|
|
|
17
1818
|
scrollUpArrow: "scrollUpArrow-P67Eti",
|
|
18
1819
|
groupLabel: "groupLabel-GC3RgN"
|
|
19
1820
|
};
|
|
20
|
-
const Label = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1821
|
+
const Label = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectLabel_SelectLabel, {
|
|
21
1822
|
ref: ref,
|
|
22
1823
|
className: clsx(Select_module.label, className),
|
|
23
1824
|
...props
|
|
24
1825
|
}));
|
|
25
|
-
const Trigger = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1826
|
+
const Trigger = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectTrigger_SelectTrigger, {
|
|
26
1827
|
ref: ref,
|
|
27
1828
|
className: clsx(Select_module.trigger, className),
|
|
28
1829
|
...props
|
|
29
1830
|
}));
|
|
30
|
-
const Value = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1831
|
+
const Value = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectValue_SelectValue, {
|
|
31
1832
|
ref: ref,
|
|
32
1833
|
className: clsx(Select_module.value, className),
|
|
33
1834
|
...props
|
|
34
1835
|
}));
|
|
35
|
-
const Icon = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1836
|
+
const Icon = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectIcon_SelectIcon, {
|
|
36
1837
|
ref: ref,
|
|
37
1838
|
className: clsx(Select_module.icon, className),
|
|
38
1839
|
...props
|
|
39
1840
|
}));
|
|
40
|
-
const Backdrop = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1841
|
+
const Backdrop = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectBackdrop_SelectBackdrop, {
|
|
41
1842
|
ref: ref,
|
|
42
1843
|
className: clsx(Select_module.backdrop, className),
|
|
43
1844
|
...props
|
|
44
1845
|
}));
|
|
45
|
-
const Positioner = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1846
|
+
const Positioner = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectPositioner_SelectPositioner, {
|
|
46
1847
|
ref: ref,
|
|
47
1848
|
className: clsx(Select_module.positioner, className),
|
|
48
1849
|
...props
|
|
49
1850
|
}));
|
|
50
|
-
const Popup = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1851
|
+
const Popup = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectPopup_SelectPopup, {
|
|
51
1852
|
ref: ref,
|
|
52
1853
|
className: clsx(Select_module.popup, className),
|
|
53
1854
|
...props
|
|
54
1855
|
}));
|
|
55
|
-
const List = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1856
|
+
const List = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectList_SelectList, {
|
|
56
1857
|
ref: ref,
|
|
57
1858
|
className: clsx(Select_module.list, className),
|
|
58
1859
|
...props
|
|
59
1860
|
}));
|
|
60
|
-
const Item = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1861
|
+
const Item = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectItem_SelectItem, {
|
|
61
1862
|
ref: ref,
|
|
62
1863
|
className: clsx(Select_module.item, className),
|
|
63
1864
|
...props
|
|
64
1865
|
}));
|
|
65
|
-
const ItemIndicator = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1866
|
+
const ItemIndicator = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectItemIndicator_SelectItemIndicator, {
|
|
66
1867
|
ref: ref,
|
|
67
1868
|
className: clsx(Select_module.itemIndicator, className),
|
|
68
1869
|
...props
|
|
69
1870
|
}));
|
|
70
|
-
const ItemText = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1871
|
+
const ItemText = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectItemText_SelectItemText, {
|
|
71
1872
|
ref: ref,
|
|
72
1873
|
className: clsx(Select_module.itemText, className),
|
|
73
1874
|
...props
|
|
74
1875
|
}));
|
|
75
|
-
const Arrow = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1876
|
+
const Arrow = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectArrow_SelectArrow, {
|
|
76
1877
|
ref: ref,
|
|
77
1878
|
className: clsx(Select_module.arrow, className),
|
|
78
1879
|
...props
|
|
79
1880
|
}));
|
|
80
|
-
const ScrollDownArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1881
|
+
const ScrollDownArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectScrollDownArrow_SelectScrollDownArrow, {
|
|
81
1882
|
ref: ref,
|
|
82
1883
|
className: clsx(Select_module.scrollDownArrow, className),
|
|
83
1884
|
...props
|
|
84
1885
|
}));
|
|
85
|
-
const ScrollUpArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1886
|
+
const ScrollUpArrow = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectScrollUpArrow_SelectScrollUpArrow, {
|
|
86
1887
|
ref: ref,
|
|
87
1888
|
className: clsx(Select_module.scrollUpArrow, className),
|
|
88
1889
|
...props
|
|
89
1890
|
}));
|
|
90
|
-
const Group = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1891
|
+
const Group = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectGroup_SelectGroup, {
|
|
91
1892
|
ref: ref,
|
|
92
1893
|
className: clsx(Select_module.group, className),
|
|
93
1894
|
...props
|
|
94
1895
|
}));
|
|
95
|
-
const GroupLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1896
|
+
const GroupLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectGroupLabel_SelectGroupLabel, {
|
|
96
1897
|
ref: ref,
|
|
97
1898
|
className: clsx(Select_module.groupLabel, className),
|
|
98
1899
|
...props
|
|
99
1900
|
}));
|
|
100
|
-
const
|
|
1901
|
+
const Select = {
|
|
101
1902
|
Label: Label,
|
|
102
1903
|
Trigger: Trigger,
|
|
103
1904
|
Value: Value,
|
|
@@ -114,8 +1915,8 @@ const Select_Select = {
|
|
|
114
1915
|
ScrollUpArrow: ScrollUpArrow,
|
|
115
1916
|
Group: Group,
|
|
116
1917
|
GroupLabel: GroupLabel,
|
|
117
|
-
Root:
|
|
118
|
-
Portal:
|
|
119
|
-
Separator:
|
|
1918
|
+
Root: SelectRoot,
|
|
1919
|
+
Portal: SelectPortal_SelectPortal,
|
|
1920
|
+
Separator: Separator
|
|
120
1921
|
};
|
|
121
|
-
export {
|
|
1922
|
+
export { Select };
|