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