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