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