@wix/site-ui 1.346.0 → 1.348.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 (226) hide show
  1. package/dist/{6706.js → 1093.js} +3 -3
  2. package/dist/{8724.js → 1219.js} +2 -2
  3. package/dist/{7373.js → 1288.js} +8 -2
  4. package/dist/{5299.js → 1381.js} +98 -127
  5. package/dist/{3056.js → 1607.js} +32 -34
  6. package/dist/1629.js +2 -0
  7. package/dist/1669.js +75 -0
  8. package/dist/1718.js +26 -0
  9. package/dist/{1477.js → 201.js} +17 -26
  10. package/dist/2221.js +9 -0
  11. package/dist/{2445.js → 226.js} +12 -48
  12. package/dist/2387.js +7 -0
  13. package/dist/2580.js +6 -0
  14. package/dist/{1500.js → 2859.js} +10 -34
  15. package/dist/3014.js +178 -0
  16. package/dist/{6247.js → 3054.js} +3 -3
  17. package/dist/{7642.js → 3093.js} +1 -1
  18. package/dist/3189.js +5 -0
  19. package/dist/{7564.js → 331.js} +2 -2
  20. package/dist/3357.js +7 -0
  21. package/dist/{487.js → 3398.js} +38 -39
  22. package/dist/3502.js +224 -0
  23. package/dist/3695.js +50 -0
  24. package/dist/3829.js +1 -1
  25. package/dist/{6588.js → 3859.js} +115 -92
  26. package/dist/{3670.js → 3910.js} +28 -21
  27. package/dist/392.js +7 -0
  28. package/dist/{4549.js → 4155.js} +11 -3
  29. package/dist/4226.js +7 -0
  30. package/dist/{6329.js → 4229.js} +1 -1
  31. package/dist/4293.js +3 -0
  32. package/dist/4346.js +853 -2
  33. package/dist/{285.js → 4472.js} +3 -3
  34. package/dist/4605.js +207 -0
  35. package/dist/{7366.js → 488.js} +60 -7
  36. package/dist/{8750.js → 497.js} +190 -375
  37. package/dist/4989.js +35 -0
  38. package/dist/{6270.js → 510.js} +157 -196
  39. package/dist/5258.js +26 -0
  40. package/dist/{5036.js → 5275.js} +0 -3
  41. package/dist/{8171.js → 5298.js} +90 -102
  42. package/dist/5473.js +11 -0
  43. package/dist/{4745.js → 5490.js} +3 -1
  44. package/dist/{6089.js → 5561.js} +869 -786
  45. package/dist/{8996.js → 5595.js} +4 -3
  46. package/dist/5890.js +25 -0
  47. package/dist/{6046.js → 5969.js} +1 -1
  48. package/dist/5984.js +38 -0
  49. package/dist/{8527.js → 6006.js} +3 -3
  50. package/dist/6040.js +97 -0
  51. package/dist/{8758.js → 6137.js} +10 -8
  52. package/dist/{4281.js → 6140.js} +18 -10
  53. package/dist/{8960.js → 6191.js} +2 -2
  54. package/dist/6240.js +121 -0
  55. package/dist/{4490.js → 6373.js} +7 -5
  56. package/dist/{904.js → 6487.js} +19 -17
  57. package/dist/{9635.js → 6498.js} +1 -1
  58. package/dist/6499.js +4 -7
  59. package/dist/6508.js +7 -0
  60. package/dist/{8225.js → 6540.js} +1 -0
  61. package/dist/6551.js +46 -0
  62. package/dist/{9369.js → 6620.js} +35 -34
  63. package/dist/{4143.js → 6838.js} +19 -10
  64. package/dist/6902.js +48 -0
  65. package/dist/6904.js +51 -0
  66. package/dist/70.js +24 -0
  67. package/dist/7024.js +39 -0
  68. package/dist/{6882.js → 721.js} +737 -362
  69. package/dist/{951.js → 7270.js} +4 -4
  70. package/dist/{3485.js → 7323.js} +143 -111
  71. package/dist/{7541.js → 7488.js} +2 -2
  72. package/dist/{4863.js → 7542.js} +7 -6
  73. package/dist/7551.js +28 -0
  74. package/dist/{7021.js → 7640.js} +1 -1
  75. package/dist/{353.js → 7692.js} +3 -7
  76. package/dist/{4707.js → 7930.js} +2 -2
  77. package/dist/{8052.js → 8.js} +80 -64
  78. package/dist/{6914.js → 8129.js} +3 -15
  79. package/dist/{3319.js → 8358.js} +62 -63
  80. package/dist/{5864.js → 8407.js} +13 -13
  81. package/dist/8488.js +15 -0
  82. package/dist/{4768.js → 8495.js} +1 -1
  83. package/dist/8734.js +171 -0
  84. package/dist/{1763.js → 9018.js} +205 -331
  85. package/dist/9053.js +29 -0
  86. package/dist/9067.js +41 -0
  87. package/dist/{2861.js → 9120.js} +2 -2
  88. package/dist/{42.js → 9197.js} +2 -2
  89. package/dist/{9189.js → 9248.js} +36 -17
  90. package/dist/{2801.js → 9252.js} +4 -9
  91. package/dist/9295.js +7 -0
  92. package/dist/9303.js +8 -0
  93. package/dist/{167.js → 9374.js} +1 -1
  94. package/dist/{9352.js → 9540.js} +17 -47
  95. package/dist/9576.js +51 -0
  96. package/dist/{8272.js → 9591.js} +36 -46
  97. package/dist/{6107.js → 9770.js} +2 -2
  98. package/dist/{5085.js → 9880.js} +6 -3
  99. package/dist/Accordion/index.d.ts +207 -41
  100. package/dist/Accordion/index.js +75 -177
  101. package/dist/AlertDialog/index.d.ts +440 -140
  102. package/dist/AlertDialog/index.js +3 -13
  103. package/dist/Autocomplete/index.d.ts +722 -150
  104. package/dist/Autocomplete/index.js +16 -29
  105. package/dist/Avatar/index.d.ts +38 -3
  106. package/dist/Avatar/index.js +82 -28
  107. package/dist/Breadcrumbs/index.d.ts +63 -91
  108. package/dist/Breadcrumbs/index.js +1 -1
  109. package/dist/Button/index.d.ts +11 -0
  110. package/dist/Button/index.js +2 -2
  111. package/dist/Checkbox/index.d.ts +206 -36
  112. package/dist/Checkbox/index.js +293 -8
  113. package/dist/CheckboxField/index.css +1 -1
  114. package/dist/CheckboxField/index.d.ts +40 -36
  115. package/dist/CheckboxGroup/index.d.ts +50 -36
  116. package/dist/CheckboxGroup/index.js +87 -58
  117. package/dist/CheckboxGroupField/index.css +1 -1
  118. package/dist/Collapsible/index.d.ts +128 -36
  119. package/dist/Collapsible/index.js +21 -25
  120. package/dist/Combobox/index.d.ts +801 -158
  121. package/dist/Combobox/index.js +70 -114
  122. package/dist/ContextMenu/index.d.ts +1162 -195
  123. package/dist/ContextMenu/index.js +46 -36
  124. package/dist/Dialog/index.d.ts +425 -133
  125. package/dist/Dialog/index.js +8 -4
  126. package/dist/Drawer/index.d.ts +589 -144
  127. package/dist/Drawer/index.js +482 -562
  128. package/dist/Field/index.css +1 -1
  129. package/dist/Field/index.d.ts +341 -42
  130. package/dist/Field/index.js +123 -273
  131. package/dist/Fieldset/index.d.ts +11 -0
  132. package/dist/Fieldset/index.js +10 -17
  133. package/dist/Form/index.d.ts +43 -39
  134. package/dist/Form/index.js +58 -50
  135. package/dist/Input/index.css +1 -1
  136. package/dist/Input/index.d.ts +94 -42
  137. package/dist/Input/index.js +1 -1
  138. package/dist/Menu/index.d.ts +1140 -175
  139. package/dist/Menu/index.js +51 -67
  140. package/dist/Menubar/index.d.ts +651 -173
  141. package/dist/Menubar/index.js +12 -16
  142. package/dist/Meter/index.js +21 -18
  143. package/dist/NavigationMenu/index.d.ts +370 -86
  144. package/dist/NavigationMenu/index.js +144 -178
  145. package/dist/NumberField/index.css +1 -1
  146. package/dist/NumberField/index.d.ts +507 -47
  147. package/dist/NumberField/index.js +434 -718
  148. package/dist/Popover/index.d.ts +561 -142
  149. package/dist/Popover/index.js +181 -252
  150. package/dist/PreviewCard/index.d.ts +507 -143
  151. package/dist/PreviewCard/index.js +97 -151
  152. package/dist/Progress/index.d.ts +117 -3
  153. package/dist/Progress/index.js +37 -36
  154. package/dist/Radio/index.d.ts +177 -7
  155. package/dist/Radio/index.js +54 -70
  156. package/dist/RadioField/index.css +1 -1
  157. package/dist/RadioField/index.d.ts +23 -7
  158. package/dist/RadioGroup/index.d.ts +51 -37
  159. package/dist/RadioGroup/index.js +60 -51
  160. package/dist/RadioGroupField/index.css +1 -1
  161. package/dist/RadioGroupField/index.d.ts +40 -37
  162. package/dist/ScrollArea/index.d.ts +295 -1
  163. package/dist/ScrollArea/index.js +256 -324
  164. package/dist/Select/index.d.ts +516 -123
  165. package/dist/Select/index.js +513 -635
  166. package/dist/SelectField/index.css +1 -1
  167. package/dist/SelectField/index.d.ts +109 -134
  168. package/dist/SelectField/index.js +5 -1
  169. package/dist/Separator/index.d.ts +12 -0
  170. package/dist/Separator/index.js +1 -1
  171. package/dist/Slider/index.d.ts +383 -64
  172. package/dist/Slider/index.js +298 -374
  173. package/dist/Switch/index.d.ts +184 -37
  174. package/dist/Switch/index.js +44 -58
  175. package/dist/Tabs/index.d.ts +220 -35
  176. package/dist/Tabs/index.js +199 -193
  177. package/dist/Toast/index.d.ts +280 -64
  178. package/dist/Toast/index.js +299 -374
  179. package/dist/Toggle/index.d.ts +55 -35
  180. package/dist/Toggle/index.js +19 -13
  181. package/dist/ToggleGroup/index.d.ts +62 -35
  182. package/dist/ToggleGroup/index.js +13 -31
  183. package/dist/Toolbar/index.d.ts +117 -2
  184. package/dist/Toolbar/index.js +31 -43
  185. package/dist/Tooltip/index.d.ts +507 -150
  186. package/dist/Tooltip/index.js +163 -213
  187. package/dist/index.d.ts +12912 -5382
  188. package/package.json +3 -3
  189. package/dist/2205.js +0 -26
  190. package/dist/2274.js +0 -34
  191. package/dist/2287.js +0 -17
  192. package/dist/3020.js +0 -7
  193. package/dist/3021.js +0 -72
  194. package/dist/3140.js +0 -4
  195. package/dist/3248.js +0 -307
  196. package/dist/4026.js +0 -12
  197. package/dist/4922.js +0 -15
  198. package/dist/5659.js +0 -4
  199. package/dist/5992.js +0 -447
  200. package/dist/6330.js +0 -30
  201. package/dist/6535.js +0 -72
  202. package/dist/6917.js +0 -55
  203. package/dist/7725.js +0 -10
  204. package/dist/7871.js +0 -38
  205. package/dist/8106.js +0 -239
  206. package/dist/8685.js +0 -102
  207. package/dist/8935.js +0 -8
  208. package/dist/8971.js +0 -40
  209. package/dist/8979.js +0 -10
  210. package/dist/9048.js +0 -52
  211. package/dist/9087.js +0 -256
  212. package/dist/9255.js +0 -136
  213. /package/dist/{1457.js → 1068.js} +0 -0
  214. /package/dist/{6003.js → 1234.js} +0 -0
  215. /package/dist/{4723.js → 1282.js} +0 -0
  216. /package/dist/{6825.js → 1876.js} +0 -0
  217. /package/dist/{5778.js → 1885.js} +0 -0
  218. /package/dist/{2445.js.LICENSE.txt → 226.js.LICENSE.txt} +0 -0
  219. /package/dist/{1279.js → 3278.js} +0 -0
  220. /package/dist/{3296.js → 5568.js} +0 -0
  221. /package/dist/{8685.css → 6240.css} +0 -0
  222. /package/dist/{9829.js → 6488.js} +0 -0
  223. /package/dist/{9863.js → 6534.js} +0 -0
  224. /package/dist/{4495.js → 7718.js} +0 -0
  225. /package/dist/{3395.js → 8866.js} +0 -0
  226. /package/dist/{2418.js → 9837.js} +0 -0
@@ -1,25 +1,27 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useIsoLayoutEffect } from "./6499.js";
3
- import { isSafari } from "./8971.js";
4
- import { visuallyHidden } from "./8225.js";
2
+ import { apple } from "./2221.js";
3
+ import { useIsoLayoutEffect } from "./3357.js";
4
+ import { webkit } from "./3189.js";
5
+ import { visuallyHidden } from "./6540.js";
5
6
  import { isNode, getComputedStyle, getNodeName, isShadowRoot, isHTMLElement } from "./3829.js";
6
- import { contains, activeElement } from "./4549.js";
7
- import { isElementVisible } from "./3319.js";
8
- import { ownerDocument } from "./9829.js";
9
- import { createAttribute } from "./2445.js";
10
- import { useRenderElement, EMPTY_OBJECT } from "./8272.js";
11
- import { useId } from "./2205.js";
12
- import { useStableCallback } from "./7541.js";
13
- import { mergeCleanups } from "./4495.js";
14
- import { addEventListener } from "./4723.js";
15
- import { createChangeEventDetails } from "./4768.js";
16
- import { focusOut } from "./2418.js";
7
+ import { contains, activeElement } from "./4155.js";
8
+ import { isElementVisible } from "./8358.js";
9
+ import { ownerDocument } from "./6488.js";
10
+ import { createAttribute } from "./226.js";
11
+ import { useRenderElement, EMPTY_OBJECT } from "./9591.js";
12
+ import { useId } from "./4989.js";
13
+ import { useStableCallback } from "./7488.js";
14
+ import { mergeCleanups } from "./7718.js";
15
+ import { addEventListener } from "./1282.js";
16
+ import { createChangeEventDetails } from "./8495.js";
17
+ import { focusOut } from "./9837.js";
17
18
  import * as __rspack_external_react from "react";
18
19
  import * as __rspack_external_react_dom_7136dc57 from "react-dom";
20
+ const voiceOver = apple;
19
21
  const FocusGuard_FocusGuard = /*#__PURE__*/ __rspack_external_react.forwardRef(function(props, ref) {
20
22
  const [role, setRole] = __rspack_external_react.useState();
21
23
  useIsoLayoutEffect(()=>{
22
- if (isSafari) setRole('button');
24
+ if (voiceOver && webkit) setRole('button');
23
25
  }, []);
24
26
  const restProps = {
25
27
  tabIndex: 0,
@@ -145,21 +147,18 @@ function getNextTabbable(referenceElement) {
145
147
  function getPreviousTabbable(referenceElement) {
146
148
  return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
147
149
  }
148
- function getTabbableNearElement(referenceElement, dir) {
150
+ function getTabbableNearElement(referenceElement, direction, exclude) {
149
151
  if (!referenceElement) return null;
150
- const list = tabbable(ownerDocument(referenceElement).body);
151
- const elementCount = list.length;
152
- if (0 === elementCount) return null;
152
+ const list = [];
153
+ appendCandidates(ownerDocument(referenceElement).body, list);
153
154
  const index = list.indexOf(referenceElement);
154
155
  if (-1 === index) return null;
155
- const nextIndex = (index + dir + elementCount) % elementCount;
156
- return list[nextIndex];
157
- }
158
- function getTabbableAfterElement(referenceElement) {
159
- return getTabbableNearElement(referenceElement, 1);
160
- }
161
- function getTabbableBeforeElement(referenceElement) {
162
- return getTabbableNearElement(referenceElement, -1);
156
+ const candidates = list.filter(isFocusableElement);
157
+ for(let offset = 1; offset < list.length; offset += 1){
158
+ const element = list[(index + direction * offset + list.length) % list.length];
159
+ if (!contains(exclude, element) && isTabbable(element) && isTabbableRadio(element, candidates)) return element;
160
+ }
161
+ return list[index];
163
162
  }
164
163
  function isOutsideEvent(event, container) {
165
164
  const containerElement = container || event.currentTarget;
@@ -229,7 +228,6 @@ function useFloatingPortalNode(props = {}) {
229
228
  }
230
229
  return;
231
230
  }
232
- if (null == uniqueId) return;
233
231
  const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
234
232
  if (null == resolvedContainer) {
235
233
  if (containerRef.current) {
@@ -246,8 +244,7 @@ function useFloatingPortalNode(props = {}) {
246
244
  }
247
245
  }, [
248
246
  containerProp,
249
- parentPortalNode,
250
- uniqueId
247
+ parentPortalNode
251
248
  ]);
252
249
  const portalElement = useRenderElement('div', componentProps, {
253
250
  ref: [
@@ -264,13 +261,14 @@ function useFloatingPortalNode(props = {}) {
264
261
  });
265
262
  const portalSubtree = containerElement && portalElement ? /*#__PURE__*/ __rspack_external_react_dom_7136dc57.createPortal(portalElement, containerElement) : null;
266
263
  return {
267
- portalNode,
268
- portalSubtree
264
+ node: portalNode,
265
+ nodeId: /*#__PURE__*/ __rspack_external_react.isValidElement(portalElement) ? portalElement.props.id : void 0,
266
+ subtree: portalSubtree
269
267
  };
270
268
  }
271
269
  const FloatingPortal_FloatingPortal = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
272
- const { render, className, style, children, container, renderGuards, ...elementProps } = componentProps;
273
- const { portalNode, portalSubtree } = useFloatingPortalNode({
270
+ const { render, className, style, children, container, portalOwnerRole, ...elementProps } = componentProps;
271
+ const { node: portalNode, nodeId: portalNodeId, subtree: portalSubtree } = useFloatingPortalNode({
274
272
  container,
275
273
  ref: forwardedRef,
276
274
  componentProps,
@@ -284,7 +282,7 @@ const FloatingPortal_FloatingPortal = /*#__PURE__*/ __rspack_external_react.forw
284
282
  const focusInsideDisabledRef = __rspack_external_react.useRef(false);
285
283
  const modal = focusManagerState?.modal;
286
284
  const open = focusManagerState?.open;
287
- const shouldRenderGuards = 'boolean' == typeof renderGuards ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
285
+ const shouldRenderGuards = !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
288
286
  __rspack_external_react.useEffect(()=>{
289
287
  if (!portalNode || modal) return;
290
288
  function onFocus(event) {
@@ -303,8 +301,8 @@ const FloatingPortal_FloatingPortal = /*#__PURE__*/ __rspack_external_react.forw
303
301
  portalNode,
304
302
  modal
305
303
  ]);
306
- __rspack_external_react.useEffect(()=>{
307
- if (!portalNode || false !== open) return;
304
+ useIsoLayoutEffect(()=>{
305
+ if (!portalNode || true !== open || !focusInsideDisabledRef.current) return;
308
306
  enableFocusInside(portalNode);
309
307
  focusInsideDisabledRef.current = false;
310
308
  }, [
@@ -340,7 +338,8 @@ const FloatingPortal_FloatingPortal = /*#__PURE__*/ __rspack_external_react.forw
340
338
  }
341
339
  }),
342
340
  shouldRenderGuards && portalNode && /*#__PURE__*/ jsx("span", {
343
- "aria-owns": portalNode.id,
341
+ role: portalOwnerRole,
342
+ "aria-owns": portalNodeId,
344
343
  style: ownerVisuallyHidden
345
344
  }),
346
345
  portalNode && /*#__PURE__*/ __rspack_external_react_dom_7136dc57.createPortal(children, portalNode),
@@ -363,4 +362,4 @@ const FloatingPortal_FloatingPortal = /*#__PURE__*/ __rspack_external_react.forw
363
362
  });
364
363
  });
365
364
  if ("production" !== process.env.NODE_ENV) FloatingPortal_FloatingPortal.displayName = "FloatingPortal";
366
- export { BASE_UI_SWIPE_IGNORE_SELECTOR, CLICK_TRIGGER_IDENTIFIER, DISABLED_TRANSITIONS_STYLE, DROPDOWN_COLLISION_AVOIDANCE, FloatingPortal_FloatingPortal, FocusGuard_FocusGuard, LEGACY_SWIPE_IGNORE_SELECTOR, POPUP_COLLISION_AVOIDANCE, disableFocusInside, enableFocusInside, focusable, getNextTabbable, getPreviousTabbable, getTabbableAfterElement, getTabbableBeforeElement, isOutsideEvent, isTabbable, ownerVisuallyHidden, tabbable, useFloatingPortalNode, usePortalContext };
365
+ export { BASE_UI_SWIPE_IGNORE_ATTRIBUTE, BASE_UI_SWIPE_IGNORE_SELECTOR, CLICK_TRIGGER_IDENTIFIER, DISABLED_TRANSITIONS_STYLE, DROPDOWN_COLLISION_AVOIDANCE, FloatingPortal_FloatingPortal, FocusGuard_FocusGuard, LEGACY_SWIPE_IGNORE_SELECTOR, POPUP_COLLISION_AVOIDANCE, disableFocusInside, enableFocusInside, focusable, getNextTabbable, getPreviousTabbable, getTabbableNearElement, isOutsideEvent, isTabbable, ownerVisuallyHidden, tabbable, useFloatingPortalNode, usePortalContext, voiceOver };
package/dist/3502.js ADDED
@@ -0,0 +1,224 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { EMPTY_OBJECT, EMPTY_ARRAY, useMergedRefs, useRenderElement } from "./9591.js";
3
+ import { useStableCallback } from "./7488.js";
4
+ import { ARROW_LEFT, scrollIntoViewIfNeeded, ARROW_UP, COMPOSITE_KEYS, ARROW_DOWN, MODIFIER_KEYS, ARROW_RIGHT, isNativeInput } from "./2859.js";
5
+ import { isIndexOutOfListBounds, getMinListIndex, getMaxListIndex, findNonDisabledListIndex, isListIndexDisabled } from "./8358.js";
6
+ import { ACTIVE_COMPOSITE_ITEM } from "./1629.js";
7
+ import { useIsoLayoutEffect } from "./3357.js";
8
+ import { getTarget } from "./4155.js";
9
+ import { isElementDisabled } from "./6499.js";
10
+ import { useDirection } from "./6534.js";
11
+ import { CompositeRootContext } from "./1219.js";
12
+ import { CompositeList } from "./3014.js";
13
+ import * as __rspack_external_react from "react";
14
+ function useCompositeRoot(params) {
15
+ const { loopFocus = true, orientation = 'both', grid, onLoop, direction, highlightedIndex: externalHighlightedIndex, onHighlightedIndexChange: externalSetHighlightedIndex, rootRef: externalRef, enableHomeAndEndKeys = false, stopEventPropagation, disabledIndices, modifierKeys = EMPTY_ARRAY } = params;
16
+ const [internalHighlightedIndex, internalSetHighlightedIndex] = __rspack_external_react.useState(0);
17
+ const isGrid = null != grid;
18
+ const rootRef = __rspack_external_react.useRef(null);
19
+ const mergedRef = useMergedRefs(rootRef, externalRef);
20
+ const elementsRef = __rspack_external_react.useRef([]);
21
+ const hasSetDefaultIndexRef = __rspack_external_react.useRef(false);
22
+ const highlightedElementRef = __rspack_external_react.useRef(null);
23
+ const highlightedIndex = externalHighlightedIndex ?? internalHighlightedIndex;
24
+ const onHighlightedIndexChange = useStableCallback((index, shouldScrollIntoView = false)=>{
25
+ highlightedElementRef.current = elementsRef.current[index] ?? null;
26
+ (externalSetHighlightedIndex ?? internalSetHighlightedIndex)(index);
27
+ if (shouldScrollIntoView) {
28
+ const newActiveItem = elementsRef.current[index];
29
+ scrollIntoViewIfNeeded(rootRef.current, newActiveItem, direction, orientation);
30
+ }
31
+ });
32
+ const onMapChange = useStableCallback((map)=>{
33
+ if (0 === map.size) return;
34
+ if (hasSetDefaultIndexRef.current) {
35
+ const elements = elementsRef.current;
36
+ const nextIndex = elements.indexOf(highlightedElementRef.current);
37
+ if (-1 === nextIndex) {
38
+ const replacement = elements[highlightedIndex];
39
+ if (!replacement || isListIndexDisabled(elements, highlightedIndex, disabledIndices)) onHighlightedIndexChange(getFallbackIndex(elements, disabledIndices));
40
+ else highlightedElementRef.current = replacement;
41
+ } else if (nextIndex !== highlightedIndex) onHighlightedIndexChange(nextIndex);
42
+ return;
43
+ }
44
+ hasSetDefaultIndexRef.current = true;
45
+ const sortedElements = Array.from(map.keys());
46
+ const activeItem = sortedElements.find((compositeElement)=>compositeElement?.hasAttribute(ACTIVE_COMPOSITE_ITEM)) ?? null;
47
+ const activeIndex = activeItem ? map.get(activeItem)?.index ?? -1 : -1;
48
+ if (-1 !== activeIndex) onHighlightedIndexChange(activeIndex);
49
+ else if (isListIndexDisabled(sortedElements, highlightedIndex, disabledIndices)) {
50
+ const firstEnabledIndex = findNonDisabledListIndex(sortedElements, {
51
+ disabledIndices
52
+ });
53
+ if (!isIndexOutOfListBounds(sortedElements, firstEnabledIndex)) onHighlightedIndexChange(firstEnabledIndex);
54
+ }
55
+ scrollIntoViewIfNeeded(rootRef.current, activeItem, direction, orientation);
56
+ });
57
+ useIsoLayoutEffect(()=>{
58
+ if (null == disabledIndices || null != externalHighlightedIndex || !hasSetDefaultIndexRef.current) return;
59
+ const elements = elementsRef.current;
60
+ if (isListIndexDisabled(elements, highlightedIndex, disabledIndices)) {
61
+ const firstEnabledIndex = findNonDisabledListIndex(elements, {
62
+ disabledIndices
63
+ });
64
+ if (!isIndexOutOfListBounds(elements, firstEnabledIndex)) onHighlightedIndexChange(firstEnabledIndex);
65
+ }
66
+ }, [
67
+ disabledIndices,
68
+ externalHighlightedIndex,
69
+ highlightedIndex,
70
+ elementsRef,
71
+ onHighlightedIndexChange
72
+ ]);
73
+ const wrappedOnLoop = useStableCallback((event, prevIndex, nextIndex)=>{
74
+ if (!onLoop) return nextIndex;
75
+ return onLoop(event, prevIndex, nextIndex, elementsRef);
76
+ });
77
+ const onKeyDown = useStableCallback((event)=>{
78
+ const isHomeOrEnd = "Home" === event.key || "End" === event.key;
79
+ if (!COMPOSITE_KEYS.has(event.key) || !enableHomeAndEndKeys && isHomeOrEnd) return;
80
+ if (isModifierKeySet(event, modifierKeys)) return;
81
+ const element = rootRef.current;
82
+ if (!element) return;
83
+ const isRtl = 'rtl' === direction;
84
+ const horizontalForwardKey = isRtl ? ARROW_LEFT : ARROW_RIGHT;
85
+ const horizontalBackwardKey = isRtl ? ARROW_RIGHT : ARROW_LEFT;
86
+ const forwardKey = 'vertical' === orientation ? ARROW_DOWN : horizontalForwardKey;
87
+ const backwardKey = 'vertical' === orientation ? ARROW_UP : horizontalBackwardKey;
88
+ const target = getTarget(event.nativeEvent);
89
+ if (null != target && isNativeInput(target) && !isElementDisabled(target)) {
90
+ const selectionStart = target.selectionStart;
91
+ const selectionEnd = target.selectionEnd;
92
+ const textContent = target.value;
93
+ if (null == selectionStart || event.shiftKey || selectionStart !== selectionEnd) return;
94
+ if (event.key !== backwardKey && selectionStart < textContent.length) return;
95
+ if (event.key !== forwardKey && selectionStart > 0) return;
96
+ }
97
+ let nextIndex = highlightedIndex;
98
+ const minIndex = getMinListIndex(elementsRef, disabledIndices);
99
+ const maxIndex = getMaxListIndex(elementsRef, disabledIndices);
100
+ if (null != grid) nextIndex = grid({
101
+ disabledIndices,
102
+ elementsRef,
103
+ event,
104
+ highlightedIndex,
105
+ loopFocus,
106
+ maxIndex,
107
+ minIndex,
108
+ onLoop: wrappedOnLoop,
109
+ orientation,
110
+ rtl: isRtl
111
+ });
112
+ const isForwardKey = 'vertical' !== orientation && event.key === horizontalForwardKey || 'horizontal' !== orientation && event.key === ARROW_DOWN;
113
+ const isBackwardKey = 'vertical' !== orientation && event.key === horizontalBackwardKey || 'horizontal' !== orientation && event.key === ARROW_UP;
114
+ if (enableHomeAndEndKeys) {
115
+ if ("Home" === event.key) nextIndex = minIndex;
116
+ else if ("End" === event.key) nextIndex = maxIndex;
117
+ }
118
+ if (nextIndex === highlightedIndex && (isForwardKey || isBackwardKey)) if (loopFocus && nextIndex === maxIndex && isForwardKey) {
119
+ nextIndex = minIndex;
120
+ if (onLoop) nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
121
+ } else if (loopFocus && nextIndex === minIndex && isBackwardKey) {
122
+ nextIndex = maxIndex;
123
+ if (onLoop) nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
124
+ } else nextIndex = findNonDisabledListIndex(elementsRef.current, {
125
+ startingIndex: nextIndex,
126
+ decrement: isBackwardKey,
127
+ disabledIndices
128
+ });
129
+ if (nextIndex !== highlightedIndex && !isIndexOutOfListBounds(elementsRef.current, nextIndex)) {
130
+ if (stopEventPropagation) event.stopPropagation();
131
+ if (isGrid || isHomeOrEnd || isForwardKey || isBackwardKey) event.preventDefault();
132
+ onHighlightedIndexChange(nextIndex, true);
133
+ queueMicrotask(()=>{
134
+ elementsRef.current[nextIndex]?.focus();
135
+ });
136
+ }
137
+ });
138
+ const props = {
139
+ ref: mergedRef,
140
+ onFocus (event) {
141
+ const element = rootRef.current;
142
+ const target = getTarget(event.nativeEvent);
143
+ if (!element || null == target || !isNativeInput(target)) return;
144
+ target.setSelectionRange(0, target.value.length);
145
+ },
146
+ onKeyDown
147
+ };
148
+ return {
149
+ props,
150
+ highlightedIndex,
151
+ onHighlightedIndexChange,
152
+ elementsRef,
153
+ onMapChange,
154
+ relayKeyboardEvent: onKeyDown
155
+ };
156
+ }
157
+ function getFallbackIndex(elements, disabledIndices) {
158
+ let fallbackIndex = -1;
159
+ for(let index = 0; index < elements.length; index += 1){
160
+ const element = elements[index];
161
+ if (!(!element || isListIndexDisabled(elements, index, disabledIndices))) {
162
+ if (element.hasAttribute(ACTIVE_COMPOSITE_ITEM)) return index;
163
+ if (-1 === fallbackIndex) fallbackIndex = index;
164
+ }
165
+ }
166
+ return Math.max(fallbackIndex, 0);
167
+ }
168
+ function isModifierKeySet(event, ignoredModifierKeys) {
169
+ for (const key of MODIFIER_KEYS)if (!ignoredModifierKeys.includes(key)) {
170
+ if (event.getModifierState(key)) return true;
171
+ }
172
+ return false;
173
+ }
174
+ function CompositeRoot(componentProps) {
175
+ const { render, className, style, refs = EMPTY_ARRAY, props = EMPTY_ARRAY, state = EMPTY_OBJECT, stateAttributesMapping, highlightedIndex: highlightedIndexProp, onHighlightedIndexChange: onHighlightedIndexChangeProp, orientation, grid, loopFocus, onLoop, enableHomeAndEndKeys, onMapChange: onMapChangeProp, stopEventPropagation = true, rootRef, disabledIndices, modifierKeys, highlightItemOnHover = false, tag = 'div', ...elementProps } = componentProps;
176
+ const direction = useDirection();
177
+ const { props: defaultProps, highlightedIndex, onHighlightedIndexChange, elementsRef, onMapChange: onMapChangeUnwrapped, relayKeyboardEvent } = useCompositeRoot({
178
+ grid,
179
+ loopFocus,
180
+ onLoop,
181
+ orientation,
182
+ highlightedIndex: highlightedIndexProp,
183
+ onHighlightedIndexChange: onHighlightedIndexChangeProp,
184
+ rootRef,
185
+ stopEventPropagation,
186
+ enableHomeAndEndKeys,
187
+ direction,
188
+ disabledIndices,
189
+ modifierKeys
190
+ });
191
+ const element = useRenderElement(tag, componentProps, {
192
+ state,
193
+ ref: refs,
194
+ props: [
195
+ defaultProps,
196
+ ...props,
197
+ elementProps
198
+ ],
199
+ stateAttributesMapping
200
+ });
201
+ const contextValue = __rspack_external_react.useMemo(()=>({
202
+ highlightedIndex,
203
+ onHighlightedIndexChange,
204
+ highlightItemOnHover,
205
+ relayKeyboardEvent
206
+ }), [
207
+ highlightedIndex,
208
+ onHighlightedIndexChange,
209
+ highlightItemOnHover,
210
+ relayKeyboardEvent
211
+ ]);
212
+ return /*#__PURE__*/ jsx(CompositeRootContext.Provider, {
213
+ value: contextValue,
214
+ children: /*#__PURE__*/ jsx(CompositeList, {
215
+ elementsRef: elementsRef,
216
+ onMapChange: (newMap)=>{
217
+ onMapChangeProp?.(newMap);
218
+ onMapChangeUnwrapped(newMap);
219
+ },
220
+ children: element
221
+ })
222
+ });
223
+ }
224
+ export { CompositeRoot };
package/dist/3695.js ADDED
@@ -0,0 +1,50 @@
1
+ import { getWindow } from "./3829.js";
2
+ import { DEFAULT_SIDES } from "./497.js";
3
+ import { ownerDocument } from "./6488.js";
4
+ import { getSide } from "./8358.js";
5
+ const adaptiveOrigin = {
6
+ name: 'adaptiveOrigin',
7
+ async fn (state) {
8
+ const { x: rawX, y: rawY, rects: { floating: floatRect }, elements: { floating }, platform, strategy, placement } = state;
9
+ const win = getWindow(floating);
10
+ const styles = win.getComputedStyle(floating);
11
+ const hasTransition = '0s' !== styles.transitionDuration && '' !== styles.transitionDuration;
12
+ if (!hasTransition) return {
13
+ x: rawX,
14
+ y: rawY,
15
+ data: DEFAULT_SIDES
16
+ };
17
+ const offsetParent = await platform.getOffsetParent?.(floating);
18
+ let offsetDimensions = {
19
+ width: 0,
20
+ height: 0
21
+ };
22
+ if ('fixed' === strategy && win?.visualViewport) offsetDimensions = {
23
+ width: win.visualViewport.width,
24
+ height: win.visualViewport.height
25
+ };
26
+ else if (offsetParent === win) {
27
+ const doc = ownerDocument(floating);
28
+ offsetDimensions = {
29
+ width: doc.documentElement.clientWidth,
30
+ height: doc.documentElement.clientHeight
31
+ };
32
+ } else if (await platform.isElement?.(offsetParent)) offsetDimensions = await platform.getDimensions(offsetParent);
33
+ const currentSide = getSide(placement);
34
+ let x = rawX;
35
+ let y = rawY;
36
+ if ('left' === currentSide) x = offsetDimensions.width - (rawX + floatRect.width);
37
+ if ('top' === currentSide) y = offsetDimensions.height - (rawY + floatRect.height);
38
+ const sideX = 'left' === currentSide ? 'right' : DEFAULT_SIDES.sideX;
39
+ const sideY = 'top' === currentSide ? 'bottom' : DEFAULT_SIDES.sideY;
40
+ return {
41
+ x,
42
+ y,
43
+ data: {
44
+ sideX,
45
+ sideY
46
+ }
47
+ };
48
+ }
49
+ };
50
+ export { adaptiveOrigin };
package/dist/3829.js CHANGED
@@ -90,7 +90,7 @@ function getParentNode(node) {
90
90
  }
91
91
  function getNearestOverflowAncestor(node) {
92
92
  const parentNode = getParentNode(node);
93
- if (isLastTraversableNode(parentNode)) return node.ownerDocument ? node.ownerDocument.body : node.body;
93
+ if (isLastTraversableNode(parentNode)) return (node.ownerDocument || node).body;
94
94
  if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) return parentNode;
95
95
  return getNearestOverflowAncestor(parentNode);
96
96
  }