@arc-ui/components 11.0.0 → 11.2.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 (142) hide show
  1. package/dist/Align/Align.esm.js +4 -4
  2. package/dist/Badge/Badge.cjs.d.ts +26 -0
  3. package/dist/Badge/Badge.cjs.js +37 -0
  4. package/dist/Badge/Badge.esm.d.ts +26 -0
  5. package/dist/Badge/Badge.esm.js +29 -0
  6. package/dist/Badge/package.json +7 -0
  7. package/dist/Base/Base.cjs.d.ts +1 -16
  8. package/dist/Base/Base.cjs.js +4 -16
  9. package/dist/Base/Base.esm.d.ts +1 -16
  10. package/dist/Base/Base.esm.js +3 -15
  11. package/dist/BrandLogo/BrandLogo.esm.d.ts +1 -1
  12. package/dist/BrandLogo/BrandLogo.esm.js +2 -2
  13. package/dist/Breadcrumbs/Breadcrumbs.esm.js +27 -27
  14. package/dist/Button/Button.esm.d.ts +1 -1
  15. package/dist/Button/Button.esm.js +4 -4
  16. package/dist/Card/Card.esm.js +27 -27
  17. package/dist/Checkbox/Checkbox.cjs.js +4 -1
  18. package/dist/Checkbox/Checkbox.esm.js +18 -15
  19. package/dist/Clock/Clock.esm.js +3 -3
  20. package/dist/Columns/Columns.esm.js +5 -5
  21. package/dist/Curve/Curve.esm.d.ts +1 -1
  22. package/dist/Curve/Curve.esm.js +1 -1
  23. package/dist/Disclosure/Disclosure.esm.d.ts +1 -1
  24. package/dist/Disclosure/Disclosure.esm.js +10 -10
  25. package/dist/Elevation/Elevation.esm.js +2 -2
  26. package/dist/FormControl/FormControl.cjs.d.ts +1 -1
  27. package/dist/FormControl/FormControl.cjs.js +4 -1
  28. package/dist/FormControl/FormControl.esm.d.ts +1 -1
  29. package/dist/FormControl/FormControl.esm.js +5 -2
  30. package/dist/Group/Group.esm.js +6 -6
  31. package/dist/Heading/Heading.esm.d.ts +1 -1
  32. package/dist/Heading/Heading.esm.js +2 -2
  33. package/dist/Icon/Icon.esm.d.ts +1 -1
  34. package/dist/Icon/Icon.esm.js +2 -2
  35. package/dist/Image/Image.esm.d.ts +1 -1
  36. package/dist/Image/Image.esm.js +1 -1
  37. package/dist/Markup/Markup.esm.js +3 -3
  38. package/dist/Poster/Poster.esm.d.ts +1 -1
  39. package/dist/Poster/Poster.esm.js +9 -9
  40. package/dist/RadioGroup/RadioGroup.cjs.d.ts +1 -1
  41. package/dist/RadioGroup/RadioGroup.cjs.js +4 -1
  42. package/dist/RadioGroup/RadioGroup.esm.d.ts +1 -1
  43. package/dist/RadioGroup/RadioGroup.esm.js +15 -12
  44. package/dist/Rule/Rule.esm.js +3 -3
  45. package/dist/Section/Section.esm.d.ts +1 -1
  46. package/dist/Section/Section.esm.js +1 -1
  47. package/dist/Select/Select.cjs.d.ts +25 -0
  48. package/dist/Select/Select.cjs.js +2611 -0
  49. package/dist/Select/Select.esm.d.ts +25 -0
  50. package/dist/Select/Select.esm.js +2584 -0
  51. package/dist/Select/package.json +7 -0
  52. package/dist/SiteFooter/SiteFooter.esm.js +33 -33
  53. package/dist/SiteHeader/SiteHeader.esm.d.ts +1 -1
  54. package/dist/SiteHeader/SiteHeader.esm.js +98 -98
  55. package/dist/Surface/Surface.esm.d.ts +1 -1
  56. package/dist/Surface/Surface.esm.js +1 -1
  57. package/dist/Switch/Switch.cjs.d.ts +40 -0
  58. package/dist/Switch/Switch.cjs.js +210 -0
  59. package/dist/Switch/Switch.esm.d.ts +40 -0
  60. package/dist/Switch/Switch.esm.js +202 -0
  61. package/dist/Switch/package.json +7 -0
  62. package/dist/Text/Text.esm.d.ts +1 -1
  63. package/dist/Text/Text.esm.js +2 -2
  64. package/dist/TextInput/TextInput.cjs.d.ts +5 -1
  65. package/dist/TextInput/TextInput.cjs.js +25 -6
  66. package/dist/TextInput/TextInput.esm.d.ts +5 -1
  67. package/dist/TextInput/TextInput.esm.js +28 -9
  68. package/dist/Truncate/Truncate.cjs.d.ts +18 -0
  69. package/dist/Truncate/Truncate.cjs.js +17 -0
  70. package/dist/Truncate/Truncate.esm.d.ts +18 -0
  71. package/dist/Truncate/Truncate.esm.js +9 -0
  72. package/dist/Truncate/package.json +7 -0
  73. package/dist/UniversalHeader/UniversalHeader.esm.js +8 -8
  74. package/dist/VerticalSpace/VerticalSpace.cjs.d.ts +1 -18
  75. package/dist/VerticalSpace/VerticalSpace.cjs.js +5 -20
  76. package/dist/VerticalSpace/VerticalSpace.esm.d.ts +1 -18
  77. package/dist/VerticalSpace/VerticalSpace.esm.js +4 -19
  78. package/dist/VisuallyHidden/VisuallyHidden.cjs.d.ts +1 -12
  79. package/dist/VisuallyHidden/VisuallyHidden.cjs.js +3 -12
  80. package/dist/VisuallyHidden/VisuallyHidden.esm.d.ts +1 -12
  81. package/dist/VisuallyHidden/VisuallyHidden.esm.js +2 -11
  82. package/dist/_shared/cjs/Base-e2b846fe.d.ts +19 -0
  83. package/dist/_shared/cjs/Base-e2b846fe.js +22 -0
  84. package/dist/_shared/cjs/BtIconTickAlt2Px-b12ecc78.js +425 -0
  85. package/dist/_shared/cjs/{FormControl-a1b7421b.d.ts → FormControl-e6b7d7c5.d.ts} +51 -3
  86. package/dist/_shared/cjs/{FormControl-a1b7421b.js → FormControl-e6b7d7c5.js} +40 -8
  87. package/dist/_shared/cjs/VerticalSpace-65ad083c.d.ts +18 -0
  88. package/dist/_shared/cjs/VerticalSpace-65ad083c.js +25 -0
  89. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.d.ts +12 -0
  90. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.js +17 -0
  91. package/dist/_shared/cjs/index-c81c9401.d.ts +1 -1
  92. package/dist/_shared/esm/Base-c235dc45.d.ts +19 -0
  93. package/dist/_shared/esm/Base-c235dc45.js +15 -0
  94. package/dist/_shared/esm/{BrandLogo-ea3dd0e6.js → BrandLogo-4f13fe85.js} +4 -4
  95. package/dist/_shared/esm/{BtIconChevronDown2Px-4abd079b.js → BtIconChevronDown2Px-782876e2.js} +2 -2
  96. package/dist/_shared/esm/{BtIconChevronRight2Px-a5cc1d05.js → BtIconChevronRight2Px-b8e7b4ad.js} +3 -3
  97. package/dist/_shared/esm/{BtIconChevronRightMid-386cf272.js → BtIconChevronRightMid-d9b11761.js} +2 -2
  98. package/dist/_shared/esm/BtIconTickAlt2Px-2c4ec3be.js +408 -0
  99. package/dist/_shared/esm/{Button-5ff56a7b.js → Button-69439f8f.js} +15 -15
  100. package/dist/_shared/esm/{Curve-cfdca379.js → Curve-50697f7e.js} +2 -2
  101. package/dist/_shared/esm/{FormControl-feedc495.d.ts → FormControl-84c9ace6.d.ts} +51 -3
  102. package/dist/_shared/esm/FormControl-84c9ace6.js +138 -0
  103. package/dist/_shared/esm/{Heading-183be76c.js → Heading-eb1e42db.js} +4 -4
  104. package/dist/_shared/esm/{Icon-76d0d8c0.js → Icon-61f7237a.js} +5 -5
  105. package/dist/_shared/esm/{Image-7e4948f6.js → Image-c0f3d42f.js} +7 -7
  106. package/dist/_shared/esm/{Section-f1256c87.js → Section-7bc71e26.js} +2 -2
  107. package/dist/_shared/esm/{Surface-d515d212.js → Surface-bf201530.js} +3 -3
  108. package/dist/_shared/esm/{Text-d8988620.js → Text-6b958ad8.js} +3 -3
  109. package/dist/_shared/esm/VerticalSpace-6b4f5e50.d.ts +18 -0
  110. package/dist/_shared/esm/VerticalSpace-6b4f5e50.js +19 -0
  111. package/dist/_shared/esm/VisuallyHidden-b9eebf71.d.ts +12 -0
  112. package/dist/_shared/esm/VisuallyHidden-b9eebf71.js +11 -0
  113. package/dist/_shared/esm/index-c81c9401.d.ts +1 -1
  114. package/dist/index.es.js +34623 -529
  115. package/dist/index.es.js.map +1 -1
  116. package/dist/index.js +34527 -411
  117. package/dist/index.js.map +1 -1
  118. package/dist/styles.css +1 -1
  119. package/dist/types/components/Badge/Badge.d.ts +25 -0
  120. package/dist/types/components/Badge/index.d.ts +1 -0
  121. package/dist/types/components/FormControl/FormControl.d.ts +17 -0
  122. package/dist/types/components/FormControl/FormControlDisclosure/FormControlDisclosure.d.ts +28 -0
  123. package/dist/types/components/FormControl/FormControlDisclosure/index.d.ts +1 -0
  124. package/dist/types/components/Select/Select.d.ts +2 -1
  125. package/dist/types/components/Switch/Switch.d.ts +13 -8
  126. package/dist/types/components/TextInput/TextInput.d.ts +4 -0
  127. package/dist/types/components/Truncate/Truncate.d.ts +17 -0
  128. package/dist/types/components/Truncate/index.d.ts +1 -0
  129. package/dist/types/components/index.d.ts +4 -0
  130. package/dist/types/hooks/use-aria-describedby.d.ts +5 -1
  131. package/dist/types/styles.d.ts +4 -0
  132. package/package.json +4 -4
  133. package/dist/_shared/esm/FormControl-feedc495.js +0 -106
  134. /package/dist/_shared/esm/{BrandLogo-ea3dd0e6.d.ts → BrandLogo-4f13fe85.d.ts} +0 -0
  135. /package/dist/_shared/esm/{Button-5ff56a7b.d.ts → Button-69439f8f.d.ts} +0 -0
  136. /package/dist/_shared/esm/{Curve-cfdca379.d.ts → Curve-50697f7e.d.ts} +0 -0
  137. /package/dist/_shared/esm/{Heading-183be76c.d.ts → Heading-eb1e42db.d.ts} +0 -0
  138. /package/dist/_shared/esm/{Icon-76d0d8c0.d.ts → Icon-61f7237a.d.ts} +0 -0
  139. /package/dist/_shared/esm/{Image-7e4948f6.d.ts → Image-c0f3d42f.d.ts} +0 -0
  140. /package/dist/_shared/esm/{Section-f1256c87.d.ts → Section-7bc71e26.d.ts} +0 -0
  141. /package/dist/_shared/esm/{Surface-d515d212.d.ts → Surface-bf201530.d.ts} +0 -0
  142. /package/dist/_shared/esm/{Text-d8988620.d.ts → Text-6b958ad8.d.ts} +0 -0
@@ -0,0 +1,2584 @@
1
+ import { c as classNames } from '../_shared/esm/index-2ae58626.js';
2
+ import * as React$1 from 'react';
3
+ import React__default, { useContext, createContext, useEffect, forwardRef, useState, createElement, useRef, useCallback, Fragment, useMemo, useId } from 'react';
4
+ import { $ as $c512c27ab02ef895$export$50c7b4e9d9f19c1, a as $6ed0406888f73fc4$export$c7b2cbe3552a0d05, b as $5e63c961fc1ce211$export$8c6ed5c666ac1360, c as $b1b2314f5f9a1d84$export$25bec8c6f54ee79a, d as $8927f6f2acc4f386$export$250ffa63cdc0d034, _ as _extends, e as $e42e1063c40fb3ef$export$b9ecd428b558ff10, f as $8927f6f2acc4f386$export$6d1a0317bde7de7f, g as $9f79659886946c16$export$e5c5a5f917a5871c, h as $71cd76cc60e0454e$export$6f32135080cb4c3, i as $010c2913dbd2fe3d$export$5cae361ad82dce8b, B as BtIconTickAlt2Px_2 } from '../_shared/esm/BtIconTickAlt2Px-2c4ec3be.js';
5
+ import $7SXl2$reactdom, { createPortal } from 'react-dom';
6
+ import { B as BtIconChevronDown2Px_2 } from '../_shared/esm/BtIconChevronDown2Px-782876e2.js';
7
+ import { I as Icon } from '../_shared/esm/Icon-61f7237a.js';
8
+ import { F as FormControl } from '../_shared/esm/FormControl-84c9ace6.js';
9
+ import { C as Context } from '../_shared/esm/Surface-bf201530.js';
10
+ import { A as ArcRootElementContext } from '../_shared/esm/Base-c235dc45.js';
11
+ import '../_shared/esm/index-229fc864.js';
12
+ import '../_shared/esm/suffix-modifier-f5e28822.js';
13
+ import '../_shared/esm/Text-6b958ad8.js';
14
+ import '../_shared/esm/BtIconChevronRightMid-d9b11761.js';
15
+
16
+ function $ae6933e535247d3d$export$7d15b64cf5a3a4c4(value, [min, max]) {
17
+ return Math.min(max, Math.max(min, value));
18
+ }
19
+
20
+ // We have resorted to returning slots directly rather than exposing primitives that can then
21
+ // be slotted like `<CollectionItem as={Slot}>…</CollectionItem>`.
22
+ // This is because we encountered issues with generic types that cannot be statically analysed
23
+ // due to creating them dynamically via createCollection.
24
+ function $e02a7d9cb1dc128c$export$c74125a8e3af6bb2(name) {
25
+ /* -----------------------------------------------------------------------------------------------
26
+ * CollectionProvider
27
+ * ---------------------------------------------------------------------------------------------*/ const PROVIDER_NAME = name + 'CollectionProvider';
28
+ const [createCollectionContext, createCollectionScope] = $c512c27ab02ef895$export$50c7b4e9d9f19c1(PROVIDER_NAME);
29
+ const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
30
+ collectionRef: {
31
+ current: null
32
+ },
33
+ itemMap: new Map()
34
+ });
35
+ const CollectionProvider = (props)=>{
36
+ const { scope: scope , children: children } = props;
37
+ const ref = React__default.useRef(null);
38
+ const itemMap = React__default.useRef(new Map()).current;
39
+ return /*#__PURE__*/ React__default.createElement(CollectionProviderImpl, {
40
+ scope: scope,
41
+ itemMap: itemMap,
42
+ collectionRef: ref
43
+ }, children);
44
+ };
45
+ /* -----------------------------------------------------------------------------------------------
46
+ * CollectionSlot
47
+ * ---------------------------------------------------------------------------------------------*/ const COLLECTION_SLOT_NAME = name + 'CollectionSlot';
48
+ const CollectionSlot = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
49
+ const { scope: scope , children: children } = props;
50
+ const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
51
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.collectionRef);
52
+ return /*#__PURE__*/ React__default.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
53
+ ref: composedRefs
54
+ }, children);
55
+ });
56
+ /* -----------------------------------------------------------------------------------------------
57
+ * CollectionItem
58
+ * ---------------------------------------------------------------------------------------------*/ const ITEM_SLOT_NAME = name + 'CollectionItemSlot';
59
+ const ITEM_DATA_ATTR = 'data-radix-collection-item';
60
+ const CollectionItemSlot = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
61
+ const { scope: scope , children: children , ...itemData } = props;
62
+ const ref = React__default.useRef(null);
63
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
64
+ const context = useCollectionContext(ITEM_SLOT_NAME, scope);
65
+ React__default.useEffect(()=>{
66
+ context.itemMap.set(ref, {
67
+ ref: ref,
68
+ ...itemData
69
+ });
70
+ return ()=>void context.itemMap.delete(ref)
71
+ ;
72
+ });
73
+ return /*#__PURE__*/ React__default.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
74
+ [ITEM_DATA_ATTR]: '',
75
+ ref: composedRefs
76
+ }, children);
77
+ });
78
+ /* -----------------------------------------------------------------------------------------------
79
+ * useCollection
80
+ * ---------------------------------------------------------------------------------------------*/ function useCollection(scope) {
81
+ const context = useCollectionContext(name + 'CollectionConsumer', scope);
82
+ const getItems = React__default.useCallback(()=>{
83
+ const collectionNode = context.collectionRef.current;
84
+ if (!collectionNode) return [];
85
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
86
+ const items = Array.from(context.itemMap.values());
87
+ const orderedItems = items.sort((a, b)=>orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
88
+ );
89
+ return orderedItems;
90
+ }, [
91
+ context.collectionRef,
92
+ context.itemMap
93
+ ]);
94
+ return getItems;
95
+ }
96
+ return [
97
+ {
98
+ Provider: CollectionProvider,
99
+ Slot: CollectionSlot,
100
+ ItemSlot: CollectionItemSlot
101
+ },
102
+ useCollection,
103
+ createCollectionScope
104
+ ];
105
+ }
106
+
107
+ const $f631663db3294ace$var$DirectionContext = /*#__PURE__*/ createContext(undefined);
108
+ /* -----------------------------------------------------------------------------------------------*/ function $f631663db3294ace$export$b39126d51d94e6f3(localDir) {
109
+ const globalDir = useContext($f631663db3294ace$var$DirectionContext);
110
+ return localDir || globalDir || 'ltr';
111
+ }
112
+
113
+ /**
114
+ * Listens for when the escape key is down
115
+ */ function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
116
+ const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp);
117
+ useEffect(()=>{
118
+ const handleKeyDown = (event)=>{
119
+ if (event.key === 'Escape') onEscapeKeyDown(event);
120
+ };
121
+ ownerDocument.addEventListener('keydown', handleKeyDown);
122
+ return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown)
123
+ ;
124
+ }, [
125
+ onEscapeKeyDown,
126
+ ownerDocument
127
+ ]);
128
+ }
129
+
130
+ const $5cb92bef7577960e$var$CONTEXT_UPDATE = 'dismissableLayer.update';
131
+ const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';
132
+ const $5cb92bef7577960e$var$FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';
133
+ let $5cb92bef7577960e$var$originalBodyPointerEvents;
134
+ const $5cb92bef7577960e$var$DismissableLayerContext = /*#__PURE__*/ createContext({
135
+ layers: new Set(),
136
+ layersWithOutsidePointerEventsDisabled: new Set(),
137
+ branches: new Set()
138
+ });
139
+ const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
140
+ var _node$ownerDocument;
141
+ const { disableOutsidePointerEvents: disableOutsidePointerEvents = false , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , onFocusOutside: onFocusOutside , onInteractOutside: onInteractOutside , onDismiss: onDismiss , ...layerProps } = props;
142
+ const context = useContext($5cb92bef7577960e$var$DismissableLayerContext);
143
+ const [node1, setNode] = useState(null);
144
+ const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
145
+ const [, force] = useState({});
146
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setNode(node)
147
+ );
148
+ const layers = Array.from(context.layers);
149
+ const [highestLayerWithOutsidePointerEventsDisabled] = [
150
+ ...context.layersWithOutsidePointerEventsDisabled
151
+ ].slice(-1); // prettier-ignore
152
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); // prettier-ignore
153
+ const index = node1 ? layers.indexOf(node1) : -1;
154
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
155
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
156
+ const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event)=>{
157
+ const target = event.target;
158
+ const isPointerDownOnBranch = [
159
+ ...context.branches
160
+ ].some((branch)=>branch.contains(target)
161
+ );
162
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
163
+ onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event);
164
+ onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
165
+ if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
166
+ }, ownerDocument);
167
+ const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event)=>{
168
+ const target = event.target;
169
+ const isFocusInBranch = [
170
+ ...context.branches
171
+ ].some((branch)=>branch.contains(target)
172
+ );
173
+ if (isFocusInBranch) return;
174
+ onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event);
175
+ onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
176
+ if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
177
+ }, ownerDocument);
178
+ $addc16e1bbe58fd0$export$3a72a57244d6e765((event)=>{
179
+ const isHighestLayer = index === context.layers.size - 1;
180
+ if (!isHighestLayer) return;
181
+ onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event);
182
+ if (!event.defaultPrevented && onDismiss) {
183
+ event.preventDefault();
184
+ onDismiss();
185
+ }
186
+ }, ownerDocument);
187
+ useEffect(()=>{
188
+ if (!node1) return;
189
+ if (disableOutsidePointerEvents) {
190
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
191
+ $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
192
+ ownerDocument.body.style.pointerEvents = 'none';
193
+ }
194
+ context.layersWithOutsidePointerEventsDisabled.add(node1);
195
+ }
196
+ context.layers.add(node1);
197
+ $5cb92bef7577960e$var$dispatchUpdate();
198
+ return ()=>{
199
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents;
200
+ };
201
+ }, [
202
+ node1,
203
+ ownerDocument,
204
+ disableOutsidePointerEvents,
205
+ context
206
+ ]);
207
+ /**
208
+ * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect
209
+ * because a change to `disableOutsidePointerEvents` would remove this layer from the stack
210
+ * and add it to the end again so the layering order wouldn't be _creation order_.
211
+ * We only want them to be removed from context stacks when unmounted.
212
+ */ useEffect(()=>{
213
+ return ()=>{
214
+ if (!node1) return;
215
+ context.layers.delete(node1);
216
+ context.layersWithOutsidePointerEventsDisabled.delete(node1);
217
+ $5cb92bef7577960e$var$dispatchUpdate();
218
+ };
219
+ }, [
220
+ node1,
221
+ context
222
+ ]);
223
+ useEffect(()=>{
224
+ const handleUpdate = ()=>force({})
225
+ ;
226
+ document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
227
+ return ()=>document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate)
228
+ ;
229
+ }, []);
230
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, layerProps, {
231
+ ref: composedRefs,
232
+ style: {
233
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? 'auto' : 'none' : undefined,
234
+ ...props.style
235
+ },
236
+ onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture),
237
+ onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture),
238
+ onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
239
+ }));
240
+ });
241
+ /* -----------------------------------------------------------------------------------------------*/ /**
242
+ * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`
243
+ * to mimic layer dismissing behaviour present in OS.
244
+ * Returns props to pass to the node we want to check for outside events.
245
+ */ function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
246
+ const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside);
247
+ const isPointerInsideReactTreeRef = useRef(false);
248
+ const handleClickRef = useRef(()=>{});
249
+ useEffect(()=>{
250
+ const handlePointerDown = (event)=>{
251
+ if (event.target && !isPointerInsideReactTreeRef.current) {
252
+ const eventDetail = {
253
+ originalEvent: event
254
+ };
255
+ function handleAndDispatchPointerDownOutsideEvent() {
256
+ $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
257
+ discrete: true
258
+ });
259
+ }
260
+ /**
261
+ * On touch devices, we need to wait for a click event because browsers implement
262
+ * a ~350ms delay between the time the user stops touching the display and when the
263
+ * browser executres events. We need to ensure we don't reactivate pointer-events within
264
+ * this timeframe otherwise the browser may execute events that should have been prevented.
265
+ *
266
+ * Additionally, this also lets us deal automatically with cancellations when a click event
267
+ * isn't raised because the page was considered scrolled/drag-scrolled, long-pressed, etc.
268
+ *
269
+ * This is why we also continuously remove the previous listener, because we cannot be
270
+ * certain that it was raised, and therefore cleaned-up.
271
+ */ if (event.pointerType === 'touch') {
272
+ ownerDocument.removeEventListener('click', handleClickRef.current);
273
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
274
+ ownerDocument.addEventListener('click', handleClickRef.current, {
275
+ once: true
276
+ });
277
+ } else handleAndDispatchPointerDownOutsideEvent();
278
+ }
279
+ isPointerInsideReactTreeRef.current = false;
280
+ };
281
+ /**
282
+ * if this hook executes in a component that mounts via a `pointerdown` event, the event
283
+ * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid
284
+ * this by delaying the event listener registration on the document.
285
+ * This is not React specific, but rather how the DOM works, ie:
286
+ * ```
287
+ * button.addEventListener('pointerdown', () => {
288
+ * console.log('I will log');
289
+ * document.addEventListener('pointerdown', () => {
290
+ * console.log('I will also log');
291
+ * })
292
+ * });
293
+ */ const timerId = window.setTimeout(()=>{
294
+ ownerDocument.addEventListener('pointerdown', handlePointerDown);
295
+ }, 0);
296
+ return ()=>{
297
+ window.clearTimeout(timerId);
298
+ ownerDocument.removeEventListener('pointerdown', handlePointerDown);
299
+ ownerDocument.removeEventListener('click', handleClickRef.current);
300
+ };
301
+ }, [
302
+ ownerDocument,
303
+ handlePointerDownOutside
304
+ ]);
305
+ return {
306
+ // ensures we check React component tree (not just DOM tree)
307
+ onPointerDownCapture: ()=>isPointerInsideReactTreeRef.current = true
308
+ };
309
+ }
310
+ /**
311
+ * Listens for when focus happens outside a react subtree.
312
+ * Returns props to pass to the root (node) of the subtree we want to check.
313
+ */ function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
314
+ const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside);
315
+ const isFocusInsideReactTreeRef = useRef(false);
316
+ useEffect(()=>{
317
+ const handleFocus = (event)=>{
318
+ if (event.target && !isFocusInsideReactTreeRef.current) {
319
+ const eventDetail = {
320
+ originalEvent: event
321
+ };
322
+ $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
323
+ discrete: false
324
+ });
325
+ }
326
+ };
327
+ ownerDocument.addEventListener('focusin', handleFocus);
328
+ return ()=>ownerDocument.removeEventListener('focusin', handleFocus)
329
+ ;
330
+ }, [
331
+ ownerDocument,
332
+ handleFocusOutside
333
+ ]);
334
+ return {
335
+ onFocusCapture: ()=>isFocusInsideReactTreeRef.current = true
336
+ ,
337
+ onBlurCapture: ()=>isFocusInsideReactTreeRef.current = false
338
+ };
339
+ }
340
+ function $5cb92bef7577960e$var$dispatchUpdate() {
341
+ const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE);
342
+ document.dispatchEvent(event);
343
+ }
344
+ function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name, handler, detail, { discrete: discrete }) {
345
+ const target = detail.originalEvent.target;
346
+ const event = new CustomEvent(name, {
347
+ bubbles: false,
348
+ cancelable: true,
349
+ detail: detail
350
+ });
351
+ if (handler) target.addEventListener(name, handler, {
352
+ once: true
353
+ });
354
+ if (discrete) $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event);
355
+ else target.dispatchEvent(event);
356
+ }
357
+
358
+ /** Number of components which have requested interest to have focus guards */ let $3db38b7d1fb3fe6a$var$count = 0;
359
+ /**
360
+ * Injects a pair of focus guards at the edges of the whole DOM tree
361
+ * to ensure `focusin` & `focusout` events can be caught consistently.
362
+ */ function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() {
363
+ useEffect(()=>{
364
+ var _edgeGuards$, _edgeGuards$2;
365
+ const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');
366
+ document.body.insertAdjacentElement('afterbegin', (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard());
367
+ document.body.insertAdjacentElement('beforeend', (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard());
368
+ $3db38b7d1fb3fe6a$var$count++;
369
+ return ()=>{
370
+ if ($3db38b7d1fb3fe6a$var$count === 1) document.querySelectorAll('[data-radix-focus-guard]').forEach((node)=>node.remove()
371
+ );
372
+ $3db38b7d1fb3fe6a$var$count--;
373
+ };
374
+ }, []);
375
+ }
376
+ function $3db38b7d1fb3fe6a$var$createFocusGuard() {
377
+ const element = document.createElement('span');
378
+ element.setAttribute('data-radix-focus-guard', '');
379
+ element.tabIndex = 0;
380
+ element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';
381
+ return element;
382
+ }
383
+
384
+ const $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = 'focusScope.autoFocusOnMount';
385
+ const $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = 'focusScope.autoFocusOnUnmount';
386
+ const $d3863c46a17e8a28$var$EVENT_OPTIONS = {
387
+ bubbles: false,
388
+ cancelable: true
389
+ };
390
+ const $d3863c46a17e8a28$export$20e40289641fbbb6 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
391
+ const { loop: loop = false , trapped: trapped = false , onMountAutoFocus: onMountAutoFocusProp , onUnmountAutoFocus: onUnmountAutoFocusProp , ...scopeProps } = props;
392
+ const [container1, setContainer] = useState(null);
393
+ const onMountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onMountAutoFocusProp);
394
+ const onUnmountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onUnmountAutoFocusProp);
395
+ const lastFocusedElementRef = useRef(null);
396
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContainer(node)
397
+ );
398
+ const focusScope = useRef({
399
+ paused: false,
400
+ pause () {
401
+ this.paused = true;
402
+ },
403
+ resume () {
404
+ this.paused = false;
405
+ }
406
+ }).current; // Takes care of trapping focus if focus is moved outside programmatically for example
407
+ useEffect(()=>{
408
+ if (trapped) {
409
+ function handleFocusIn(event) {
410
+ if (focusScope.paused || !container1) return;
411
+ const target = event.target;
412
+ if (container1.contains(target)) lastFocusedElementRef.current = target;
413
+ else $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
414
+ select: true
415
+ });
416
+ }
417
+ function handleFocusOut(event) {
418
+ if (focusScope.paused || !container1) return;
419
+ if (!container1.contains(event.relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
420
+ select: true
421
+ });
422
+ }
423
+ document.addEventListener('focusin', handleFocusIn);
424
+ document.addEventListener('focusout', handleFocusOut);
425
+ return ()=>{
426
+ document.removeEventListener('focusin', handleFocusIn);
427
+ document.removeEventListener('focusout', handleFocusOut);
428
+ };
429
+ }
430
+ }, [
431
+ trapped,
432
+ container1,
433
+ focusScope.paused
434
+ ]);
435
+ useEffect(()=>{
436
+ if (container1) {
437
+ $d3863c46a17e8a28$var$focusScopesStack.add(focusScope);
438
+ const previouslyFocusedElement = document.activeElement;
439
+ const hasFocusedCandidate = container1.contains(previouslyFocusedElement);
440
+ if (!hasFocusedCandidate) {
441
+ const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
442
+ container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
443
+ container1.dispatchEvent(mountEvent);
444
+ if (!mountEvent.defaultPrevented) {
445
+ $d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), {
446
+ select: true
447
+ });
448
+ if (document.activeElement === previouslyFocusedElement) $d3863c46a17e8a28$var$focus(container1);
449
+ }
450
+ }
451
+ return ()=>{
452
+ container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); // We hit a react bug (fixed in v17) with focusing in unmount.
453
+ // We need to delay the focus a little to get around it for now.
454
+ // See: https://github.com/facebook/react/issues/17894
455
+ setTimeout(()=>{
456
+ const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
457
+ container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
458
+ container1.dispatchEvent(unmountEvent);
459
+ if (!unmountEvent.defaultPrevented) $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, {
460
+ select: true
461
+ });
462
+ // we need to remove the listener after we `dispatchEvent`
463
+ container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
464
+ $d3863c46a17e8a28$var$focusScopesStack.remove(focusScope);
465
+ }, 0);
466
+ };
467
+ }
468
+ }, [
469
+ container1,
470
+ onMountAutoFocus,
471
+ onUnmountAutoFocus,
472
+ focusScope
473
+ ]); // Takes care of looping focus (when tabbing whilst at the edges)
474
+ const handleKeyDown = useCallback((event)=>{
475
+ if (!loop && !trapped) return;
476
+ if (focusScope.paused) return;
477
+ const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;
478
+ const focusedElement = document.activeElement;
479
+ if (isTabKey && focusedElement) {
480
+ const container = event.currentTarget;
481
+ const [first, last] = $d3863c46a17e8a28$var$getTabbableEdges(container);
482
+ const hasTabbableElementsInside = first && last; // we can only wrap focus if we have tabbable edges
483
+ if (!hasTabbableElementsInside) {
484
+ if (focusedElement === container) event.preventDefault();
485
+ } else {
486
+ if (!event.shiftKey && focusedElement === last) {
487
+ event.preventDefault();
488
+ if (loop) $d3863c46a17e8a28$var$focus(first, {
489
+ select: true
490
+ });
491
+ } else if (event.shiftKey && focusedElement === first) {
492
+ event.preventDefault();
493
+ if (loop) $d3863c46a17e8a28$var$focus(last, {
494
+ select: true
495
+ });
496
+ }
497
+ }
498
+ }
499
+ }, [
500
+ loop,
501
+ trapped,
502
+ focusScope.paused
503
+ ]);
504
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
505
+ tabIndex: -1
506
+ }, scopeProps, {
507
+ ref: composedRefs,
508
+ onKeyDown: handleKeyDown
509
+ }));
510
+ });
511
+ /* -------------------------------------------------------------------------------------------------
512
+ * Utils
513
+ * -----------------------------------------------------------------------------------------------*/ /**
514
+ * Attempts focusing the first element in a list of candidates.
515
+ * Stops when focus has actually moved.
516
+ */ function $d3863c46a17e8a28$var$focusFirst(candidates, { select: select = false } = {}) {
517
+ const previouslyFocusedElement = document.activeElement;
518
+ for (const candidate of candidates){
519
+ $d3863c46a17e8a28$var$focus(candidate, {
520
+ select: select
521
+ });
522
+ if (document.activeElement !== previouslyFocusedElement) return;
523
+ }
524
+ }
525
+ /**
526
+ * Returns the first and last tabbable elements inside a container.
527
+ */ function $d3863c46a17e8a28$var$getTabbableEdges(container) {
528
+ const candidates = $d3863c46a17e8a28$var$getTabbableCandidates(container);
529
+ const first = $d3863c46a17e8a28$var$findVisible(candidates, container);
530
+ const last = $d3863c46a17e8a28$var$findVisible(candidates.reverse(), container);
531
+ return [
532
+ first,
533
+ last
534
+ ];
535
+ }
536
+ /**
537
+ * Returns a list of potential tabbable candidates.
538
+ *
539
+ * NOTE: This is only a close approximation. For example it doesn't take into account cases like when
540
+ * elements are not visible. This cannot be worked out easily by just reading a property, but rather
541
+ * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.
542
+ *
543
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
544
+ * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
545
+ */ function $d3863c46a17e8a28$var$getTabbableCandidates(container) {
546
+ const nodes = [];
547
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
548
+ acceptNode: (node)=>{
549
+ const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';
550
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP; // `.tabIndex` is not the same as the `tabindex` attribute. It works on the
551
+ // runtime's understanding of tabbability, so this automatically accounts
552
+ // for any kind of element that could be tabbed to.
553
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
554
+ }
555
+ });
556
+ while(walker.nextNode())nodes.push(walker.currentNode); // we do not take into account the order of nodes with positive `tabIndex` as it
557
+ // hinders accessibility to have tab order different from visual order.
558
+ return nodes;
559
+ }
560
+ /**
561
+ * Returns the first visible element in a list.
562
+ * NOTE: Only checks visibility up to the `container`.
563
+ */ function $d3863c46a17e8a28$var$findVisible(elements, container) {
564
+ for (const element of elements){
565
+ // we stop checking if it's hidden at the `container` level (excluding)
566
+ if (!$d3863c46a17e8a28$var$isHidden(element, {
567
+ upTo: container
568
+ })) return element;
569
+ }
570
+ }
571
+ function $d3863c46a17e8a28$var$isHidden(node, { upTo: upTo }) {
572
+ if (getComputedStyle(node).visibility === 'hidden') return true;
573
+ while(node){
574
+ // we stop at `upTo` (excluding it)
575
+ if (upTo !== undefined && node === upTo) return false;
576
+ if (getComputedStyle(node).display === 'none') return true;
577
+ node = node.parentElement;
578
+ }
579
+ return false;
580
+ }
581
+ function $d3863c46a17e8a28$var$isSelectableInput(element) {
582
+ return element instanceof HTMLInputElement && 'select' in element;
583
+ }
584
+ function $d3863c46a17e8a28$var$focus(element, { select: select = false } = {}) {
585
+ // only focus if that element is focusable
586
+ if (element && element.focus) {
587
+ const previouslyFocusedElement = document.activeElement; // NOTE: we prevent scrolling on focus, to minimize jarring transitions for users
588
+ element.focus({
589
+ preventScroll: true
590
+ }); // only select if its not the same element, it supports selection and we need to select
591
+ if (element !== previouslyFocusedElement && $d3863c46a17e8a28$var$isSelectableInput(element) && select) element.select();
592
+ }
593
+ }
594
+ /* -------------------------------------------------------------------------------------------------
595
+ * FocusScope stack
596
+ * -----------------------------------------------------------------------------------------------*/ const $d3863c46a17e8a28$var$focusScopesStack = $d3863c46a17e8a28$var$createFocusScopesStack();
597
+ function $d3863c46a17e8a28$var$createFocusScopesStack() {
598
+ /** A stack of focus scopes, with the active one at the top */ let stack = [];
599
+ return {
600
+ add (focusScope) {
601
+ // pause the currently active focus scope (at the top of the stack)
602
+ const activeFocusScope = stack[0];
603
+ if (focusScope !== activeFocusScope) activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause();
604
+ // remove in case it already exists (because we'll re-add it at the top of the stack)
605
+ stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
606
+ stack.unshift(focusScope);
607
+ },
608
+ remove (focusScope) {
609
+ var _stack$;
610
+ stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
611
+ (_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume();
612
+ }
613
+ };
614
+ }
615
+ function $d3863c46a17e8a28$var$arrayRemove(array, item) {
616
+ const updatedArray = [
617
+ ...array
618
+ ];
619
+ const index = updatedArray.indexOf(item);
620
+ if (index !== -1) updatedArray.splice(index, 1);
621
+ return updatedArray;
622
+ }
623
+ function $d3863c46a17e8a28$var$removeLinks(items) {
624
+ return items.filter((item)=>item.tagName !== 'A'
625
+ );
626
+ }
627
+
628
+ const $1746a345f3d73bb7$var$useReactId = React$1['useId'.toString()] || (()=>undefined
629
+ );
630
+ let $1746a345f3d73bb7$var$count = 0;
631
+ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
632
+ const [id, setId] = React$1.useState($1746a345f3d73bb7$var$useReactId()); // React versions older than 18 will have client-side ids only.
633
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
634
+ if (!deterministicId) setId((reactId)=>reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
635
+ );
636
+ }, [
637
+ deterministicId
638
+ ]);
639
+ return deterministicId || (id ? `radix-${id}` : '');
640
+ }
641
+
642
+ const $f1701beae083dbae$export$602eac185826482c = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
643
+ var _globalThis$document;
644
+ const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body , ...portalProps } = props;
645
+ return container ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(/*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
646
+ ref: forwardedRef
647
+ })), container) : null;
648
+ });
649
+
650
+ const $ea1ef594cf570d83$export$439d29a4e110a164 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
651
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, props, {
652
+ ref: forwardedRef,
653
+ style: {
654
+ // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
655
+ position: 'absolute',
656
+ border: 0,
657
+ width: 1,
658
+ height: 1,
659
+ padding: 0,
660
+ margin: -1,
661
+ overflow: 'hidden',
662
+ clip: 'rect(0, 0, 0, 0)',
663
+ whiteSpace: 'nowrap',
664
+ wordWrap: 'normal',
665
+ ...props.style
666
+ }
667
+ }));
668
+ });
669
+
670
+ var getDefaultParent = function (originalTarget) {
671
+ if (typeof document === 'undefined') {
672
+ return null;
673
+ }
674
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
675
+ return sampleTarget.ownerDocument.body;
676
+ };
677
+ var counterMap = new WeakMap();
678
+ var uncontrolledNodes = new WeakMap();
679
+ var markerMap = {};
680
+ var lockCount = 0;
681
+ var unwrapHost = function (node) {
682
+ return node && (node.host || unwrapHost(node.parentNode));
683
+ };
684
+ var correctTargets = function (parent, targets) {
685
+ return targets.map(function (target) {
686
+ if (parent.contains(target)) {
687
+ return target;
688
+ }
689
+ var correctedTarget = unwrapHost(target);
690
+ if (correctedTarget && parent.contains(correctedTarget)) {
691
+ return correctedTarget;
692
+ }
693
+ console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
694
+ return null;
695
+ }).filter(function (x) { return Boolean(x); });
696
+ };
697
+ /**
698
+ * Marks everything except given node(or nodes) as aria-hidden
699
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
700
+ * @param [parentNode] - top element, defaults to document.body
701
+ * @param {String} [markerName] - a special attribute to mark every node
702
+ * @param {String} [controlAttribute] - html Attribute to control
703
+ * @return {Undo} undo command
704
+ */
705
+ var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
706
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
707
+ if (!markerMap[markerName]) {
708
+ markerMap[markerName] = new WeakMap();
709
+ }
710
+ var markerCounter = markerMap[markerName];
711
+ var hiddenNodes = [];
712
+ var elementsToKeep = new Set();
713
+ var elementsToStop = new Set(targets);
714
+ var keep = function (el) {
715
+ if (!el || elementsToKeep.has(el)) {
716
+ return;
717
+ }
718
+ elementsToKeep.add(el);
719
+ keep(el.parentNode);
720
+ };
721
+ targets.forEach(keep);
722
+ var deep = function (parent) {
723
+ if (!parent || elementsToStop.has(parent)) {
724
+ return;
725
+ }
726
+ Array.prototype.forEach.call(parent.children, function (node) {
727
+ if (elementsToKeep.has(node)) {
728
+ deep(node);
729
+ }
730
+ else {
731
+ var attr = node.getAttribute(controlAttribute);
732
+ var alreadyHidden = attr !== null && attr !== 'false';
733
+ var counterValue = (counterMap.get(node) || 0) + 1;
734
+ var markerValue = (markerCounter.get(node) || 0) + 1;
735
+ counterMap.set(node, counterValue);
736
+ markerCounter.set(node, markerValue);
737
+ hiddenNodes.push(node);
738
+ if (counterValue === 1 && alreadyHidden) {
739
+ uncontrolledNodes.set(node, true);
740
+ }
741
+ if (markerValue === 1) {
742
+ node.setAttribute(markerName, 'true');
743
+ }
744
+ if (!alreadyHidden) {
745
+ node.setAttribute(controlAttribute, 'true');
746
+ }
747
+ }
748
+ });
749
+ };
750
+ deep(parentNode);
751
+ elementsToKeep.clear();
752
+ lockCount++;
753
+ return function () {
754
+ hiddenNodes.forEach(function (node) {
755
+ var counterValue = counterMap.get(node) - 1;
756
+ var markerValue = markerCounter.get(node) - 1;
757
+ counterMap.set(node, counterValue);
758
+ markerCounter.set(node, markerValue);
759
+ if (!counterValue) {
760
+ if (!uncontrolledNodes.has(node)) {
761
+ node.removeAttribute(controlAttribute);
762
+ }
763
+ uncontrolledNodes.delete(node);
764
+ }
765
+ if (!markerValue) {
766
+ node.removeAttribute(markerName);
767
+ }
768
+ });
769
+ lockCount--;
770
+ if (!lockCount) {
771
+ // clear
772
+ counterMap = new WeakMap();
773
+ counterMap = new WeakMap();
774
+ uncontrolledNodes = new WeakMap();
775
+ markerMap = {};
776
+ }
777
+ };
778
+ };
779
+ /**
780
+ * Marks everything except given node(or nodes) as aria-hidden
781
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
782
+ * @param [parentNode] - top element, defaults to document.body
783
+ * @param {String} [markerName] - a special attribute to mark every node
784
+ * @return {Undo} undo command
785
+ */
786
+ var hideOthers = function (originalTarget, parentNode, markerName) {
787
+ if (markerName === void 0) { markerName = 'data-aria-hidden'; }
788
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
789
+ var activeParentNode = parentNode || getDefaultParent(originalTarget);
790
+ if (!activeParentNode) {
791
+ return function () { return null; };
792
+ }
793
+ // we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
794
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
795
+ return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
796
+ };
797
+
798
+ /******************************************************************************
799
+ Copyright (c) Microsoft Corporation.
800
+
801
+ Permission to use, copy, modify, and/or distribute this software for any
802
+ purpose with or without fee is hereby granted.
803
+
804
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
805
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
806
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
807
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
808
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
809
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
810
+ PERFORMANCE OF THIS SOFTWARE.
811
+ ***************************************************************************** */
812
+
813
+ var __assign$1 = function() {
814
+ __assign$1 = Object.assign || function __assign(t) {
815
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
816
+ s = arguments[i];
817
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
818
+ }
819
+ return t;
820
+ };
821
+ return __assign$1.apply(this, arguments);
822
+ };
823
+
824
+ function __rest$1(s, e) {
825
+ var t = {};
826
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
827
+ t[p] = s[p];
828
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
829
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
830
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
831
+ t[p[i]] = s[p[i]];
832
+ }
833
+ return t;
834
+ }
835
+
836
+ function __spreadArray(to, from, pack) {
837
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
838
+ if (ar || !(i in from)) {
839
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
840
+ ar[i] = from[i];
841
+ }
842
+ }
843
+ return to.concat(ar || Array.prototype.slice.call(from));
844
+ }
845
+
846
+ var zeroRightClassName = 'right-scroll-bar-position';
847
+ var fullWidthClassName = 'width-before-scroll-bar';
848
+ var noScrollbarsClassName = 'with-scroll-bars-hidden';
849
+ /**
850
+ * Name of a CSS variable containing the amount of "hidden" scrollbar
851
+ * ! might be undefined ! use will fallback!
852
+ */
853
+ var removedBarSizeVariable = '--removed-body-scroll-bar-size';
854
+
855
+ /**
856
+ * Assigns a value for a given ref, no matter of the ref format
857
+ * @param {RefObject} ref - a callback function or ref object
858
+ * @param value - a new value
859
+ *
860
+ * @see https://github.com/theKashey/use-callback-ref#assignref
861
+ * @example
862
+ * const refObject = useRef();
863
+ * const refFn = (ref) => {....}
864
+ *
865
+ * assignRef(refObject, "refValue");
866
+ * assignRef(refFn, "refValue");
867
+ */
868
+ function assignRef(ref, value) {
869
+ if (typeof ref === 'function') {
870
+ ref(value);
871
+ }
872
+ else if (ref) {
873
+ ref.current = value;
874
+ }
875
+ return ref;
876
+ }
877
+
878
+ /**
879
+ * creates a MutableRef with ref change callback
880
+ * @param initialValue - initial ref value
881
+ * @param {Function} callback - a callback to run when value changes
882
+ *
883
+ * @example
884
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
885
+ * ref.current = 1;
886
+ * // prints 0 -> 1
887
+ *
888
+ * @see https://reactjs.org/docs/hooks-reference.html#useref
889
+ * @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
890
+ * @returns {MutableRefObject}
891
+ */
892
+ function useCallbackRef(initialValue, callback) {
893
+ var ref = useState(function () { return ({
894
+ // value
895
+ value: initialValue,
896
+ // last callback
897
+ callback: callback,
898
+ // "memoized" public interface
899
+ facade: {
900
+ get current() {
901
+ return ref.value;
902
+ },
903
+ set current(value) {
904
+ var last = ref.value;
905
+ if (last !== value) {
906
+ ref.value = value;
907
+ ref.callback(value, last);
908
+ }
909
+ },
910
+ },
911
+ }); })[0];
912
+ // update callback
913
+ ref.callback = callback;
914
+ return ref.facade;
915
+ }
916
+
917
+ /**
918
+ * Merges two or more refs together providing a single interface to set their value
919
+ * @param {RefObject|Ref} refs
920
+ * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
921
+ *
922
+ * @see {@link mergeRefs} a version without buit-in memoization
923
+ * @see https://github.com/theKashey/use-callback-ref#usemergerefs
924
+ * @example
925
+ * const Component = React.forwardRef((props, ref) => {
926
+ * const ownRef = useRef();
927
+ * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
928
+ * return <div ref={domRef}>...</div>
929
+ * }
930
+ */
931
+ function useMergeRefs(refs, defaultValue) {
932
+ return useCallbackRef(defaultValue || null, function (newValue) { return refs.forEach(function (ref) { return assignRef(ref, newValue); }); });
933
+ }
934
+
935
+ /*! *****************************************************************************
936
+ Copyright (c) Microsoft Corporation.
937
+
938
+ Permission to use, copy, modify, and/or distribute this software for any
939
+ purpose with or without fee is hereby granted.
940
+
941
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
942
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
943
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
944
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
945
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
946
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
947
+ PERFORMANCE OF THIS SOFTWARE.
948
+ ***************************************************************************** */
949
+
950
+ var __assign = function() {
951
+ __assign = Object.assign || function __assign(t) {
952
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
953
+ s = arguments[i];
954
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
955
+ }
956
+ return t;
957
+ };
958
+ return __assign.apply(this, arguments);
959
+ };
960
+
961
+ function __rest(s, e) {
962
+ var t = {};
963
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
964
+ t[p] = s[p];
965
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
966
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
967
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
968
+ t[p[i]] = s[p[i]];
969
+ }
970
+ return t;
971
+ }
972
+
973
+ function ItoI(a) {
974
+ return a;
975
+ }
976
+ function innerCreateMedium(defaults, middleware) {
977
+ if (middleware === void 0) { middleware = ItoI; }
978
+ var buffer = [];
979
+ var assigned = false;
980
+ var medium = {
981
+ read: function () {
982
+ if (assigned) {
983
+ throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
984
+ }
985
+ if (buffer.length) {
986
+ return buffer[buffer.length - 1];
987
+ }
988
+ return defaults;
989
+ },
990
+ useMedium: function (data) {
991
+ var item = middleware(data, assigned);
992
+ buffer.push(item);
993
+ return function () {
994
+ buffer = buffer.filter(function (x) { return x !== item; });
995
+ };
996
+ },
997
+ assignSyncMedium: function (cb) {
998
+ assigned = true;
999
+ while (buffer.length) {
1000
+ var cbs = buffer;
1001
+ buffer = [];
1002
+ cbs.forEach(cb);
1003
+ }
1004
+ buffer = {
1005
+ push: function (x) { return cb(x); },
1006
+ filter: function () { return buffer; },
1007
+ };
1008
+ },
1009
+ assignMedium: function (cb) {
1010
+ assigned = true;
1011
+ var pendingQueue = [];
1012
+ if (buffer.length) {
1013
+ var cbs = buffer;
1014
+ buffer = [];
1015
+ cbs.forEach(cb);
1016
+ pendingQueue = buffer;
1017
+ }
1018
+ var executeQueue = function () {
1019
+ var cbs = pendingQueue;
1020
+ pendingQueue = [];
1021
+ cbs.forEach(cb);
1022
+ };
1023
+ var cycle = function () { return Promise.resolve().then(executeQueue); };
1024
+ cycle();
1025
+ buffer = {
1026
+ push: function (x) {
1027
+ pendingQueue.push(x);
1028
+ cycle();
1029
+ },
1030
+ filter: function (filter) {
1031
+ pendingQueue = pendingQueue.filter(filter);
1032
+ return buffer;
1033
+ },
1034
+ };
1035
+ },
1036
+ };
1037
+ return medium;
1038
+ }
1039
+ // eslint-disable-next-line @typescript-eslint/ban-types
1040
+ function createSidecarMedium(options) {
1041
+ if (options === void 0) { options = {}; }
1042
+ var medium = innerCreateMedium(null);
1043
+ medium.options = __assign({ async: true, ssr: false }, options);
1044
+ return medium;
1045
+ }
1046
+
1047
+ var SideCar$1 = function (_a) {
1048
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
1049
+ if (!sideCar) {
1050
+ throw new Error('Sidecar: please provide `sideCar` property to import the right car');
1051
+ }
1052
+ var Target = sideCar.read();
1053
+ if (!Target) {
1054
+ throw new Error('Sidecar medium not found');
1055
+ }
1056
+ return React$1.createElement(Target, __assign({}, rest));
1057
+ };
1058
+ SideCar$1.isSideCarExport = true;
1059
+ function exportSidecar(medium, exported) {
1060
+ medium.useMedium(exported);
1061
+ return SideCar$1;
1062
+ }
1063
+
1064
+ var effectCar = createSidecarMedium();
1065
+
1066
+ var nothing = function () {
1067
+ return;
1068
+ };
1069
+ /**
1070
+ * Removes scrollbar from the page and contain the scroll within the Lock
1071
+ */
1072
+ var RemoveScroll = React$1.forwardRef(function (props, parentRef) {
1073
+ var ref = React$1.useRef(null);
1074
+ var _a = React$1.useState({
1075
+ onScrollCapture: nothing,
1076
+ onWheelCapture: nothing,
1077
+ onTouchMoveCapture: nothing,
1078
+ }), callbacks = _a[0], setCallbacks = _a[1];
1079
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, rest = __rest$1(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as"]);
1080
+ var SideCar = sideCar;
1081
+ var containerRef = useMergeRefs([ref, parentRef]);
1082
+ var containerProps = __assign$1(__assign$1({}, rest), callbacks);
1083
+ return (React$1.createElement(React$1.Fragment, null,
1084
+ enabled && (React$1.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref })),
1085
+ forwardProps ? (React$1.cloneElement(React$1.Children.only(children), __assign$1(__assign$1({}, containerProps), { ref: containerRef }))) : (React$1.createElement(Container, __assign$1({}, containerProps, { className: className, ref: containerRef }), children))));
1086
+ });
1087
+ RemoveScroll.defaultProps = {
1088
+ enabled: true,
1089
+ removeScrollBar: true,
1090
+ inert: false,
1091
+ };
1092
+ RemoveScroll.classNames = {
1093
+ fullWidth: fullWidthClassName,
1094
+ zeroRight: zeroRightClassName,
1095
+ };
1096
+
1097
+ var getNonce = function () {
1098
+ if (typeof __webpack_nonce__ !== 'undefined') {
1099
+ return __webpack_nonce__;
1100
+ }
1101
+ return undefined;
1102
+ };
1103
+
1104
+ function makeStyleTag() {
1105
+ if (!document)
1106
+ return null;
1107
+ var tag = document.createElement('style');
1108
+ tag.type = 'text/css';
1109
+ var nonce = getNonce();
1110
+ if (nonce) {
1111
+ tag.setAttribute('nonce', nonce);
1112
+ }
1113
+ return tag;
1114
+ }
1115
+ function injectStyles(tag, css) {
1116
+ // @ts-ignore
1117
+ if (tag.styleSheet) {
1118
+ // @ts-ignore
1119
+ tag.styleSheet.cssText = css;
1120
+ }
1121
+ else {
1122
+ tag.appendChild(document.createTextNode(css));
1123
+ }
1124
+ }
1125
+ function insertStyleTag(tag) {
1126
+ var head = document.head || document.getElementsByTagName('head')[0];
1127
+ head.appendChild(tag);
1128
+ }
1129
+ var stylesheetSingleton = function () {
1130
+ var counter = 0;
1131
+ var stylesheet = null;
1132
+ return {
1133
+ add: function (style) {
1134
+ if (counter == 0) {
1135
+ if ((stylesheet = makeStyleTag())) {
1136
+ injectStyles(stylesheet, style);
1137
+ insertStyleTag(stylesheet);
1138
+ }
1139
+ }
1140
+ counter++;
1141
+ },
1142
+ remove: function () {
1143
+ counter--;
1144
+ if (!counter && stylesheet) {
1145
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
1146
+ stylesheet = null;
1147
+ }
1148
+ },
1149
+ };
1150
+ };
1151
+
1152
+ /**
1153
+ * creates a hook to control style singleton
1154
+ * @see {@link styleSingleton} for a safer component version
1155
+ * @example
1156
+ * ```tsx
1157
+ * const useStyle = styleHookSingleton();
1158
+ * ///
1159
+ * useStyle('body { overflow: hidden}');
1160
+ */
1161
+ var styleHookSingleton = function () {
1162
+ var sheet = stylesheetSingleton();
1163
+ return function (styles, isDynamic) {
1164
+ React$1.useEffect(function () {
1165
+ sheet.add(styles);
1166
+ return function () {
1167
+ sheet.remove();
1168
+ };
1169
+ }, [styles && isDynamic]);
1170
+ };
1171
+ };
1172
+
1173
+ /**
1174
+ * create a Component to add styles on demand
1175
+ * - styles are added when first instance is mounted
1176
+ * - styles are removed when the last instance is unmounted
1177
+ * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
1178
+ */
1179
+ var styleSingleton = function () {
1180
+ var useStyle = styleHookSingleton();
1181
+ var Sheet = function (_a) {
1182
+ var styles = _a.styles, dynamic = _a.dynamic;
1183
+ useStyle(styles, dynamic);
1184
+ return null;
1185
+ };
1186
+ return Sheet;
1187
+ };
1188
+
1189
+ var zeroGap = {
1190
+ left: 0,
1191
+ top: 0,
1192
+ right: 0,
1193
+ gap: 0,
1194
+ };
1195
+ var parse = function (x) { return parseInt(x || '', 10) || 0; };
1196
+ var getOffset = function (gapMode) {
1197
+ var cs = window.getComputedStyle(document.body);
1198
+ var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
1199
+ var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
1200
+ var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
1201
+ return [parse(left), parse(top), parse(right)];
1202
+ };
1203
+ var getGapWidth = function (gapMode) {
1204
+ if (gapMode === void 0) { gapMode = 'margin'; }
1205
+ if (typeof window === 'undefined') {
1206
+ return zeroGap;
1207
+ }
1208
+ var offsets = getOffset(gapMode);
1209
+ var documentWidth = document.documentElement.clientWidth;
1210
+ var windowWidth = window.innerWidth;
1211
+ return {
1212
+ left: offsets[0],
1213
+ top: offsets[1],
1214
+ right: offsets[2],
1215
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
1216
+ };
1217
+ };
1218
+
1219
+ var Style = styleSingleton();
1220
+ // important tip - once we measure scrollBar width and remove them
1221
+ // we could not repeat this operation
1222
+ // thus we are using style-singleton - only the first "yet correct" style will be applied.
1223
+ var getStyles = function (_a, allowRelative, gapMode, important) {
1224
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
1225
+ if (gapMode === void 0) { gapMode = 'margin'; }
1226
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
1227
+ allowRelative && "position: relative ".concat(important, ";"),
1228
+ gapMode === 'margin' &&
1229
+ "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
1230
+ gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
1231
+ ]
1232
+ .filter(Boolean)
1233
+ .join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
1234
+ };
1235
+ /**
1236
+ * Removes page scrollbar and blocks page scroll when mounted
1237
+ */
1238
+ var RemoveScrollBar = function (props) {
1239
+ var noRelative = props.noRelative, noImportant = props.noImportant, _a = props.gapMode, gapMode = _a === void 0 ? 'margin' : _a;
1240
+ /*
1241
+ gap will be measured on every component mount
1242
+ however it will be used only by the "first" invocation
1243
+ due to singleton nature of <Style
1244
+ */
1245
+ var gap = React$1.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
1246
+ return React$1.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
1247
+ };
1248
+
1249
+ var passiveSupported = false;
1250
+ if (typeof window !== 'undefined') {
1251
+ try {
1252
+ var options = Object.defineProperty({}, 'passive', {
1253
+ get: function () {
1254
+ passiveSupported = true;
1255
+ return true;
1256
+ },
1257
+ });
1258
+ // @ts-ignore
1259
+ window.addEventListener('test', options, options);
1260
+ // @ts-ignore
1261
+ window.removeEventListener('test', options, options);
1262
+ }
1263
+ catch (err) {
1264
+ passiveSupported = false;
1265
+ }
1266
+ }
1267
+ var nonPassive = passiveSupported ? { passive: false } : false;
1268
+
1269
+ var alwaysContainsScroll = function (node) {
1270
+ // textarea will always _contain_ scroll inside self. It only can be hidden
1271
+ return node.tagName === 'TEXTAREA';
1272
+ };
1273
+ var elementCanBeScrolled = function (node, overflow) {
1274
+ var styles = window.getComputedStyle(node);
1275
+ return (
1276
+ // not-not-scrollable
1277
+ styles[overflow] !== 'hidden' &&
1278
+ // contains scroll inside self
1279
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
1280
+ };
1281
+ var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
1282
+ var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
1283
+ var locationCouldBeScrolled = function (axis, node) {
1284
+ var current = node;
1285
+ do {
1286
+ // Skip over shadow root
1287
+ if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
1288
+ current = current.host;
1289
+ }
1290
+ var isScrollable = elementCouldBeScrolled(axis, current);
1291
+ if (isScrollable) {
1292
+ var _a = getScrollVariables(axis, current), s = _a[1], d = _a[2];
1293
+ if (s > d) {
1294
+ return true;
1295
+ }
1296
+ }
1297
+ current = current.parentNode;
1298
+ } while (current && current !== document.body);
1299
+ return false;
1300
+ };
1301
+ var getVScrollVariables = function (_a) {
1302
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
1303
+ return [
1304
+ scrollTop,
1305
+ scrollHeight,
1306
+ clientHeight,
1307
+ ];
1308
+ };
1309
+ var getHScrollVariables = function (_a) {
1310
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
1311
+ return [
1312
+ scrollLeft,
1313
+ scrollWidth,
1314
+ clientWidth,
1315
+ ];
1316
+ };
1317
+ var elementCouldBeScrolled = function (axis, node) {
1318
+ return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
1319
+ };
1320
+ var getScrollVariables = function (axis, node) {
1321
+ return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
1322
+ };
1323
+ var getDirectionFactor = function (axis, direction) {
1324
+ /**
1325
+ * If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
1326
+ * and then increasingly negative as you scroll towards the end of the content.
1327
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
1328
+ */
1329
+ return axis === 'h' && direction === 'rtl' ? -1 : 1;
1330
+ };
1331
+ var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
1332
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
1333
+ var delta = directionFactor * sourceDelta;
1334
+ // find scrollable target
1335
+ var target = event.target;
1336
+ var targetInLock = endTarget.contains(target);
1337
+ var shouldCancelScroll = false;
1338
+ var isDeltaPositive = delta > 0;
1339
+ var availableScroll = 0;
1340
+ var availableScrollTop = 0;
1341
+ do {
1342
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
1343
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
1344
+ if (position || elementScroll) {
1345
+ if (elementCouldBeScrolled(axis, target)) {
1346
+ availableScroll += elementScroll;
1347
+ availableScrollTop += position;
1348
+ }
1349
+ }
1350
+ target = target.parentNode;
1351
+ } while (
1352
+ // portaled content
1353
+ (!targetInLock && target !== document.body) ||
1354
+ // self content
1355
+ (targetInLock && (endTarget.contains(target) || endTarget === target)));
1356
+ if (isDeltaPositive && ((noOverscroll && availableScroll === 0) || (!noOverscroll && delta > availableScroll))) {
1357
+ shouldCancelScroll = true;
1358
+ }
1359
+ else if (!isDeltaPositive &&
1360
+ ((noOverscroll && availableScrollTop === 0) || (!noOverscroll && -delta > availableScrollTop))) {
1361
+ shouldCancelScroll = true;
1362
+ }
1363
+ return shouldCancelScroll;
1364
+ };
1365
+
1366
+ var getTouchXY = function (event) {
1367
+ return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
1368
+ };
1369
+ var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
1370
+ var extractRef = function (ref) {
1371
+ return ref && 'current' in ref ? ref.current : ref;
1372
+ };
1373
+ var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
1374
+ var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
1375
+ var idCounter = 0;
1376
+ var lockStack = [];
1377
+ function RemoveScrollSideCar(props) {
1378
+ var shouldPreventQueue = React$1.useRef([]);
1379
+ var touchStartRef = React$1.useRef([0, 0]);
1380
+ var activeAxis = React$1.useRef();
1381
+ var id = React$1.useState(idCounter++)[0];
1382
+ var Style = React$1.useState(function () { return styleSingleton(); })[0];
1383
+ var lastProps = React$1.useRef(props);
1384
+ React$1.useEffect(function () {
1385
+ lastProps.current = props;
1386
+ }, [props]);
1387
+ React$1.useEffect(function () {
1388
+ if (props.inert) {
1389
+ document.body.classList.add("block-interactivity-".concat(id));
1390
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
1391
+ allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
1392
+ return function () {
1393
+ document.body.classList.remove("block-interactivity-".concat(id));
1394
+ allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
1395
+ };
1396
+ }
1397
+ return;
1398
+ }, [props.inert, props.lockRef.current, props.shards]);
1399
+ var shouldCancelEvent = React$1.useCallback(function (event, parent) {
1400
+ if ('touches' in event && event.touches.length === 2) {
1401
+ return !lastProps.current.allowPinchZoom;
1402
+ }
1403
+ var touch = getTouchXY(event);
1404
+ var touchStart = touchStartRef.current;
1405
+ var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
1406
+ var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
1407
+ var currentAxis;
1408
+ var target = event.target;
1409
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
1410
+ // allow horizontal touch move on Range inputs. They will not cause any scroll
1411
+ if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
1412
+ return false;
1413
+ }
1414
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1415
+ if (!canBeScrolledInMainDirection) {
1416
+ return true;
1417
+ }
1418
+ if (canBeScrolledInMainDirection) {
1419
+ currentAxis = moveDirection;
1420
+ }
1421
+ else {
1422
+ currentAxis = moveDirection === 'v' ? 'h' : 'v';
1423
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1424
+ // other axis might be not scrollable
1425
+ }
1426
+ if (!canBeScrolledInMainDirection) {
1427
+ return false;
1428
+ }
1429
+ if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
1430
+ activeAxis.current = currentAxis;
1431
+ }
1432
+ if (!currentAxis) {
1433
+ return true;
1434
+ }
1435
+ var cancelingAxis = activeAxis.current || currentAxis;
1436
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY, true);
1437
+ }, []);
1438
+ var shouldPrevent = React$1.useCallback(function (_event) {
1439
+ var event = _event;
1440
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
1441
+ // not the last active
1442
+ return;
1443
+ }
1444
+ var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
1445
+ var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && e.target === event.target && deltaCompare(e.delta, delta); })[0];
1446
+ // self event, and should be canceled
1447
+ if (sourceEvent && sourceEvent.should) {
1448
+ if (event.cancelable) {
1449
+ event.preventDefault();
1450
+ }
1451
+ return;
1452
+ }
1453
+ // outside or shard event
1454
+ if (!sourceEvent) {
1455
+ var shardNodes = (lastProps.current.shards || [])
1456
+ .map(extractRef)
1457
+ .filter(Boolean)
1458
+ .filter(function (node) { return node.contains(event.target); });
1459
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
1460
+ if (shouldStop) {
1461
+ if (event.cancelable) {
1462
+ event.preventDefault();
1463
+ }
1464
+ }
1465
+ }
1466
+ }, []);
1467
+ var shouldCancel = React$1.useCallback(function (name, delta, target, should) {
1468
+ var event = { name: name, delta: delta, target: target, should: should };
1469
+ shouldPreventQueue.current.push(event);
1470
+ setTimeout(function () {
1471
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
1472
+ }, 1);
1473
+ }, []);
1474
+ var scrollTouchStart = React$1.useCallback(function (event) {
1475
+ touchStartRef.current = getTouchXY(event);
1476
+ activeAxis.current = undefined;
1477
+ }, []);
1478
+ var scrollWheel = React$1.useCallback(function (event) {
1479
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1480
+ }, []);
1481
+ var scrollTouchMove = React$1.useCallback(function (event) {
1482
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1483
+ }, []);
1484
+ React$1.useEffect(function () {
1485
+ lockStack.push(Style);
1486
+ props.setCallbacks({
1487
+ onScrollCapture: scrollWheel,
1488
+ onWheelCapture: scrollWheel,
1489
+ onTouchMoveCapture: scrollTouchMove,
1490
+ });
1491
+ document.addEventListener('wheel', shouldPrevent, nonPassive);
1492
+ document.addEventListener('touchmove', shouldPrevent, nonPassive);
1493
+ document.addEventListener('touchstart', scrollTouchStart, nonPassive);
1494
+ return function () {
1495
+ lockStack = lockStack.filter(function (inst) { return inst !== Style; });
1496
+ document.removeEventListener('wheel', shouldPrevent, nonPassive);
1497
+ document.removeEventListener('touchmove', shouldPrevent, nonPassive);
1498
+ document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
1499
+ };
1500
+ }, []);
1501
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
1502
+ return (React$1.createElement(React$1.Fragment, null,
1503
+ inert ? React$1.createElement(Style, { styles: generateStyle(id) }) : null,
1504
+ removeScrollBar ? React$1.createElement(RemoveScrollBar, { gapMode: "margin" }) : null));
1505
+ }
1506
+
1507
+ var SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
1508
+
1509
+ var ReactRemoveScroll = React$1.forwardRef(function (props, ref) { return (React$1.createElement(RemoveScroll, __assign$1({}, props, { ref: ref, sideCar: SideCar }))); });
1510
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
1511
+ var $01b9c$RemoveScroll = ReactRemoveScroll;
1512
+
1513
+ const $cc7e05a45900e73f$var$OPEN_KEYS = [
1514
+ ' ',
1515
+ 'Enter',
1516
+ 'ArrowUp',
1517
+ 'ArrowDown'
1518
+ ];
1519
+ const $cc7e05a45900e73f$var$SELECTION_KEYS = [
1520
+ ' ',
1521
+ 'Enter'
1522
+ ];
1523
+ /* -------------------------------------------------------------------------------------------------
1524
+ * Select
1525
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SELECT_NAME = 'Select';
1526
+ const [$cc7e05a45900e73f$var$Collection, $cc7e05a45900e73f$var$useCollection, $cc7e05a45900e73f$var$createCollectionScope] = $e02a7d9cb1dc128c$export$c74125a8e3af6bb2($cc7e05a45900e73f$var$SELECT_NAME);
1527
+ const [$cc7e05a45900e73f$var$createSelectContext, $cc7e05a45900e73f$export$286727a75dc039bd] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cc7e05a45900e73f$var$SELECT_NAME, [
1528
+ $cc7e05a45900e73f$var$createCollectionScope
1529
+ ]);
1530
+ const [$cc7e05a45900e73f$var$SelectProvider, $cc7e05a45900e73f$var$useSelectContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
1531
+ const [$cc7e05a45900e73f$var$SelectNativeOptionsProvider, $cc7e05a45900e73f$var$useSelectNativeOptionsContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
1532
+ const $cc7e05a45900e73f$export$ef9b1a59e592288f = (props)=>{
1533
+ 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;
1534
+ const [trigger, setTrigger] = useState(null);
1535
+ const [valueNode, setValueNode] = useState(null);
1536
+ const [valueNodeHasChildren, setValueNodeHasChildren] = useState(false);
1537
+ const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
1538
+ const [open = false, setOpen] = $71cd76cc60e0454e$export$6f32135080cb4c3({
1539
+ prop: openProp,
1540
+ defaultProp: defaultOpen,
1541
+ onChange: onOpenChange
1542
+ });
1543
+ const [value, setValue] = $71cd76cc60e0454e$export$6f32135080cb4c3({
1544
+ prop: valueProp,
1545
+ defaultProp: defaultValue,
1546
+ onChange: onValueChange
1547
+ });
1548
+ const triggerPointerDownPosRef = useRef(null); // We set this to true by default so that events bubble to forms without JS (SSR)
1549
+ const isFormControl = trigger ? Boolean(trigger.closest('form')) : true;
1550
+ const [nativeOptionsSet, setNativeOptionsSet] = useState(new Set()); // The native `select` only associates the correct default value if the corresponding
1551
+ // `option` is rendered as a child **at the same time** as itself.
1552
+ // Because it might take a few renders for our items to gather the information to build
1553
+ // the native `option`(s), we generate a key on the `select` to make sure React re-builds it
1554
+ // each time the options change.
1555
+ const nativeSelectKey = Array.from(nativeOptionsSet).map((option)=>option.props.value
1556
+ ).join(';');
1557
+ return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectProvider, {
1558
+ required: required,
1559
+ scope: __scopeSelect,
1560
+ trigger: trigger,
1561
+ onTriggerChange: setTrigger,
1562
+ valueNode: valueNode,
1563
+ onValueNodeChange: setValueNode,
1564
+ valueNodeHasChildren: valueNodeHasChildren,
1565
+ onValueNodeHasChildrenChange: setValueNodeHasChildren,
1566
+ contentId: $1746a345f3d73bb7$export$f680877a34711e37(),
1567
+ value: value,
1568
+ onValueChange: setValue,
1569
+ open: open,
1570
+ onOpenChange: setOpen,
1571
+ dir: direction,
1572
+ triggerPointerDownPosRef: triggerPointerDownPosRef,
1573
+ disabled: disabled
1574
+ }, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$Collection.Provider, {
1575
+ scope: __scopeSelect
1576
+ }, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectNativeOptionsProvider, {
1577
+ scope: props.__scopeSelect,
1578
+ onNativeOptionAdd: useCallback((option)=>{
1579
+ setNativeOptionsSet((prev)=>new Set(prev).add(option)
1580
+ );
1581
+ }, []),
1582
+ onNativeOptionRemove: useCallback((option)=>{
1583
+ setNativeOptionsSet((prev)=>{
1584
+ const optionsSet = new Set(prev);
1585
+ optionsSet.delete(option);
1586
+ return optionsSet;
1587
+ });
1588
+ }, [])
1589
+ }, children)), isFormControl ? /*#__PURE__*/ createElement($cc7e05a45900e73f$var$BubbleSelect, {
1590
+ key: nativeSelectKey,
1591
+ "aria-hidden": true,
1592
+ required: required,
1593
+ tabIndex: -1,
1594
+ name: name,
1595
+ autoComplete: autoComplete,
1596
+ value: value // enable form autofill
1597
+ ,
1598
+ onChange: (event)=>setValue(event.target.value)
1599
+ ,
1600
+ disabled: disabled
1601
+ }, value === undefined ? /*#__PURE__*/ createElement("option", {
1602
+ value: ""
1603
+ }) : null, Array.from(nativeOptionsSet)) : null);
1604
+ };
1605
+ /* -------------------------------------------------------------------------------------------------
1606
+ * SelectTrigger
1607
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$TRIGGER_NAME = 'SelectTrigger';
1608
+ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1609
+ const { __scopeSelect: __scopeSelect , disabled: disabled = false , ...triggerProps } = props;
1610
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$TRIGGER_NAME, __scopeSelect);
1611
+ const isDisabled = context.disabled || disabled;
1612
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.onTriggerChange);
1613
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
1614
+ const [searchRef, handleTypeaheadSearch, resetTypeahead] = $cc7e05a45900e73f$var$useTypeaheadSearch((search)=>{
1615
+ const enabledItems = getItems().filter((item)=>!item.disabled
1616
+ );
1617
+ const currentItem = enabledItems.find((item)=>item.value === context.value
1618
+ );
1619
+ const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
1620
+ if (nextItem !== undefined) context.onValueChange(nextItem.value);
1621
+ });
1622
+ const handleOpen = ()=>{
1623
+ if (!isDisabled) {
1624
+ context.onOpenChange(true); // reset typeahead when we open
1625
+ resetTypeahead();
1626
+ }
1627
+ };
1628
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
1629
+ type: "button",
1630
+ role: "combobox",
1631
+ "aria-controls": context.contentId,
1632
+ "aria-expanded": context.open,
1633
+ "aria-required": context.required,
1634
+ "aria-autocomplete": "none",
1635
+ dir: context.dir,
1636
+ "data-state": context.open ? 'open' : 'closed',
1637
+ disabled: isDisabled,
1638
+ "data-disabled": isDisabled ? '' : undefined,
1639
+ "data-placeholder": context.value === undefined ? '' : undefined
1640
+ }, triggerProps, {
1641
+ ref: composedRefs // Enable compatibility with native label or custom `Label` "click" for Safari:
1642
+ ,
1643
+ onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onClick, (event)=>{
1644
+ // Whilst browsers generally have no issue focusing the trigger when clicking
1645
+ // on a label, Safari seems to struggle with the fact that there's no `onClick`.
1646
+ // We force `focus` in this case. Note: this doesn't create any other side-effect
1647
+ // because we are preventing default in `onPointerDown` so effectively
1648
+ // this only runs for a label "click"
1649
+ event.currentTarget.focus();
1650
+ }),
1651
+ onPointerDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onPointerDown, (event)=>{
1652
+ // prevent implicit pointer capture
1653
+ // https://www.w3.org/TR/pointerevents3/#implicit-pointer-capture
1654
+ const target = event.target;
1655
+ if (target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
1656
+ // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
1657
+ // but not when the control key is pressed (avoiding MacOS right click)
1658
+ if (event.button === 0 && event.ctrlKey === false) {
1659
+ handleOpen();
1660
+ context.triggerPointerDownPosRef.current = {
1661
+ x: Math.round(event.pageX),
1662
+ y: Math.round(event.pageY)
1663
+ }; // prevent trigger from stealing focus from the active item after opening.
1664
+ event.preventDefault();
1665
+ }
1666
+ }),
1667
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onKeyDown, (event)=>{
1668
+ const isTypingAhead = searchRef.current !== '';
1669
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
1670
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
1671
+ if (isTypingAhead && event.key === ' ') return;
1672
+ if ($cc7e05a45900e73f$var$OPEN_KEYS.includes(event.key)) {
1673
+ handleOpen();
1674
+ event.preventDefault();
1675
+ }
1676
+ })
1677
+ }));
1678
+ });
1679
+ /* -------------------------------------------------------------------------------------------------
1680
+ * SelectValue
1681
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VALUE_NAME = 'SelectValue';
1682
+ const $cc7e05a45900e73f$export$e288731fd71264f0 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1683
+ // We ignore `className` and `style` as this part shouldn't be styled.
1684
+ const { __scopeSelect: __scopeSelect , className: className , style: style , children: children , placeholder: placeholder , ...valueProps } = props;
1685
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$VALUE_NAME, __scopeSelect);
1686
+ const { onValueNodeHasChildrenChange: onValueNodeHasChildrenChange } = context;
1687
+ const hasChildren = children !== undefined;
1688
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.onValueNodeChange);
1689
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1690
+ onValueNodeHasChildrenChange(hasChildren);
1691
+ }, [
1692
+ onValueNodeHasChildrenChange,
1693
+ hasChildren
1694
+ ]);
1695
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, valueProps, {
1696
+ ref: composedRefs // we don't want events from the portalled `SelectValue` children to bubble
1697
+ ,
1698
+ style: {
1699
+ pointerEvents: 'none'
1700
+ }
1701
+ }), context.value === undefined && placeholder !== undefined ? placeholder : children);
1702
+ });
1703
+ const $cc7e05a45900e73f$export$99b400cabb58c515 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1704
+ const { __scopeSelect: __scopeSelect , children: children , ...iconProps } = props;
1705
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
1706
+ "aria-hidden": true
1707
+ }, iconProps, {
1708
+ ref: forwardedRef
1709
+ }), children || '▼');
1710
+ });
1711
+ const $cc7e05a45900e73f$export$b2af6c9944296213 = (props)=>{
1712
+ return /*#__PURE__*/ createElement($f1701beae083dbae$export$602eac185826482c, _extends({
1713
+ asChild: true
1714
+ }, props));
1715
+ };
1716
+ /* -------------------------------------------------------------------------------------------------
1717
+ * SelectContent
1718
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$CONTENT_NAME = 'SelectContent';
1719
+ const $cc7e05a45900e73f$export$c973a4b3cb86a03d = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1720
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, props.__scopeSelect);
1721
+ const [fragment, setFragment] = useState(); // setting the fragment in `useLayoutEffect` as `DocumentFragment` doesn't exist on the server
1722
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1723
+ setFragment(new DocumentFragment());
1724
+ }, []);
1725
+ return /*#__PURE__*/ createElement(Fragment, null, context.open ? /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentImpl, _extends({}, props, {
1726
+ ref: forwardedRef
1727
+ })) : fragment ? /*#__PURE__*/ createPortal(/*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentProvider, {
1728
+ scope: props.__scopeSelect
1729
+ }, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$Collection.Slot, {
1730
+ scope: props.__scopeSelect
1731
+ }, /*#__PURE__*/ createElement("div", null, props.children))), fragment) : null);
1732
+ });
1733
+ const $cc7e05a45900e73f$var$CONTENT_MARGIN = 10;
1734
+ const [$cc7e05a45900e73f$var$SelectContentProvider, $cc7e05a45900e73f$var$useSelectContentContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME);
1735
+ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
1736
+ const { __scopeSelect: __scopeSelect , onCloseAutoFocus: onCloseAutoFocus , ...contentProps } = props;
1737
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
1738
+ const [contentWrapper, setContentWrapper] = useState(null);
1739
+ const [content, setContent] = useState(null);
1740
+ const [viewport, setViewport] = useState(null);
1741
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
1742
+ );
1743
+ const [selectedItem, setSelectedItem] = useState(null);
1744
+ const [selectedItemText, setSelectedItemText] = useState(null);
1745
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
1746
+ const [isPositioned, setIsPositioned] = useState(false);
1747
+ const shouldRepositionRef = useRef(true);
1748
+ const shouldExpandOnScrollRef = useRef(false);
1749
+ const firstValidItemFoundRef = useRef(false); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
1750
+ useEffect(()=>{
1751
+ if (content) return hideOthers(content);
1752
+ }, [
1753
+ content
1754
+ ]); // Make sure the whole tree has focus guards as our `Select` may be
1755
+ // the last element in the DOM (because of the `Portal`)
1756
+ $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
1757
+ const [contentZIndex, setContentZIndex] = useState();
1758
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
1759
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
1760
+ }, [
1761
+ content
1762
+ ]);
1763
+ const focusFirst = useCallback((candidates)=>{
1764
+ const [firstItem, ...restItems] = getItems().map((item)=>item.ref.current
1765
+ );
1766
+ const [lastItem] = restItems.slice(-1);
1767
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
1768
+ for (const candidate of candidates){
1769
+ // if focus is already where we want to go, we don't want to keep going through the candidates
1770
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
1771
+ candidate === null || candidate === void 0 || candidate.scrollIntoView({
1772
+ block: 'nearest'
1773
+ }); // viewport might have padding so scroll to its edges when focusing first/last items.
1774
+ if (candidate === firstItem && viewport) viewport.scrollTop = 0;
1775
+ if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
1776
+ candidate === null || candidate === void 0 || candidate.focus();
1777
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
1778
+ }
1779
+ }, [
1780
+ getItems,
1781
+ viewport
1782
+ ]);
1783
+ const position = useCallback(()=>{
1784
+ if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
1785
+ const triggerRect = context.trigger.getBoundingClientRect(); // -----------------------------------------------------------------------------------------
1786
+ // Horizontal positioning
1787
+ // -----------------------------------------------------------------------------------------
1788
+ const contentRect = content.getBoundingClientRect();
1789
+ const valueNodeRect = context.valueNode.getBoundingClientRect();
1790
+ const itemTextRect = selectedItemText.getBoundingClientRect();
1791
+ if (context.dir !== 'rtl') {
1792
+ const itemTextOffset = itemTextRect.left - contentRect.left;
1793
+ const left = valueNodeRect.left - itemTextOffset;
1794
+ const leftDelta = triggerRect.left - left;
1795
+ const minContentWidth = triggerRect.width + leftDelta;
1796
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
1797
+ const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
1798
+ const clampedLeft = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(left, [
1799
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
1800
+ rightEdge - contentWidth
1801
+ ]);
1802
+ contentWrapper.style.minWidth = minContentWidth + 'px';
1803
+ contentWrapper.style.left = clampedLeft + 'px';
1804
+ } else {
1805
+ const itemTextOffset = contentRect.right - itemTextRect.right;
1806
+ const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
1807
+ const rightDelta = window.innerWidth - triggerRect.right - right;
1808
+ const minContentWidth = triggerRect.width + rightDelta;
1809
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
1810
+ const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
1811
+ const clampedRight = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(right, [
1812
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
1813
+ leftEdge - contentWidth
1814
+ ]);
1815
+ contentWrapper.style.minWidth = minContentWidth + 'px';
1816
+ contentWrapper.style.right = clampedRight + 'px';
1817
+ } // -----------------------------------------------------------------------------------------
1818
+ // Vertical positioning
1819
+ // -----------------------------------------------------------------------------------------
1820
+ const items = getItems();
1821
+ const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
1822
+ const itemsHeight = viewport.scrollHeight;
1823
+ const contentStyles = window.getComputedStyle(content);
1824
+ const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
1825
+ const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
1826
+ const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
1827
+ const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
1828
+ const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth; // prettier-ignore
1829
+ const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
1830
+ const viewportStyles = window.getComputedStyle(viewport);
1831
+ const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
1832
+ const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
1833
+ const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
1834
+ const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
1835
+ const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
1836
+ const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
1837
+ const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
1838
+ const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
1839
+ const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
1840
+ if (willAlignWithoutTopOverflow) {
1841
+ const isLastItem = selectedItem === items[items.length - 1].ref.current;
1842
+ contentWrapper.style.bottom = "0px";
1843
+ const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
1844
+ const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
1845
+ const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
1846
+ contentWrapper.style.height = height + 'px';
1847
+ } else {
1848
+ const isFirstItem = selectedItem === items[0].ref.current;
1849
+ contentWrapper.style.top = "0px";
1850
+ const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
1851
+ const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
1852
+ contentWrapper.style.height = height + 'px';
1853
+ viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
1854
+ }
1855
+ contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
1856
+ contentWrapper.style.minHeight = minContentHeight + 'px';
1857
+ contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
1858
+ setIsPositioned(true); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
1859
+ // so we explicitly turn it on only after they've registered.
1860
+ requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
1861
+ );
1862
+ }
1863
+ }, [
1864
+ getItems,
1865
+ context.trigger,
1866
+ context.valueNode,
1867
+ contentWrapper,
1868
+ content,
1869
+ viewport,
1870
+ selectedItem,
1871
+ selectedItemText,
1872
+ context.dir
1873
+ ]);
1874
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>position()
1875
+ , [
1876
+ position
1877
+ ]);
1878
+ const focusSelectedItem = useCallback(()=>focusFirst([
1879
+ selectedItem,
1880
+ content
1881
+ ])
1882
+ , [
1883
+ focusFirst,
1884
+ selectedItem,
1885
+ content
1886
+ ]); // Since this is not dependent on layout, we want to ensure this runs at the same time as
1887
+ // other effects across components. Hence why we don't call `focusSelectedItem` inside `position`.
1888
+ useEffect(()=>{
1889
+ if (isPositioned) focusSelectedItem();
1890
+ }, [
1891
+ isPositioned,
1892
+ focusSelectedItem
1893
+ ]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
1894
+ // Because it is part of the normal flow, it will push down the viewport, thus throwing our
1895
+ // trigger => selectedItem alignment off by the amount the viewport was pushed down.
1896
+ // We wait for this to happen and then re-run the positining logic one more time to account for it.
1897
+ const handleScrollButtonChange = useCallback((node)=>{
1898
+ if (node && shouldRepositionRef.current === true) {
1899
+ position();
1900
+ focusSelectedItem();
1901
+ shouldRepositionRef.current = false;
1902
+ }
1903
+ }, [
1904
+ position,
1905
+ focusSelectedItem
1906
+ ]); // prevent selecting items on `pointerup` in some cases after opening from `pointerdown`
1907
+ // and close on `pointerup` outside.
1908
+ const { onOpenChange: onOpenChange , triggerPointerDownPosRef: triggerPointerDownPosRef } = context;
1909
+ useEffect(()=>{
1910
+ if (content) {
1911
+ let pointerMoveDelta = {
1912
+ x: 0,
1913
+ y: 0
1914
+ };
1915
+ const handlePointerMove = (event)=>{
1916
+ var _triggerPointerDownPo, _triggerPointerDownPo2, _triggerPointerDownPo3, _triggerPointerDownPo4;
1917
+ pointerMoveDelta = {
1918
+ 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)),
1919
+ 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))
1920
+ };
1921
+ };
1922
+ const handlePointerUp = (event)=>{
1923
+ // If the pointer hasn't moved by a certain threshold then we prevent selecting item on `pointerup`.
1924
+ if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) event.preventDefault();
1925
+ else // otherwise, if the event was outside the content, close.
1926
+ if (!content.contains(event.target)) onOpenChange(false);
1927
+ document.removeEventListener('pointermove', handlePointerMove);
1928
+ triggerPointerDownPosRef.current = null;
1929
+ };
1930
+ if (triggerPointerDownPosRef.current !== null) {
1931
+ document.addEventListener('pointermove', handlePointerMove);
1932
+ document.addEventListener('pointerup', handlePointerUp, {
1933
+ capture: true,
1934
+ once: true
1935
+ });
1936
+ }
1937
+ return ()=>{
1938
+ document.removeEventListener('pointermove', handlePointerMove);
1939
+ document.removeEventListener('pointerup', handlePointerUp, {
1940
+ capture: true
1941
+ });
1942
+ };
1943
+ }
1944
+ }, [
1945
+ content,
1946
+ onOpenChange,
1947
+ triggerPointerDownPosRef
1948
+ ]);
1949
+ useEffect(()=>{
1950
+ const close = ()=>onOpenChange(false)
1951
+ ;
1952
+ window.addEventListener('blur', close);
1953
+ window.addEventListener('resize', close);
1954
+ return ()=>{
1955
+ window.removeEventListener('blur', close);
1956
+ window.removeEventListener('resize', close);
1957
+ };
1958
+ }, [
1959
+ onOpenChange
1960
+ ]);
1961
+ const [searchRef, handleTypeaheadSearch] = $cc7e05a45900e73f$var$useTypeaheadSearch((search)=>{
1962
+ const enabledItems = getItems().filter((item)=>!item.disabled
1963
+ );
1964
+ const currentItem = enabledItems.find((item)=>item.ref.current === document.activeElement
1965
+ );
1966
+ const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
1967
+ if (nextItem) /**
1968
+ * Imperative focus during keydown is risky so we prevent React's batching updates
1969
+ * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
1970
+ */ setTimeout(()=>nextItem.ref.current.focus()
1971
+ );
1972
+ });
1973
+ const itemRefCallback = useCallback((node, value, disabled)=>{
1974
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
1975
+ const isSelectedItem = context.value !== undefined && context.value === value;
1976
+ if (isSelectedItem || isFirstValidItem) {
1977
+ setSelectedItem(node);
1978
+ if (isFirstValidItem) firstValidItemFoundRef.current = true;
1979
+ }
1980
+ }, [
1981
+ context.value
1982
+ ]);
1983
+ const handleItemLeave = useCallback(()=>content === null || content === void 0 ? void 0 : content.focus()
1984
+ , [
1985
+ content
1986
+ ]);
1987
+ const itemTextRefCallback = useCallback((node, value, disabled)=>{
1988
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
1989
+ const isSelectedItem = context.value !== undefined && context.value === value;
1990
+ if (isSelectedItem || isFirstValidItem) setSelectedItemText(node);
1991
+ }, [
1992
+ context.value
1993
+ ]);
1994
+ return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectContentProvider, {
1995
+ scope: __scopeSelect,
1996
+ contentWrapper: contentWrapper,
1997
+ content: content,
1998
+ viewport: viewport,
1999
+ onViewportChange: setViewport,
2000
+ itemRefCallback: itemRefCallback,
2001
+ selectedItem: selectedItem,
2002
+ onItemLeave: handleItemLeave,
2003
+ itemTextRefCallback: itemTextRefCallback,
2004
+ selectedItemText: selectedItemText,
2005
+ onScrollButtonChange: handleScrollButtonChange,
2006
+ isPositioned: isPositioned,
2007
+ shouldExpandOnScrollRef: shouldExpandOnScrollRef,
2008
+ searchRef: searchRef
2009
+ }, /*#__PURE__*/ createElement($01b9c$RemoveScroll, {
2010
+ as: $5e63c961fc1ce211$export$8c6ed5c666ac1360,
2011
+ allowPinchZoom: true
2012
+ }, /*#__PURE__*/ createElement("div", {
2013
+ ref: setContentWrapper,
2014
+ style: {
2015
+ display: 'flex',
2016
+ flexDirection: 'column',
2017
+ position: 'fixed',
2018
+ zIndex: contentZIndex
2019
+ }
2020
+ }, /*#__PURE__*/ createElement($d3863c46a17e8a28$export$20e40289641fbbb6, {
2021
+ asChild: true // we make sure we're not trapping once it's been closed
2022
+ ,
2023
+ trapped: context.open,
2024
+ onMountAutoFocus: (event)=>{
2025
+ // we prevent open autofocus because we manually focus the selected item
2026
+ event.preventDefault();
2027
+ },
2028
+ onUnmountAutoFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(onCloseAutoFocus, (event)=>{
2029
+ var _context$trigger;
2030
+ (_context$trigger = context.trigger) === null || _context$trigger === void 0 || _context$trigger.focus({
2031
+ preventScroll: true
2032
+ });
2033
+ event.preventDefault();
2034
+ })
2035
+ }, /*#__PURE__*/ createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, _extends({
2036
+ role: "listbox",
2037
+ id: context.contentId,
2038
+ "data-state": context.open ? 'open' : 'closed',
2039
+ dir: context.dir,
2040
+ onContextMenu: (event)=>event.preventDefault()
2041
+ }, contentProps, {
2042
+ ref: composedRefs,
2043
+ style: {
2044
+ display: 'flex',
2045
+ flexDirection: 'column',
2046
+ // When we get the height of the content, it includes borders. If we were to set
2047
+ // the height without having `boxSizing: 'border-box'` it would be too big.
2048
+ boxSizing: 'border-box',
2049
+ maxHeight: '100%',
2050
+ outline: 'none',
2051
+ ...contentProps.style
2052
+ },
2053
+ disableOutsidePointerEvents: true // When focus is trapped, a focusout event may still happen.
2054
+ ,
2055
+ onFocusOutside: (event)=>event.preventDefault()
2056
+ ,
2057
+ onDismiss: ()=>context.onOpenChange(false)
2058
+ ,
2059
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(contentProps.onKeyDown, (event)=>{
2060
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey; // select should not be navigated using tab key so we prevent it
2061
+ if (event.key === 'Tab') event.preventDefault();
2062
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
2063
+ if ([
2064
+ 'ArrowUp',
2065
+ 'ArrowDown',
2066
+ 'Home',
2067
+ 'End'
2068
+ ].includes(event.key)) {
2069
+ const items = getItems().filter((item)=>!item.disabled
2070
+ );
2071
+ let candidateNodes = items.map((item)=>item.ref.current
2072
+ );
2073
+ if ([
2074
+ 'ArrowUp',
2075
+ 'End'
2076
+ ].includes(event.key)) candidateNodes = candidateNodes.slice().reverse();
2077
+ if ([
2078
+ 'ArrowUp',
2079
+ 'ArrowDown'
2080
+ ].includes(event.key)) {
2081
+ const currentElement = event.target;
2082
+ const currentIndex = candidateNodes.indexOf(currentElement);
2083
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
2084
+ }
2085
+ /**
2086
+ * Imperative focus during keydown is risky so we prevent React's batching updates
2087
+ * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
2088
+ */ setTimeout(()=>focusFirst(candidateNodes)
2089
+ );
2090
+ event.preventDefault();
2091
+ }
2092
+ })
2093
+ }))))));
2094
+ });
2095
+ /* -------------------------------------------------------------------------------------------------
2096
+ * SelectViewport
2097
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VIEWPORT_NAME = 'SelectViewport';
2098
+ const $cc7e05a45900e73f$export$9ed6e7b40248d36d = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2099
+ const { __scopeSelect: __scopeSelect , ...viewportProps } = props;
2100
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$VIEWPORT_NAME, __scopeSelect);
2101
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onViewportChange);
2102
+ const prevScrollTopRef = useRef(0);
2103
+ return /*#__PURE__*/ createElement(Fragment, null, /*#__PURE__*/ createElement("style", {
2104
+ dangerouslySetInnerHTML: {
2105
+ __html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
2106
+ }
2107
+ }), /*#__PURE__*/ createElement($cc7e05a45900e73f$var$Collection.Slot, {
2108
+ scope: __scopeSelect
2109
+ }, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2110
+ "data-radix-select-viewport": "",
2111
+ role: "presentation"
2112
+ }, viewportProps, {
2113
+ ref: composedRefs,
2114
+ style: {
2115
+ // we use position: 'relative' here on the `viewport` so that when we call
2116
+ // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
2117
+ // (independent of the scrollUpButton).
2118
+ position: 'relative',
2119
+ flex: 1,
2120
+ overflow: 'auto',
2121
+ ...viewportProps.style
2122
+ },
2123
+ onScroll: $e42e1063c40fb3ef$export$b9ecd428b558ff10(viewportProps.onScroll, (event)=>{
2124
+ const viewport = event.currentTarget;
2125
+ const { contentWrapper: contentWrapper , shouldExpandOnScrollRef: shouldExpandOnScrollRef } = contentContext;
2126
+ if (shouldExpandOnScrollRef !== null && shouldExpandOnScrollRef !== void 0 && shouldExpandOnScrollRef.current && contentWrapper) {
2127
+ const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
2128
+ if (scrolledBy > 0) {
2129
+ const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
2130
+ const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
2131
+ const cssHeight = parseFloat(contentWrapper.style.height);
2132
+ const prevHeight = Math.max(cssMinHeight, cssHeight);
2133
+ if (prevHeight < availableHeight) {
2134
+ const nextHeight = prevHeight + scrolledBy;
2135
+ const clampedNextHeight = Math.min(availableHeight, nextHeight);
2136
+ const heightDiff = nextHeight - clampedNextHeight;
2137
+ contentWrapper.style.height = clampedNextHeight + 'px';
2138
+ if (contentWrapper.style.bottom === '0px') {
2139
+ viewport.scrollTop = heightDiff > 0 ? heightDiff : 0; // ensure the content stays pinned to the bottom
2140
+ contentWrapper.style.justifyContent = 'flex-end';
2141
+ }
2142
+ }
2143
+ }
2144
+ }
2145
+ prevScrollTopRef.current = viewport.scrollTop;
2146
+ })
2147
+ }))));
2148
+ });
2149
+ /* -------------------------------------------------------------------------------------------------
2150
+ * SelectGroup
2151
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$GROUP_NAME = 'SelectGroup';
2152
+ $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$GROUP_NAME);
2153
+ /* -------------------------------------------------------------------------------------------------
2154
+ * SelectItem
2155
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_NAME = 'SelectItem';
2156
+ const [$cc7e05a45900e73f$var$SelectItemContextProvider, $cc7e05a45900e73f$var$useSelectItemContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$ITEM_NAME);
2157
+ const $cc7e05a45900e73f$export$13ef48a934230896 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2158
+ const { __scopeSelect: __scopeSelect , value: value , disabled: disabled = false , textValue: textValueProp , ...itemProps } = props;
2159
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
2160
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
2161
+ const isSelected = context.value === value;
2162
+ const [textValue, setTextValue] = useState(textValueProp !== null && textValueProp !== void 0 ? textValueProp : '');
2163
+ const [isFocused, setIsFocused] = useState(false);
2164
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>{
2165
+ var _contentContext$itemR;
2166
+ return (_contentContext$itemR = contentContext.itemRefCallback) === null || _contentContext$itemR === void 0 ? void 0 : _contentContext$itemR.call(contentContext, node, value, disabled);
2167
+ });
2168
+ const textId = $1746a345f3d73bb7$export$f680877a34711e37();
2169
+ const handleSelect = ()=>{
2170
+ if (!disabled) {
2171
+ context.onValueChange(value);
2172
+ context.onOpenChange(false);
2173
+ }
2174
+ };
2175
+ return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectItemContextProvider, {
2176
+ scope: __scopeSelect,
2177
+ value: value,
2178
+ disabled: disabled,
2179
+ textId: textId,
2180
+ isSelected: isSelected,
2181
+ onItemTextChange: useCallback((node)=>{
2182
+ setTextValue((prevTextValue)=>{
2183
+ var _node$textContent;
2184
+ return prevTextValue || ((_node$textContent = node === null || node === void 0 ? void 0 : node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : '').trim();
2185
+ });
2186
+ }, [])
2187
+ }, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$Collection.ItemSlot, {
2188
+ scope: __scopeSelect,
2189
+ value: value,
2190
+ disabled: disabled,
2191
+ textValue: textValue
2192
+ }, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2193
+ role: "option",
2194
+ "aria-labelledby": textId,
2195
+ "data-highlighted": isFocused ? '' : undefined // `isFocused` caveat fixes stuttering in VoiceOver
2196
+ ,
2197
+ "aria-selected": isSelected && isFocused,
2198
+ "data-state": isSelected ? 'checked' : 'unchecked',
2199
+ "aria-disabled": disabled || undefined,
2200
+ "data-disabled": disabled ? '' : undefined,
2201
+ tabIndex: disabled ? undefined : -1
2202
+ }, itemProps, {
2203
+ ref: composedRefs,
2204
+ onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onFocus, ()=>setIsFocused(true)
2205
+ ),
2206
+ onBlur: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onBlur, ()=>setIsFocused(false)
2207
+ ),
2208
+ onPointerUp: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerUp, handleSelect),
2209
+ onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerMove, (event)=>{
2210
+ if (disabled) {
2211
+ var _contentContext$onIte;
2212
+ (_contentContext$onIte = contentContext.onItemLeave) === null || _contentContext$onIte === void 0 || _contentContext$onIte.call(contentContext);
2213
+ } else // even though safari doesn't support this option, it's acceptable
2214
+ // as it only means it might scroll a few pixels when using the pointer.
2215
+ event.currentTarget.focus({
2216
+ preventScroll: true
2217
+ });
2218
+ }),
2219
+ onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerLeave, (event)=>{
2220
+ if (event.currentTarget === document.activeElement) {
2221
+ var _contentContext$onIte2;
2222
+ (_contentContext$onIte2 = contentContext.onItemLeave) === null || _contentContext$onIte2 === void 0 || _contentContext$onIte2.call(contentContext);
2223
+ }
2224
+ }),
2225
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onKeyDown, (event)=>{
2226
+ var _contentContext$searc;
2227
+ const isTypingAhead = ((_contentContext$searc = contentContext.searchRef) === null || _contentContext$searc === void 0 ? void 0 : _contentContext$searc.current) !== '';
2228
+ if (isTypingAhead && event.key === ' ') return;
2229
+ if ($cc7e05a45900e73f$var$SELECTION_KEYS.includes(event.key)) handleSelect(); // prevent page scroll if using the space key to select an item
2230
+ if (event.key === ' ') event.preventDefault();
2231
+ })
2232
+ }))));
2233
+ });
2234
+ /* -------------------------------------------------------------------------------------------------
2235
+ * SelectItemText
2236
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_TEXT_NAME = 'SelectItemText';
2237
+ const $cc7e05a45900e73f$export$3572fb0fb821ff49 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2238
+ // We ignore `className` and `style` as this part shouldn't be styled.
2239
+ const { __scopeSelect: __scopeSelect , className: className , style: style , ...itemTextProps } = props;
2240
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2241
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2242
+ const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2243
+ const nativeOptionsContext = $cc7e05a45900e73f$var$useSelectNativeOptionsContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2244
+ const [itemTextNode, setItemTextNode] = useState(null);
2245
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setItemTextNode(node)
2246
+ , itemContext.onItemTextChange, (node)=>{
2247
+ var _contentContext$itemT;
2248
+ return (_contentContext$itemT = contentContext.itemTextRefCallback) === null || _contentContext$itemT === void 0 ? void 0 : _contentContext$itemT.call(contentContext, node, itemContext.value, itemContext.disabled);
2249
+ });
2250
+ const textContent = itemTextNode === null || itemTextNode === void 0 ? void 0 : itemTextNode.textContent;
2251
+ const nativeOption = useMemo(()=>/*#__PURE__*/ createElement("option", {
2252
+ key: itemContext.value,
2253
+ value: itemContext.value,
2254
+ disabled: itemContext.disabled
2255
+ }, textContent)
2256
+ , [
2257
+ itemContext.disabled,
2258
+ itemContext.value,
2259
+ textContent
2260
+ ]);
2261
+ const { onNativeOptionAdd: onNativeOptionAdd , onNativeOptionRemove: onNativeOptionRemove } = nativeOptionsContext;
2262
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2263
+ onNativeOptionAdd(nativeOption);
2264
+ return ()=>onNativeOptionRemove(nativeOption)
2265
+ ;
2266
+ }, [
2267
+ onNativeOptionAdd,
2268
+ onNativeOptionRemove,
2269
+ nativeOption
2270
+ ]);
2271
+ return /*#__PURE__*/ createElement(Fragment, null, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
2272
+ id: itemContext.textId
2273
+ }, itemTextProps, {
2274
+ ref: composedRefs
2275
+ })), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? /*#__PURE__*/ createPortal(itemTextProps.children, context.valueNode) : null);
2276
+ });
2277
+ /* -------------------------------------------------------------------------------------------------
2278
+ * SelectItemIndicator
2279
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_INDICATOR_NAME = 'SelectItemIndicator';
2280
+ const $cc7e05a45900e73f$export$6b9198de19accfe6 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2281
+ const { __scopeSelect: __scopeSelect , ...itemIndicatorProps } = props;
2282
+ const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_INDICATOR_NAME, __scopeSelect);
2283
+ return itemContext.isSelected ? /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
2284
+ "aria-hidden": true
2285
+ }, itemIndicatorProps, {
2286
+ ref: forwardedRef
2287
+ })) : null;
2288
+ });
2289
+ /* -------------------------------------------------------------------------------------------------
2290
+ * SelectScrollUpButton
2291
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton';
2292
+ const $cc7e05a45900e73f$export$d8117927658af6d7 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2293
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
2294
+ const [canScrollUp1, setCanScrollUp] = useState(false);
2295
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
2296
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2297
+ if (contentContext.viewport && contentContext.isPositioned) {
2298
+ const viewport = contentContext.viewport;
2299
+ function handleScroll() {
2300
+ const canScrollUp = viewport.scrollTop > 0;
2301
+ setCanScrollUp(canScrollUp);
2302
+ }
2303
+ handleScroll();
2304
+ viewport.addEventListener('scroll', handleScroll);
2305
+ return ()=>viewport.removeEventListener('scroll', handleScroll)
2306
+ ;
2307
+ }
2308
+ }, [
2309
+ contentContext.viewport,
2310
+ contentContext.isPositioned
2311
+ ]);
2312
+ return canScrollUp1 ? /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, _extends({}, props, {
2313
+ ref: composedRefs,
2314
+ onAutoScroll: ()=>{
2315
+ const { viewport: viewport , selectedItem: selectedItem } = contentContext;
2316
+ if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
2317
+ }
2318
+ })) : null;
2319
+ });
2320
+ /* -------------------------------------------------------------------------------------------------
2321
+ * SelectScrollDownButton
2322
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton';
2323
+ const $cc7e05a45900e73f$export$ff951e476c12189 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2324
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
2325
+ const [canScrollDown1, setCanScrollDown] = useState(false);
2326
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
2327
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2328
+ if (contentContext.viewport && contentContext.isPositioned) {
2329
+ const viewport = contentContext.viewport;
2330
+ function handleScroll() {
2331
+ const maxScroll = viewport.scrollHeight - viewport.clientHeight; // we use Math.ceil here because if the UI is zoomed-in
2332
+ // `scrollTop` is not always reported as an integer
2333
+ const canScrollDown = Math.ceil(viewport.scrollTop) < maxScroll;
2334
+ setCanScrollDown(canScrollDown);
2335
+ }
2336
+ handleScroll();
2337
+ viewport.addEventListener('scroll', handleScroll);
2338
+ return ()=>viewport.removeEventListener('scroll', handleScroll)
2339
+ ;
2340
+ }
2341
+ }, [
2342
+ contentContext.viewport,
2343
+ contentContext.isPositioned
2344
+ ]);
2345
+ return canScrollDown1 ? /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, _extends({}, props, {
2346
+ ref: composedRefs,
2347
+ onAutoScroll: ()=>{
2348
+ const { viewport: viewport , selectedItem: selectedItem } = contentContext;
2349
+ if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
2350
+ }
2351
+ })) : null;
2352
+ });
2353
+ const $cc7e05a45900e73f$var$SelectScrollButtonImpl = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2354
+ const { __scopeSelect: __scopeSelect , onAutoScroll: onAutoScroll , ...scrollIndicatorProps } = props;
2355
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext('SelectScrollButton', __scopeSelect);
2356
+ const autoScrollTimerRef = useRef(null);
2357
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
2358
+ const clearAutoScrollTimer = useCallback(()=>{
2359
+ if (autoScrollTimerRef.current !== null) {
2360
+ window.clearInterval(autoScrollTimerRef.current);
2361
+ autoScrollTimerRef.current = null;
2362
+ }
2363
+ }, []);
2364
+ useEffect(()=>{
2365
+ return ()=>clearAutoScrollTimer()
2366
+ ;
2367
+ }, [
2368
+ clearAutoScrollTimer
2369
+ ]); // When the viewport becomes scrollable on either side, the relevant scroll button will mount.
2370
+ // Because it is part of the normal flow, it will push down (top button) or shrink (bottom button)
2371
+ // the viewport, potentially causing the active item to now be partially out of view.
2372
+ // We re-run the `scrollIntoView` logic to make sure it stays within the viewport.
2373
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2374
+ var _activeItem$ref$curre;
2375
+ const activeItem = getItems().find((item)=>item.ref.current === document.activeElement
2376
+ );
2377
+ activeItem === null || activeItem === void 0 || (_activeItem$ref$curre = activeItem.ref.current) === null || _activeItem$ref$curre === void 0 || _activeItem$ref$curre.scrollIntoView({
2378
+ block: 'nearest'
2379
+ });
2380
+ }, [
2381
+ getItems
2382
+ ]);
2383
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2384
+ "aria-hidden": true
2385
+ }, scrollIndicatorProps, {
2386
+ ref: forwardedRef,
2387
+ style: {
2388
+ flexShrink: 0,
2389
+ ...scrollIndicatorProps.style
2390
+ },
2391
+ onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerMove, ()=>{
2392
+ var _contentContext$onIte3;
2393
+ (_contentContext$onIte3 = contentContext.onItemLeave) === null || _contentContext$onIte3 === void 0 || _contentContext$onIte3.call(contentContext);
2394
+ if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
2395
+ }),
2396
+ onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerLeave, ()=>{
2397
+ clearAutoScrollTimer();
2398
+ })
2399
+ }));
2400
+ });
2401
+ /* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2402
+ const { value: value , ...selectProps } = props;
2403
+ const ref = useRef(null);
2404
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
2405
+ const prevValue = $010c2913dbd2fe3d$export$5cae361ad82dce8b(value); // Bubble value change to parents (e.g form change event)
2406
+ useEffect(()=>{
2407
+ const select = ref.current;
2408
+ const selectProto = window.HTMLSelectElement.prototype;
2409
+ const descriptor = Object.getOwnPropertyDescriptor(selectProto, 'value');
2410
+ const setValue = descriptor.set;
2411
+ if (prevValue !== value && setValue) {
2412
+ const event = new Event('change', {
2413
+ bubbles: true
2414
+ });
2415
+ setValue.call(select, value);
2416
+ select.dispatchEvent(event);
2417
+ }
2418
+ }, [
2419
+ prevValue,
2420
+ value
2421
+ ]);
2422
+ /**
2423
+ * We purposefully use a `select` here to support form autofill as much
2424
+ * as possible.
2425
+ *
2426
+ * We purposefully do not add the `value` attribute here to allow the value
2427
+ * to be set programatically and bubble to any parent form `onChange` event.
2428
+ * Adding the `value` will cause React to consider the programatic
2429
+ * dispatch a duplicate and it will get swallowed.
2430
+ *
2431
+ * We use `VisuallyHidden` rather than `display: "none"` because Safari autofill
2432
+ * won't work otherwise.
2433
+ */ return /*#__PURE__*/ createElement($ea1ef594cf570d83$export$439d29a4e110a164, {
2434
+ asChild: true
2435
+ }, /*#__PURE__*/ createElement("select", _extends({}, selectProps, {
2436
+ ref: composedRefs,
2437
+ defaultValue: value
2438
+ })));
2439
+ });
2440
+ $cc7e05a45900e73f$var$BubbleSelect.displayName = 'BubbleSelect';
2441
+ function $cc7e05a45900e73f$var$useTypeaheadSearch(onSearchChange) {
2442
+ const handleSearchChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onSearchChange);
2443
+ const searchRef = useRef('');
2444
+ const timerRef = useRef(0);
2445
+ const handleTypeaheadSearch = useCallback((key)=>{
2446
+ const search = searchRef.current + key;
2447
+ handleSearchChange(search);
2448
+ (function updateSearch(value) {
2449
+ searchRef.current = value;
2450
+ window.clearTimeout(timerRef.current); // Reset `searchRef` 1 second after it was last updated
2451
+ if (value !== '') timerRef.current = window.setTimeout(()=>updateSearch('')
2452
+ , 1000);
2453
+ })(search);
2454
+ }, [
2455
+ handleSearchChange
2456
+ ]);
2457
+ const resetTypeahead = useCallback(()=>{
2458
+ searchRef.current = '';
2459
+ window.clearTimeout(timerRef.current);
2460
+ }, []);
2461
+ useEffect(()=>{
2462
+ return ()=>window.clearTimeout(timerRef.current)
2463
+ ;
2464
+ }, []);
2465
+ return [
2466
+ searchRef,
2467
+ handleTypeaheadSearch,
2468
+ resetTypeahead
2469
+ ];
2470
+ }
2471
+ /**
2472
+ * This is the "meat" of the typeahead matching logic. It takes in a list of items,
2473
+ * the search and the current item, and returns the next item (or `undefined`).
2474
+ *
2475
+ * We normalize the search because if a user has repeatedly pressed a character,
2476
+ * we want the exact same behavior as if we only had that one character
2477
+ * (ie. cycle through items starting with that character)
2478
+ *
2479
+ * We also reorder the items by wrapping the array around the current item.
2480
+ * This is so we always look forward from the current item, and picking the first
2481
+ * item will always be the correct one.
2482
+ *
2483
+ * Finally, if the normalized search is exactly one character, we exclude the
2484
+ * current item from the values because otherwise it would be the first to match always
2485
+ * and focus would never move. This is as opposed to the regular case, where we
2486
+ * don't want focus to move if the current item still matches.
2487
+ */ function $cc7e05a45900e73f$var$findNextItem(items, search, currentItem) {
2488
+ const isRepeated = search.length > 1 && Array.from(search).every((char)=>char === search[0]
2489
+ );
2490
+ const normalizedSearch = isRepeated ? search[0] : search;
2491
+ const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
2492
+ let wrappedItems = $cc7e05a45900e73f$var$wrapArray(items, Math.max(currentItemIndex, 0));
2493
+ const excludeCurrentItem = normalizedSearch.length === 1;
2494
+ if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v)=>v !== currentItem
2495
+ );
2496
+ const nextItem = wrappedItems.find((item)=>item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
2497
+ );
2498
+ return nextItem !== currentItem ? nextItem : undefined;
2499
+ }
2500
+ /**
2501
+ * Wraps an array around itself at a given start index
2502
+ * Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
2503
+ */ function $cc7e05a45900e73f$var$wrapArray(array, startIndex) {
2504
+ return array.map((_, index)=>array[(startIndex + index) % array.length]
2505
+ );
2506
+ }
2507
+ const $cc7e05a45900e73f$export$be92b6f5f03c0fe9 = $cc7e05a45900e73f$export$ef9b1a59e592288f;
2508
+ const $cc7e05a45900e73f$export$41fb9f06171c75f4 = $cc7e05a45900e73f$export$3ac1e88a1c0b9f1;
2509
+ const $cc7e05a45900e73f$export$4c8d1a57a761ef94 = $cc7e05a45900e73f$export$e288731fd71264f0;
2510
+ const $cc7e05a45900e73f$export$f04a61298a47a40f = $cc7e05a45900e73f$export$99b400cabb58c515;
2511
+ const $cc7e05a45900e73f$export$602eac185826482c = $cc7e05a45900e73f$export$b2af6c9944296213;
2512
+ const $cc7e05a45900e73f$export$7c6e2c02157bb7d2 = $cc7e05a45900e73f$export$c973a4b3cb86a03d;
2513
+ const $cc7e05a45900e73f$export$d5c6c08dc2d3ca7 = $cc7e05a45900e73f$export$9ed6e7b40248d36d;
2514
+ const $cc7e05a45900e73f$export$6d08773d2e66f8f2 = $cc7e05a45900e73f$export$13ef48a934230896;
2515
+ const $cc7e05a45900e73f$export$d6e5bf9c43ea9319 = $cc7e05a45900e73f$export$3572fb0fb821ff49;
2516
+ const $cc7e05a45900e73f$export$c3468e2714d175fa = $cc7e05a45900e73f$export$6b9198de19accfe6;
2517
+ const $cc7e05a45900e73f$export$2f60d3ec9ad468f2 = $cc7e05a45900e73f$export$d8117927658af6d7;
2518
+ const $cc7e05a45900e73f$export$bf1aedc3039c8d63 = $cc7e05a45900e73f$export$ff951e476c12189;
2519
+
2520
+ const React = React__default;
2521
+ const BtIconChevronUp2Px = props =>
2522
+ /*#__PURE__*/ React.createElement(
2523
+ "svg",
2524
+ Object.assign(
2525
+ {
2526
+ xmlns: "http://www.w3.org/2000/svg",
2527
+ viewBox: "0 0 32 32"
2528
+ },
2529
+ props
2530
+ ),
2531
+ /*#__PURE__*/ React.createElement("defs", null),
2532
+ /*#__PURE__*/ React.createElement("path", {
2533
+ d:
2534
+ "M28.999,23.5a.99676.99676,0,0,1-.707-.293l-12.28515-12.293L3.708,23.207A.99989.99989,0,0,1,2.294,21.793l13.71289-13.707L29.70605,21.793a.99976.99976,0,0,1-.707,1.707Z",
2535
+ fill: "currentColor"
2536
+ })
2537
+ );
2538
+ var BtIconChevronUp2Px_2 = BtIconChevronUp2Px;
2539
+
2540
+ /** Use `Select` to choose from a dropdown list of options. */
2541
+ var Select = function (_a) {
2542
+ var isRequired = _a.isRequired, isDisabled = _a.isDisabled, placeholder = _a.placeholder, label = _a.label, options = _a.options, onOpenChange = _a.onOpenChange, isDefaultOpen = _a.isDefaultOpen, defaultValue = _a.defaultValue, errorMessage = _a.errorMessage, labelSize = _a.labelSize, helper = _a.helper, name = _a.name, isFluid = _a.isFluid, onBlur = _a.onBlur, onChange = _a.onChange, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure;
2543
+ var id = useId();
2544
+ var arcRootElement = useContext(ArcRootElementContext);
2545
+ var surface = useContext(Context).surface;
2546
+ var _b = useState(defaultValue), selectedValue = _b[0], setSelectedValue = _b[1];
2547
+ var onValueChange = function (value) {
2548
+ onChange && onChange(value);
2549
+ setSelectedValue(value);
2550
+ };
2551
+ var getSelectedValueName = function (value) {
2552
+ var _a;
2553
+ return (_a = options.find(function (option) { return option.value === value; })) === null || _a === void 0 ? void 0 : _a.name;
2554
+ };
2555
+ return (React__default.createElement(FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", isDisabled: isDisabled, disclosureText: disclosureText, disclosureTitle: disclosureTitle, onClickDisclosure: onClickDisclosure },
2556
+ React__default.createElement($cc7e05a45900e73f$export$be92b6f5f03c0fe9, { name: name, required: isRequired, disabled: isDisabled, defaultOpen: isDefaultOpen, value: selectedValue, onOpenChange: onOpenChange, onValueChange: function (value) { return onValueChange(value); } },
2557
+ React__default.createElement($cc7e05a45900e73f$export$41fb9f06171c75f4, { id: id, name: name, onBlur: onBlur, className: classNames("arc-Select-trigger", {
2558
+ "arc-Select-trigger--constrained": !isFluid,
2559
+ "arc-Select-trigger--onDarkSurface": surface === "dark",
2560
+ "arc-Select-trigger--invalid": errorMessage
2561
+ }) },
2562
+ React__default.createElement($cc7e05a45900e73f$export$4c8d1a57a761ef94, { asChild: true, "aria-label": getSelectedValueName(selectedValue) }, !selectedValue ? (React__default.createElement("span", { "aria-hidden": true, className: "arc-Select-placeHolder" }, placeholder)) : (React__default.createElement("span", { className: "arc-Select-valueItem" }, getSelectedValueName(selectedValue)))),
2563
+ React__default.createElement($cc7e05a45900e73f$export$f04a61298a47a40f, { className: "arc-Select-triggerIcon" },
2564
+ React__default.createElement(Icon, { icon: BtIconChevronDown2Px_2, size: 20 }))),
2565
+ React__default.createElement($cc7e05a45900e73f$export$602eac185826482c, { container: arcRootElement },
2566
+ React__default.createElement($cc7e05a45900e73f$export$7c6e2c02157bb7d2, { className: classNames("arc-Select-content", {
2567
+ "arc-Select-content--onDarkSurface": surface === "dark"
2568
+ }) },
2569
+ React__default.createElement($cc7e05a45900e73f$export$2f60d3ec9ad468f2, { className: "arc-Select-scrollButton" },
2570
+ React__default.createElement(Icon, { icon: BtIconChevronUp2Px_2, size: 16 })),
2571
+ React__default.createElement($cc7e05a45900e73f$export$d5c6c08dc2d3ca7, null, options.map(function (_a, i) {
2572
+ var name = _a.name, value = _a.value;
2573
+ return (React__default.createElement($cc7e05a45900e73f$export$6d08773d2e66f8f2, { className: "arc-Select-item", key: "select-item-".concat(i), value: value },
2574
+ React__default.createElement("div", { className: "arc-Select-itemTextWrapper" },
2575
+ React__default.createElement($cc7e05a45900e73f$export$d6e5bf9c43ea9319, { asChild: true },
2576
+ React__default.createElement("span", { className: "arc-Select-itemText" }, name))),
2577
+ React__default.createElement($cc7e05a45900e73f$export$c3468e2714d175fa, null,
2578
+ React__default.createElement(Icon, { icon: BtIconTickAlt2Px_2, size: 20 }))));
2579
+ })),
2580
+ React__default.createElement($cc7e05a45900e73f$export$bf1aedc3039c8d63, { className: "arc-Select-scrollButton" },
2581
+ React__default.createElement(Icon, { icon: BtIconChevronDown2Px_2, size: 16 })))))));
2582
+ };
2583
+
2584
+ export { Select };