@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,40 +1,46 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
- import { FloatingPortalLite_FloatingPortalLite } from "../8960.js";
4
- import { useRefWithInit, useRenderElement, esm_formatErrorMessage } from "../8272.js";
5
- import { Timeout, useTimeout } from "../42.js";
6
- import { getTarget, contains, activeElement } from "../4549.js";
7
- import { ownerDocument } from "../9829.js";
3
+ import { FloatingPortalLite_FloatingPortalLite } from "../6191.js";
4
+ import { utils_formatErrorMessage } from "../5473.js";
5
+ import { Timeout, useTimeout } from "../9197.js";
8
6
  import { getWindow } from "../3829.js";
9
- import { addEventListener } from "../4723.js";
10
- import { matchesFocusVisible } from "../8758.js";
11
- import { mergeCleanups } from "../4495.js";
12
- import { FocusGuard_FocusGuard, LEGACY_SWIPE_IGNORE_SELECTOR, BASE_UI_SWIPE_IGNORE_SELECTOR } from "../487.js";
13
- import { visuallyHidden } from "../8225.js";
14
- import { transitionStatusMapping, useOpenChangeComplete } from "../9369.js";
15
- import { useStableCallback } from "../7541.js";
16
- import { useIsoLayoutEffect } from "../6499.js";
17
- import { getDisplacement, getElementTransform } from "../1763.js";
18
- import { inertValue } from "../167.js";
19
- import { useId } from "../2205.js";
20
- import { useButton } from "../9189.js";
21
- import { ReactStore, createSelector } from "../2445.js";
22
- import { useOnMount } from "../2861.js";
7
+ import { ownerDocument } from "../6488.js";
8
+ import { contains, activeElement, getTarget, closest } from "../4155.js";
9
+ import { matchesFocusVisible } from "../6137.js";
10
+ import { mergeCleanups } from "../7718.js";
11
+ import { addEventListener } from "../1282.js";
12
+ import { FocusGuard_FocusGuard, LEGACY_SWIPE_IGNORE_SELECTOR, BASE_UI_SWIPE_IGNORE_SELECTOR } from "../3398.js";
13
+ import { useRefWithInit, useRenderElement } from "../9591.js";
14
+ import { visuallyHidden } from "../6540.js";
15
+ import { useOpenChangeComplete } from "../6620.js";
16
+ import { transitionStatusMapping } from "../8488.js";
17
+ import { useStableCallback } from "../7488.js";
18
+ import { useIsoLayoutEffect } from "../3357.js";
19
+ import { getDisplacement } from "../9018.js";
20
+ import { getElementTransform } from "../7551.js";
21
+ import { inertValue } from "../9374.js";
22
+ import { useId } from "../4989.js";
23
+ import { useButton } from "../9248.js";
24
+ import { ReactStore } from "../226.js";
25
+ import { useOnMount } from "../9120.js";
23
26
  import { getThemedContainer } from "../3699.js";
24
27
  import * as __rspack_external_react from "react";
25
28
  import * as __rspack_external_react_dom_7136dc57 from "react-dom";
26
- const ToastPortal = FloatingPortalLite_FloatingPortalLite;
29
+ const ToastPortal_ToastPortal = /*#__PURE__*/ __rspack_external_react.forwardRef(function(props, forwardedRef) {
30
+ return /*#__PURE__*/ jsx(FloatingPortalLite_FloatingPortalLite, {
31
+ ref: forwardedRef,
32
+ ...props
33
+ });
34
+ });
35
+ if ("production" !== process.env.NODE_ENV) ToastPortal_ToastPortal.displayName = "ToastPortal";
27
36
  const ToastContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
28
37
  if ("production" !== process.env.NODE_ENV) ToastContext.displayName = "ToastContext";
29
38
  function useToastProviderContext() {
30
39
  const context = __rspack_external_react.useContext(ToastContext);
31
- if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: useToastManager must be used within <Toast.Provider>.' : esm_formatErrorMessage(73));
40
+ if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: useToastManager must be used within <Toast.Provider>.' : utils_formatErrorMessage(73));
32
41
  return context;
33
42
  }
34
- let ToastViewportCssVars_ToastViewportCssVars = /*#__PURE__*/ function(ToastViewportCssVars) {
35
- ToastViewportCssVars["frontmostHeight"] = "--toast-frontmost-height";
36
- return ToastViewportCssVars;
37
- }({});
43
+ const ToastViewportCssVars_frontmostHeight = '--toast-frontmost-height';
38
44
  const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
39
45
  const { render, className, style, children, ...elementProps } = componentProps;
40
46
  const store = useToastProviderContext();
@@ -47,41 +53,28 @@ const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwar
47
53
  const focused = store.useState('focused');
48
54
  const expanded = store.useState('expanded');
49
55
  const prevFocusElement = store.useState('prevFocusElement');
50
- const frontmostHeight = toasts[0]?.height ?? 0;
51
- const hasTransitioningToasts = __rspack_external_react.useMemo(()=>toasts.some((toast)=>'ending' === toast.transitionStatus), [
52
- toasts
53
- ]);
54
- const highPriorityToasts = __rspack_external_react.useMemo(()=>toasts.filter((toast)=>'high' === toast.priority), [
55
- toasts
56
- ]);
56
+ const frontmostHeight = toasts[0]?.height;
57
+ const hasTransitioningToasts = toasts.some((toast)=>'ending' === toast.transitionStatus);
58
+ const highPriorityToasts = toasts.filter((toast)=>'high' === toast.priority);
57
59
  __rspack_external_react.useEffect(()=>{
58
60
  const viewport = store.state.viewport;
59
- if (!viewport) return;
61
+ if (!viewport || isEmpty) return;
62
+ const win = getWindow(viewport);
63
+ const doc = ownerDocument(viewport);
60
64
  function handleGlobalKeyDown(event) {
61
- if (isEmpty) return;
62
65
  if ('F6' === event.key && getTarget(event) !== viewport) {
63
66
  event.preventDefault();
64
- store.setPrevFocusElement(activeElement(ownerDocument(viewport)));
67
+ store.set('prevFocusElement', activeElement(doc));
65
68
  viewport?.focus({
66
69
  preventScroll: true
67
70
  });
68
71
  store.pauseTimers();
69
- store.setFocused(true);
72
+ store.set('focused', true);
70
73
  }
71
74
  }
72
- const win = getWindow(viewport);
73
- return addEventListener(win, 'keydown', handleGlobalKeyDown);
74
- }, [
75
- store,
76
- isEmpty
77
- ]);
78
- __rspack_external_react.useEffect(()=>{
79
- const viewport = store.state.viewport;
80
- if (!viewport || isEmpty) return;
81
- const win = getWindow(viewport);
82
75
  function handleWindowBlur(event) {
83
76
  if (getTarget(event) !== win) return;
84
- store.setIsWindowFocused(false);
77
+ store.set('isWindowFocused', false);
85
78
  store.pauseTimers();
86
79
  }
87
80
  function handleWindowFocus(event) {
@@ -89,42 +82,31 @@ const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwar
89
82
  const target = getTarget(event);
90
83
  const activeEl = activeElement(ownerDocument(viewport));
91
84
  if (target === win || !contains(viewport, target) || !matchesFocusVisible(activeEl)) store.resumeTimers();
92
- windowFocusTimeout.start(0, ()=>store.setIsWindowFocused(true));
85
+ windowFocusTimeout.start(0, ()=>store.set('isWindowFocused', true));
93
86
  }
94
- return mergeCleanups(addEventListener(win, 'blur', handleWindowBlur, true), addEventListener(win, 'focus', handleWindowFocus, true));
87
+ return mergeCleanups(addEventListener(win, 'keydown', handleGlobalKeyDown), addEventListener(win, 'blur', handleWindowBlur, true), addEventListener(win, 'focus', handleWindowFocus, true), addEventListener(doc, 'pointerdown', store.handleDocumentPointerDown, true));
95
88
  }, [
96
89
  store,
97
90
  windowFocusTimeout,
98
91
  isEmpty
99
92
  ]);
100
- __rspack_external_react.useEffect(()=>{
101
- const viewport = store.state.viewport;
102
- if (!viewport || isEmpty) return;
103
- const doc = ownerDocument(viewport);
104
- return addEventListener(doc, 'pointerdown', store.handleDocumentPointerDown, true);
105
- }, [
106
- isEmpty,
107
- store
108
- ]);
109
93
  function handleFocusGuard(event) {
110
- const viewport = store.state.viewport;
111
- if (!viewport) return;
112
94
  handlingFocusGuardRef.current = true;
113
- if (event.relatedTarget === viewport) toasts[0]?.ref?.current?.focus();
95
+ const firstFocusableToast = event.relatedTarget === store.state.viewport ? toasts.find((toast)=>'ending' !== toast.transitionStatus && !toast.limited) : void 0;
96
+ if (firstFocusableToast) firstFocusableToast.ref?.current?.focus();
114
97
  else store.restoreFocusToPrevElement();
115
98
  }
116
99
  function handleKeyDown(event) {
117
100
  if ('Tab' === event.key && event.shiftKey && getTarget(event.nativeEvent) === store.state.viewport) {
118
101
  event.preventDefault();
119
102
  store.restoreFocusToPrevElement();
120
- store.resumeTimers();
121
103
  }
122
104
  }
123
105
  function flushMouseLeave() {
124
106
  const hasEndingToasts = store.state.toasts.some((toast)=>'ending' === toast.transitionStatus);
125
- if (!store.state.isWindowFocused || hasEndingToasts || touchActiveRef.current || !markedReadyForMouseLeaveRef.current) return;
126
- store.resumeTimers();
127
- store.setHovering(false);
107
+ if (hasEndingToasts || touchActiveRef.current || !markedReadyForMouseLeaveRef.current) return;
108
+ store.set('hovering', false);
109
+ if (!store.select('expandedOrOutOfFocus')) store.resumeTimers();
128
110
  markedReadyForMouseLeaveRef.current = false;
129
111
  }
130
112
  __rspack_external_react.useEffect(flushMouseLeave, [
@@ -133,15 +115,12 @@ const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwar
133
115
  ]);
134
116
  function handleMouseEnter() {
135
117
  store.pauseTimers();
136
- store.setHovering(true);
118
+ store.set('hovering', true);
137
119
  markedReadyForMouseLeaveRef.current = false;
138
120
  }
139
121
  function handleMouseLeave() {
140
- if (hasTransitioningToasts || touchActiveRef.current) markedReadyForMouseLeaveRef.current = true;
141
- else {
142
- store.resumeTimers();
143
- store.setHovering(false);
144
- }
122
+ markedReadyForMouseLeaveRef.current = true;
123
+ flushMouseLeave();
145
124
  }
146
125
  function handlePointerDown(event) {
147
126
  if ('touch' === event.pointerType) touchActiveRef.current = true;
@@ -158,14 +137,14 @@ const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwar
158
137
  }
159
138
  if (focused) return;
160
139
  if (matchesFocusVisible(activeElement(ownerDocument(store.state.viewport)))) {
161
- store.setFocused(true);
140
+ store.set('focused', true);
162
141
  store.pauseTimers();
163
142
  }
164
143
  }
165
144
  function handleBlur(event) {
166
145
  if (!focused || contains(store.state.viewport, event.relatedTarget)) return;
167
- store.setFocused(false);
168
- store.resumeTimers();
146
+ store.set('focused', false);
147
+ if (!store.select('expandedOrOutOfFocus')) store.resumeTimers();
169
148
  }
170
149
  const defaultProps = {
171
150
  tabIndex: -1,
@@ -183,11 +162,17 @@ const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwar
183
162
  onClick: handleFocus,
184
163
  onPointerDown: handlePointerDown,
185
164
  onPointerUp: handlePointerEnd,
186
- onPointerCancel: handlePointerEnd
165
+ onPointerCancel: handlePointerEnd,
166
+ style: {
167
+ [ToastViewportCssVars_frontmostHeight]: frontmostHeight ? `${frontmostHeight}px` : void 0
168
+ }
187
169
  };
188
170
  const state = {
189
171
  expanded
190
172
  };
173
+ const focusGuard = !isEmpty && prevFocusElement && /*#__PURE__*/ jsx(FocusGuard_FocusGuard, {
174
+ onFocus: handleFocusGuard
175
+ });
191
176
  const element = useRenderElement('div', componentProps, {
192
177
  ref: [
193
178
  forwardedRef,
@@ -196,22 +181,13 @@ const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwar
196
181
  state,
197
182
  props: [
198
183
  defaultProps,
199
- {
200
- style: {
201
- [ToastViewportCssVars_ToastViewportCssVars.frontmostHeight]: frontmostHeight ? `${frontmostHeight}px` : void 0
202
- }
203
- },
204
184
  elementProps,
205
185
  {
206
186
  children: /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
207
187
  children: [
208
- !isEmpty && prevFocusElement && /*#__PURE__*/ jsx(FocusGuard_FocusGuard, {
209
- onFocus: handleFocusGuard
210
- }),
188
+ focusGuard,
211
189
  children,
212
- !isEmpty && prevFocusElement && /*#__PURE__*/ jsx(FocusGuard_FocusGuard, {
213
- onFocus: handleFocusGuard
214
- })
190
+ focusGuard
215
191
  ]
216
192
  })
217
193
  }
@@ -219,9 +195,7 @@ const ToastViewport_ToastViewport = /*#__PURE__*/ __rspack_external_react.forwar
219
195
  });
220
196
  return /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
221
197
  children: [
222
- !isEmpty && prevFocusElement && /*#__PURE__*/ jsx(FocusGuard_FocusGuard, {
223
- onFocus: handleFocusGuard
224
- }),
198
+ focusGuard,
225
199
  element,
226
200
  !focused && highPriorityToasts.length > 0 && /*#__PURE__*/ jsx("div", {
227
201
  style: visuallyHidden,
@@ -246,22 +220,20 @@ const ToastRootContext = /*#__PURE__*/ __rspack_external_react.createContext(voi
246
220
  if ("production" !== process.env.NODE_ENV) ToastRootContext.displayName = "ToastRootContext";
247
221
  function useToastRootContext() {
248
222
  const context = __rspack_external_react.useContext(ToastRootContext);
249
- if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: ToastRootContext is missing. Toast parts must be used within <Toast.Root>.' : esm_formatErrorMessage(66));
223
+ if (!context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: ToastRootContext is missing. Toast parts must be used within <Toast.Root>.' : utils_formatErrorMessage(66));
250
224
  return context;
251
225
  }
252
- let ToastRootCssVars_ToastRootCssVars = /*#__PURE__*/ function(ToastRootCssVars) {
253
- ToastRootCssVars["index"] = "--toast-index";
254
- ToastRootCssVars["offsetY"] = "--toast-offset-y";
255
- ToastRootCssVars["height"] = "--toast-height";
256
- ToastRootCssVars["swipeMovementX"] = "--toast-swipe-movement-x";
257
- ToastRootCssVars["swipeMovementY"] = "--toast-swipe-movement-y";
258
- return ToastRootCssVars;
259
- }({});
260
- const stateAttributesMapping = {
226
+ const ToastRootCssVars_index = '--toast-index';
227
+ const ToastRootCssVars_offsetY = '--toast-offset-y';
228
+ const ToastRootCssVars_height = '--toast-height';
229
+ const swipeMovementX = '--toast-swipe-movement-x';
230
+ const swipeMovementY = '--toast-swipe-movement-y';
231
+ const ToastRootDataAttributes_swipeDirection = 'data-swipe-direction';
232
+ const toastRootStateAttributesMapping = {
261
233
  ...transitionStatusMapping,
262
234
  swipeDirection (value) {
263
235
  return value ? {
264
- 'data-swipe-direction': value
236
+ [ToastRootDataAttributes_swipeDirection]: value
265
237
  } : null;
266
238
  }
267
239
  };
@@ -285,7 +257,6 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
285
257
  const [currentSwipeDirection, setCurrentSwipeDirection] = __rspack_external_react.useState(void 0);
286
258
  const [isSwiping, setIsSwiping] = __rspack_external_react.useState(false);
287
259
  const [isRealSwipe, setIsRealSwipe] = __rspack_external_react.useState(false);
288
- const [dragDismissed, setDragDismissed] = __rspack_external_react.useState(false);
289
260
  const [dragOffset, setDragOffset] = __rspack_external_react.useState({
290
261
  x: 0,
291
262
  y: 0
@@ -299,6 +270,7 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
299
270
  const [descriptionId, setDescriptionId] = __rspack_external_react.useState();
300
271
  const [lockedDirection, setLockedDirection] = __rspack_external_react.useState(null);
301
272
  const rootRef = __rspack_external_react.useRef(null);
273
+ const lastToastIdRef = __rspack_external_react.useRef(void 0);
302
274
  const dragStartPosRef = __rspack_external_react.useRef({
303
275
  x: 0,
304
276
  y: 0
@@ -345,16 +317,33 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
345
317
  store.updateToastInternal(toast.id, {
346
318
  ref: rootRef,
347
319
  height,
348
- ...'starting' === toast.transitionStatus ? {
349
- transitionStatus: void 0
350
- } : {}
320
+ transitionStatus: void 0
351
321
  });
352
322
  }
353
323
  if (flushSync) __rspack_external_react_dom_7136dc57.flushSync(update);
354
324
  else update();
355
325
  });
356
- useIsoLayoutEffect(recalculateHeight, [
357
- recalculateHeight
326
+ useIsoLayoutEffect(()=>{
327
+ const previousToastId = lastToastIdRef.current;
328
+ if ('starting' !== toast.transitionStatus && previousToastId === toast.id) return;
329
+ if (void 0 !== previousToastId) {
330
+ setCurrentSwipeDirection(void 0);
331
+ setInitialTransform({
332
+ x: 0,
333
+ y: 0,
334
+ scale: 1
335
+ });
336
+ setResolvedDragOffset({
337
+ x: 0,
338
+ y: 0
339
+ });
340
+ }
341
+ lastToastIdRef.current = toast.id;
342
+ recalculateHeight();
343
+ }, [
344
+ recalculateHeight,
345
+ toast.id,
346
+ toast.transitionStatus
358
347
  ]);
359
348
  function setResolvedDragOffset(nextDragOffset) {
360
349
  dragOffsetRef.current = nextDragOffset;
@@ -364,19 +353,12 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
364
353
  dragAbortControllerRef.current?.abort();
365
354
  }, []);
366
355
  function applyDirectionalDamping(deltaX, deltaY) {
367
- let newDeltaX = deltaX;
368
- let newDeltaY = deltaY;
369
- if (swipeDirections.includes('left') || swipeDirections.includes('right')) {
370
- if (!swipeDirections.includes('right') && deltaX > 0) newDeltaX = deltaX ** OPPOSITE_DIRECTION_DAMPING_FACTOR;
371
- if (!swipeDirections.includes('left') && deltaX < 0) newDeltaX = -(Math.abs(deltaX) ** OPPOSITE_DIRECTION_DAMPING_FACTOR);
372
- } else newDeltaX = deltaX > 0 ? deltaX ** OPPOSITE_DIRECTION_DAMPING_FACTOR : -(Math.abs(deltaX) ** OPPOSITE_DIRECTION_DAMPING_FACTOR);
373
- if (swipeDirections.includes('up') || swipeDirections.includes('down')) {
374
- if (!swipeDirections.includes('down') && deltaY > 0) newDeltaY = deltaY ** OPPOSITE_DIRECTION_DAMPING_FACTOR;
375
- if (!swipeDirections.includes('up') && deltaY < 0) newDeltaY = -(Math.abs(deltaY) ** OPPOSITE_DIRECTION_DAMPING_FACTOR);
376
- } else newDeltaY = deltaY > 0 ? deltaY ** OPPOSITE_DIRECTION_DAMPING_FACTOR : -(Math.abs(deltaY) ** OPPOSITE_DIRECTION_DAMPING_FACTOR);
356
+ const damp = (delta)=>delta > 0 ? delta ** OPPOSITE_DIRECTION_DAMPING_FACTOR : -(Math.abs(delta) ** OPPOSITE_DIRECTION_DAMPING_FACTOR);
357
+ const dampX = deltaX > 0 && !swipeDirections.includes('right') || deltaX < 0 && !swipeDirections.includes('left');
358
+ const dampY = deltaY > 0 && !swipeDirections.includes('down') || deltaY < 0 && !swipeDirections.includes('up');
377
359
  return {
378
- x: newDeltaX,
379
- y: newDeltaY
360
+ x: dampX ? damp(deltaX) : deltaX,
361
+ y: dampY ? damp(deltaY) : deltaY
380
362
  };
381
363
  }
382
364
  const handleSwipeEnd = useStableCallback((event)=>{
@@ -396,45 +378,16 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
396
378
  setCurrentSwipeDirection(void 0);
397
379
  return;
398
380
  }
399
- let shouldClose = false;
400
381
  const resolvedDragOffset = dragOffsetRef.current;
401
382
  const deltaX = resolvedDragOffset.x - resolvedInitialTransform.x;
402
383
  const deltaY = resolvedDragOffset.y - resolvedInitialTransform.y;
403
384
  let dismissDirection;
404
- for (const direction of swipeDirections){
405
- switch(direction){
406
- case 'right':
407
- if (deltaX > SWIPE_THRESHOLD) {
408
- shouldClose = true;
409
- dismissDirection = 'right';
410
- }
411
- break;
412
- case 'left':
413
- if (deltaX < -SWIPE_THRESHOLD) {
414
- shouldClose = true;
415
- dismissDirection = 'left';
416
- }
417
- break;
418
- case 'down':
419
- if (deltaY > SWIPE_THRESHOLD) {
420
- shouldClose = true;
421
- dismissDirection = 'down';
422
- }
423
- break;
424
- case 'up':
425
- if (deltaY < -SWIPE_THRESHOLD) {
426
- shouldClose = true;
427
- dismissDirection = 'up';
428
- }
429
- break;
430
- default:
431
- break;
432
- }
433
- if (shouldClose) break;
385
+ for (const direction of swipeDirections)if (getDisplacement(direction, deltaX, deltaY) > SWIPE_THRESHOLD) {
386
+ dismissDirection = direction;
387
+ break;
434
388
  }
435
- if (shouldClose) {
389
+ if (dismissDirection) {
436
390
  setCurrentSwipeDirection(dismissDirection);
437
- setDragDismissed(true);
438
391
  store.closeToast(toast.id);
439
392
  } else {
440
393
  setResolvedDragOffset({
@@ -448,7 +401,7 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
448
401
  if (0 !== event.button) return;
449
402
  if ('touch' === event.pointerType) store.pauseTimers();
450
403
  const target = getTarget(event.nativeEvent);
451
- const isInteractiveElement = target ? target.closest(`button,a,input,textarea,[role="button"],${TOAST_SWIPE_IGNORE_SELECTOR}`) : false;
404
+ const isInteractiveElement = closest(target, `button,a,input,textarea,[role="button"],${TOAST_SWIPE_IGNORE_SELECTOR}`);
452
405
  if (isInteractiveElement) return;
453
406
  cancelledSwipeRef.current = false;
454
407
  intendedSwipeDirectionRef.current = void 0;
@@ -459,34 +412,30 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
459
412
  y: event.clientY
460
413
  };
461
414
  swipeCancelBaselineRef.current = dragStartPosRef.current;
462
- if (rootRef.current) {
463
- const transform = getElementTransform(rootRef.current);
464
- initialTransformRef.current = transform;
465
- setInitialTransform(transform);
466
- setResolvedDragOffset({
467
- x: transform.x,
468
- y: transform.y
469
- });
470
- }
471
- store.setHovering(true);
415
+ const element = event.currentTarget;
416
+ const transform = getElementTransform(element);
417
+ initialTransformRef.current = transform;
418
+ setInitialTransform(transform);
419
+ setResolvedDragOffset({
420
+ x: transform.x,
421
+ y: transform.y
422
+ });
423
+ store.set('hovering', true);
472
424
  setIsSwiping(true);
473
425
  setIsRealSwipe(false);
474
426
  setLockedDirection(null);
475
427
  isFirstPointerMoveRef.current = true;
476
- const element = rootRef.current;
477
- if (element) {
478
- dragAbortControllerRef.current?.abort();
479
- const dragAbortController = new AbortController();
480
- dragAbortControllerRef.current = dragAbortController;
481
- const doc = ownerDocument(element);
482
- doc.addEventListener('pointerup', handleSwipeEnd, {
483
- signal: dragAbortController.signal
484
- });
485
- doc.addEventListener('pointercancel', handleSwipeEnd, {
486
- signal: dragAbortController.signal
487
- });
488
- element.setPointerCapture?.(event.pointerId);
489
- }
428
+ dragAbortControllerRef.current?.abort();
429
+ const dragAbortController = new AbortController();
430
+ dragAbortControllerRef.current = dragAbortController;
431
+ const doc = ownerDocument(element);
432
+ doc.addEventListener('pointerup', handleSwipeEnd, {
433
+ signal: dragAbortController.signal
434
+ });
435
+ doc.addEventListener('pointercancel', handleSwipeEnd, {
436
+ signal: dragAbortController.signal
437
+ });
438
+ element.setPointerCapture?.(event.pointerId);
490
439
  }
491
440
  function handlePointerMove(event) {
492
441
  if (event.pointerId !== activePointerIdRef.current) return;
@@ -511,18 +460,18 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
511
460
  const deltaY = clientY - dragStartPosRef.current.y;
512
461
  const cancelDeltaY = clientY - swipeCancelBaselineRef.current.y;
513
462
  const cancelDeltaX = clientX - swipeCancelBaselineRef.current.x;
463
+ let resolvedLockedDirection = lockedDirection;
514
464
  if (!isRealSwipe) {
515
465
  const movementDistance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
516
466
  if (movementDistance >= MIN_DRAG_THRESHOLD) {
517
467
  setIsRealSwipe(true);
518
- if (null === lockedDirection) {
519
- const hasHorizontal = swipeDirections.includes('left') || swipeDirections.includes('right');
520
- const hasVertical = swipeDirections.includes('up') || swipeDirections.includes('down');
521
- if (hasHorizontal && hasVertical) {
522
- const absX = Math.abs(deltaX);
523
- const absY = Math.abs(deltaY);
524
- setLockedDirection(absX > absY ? 'horizontal' : 'vertical');
525
- }
468
+ const hasHorizontal = swipeDirections.includes('left') || swipeDirections.includes('right');
469
+ const hasVertical = swipeDirections.includes('up') || swipeDirections.includes('down');
470
+ if (hasHorizontal && hasVertical) {
471
+ const absX = Math.abs(deltaX);
472
+ const absY = Math.abs(deltaY);
473
+ resolvedLockedDirection = absX > absY ? 'horizontal' : 'vertical';
474
+ setLockedDirection(resolvedLockedDirection);
526
475
  }
527
476
  }
528
477
  }
@@ -535,10 +484,10 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
535
484
  setCurrentSwipeDirection(direction);
536
485
  } else if (!(swipeDirections.includes('left') && swipeDirections.includes('right')) && !(swipeDirections.includes('up') && swipeDirections.includes('down')) && maxSwipeDisplacementRef.current - currentDisplacement >= REVERSE_CANCEL_THRESHOLD) cancelledSwipeRef.current = true;
537
486
  } else {
538
- if ('vertical' === lockedDirection) {
487
+ if ('vertical' === resolvedLockedDirection) {
539
488
  if (deltaY > 0) candidate = 'down';
540
489
  else if (deltaY < 0) candidate = 'up';
541
- } else if ('horizontal' === lockedDirection) {
490
+ } else if ('horizontal' === resolvedLockedDirection) {
542
491
  if (deltaX > 0) candidate = 'right';
543
492
  else if (deltaX < 0) candidate = 'left';
544
493
  } else candidate = Math.abs(deltaX) >= Math.abs(deltaY) ? deltaX > 0 ? 'right' : 'left' : deltaY > 0 ? 'down' : 'up';
@@ -551,14 +500,10 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
551
500
  const dampedDelta = applyDirectionalDamping(deltaX, deltaY);
552
501
  let newOffsetX = initialTransformRef.current.x;
553
502
  let newOffsetY = initialTransformRef.current.y;
554
- if ('horizontal' === lockedDirection) {
555
- if (swipeDirections.includes('left') || swipeDirections.includes('right')) newOffsetX += dampedDelta.x;
556
- } else if ('vertical' === lockedDirection) {
557
- if (swipeDirections.includes('up') || swipeDirections.includes('down')) newOffsetY += dampedDelta.y;
558
- } else {
559
- if (swipeDirections.includes('left') || swipeDirections.includes('right')) newOffsetX += dampedDelta.x;
560
- if (swipeDirections.includes('up') || swipeDirections.includes('down')) newOffsetY += dampedDelta.y;
561
- }
503
+ const hasHorizontalDir = swipeDirections.includes('left') || swipeDirections.includes('right');
504
+ const hasVerticalDir = swipeDirections.includes('up') || swipeDirections.includes('down');
505
+ if ('vertical' !== resolvedLockedDirection && hasHorizontalDir) newOffsetX += dampedDelta.x;
506
+ if ('horizontal' !== resolvedLockedDirection && hasVerticalDir) newOffsetY += dampedDelta.y;
562
507
  setResolvedDragOffset({
563
508
  x: newOffsetX,
564
509
  y: newOffsetY
@@ -571,11 +516,11 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
571
516
  }
572
517
  }
573
518
  __rspack_external_react.useEffect(()=>{
574
- if (!swipeEnabled) return;
575
519
  const element = rootRef.current;
576
- if (!element) return;
520
+ if (!swipeEnabled || !element) return;
577
521
  function preventDefaultTouchStart(event) {
578
- if (contains(element, getTarget(event))) event.preventDefault();
522
+ if (null === activePointerIdRef.current || !contains(element, getTarget(event))) return;
523
+ event.preventDefault();
579
524
  }
580
525
  return addEventListener(element, 'touchmove', preventDefaultTouchStart, {
581
526
  passive: false
@@ -584,17 +529,13 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
584
529
  swipeEnabled
585
530
  ]);
586
531
  function getDragStyles() {
587
- if (!isSwiping && dragOffset.x === initialTransform.x && dragOffset.y === initialTransform.y && !dragDismissed) return {
588
- [ToastRootCssVars_ToastRootCssVars.swipeMovementX]: '0px',
589
- [ToastRootCssVars_ToastRootCssVars.swipeMovementY]: '0px'
590
- };
591
532
  const deltaX = dragOffset.x - initialTransform.x;
592
533
  const deltaY = dragOffset.y - initialTransform.y;
593
534
  return {
594
535
  transition: isSwiping ? 'none' : void 0,
595
536
  transform: isSwiping ? `translateX(${dragOffset.x}px) translateY(${dragOffset.y}px) scale(${initialTransform.scale})` : void 0,
596
- [ToastRootCssVars_ToastRootCssVars.swipeMovementX]: `${deltaX}px`,
597
- [ToastRootCssVars_ToastRootCssVars.swipeMovementY]: `${deltaY}px`
537
+ [swipeMovementX]: `${deltaX}px`,
538
+ [swipeMovementY]: `${deltaY}px`
598
539
  };
599
540
  }
600
541
  const isHighPriority = 'high' === toast.priority;
@@ -613,32 +554,23 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
613
554
  inert: inertValue(toast.limited),
614
555
  style: {
615
556
  ...getDragStyles(),
616
- [ToastRootCssVars_ToastRootCssVars.index]: 'ending' === toast.transitionStatus ? domIndex : visibleIndex,
617
- [ToastRootCssVars_ToastRootCssVars.offsetY]: `${offsetY}px`,
618
- [ToastRootCssVars_ToastRootCssVars.height]: toast.height ? `${toast.height}px` : void 0
557
+ [ToastRootCssVars_index]: 'ending' === toast.transitionStatus ? domIndex : visibleIndex,
558
+ [ToastRootCssVars_offsetY]: `${offsetY}px`,
559
+ [ToastRootCssVars_height]: toast.height ? `${toast.height}px` : void 0
619
560
  }
620
561
  };
621
562
  const toastRoot = __rspack_external_react.useMemo(()=>({
622
- rootRef,
623
563
  toast,
624
- titleId,
625
564
  setTitleId,
626
- descriptionId,
627
565
  setDescriptionId,
628
- swiping: isSwiping,
629
- swipeDirection: currentSwipeDirection,
630
566
  recalculateHeight,
631
- index: domIndex,
632
567
  visibleIndex,
633
568
  expanded
634
569
  }), [
635
570
  toast,
636
- titleId,
637
- descriptionId,
638
- isSwiping,
639
- currentSwipeDirection,
571
+ setTitleId,
572
+ setDescriptionId,
640
573
  recalculateHeight,
641
- domIndex,
642
574
  visibleIndex,
643
575
  expanded
644
576
  ]);
@@ -647,16 +579,16 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
647
579
  expanded,
648
580
  limited: toast.limited || false,
649
581
  type: toast.type,
650
- swiping: toastRoot.swiping,
651
- swipeDirection: toastRoot.swipeDirection
582
+ swiping: isSwiping,
583
+ swipeDirection: currentSwipeDirection
652
584
  };
653
585
  const element = useRenderElement('div', componentProps, {
654
586
  ref: [
655
587
  forwardedRef,
656
- toastRoot.rootRef
588
+ rootRef
657
589
  ],
658
590
  state,
659
- stateAttributesMapping: stateAttributesMapping,
591
+ stateAttributesMapping: toastRootStateAttributesMapping,
660
592
  props: [
661
593
  defaultProps,
662
594
  elementProps
@@ -668,25 +600,46 @@ const ToastRoot_ToastRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
668
600
  });
669
601
  });
670
602
  if ("production" !== process.env.NODE_ENV) ToastRoot_ToastRoot.displayName = "ToastRoot";
671
- const ToastTitle_ToastTitle = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
672
- const { render, className, style, id: idProp, children: childrenProp, ...elementProps } = componentProps;
673
- const { toast, setTitleId } = useToastRootContext();
674
- const children = childrenProp ?? toast.title;
675
- const shouldRender = Boolean(children);
603
+ function isRenderableNode(node) {
604
+ if (null == node || 'boolean' == typeof node || '' === node) return false;
605
+ if (Array.isArray(node)) return node.some(isRenderableNode);
606
+ return true;
607
+ }
608
+ function hasRenderableChildren(element) {
609
+ return /*#__PURE__*/ __rspack_external_react.isValidElement(element) && isRenderableNode(element.props.children);
610
+ }
611
+ function useToastLabelPart(idProp, childrenProp, part) {
612
+ const { toast, setTitleId, setDescriptionId } = useToastRootContext();
613
+ const setId = 'title' === part ? setTitleId : setDescriptionId;
614
+ const children = childrenProp ?? ('title' === part ? toast.title : toast.description);
676
615
  const id = useId(idProp);
616
+ return {
617
+ id,
618
+ children,
619
+ type: toast.type,
620
+ setId
621
+ };
622
+ }
623
+ function useToastLabelElement(element, id, setId) {
624
+ const shouldRender = hasRenderableChildren(element);
677
625
  useIsoLayoutEffect(()=>{
678
626
  if (!shouldRender) return;
679
- setTitleId(id);
627
+ setId(id);
680
628
  return ()=>{
681
- setTitleId(void 0);
629
+ setId((currentId)=>currentId === id ? void 0 : currentId);
682
630
  };
683
631
  }, [
684
632
  shouldRender,
685
633
  id,
686
- setTitleId
634
+ setId
687
635
  ]);
636
+ return shouldRender ? element : null;
637
+ }
638
+ const ToastTitle_ToastTitle = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
639
+ const { render, className, style, id: idProp, children: childrenProp, ...elementProps } = componentProps;
640
+ const { id, children, type, setId } = useToastLabelPart(idProp, childrenProp, 'title');
688
641
  const state = {
689
- type: toast.type
642
+ type
690
643
  };
691
644
  const element = useRenderElement('h2', componentProps, {
692
645
  ref: forwardedRef,
@@ -697,15 +650,13 @@ const ToastTitle_ToastTitle = /*#__PURE__*/ __rspack_external_react.forwardRef(f
697
650
  children
698
651
  }
699
652
  });
700
- if (!shouldRender) return null;
701
- return element;
653
+ return useToastLabelElement(element, id, setId);
702
654
  });
703
655
  if ("production" !== process.env.NODE_ENV) ToastTitle_ToastTitle.displayName = "ToastTitle";
704
656
  const ToastClose_ToastClose = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
705
657
  const { render, className, style, disabled, nativeButton = true, ...elementProps } = componentProps;
706
658
  const store = useToastProviderContext();
707
- const { toast } = useToastRootContext();
708
- const expanded = store.useState('expanded');
659
+ const { toast, expanded } = useToastRootContext();
709
660
  const [hasFocus, setHasFocus] = __rspack_external_react.useState(false);
710
661
  const { getButtonProps, buttonRef } = useButton({
711
662
  disabled,
@@ -714,7 +665,7 @@ const ToastClose_ToastClose = /*#__PURE__*/ __rspack_external_react.forwardRef(f
714
665
  const state = {
715
666
  type: toast.type
716
667
  };
717
- const element = useRenderElement('button', componentProps, {
668
+ return useRenderElement('button', componentProps, {
718
669
  ref: [
719
670
  forwardedRef,
720
671
  buttonRef
@@ -737,7 +688,6 @@ const ToastClose_ToastClose = /*#__PURE__*/ __rspack_external_react.forwardRef(f
737
688
  getButtonProps
738
689
  ]
739
690
  });
740
- return element;
741
691
  });
742
692
  if ("production" !== process.env.NODE_ENV) ToastClose_ToastClose.displayName = "ToastClose";
743
693
  let counter = 0;
@@ -774,19 +724,29 @@ function createToastMetadata(toasts) {
774
724
  });
775
725
  return metadata;
776
726
  }
777
- const toastMetadataSelector = (state)=>state.toastMetadata;
727
+ function applyLimited(toasts, limit) {
728
+ let activeIndex = 0;
729
+ return toasts.map((toast)=>{
730
+ if ('ending' === toast.transitionStatus) return toast;
731
+ const limited = activeIndex >= limit;
732
+ activeIndex += 1;
733
+ return toast.limited === limited ? toast : {
734
+ ...toast,
735
+ limited
736
+ };
737
+ });
738
+ }
778
739
  const selectors = {
779
- toasts: createSelector((state)=>state.toasts),
780
- isEmpty: createSelector((state)=>0 === state.toasts.length),
781
- toast: createSelector(toastMetadataSelector, (toastMetadata, id)=>toastMetadata.get(id)?.value),
782
- toastIndex: createSelector(toastMetadataSelector, (toastMetadata, id)=>toastMetadata.get(id)?.domIndex ?? -1),
783
- toastOffsetY: createSelector(toastMetadataSelector, (toastMetadata, id)=>toastMetadata.get(id)?.offsetY ?? 0),
784
- toastVisibleIndex: createSelector(toastMetadataSelector, (toastMetadata, id)=>toastMetadata.get(id)?.visibleIndex ?? -1),
785
- hovering: createSelector((state)=>state.hovering),
786
- focused: createSelector((state)=>state.focused),
787
- expanded: createSelector((state)=>state.hovering || state.focused),
788
- expandedOrOutOfFocus: createSelector((state)=>state.hovering || state.focused || !state.isWindowFocused),
789
- prevFocusElement: createSelector((state)=>state.prevFocusElement)
740
+ toasts: (state)=>state.toasts,
741
+ isEmpty: (state)=>0 === state.toasts.length,
742
+ toast: (state, id)=>state.toastMetadata.get(id)?.value,
743
+ toastIndex: (state, id)=>state.toastMetadata.get(id)?.domIndex ?? -1,
744
+ toastOffsetY: (state, id)=>state.toastMetadata.get(id)?.offsetY ?? 0,
745
+ toastVisibleIndex: (state, id)=>state.toastMetadata.get(id)?.visibleIndex ?? -1,
746
+ focused: (state)=>state.focused,
747
+ expanded: (state)=>state.hovering || state.focused,
748
+ expandedOrOutOfFocus: (state)=>state.hovering || state.focused || !state.isWindowFocused,
749
+ prevFocusElement: (state)=>state.prevFocusElement
790
750
  };
791
751
  class ToastStore extends ReactStore {
792
752
  timers = new Map();
@@ -797,32 +757,34 @@ class ToastStore extends ReactStore {
797
757
  toastMetadata: createToastMetadata(initialState.toasts)
798
758
  }, {}, selectors);
799
759
  }
800
- setFocused(focused) {
801
- this.set('focused', focused);
802
- }
803
- setHovering(hovering) {
804
- this.set('hovering', hovering);
805
- }
806
- setIsWindowFocused(isWindowFocused) {
807
- this.set('isWindowFocused', isWindowFocused);
808
- }
809
- setPrevFocusElement(prevFocusElement) {
810
- this.set('prevFocusElement', prevFocusElement);
811
- }
812
760
  setViewport = (viewport)=>{
813
761
  this.set('viewport', viewport);
814
762
  };
763
+ syncProviderProps(timeout, limit) {
764
+ const limitChanged = this.state.limit !== limit;
765
+ if (this.state.timeout === timeout && !limitChanged) return;
766
+ const updates = {
767
+ timeout,
768
+ limit
769
+ };
770
+ if (limitChanged) {
771
+ const newToasts = applyLimited(this.state.toasts, limit);
772
+ updates.toasts = newToasts;
773
+ updates.toastMetadata = createToastMetadata(newToasts);
774
+ }
775
+ this.update(updates);
776
+ }
815
777
  disposeEffect = ()=>()=>{
816
778
  this.timers.forEach((timer)=>{
817
779
  timer.timeout?.clear();
818
780
  });
819
781
  this.timers.clear();
820
782
  };
821
- removeToast(toastId, behavior = {}) {
783
+ removeToast(toastId, skipOnRemove = false) {
822
784
  const index = selectors.toastIndex(this.state, toastId);
823
785
  if (-1 === index) return;
824
786
  const toast = this.state.toasts[index];
825
- if (!behavior.skipOnRemove) toast?.onRemove?.();
787
+ if (!skipOnRemove) toast?.onRemove?.();
826
788
  const newToasts = [
827
789
  ...this.state.toasts
828
790
  ];
@@ -834,15 +796,10 @@ class ToastStore extends ReactStore {
834
796
  const id = toast.id || generateId('toast');
835
797
  if (toast.id) {
836
798
  const existingToast = selectors.toast(this.state, toast.id);
837
- if (existingToast) if ('ending' === existingToast.transitionStatus) this.removeToast(toast.id, {
838
- skipOnRemove: true
839
- });
799
+ if (existingToast) if ('ending' === existingToast.transitionStatus) this.removeToast(toast.id, true);
840
800
  else {
841
801
  const { id: ignoredId, transitionStatus: ignoredTransitionStatus, ...updates } = toast;
842
- this.updateToastInternal(toast.id, updates, {
843
- resetTimer: true,
844
- markUpdated: true
845
- });
802
+ this.updateToastInternal(toast.id, updates, true, true);
846
803
  return toast.id;
847
804
  }
848
805
  }
@@ -856,65 +813,40 @@ class ToastStore extends ReactStore {
856
813
  toastToAdd,
857
814
  ...this.state.toasts
858
815
  ];
859
- const activeToasts = updatedToasts.filter((t)=>'ending' !== t.transitionStatus);
860
- if (activeToasts.length > limit) {
861
- const excessCount = activeToasts.length - limit;
862
- const oldestActiveToasts = activeToasts.slice(-excessCount);
863
- const limitedIds = new Set(oldestActiveToasts.map((t)=>t.id));
864
- this.setToasts(updatedToasts.map((t)=>{
865
- const limited = limitedIds.has(t.id);
866
- if (t.limited !== limited) return {
867
- ...t,
868
- limited
869
- };
870
- return t;
871
- }));
872
- } else this.setToasts(updatedToasts.map((t)=>t.limited ? {
873
- ...t,
874
- limited: false
875
- } : t));
816
+ this.setToasts(applyLimited(updatedToasts, limit));
876
817
  const duration = toastToAdd.timeout ?? timeout;
877
818
  if ('loading' !== toastToAdd.type && duration > 0) this.scheduleTimer(id, duration, ()=>this.closeToast(id));
878
819
  if (selectors.expandedOrOutOfFocus(this.state)) this.pauseTimers();
879
820
  return id;
880
821
  };
881
822
  updateToast = (id, updates)=>{
882
- this.updateToastInternal(id, updates, {
883
- markUpdated: true
884
- });
823
+ const prevToast = selectors.toast(this.state, id);
824
+ if (!prevToast || 'ending' === prevToast.transitionStatus) return;
825
+ this.updateToastInternal(id, 'function' == typeof updates ? updates(prevToast) : updates, false, true);
885
826
  };
886
- updateToastInternal = (id, updates, behavior = {})=>{
827
+ updateToastInternal = (id, updates, resetTimer = false, markUpdated = false)=>{
887
828
  const { timeout, toasts } = this.state;
888
- const prevToast = selectors.toast(this.state, id) ?? null;
829
+ const prevToast = selectors.toast(this.state, id);
889
830
  if (!prevToast) return;
890
831
  if ('ending' === prevToast.transitionStatus) return;
891
832
  const nextToast = {
892
833
  ...prevToast,
893
834
  ...updates,
894
- ...behavior.markUpdated && {
895
- updateKey: (prevToast.updateKey ?? 0) + 1
835
+ ...markUpdated && {
836
+ updateKey: prevToast.updateKey + 1
896
837
  }
897
838
  };
898
839
  this.setToasts(toasts.map((toast)=>toast.id === id ? nextToast : toast));
899
840
  const nextTimeout = nextToast.timeout ?? timeout;
900
- const prevTimeout = prevToast?.timeout ?? timeout;
841
+ const prevTimeout = prevToast.timeout ?? timeout;
901
842
  const timeoutUpdated = Object.hasOwn(updates, 'timeout');
902
843
  const shouldHaveTimer = 'ending' !== nextToast.transitionStatus && 'loading' !== nextToast.type && nextTimeout > 0;
903
844
  const hasTimer = this.timers.has(id);
904
845
  const timeoutChanged = prevTimeout !== nextTimeout;
905
- const wasLoading = prevToast?.type === 'loading';
906
- if (!shouldHaveTimer && hasTimer) {
907
- const timer = this.timers.get(id);
908
- timer?.timeout?.clear();
909
- this.timers.delete(id);
910
- return;
911
- }
912
- if (shouldHaveTimer && (!hasTimer || timeoutChanged || timeoutUpdated || wasLoading || behavior.resetTimer)) {
913
- const timer = this.timers.get(id);
914
- if (timer) {
915
- timer.timeout?.clear();
916
- this.timers.delete(id);
917
- }
846
+ const wasLoading = 'loading' === prevToast.type;
847
+ if (!shouldHaveTimer && hasTimer) return void this.clearTimer(id);
848
+ if (shouldHaveTimer && (!hasTimer || timeoutChanged || timeoutUpdated || wasLoading || resetTimer)) {
849
+ this.clearTimer(id);
918
850
  this.scheduleTimer(id, nextTimeout, ()=>this.closeToast(id));
919
851
  if (selectors.expandedOrOutOfFocus(this.state)) this.pauseTimers();
920
852
  }
@@ -925,46 +857,22 @@ class ToastStore extends ReactStore {
925
857
  let toastsToClose;
926
858
  if (closeAll) {
927
859
  toastsToClose = toasts;
928
- this.timers.forEach((timer)=>{
929
- timer.timeout?.clear();
930
- });
931
- this.timers.clear();
860
+ this.clearTimers();
932
861
  } else {
933
862
  const toast = selectors.toast(this.state, toastId);
934
863
  if (!toast) return;
935
864
  toastsToClose = [
936
865
  toast
937
866
  ];
938
- const timer = this.timers.get(toastId);
939
- if (timer?.timeout) {
940
- timer.timeout.clear();
941
- this.timers.delete(toastId);
942
- }
867
+ this.clearTimer(toastId);
943
868
  }
944
- let activeIndex = 0;
945
- const newToasts = toasts.map((item)=>{
946
- if (closeAll || item.id === toastId) return {
869
+ const endingToasts = toasts.map((item)=>closeAll || item.id === toastId ? {
947
870
  ...item,
948
871
  transitionStatus: 'ending',
949
872
  height: 0
950
- };
951
- if ('ending' === item.transitionStatus) return item;
952
- const isLimited = activeIndex >= limit;
953
- activeIndex += 1;
954
- return item.limited !== isLimited ? {
955
- ...item,
956
- limited: isLimited
957
- } : item;
958
- });
959
- const updates = {
960
- toasts: newToasts,
961
- toastMetadata: createToastMetadata(newToasts)
962
- };
963
- if (closeAll || 1 === toasts.length) {
964
- updates.hovering = false;
965
- updates.focused = false;
966
- }
967
- this.update(updates);
873
+ } : item);
874
+ const newToasts = applyLimited(endingToasts, limit);
875
+ this.setToasts(newToasts, !newToasts.some((toast)=>'ending' !== toast.transitionStatus));
968
876
  toastsToClose.forEach((toast)=>{
969
877
  if ('ending' !== toast.transitionStatus) toast.onClose?.();
970
878
  });
@@ -1002,9 +910,7 @@ class ToastStore extends ReactStore {
1002
910
  this.timers.forEach((timer)=>{
1003
911
  if (timer.timeout) {
1004
912
  timer.timeout.clear();
1005
- const elapsed = Date.now() - timer.start;
1006
- const remaining = timer.delay - elapsed;
1007
- timer.remaining = remaining > 0 ? remaining : 0;
913
+ timer.remaining = Math.max(timer.remaining - (Date.now() - timer.start), 0);
1008
914
  }
1009
915
  });
1010
916
  }
@@ -1015,7 +921,7 @@ class ToastStore extends ReactStore {
1015
921
  timer.remaining = timer.remaining > 0 ? timer.remaining : timer.delay;
1016
922
  timer.timeout ??= Timeout.create();
1017
923
  timer.timeout.start(timer.remaining, ()=>{
1018
- this.timers.delete(id);
924
+ this.handleTimerFired(id);
1019
925
  timer.callback();
1020
926
  });
1021
927
  timer.start = Date.now();
@@ -1041,23 +947,43 @@ class ToastStore extends ReactStore {
1041
947
  const shouldStartActive = !selectors.expandedOrOutOfFocus(this.state);
1042
948
  const currentTimeout = shouldStartActive ? Timeout.create() : void 0;
1043
949
  currentTimeout?.start(delay, ()=>{
1044
- this.timers.delete(id);
950
+ this.handleTimerFired(id);
1045
951
  callback();
1046
952
  });
1047
953
  this.timers.set(id, {
1048
954
  timeout: currentTimeout,
1049
- start: shouldStartActive ? start : 0,
955
+ start,
1050
956
  delay,
1051
957
  remaining: delay,
1052
958
  callback
1053
959
  });
1054
960
  }
1055
- setToasts(newToasts) {
961
+ clearTimers() {
962
+ this.timers.forEach((timer)=>{
963
+ timer.timeout?.clear();
964
+ });
965
+ this.timers.clear();
966
+ this.areTimersPaused = false;
967
+ }
968
+ clearTimer(id) {
969
+ const timer = this.timers.get(id);
970
+ timer?.timeout?.clear();
971
+ this.timers.delete(id);
972
+ this.resetPausedStateIfNoTimersRemain();
973
+ }
974
+ handleTimerFired(id) {
975
+ this.timers.delete(id);
976
+ this.resetPausedStateIfNoTimersRemain();
977
+ }
978
+ resetPausedStateIfNoTimersRemain() {
979
+ if (0 === this.timers.size) this.areTimersPaused = false;
980
+ }
981
+ setToasts(newToasts, clearInteraction = 0 === newToasts.length) {
1056
982
  const updates = {
1057
983
  toasts: newToasts,
1058
984
  toastMetadata: createToastMetadata(newToasts)
1059
985
  };
1060
- if (0 === newToasts.length) {
986
+ if (clearInteraction) {
1061
987
  updates.hovering = false;
1062
988
  updates.focused = false;
1063
989
  }
@@ -1069,25 +995,11 @@ class ToastStore extends ReactStore {
1069
995
  if (void 0 === toastId) return void this.restoreFocusToPrevElement();
1070
996
  const toasts = selectors.toasts(this.state);
1071
997
  const currentIndex = selectors.toastIndex(this.state, toastId);
1072
- let nextToast = null;
1073
- let index = currentIndex + 1;
1074
- while(index < toasts.length){
1075
- if ('ending' !== toasts[index].transitionStatus) {
1076
- nextToast = toasts[index];
1077
- break;
1078
- }
1079
- index += 1;
1080
- }
1081
- if (!nextToast) {
1082
- index = currentIndex - 1;
1083
- while(index >= 0){
1084
- if ('ending' !== toasts[index].transitionStatus) {
1085
- nextToast = toasts[index];
1086
- break;
1087
- }
1088
- index -= 1;
1089
- }
1090
- }
998
+ const scan = (from, step)=>{
999
+ for(let index = from; index >= 0 && index < toasts.length; index += step)if ('ending' !== toasts[index].transitionStatus) return toasts[index];
1000
+ return null;
1001
+ };
1002
+ const nextToast = scan(currentIndex + 1, 1) ?? scan(currentIndex - 1, -1);
1091
1003
  if (nextToast) nextToast.ref?.current?.focus();
1092
1004
  else this.restoreFocusToPrevElement();
1093
1005
  }
@@ -1110,7 +1022,7 @@ const ToastProvider_ToastProvider = function(props) {
1110
1022
  const unsubscribe = toastManager[' subscribe'](({ action, options })=>{
1111
1023
  const id = options.id;
1112
1024
  if ('promise' === action && options.promise) store.promiseToast(options.promise, options);
1113
- else if ('update' === action && id) store.updateToast(id, options);
1025
+ else if ('update' === action && id) store.updateToast(id, options.updates);
1114
1026
  else if ('close' === action) store.closeToast(id);
1115
1027
  else store.addToast(options);
1116
1028
  });
@@ -1119,19 +1031,32 @@ const ToastProvider_ToastProvider = function(props) {
1119
1031
  store,
1120
1032
  toastManager
1121
1033
  ]);
1122
- store.useSyncedValues({
1123
- timeout,
1124
- limit
1125
- });
1126
- return /*#__PURE__*/ jsx(ToastContext.Provider, {
1034
+ return /*#__PURE__*/ jsxs(ToastContext.Provider, {
1127
1035
  value: store,
1128
- children: children
1036
+ children: [
1037
+ /*#__PURE__*/ jsx(ToastProviderPropsSynchronizer, {
1038
+ store: store,
1039
+ timeout: timeout,
1040
+ limit: limit
1041
+ }),
1042
+ children
1043
+ ]
1129
1044
  });
1130
1045
  };
1131
1046
  if ("production" !== process.env.NODE_ENV) ToastProvider_ToastProvider.displayName = "ToastProvider";
1047
+ function ToastProviderPropsSynchronizer(props) {
1048
+ const { store, timeout, limit } = props;
1049
+ useIsoLayoutEffect(()=>{
1050
+ store.syncProviderProps(timeout, limit);
1051
+ }, [
1052
+ store,
1053
+ timeout,
1054
+ limit
1055
+ ]);
1056
+ return null;
1057
+ }
1132
1058
  function useToastManager() {
1133
- const store = __rspack_external_react.useContext(ToastContext);
1134
- if (!store) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: useToastManager must be used within <Toast.Provider>.' : esm_formatErrorMessage(73));
1059
+ const store = useToastProviderContext();
1135
1060
  const toasts = store.useState('toasts');
1136
1061
  return __rspack_external_react.useMemo(()=>({
1137
1062
  toasts,
@@ -1178,7 +1103,7 @@ function getSkinClassName(skin) {
1178
1103
  return Toast_module.status;
1179
1104
  }
1180
1105
  }
1181
- const Portal = ({ container, ...props })=>/*#__PURE__*/ jsx(ToastPortal, {
1106
+ const Portal = ({ container, ...props })=>/*#__PURE__*/ jsx(ToastPortal_ToastPortal, {
1182
1107
  container: container ?? getThemedContainer(),
1183
1108
  ...props
1184
1109
  });