@arc-ui/components 11.24.2 → 11.26.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/Button/Button.cjs.js +1 -1
- package/dist/Button/Button.esm.js +1 -1
- package/dist/DatePicker/DatePicker.cjs.js +1276 -22
- package/dist/DatePicker/DatePicker.esm.js +1245 -10
- package/dist/InformationCard/InformationCard.cjs.js +1 -1
- package/dist/InformationCard/InformationCard.esm.js +1 -1
- package/dist/Modal/Modal.cjs.js +438 -225
- package/dist/Modal/Modal.esm.js +420 -225
- package/dist/PaginationSimple/PaginationSimple.cjs.js +23 -2
- package/dist/PaginationSimple/PaginationSimple.esm.js +23 -2
- package/dist/Select/Select.cjs.js +1514 -1065
- package/dist/Select/Select.esm.js +1496 -1066
- package/dist/SiteHeader/SiteHeader.cjs.js +2 -2
- package/dist/SiteHeader/SiteHeader.esm.js +2 -2
- package/dist/SiteHeaderV2/SiteHeaderV2.cjs.js +2 -2
- package/dist/SiteHeaderV2/SiteHeaderV2.esm.js +2 -2
- package/dist/Tabs/Tabs.cjs.js +4 -6
- package/dist/Tabs/Tabs.esm.js +4 -6
- package/dist/TextArea/TextArea.cjs.js +10 -13
- package/dist/TextArea/TextArea.esm.js +10 -13
- package/dist/Toast/Toast.cjs.js +4 -6
- package/dist/Toast/Toast.esm.js +4 -6
- package/dist/UniversalHeader/UniversalHeader.cjs.js +2 -2
- package/dist/UniversalHeader/UniversalHeader.esm.js +2 -2
- package/dist/_shared/cjs/{Button-6ba21d3b.js → Button-5b28f0ce.js} +3 -3
- package/dist/_shared/cjs/{SiteHeader.rehydrator-9d8f3dad.js → SiteHeader.rehydrator-8fa9d174.js} +1 -1
- package/dist/_shared/cjs/{SiteHeaderV2-ce1c8737.js → SiteHeaderV2-ca2f13a8.js} +1 -1
- package/dist/_shared/cjs/{Tabs-bc9fac46.js → Tabs-89455281.js} +19 -15
- package/dist/_shared/cjs/{Toast-26207fef.js → Toast-c760c89d.js} +32 -14
- package/dist/_shared/cjs/{UniversalHeader-b8389447.js → UniversalHeader-73e154eb.js} +6 -2
- package/dist/_shared/cjs/component-4979b2e7.js +409 -0
- package/dist/_shared/cjs/{index-77ab5c6a.js → floating-ui.react-dom-08b8b87c.js} +12 -284
- package/dist/_shared/cjs/index-1efbba95.js +1252 -0
- package/dist/_shared/cjs/{index-74004a9c.js → index-4edec793.js} +1 -1
- package/dist/_shared/cjs/{index-dd1d18ea.js → index-7641213c.js} +127 -2
- package/dist/_shared/cjs/{index-9f99d686.js → index-af744fa9.js} +1 -1
- package/dist/_shared/cjs/{index-6eb396a3.js → index-fb0cad18.js} +1 -1
- package/dist/_shared/esm/{Button-a7d134c6.js → Button-5b48b7ce.js} +3 -3
- package/dist/_shared/esm/{SiteHeader.rehydrator-2ec02ee7.js → SiteHeader.rehydrator-8f3c5d6e.js} +1 -1
- package/dist/_shared/esm/{SiteHeaderV2-a7c1b1cb.js → SiteHeaderV2-cb081752.js} +1 -1
- package/dist/_shared/esm/{Tabs-9485cab6.js → Tabs-959e885d.js} +10 -6
- package/dist/_shared/esm/{Toast-fcbfc194.js → Toast-a590067d.js} +25 -7
- package/dist/_shared/esm/{UniversalHeader-80c7313f.js → UniversalHeader-96bfbacc.js} +6 -2
- package/dist/_shared/esm/component-d7b471ff.js +382 -0
- package/dist/_shared/esm/{index-b84a20c6.js → floating-ui.react-dom-1bb71aae.js} +4 -281
- package/dist/_shared/esm/{index-7b531fa7.js → index-0ae23b06.js} +126 -2
- package/dist/_shared/esm/index-307f1bbc.js +1212 -0
- package/dist/_shared/esm/{index-044da8d0.js → index-9e54cc7d.js} +1 -1
- package/dist/_shared/esm/{index-efa9be1a.js → index-af7b6e55.js} +1 -1
- package/dist/_shared/esm/{index-2cfab9f2.js → index-ebe72f34.js} +1 -1
- package/dist/index.es.js +3608 -2938
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3591 -2921
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -2
- package/dist/types/components/Button/Button.d.ts +12 -0
- package/dist/types/components/PaginationSimple/PaginationSimple.d.ts +28 -0
- package/dist/types/components/UniversalHeader/UniversalHeader.d.ts +4 -0
- package/package.json +3 -3
- package/dist/_shared/cjs/Combination-9974f2e2.js +0 -1330
- package/dist/_shared/cjs/index-a31e64a9.js +0 -27
- package/dist/_shared/cjs/index-d38f1bd0.js +0 -131
- package/dist/_shared/cjs/index-dcfdd5da.js +0 -11
- package/dist/_shared/esm/Combination-e9f7e64e.js +0 -1301
- package/dist/_shared/esm/index-25a5b393.js +0 -25
- package/dist/_shared/esm/index-a624de47.js +0 -9
- package/dist/_shared/esm/index-ca72c9d5.js +0 -129
|
@@ -3,24 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var filterDataAttrs = require('../_shared/cjs/filter-data-attrs-1c9a530c.js');
|
|
6
|
-
var index$
|
|
6
|
+
var index$1 = require('../_shared/cjs/index-9947ac13.js');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var index$3 = require('../_shared/cjs/index-dcfdd5da.js');
|
|
13
|
-
var Combination = require('../_shared/cjs/Combination-9974f2e2.js');
|
|
14
|
-
var index$4 = require('../_shared/cjs/index-6eb396a3.js');
|
|
15
|
-
var index$2 = require('../_shared/cjs/index-77ab5c6a.js');
|
|
16
|
-
var index$5 = require('../_shared/cjs/index-a31e64a9.js');
|
|
8
|
+
var ReactDOM = require('react-dom');
|
|
9
|
+
var index = require('../_shared/cjs/index-1efbba95.js');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
var floatingUi_reactDom = require('../_shared/cjs/floating-ui.react-dom-08b8b87c.js');
|
|
17
12
|
var BtIconChevronDown2Px_esm = require('../_shared/cjs/BtIconChevronDown2Px.esm-39030ee0.js');
|
|
18
13
|
var BtIconTickAlt2Px_esm = require('../_shared/cjs/BtIconTickAlt2Px.esm-57c89acc.js');
|
|
19
|
-
var Icon = require('../_shared/cjs/Icon-b46897a3.js');
|
|
14
|
+
var Icon$1 = require('../_shared/cjs/Icon-b46897a3.js');
|
|
20
15
|
var FormControl = require('../_shared/cjs/FormControl-68258ce1.js');
|
|
21
16
|
var Surface = require('../_shared/cjs/Surface-038db6e1.js');
|
|
22
17
|
var Base = require('../_shared/cjs/Base-4676f12e.js');
|
|
23
|
-
require('../_shared/cjs/
|
|
18
|
+
require('../_shared/cjs/component-4979b2e7.js');
|
|
24
19
|
require('../_shared/cjs/suffix-modifier-64dcd338.js');
|
|
25
20
|
require('../_shared/cjs/BtIconAlert.esm-1a0ff9f0.js');
|
|
26
21
|
require('../_shared/cjs/DisclosureMini-09c749e5.js');
|
|
@@ -29,152 +24,604 @@ require('../_shared/cjs/VisuallyHidden-b0de4c7b.js');
|
|
|
29
24
|
|
|
30
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
26
|
|
|
27
|
+
function _interopNamespace(e) {
|
|
28
|
+
if (e && e.__esModule) return e;
|
|
29
|
+
var n = Object.create(null);
|
|
30
|
+
if (e) {
|
|
31
|
+
Object.keys(e).forEach(function (k) {
|
|
32
|
+
if (k !== 'default') {
|
|
33
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
34
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return e[k]; }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
n["default"] = e;
|
|
42
|
+
return Object.freeze(n);
|
|
43
|
+
}
|
|
44
|
+
|
|
32
45
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
46
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
47
|
+
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
48
|
+
|
|
49
|
+
// packages/core/number/src/number.ts
|
|
50
|
+
function clamp(value, [min, max]) {
|
|
51
|
+
return Math.min(max, Math.max(min, value));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function createCollection(name) {
|
|
55
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
56
|
+
const [createCollectionContext, createCollectionScope] = index.createContextScope(PROVIDER_NAME);
|
|
57
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
|
|
58
|
+
PROVIDER_NAME,
|
|
59
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
|
60
|
+
);
|
|
61
|
+
const CollectionProvider = (props) => {
|
|
62
|
+
const { scope, children } = props;
|
|
63
|
+
const ref = React__default["default"].useRef(null);
|
|
64
|
+
const itemMap = React__default["default"].useRef(/* @__PURE__ */ new Map()).current;
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
66
|
+
};
|
|
67
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
68
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
69
|
+
const CollectionSlot = React__default["default"].forwardRef(
|
|
70
|
+
(props, forwardedRef) => {
|
|
71
|
+
const { scope, children } = props;
|
|
72
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
73
|
+
const composedRefs = index.useComposedRefs(forwardedRef, context.collectionRef);
|
|
74
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Slot, { ref: composedRefs, children });
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
78
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
79
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
80
|
+
const CollectionItemSlot = React__default["default"].forwardRef(
|
|
81
|
+
(props, forwardedRef) => {
|
|
82
|
+
const { scope, children, ...itemData } = props;
|
|
83
|
+
const ref = React__default["default"].useRef(null);
|
|
84
|
+
const composedRefs = index.useComposedRefs(forwardedRef, ref);
|
|
85
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
86
|
+
React__default["default"].useEffect(() => {
|
|
87
|
+
context.itemMap.set(ref, { ref, ...itemData });
|
|
88
|
+
return () => void context.itemMap.delete(ref);
|
|
89
|
+
});
|
|
90
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Slot, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
94
|
+
function useCollection(scope) {
|
|
95
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
96
|
+
const getItems = React__default["default"].useCallback(() => {
|
|
97
|
+
const collectionNode = context.collectionRef.current;
|
|
98
|
+
if (!collectionNode) return [];
|
|
99
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
100
|
+
const items = Array.from(context.itemMap.values());
|
|
101
|
+
const orderedItems = items.sort(
|
|
102
|
+
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
103
|
+
);
|
|
104
|
+
return orderedItems;
|
|
105
|
+
}, [context.collectionRef, context.itemMap]);
|
|
106
|
+
return getItems;
|
|
107
|
+
}
|
|
108
|
+
return [
|
|
109
|
+
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
110
|
+
useCollection,
|
|
111
|
+
createCollectionScope
|
|
112
|
+
];
|
|
113
|
+
}
|
|
33
114
|
|
|
34
|
-
|
|
35
|
-
|
|
115
|
+
// packages/react/direction/src/Direction.tsx
|
|
116
|
+
var DirectionContext = React__namespace.createContext(void 0);
|
|
117
|
+
function useDirection(localDir) {
|
|
118
|
+
const globalDir = React__namespace.useContext(DirectionContext);
|
|
119
|
+
return localDir || globalDir || "ltr";
|
|
36
120
|
}
|
|
37
121
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
122
|
+
// packages/react/arrow/src/arrow.tsx
|
|
123
|
+
var NAME$1 = "Arrow";
|
|
124
|
+
var Arrow$1 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
125
|
+
const { children, width = 10, height = 5, ...arrowProps } = props;
|
|
126
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
127
|
+
index.Primitive.svg,
|
|
128
|
+
{
|
|
129
|
+
...arrowProps,
|
|
130
|
+
ref: forwardedRef,
|
|
131
|
+
width,
|
|
132
|
+
height,
|
|
133
|
+
viewBox: "0 0 30 10",
|
|
134
|
+
preserveAspectRatio: "none",
|
|
135
|
+
children: props.asChild ? children : /* @__PURE__ */ jsxRuntime.jsx("polygon", { points: "0,0 30,0 15,10" })
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
Arrow$1.displayName = NAME$1;
|
|
140
|
+
var Root = Arrow$1;
|
|
141
|
+
|
|
142
|
+
// packages/react/use-size/src/useSize.tsx
|
|
143
|
+
function useSize(element) {
|
|
144
|
+
const [size, setSize] = React__namespace.useState(void 0);
|
|
145
|
+
index.useLayoutEffect2(() => {
|
|
146
|
+
if (element) {
|
|
147
|
+
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
148
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
149
|
+
if (!Array.isArray(entries)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!entries.length) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const entry = entries[0];
|
|
156
|
+
let width;
|
|
157
|
+
let height;
|
|
158
|
+
if ("borderBoxSize" in entry) {
|
|
159
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
160
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
161
|
+
width = borderSize["inlineSize"];
|
|
162
|
+
height = borderSize["blockSize"];
|
|
163
|
+
} else {
|
|
164
|
+
width = element.offsetWidth;
|
|
165
|
+
height = element.offsetHeight;
|
|
49
166
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
167
|
+
setSize({ width, height });
|
|
168
|
+
});
|
|
169
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
170
|
+
return () => resizeObserver.unobserve(element);
|
|
171
|
+
} else {
|
|
172
|
+
setSize(void 0);
|
|
173
|
+
}
|
|
174
|
+
}, [element]);
|
|
175
|
+
return size;
|
|
54
176
|
}
|
|
55
177
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const $cc7e05a45900e73f$var$usePopperScope = index$2.$cf1ac5d9fe0e8206$export$722aac194ae923();
|
|
75
|
-
const [$cc7e05a45900e73f$var$SelectProvider, $cc7e05a45900e73f$var$useSelectContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
|
|
76
|
-
const [$cc7e05a45900e73f$var$SelectNativeOptionsProvider, $cc7e05a45900e73f$var$useSelectNativeOptionsContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
|
|
77
|
-
const $cc7e05a45900e73f$export$ef9b1a59e592288f = (props)=>{
|
|
78
|
-
const { __scopeSelect: __scopeSelect , children: children , open: openProp , defaultOpen: defaultOpen , onOpenChange: onOpenChange , value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange , dir: dir , name: name , autoComplete: autoComplete , disabled: disabled , required: required } = props;
|
|
79
|
-
const popperScope = $cc7e05a45900e73f$var$usePopperScope(__scopeSelect);
|
|
80
|
-
const [trigger, setTrigger] = React.useState(null);
|
|
81
|
-
const [valueNode, setValueNode] = React.useState(null);
|
|
82
|
-
const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
|
|
83
|
-
const direction = index$3.$f631663db3294ace$export$b39126d51d94e6f3(dir);
|
|
84
|
-
const [open = false, setOpen] = index$1.$71cd76cc60e0454e$export$6f32135080cb4c3({
|
|
85
|
-
prop: openProp,
|
|
86
|
-
defaultProp: defaultOpen,
|
|
87
|
-
onChange: onOpenChange
|
|
178
|
+
var POPPER_NAME = "Popper";
|
|
179
|
+
var [createPopperContext, createPopperScope] = index.createContextScope(POPPER_NAME);
|
|
180
|
+
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
181
|
+
var Popper = (props) => {
|
|
182
|
+
const { __scopePopper, children } = props;
|
|
183
|
+
const [anchor, setAnchor] = React__namespace.useState(null);
|
|
184
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
|
|
185
|
+
};
|
|
186
|
+
Popper.displayName = POPPER_NAME;
|
|
187
|
+
var ANCHOR_NAME = "PopperAnchor";
|
|
188
|
+
var PopperAnchor = React__namespace.forwardRef(
|
|
189
|
+
(props, forwardedRef) => {
|
|
190
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
191
|
+
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
192
|
+
const ref = React__namespace.useRef(null);
|
|
193
|
+
const composedRefs = index.useComposedRefs(forwardedRef, ref);
|
|
194
|
+
React__namespace.useEffect(() => {
|
|
195
|
+
context.onAnchorChange(virtualRef?.current || ref.current);
|
|
88
196
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
197
|
+
return virtualRef ? null : /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.div, { ...anchorProps, ref: composedRefs });
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
201
|
+
var CONTENT_NAME$1 = "PopperContent";
|
|
202
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$1);
|
|
203
|
+
var PopperContent = React__namespace.forwardRef(
|
|
204
|
+
(props, forwardedRef) => {
|
|
205
|
+
const {
|
|
206
|
+
__scopePopper,
|
|
207
|
+
side = "bottom",
|
|
208
|
+
sideOffset = 0,
|
|
209
|
+
align = "center",
|
|
210
|
+
alignOffset = 0,
|
|
211
|
+
arrowPadding = 0,
|
|
212
|
+
avoidCollisions = true,
|
|
213
|
+
collisionBoundary = [],
|
|
214
|
+
collisionPadding: collisionPaddingProp = 0,
|
|
215
|
+
sticky = "partial",
|
|
216
|
+
hideWhenDetached = false,
|
|
217
|
+
updatePositionStrategy = "optimized",
|
|
218
|
+
onPlaced,
|
|
219
|
+
...contentProps
|
|
220
|
+
} = props;
|
|
221
|
+
const context = usePopperContext(CONTENT_NAME$1, __scopePopper);
|
|
222
|
+
const [content, setContent] = React__namespace.useState(null);
|
|
223
|
+
const composedRefs = index.useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
224
|
+
const [arrow, setArrow] = React__namespace.useState(null);
|
|
225
|
+
const arrowSize = useSize(arrow);
|
|
226
|
+
const arrowWidth = arrowSize?.width ?? 0;
|
|
227
|
+
const arrowHeight = arrowSize?.height ?? 0;
|
|
228
|
+
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
|
229
|
+
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
|
|
230
|
+
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
|
|
231
|
+
const hasExplicitBoundaries = boundary.length > 0;
|
|
232
|
+
const detectOverflowOptions = {
|
|
233
|
+
padding: collisionPadding,
|
|
234
|
+
boundary: boundary.filter(isNotNull),
|
|
235
|
+
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
236
|
+
altBoundary: hasExplicitBoundaries
|
|
237
|
+
};
|
|
238
|
+
const { refs, floatingStyles, placement, isPositioned, middlewareData } = floatingUi_reactDom.useFloating({
|
|
239
|
+
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
240
|
+
strategy: "fixed",
|
|
241
|
+
placement: desiredPlacement,
|
|
242
|
+
whileElementsMounted: (...args) => {
|
|
243
|
+
const cleanup = floatingUi_reactDom.autoUpdate(...args, {
|
|
244
|
+
animationFrame: updatePositionStrategy === "always"
|
|
245
|
+
});
|
|
246
|
+
return cleanup;
|
|
247
|
+
},
|
|
248
|
+
elements: {
|
|
249
|
+
reference: context.anchor
|
|
250
|
+
},
|
|
251
|
+
middleware: [
|
|
252
|
+
floatingUi_reactDom.offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
|
|
253
|
+
avoidCollisions && floatingUi_reactDom.shift({
|
|
254
|
+
mainAxis: true,
|
|
255
|
+
crossAxis: false,
|
|
256
|
+
limiter: sticky === "partial" ? floatingUi_reactDom.limitShift() : void 0,
|
|
257
|
+
...detectOverflowOptions
|
|
258
|
+
}),
|
|
259
|
+
avoidCollisions && floatingUi_reactDom.flip({ ...detectOverflowOptions }),
|
|
260
|
+
floatingUi_reactDom.size({
|
|
261
|
+
...detectOverflowOptions,
|
|
262
|
+
apply: ({ elements, rects, availableWidth, availableHeight }) => {
|
|
263
|
+
const { width: anchorWidth, height: anchorHeight } = rects.reference;
|
|
264
|
+
const contentStyle = elements.floating.style;
|
|
265
|
+
contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
|
|
266
|
+
contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
|
|
267
|
+
contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
|
|
268
|
+
contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
|
|
269
|
+
}
|
|
270
|
+
}),
|
|
271
|
+
arrow && floatingUi_reactDom.arrow({ element: arrow, padding: arrowPadding }),
|
|
272
|
+
transformOrigin({ arrowWidth, arrowHeight }),
|
|
273
|
+
hideWhenDetached && floatingUi_reactDom.hide({ strategy: "referenceHidden", ...detectOverflowOptions })
|
|
274
|
+
]
|
|
93
275
|
});
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
276
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
277
|
+
const handlePlaced = index.useCallbackRef(onPlaced);
|
|
278
|
+
index.useLayoutEffect2(() => {
|
|
279
|
+
if (isPositioned) {
|
|
280
|
+
handlePlaced?.();
|
|
281
|
+
}
|
|
282
|
+
}, [isPositioned, handlePlaced]);
|
|
283
|
+
const arrowX = middlewareData.arrow?.x;
|
|
284
|
+
const arrowY = middlewareData.arrow?.y;
|
|
285
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
286
|
+
const [contentZIndex, setContentZIndex] = React__namespace.useState();
|
|
287
|
+
index.useLayoutEffect2(() => {
|
|
288
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
289
|
+
}, [content]);
|
|
290
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
291
|
+
"div",
|
|
292
|
+
{
|
|
293
|
+
ref: refs.setFloating,
|
|
294
|
+
"data-radix-popper-content-wrapper": "",
|
|
295
|
+
style: {
|
|
296
|
+
...floatingStyles,
|
|
297
|
+
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
|
298
|
+
// keep off the page when measuring
|
|
299
|
+
minWidth: "max-content",
|
|
300
|
+
zIndex: contentZIndex,
|
|
301
|
+
["--radix-popper-transform-origin"]: [
|
|
302
|
+
middlewareData.transformOrigin?.x,
|
|
303
|
+
middlewareData.transformOrigin?.y
|
|
304
|
+
].join(" "),
|
|
305
|
+
// hide the content if using the hide middleware and should be hidden
|
|
306
|
+
// set visibility to hidden and disable pointer events so the UI behaves
|
|
307
|
+
// as if the PopperContent isn't there at all
|
|
308
|
+
...middlewareData.hide?.referenceHidden && {
|
|
309
|
+
visibility: "hidden",
|
|
310
|
+
pointerEvents: "none"
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
dir: props.dir,
|
|
314
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
315
|
+
PopperContentProvider,
|
|
316
|
+
{
|
|
317
|
+
scope: __scopePopper,
|
|
318
|
+
placedSide,
|
|
319
|
+
onArrowChange: setArrow,
|
|
320
|
+
arrowX,
|
|
321
|
+
arrowY,
|
|
322
|
+
shouldHideArrow: cannotCenterArrow,
|
|
323
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
324
|
+
index.Primitive.div,
|
|
325
|
+
{
|
|
326
|
+
"data-side": placedSide,
|
|
327
|
+
"data-align": placedAlign,
|
|
328
|
+
...contentProps,
|
|
329
|
+
ref: composedRefs,
|
|
330
|
+
style: {
|
|
331
|
+
...contentProps.style,
|
|
332
|
+
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
333
|
+
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
334
|
+
animation: !isPositioned ? "none" : void 0
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
PopperContent.displayName = CONTENT_NAME$1;
|
|
345
|
+
var ARROW_NAME$1 = "PopperArrow";
|
|
346
|
+
var OPPOSITE_SIDE = {
|
|
347
|
+
top: "bottom",
|
|
348
|
+
right: "left",
|
|
349
|
+
bottom: "top",
|
|
350
|
+
left: "right"
|
|
351
|
+
};
|
|
352
|
+
var PopperArrow = React__namespace.forwardRef(function PopperArrow2(props, forwardedRef) {
|
|
353
|
+
const { __scopePopper, ...arrowProps } = props;
|
|
354
|
+
const contentContext = useContentContext(ARROW_NAME$1, __scopePopper);
|
|
355
|
+
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
|
356
|
+
return (
|
|
357
|
+
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
|
358
|
+
// doesn't report size as we'd expect on SVG elements.
|
|
359
|
+
// it reports their bounding box which is effectively the largest path inside the SVG.
|
|
360
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
361
|
+
"span",
|
|
362
|
+
{
|
|
363
|
+
ref: contentContext.onArrowChange,
|
|
364
|
+
style: {
|
|
365
|
+
position: "absolute",
|
|
366
|
+
left: contentContext.arrowX,
|
|
367
|
+
top: contentContext.arrowY,
|
|
368
|
+
[baseSide]: 0,
|
|
369
|
+
transformOrigin: {
|
|
370
|
+
top: "",
|
|
371
|
+
right: "0 0",
|
|
372
|
+
bottom: "center 0",
|
|
373
|
+
left: "100% 0"
|
|
374
|
+
}[contentContext.placedSide],
|
|
375
|
+
transform: {
|
|
376
|
+
top: "translateY(100%)",
|
|
377
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
378
|
+
bottom: `rotate(180deg)`,
|
|
379
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
380
|
+
}[contentContext.placedSide],
|
|
381
|
+
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
382
|
+
},
|
|
383
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
384
|
+
Root,
|
|
385
|
+
{
|
|
386
|
+
...arrowProps,
|
|
387
|
+
ref: forwardedRef,
|
|
388
|
+
style: {
|
|
389
|
+
...arrowProps.style,
|
|
390
|
+
// ensures the element can be measured correctly (mostly for if SVG)
|
|
391
|
+
display: "block"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
)
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
);
|
|
398
|
+
});
|
|
399
|
+
PopperArrow.displayName = ARROW_NAME$1;
|
|
400
|
+
function isNotNull(value) {
|
|
401
|
+
return value !== null;
|
|
402
|
+
}
|
|
403
|
+
var transformOrigin = (options) => ({
|
|
404
|
+
name: "transformOrigin",
|
|
405
|
+
options,
|
|
406
|
+
fn(data) {
|
|
407
|
+
const { placement, rects, middlewareData } = data;
|
|
408
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
409
|
+
const isArrowHidden = cannotCenterArrow;
|
|
410
|
+
const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
|
|
411
|
+
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
412
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
413
|
+
const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
|
|
414
|
+
const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
|
|
415
|
+
const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
|
|
416
|
+
let x = "";
|
|
417
|
+
let y = "";
|
|
418
|
+
if (placedSide === "bottom") {
|
|
419
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
420
|
+
y = `${-arrowHeight}px`;
|
|
421
|
+
} else if (placedSide === "top") {
|
|
422
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
423
|
+
y = `${rects.floating.height + arrowHeight}px`;
|
|
424
|
+
} else if (placedSide === "right") {
|
|
425
|
+
x = `${-arrowHeight}px`;
|
|
426
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
427
|
+
} else if (placedSide === "left") {
|
|
428
|
+
x = `${rects.floating.width + arrowHeight}px`;
|
|
429
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
430
|
+
}
|
|
431
|
+
return { data: { x, y } };
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
function getSideAndAlignFromPlacement(placement) {
|
|
435
|
+
const [side, align = "center"] = placement.split("-");
|
|
436
|
+
return [side, align];
|
|
437
|
+
}
|
|
438
|
+
var Root2$1 = Popper;
|
|
439
|
+
var Anchor = PopperAnchor;
|
|
440
|
+
var Content = PopperContent;
|
|
441
|
+
var Arrow = PopperArrow;
|
|
442
|
+
|
|
443
|
+
// packages/react/use-previous/src/usePrevious.tsx
|
|
444
|
+
function usePrevious(value) {
|
|
445
|
+
const ref = React__namespace.useRef({ value, previous: value });
|
|
446
|
+
return React__namespace.useMemo(() => {
|
|
447
|
+
if (ref.current.value !== value) {
|
|
448
|
+
ref.current.previous = ref.current.value;
|
|
449
|
+
ref.current.value = value;
|
|
450
|
+
}
|
|
451
|
+
return ref.current.previous;
|
|
452
|
+
}, [value]);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// packages/react/visually-hidden/src/visually-hidden.tsx
|
|
456
|
+
var NAME = "VisuallyHidden";
|
|
457
|
+
var VisuallyHidden = React__namespace.forwardRef(
|
|
458
|
+
(props, forwardedRef) => {
|
|
459
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
460
|
+
index.Primitive.span,
|
|
461
|
+
{
|
|
462
|
+
...props,
|
|
463
|
+
ref: forwardedRef,
|
|
464
|
+
style: {
|
|
465
|
+
// See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
|
|
466
|
+
position: "absolute",
|
|
467
|
+
border: 0,
|
|
468
|
+
width: 1,
|
|
469
|
+
height: 1,
|
|
470
|
+
padding: 0,
|
|
471
|
+
margin: -1,
|
|
472
|
+
overflow: "hidden",
|
|
473
|
+
clip: "rect(0, 0, 0, 0)",
|
|
474
|
+
whiteSpace: "nowrap",
|
|
475
|
+
wordWrap: "normal",
|
|
476
|
+
...props.style
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
VisuallyHidden.displayName = NAME;
|
|
483
|
+
|
|
484
|
+
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
485
|
+
var SELECTION_KEYS = [" ", "Enter"];
|
|
486
|
+
var SELECT_NAME = "Select";
|
|
487
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
|
|
488
|
+
var [createSelectContext, createSelectScope] = index.createContextScope(SELECT_NAME, [
|
|
489
|
+
createCollectionScope,
|
|
490
|
+
createPopperScope
|
|
491
|
+
]);
|
|
492
|
+
var usePopperScope = createPopperScope();
|
|
493
|
+
var [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
494
|
+
var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
|
|
495
|
+
var Select$1 = (props) => {
|
|
496
|
+
const {
|
|
497
|
+
__scopeSelect,
|
|
498
|
+
children,
|
|
499
|
+
open: openProp,
|
|
500
|
+
defaultOpen,
|
|
501
|
+
onOpenChange,
|
|
502
|
+
value: valueProp,
|
|
503
|
+
defaultValue,
|
|
504
|
+
onValueChange,
|
|
505
|
+
dir,
|
|
506
|
+
name,
|
|
507
|
+
autoComplete,
|
|
508
|
+
disabled,
|
|
509
|
+
required,
|
|
510
|
+
form
|
|
511
|
+
} = props;
|
|
512
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
513
|
+
const [trigger, setTrigger] = React__namespace.useState(null);
|
|
514
|
+
const [valueNode, setValueNode] = React__namespace.useState(null);
|
|
515
|
+
const [valueNodeHasChildren, setValueNodeHasChildren] = React__namespace.useState(false);
|
|
516
|
+
const direction = useDirection(dir);
|
|
517
|
+
const [open = false, setOpen] = index.useControllableState({
|
|
518
|
+
prop: openProp,
|
|
519
|
+
defaultProp: defaultOpen,
|
|
520
|
+
onChange: onOpenChange
|
|
521
|
+
});
|
|
522
|
+
const [value, setValue] = index.useControllableState({
|
|
523
|
+
prop: valueProp,
|
|
524
|
+
defaultProp: defaultValue,
|
|
525
|
+
onChange: onValueChange
|
|
526
|
+
});
|
|
527
|
+
const triggerPointerDownPosRef = React__namespace.useRef(null);
|
|
528
|
+
const isFormControl = trigger ? form || !!trigger.closest("form") : true;
|
|
529
|
+
const [nativeOptionsSet, setNativeOptionsSet] = React__namespace.useState(/* @__PURE__ */ new Set());
|
|
530
|
+
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
|
531
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
532
|
+
SelectProvider,
|
|
533
|
+
{
|
|
534
|
+
required,
|
|
535
|
+
scope: __scopeSelect,
|
|
536
|
+
trigger,
|
|
537
|
+
onTriggerChange: setTrigger,
|
|
538
|
+
valueNode,
|
|
539
|
+
onValueNodeChange: setValueNode,
|
|
540
|
+
valueNodeHasChildren,
|
|
541
|
+
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
542
|
+
contentId: index.useId(),
|
|
543
|
+
value,
|
|
544
|
+
onValueChange: setValue,
|
|
545
|
+
open,
|
|
546
|
+
onOpenChange: setOpen,
|
|
547
|
+
dir: direction,
|
|
548
|
+
triggerPointerDownPosRef,
|
|
549
|
+
disabled,
|
|
550
|
+
children: [
|
|
551
|
+
/* @__PURE__ */ jsxRuntime.jsx(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
552
|
+
SelectNativeOptionsProvider,
|
|
553
|
+
{
|
|
554
|
+
scope: props.__scopeSelect,
|
|
555
|
+
onNativeOptionAdd: React__namespace.useCallback((option) => {
|
|
556
|
+
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
|
557
|
+
}, []),
|
|
558
|
+
onNativeOptionRemove: React__namespace.useCallback((option) => {
|
|
559
|
+
setNativeOptionsSet((prev) => {
|
|
130
560
|
const optionsSet = new Set(prev);
|
|
131
561
|
optionsSet.delete(option);
|
|
132
562
|
return optionsSet;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
563
|
+
});
|
|
564
|
+
}, []),
|
|
565
|
+
children
|
|
566
|
+
}
|
|
567
|
+
) }),
|
|
568
|
+
isFormControl ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
569
|
+
BubbleSelect,
|
|
570
|
+
{
|
|
571
|
+
"aria-hidden": true,
|
|
572
|
+
required,
|
|
573
|
+
tabIndex: -1,
|
|
574
|
+
name,
|
|
575
|
+
autoComplete,
|
|
576
|
+
value,
|
|
577
|
+
onChange: (event) => setValue(event.target.value),
|
|
578
|
+
disabled,
|
|
579
|
+
form,
|
|
580
|
+
children: [
|
|
581
|
+
value === void 0 ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: "" }) : null,
|
|
582
|
+
Array.from(nativeOptionsSet)
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
nativeSelectKey
|
|
586
|
+
) : null
|
|
587
|
+
]
|
|
588
|
+
}
|
|
589
|
+
) });
|
|
150
590
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const { __scopeSelect
|
|
156
|
-
const popperScope =
|
|
157
|
-
const context =
|
|
591
|
+
Select$1.displayName = SELECT_NAME;
|
|
592
|
+
var TRIGGER_NAME = "SelectTrigger";
|
|
593
|
+
var SelectTrigger = React__namespace.forwardRef(
|
|
594
|
+
(props, forwardedRef) => {
|
|
595
|
+
const { __scopeSelect, disabled = false, ...triggerProps } = props;
|
|
596
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
597
|
+
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
158
598
|
const isDisabled = context.disabled || disabled;
|
|
159
|
-
const composedRefs = index
|
|
160
|
-
const getItems =
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
599
|
+
const composedRefs = index.useComposedRefs(forwardedRef, context.onTriggerChange);
|
|
600
|
+
const getItems = useCollection(__scopeSelect);
|
|
601
|
+
const pointerTypeRef = React__namespace.useRef("touch");
|
|
602
|
+
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
|
|
603
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
604
|
+
const currentItem = enabledItems.find((item) => item.value === context.value);
|
|
605
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
606
|
+
if (nextItem !== void 0) {
|
|
607
|
+
context.onValueChange(nextItem.value);
|
|
608
|
+
}
|
|
168
609
|
});
|
|
169
|
-
const handleOpen = ()=>{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
610
|
+
const handleOpen = (pointerEvent) => {
|
|
611
|
+
if (!isDisabled) {
|
|
612
|
+
context.onOpenChange(true);
|
|
613
|
+
resetTypeahead();
|
|
614
|
+
}
|
|
615
|
+
if (pointerEvent) {
|
|
616
|
+
context.triggerPointerDownPosRef.current = {
|
|
617
|
+
x: Math.round(pointerEvent.pageX),
|
|
618
|
+
y: Math.round(pointerEvent.pageY)
|
|
619
|
+
};
|
|
620
|
+
}
|
|
174
621
|
};
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
622
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
623
|
+
index.Primitive.button,
|
|
624
|
+
{
|
|
178
625
|
type: "button",
|
|
179
626
|
role: "combobox",
|
|
180
627
|
"aria-controls": context.contentId,
|
|
@@ -182,970 +629,972 @@ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ React.forwardRef(
|
|
|
182
629
|
"aria-required": context.required,
|
|
183
630
|
"aria-autocomplete": "none",
|
|
184
631
|
dir: context.dir,
|
|
185
|
-
"data-state": context.open ?
|
|
632
|
+
"data-state": context.open ? "open" : "closed",
|
|
186
633
|
disabled: isDisabled,
|
|
187
|
-
"data-disabled": isDisabled ?
|
|
188
|
-
"data-placeholder":
|
|
189
|
-
|
|
190
|
-
ref: composedRefs
|
|
191
|
-
,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
// because we are preventing default in `onPointerDown` so effectively
|
|
197
|
-
// this only runs for a label "click"
|
|
198
|
-
event.currentTarget.focus();
|
|
634
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
635
|
+
"data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
|
|
636
|
+
...triggerProps,
|
|
637
|
+
ref: composedRefs,
|
|
638
|
+
onClick: index.composeEventHandlers(triggerProps.onClick, (event) => {
|
|
639
|
+
event.currentTarget.focus();
|
|
640
|
+
if (pointerTypeRef.current !== "mouse") {
|
|
641
|
+
handleOpen(event);
|
|
642
|
+
}
|
|
199
643
|
}),
|
|
200
|
-
onPointerDown: index
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
x: Math.round(event.pageX),
|
|
211
|
-
y: Math.round(event.pageY)
|
|
212
|
-
}; // prevent trigger from stealing focus from the active item after opening.
|
|
213
|
-
event.preventDefault();
|
|
214
|
-
}
|
|
644
|
+
onPointerDown: index.composeEventHandlers(triggerProps.onPointerDown, (event) => {
|
|
645
|
+
pointerTypeRef.current = event.pointerType;
|
|
646
|
+
const target = event.target;
|
|
647
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
|
648
|
+
target.releasePointerCapture(event.pointerId);
|
|
649
|
+
}
|
|
650
|
+
if (event.button === 0 && event.ctrlKey === false && event.pointerType === "mouse") {
|
|
651
|
+
handleOpen(event);
|
|
652
|
+
event.preventDefault();
|
|
653
|
+
}
|
|
215
654
|
}),
|
|
216
|
-
onKeyDown: index
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
655
|
+
onKeyDown: index.composeEventHandlers(triggerProps.onKeyDown, (event) => {
|
|
656
|
+
const isTypingAhead = searchRef.current !== "";
|
|
657
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
658
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
659
|
+
if (isTypingAhead && event.key === " ") return;
|
|
660
|
+
if (OPEN_KEYS.includes(event.key)) {
|
|
661
|
+
handleOpen();
|
|
662
|
+
event.preventDefault();
|
|
663
|
+
}
|
|
225
664
|
})
|
|
226
|
-
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
index
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
,
|
|
247
|
-
style: {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
665
|
+
}
|
|
666
|
+
) });
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
SelectTrigger.displayName = TRIGGER_NAME;
|
|
670
|
+
var VALUE_NAME = "SelectValue";
|
|
671
|
+
var SelectValue = React__namespace.forwardRef(
|
|
672
|
+
(props, forwardedRef) => {
|
|
673
|
+
const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
|
|
674
|
+
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
|
675
|
+
const { onValueNodeHasChildrenChange } = context;
|
|
676
|
+
const hasChildren = children !== void 0;
|
|
677
|
+
const composedRefs = index.useComposedRefs(forwardedRef, context.onValueNodeChange);
|
|
678
|
+
index.useLayoutEffect2(() => {
|
|
679
|
+
onValueNodeHasChildrenChange(hasChildren);
|
|
680
|
+
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
681
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
682
|
+
index.Primitive.span,
|
|
683
|
+
{
|
|
684
|
+
...valueProps,
|
|
685
|
+
ref: composedRefs,
|
|
686
|
+
style: { pointerEvents: "none" },
|
|
687
|
+
children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: placeholder }) : children
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
);
|
|
692
|
+
SelectValue.displayName = VALUE_NAME;
|
|
693
|
+
var ICON_NAME = "SelectIcon";
|
|
694
|
+
var SelectIcon = React__namespace.forwardRef(
|
|
695
|
+
(props, forwardedRef) => {
|
|
696
|
+
const { __scopeSelect, children, ...iconProps } = props;
|
|
697
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "\u25BC" });
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
SelectIcon.displayName = ICON_NAME;
|
|
701
|
+
var PORTAL_NAME = "SelectPortal";
|
|
702
|
+
var SelectPortal = (props) => {
|
|
703
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Portal, { asChild: true, ...props });
|
|
264
704
|
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const context =
|
|
270
|
-
const [fragment, setFragment] =
|
|
271
|
-
index
|
|
272
|
-
|
|
705
|
+
SelectPortal.displayName = PORTAL_NAME;
|
|
706
|
+
var CONTENT_NAME = "SelectContent";
|
|
707
|
+
var SelectContent = React__namespace.forwardRef(
|
|
708
|
+
(props, forwardedRef) => {
|
|
709
|
+
const context = useSelectContext(CONTENT_NAME, props.__scopeSelect);
|
|
710
|
+
const [fragment, setFragment] = React__namespace.useState();
|
|
711
|
+
index.useLayoutEffect2(() => {
|
|
712
|
+
setFragment(new DocumentFragment());
|
|
273
713
|
}, []);
|
|
274
714
|
if (!context.open) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}, /*#__PURE__*/ React.createElement("div", null, props.children))), frag) : null;
|
|
715
|
+
const frag = fragment;
|
|
716
|
+
return frag ? ReactDOM__namespace.createPortal(
|
|
717
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: props.children }) }) }),
|
|
718
|
+
frag
|
|
719
|
+
) : null;
|
|
281
720
|
}
|
|
282
|
-
return
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
721
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectContentImpl, { ...props, ref: forwardedRef });
|
|
722
|
+
}
|
|
723
|
+
);
|
|
724
|
+
SelectContent.displayName = CONTENT_NAME;
|
|
725
|
+
var CONTENT_MARGIN = 10;
|
|
726
|
+
var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME);
|
|
727
|
+
var CONTENT_IMPL_NAME = "SelectContentImpl";
|
|
728
|
+
var SelectContentImpl = React__namespace.forwardRef(
|
|
729
|
+
(props, forwardedRef) => {
|
|
730
|
+
const {
|
|
731
|
+
__scopeSelect,
|
|
732
|
+
position = "item-aligned",
|
|
733
|
+
onCloseAutoFocus,
|
|
734
|
+
onEscapeKeyDown,
|
|
735
|
+
onPointerDownOutside,
|
|
736
|
+
//
|
|
737
|
+
// PopperContent props
|
|
738
|
+
side,
|
|
739
|
+
sideOffset,
|
|
740
|
+
align,
|
|
741
|
+
alignOffset,
|
|
742
|
+
arrowPadding,
|
|
743
|
+
collisionBoundary,
|
|
744
|
+
collisionPadding,
|
|
745
|
+
sticky,
|
|
746
|
+
hideWhenDetached,
|
|
747
|
+
avoidCollisions,
|
|
748
|
+
//
|
|
749
|
+
...contentProps
|
|
750
|
+
} = props;
|
|
751
|
+
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
752
|
+
const [content, setContent] = React__namespace.useState(null);
|
|
753
|
+
const [viewport, setViewport] = React__namespace.useState(null);
|
|
754
|
+
const composedRefs = index.useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
755
|
+
const [selectedItem, setSelectedItem] = React__namespace.useState(null);
|
|
756
|
+
const [selectedItemText, setSelectedItemText] = React__namespace.useState(
|
|
757
|
+
null
|
|
299
758
|
);
|
|
300
|
-
const
|
|
301
|
-
const [
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// the last element in the DOM (because of the `Portal`)
|
|
311
|
-
Combination.$3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
|
|
312
|
-
const focusFirst = React.useCallback((candidates)=>{
|
|
313
|
-
const [firstItem, ...restItems] = getItems().map((item)=>item.ref.current
|
|
314
|
-
);
|
|
759
|
+
const getItems = useCollection(__scopeSelect);
|
|
760
|
+
const [isPositioned, setIsPositioned] = React__namespace.useState(false);
|
|
761
|
+
const firstValidItemFoundRef = React__namespace.useRef(false);
|
|
762
|
+
React__namespace.useEffect(() => {
|
|
763
|
+
if (content) return index.hideOthers(content);
|
|
764
|
+
}, [content]);
|
|
765
|
+
index.useFocusGuards();
|
|
766
|
+
const focusFirst = React__namespace.useCallback(
|
|
767
|
+
(candidates) => {
|
|
768
|
+
const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
|
|
315
769
|
const [lastItem] = restItems.slice(-1);
|
|
316
770
|
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
317
|
-
for (const candidate of candidates){
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
|
325
|
-
candidate === null || candidate === void 0 || candidate.focus();
|
|
326
|
-
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
771
|
+
for (const candidate of candidates) {
|
|
772
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
773
|
+
candidate?.scrollIntoView({ block: "nearest" });
|
|
774
|
+
if (candidate === firstItem && viewport) viewport.scrollTop = 0;
|
|
775
|
+
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
|
776
|
+
candidate?.focus();
|
|
777
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
327
778
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const handlePointerMove = (event)=>{
|
|
357
|
-
var _triggerPointerDownPo, _triggerPointerDownPo2, _triggerPointerDownPo3, _triggerPointerDownPo4;
|
|
358
|
-
pointerMoveDelta = {
|
|
359
|
-
x: Math.abs(Math.round(event.pageX) - ((_triggerPointerDownPo = (_triggerPointerDownPo2 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo2 === void 0 ? void 0 : _triggerPointerDownPo2.x) !== null && _triggerPointerDownPo !== void 0 ? _triggerPointerDownPo : 0)),
|
|
360
|
-
y: Math.abs(Math.round(event.pageY) - ((_triggerPointerDownPo3 = (_triggerPointerDownPo4 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo4 === void 0 ? void 0 : _triggerPointerDownPo4.y) !== null && _triggerPointerDownPo3 !== void 0 ? _triggerPointerDownPo3 : 0))
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
const handlePointerUp = (event)=>{
|
|
364
|
-
// If the pointer hasn't moved by a certain threshold then we prevent selecting item on `pointerup`.
|
|
365
|
-
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) event.preventDefault();
|
|
366
|
-
else // otherwise, if the event was outside the content, close.
|
|
367
|
-
if (!content.contains(event.target)) onOpenChange(false);
|
|
368
|
-
document.removeEventListener('pointermove', handlePointerMove);
|
|
369
|
-
triggerPointerDownPosRef.current = null;
|
|
370
|
-
};
|
|
371
|
-
if (triggerPointerDownPosRef.current !== null) {
|
|
372
|
-
document.addEventListener('pointermove', handlePointerMove);
|
|
373
|
-
document.addEventListener('pointerup', handlePointerUp, {
|
|
374
|
-
capture: true,
|
|
375
|
-
once: true
|
|
376
|
-
});
|
|
779
|
+
},
|
|
780
|
+
[getItems, viewport]
|
|
781
|
+
);
|
|
782
|
+
const focusSelectedItem = React__namespace.useCallback(
|
|
783
|
+
() => focusFirst([selectedItem, content]),
|
|
784
|
+
[focusFirst, selectedItem, content]
|
|
785
|
+
);
|
|
786
|
+
React__namespace.useEffect(() => {
|
|
787
|
+
if (isPositioned) {
|
|
788
|
+
focusSelectedItem();
|
|
789
|
+
}
|
|
790
|
+
}, [isPositioned, focusSelectedItem]);
|
|
791
|
+
const { onOpenChange, triggerPointerDownPosRef } = context;
|
|
792
|
+
React__namespace.useEffect(() => {
|
|
793
|
+
if (content) {
|
|
794
|
+
let pointerMoveDelta = { x: 0, y: 0 };
|
|
795
|
+
const handlePointerMove = (event) => {
|
|
796
|
+
pointerMoveDelta = {
|
|
797
|
+
x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
|
|
798
|
+
y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
const handlePointerUp = (event) => {
|
|
802
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
|
803
|
+
event.preventDefault();
|
|
804
|
+
} else {
|
|
805
|
+
if (!content.contains(event.target)) {
|
|
806
|
+
onOpenChange(false);
|
|
377
807
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
808
|
+
}
|
|
809
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
810
|
+
triggerPointerDownPosRef.current = null;
|
|
811
|
+
};
|
|
812
|
+
if (triggerPointerDownPosRef.current !== null) {
|
|
813
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
814
|
+
document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
|
|
384
815
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
triggerPointerDownPosRef
|
|
389
|
-
]);
|
|
390
|
-
React.useEffect(()=>{
|
|
391
|
-
const close = ()=>onOpenChange(false)
|
|
392
|
-
;
|
|
393
|
-
window.addEventListener('blur', close);
|
|
394
|
-
window.addEventListener('resize', close);
|
|
395
|
-
return ()=>{
|
|
396
|
-
window.removeEventListener('blur', close);
|
|
397
|
-
window.removeEventListener('resize', close);
|
|
816
|
+
return () => {
|
|
817
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
818
|
+
document.removeEventListener("pointerup", handlePointerUp, { capture: true });
|
|
398
819
|
};
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
820
|
+
}
|
|
821
|
+
}, [content, onOpenChange, triggerPointerDownPosRef]);
|
|
822
|
+
React__namespace.useEffect(() => {
|
|
823
|
+
const close = () => onOpenChange(false);
|
|
824
|
+
window.addEventListener("blur", close);
|
|
825
|
+
window.addEventListener("resize", close);
|
|
826
|
+
return () => {
|
|
827
|
+
window.removeEventListener("blur", close);
|
|
828
|
+
window.removeEventListener("resize", close);
|
|
829
|
+
};
|
|
830
|
+
}, [onOpenChange]);
|
|
831
|
+
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
|
|
832
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
833
|
+
const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
|
|
834
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
835
|
+
if (nextItem) {
|
|
836
|
+
setTimeout(() => nextItem.ref.current.focus());
|
|
837
|
+
}
|
|
413
838
|
});
|
|
414
|
-
const itemRefCallback =
|
|
839
|
+
const itemRefCallback = React__namespace.useCallback(
|
|
840
|
+
(node, value, disabled) => {
|
|
415
841
|
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
416
|
-
const isSelectedItem = context.value !==
|
|
842
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
417
843
|
if (isSelectedItem || isFirstValidItem) {
|
|
418
|
-
|
|
419
|
-
|
|
844
|
+
setSelectedItem(node);
|
|
845
|
+
if (isFirstValidItem) firstValidItemFoundRef.current = true;
|
|
420
846
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const handleItemLeave =
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
]);
|
|
428
|
-
const itemTextRefCallback = React.useCallback((node, value, disabled)=>{
|
|
847
|
+
},
|
|
848
|
+
[context.value]
|
|
849
|
+
);
|
|
850
|
+
const handleItemLeave = React__namespace.useCallback(() => content?.focus(), [content]);
|
|
851
|
+
const itemTextRefCallback = React__namespace.useCallback(
|
|
852
|
+
(node, value, disabled) => {
|
|
429
853
|
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
430
|
-
const isSelectedItem = context.value !==
|
|
431
|
-
if (isSelectedItem || isFirstValidItem)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
854
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
855
|
+
if (isSelectedItem || isFirstValidItem) {
|
|
856
|
+
setSelectedItemText(node);
|
|
857
|
+
}
|
|
858
|
+
},
|
|
859
|
+
[context.value]
|
|
860
|
+
);
|
|
861
|
+
const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
|
|
862
|
+
const popperContentProps = SelectPosition === SelectPopperPosition ? {
|
|
863
|
+
side,
|
|
864
|
+
sideOffset,
|
|
865
|
+
align,
|
|
866
|
+
alignOffset,
|
|
867
|
+
arrowPadding,
|
|
868
|
+
collisionBoundary,
|
|
869
|
+
collisionPadding,
|
|
870
|
+
sticky,
|
|
871
|
+
hideWhenDetached,
|
|
872
|
+
avoidCollisions
|
|
447
873
|
} : {};
|
|
448
|
-
return
|
|
874
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
875
|
+
SelectContentProvider,
|
|
876
|
+
{
|
|
449
877
|
scope: __scopeSelect,
|
|
450
|
-
content: content,
|
|
451
|
-
viewport: viewport,
|
|
452
|
-
onViewportChange: setViewport,
|
|
453
|
-
itemRefCallback: itemRefCallback,
|
|
454
|
-
selectedItem: selectedItem,
|
|
455
|
-
onItemLeave: handleItemLeave,
|
|
456
|
-
itemTextRefCallback: itemTextRefCallback,
|
|
457
|
-
focusSelectedItem: focusSelectedItem,
|
|
458
|
-
selectedItemText: selectedItemText,
|
|
459
|
-
position: position,
|
|
460
|
-
isPositioned: isPositioned,
|
|
461
|
-
searchRef: searchRef
|
|
462
|
-
}, /*#__PURE__*/ React.createElement(Combination.$01b9c$RemoveScroll, {
|
|
463
|
-
as: index$1.$5e63c961fc1ce211$export$8c6ed5c666ac1360,
|
|
464
|
-
allowPinchZoom: true
|
|
465
|
-
}, /*#__PURE__*/ React.createElement(Combination.$d3863c46a17e8a28$export$20e40289641fbbb6, {
|
|
466
|
-
asChild: true // we make sure we're not trapping once it's been closed
|
|
467
|
-
,
|
|
468
|
-
trapped: context.open,
|
|
469
|
-
onMountAutoFocus: (event)=>{
|
|
470
|
-
// we prevent open autofocus because we manually focus the selected item
|
|
471
|
-
event.preventDefault();
|
|
472
|
-
},
|
|
473
|
-
onUnmountAutoFocus: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(onCloseAutoFocus, (event)=>{
|
|
474
|
-
var _context$trigger;
|
|
475
|
-
(_context$trigger = context.trigger) === null || _context$trigger === void 0 || _context$trigger.focus({
|
|
476
|
-
preventScroll: true
|
|
477
|
-
});
|
|
478
|
-
event.preventDefault();
|
|
479
|
-
})
|
|
480
|
-
}, /*#__PURE__*/ React.createElement(Combination.$5cb92bef7577960e$export$177fb62ff3ec1f22, {
|
|
481
|
-
asChild: true,
|
|
482
|
-
disableOutsidePointerEvents: true,
|
|
483
|
-
onEscapeKeyDown: onEscapeKeyDown,
|
|
484
|
-
onPointerDownOutside: onPointerDownOutside // When focus is trapped, a focusout event may still happen.
|
|
485
|
-
,
|
|
486
|
-
onFocusOutside: (event)=>event.preventDefault()
|
|
487
|
-
,
|
|
488
|
-
onDismiss: ()=>context.onOpenChange(false)
|
|
489
|
-
}, /*#__PURE__*/ React.createElement(SelectPosition, _extends._extends({
|
|
490
|
-
role: "listbox",
|
|
491
|
-
id: context.contentId,
|
|
492
|
-
"data-state": context.open ? 'open' : 'closed',
|
|
493
|
-
dir: context.dir,
|
|
494
|
-
onContextMenu: (event)=>event.preventDefault()
|
|
495
|
-
}, contentProps, popperContentProps, {
|
|
496
|
-
onPlaced: ()=>setIsPositioned(true)
|
|
497
|
-
,
|
|
498
|
-
ref: composedRefs,
|
|
499
|
-
style: {
|
|
500
|
-
// flex layout so we can place the scroll buttons properly
|
|
501
|
-
display: 'flex',
|
|
502
|
-
flexDirection: 'column',
|
|
503
|
-
// reset the outline by default as the content MAY get focused
|
|
504
|
-
outline: 'none',
|
|
505
|
-
...contentProps.style
|
|
506
|
-
},
|
|
507
|
-
onKeyDown: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(contentProps.onKeyDown, (event)=>{
|
|
508
|
-
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey; // select should not be navigated using tab key so we prevent it
|
|
509
|
-
if (event.key === 'Tab') event.preventDefault();
|
|
510
|
-
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
511
|
-
if ([
|
|
512
|
-
'ArrowUp',
|
|
513
|
-
'ArrowDown',
|
|
514
|
-
'Home',
|
|
515
|
-
'End'
|
|
516
|
-
].includes(event.key)) {
|
|
517
|
-
const items = getItems().filter((item)=>!item.disabled
|
|
518
|
-
);
|
|
519
|
-
let candidateNodes = items.map((item)=>item.ref.current
|
|
520
|
-
);
|
|
521
|
-
if ([
|
|
522
|
-
'ArrowUp',
|
|
523
|
-
'End'
|
|
524
|
-
].includes(event.key)) candidateNodes = candidateNodes.slice().reverse();
|
|
525
|
-
if ([
|
|
526
|
-
'ArrowUp',
|
|
527
|
-
'ArrowDown'
|
|
528
|
-
].includes(event.key)) {
|
|
529
|
-
const currentElement = event.target;
|
|
530
|
-
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
531
|
-
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Imperative focus during keydown is risky so we prevent React's batching updates
|
|
535
|
-
* to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
|
|
536
|
-
*/ setTimeout(()=>focusFirst(candidateNodes)
|
|
537
|
-
);
|
|
538
|
-
event.preventDefault();
|
|
539
|
-
}
|
|
540
|
-
})
|
|
541
|
-
}))))));
|
|
542
|
-
});
|
|
543
|
-
const $cc7e05a45900e73f$var$SelectItemAlignedPosition = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
544
|
-
const { __scopeSelect: __scopeSelect , onPlaced: onPlaced , ...popperProps } = props;
|
|
545
|
-
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
|
|
546
|
-
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
|
|
547
|
-
const [contentWrapper, setContentWrapper] = React.useState(null);
|
|
548
|
-
const [content, setContent] = React.useState(null);
|
|
549
|
-
const composedRefs = index$1.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
|
|
550
|
-
);
|
|
551
|
-
const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
|
|
552
|
-
const shouldExpandOnScrollRef = React.useRef(false);
|
|
553
|
-
const shouldRepositionRef = React.useRef(true);
|
|
554
|
-
const { viewport: viewport , selectedItem: selectedItem , selectedItemText: selectedItemText , focusSelectedItem: focusSelectedItem } = contentContext;
|
|
555
|
-
const position = React.useCallback(()=>{
|
|
556
|
-
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
557
|
-
const triggerRect = context.trigger.getBoundingClientRect(); // -----------------------------------------------------------------------------------------
|
|
558
|
-
// Horizontal positioning
|
|
559
|
-
// -----------------------------------------------------------------------------------------
|
|
560
|
-
const contentRect = content.getBoundingClientRect();
|
|
561
|
-
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
562
|
-
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
563
|
-
if (context.dir !== 'rtl') {
|
|
564
|
-
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
565
|
-
const left = valueNodeRect.left - itemTextOffset;
|
|
566
|
-
const leftDelta = triggerRect.left - left;
|
|
567
|
-
const minContentWidth = triggerRect.width + leftDelta;
|
|
568
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
569
|
-
const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
570
|
-
const clampedLeft = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(left, [
|
|
571
|
-
$cc7e05a45900e73f$var$CONTENT_MARGIN,
|
|
572
|
-
rightEdge - contentWidth
|
|
573
|
-
]);
|
|
574
|
-
contentWrapper.style.minWidth = minContentWidth + 'px';
|
|
575
|
-
contentWrapper.style.left = clampedLeft + 'px';
|
|
576
|
-
} else {
|
|
577
|
-
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
578
|
-
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
579
|
-
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
580
|
-
const minContentWidth = triggerRect.width + rightDelta;
|
|
581
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
582
|
-
const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
583
|
-
const clampedRight = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(right, [
|
|
584
|
-
$cc7e05a45900e73f$var$CONTENT_MARGIN,
|
|
585
|
-
leftEdge - contentWidth
|
|
586
|
-
]);
|
|
587
|
-
contentWrapper.style.minWidth = minContentWidth + 'px';
|
|
588
|
-
contentWrapper.style.right = clampedRight + 'px';
|
|
589
|
-
} // -----------------------------------------------------------------------------------------
|
|
590
|
-
// Vertical positioning
|
|
591
|
-
// -----------------------------------------------------------------------------------------
|
|
592
|
-
const items = getItems();
|
|
593
|
-
const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
|
|
594
|
-
const itemsHeight = viewport.scrollHeight;
|
|
595
|
-
const contentStyles = window.getComputedStyle(content);
|
|
596
|
-
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
|
597
|
-
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
|
598
|
-
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
|
599
|
-
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
|
600
|
-
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth; // prettier-ignore
|
|
601
|
-
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
602
|
-
const viewportStyles = window.getComputedStyle(viewport);
|
|
603
|
-
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
604
|
-
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
605
|
-
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
606
|
-
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
607
|
-
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
608
|
-
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
609
|
-
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
610
|
-
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
611
|
-
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
612
|
-
if (willAlignWithoutTopOverflow) {
|
|
613
|
-
const isLastItem = selectedItem === items[items.length - 1].ref.current;
|
|
614
|
-
contentWrapper.style.bottom = "0px";
|
|
615
|
-
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
616
|
-
const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
|
|
617
|
-
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
618
|
-
contentWrapper.style.height = height + 'px';
|
|
619
|
-
} else {
|
|
620
|
-
const isFirstItem = selectedItem === items[0].ref.current;
|
|
621
|
-
contentWrapper.style.top = "0px";
|
|
622
|
-
const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
|
|
623
|
-
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
624
|
-
contentWrapper.style.height = height + 'px';
|
|
625
|
-
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
626
|
-
}
|
|
627
|
-
contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
|
|
628
|
-
contentWrapper.style.minHeight = minContentHeight + 'px';
|
|
629
|
-
contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
|
|
630
|
-
onPlaced === null || onPlaced === void 0 || onPlaced(); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
|
|
631
|
-
// so we explicitly turn it on only after they've registered.
|
|
632
|
-
requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
|
|
633
|
-
);
|
|
634
|
-
}
|
|
635
|
-
}, [
|
|
636
|
-
getItems,
|
|
637
|
-
context.trigger,
|
|
638
|
-
context.valueNode,
|
|
639
|
-
contentWrapper,
|
|
640
878
|
content,
|
|
641
879
|
viewport,
|
|
880
|
+
onViewportChange: setViewport,
|
|
881
|
+
itemRefCallback,
|
|
642
882
|
selectedItem,
|
|
883
|
+
onItemLeave: handleItemLeave,
|
|
884
|
+
itemTextRefCallback,
|
|
885
|
+
focusSelectedItem,
|
|
643
886
|
selectedItemText,
|
|
644
|
-
context.dir,
|
|
645
|
-
onPlaced
|
|
646
|
-
]);
|
|
647
|
-
index$1.$9f79659886946c16$export$e5c5a5f917a5871c(()=>position()
|
|
648
|
-
, [
|
|
649
|
-
position
|
|
650
|
-
]); // copy z-index from content to wrapper
|
|
651
|
-
const [contentZIndex, setContentZIndex] = React.useState();
|
|
652
|
-
index$1.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
|
|
653
|
-
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
654
|
-
}, [
|
|
655
|
-
content
|
|
656
|
-
]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
|
|
657
|
-
// Because it is part of the normal flow, it will push down the viewport, thus throwing our
|
|
658
|
-
// trigger => selectedItem alignment off by the amount the viewport was pushed down.
|
|
659
|
-
// We wait for this to happen and then re-run the positining logic one more time to account for it.
|
|
660
|
-
const handleScrollButtonChange = React.useCallback((node)=>{
|
|
661
|
-
if (node && shouldRepositionRef.current === true) {
|
|
662
|
-
position();
|
|
663
|
-
focusSelectedItem === null || focusSelectedItem === void 0 || focusSelectedItem();
|
|
664
|
-
shouldRepositionRef.current = false;
|
|
665
|
-
}
|
|
666
|
-
}, [
|
|
667
887
|
position,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
888
|
+
isPositioned,
|
|
889
|
+
searchRef,
|
|
890
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(index.RemoveScroll, { as: index.Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
891
|
+
index.FocusScope,
|
|
892
|
+
{
|
|
893
|
+
asChild: true,
|
|
894
|
+
trapped: context.open,
|
|
895
|
+
onMountAutoFocus: (event) => {
|
|
896
|
+
event.preventDefault();
|
|
897
|
+
},
|
|
898
|
+
onUnmountAutoFocus: index.composeEventHandlers(onCloseAutoFocus, (event) => {
|
|
899
|
+
context.trigger?.focus({ preventScroll: true });
|
|
900
|
+
event.preventDefault();
|
|
901
|
+
}),
|
|
902
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
903
|
+
index.DismissableLayer,
|
|
904
|
+
{
|
|
905
|
+
asChild: true,
|
|
906
|
+
disableOutsidePointerEvents: true,
|
|
907
|
+
onEscapeKeyDown,
|
|
908
|
+
onPointerDownOutside,
|
|
909
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
910
|
+
onDismiss: () => context.onOpenChange(false),
|
|
911
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
912
|
+
SelectPosition,
|
|
913
|
+
{
|
|
914
|
+
role: "listbox",
|
|
915
|
+
id: context.contentId,
|
|
916
|
+
"data-state": context.open ? "open" : "closed",
|
|
917
|
+
dir: context.dir,
|
|
918
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
919
|
+
...contentProps,
|
|
920
|
+
...popperContentProps,
|
|
921
|
+
onPlaced: () => setIsPositioned(true),
|
|
922
|
+
ref: composedRefs,
|
|
923
|
+
style: {
|
|
924
|
+
// flex layout so we can place the scroll buttons properly
|
|
925
|
+
display: "flex",
|
|
926
|
+
flexDirection: "column",
|
|
927
|
+
// reset the outline by default as the content MAY get focused
|
|
928
|
+
outline: "none",
|
|
929
|
+
...contentProps.style
|
|
930
|
+
},
|
|
931
|
+
onKeyDown: index.composeEventHandlers(contentProps.onKeyDown, (event) => {
|
|
932
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
933
|
+
if (event.key === "Tab") event.preventDefault();
|
|
934
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
935
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
|
936
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
937
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
|
938
|
+
if (["ArrowUp", "End"].includes(event.key)) {
|
|
939
|
+
candidateNodes = candidateNodes.slice().reverse();
|
|
940
|
+
}
|
|
941
|
+
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
942
|
+
const currentElement = event.target;
|
|
943
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
944
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
945
|
+
}
|
|
946
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
947
|
+
event.preventDefault();
|
|
948
|
+
}
|
|
949
|
+
})
|
|
950
|
+
}
|
|
951
|
+
)
|
|
952
|
+
}
|
|
953
|
+
)
|
|
954
|
+
}
|
|
955
|
+
) })
|
|
956
|
+
}
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
);
|
|
960
|
+
SelectContentImpl.displayName = CONTENT_IMPL_NAME;
|
|
961
|
+
var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
|
|
962
|
+
var SelectItemAlignedPosition = React__namespace.forwardRef((props, forwardedRef) => {
|
|
963
|
+
const { __scopeSelect, onPlaced, ...popperProps } = props;
|
|
964
|
+
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
965
|
+
const contentContext = useSelectContentContext(CONTENT_NAME, __scopeSelect);
|
|
966
|
+
const [contentWrapper, setContentWrapper] = React__namespace.useState(null);
|
|
967
|
+
const [content, setContent] = React__namespace.useState(null);
|
|
968
|
+
const composedRefs = index.useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
969
|
+
const getItems = useCollection(__scopeSelect);
|
|
970
|
+
const shouldExpandOnScrollRef = React__namespace.useRef(false);
|
|
971
|
+
const shouldRepositionRef = React__namespace.useRef(true);
|
|
972
|
+
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
|
973
|
+
const position = React__namespace.useCallback(() => {
|
|
974
|
+
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
975
|
+
const triggerRect = context.trigger.getBoundingClientRect();
|
|
976
|
+
const contentRect = content.getBoundingClientRect();
|
|
977
|
+
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
978
|
+
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
979
|
+
if (context.dir !== "rtl") {
|
|
980
|
+
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
981
|
+
const left = valueNodeRect.left - itemTextOffset;
|
|
982
|
+
const leftDelta = triggerRect.left - left;
|
|
983
|
+
const minContentWidth = triggerRect.width + leftDelta;
|
|
984
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
985
|
+
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
|
986
|
+
const clampedLeft = clamp(left, [
|
|
987
|
+
CONTENT_MARGIN,
|
|
988
|
+
// Prevents the content from going off the starting edge of the
|
|
989
|
+
// viewport. It may still go off the ending edge, but this can be
|
|
990
|
+
// controlled by the user since they may want to manage overflow in a
|
|
991
|
+
// specific way.
|
|
992
|
+
// https://github.com/radix-ui/primitives/issues/2049
|
|
993
|
+
Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
|
|
994
|
+
]);
|
|
995
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
996
|
+
contentWrapper.style.left = clampedLeft + "px";
|
|
997
|
+
} else {
|
|
998
|
+
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
999
|
+
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
1000
|
+
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
1001
|
+
const minContentWidth = triggerRect.width + rightDelta;
|
|
1002
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
1003
|
+
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
|
1004
|
+
const clampedRight = clamp(right, [
|
|
1005
|
+
CONTENT_MARGIN,
|
|
1006
|
+
Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
|
|
1007
|
+
]);
|
|
1008
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
1009
|
+
contentWrapper.style.right = clampedRight + "px";
|
|
1010
|
+
}
|
|
1011
|
+
const items = getItems();
|
|
1012
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
1013
|
+
const itemsHeight = viewport.scrollHeight;
|
|
1014
|
+
const contentStyles = window.getComputedStyle(content);
|
|
1015
|
+
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
|
1016
|
+
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
|
1017
|
+
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
|
1018
|
+
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
|
1019
|
+
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
|
1020
|
+
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
1021
|
+
const viewportStyles = window.getComputedStyle(viewport);
|
|
1022
|
+
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
1023
|
+
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
1024
|
+
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
|
1025
|
+
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
1026
|
+
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
1027
|
+
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
1028
|
+
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
1029
|
+
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
1030
|
+
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
1031
|
+
if (willAlignWithoutTopOverflow) {
|
|
1032
|
+
const isLastItem = items.length > 0 && selectedItem === items[items.length - 1].ref.current;
|
|
1033
|
+
contentWrapper.style.bottom = "0px";
|
|
1034
|
+
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
1035
|
+
const clampedTriggerMiddleToBottomEdge = Math.max(
|
|
1036
|
+
triggerMiddleToBottomEdge,
|
|
1037
|
+
selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
1038
|
+
(isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
|
|
1039
|
+
);
|
|
1040
|
+
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
1041
|
+
contentWrapper.style.height = height + "px";
|
|
1042
|
+
} else {
|
|
1043
|
+
const isFirstItem = items.length > 0 && selectedItem === items[0].ref.current;
|
|
1044
|
+
contentWrapper.style.top = "0px";
|
|
1045
|
+
const clampedTopEdgeToTriggerMiddle = Math.max(
|
|
1046
|
+
topEdgeToTriggerMiddle,
|
|
1047
|
+
contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
1048
|
+
(isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
|
|
1049
|
+
);
|
|
1050
|
+
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
1051
|
+
contentWrapper.style.height = height + "px";
|
|
1052
|
+
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
1053
|
+
}
|
|
1054
|
+
contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
|
|
1055
|
+
contentWrapper.style.minHeight = minContentHeight + "px";
|
|
1056
|
+
contentWrapper.style.maxHeight = availableHeight + "px";
|
|
1057
|
+
onPlaced?.();
|
|
1058
|
+
requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
|
|
1059
|
+
}
|
|
1060
|
+
}, [
|
|
1061
|
+
getItems,
|
|
1062
|
+
context.trigger,
|
|
1063
|
+
context.valueNode,
|
|
1064
|
+
contentWrapper,
|
|
1065
|
+
content,
|
|
1066
|
+
viewport,
|
|
1067
|
+
selectedItem,
|
|
1068
|
+
selectedItemText,
|
|
1069
|
+
context.dir,
|
|
1070
|
+
onPlaced
|
|
1071
|
+
]);
|
|
1072
|
+
index.useLayoutEffect2(() => position(), [position]);
|
|
1073
|
+
const [contentZIndex, setContentZIndex] = React__namespace.useState();
|
|
1074
|
+
index.useLayoutEffect2(() => {
|
|
1075
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
1076
|
+
}, [content]);
|
|
1077
|
+
const handleScrollButtonChange = React__namespace.useCallback(
|
|
1078
|
+
(node) => {
|
|
1079
|
+
if (node && shouldRepositionRef.current === true) {
|
|
1080
|
+
position();
|
|
1081
|
+
focusSelectedItem?.();
|
|
1082
|
+
shouldRepositionRef.current = false;
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
[position, focusSelectedItem]
|
|
1086
|
+
);
|
|
1087
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1088
|
+
SelectViewportProvider,
|
|
1089
|
+
{
|
|
1090
|
+
scope: __scopeSelect,
|
|
1091
|
+
contentWrapper,
|
|
1092
|
+
shouldExpandOnScrollRef,
|
|
1093
|
+
onScrollButtonChange: handleScrollButtonChange,
|
|
1094
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1095
|
+
"div",
|
|
1096
|
+
{
|
|
1097
|
+
ref: setContentWrapper,
|
|
1098
|
+
style: {
|
|
1099
|
+
display: "flex",
|
|
1100
|
+
flexDirection: "column",
|
|
1101
|
+
position: "fixed",
|
|
681
1102
|
zIndex: contentZIndex
|
|
1103
|
+
},
|
|
1104
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1105
|
+
index.Primitive.div,
|
|
1106
|
+
{
|
|
1107
|
+
...popperProps,
|
|
1108
|
+
ref: composedRefs,
|
|
1109
|
+
style: {
|
|
1110
|
+
// When we get the height of the content, it includes borders. If we were to set
|
|
1111
|
+
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
1112
|
+
boxSizing: "border-box",
|
|
1113
|
+
// We need to ensure the content doesn't get taller than the wrapper
|
|
1114
|
+
maxHeight: "100%",
|
|
1115
|
+
...popperProps.style
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
)
|
|
682
1119
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
// When we get the height of the content, it includes borders. If we were to set
|
|
687
|
-
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
688
|
-
boxSizing: 'border-box',
|
|
689
|
-
// We need to ensure the content doesn't get taller than the wrapper
|
|
690
|
-
maxHeight: '100%',
|
|
691
|
-
...popperProps.style
|
|
692
|
-
}
|
|
693
|
-
}))));
|
|
1120
|
+
)
|
|
1121
|
+
}
|
|
1122
|
+
);
|
|
694
1123
|
});
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1124
|
+
SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
|
|
1125
|
+
var POPPER_POSITION_NAME = "SelectPopperPosition";
|
|
1126
|
+
var SelectPopperPosition = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1127
|
+
const {
|
|
1128
|
+
__scopeSelect,
|
|
1129
|
+
align = "start",
|
|
1130
|
+
collisionPadding = CONTENT_MARGIN,
|
|
1131
|
+
...popperProps
|
|
1132
|
+
} = props;
|
|
1133
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
1134
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1135
|
+
Content,
|
|
1136
|
+
{
|
|
1137
|
+
...popperScope,
|
|
1138
|
+
...popperProps,
|
|
1139
|
+
ref: forwardedRef,
|
|
1140
|
+
align,
|
|
1141
|
+
collisionPadding,
|
|
1142
|
+
style: {
|
|
1143
|
+
// Ensure border-box for floating-ui calculations
|
|
1144
|
+
boxSizing: "border-box",
|
|
1145
|
+
...popperProps.style,
|
|
1146
|
+
// re-namespace exposed content custom properties
|
|
1147
|
+
...{
|
|
1148
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1149
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
|
1150
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
|
1151
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1152
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
711
1153
|
}
|
|
712
|
-
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
);
|
|
713
1157
|
});
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
const { __scopeSelect
|
|
720
|
-
const contentContext =
|
|
721
|
-
const viewportContext =
|
|
722
|
-
const composedRefs = index
|
|
723
|
-
const prevScrollTopRef =
|
|
724
|
-
return
|
|
725
|
-
|
|
1158
|
+
SelectPopperPosition.displayName = POPPER_POSITION_NAME;
|
|
1159
|
+
var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME, {});
|
|
1160
|
+
var VIEWPORT_NAME = "SelectViewport";
|
|
1161
|
+
var SelectViewport = React__namespace.forwardRef(
|
|
1162
|
+
(props, forwardedRef) => {
|
|
1163
|
+
const { __scopeSelect, nonce, ...viewportProps } = props;
|
|
1164
|
+
const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
|
|
1165
|
+
const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
|
|
1166
|
+
const composedRefs = index.useComposedRefs(forwardedRef, contentContext.onViewportChange);
|
|
1167
|
+
const prevScrollTopRef = React__namespace.useRef(0);
|
|
1168
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1169
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1170
|
+
"style",
|
|
1171
|
+
{
|
|
1172
|
+
dangerouslySetInnerHTML: {
|
|
726
1173
|
__html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
|
|
1174
|
+
},
|
|
1175
|
+
nonce
|
|
727
1176
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
1177
|
+
),
|
|
1178
|
+
/* @__PURE__ */ jsxRuntime.jsx(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1179
|
+
index.Primitive.div,
|
|
1180
|
+
{
|
|
1181
|
+
"data-radix-select-viewport": "",
|
|
1182
|
+
role: "presentation",
|
|
1183
|
+
...viewportProps,
|
|
1184
|
+
ref: composedRefs,
|
|
1185
|
+
style: {
|
|
736
1186
|
// we use position: 'relative' here on the `viewport` so that when we call
|
|
737
1187
|
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
738
1188
|
// (independent of the scrollUpButton).
|
|
739
|
-
position:
|
|
1189
|
+
position: "relative",
|
|
740
1190
|
flex: 1,
|
|
741
|
-
|
|
1191
|
+
// Viewport should only be scrollable in the vertical direction.
|
|
1192
|
+
// This won't work in vertical writing modes, so we'll need to
|
|
1193
|
+
// revisit this if/when that is supported
|
|
1194
|
+
// https://developer.chrome.com/blog/vertical-form-controls
|
|
1195
|
+
overflow: "hidden auto",
|
|
742
1196
|
...viewportProps.style
|
|
743
|
-
|
|
744
|
-
|
|
1197
|
+
},
|
|
1198
|
+
onScroll: index.composeEventHandlers(viewportProps.onScroll, (event) => {
|
|
745
1199
|
const viewport = event.currentTarget;
|
|
746
|
-
const { contentWrapper
|
|
747
|
-
if (shouldExpandOnScrollRef
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}
|
|
1200
|
+
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
|
1201
|
+
if (shouldExpandOnScrollRef?.current && contentWrapper) {
|
|
1202
|
+
const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
|
|
1203
|
+
if (scrolledBy > 0) {
|
|
1204
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
1205
|
+
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
|
1206
|
+
const cssHeight = parseFloat(contentWrapper.style.height);
|
|
1207
|
+
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
|
1208
|
+
if (prevHeight < availableHeight) {
|
|
1209
|
+
const nextHeight = prevHeight + scrolledBy;
|
|
1210
|
+
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
|
1211
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
|
1212
|
+
contentWrapper.style.height = clampedNextHeight + "px";
|
|
1213
|
+
if (contentWrapper.style.bottom === "0px") {
|
|
1214
|
+
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
1215
|
+
contentWrapper.style.justifyContent = "flex-end";
|
|
1216
|
+
}
|
|
764
1217
|
}
|
|
1218
|
+
}
|
|
765
1219
|
}
|
|
766
1220
|
prevScrollTopRef.current = viewport.scrollTop;
|
|
767
|
-
|
|
768
|
-
}))));
|
|
769
|
-
});
|
|
770
|
-
/* -------------------------------------------------------------------------------------------------
|
|
771
|
-
* SelectGroup
|
|
772
|
-
* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$GROUP_NAME = 'SelectGroup';
|
|
773
|
-
$cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$GROUP_NAME);
|
|
774
|
-
/* -------------------------------------------------------------------------------------------------
|
|
775
|
-
* SelectItem
|
|
776
|
-
* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_NAME = 'SelectItem';
|
|
777
|
-
const [$cc7e05a45900e73f$var$SelectItemContextProvider, $cc7e05a45900e73f$var$useSelectItemContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$ITEM_NAME);
|
|
778
|
-
const $cc7e05a45900e73f$export$13ef48a934230896 = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
779
|
-
const { __scopeSelect: __scopeSelect , value: value , disabled: disabled = false , textValue: textValueProp , ...itemProps } = props;
|
|
780
|
-
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
|
|
781
|
-
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
|
|
782
|
-
const isSelected = context.value === value;
|
|
783
|
-
const [textValue, setTextValue] = React.useState(textValueProp !== null && textValueProp !== void 0 ? textValueProp : '');
|
|
784
|
-
const [isFocused, setIsFocused] = React.useState(false);
|
|
785
|
-
const composedRefs = index$1.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>{
|
|
786
|
-
var _contentContext$itemR;
|
|
787
|
-
return (_contentContext$itemR = contentContext.itemRefCallback) === null || _contentContext$itemR === void 0 ? void 0 : _contentContext$itemR.call(contentContext, node, value, disabled);
|
|
788
|
-
});
|
|
789
|
-
const textId = index$4.$1746a345f3d73bb7$export$f680877a34711e37();
|
|
790
|
-
const handleSelect = ()=>{
|
|
791
|
-
if (!disabled) {
|
|
792
|
-
context.onValueChange(value);
|
|
793
|
-
context.onOpenChange(false);
|
|
1221
|
+
})
|
|
794
1222
|
}
|
|
1223
|
+
) })
|
|
1224
|
+
] });
|
|
1225
|
+
}
|
|
1226
|
+
);
|
|
1227
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
|
1228
|
+
var GROUP_NAME = "SelectGroup";
|
|
1229
|
+
var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
|
1230
|
+
var SelectGroup = React__namespace.forwardRef(
|
|
1231
|
+
(props, forwardedRef) => {
|
|
1232
|
+
const { __scopeSelect, ...groupProps } = props;
|
|
1233
|
+
const groupId = index.useId();
|
|
1234
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
|
|
1235
|
+
}
|
|
1236
|
+
);
|
|
1237
|
+
SelectGroup.displayName = GROUP_NAME;
|
|
1238
|
+
var LABEL_NAME = "SelectLabel";
|
|
1239
|
+
var SelectLabel = React__namespace.forwardRef(
|
|
1240
|
+
(props, forwardedRef) => {
|
|
1241
|
+
const { __scopeSelect, ...labelProps } = props;
|
|
1242
|
+
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
1243
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
|
1244
|
+
}
|
|
1245
|
+
);
|
|
1246
|
+
SelectLabel.displayName = LABEL_NAME;
|
|
1247
|
+
var ITEM_NAME = "SelectItem";
|
|
1248
|
+
var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
1249
|
+
var SelectItem = React__namespace.forwardRef(
|
|
1250
|
+
(props, forwardedRef) => {
|
|
1251
|
+
const {
|
|
1252
|
+
__scopeSelect,
|
|
1253
|
+
value,
|
|
1254
|
+
disabled = false,
|
|
1255
|
+
textValue: textValueProp,
|
|
1256
|
+
...itemProps
|
|
1257
|
+
} = props;
|
|
1258
|
+
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
1259
|
+
const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
|
|
1260
|
+
const isSelected = context.value === value;
|
|
1261
|
+
const [textValue, setTextValue] = React__namespace.useState(textValueProp ?? "");
|
|
1262
|
+
const [isFocused, setIsFocused] = React__namespace.useState(false);
|
|
1263
|
+
const composedRefs = index.useComposedRefs(
|
|
1264
|
+
forwardedRef,
|
|
1265
|
+
(node) => contentContext.itemRefCallback?.(node, value, disabled)
|
|
1266
|
+
);
|
|
1267
|
+
const textId = index.useId();
|
|
1268
|
+
const pointerTypeRef = React__namespace.useRef("touch");
|
|
1269
|
+
const handleSelect = () => {
|
|
1270
|
+
if (!disabled) {
|
|
1271
|
+
context.onValueChange(value);
|
|
1272
|
+
context.onOpenChange(false);
|
|
1273
|
+
}
|
|
795
1274
|
};
|
|
796
|
-
if (value ===
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
setTextValue((prevTextValue)=>{
|
|
805
|
-
var _node$textContent;
|
|
806
|
-
return prevTextValue || ((_node$textContent = node === null || node === void 0 ? void 0 : node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : '').trim();
|
|
807
|
-
});
|
|
808
|
-
}, [])
|
|
809
|
-
}, /*#__PURE__*/ React.createElement($cc7e05a45900e73f$var$Collection.ItemSlot, {
|
|
1275
|
+
if (value === "") {
|
|
1276
|
+
throw new Error(
|
|
1277
|
+
"A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1281
|
+
SelectItemContextProvider,
|
|
1282
|
+
{
|
|
810
1283
|
scope: __scopeSelect,
|
|
811
|
-
value
|
|
812
|
-
disabled
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1284
|
+
value,
|
|
1285
|
+
disabled,
|
|
1286
|
+
textId,
|
|
1287
|
+
isSelected,
|
|
1288
|
+
onItemTextChange: React__namespace.useCallback((node) => {
|
|
1289
|
+
setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
|
|
1290
|
+
}, []),
|
|
1291
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1292
|
+
Collection.ItemSlot,
|
|
1293
|
+
{
|
|
1294
|
+
scope: __scopeSelect,
|
|
1295
|
+
value,
|
|
1296
|
+
disabled,
|
|
1297
|
+
textValue,
|
|
1298
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1299
|
+
index.Primitive.div,
|
|
1300
|
+
{
|
|
1301
|
+
role: "option",
|
|
1302
|
+
"aria-labelledby": textId,
|
|
1303
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
1304
|
+
"aria-selected": isSelected && isFocused,
|
|
1305
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
|
1306
|
+
"aria-disabled": disabled || void 0,
|
|
1307
|
+
"data-disabled": disabled ? "" : void 0,
|
|
1308
|
+
tabIndex: disabled ? void 0 : -1,
|
|
1309
|
+
...itemProps,
|
|
1310
|
+
ref: composedRefs,
|
|
1311
|
+
onFocus: index.composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
|
|
1312
|
+
onBlur: index.composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
|
|
1313
|
+
onClick: index.composeEventHandlers(itemProps.onClick, () => {
|
|
1314
|
+
if (pointerTypeRef.current !== "mouse") handleSelect();
|
|
1315
|
+
}),
|
|
1316
|
+
onPointerUp: index.composeEventHandlers(itemProps.onPointerUp, () => {
|
|
1317
|
+
if (pointerTypeRef.current === "mouse") handleSelect();
|
|
1318
|
+
}),
|
|
1319
|
+
onPointerDown: index.composeEventHandlers(itemProps.onPointerDown, (event) => {
|
|
1320
|
+
pointerTypeRef.current = event.pointerType;
|
|
1321
|
+
}),
|
|
1322
|
+
onPointerMove: index.composeEventHandlers(itemProps.onPointerMove, (event) => {
|
|
1323
|
+
pointerTypeRef.current = event.pointerType;
|
|
1324
|
+
if (disabled) {
|
|
1325
|
+
contentContext.onItemLeave?.();
|
|
1326
|
+
} else if (pointerTypeRef.current === "mouse") {
|
|
1327
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
1328
|
+
}
|
|
1329
|
+
}),
|
|
1330
|
+
onPointerLeave: index.composeEventHandlers(itemProps.onPointerLeave, (event) => {
|
|
1331
|
+
if (event.currentTarget === document.activeElement) {
|
|
1332
|
+
contentContext.onItemLeave?.();
|
|
1333
|
+
}
|
|
1334
|
+
}),
|
|
1335
|
+
onKeyDown: index.composeEventHandlers(itemProps.onKeyDown, (event) => {
|
|
1336
|
+
const isTypingAhead = contentContext.searchRef?.current !== "";
|
|
1337
|
+
if (isTypingAhead && event.key === " ") return;
|
|
1338
|
+
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
|
1339
|
+
if (event.key === " ") event.preventDefault();
|
|
1340
|
+
})
|
|
1341
|
+
}
|
|
1342
|
+
)
|
|
1343
|
+
}
|
|
1344
|
+
)
|
|
1345
|
+
}
|
|
1346
|
+
);
|
|
1347
|
+
}
|
|
1348
|
+
);
|
|
1349
|
+
SelectItem.displayName = ITEM_NAME;
|
|
1350
|
+
var ITEM_TEXT_NAME = "SelectItemText";
|
|
1351
|
+
var SelectItemText = React__namespace.forwardRef(
|
|
1352
|
+
(props, forwardedRef) => {
|
|
1353
|
+
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
|
1354
|
+
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
1355
|
+
const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
1356
|
+
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
1357
|
+
const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
1358
|
+
const [itemTextNode, setItemTextNode] = React__namespace.useState(null);
|
|
1359
|
+
const composedRefs = index.useComposedRefs(
|
|
1360
|
+
forwardedRef,
|
|
1361
|
+
(node) => setItemTextNode(node),
|
|
1362
|
+
itemContext.onItemTextChange,
|
|
1363
|
+
(node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
|
|
1364
|
+
);
|
|
1365
|
+
const textContent = itemTextNode?.textContent;
|
|
1366
|
+
const nativeOption = React__namespace.useMemo(
|
|
1367
|
+
() => /* @__PURE__ */ jsxRuntime.jsx("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
|
|
1368
|
+
[itemContext.disabled, itemContext.value, textContent]
|
|
1369
|
+
);
|
|
1370
|
+
const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
|
|
1371
|
+
index.useLayoutEffect2(() => {
|
|
1372
|
+
onNativeOptionAdd(nativeOption);
|
|
1373
|
+
return () => onNativeOptionRemove(nativeOption);
|
|
1374
|
+
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
|
1375
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1376
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
|
1377
|
+
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM__namespace.createPortal(itemTextProps.children, context.valueNode) : null
|
|
1378
|
+
] });
|
|
1379
|
+
}
|
|
1380
|
+
);
|
|
1381
|
+
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
1382
|
+
var ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
1383
|
+
var SelectItemIndicator = React__namespace.forwardRef(
|
|
1384
|
+
(props, forwardedRef) => {
|
|
1385
|
+
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
1386
|
+
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
1387
|
+
return itemContext.isSelected ? /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
|
1388
|
+
}
|
|
1389
|
+
);
|
|
1390
|
+
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
1391
|
+
var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
1392
|
+
var SelectScrollUpButton = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1393
|
+
const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
1394
|
+
const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
1395
|
+
const [canScrollUp, setCanScrollUp] = React__namespace.useState(false);
|
|
1396
|
+
const composedRefs = index.useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
1397
|
+
index.useLayoutEffect2(() => {
|
|
1398
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
1399
|
+
let handleScroll2 = function() {
|
|
1400
|
+
const canScrollUp2 = viewport.scrollTop > 0;
|
|
1401
|
+
setCanScrollUp(canScrollUp2);
|
|
1402
|
+
};
|
|
1403
|
+
const viewport = contentContext.viewport;
|
|
1404
|
+
handleScroll2();
|
|
1405
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
1406
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
1407
|
+
}
|
|
1408
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
1409
|
+
return canScrollUp ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1410
|
+
SelectScrollButtonImpl,
|
|
1411
|
+
{
|
|
1412
|
+
...props,
|
|
1413
|
+
ref: composedRefs,
|
|
1414
|
+
onAutoScroll: () => {
|
|
1415
|
+
const { viewport, selectedItem } = contentContext;
|
|
1416
|
+
if (viewport && selectedItem) {
|
|
1417
|
+
viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
|
|
940
1418
|
}
|
|
941
|
-
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
) : null;
|
|
942
1422
|
});
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
const { viewport: viewport , selectedItem: selectedItem } = contentContext;
|
|
973
|
-
if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
|
1423
|
+
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
1424
|
+
var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
1425
|
+
var SelectScrollDownButton = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1426
|
+
const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
1427
|
+
const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
1428
|
+
const [canScrollDown, setCanScrollDown] = React__namespace.useState(false);
|
|
1429
|
+
const composedRefs = index.useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
1430
|
+
index.useLayoutEffect2(() => {
|
|
1431
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
1432
|
+
let handleScroll2 = function() {
|
|
1433
|
+
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
|
1434
|
+
const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
|
|
1435
|
+
setCanScrollDown(canScrollDown2);
|
|
1436
|
+
};
|
|
1437
|
+
const viewport = contentContext.viewport;
|
|
1438
|
+
handleScroll2();
|
|
1439
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
1440
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
1441
|
+
}
|
|
1442
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
1443
|
+
return canScrollDown ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1444
|
+
SelectScrollButtonImpl,
|
|
1445
|
+
{
|
|
1446
|
+
...props,
|
|
1447
|
+
ref: composedRefs,
|
|
1448
|
+
onAutoScroll: () => {
|
|
1449
|
+
const { viewport, selectedItem } = contentContext;
|
|
1450
|
+
if (viewport && selectedItem) {
|
|
1451
|
+
viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
|
974
1452
|
}
|
|
975
|
-
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
) : null;
|
|
976
1456
|
});
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1457
|
+
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
1458
|
+
var SelectScrollButtonImpl = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1459
|
+
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
|
1460
|
+
const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
|
|
1461
|
+
const autoScrollTimerRef = React__namespace.useRef(null);
|
|
1462
|
+
const getItems = useCollection(__scopeSelect);
|
|
1463
|
+
const clearAutoScrollTimer = React__namespace.useCallback(() => {
|
|
1464
|
+
if (autoScrollTimerRef.current !== null) {
|
|
1465
|
+
window.clearInterval(autoScrollTimerRef.current);
|
|
1466
|
+
autoScrollTimerRef.current = null;
|
|
1467
|
+
}
|
|
1468
|
+
}, []);
|
|
1469
|
+
React__namespace.useEffect(() => {
|
|
1470
|
+
return () => clearAutoScrollTimer();
|
|
1471
|
+
}, [clearAutoScrollTimer]);
|
|
1472
|
+
index.useLayoutEffect2(() => {
|
|
1473
|
+
const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
|
|
1474
|
+
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
1475
|
+
}, [getItems]);
|
|
1476
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1477
|
+
index.Primitive.div,
|
|
1478
|
+
{
|
|
1479
|
+
"aria-hidden": true,
|
|
1480
|
+
...scrollIndicatorProps,
|
|
1481
|
+
ref: forwardedRef,
|
|
1482
|
+
style: { flexShrink: 0, ...scrollIndicatorProps.style },
|
|
1483
|
+
onPointerDown: index.composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
|
|
1484
|
+
if (autoScrollTimerRef.current === null) {
|
|
1485
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
986
1486
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
clearAutoScrollTimer
|
|
993
|
-
]); // When the viewport becomes scrollable on either side, the relevant scroll button will mount.
|
|
994
|
-
// Because it is part of the normal flow, it will push down (top button) or shrink (bottom button)
|
|
995
|
-
// the viewport, potentially causing the active item to now be partially out of view.
|
|
996
|
-
// We re-run the `scrollIntoView` logic to make sure it stays within the viewport.
|
|
997
|
-
index$1.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
|
|
998
|
-
var _activeItem$ref$curre;
|
|
999
|
-
const activeItem = getItems().find((item)=>item.ref.current === document.activeElement
|
|
1000
|
-
);
|
|
1001
|
-
activeItem === null || activeItem === void 0 || (_activeItem$ref$curre = activeItem.ref.current) === null || _activeItem$ref$curre === void 0 || _activeItem$ref$curre.scrollIntoView({
|
|
1002
|
-
block: 'nearest'
|
|
1003
|
-
});
|
|
1004
|
-
}, [
|
|
1005
|
-
getItems
|
|
1006
|
-
]);
|
|
1007
|
-
return /*#__PURE__*/ React.createElement(index$1.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends._extends({
|
|
1008
|
-
"aria-hidden": true
|
|
1009
|
-
}, scrollIndicatorProps, {
|
|
1010
|
-
ref: forwardedRef,
|
|
1011
|
-
style: {
|
|
1012
|
-
flexShrink: 0,
|
|
1013
|
-
...scrollIndicatorProps.style
|
|
1014
|
-
},
|
|
1015
|
-
onPointerDown: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerDown, ()=>{
|
|
1016
|
-
if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1017
|
-
}),
|
|
1018
|
-
onPointerMove: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerMove, ()=>{
|
|
1019
|
-
var _contentContext$onIte3;
|
|
1020
|
-
(_contentContext$onIte3 = contentContext.onItemLeave) === null || _contentContext$onIte3 === void 0 || _contentContext$onIte3.call(contentContext);
|
|
1021
|
-
if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1022
|
-
}),
|
|
1023
|
-
onPointerLeave: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerLeave, ()=>{
|
|
1024
|
-
clearAutoScrollTimer();
|
|
1025
|
-
})
|
|
1026
|
-
}));
|
|
1027
|
-
});
|
|
1028
|
-
/* -----------------------------------------------------------------------------------------------*/ function $cc7e05a45900e73f$var$shouldShowPlaceholder(value) {
|
|
1029
|
-
return value === '' || value === undefined;
|
|
1030
|
-
}
|
|
1031
|
-
const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
1032
|
-
const { value: value , ...selectProps } = props;
|
|
1033
|
-
const ref = React.useRef(null);
|
|
1034
|
-
const composedRefs = index$1.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
|
|
1035
|
-
const prevValue = $010c2913dbd2fe3d$export$5cae361ad82dce8b(value); // Bubble value change to parents (e.g form change event)
|
|
1036
|
-
React.useEffect(()=>{
|
|
1037
|
-
const select = ref.current;
|
|
1038
|
-
const selectProto = window.HTMLSelectElement.prototype;
|
|
1039
|
-
const descriptor = Object.getOwnPropertyDescriptor(selectProto, 'value');
|
|
1040
|
-
const setValue = descriptor.set;
|
|
1041
|
-
if (prevValue !== value && setValue) {
|
|
1042
|
-
const event = new Event('change', {
|
|
1043
|
-
bubbles: true
|
|
1044
|
-
});
|
|
1045
|
-
setValue.call(select, value);
|
|
1046
|
-
select.dispatchEvent(event);
|
|
1487
|
+
}),
|
|
1488
|
+
onPointerMove: index.composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
|
|
1489
|
+
contentContext.onItemLeave?.();
|
|
1490
|
+
if (autoScrollTimerRef.current === null) {
|
|
1491
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1047
1492
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
* as possible.
|
|
1055
|
-
*
|
|
1056
|
-
* We purposefully do not add the `value` attribute here to allow the value
|
|
1057
|
-
* to be set programatically and bubble to any parent form `onChange` event.
|
|
1058
|
-
* Adding the `value` will cause React to consider the programatic
|
|
1059
|
-
* dispatch a duplicate and it will get swallowed.
|
|
1060
|
-
*
|
|
1061
|
-
* We use `VisuallyHidden` rather than `display: "none"` because Safari autofill
|
|
1062
|
-
* won't work otherwise.
|
|
1063
|
-
*/ return /*#__PURE__*/ React.createElement(index$5.$ea1ef594cf570d83$export$439d29a4e110a164, {
|
|
1064
|
-
asChild: true
|
|
1065
|
-
}, /*#__PURE__*/ React.createElement("select", _extends._extends({}, selectProps, {
|
|
1066
|
-
ref: composedRefs,
|
|
1067
|
-
defaultValue: value
|
|
1068
|
-
})));
|
|
1493
|
+
}),
|
|
1494
|
+
onPointerLeave: index.composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
|
|
1495
|
+
clearAutoScrollTimer();
|
|
1496
|
+
})
|
|
1497
|
+
}
|
|
1498
|
+
);
|
|
1069
1499
|
});
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1500
|
+
var SEPARATOR_NAME = "SelectSeparator";
|
|
1501
|
+
var SelectSeparator = React__namespace.forwardRef(
|
|
1502
|
+
(props, forwardedRef) => {
|
|
1503
|
+
const { __scopeSelect, ...separatorProps } = props;
|
|
1504
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
|
1505
|
+
}
|
|
1506
|
+
);
|
|
1507
|
+
SelectSeparator.displayName = SEPARATOR_NAME;
|
|
1508
|
+
var ARROW_NAME = "SelectArrow";
|
|
1509
|
+
var SelectArrow = React__namespace.forwardRef(
|
|
1510
|
+
(props, forwardedRef) => {
|
|
1511
|
+
const { __scopeSelect, ...arrowProps } = props;
|
|
1512
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
1513
|
+
const context = useSelectContext(ARROW_NAME, __scopeSelect);
|
|
1514
|
+
const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
|
|
1515
|
+
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
|
1516
|
+
}
|
|
1517
|
+
);
|
|
1518
|
+
SelectArrow.displayName = ARROW_NAME;
|
|
1519
|
+
function shouldShowPlaceholder(value) {
|
|
1520
|
+
return value === "" || value === void 0;
|
|
1521
|
+
}
|
|
1522
|
+
var BubbleSelect = React__namespace.forwardRef(
|
|
1523
|
+
(props, forwardedRef) => {
|
|
1524
|
+
const { value, ...selectProps } = props;
|
|
1525
|
+
const ref = React__namespace.useRef(null);
|
|
1526
|
+
const composedRefs = index.useComposedRefs(forwardedRef, ref);
|
|
1527
|
+
const prevValue = usePrevious(value);
|
|
1528
|
+
React__namespace.useEffect(() => {
|
|
1529
|
+
const select = ref.current;
|
|
1530
|
+
const selectProto = window.HTMLSelectElement.prototype;
|
|
1531
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1532
|
+
selectProto,
|
|
1533
|
+
"value"
|
|
1534
|
+
);
|
|
1535
|
+
const setValue = descriptor.set;
|
|
1536
|
+
if (prevValue !== value && setValue) {
|
|
1537
|
+
const event = new Event("change", { bubbles: true });
|
|
1538
|
+
setValue.call(select, value);
|
|
1539
|
+
select.dispatchEvent(event);
|
|
1540
|
+
}
|
|
1541
|
+
}, [prevValue, value]);
|
|
1542
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("select", { ...selectProps, ref: composedRefs, defaultValue: value }) });
|
|
1543
|
+
}
|
|
1544
|
+
);
|
|
1545
|
+
BubbleSelect.displayName = "BubbleSelect";
|
|
1546
|
+
function useTypeaheadSearch(onSearchChange) {
|
|
1547
|
+
const handleSearchChange = index.useCallbackRef(onSearchChange);
|
|
1548
|
+
const searchRef = React__namespace.useRef("");
|
|
1549
|
+
const timerRef = React__namespace.useRef(0);
|
|
1550
|
+
const handleTypeaheadSearch = React__namespace.useCallback(
|
|
1551
|
+
(key) => {
|
|
1552
|
+
const search = searchRef.current + key;
|
|
1553
|
+
handleSearchChange(search);
|
|
1554
|
+
(function updateSearch(value) {
|
|
1555
|
+
searchRef.current = value;
|
|
1089
1556
|
window.clearTimeout(timerRef.current);
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1557
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
1558
|
+
})(search);
|
|
1559
|
+
},
|
|
1560
|
+
[handleSearchChange]
|
|
1561
|
+
);
|
|
1562
|
+
const resetTypeahead = React__namespace.useCallback(() => {
|
|
1563
|
+
searchRef.current = "";
|
|
1564
|
+
window.clearTimeout(timerRef.current);
|
|
1565
|
+
}, []);
|
|
1566
|
+
React__namespace.useEffect(() => {
|
|
1567
|
+
return () => window.clearTimeout(timerRef.current);
|
|
1568
|
+
}, []);
|
|
1569
|
+
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
|
1100
1570
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
*
|
|
1113
|
-
* Finally, if the normalized search is exactly one character, we exclude the
|
|
1114
|
-
* current item from the values because otherwise it would be the first to match always
|
|
1115
|
-
* and focus would never move. This is as opposed to the regular case, where we
|
|
1116
|
-
* don't want focus to move if the current item still matches.
|
|
1117
|
-
*/ function $cc7e05a45900e73f$var$findNextItem(items, search, currentItem) {
|
|
1118
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char)=>char === search[0]
|
|
1119
|
-
);
|
|
1120
|
-
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1121
|
-
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
1122
|
-
let wrappedItems = $cc7e05a45900e73f$var$wrapArray(items, Math.max(currentItemIndex, 0));
|
|
1123
|
-
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
1124
|
-
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v)=>v !== currentItem
|
|
1125
|
-
);
|
|
1126
|
-
const nextItem = wrappedItems.find((item)=>item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
1127
|
-
);
|
|
1128
|
-
return nextItem !== currentItem ? nextItem : undefined;
|
|
1571
|
+
function findNextItem(items, search, currentItem) {
|
|
1572
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
1573
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1574
|
+
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
1575
|
+
let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
|
|
1576
|
+
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
1577
|
+
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
|
|
1578
|
+
const nextItem = wrappedItems.find(
|
|
1579
|
+
(item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
1580
|
+
);
|
|
1581
|
+
return nextItem !== currentItem ? nextItem : void 0;
|
|
1129
1582
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
* Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
|
|
1133
|
-
*/ function $cc7e05a45900e73f$var$wrapArray(array, startIndex) {
|
|
1134
|
-
return array.map((_, index)=>array[(startIndex + index) % array.length]
|
|
1135
|
-
);
|
|
1583
|
+
function wrapArray(array, startIndex) {
|
|
1584
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
1136
1585
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1586
|
+
var Root2 = Select$1;
|
|
1587
|
+
var Trigger = SelectTrigger;
|
|
1588
|
+
var Value = SelectValue;
|
|
1589
|
+
var Icon = SelectIcon;
|
|
1590
|
+
var Portal = SelectPortal;
|
|
1591
|
+
var Content2 = SelectContent;
|
|
1592
|
+
var Viewport = SelectViewport;
|
|
1593
|
+
var Item = SelectItem;
|
|
1594
|
+
var ItemText = SelectItemText;
|
|
1595
|
+
var ItemIndicator = SelectItemIndicator;
|
|
1596
|
+
var ScrollUpButton = SelectScrollUpButton;
|
|
1597
|
+
var ScrollDownButton = SelectScrollDownButton;
|
|
1149
1598
|
|
|
1150
1599
|
const BtIconChevronUp2Px = (props) =>
|
|
1151
1600
|
/*#__PURE__*/ React__default["default"].createElement(
|
|
@@ -1193,35 +1642,35 @@ var Select = function (_a) {
|
|
|
1193
1642
|
}
|
|
1194
1643
|
};
|
|
1195
1644
|
return (React__default["default"].createElement(FormControl.FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, hideLabel: hideLabel, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", isDisabled: isDisabled, disclosureText: disclosureText, disclosureTitle: disclosureTitle, onClickDisclosure: onClickDisclosure },
|
|
1196
|
-
React__default["default"].createElement(
|
|
1645
|
+
React__default["default"].createElement(Root2, { name: name, required: isRequired, disabled: isDisabled, defaultOpen: isDefaultOpen, value: selectValue, onOpenChange: onOpenChange, onValueChange: function (value) { return onValueChange(value); } },
|
|
1197
1646
|
React__default["default"].createElement("div", { className: "arc-Select-wrapper" },
|
|
1198
|
-
React__default["default"].createElement(
|
|
1647
|
+
React__default["default"].createElement(Trigger, filterDataAttrs.__assign({ id: id, name: name, onBlur: onBlur, "aria-label": ariaLabel, style: { width: width }, className: index$1.classNames("arc-Select-trigger", (_b = {
|
|
1199
1648
|
"arc-Select-trigger--constrained": !isFluid,
|
|
1200
1649
|
"arc-Select-trigger--onDarkSurface": surface === "dark",
|
|
1201
1650
|
"arc-Select-trigger--invalid": errorMessage
|
|
1202
1651
|
},
|
|
1203
1652
|
_b["arc-Select-trigger--size".concat(selectSize && selectSize.toUpperCase())] = selectSize && selectSize !== "m",
|
|
1204
1653
|
_b)), "aria-describedby": "".concat(id, "-helper") }, filterDataAttrs.filterDataAttrs(props)),
|
|
1205
|
-
React__default["default"].createElement(
|
|
1206
|
-
React__default["default"].createElement(
|
|
1207
|
-
React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronDown2Px_esm.BtIconChevronDown2Px, size: getIconSize(selectSize) }))),
|
|
1208
|
-
React__default["default"].createElement(
|
|
1209
|
-
React__default["default"].createElement(
|
|
1654
|
+
React__default["default"].createElement(Value, { className: "arc-Select-triggerText", placeholder: placeholder, "aria-label": getSelectedValueName(uncontrolledValue) }),
|
|
1655
|
+
React__default["default"].createElement(Icon, { className: "arc-Select-triggerIcon" },
|
|
1656
|
+
React__default["default"].createElement(Icon$1.Icon, { icon: BtIconChevronDown2Px_esm.BtIconChevronDown2Px, size: getIconSize(selectSize) }))),
|
|
1657
|
+
React__default["default"].createElement(Portal, { container: arcRootElement || undefined },
|
|
1658
|
+
React__default["default"].createElement(Content2, { sideOffset: 5, position: "popper", className: index$1.classNames("arc-Select-content", {
|
|
1210
1659
|
"arc-Select-content--onDarkSurface": surface === "dark"
|
|
1211
1660
|
}) },
|
|
1212
|
-
React__default["default"].createElement(
|
|
1213
|
-
React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronUp2Px, size: 16 })),
|
|
1214
|
-
React__default["default"].createElement(
|
|
1661
|
+
React__default["default"].createElement(ScrollUpButton, { className: "arc-Select-scrollButton" },
|
|
1662
|
+
React__default["default"].createElement(Icon$1.Icon, { icon: BtIconChevronUp2Px, size: 16 })),
|
|
1663
|
+
React__default["default"].createElement(Viewport, null, options.map(function (_a, i) {
|
|
1215
1664
|
var name = _a.name, value = _a.value;
|
|
1216
|
-
return (React__default["default"].createElement(
|
|
1665
|
+
return (React__default["default"].createElement(Item, { className: "arc-Select-item", key: "select-item-".concat(i), value: value },
|
|
1217
1666
|
React__default["default"].createElement("div", { className: "arc-Select-itemTextWrapper" },
|
|
1218
|
-
React__default["default"].createElement(
|
|
1667
|
+
React__default["default"].createElement(ItemText, { asChild: true },
|
|
1219
1668
|
React__default["default"].createElement("span", { className: "arc-Select-itemText" }, name))),
|
|
1220
|
-
React__default["default"].createElement(
|
|
1221
|
-
React__default["default"].createElement(Icon.Icon, { icon: BtIconTickAlt2Px_esm.BtIconTickAlt2Px, size: 20 }))));
|
|
1669
|
+
React__default["default"].createElement(ItemIndicator, null,
|
|
1670
|
+
React__default["default"].createElement(Icon$1.Icon, { icon: BtIconTickAlt2Px_esm.BtIconTickAlt2Px, size: 20 }))));
|
|
1222
1671
|
})),
|
|
1223
|
-
React__default["default"].createElement(
|
|
1224
|
-
React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronDown2Px_esm.BtIconChevronDown2Px, size: 16 }))))))));
|
|
1672
|
+
React__default["default"].createElement(ScrollDownButton, { className: "arc-Select-scrollButton" },
|
|
1673
|
+
React__default["default"].createElement(Icon$1.Icon, { icon: BtIconChevronDown2Px_esm.BtIconChevronDown2Px, size: 16 }))))))));
|
|
1225
1674
|
};
|
|
1226
1675
|
|
|
1227
1676
|
exports.Select = Select;
|