@wix/site-ui 1.347.0 → 1.349.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,11 +1,11 @@
1
- import { useBaseUiId } from "./6046.js";
2
- import { useIsoLayoutEffect } from "./6499.js";
1
+ import { useBaseUiId } from "./5969.js";
2
+ import { useIsoLayoutEffect } from "./3357.js";
3
3
  function useRegisteredLabelId(idProp, setLabelId) {
4
4
  const id = useBaseUiId(idProp);
5
5
  useIsoLayoutEffect(()=>{
6
6
  setLabelId(id);
7
7
  return ()=>{
8
- setLabelId(void 0);
8
+ setLabelId((currentId)=>currentId === id ? void 0 : currentId);
9
9
  };
10
10
  }, [
11
11
  id,
@@ -1,10 +1,10 @@
1
- import { esm_formatErrorMessage } from "./8272.js";
1
+ import { utils_formatErrorMessage } from "./5473.js";
2
2
  import * as __rspack_external_react from "react";
3
3
  const CompositeRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
4
4
  if ("production" !== process.env.NODE_ENV) CompositeRootContext.displayName = "CompositeRootContext";
5
5
  function useCompositeRootContext(optional = false) {
6
6
  const context = __rspack_external_react.useContext(CompositeRootContext);
7
- if (void 0 === context && !optional) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.' : esm_formatErrorMessage(16));
7
+ if (void 0 === context && !optional) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.' : utils_formatErrorMessage(16));
8
8
  return context;
9
9
  }
10
10
  export { CompositeRootContext, useCompositeRootContext };
@@ -1,8 +1,14 @@
1
1
  import { getWindow } from "./3829.js";
2
+ import { jsdom } from "./5490.js";
3
+ const BOUNDARY_OFFSET = 5;
4
+ function isMouseWithinBounds(event, element) {
5
+ const bounds = getPseudoElementBounds(element);
6
+ return event.clientX >= bounds.left - BOUNDARY_OFFSET && event.clientX <= bounds.right + BOUNDARY_OFFSET && event.clientY >= bounds.top - BOUNDARY_OFFSET && event.clientY <= bounds.bottom + BOUNDARY_OFFSET;
7
+ }
2
8
  function getPseudoElementBounds(element) {
3
9
  const elementRect = element.getBoundingClientRect();
4
- if ('production' !== process.env.NODE_ENV) return elementRect;
5
10
  const win = getWindow(element);
11
+ if (jsdom) return elementRect;
6
12
  const beforeStyles = win.getComputedStyle(element, '::before');
7
13
  const afterStyles = win.getComputedStyle(element, '::after');
8
14
  const hasPseudoElements = 'none' !== beforeStyles.content || 'none' !== afterStyles.content;
@@ -22,4 +28,4 @@ function getPseudoElementBounds(element) {
22
28
  bottom: elementRect.bottom + heightDiff / 2
23
29
  };
24
30
  }
25
- export { getPseudoElementBounds };
31
+ export { isMouseWithinBounds };
@@ -1,41 +1,46 @@
1
- import { useTimeout } from "./42.js";
2
- import { useStableCallback } from "./7541.js";
3
- import { isListIndexDisabled, getGridCellIndices, findNonDisabledListIndex, getGridNavigatedIndex, createGridCellMap, getMinListIndex, isElementVisible, getGridCellIndexOfCorner, getMaxListIndex, isIndexOutOfListBounds } from "./3319.js";
4
- import { stopEvent, isVirtualPointerEvent, isVirtualClick } from "./6330.js";
5
- import { getTarget, contains, activeElement } from "./4549.js";
6
- import { useIsoLayoutEffect } from "./6499.js";
7
- import { ARROW_LEFT, ARROW_UP, ARROW_DOWN, ARROW_RIGHT } from "./4745.js";
8
- import { getFloatingFocusElement, isTypeableCombobox } from "./8758.js";
9
- import { useValueAsRef } from "./4707.js";
10
- import { useFloatingParentNodeId, useFloatingTree } from "./285.js";
11
- import { useAnimationFrame } from "./8996.js";
12
- import { enqueueFocus } from "./3485.js";
13
- import { ownerDocument } from "./9829.js";
14
- import { createChangeEventDetails } from "./4768.js";
15
- import { listNavigation, focusOut } from "./2418.js";
1
+ import { useStableCallback } from "./7488.js";
2
+ import { useTimeout } from "./9197.js";
3
+ import { isListIndexDisabled, isVirtualClick, isVirtualPointerEvent, getNextListIndex, getMinListIndex, stopEvent, isElementVisible, isIndexOutOfListBounds, getMaxListIndex } from "./8358.js";
4
+ import { EMPTY_ARRAY } from "./9591.js";
5
+ import { getTarget, contains, activeElement } from "./4155.js";
6
+ import { useIsoLayoutEffect } from "./3357.js";
7
+ import { webkit } from "./3189.js";
8
+ import { ARROW_LEFT, ARROW_UP, ARROW_DOWN, ARROW_RIGHT } from "./5490.js";
9
+ import { getFloatingFocusElement, isTypeableCombobox, isTypeableElement } from "./6137.js";
10
+ import { useValueAsRef } from "./7930.js";
11
+ import { useFloatingParentNodeId, useFloatingTree } from "./4472.js";
12
+ import { useAnimationFrame } from "./5595.js";
13
+ import { enqueueFocus } from "./7323.js";
14
+ import { ownerDocument } from "./6488.js";
15
+ import { createChangeEventDetails } from "./8495.js";
16
+ import { listNavigation, focusOut } from "./9837.js";
16
17
  import { isHTMLElement } from "./3829.js";
17
18
  import * as __rspack_external_react from "react";
18
- function useTypeahead(context, props) {
19
- const { listRef, elementsRef, activeIndex, onMatch: onMatchProp, onTyping, enabled = true, resetMs = 750, selectedIndex = null } = props;
20
- const store = 'rootStore' in context ? context.rootStore : context;
19
+ function useTypeahead(store, props) {
20
+ const { listRef, elementsRef, activeIndex, onMatch: onMatchProp, disabledIndices, onTyping: onTypingProp, enabled = true, resetMs = 750, selectedIndex = null } = props;
21
+ const onTyping = useStableCallback(onTypingProp);
21
22
  const open = store.useState('open');
22
23
  const timeout = useTimeout();
23
24
  const stringRef = __rspack_external_react.useRef('');
24
25
  const prevIndexRef = __rspack_external_react.useRef(selectedIndex ?? activeIndex ?? -1);
25
26
  const matchIndexRef = __rspack_external_react.useRef(null);
26
27
  const onKeyDown = useStableCallback((event)=>{
27
- function isVisible(index) {
28
- const element = elementsRef?.current[index];
29
- return !element || isElementVisible(element);
28
+ function getElement(index) {
29
+ return elementsRef?.current[index];
30
+ }
31
+ function isItemAvailable(index) {
32
+ const element = getElement(index);
33
+ if (element && !isElementVisible(element) || element?.matches(':disabled')) return false;
34
+ return null == disabledIndices || !isListIndexDisabled(EMPTY_ARRAY, index, disabledIndices);
30
35
  }
31
36
  function getMatchingIndex(list, string, startIndex = 0) {
32
37
  if (0 === list.length) return -1;
33
38
  const normalizedStartIndex = (startIndex % list.length + list.length) % list.length;
34
- const lowerString = string.toLocaleLowerCase();
39
+ const lowerString = string.toLowerCase();
35
40
  for(let offset = 0; offset < list.length; offset += 1){
36
41
  const index = (normalizedStartIndex + offset) % list.length;
37
42
  const text = list[index];
38
- if (text?.toLocaleLowerCase().startsWith(lowerString) && isVisible(index)) return index;
43
+ if (text?.toLowerCase().startsWith(lowerString) && isItemAvailable(index)) return index;
39
44
  }
40
45
  return -1;
41
46
  }
@@ -54,7 +59,7 @@ function useTypeahead(context, props) {
54
59
  }
55
60
  const isNewSession = '' === stringRef.current;
56
61
  if (isNewSession) prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
57
- const allowRapidSuccessionOfFirstLetter = listContent.every((text)=>text ? text[0]?.toLocaleLowerCase() !== text[1]?.toLocaleLowerCase() : true);
62
+ const allowRapidSuccessionOfFirstLetter = listContent.every((text, index)=>text && isItemAvailable(index) ? text[0]?.toLowerCase() !== text[1]?.toLowerCase() : true);
58
63
  if (allowRapidSuccessionOfFirstLetter && stringRef.current === event.key) {
59
64
  stringRef.current = '';
60
65
  prevIndexRef.current = matchIndexRef.current;
@@ -69,7 +74,7 @@ function useTypeahead(context, props) {
69
74
  const startIndex = (prevIndex ?? 0) + 1;
70
75
  const index = getMatchingIndex(listContent, stringRef.current, startIndex);
71
76
  if (-1 !== index) {
72
- onMatchProp?.(index);
77
+ onMatchProp?.(index, event);
73
78
  matchIndexRef.current = index;
74
79
  } else if (' ' !== event.key) {
75
80
  stringRef.current = '';
@@ -91,18 +96,15 @@ function useTypeahead(context, props) {
91
96
  if (!open && null !== selectedIndex) return;
92
97
  timeout.clear();
93
98
  matchIndexRef.current = null;
94
- if ('' !== stringRef.current) stringRef.current = '';
95
- }, [
96
- open,
97
- selectedIndex,
98
- timeout
99
- ]);
100
- useIsoLayoutEffect(()=>{
101
- if (open && '' === stringRef.current) prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
99
+ if ('' !== stringRef.current) {
100
+ stringRef.current = '';
101
+ onTyping?.(false);
102
+ }
102
103
  }, [
103
104
  open,
104
105
  selectedIndex,
105
- activeIndex
106
+ timeout,
107
+ onTyping
106
108
  ]);
107
109
  const sharedProps = __rspack_external_react.useMemo(()=>({
108
110
  onKeyDown,
@@ -119,7 +121,9 @@ function useTypeahead(context, props) {
119
121
  sharedProps
120
122
  ]);
121
123
  }
122
- const ESCAPE = 'Escape';
124
+ function isStationaryWebKitPointer(event) {
125
+ return webkit && 0 === event.movementX && 0 === event.movementY;
126
+ }
123
127
  function doSwitch(orientation, vertical, horizontal) {
124
128
  switch(orientation){
125
129
  case 'vertical':
@@ -145,22 +149,22 @@ function isCrossOrientationOpenKey(key, orientation, rtl) {
145
149
  const horizontal = key === ARROW_DOWN;
146
150
  return doSwitch(orientation, vertical, horizontal);
147
151
  }
148
- function isCrossOrientationCloseKey(key, orientation, rtl, cols) {
152
+ function isCrossOrientationCloseKey(key, orientation, rtl, grid) {
149
153
  const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
150
154
  const horizontal = key === ARROW_UP;
151
- if ('both' === orientation || 'horizontal' === orientation && cols && cols > 1) return key === ESCAPE;
155
+ if ('both' === orientation || 'horizontal' === orientation && grid) return 'Escape' === key;
152
156
  return doSwitch(orientation, vertical, horizontal);
153
157
  }
154
- function useListNavigation(context, props) {
155
- const { listRef, activeIndex, onNavigate: onNavigateProp = ()=>{}, enabled = true, selectedIndex = null, allowEscape = false, loopFocus = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = 'auto', focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices, orientation = 'vertical', parentOrientation, cols = 1, id, resetOnPointerLeave = true, externalTree } = props;
158
+ function useListNavigation(store, props) {
159
+ const { listRef, activeIndex, onNavigate: onNavigateProp = ()=>{}, enabled = true, selectedIndex = null, allowEscape = false, loopFocus = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = 'auto', focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices, orientation = 'vertical', triggerOrientation = orientation, parentOrientation, id, resetOnPointerLeave = true, externalTree, nestedReturnFocusRef, grid: navigateGrid } = props;
160
+ const isGrid = null != navigateGrid;
156
161
  if ('production' !== process.env.NODE_ENV) {
157
162
  if (allowEscape) {
158
163
  if (!loopFocus) console.warn('`useListNavigation` looping must be enabled to allow escaping.');
159
164
  if (!virtual) console.warn('`useListNavigation` must be virtual to allow escaping.');
160
165
  }
161
- if ('vertical' === orientation && cols > 1) console.warn('In grid list navigation mode (`cols` > 1), the `orientation` should', 'be either "horizontal" or "both".');
166
+ if ('vertical' === orientation && isGrid) console.warn('In grid list navigation mode, the `orientation` should', 'be either "horizontal" or "both".');
162
167
  }
163
- const store = 'rootStore' in context ? context.rootStore : context;
164
168
  const open = store.useState('open');
165
169
  const floatingElement = store.useState('floatingElement');
166
170
  const domReferenceElement = store.useState('domReferenceElement');
@@ -177,7 +181,6 @@ function useListNavigation(context, props) {
177
181
  const onNavigate = useStableCallback((event)=>{
178
182
  onNavigateProp(-1 === indexRef.current ? null : indexRef.current, event);
179
183
  });
180
- const previousOnNavigateRef = __rspack_external_react.useRef(onNavigate);
181
184
  const previousMountedRef = __rspack_external_react.useRef(!!floatingElement);
182
185
  const previousOpenRef = __rspack_external_react.useRef(open);
183
186
  const forceSyncFocusRef = __rspack_external_react.useRef(false);
@@ -190,9 +193,9 @@ function useListNavigation(context, props) {
190
193
  const focusFrame = useAnimationFrame();
191
194
  const waitForListPopulatedFrame = useAnimationFrame();
192
195
  const focusItem = useStableCallback(()=>{
196
+ focusFrame.cancel();
193
197
  function runFocus(item) {
194
- if (virtual) tree?.events.emit('virtualfocus', item);
195
- else cancelQueuedFocusRef.current = enqueueFocus(item, {
198
+ if (!virtual) cancelQueuedFocusRef.current = enqueueFocus(item, {
196
199
  sync: forceSyncFocusRef.current,
197
200
  preventScroll: true
198
201
  });
@@ -218,6 +221,13 @@ function useListNavigation(context, props) {
218
221
  dataRef,
219
222
  orientation
220
223
  ]);
224
+ useIsoLayoutEffect(()=>{
225
+ if (!open) keyRef.current = null;
226
+ if (!open || 'auto' !== focusItemOnOpen) focusItemOnOpenRef.current = focusItemOnOpen;
227
+ }, [
228
+ open,
229
+ focusItemOnOpen
230
+ ]);
221
231
  useIsoLayoutEffect(()=>{
222
232
  if (!enabled) return;
223
233
  if (open && floatingElement) {
@@ -228,7 +238,7 @@ function useListNavigation(context, props) {
228
238
  }
229
239
  } else if (previousMountedRef.current) {
230
240
  indexRef.current = -1;
231
- previousOnNavigateRef.current();
241
+ onNavigate();
232
242
  }
233
243
  }, [
234
244
  enabled,
@@ -261,7 +271,7 @@ function useListNavigation(context, props) {
261
271
  }
262
272
  runs += 1;
263
273
  } else {
264
- indexRef.current = null == keyRef.current || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef) : getMaxListIndex(listRef);
274
+ indexRef.current = null == keyRef.current || isMainOrientationToEndKey(keyRef.current, triggerOrientation, rtl) || nested ? getMinListIndex(listRef) : getMaxListIndex(listRef);
265
275
  keyRef.current = null;
266
276
  onNavigate();
267
277
  }
@@ -281,7 +291,7 @@ function useListNavigation(context, props) {
281
291
  selectedIndexRef,
282
292
  nested,
283
293
  listRef,
284
- orientation,
294
+ triggerOrientation,
285
295
  rtl,
286
296
  onNavigate,
287
297
  focusItem,
@@ -291,7 +301,7 @@ function useListNavigation(context, props) {
291
301
  if (!enabled || floatingElement || !tree || virtual || !previousMountedRef.current) return;
292
302
  const nodes = tree.nodesRef.current;
293
303
  const parent = nodes.find((node)=>node.id === parentId)?.context?.elements.floating;
294
- const activeEl = activeElement(ownerDocument(floatingElement));
304
+ const activeEl = activeElement(ownerDocument(domReferenceElement ?? parent ?? null));
295
305
  const treeContainsActiveEl = nodes.some((node)=>node.context && contains(node.context.elements.floating, activeEl));
296
306
  if (parent && !treeContainsActiveEl && isPointerModalityRef.current) parent.focus({
297
307
  preventScroll: true
@@ -299,24 +309,15 @@ function useListNavigation(context, props) {
299
309
  }, [
300
310
  enabled,
301
311
  floatingElement,
312
+ domReferenceElement,
302
313
  tree,
303
314
  parentId,
304
315
  virtual
305
316
  ]);
306
317
  useIsoLayoutEffect(()=>{
307
- previousOnNavigateRef.current = onNavigate;
308
318
  previousOpenRef.current = open;
309
319
  previousMountedRef.current = !!floatingElement;
310
320
  });
311
- useIsoLayoutEffect(()=>{
312
- if (!open) {
313
- keyRef.current = null;
314
- focusItemOnOpenRef.current = focusItemOnOpen;
315
- }
316
- }, [
317
- open,
318
- focusItemOnOpen
319
- ]);
320
321
  const hasActiveIndex = null != activeIndex;
321
322
  const syncCurrentTarget = useStableCallback((event)=>{
322
323
  if (!latestOpenRef.current) return;
@@ -333,13 +334,14 @@ function useListNavigation(context, props) {
333
334
  forceSyncFocusRef.current = true;
334
335
  if (229 === event.which) return;
335
336
  if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) return;
336
- if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, cols)) {
337
+ if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, isGrid)) {
337
338
  if (!isMainOrientationKey(event.key, getParentOrientation())) stopEvent(event);
338
339
  store.setOpen(false, createChangeEventDetails(listNavigation, event.nativeEvent));
339
- if (isHTMLElement(domReferenceElement)) if (virtual) tree?.events.emit('virtualfocus', domReferenceElement);
340
- else domReferenceElement.focus();
340
+ const returnElement = nestedReturnFocusRef?.current ?? domReferenceElement;
341
+ if (isHTMLElement(returnElement)) returnElement.focus();
341
342
  return;
342
343
  }
344
+ if (null != activeIndex && activeIndex !== indexRef.current && !isIndexOutOfListBounds(listRef.current, activeIndex)) indexRef.current = activeIndex;
343
345
  const currentIndex = indexRef.current;
344
346
  const minIndex = getMinListIndex(listRef, disabledIndices);
345
347
  const maxIndex = getMaxListIndex(listRef, disabledIndices);
@@ -355,32 +357,9 @@ function useListNavigation(context, props) {
355
357
  onNavigate(event);
356
358
  }
357
359
  }
358
- if (cols > 1) {
359
- const sizes = Array.from({
360
- length: listRef.current.length
361
- }, ()=>({
362
- width: 1,
363
- height: 1
364
- }));
365
- const cellMap = createGridCellMap(sizes, cols, false);
366
- const minGridIndex = cellMap.findIndex((index)=>null != index && !isListIndexDisabled(listRef.current, index, disabledIndices));
367
- const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex)=>null == index || isListIndexDisabled(listRef.current, index, disabledIndices) ? foundIndex : cellIndex, -1);
368
- const index = cellMap[getGridNavigatedIndex(cellMap.map((itemIndex)=>null != itemIndex ? listRef.current[itemIndex] : null), {
369
- event,
370
- orientation,
371
- loopFocus,
372
- rtl,
373
- cols,
374
- disabledIndices: getGridCellIndices([
375
- ...('function' != typeof disabledIndices ? disabledIndices : null) || listRef.current.map((_, listIndex)=>isListIndexDisabled(listRef.current, listIndex, disabledIndices) ? listIndex : void 0),
376
- void 0
377
- ], cellMap),
378
- minIndex: minGridIndex,
379
- maxIndex: maxGridIndex,
380
- prevIndex: getGridCellIndexOfCorner(indexRef.current > maxIndex ? minIndex : indexRef.current, sizes, cellMap, cols, event.key === ARROW_DOWN ? 'bl' : event.key === (rtl ? ARROW_LEFT : ARROW_RIGHT) ? 'tr' : 'tl'),
381
- stopEvent: true
382
- })];
383
- if (null != index) {
360
+ if (null != navigateGrid) {
361
+ const index = navigateGrid(event, indexRef.current, listRef, orientation, loopFocus, rtl, disabledIndices, minIndex, maxIndex);
362
+ if (null != index && index !== indexRef.current) {
384
363
  indexRef.current = index;
385
364
  onNavigate(event);
386
365
  }
@@ -388,40 +367,23 @@ function useListNavigation(context, props) {
388
367
  }
389
368
  if (isMainOrientationKey(event.key, orientation)) {
390
369
  stopEvent(event);
391
- if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {
370
+ const focusedElement = activeElement(event.currentTarget.ownerDocument);
371
+ if (open && !virtual && contains(event.currentTarget, focusedElement) && !listRef.current.some((item)=>null != item && contains(item, focusedElement))) {
392
372
  indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
393
373
  onNavigate(event);
374
+ if (activeIndex === indexRef.current) focusItem();
394
375
  return;
395
376
  }
396
- if (isMainOrientationToEndKey(event.key, orientation, rtl)) if (loopFocus) if (currentIndex >= maxIndex) if (allowEscape && currentIndex !== listRef.current.length) indexRef.current = -1;
397
- else {
398
- forceSyncFocusRef.current = false;
399
- indexRef.current = minIndex;
400
- }
401
- else indexRef.current = findNonDisabledListIndex(listRef.current, {
402
- startingIndex: currentIndex,
403
- disabledIndices
404
- });
405
- else indexRef.current = Math.min(maxIndex, findNonDisabledListIndex(listRef.current, {
406
- startingIndex: currentIndex,
407
- disabledIndices
408
- }));
409
- else if (loopFocus) if (currentIndex <= minIndex) if (allowEscape && -1 !== currentIndex) indexRef.current = listRef.current.length;
410
- else {
411
- forceSyncFocusRef.current = false;
412
- indexRef.current = maxIndex;
413
- }
414
- else indexRef.current = findNonDisabledListIndex(listRef.current, {
415
- startingIndex: currentIndex,
416
- decrement: true,
417
- disabledIndices
377
+ const { index, wrapped } = getNextListIndex(listRef.current, currentIndex, {
378
+ decrement: !isMainOrientationToEndKey(event.key, orientation, rtl),
379
+ loopFocus,
380
+ allowEscape,
381
+ disabledIndices,
382
+ minIndex,
383
+ maxIndex
418
384
  });
419
- else indexRef.current = Math.max(minIndex, findNonDisabledListIndex(listRef.current, {
420
- startingIndex: currentIndex,
421
- decrement: true,
422
- disabledIndices
423
- }));
424
- if (isIndexOutOfListBounds(listRef.current, indexRef.current)) indexRef.current = -1;
385
+ if (wrapped) forceSyncFocusRef.current = false;
386
+ indexRef.current = index;
425
387
  onNavigate(event);
426
388
  }
427
389
  });
@@ -431,10 +393,13 @@ function useListNavigation(context, props) {
431
393
  forceSyncFocusRef.current = true;
432
394
  syncCurrentTarget(event);
433
395
  },
434
- onClick: ({ currentTarget })=>currentTarget.focus({
396
+ onClick ({ currentTarget }) {
397
+ if (!virtual) currentTarget.focus({
435
398
  preventScroll: true
436
- }),
399
+ });
400
+ },
437
401
  onMouseMove (event) {
402
+ if (isStationaryWebKitPointer(event)) return;
438
403
  forceSyncFocusRef.current = true;
439
404
  forceScrollIntoViewRef.current = false;
440
405
  if (focusItemOnHover) syncCurrentTarget(event);
@@ -479,32 +444,34 @@ function useListNavigation(context, props) {
479
444
  activeIndex
480
445
  ]);
481
446
  const floating = __rspack_external_react.useMemo(()=>({
482
- 'aria-orientation': 'both' === orientation ? void 0 : orientation,
483
447
  ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
484
448
  onKeyDown (event) {
485
449
  if ('Tab' === event.key && event.shiftKey && open && !virtual) {
486
450
  const target = getTarget(event.nativeEvent);
487
451
  if (target && !contains(floatingFocusElementRef.current, target)) return;
488
452
  stopEvent(event);
489
- store.setOpen(false, createChangeEventDetails(focusOut, event.nativeEvent));
490
- if (isHTMLElement(domReferenceElement)) domReferenceElement.focus();
453
+ const details = createChangeEventDetails(focusOut, event.nativeEvent);
454
+ store.setOpen(false, details);
455
+ const returnElement = nestedReturnFocusRef?.current ?? domReferenceElement;
456
+ if (!details.isCanceled && isHTMLElement(returnElement)) returnElement.focus();
491
457
  return;
492
458
  }
493
459
  commonOnKeyDown(event);
494
460
  },
495
- onPointerMove () {
461
+ onPointerMove (event) {
462
+ if (isStationaryWebKitPointer(event)) return;
496
463
  isPointerModalityRef.current = true;
497
464
  }
498
465
  }), [
499
466
  ariaActiveDescendantProp,
500
467
  commonOnKeyDown,
501
468
  floatingFocusElementRef,
502
- orientation,
503
469
  typeableComboboxReference,
504
470
  store,
505
471
  open,
506
472
  virtual,
507
- domReferenceElement
473
+ domReferenceElement,
474
+ nestedReturnFocusRef
508
475
  ]);
509
476
  const trigger = __rspack_external_react.useMemo(()=>{
510
477
  function openOnNavigationKeyDown(event) {
@@ -523,9 +490,9 @@ function useListNavigation(context, props) {
523
490
  isPointerModalityRef.current = false;
524
491
  const isArrowKey = event.key.startsWith('Arrow');
525
492
  const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
526
- const isMainKey = isMainOrientationKey(event.key, orientation);
493
+ const isMainKey = isMainOrientationKey(event.key, currentOpen ? orientation : triggerOrientation);
527
494
  const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || 'Enter' === event.key || '' === event.key.trim();
528
- if (virtual && currentOpen) return commonOnKeyDown(event);
495
+ if (virtual && currentOpen && (!nested || isTypeableElement(event.currentTarget))) return commonOnKeyDown(event);
529
496
  if (!currentOpen && !openOnArrowKeyDown && isArrowKey) return;
530
497
  if (isNavigationKey) {
531
498
  const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
@@ -537,6 +504,7 @@ function useListNavigation(context, props) {
537
504
  if (currentOpen) {
538
505
  indexRef.current = getMinEnabledIndex();
539
506
  onNavigate(event);
507
+ if (virtual) floatingFocusElementRef.current?.focus();
540
508
  } else openOnNavigationKeyDown(event);
541
509
  }
542
510
  return;
@@ -550,6 +518,7 @@ function useListNavigation(context, props) {
550
518
  }
551
519
  },
552
520
  onFocus (event) {
521
+ if (event.target !== event.currentTarget) return;
553
522
  if (store.select('open') && !virtual) {
554
523
  indexRef.current = -1;
555
524
  onNavigate(event);
@@ -569,10 +538,12 @@ function useListNavigation(context, props) {
569
538
  store,
570
539
  openOnArrowKeyDown,
571
540
  orientation,
541
+ triggerOrientation,
572
542
  getParentOrientation,
573
543
  rtl,
574
544
  selectedIndexRef,
575
- virtual
545
+ virtual,
546
+ floatingFocusElementRef
576
547
  ]);
577
548
  const reference = __rspack_external_react.useMemo(()=>({
578
549
  ...ariaActiveDescendantProp,
@@ -1,35 +1,33 @@
1
- import { Timeout, useTimeout } from "./42.js";
2
- import { useRefWithInit } from "./8272.js";
3
- import { useOnMount } from "./2861.js";
4
- import { isMouseLikePointerType } from "./6330.js";
5
- import { useFloatingTree, useFloatingParentNodeId } from "./285.js";
6
- import { useStableCallback } from "./7541.js";
7
- import { useIsoLayoutEffect } from "./6499.js";
1
+ import { Timeout, useTimeout } from "./9197.js";
2
+ import { useRefWithInit } from "./9591.js";
3
+ import { useOnMount } from "./9120.js";
4
+ import { isMouseLikePointerType } from "./8358.js";
5
+ import { useFloatingTree, useFloatingParentNodeId } from "./4472.js";
6
+ import { useStableCallback } from "./7488.js";
7
+ import { useIsoLayoutEffect } from "./3357.js";
8
8
  import { isElement } from "./3829.js";
9
- import { ownerDocument } from "./9829.js";
10
- import { getNodeChildren } from "./5992.js";
11
- import { createChangeEventDetails } from "./4768.js";
12
- import { triggerHover } from "./2418.js";
13
- import { getTarget, contains } from "./4549.js";
14
- import { isTargetInsideEnabledTrigger, isInteractiveElement } from "./8758.js";
15
- import { mergeCleanups } from "./4495.js";
16
- import { addEventListener } from "./4723.js";
9
+ import { ownerDocument } from "./6488.js";
10
+ import { closest, getTarget, contains } from "./4155.js";
11
+ import { getNodeChildren } from "./4346.js";
12
+ import { createChangeEventDetails } from "./8495.js";
13
+ import { triggerHover } from "./9837.js";
14
+ import { isTargetInsideEnabledTrigger, isInteractiveElement } from "./6137.js";
15
+ import { mergeCleanups } from "./7718.js";
16
+ import { addEventListener } from "./1282.js";
17
17
  import * as __rspack_external_react from "react";
18
18
  class HoverInteraction {
19
- constructor(){
20
- this.pointerType = void 0;
21
- this.interactedInside = false;
22
- this.handler = void 0;
23
- this.blockMouseMove = true;
24
- this.performedPointerEventsMutation = false;
25
- this.pointerEventsScopeElement = null;
26
- this.pointerEventsReferenceElement = null;
27
- this.pointerEventsFloatingElement = null;
28
- this.restTimeoutPending = false;
29
- this.openChangeTimeout = new Timeout();
30
- this.restTimeout = new Timeout();
31
- this.handleCloseOptions = void 0;
32
- }
19
+ pointerType = void 0;
20
+ interactedInside = false;
21
+ handler = void 0;
22
+ blockMouseMove = true;
23
+ performedPointerEventsMutation = false;
24
+ pointerEventsScopeElement = null;
25
+ pointerEventsReferenceElement = null;
26
+ pointerEventsFloatingElement = null;
27
+ restTimeoutPending = false;
28
+ openChangeTimeout = new Timeout();
29
+ restTimeout = new Timeout();
30
+ handleCloseOptions = void 0;
33
31
  static create() {
34
32
  return new HoverInteraction();
35
33
  }
@@ -95,9 +93,8 @@ function useHoverShared_isClickLikeOpenEvent(openEventType, interactedInside) {
95
93
  function isHoverOpenEvent(openEventType) {
96
94
  return openEventType?.includes('mouse') && 'mousedown' !== openEventType;
97
95
  }
98
- function useHoverFloatingInteraction(context, parameters = {}) {
96
+ function useHoverFloatingInteraction(store, parameters = {}) {
99
97
  const { enabled = true, closeDelay: closeDelayProp = 0, nodeId: nodeIdProp } = parameters;
100
- const store = 'rootStore' in context ? context.rootStore : context;
101
98
  const open = store.useState('open');
102
99
  const floatingElement = store.useState('floatingElement');
103
100
  const domReferenceElement = store.useState('domReferenceElement');
@@ -136,7 +133,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
136
133
  if (parentFloating) parentFloating.style.pointerEvents = '';
137
134
  const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
138
135
  const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
139
- const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest('[data-rootownerid]') ?? doc.body;
136
+ const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? closest(ref, '[data-rootownerid]') ?? doc.body;
140
137
  applySafePolygonPointerEventsMutation(instance, {
141
138
  scopeElement,
142
139
  referenceElement: ref,
@@ -180,7 +177,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
180
177
  instance.interactedInside = false;
181
178
  return;
182
179
  }
183
- instance.interactedInside = target?.closest('[aria-haspopup]') != null;
180
+ instance.interactedInside = null != closest(target, '[aria-haspopup]');
184
181
  }
185
182
  function onFloatingMouseEnter() {
186
183
  instance.openChangeTimeout.clear();
@@ -197,7 +194,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
197
194
  if (isMovingIntoDescendantFloating) return;
198
195
  if (instance.handler) return void instance.handler(event);
199
196
  clearPointerEvents();
200
- if (!isClickLikeOpenEvent()) closeWithDelay(event);
197
+ if (isHoverOpen() && !isClickLikeOpenEvent()) closeWithDelay(event);
201
198
  }
202
199
  function onNodeClosed(event) {
203
200
  if (!tree || !parentId || hasParentChildren()) return;
@@ -218,6 +215,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
218
215
  dataRef,
219
216
  closeDelayProp,
220
217
  nodeIdProp,
218
+ isHoverOpen,
221
219
  isClickLikeOpenEvent,
222
220
  clearPointerEvents,
223
221
  instance,
package/dist/1629.js ADDED
@@ -0,0 +1,2 @@
1
+ const ACTIVE_COMPOSITE_ITEM = 'data-composite-item-active';
2
+ export { ACTIVE_COMPOSITE_ITEM };