@yahoo/uds-mobile 2.16.0 → 2.18.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 (236) hide show
  1. package/dist/bin/fixtures/dist/index.mjs +14 -0
  2. package/dist/bin/generateTheme.mjs +7 -2
  3. package/dist/bin/mobile/scripts/utils/configToRNMappings.mjs +4 -0
  4. package/dist/components/Popover/Popover.cjs +92 -0
  5. package/dist/components/Popover/Popover.d.cts +26 -0
  6. package/dist/components/Popover/Popover.d.cts.map +1 -0
  7. package/dist/components/Popover/Popover.d.ts +26 -0
  8. package/dist/components/Popover/Popover.d.ts.map +1 -0
  9. package/dist/components/Popover/Popover.js +92 -0
  10. package/dist/components/Popover/Popover.js.map +1 -0
  11. package/dist/components/Popover/PopoverContent.cjs +124 -0
  12. package/dist/components/Popover/PopoverContent.d.cts +15 -0
  13. package/dist/components/Popover/PopoverContent.d.cts.map +1 -0
  14. package/dist/components/Popover/PopoverContent.d.ts +15 -0
  15. package/dist/components/Popover/PopoverContent.d.ts.map +1 -0
  16. package/dist/components/Popover/PopoverContent.js +124 -0
  17. package/dist/components/Popover/PopoverContent.js.map +1 -0
  18. package/dist/components/Popover/PopoverContext.cjs +14 -0
  19. package/dist/components/Popover/PopoverContext.d.cts +10 -0
  20. package/dist/components/Popover/PopoverContext.d.cts.map +1 -0
  21. package/dist/components/Popover/PopoverContext.d.ts +10 -0
  22. package/dist/components/Popover/PopoverContext.d.ts.map +1 -0
  23. package/dist/components/Popover/PopoverContext.js +13 -0
  24. package/dist/components/Popover/PopoverContext.js.map +1 -0
  25. package/dist/components/Popover/PopoverDescription.cjs +23 -0
  26. package/dist/components/Popover/PopoverDescription.d.cts +15 -0
  27. package/dist/components/Popover/PopoverDescription.d.cts.map +1 -0
  28. package/dist/components/Popover/PopoverDescription.d.ts +15 -0
  29. package/dist/components/Popover/PopoverDescription.d.ts.map +1 -0
  30. package/dist/components/Popover/PopoverDescription.js +23 -0
  31. package/dist/components/Popover/PopoverDescription.js.map +1 -0
  32. package/dist/components/Popover/PopoverDismiss.cjs +22 -0
  33. package/dist/components/Popover/PopoverDismiss.d.cts +15 -0
  34. package/dist/components/Popover/PopoverDismiss.d.cts.map +1 -0
  35. package/dist/components/Popover/PopoverDismiss.d.ts +15 -0
  36. package/dist/components/Popover/PopoverDismiss.d.ts.map +1 -0
  37. package/dist/components/Popover/PopoverDismiss.js +22 -0
  38. package/dist/components/Popover/PopoverDismiss.js.map +1 -0
  39. package/dist/components/Popover/PopoverFrame.cjs +56 -0
  40. package/dist/components/Popover/PopoverFrame.d.cts +23 -0
  41. package/dist/components/Popover/PopoverFrame.d.cts.map +1 -0
  42. package/dist/components/Popover/PopoverFrame.d.ts +23 -0
  43. package/dist/components/Popover/PopoverFrame.d.ts.map +1 -0
  44. package/dist/components/Popover/PopoverFrame.js +55 -0
  45. package/dist/components/Popover/PopoverFrame.js.map +1 -0
  46. package/dist/components/Popover/PopoverPortalLayer.cjs +45 -0
  47. package/dist/components/Popover/PopoverPortalLayer.d.cts +15 -0
  48. package/dist/components/Popover/PopoverPortalLayer.d.cts.map +1 -0
  49. package/dist/components/Popover/PopoverPortalLayer.d.ts +15 -0
  50. package/dist/components/Popover/PopoverPortalLayer.d.ts.map +1 -0
  51. package/dist/components/Popover/PopoverPortalLayer.js +45 -0
  52. package/dist/components/Popover/PopoverPortalLayer.js.map +1 -0
  53. package/dist/components/Popover/PopoverSurface.cjs +228 -0
  54. package/dist/components/Popover/PopoverSurface.d.cts +26 -0
  55. package/dist/components/Popover/PopoverSurface.d.cts.map +1 -0
  56. package/dist/components/Popover/PopoverSurface.d.ts +26 -0
  57. package/dist/components/Popover/PopoverSurface.d.ts.map +1 -0
  58. package/dist/components/Popover/PopoverSurface.js +227 -0
  59. package/dist/components/Popover/PopoverSurface.js.map +1 -0
  60. package/dist/components/Popover/PopoverTitle.cjs +23 -0
  61. package/dist/components/Popover/PopoverTitle.d.cts +15 -0
  62. package/dist/components/Popover/PopoverTitle.d.cts.map +1 -0
  63. package/dist/components/Popover/PopoverTitle.d.ts +15 -0
  64. package/dist/components/Popover/PopoverTitle.d.ts.map +1 -0
  65. package/dist/components/Popover/PopoverTitle.js +23 -0
  66. package/dist/components/Popover/PopoverTitle.js.map +1 -0
  67. package/dist/components/Popover/PopoverTrigger.cjs +88 -0
  68. package/dist/components/Popover/PopoverTrigger.d.cts +15 -0
  69. package/dist/components/Popover/PopoverTrigger.d.cts.map +1 -0
  70. package/dist/components/Popover/PopoverTrigger.d.ts +15 -0
  71. package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -0
  72. package/dist/components/Popover/PopoverTrigger.js +88 -0
  73. package/dist/components/Popover/PopoverTrigger.js.map +1 -0
  74. package/dist/components/Popover/index.cjs +14 -0
  75. package/dist/components/Popover/index.d.cts +9 -0
  76. package/dist/components/Popover/index.d.ts +9 -0
  77. package/dist/components/Popover/index.js +8 -0
  78. package/dist/components/Popover/popoverFrameGeometry.cjs +177 -0
  79. package/dist/components/Popover/popoverFrameGeometry.d.cts +48 -0
  80. package/dist/components/Popover/popoverFrameGeometry.d.cts.map +1 -0
  81. package/dist/components/Popover/popoverFrameGeometry.d.ts +48 -0
  82. package/dist/components/Popover/popoverFrameGeometry.d.ts.map +1 -0
  83. package/dist/components/Popover/popoverFrameGeometry.js +177 -0
  84. package/dist/components/Popover/popoverFrameGeometry.js.map +1 -0
  85. package/dist/components/Popover/popoverLayer.cjs +16 -0
  86. package/dist/components/Popover/popoverLayer.d.cts +8 -0
  87. package/dist/components/Popover/popoverLayer.d.cts.map +1 -0
  88. package/dist/components/Popover/popoverLayer.d.ts +8 -0
  89. package/dist/components/Popover/popoverLayer.d.ts.map +1 -0
  90. package/dist/components/Popover/popoverLayer.js +16 -0
  91. package/dist/components/Popover/popoverLayer.js.map +1 -0
  92. package/dist/components/Popover/types.cjs +1 -0
  93. package/dist/components/Popover/types.d.cts +170 -0
  94. package/dist/components/Popover/types.d.cts.map +1 -0
  95. package/dist/components/Popover/types.d.ts +170 -0
  96. package/dist/components/Popover/types.d.ts.map +1 -0
  97. package/dist/components/Popover/types.js +1 -0
  98. package/dist/components/Toast/Toast.cjs +141 -0
  99. package/dist/components/Toast/Toast.d.cts +38 -0
  100. package/dist/components/Toast/Toast.d.cts.map +1 -0
  101. package/dist/components/Toast/Toast.d.ts +38 -0
  102. package/dist/components/Toast/Toast.d.ts.map +1 -0
  103. package/dist/components/Toast/Toast.js +141 -0
  104. package/dist/components/Toast/Toast.js.map +1 -0
  105. package/dist/components/Toast/ToastAnimatedItem.cjs +88 -0
  106. package/dist/components/Toast/ToastAnimatedItem.d.cts +27 -0
  107. package/dist/components/Toast/ToastAnimatedItem.d.cts.map +1 -0
  108. package/dist/components/Toast/ToastAnimatedItem.d.ts +27 -0
  109. package/dist/components/Toast/ToastAnimatedItem.d.ts.map +1 -0
  110. package/dist/components/Toast/ToastAnimatedItem.js +87 -0
  111. package/dist/components/Toast/ToastAnimatedItem.js.map +1 -0
  112. package/dist/components/Toast/ToastItem.cjs +35 -0
  113. package/dist/components/Toast/ToastItem.d.cts +25 -0
  114. package/dist/components/Toast/ToastItem.d.cts.map +1 -0
  115. package/dist/components/Toast/ToastItem.d.ts +25 -0
  116. package/dist/components/Toast/ToastItem.d.ts.map +1 -0
  117. package/dist/components/Toast/ToastItem.js +35 -0
  118. package/dist/components/Toast/ToastItem.js.map +1 -0
  119. package/dist/components/Toast/ToastProvider.cjs +144 -0
  120. package/dist/components/Toast/ToastProvider.d.cts +58 -0
  121. package/dist/components/Toast/ToastProvider.d.cts.map +1 -0
  122. package/dist/components/Toast/ToastProvider.d.ts +58 -0
  123. package/dist/components/Toast/ToastProvider.d.ts.map +1 -0
  124. package/dist/components/Toast/ToastProvider.js +143 -0
  125. package/dist/components/Toast/ToastProvider.js.map +1 -0
  126. package/dist/components/Toast/ToastViewport.cjs +48 -0
  127. package/dist/components/Toast/ToastViewport.d.cts +42 -0
  128. package/dist/components/Toast/ToastViewport.d.cts.map +1 -0
  129. package/dist/components/Toast/ToastViewport.d.ts +42 -0
  130. package/dist/components/Toast/ToastViewport.d.ts.map +1 -0
  131. package/dist/components/Toast/ToastViewport.js +48 -0
  132. package/dist/components/Toast/ToastViewport.js.map +1 -0
  133. package/dist/components/Toast/createToast.cjs +21 -0
  134. package/dist/components/Toast/createToast.d.cts +10 -0
  135. package/dist/components/Toast/createToast.d.cts.map +1 -0
  136. package/dist/components/Toast/createToast.d.ts +10 -0
  137. package/dist/components/Toast/createToast.d.ts.map +1 -0
  138. package/dist/components/Toast/createToast.js +20 -0
  139. package/dist/components/Toast/createToast.js.map +1 -0
  140. package/dist/components/Toast/index.cjs +10 -0
  141. package/dist/components/Toast/index.d.cts +6 -0
  142. package/dist/components/Toast/index.d.ts +6 -0
  143. package/dist/components/Toast/index.js +5 -0
  144. package/dist/components/Toast/types.cjs +1 -0
  145. package/dist/components/Toast/types.d.cts +113 -0
  146. package/dist/components/Toast/types.d.cts.map +1 -0
  147. package/dist/components/Toast/types.d.ts +113 -0
  148. package/dist/components/Toast/types.d.ts.map +1 -0
  149. package/dist/components/Toast/types.js +1 -0
  150. package/dist/components/Toast/useToastController.cjs +286 -0
  151. package/dist/components/Toast/useToastController.d.cts +25 -0
  152. package/dist/components/Toast/useToastController.d.cts.map +1 -0
  153. package/dist/components/Toast/useToastController.d.ts +25 -0
  154. package/dist/components/Toast/useToastController.d.ts.map +1 -0
  155. package/dist/components/Toast/useToastController.js +286 -0
  156. package/dist/components/Toast/useToastController.js.map +1 -0
  157. package/dist/components/Toast/utils.cjs +69 -0
  158. package/dist/components/Toast/utils.d.cts +27 -0
  159. package/dist/components/Toast/utils.d.cts.map +1 -0
  160. package/dist/components/Toast/utils.d.ts +27 -0
  161. package/dist/components/Toast/utils.d.ts.map +1 -0
  162. package/dist/components/Toast/utils.js +55 -0
  163. package/dist/components/Toast/utils.js.map +1 -0
  164. package/dist/components/internal/Overlay/index.cjs +4 -0
  165. package/dist/components/internal/Overlay/index.d.cts +4 -2
  166. package/dist/components/internal/Overlay/index.d.ts +4 -2
  167. package/dist/components/internal/Overlay/index.js +3 -1
  168. package/dist/components/internal/Overlay/types.d.cts +47 -1
  169. package/dist/components/internal/Overlay/types.d.cts.map +1 -1
  170. package/dist/components/internal/Overlay/types.d.ts +47 -1
  171. package/dist/components/internal/Overlay/types.d.ts.map +1 -1
  172. package/dist/components/internal/Overlay/useAnchoredPosition.cjs +225 -0
  173. package/dist/components/internal/Overlay/useAnchoredPosition.d.cts +22 -0
  174. package/dist/components/internal/Overlay/useAnchoredPosition.d.cts.map +1 -0
  175. package/dist/components/internal/Overlay/useAnchoredPosition.d.ts +22 -0
  176. package/dist/components/internal/Overlay/useAnchoredPosition.d.ts.map +1 -0
  177. package/dist/components/internal/Overlay/useAnchoredPosition.js +225 -0
  178. package/dist/components/internal/Overlay/useAnchoredPosition.js.map +1 -0
  179. package/dist/components/internal/Overlay/useOverlayDismiss.cjs +22 -0
  180. package/dist/components/internal/Overlay/useOverlayDismiss.d.cts +12 -0
  181. package/dist/components/internal/Overlay/useOverlayDismiss.d.cts.map +1 -0
  182. package/dist/components/internal/Overlay/useOverlayDismiss.d.ts +12 -0
  183. package/dist/components/internal/Overlay/useOverlayDismiss.d.ts.map +1 -0
  184. package/dist/components/internal/Overlay/useOverlayDismiss.js +22 -0
  185. package/dist/components/internal/Overlay/useOverlayDismiss.js.map +1 -0
  186. package/dist/jest/mocks/gesture-handler.cjs +38 -0
  187. package/dist/jest/mocks/gesture-handler.d.cts +41 -0
  188. package/dist/jest/mocks/gesture-handler.d.cts.map +1 -0
  189. package/dist/jest/mocks/gesture-handler.d.ts +41 -0
  190. package/dist/jest/mocks/gesture-handler.d.ts.map +1 -0
  191. package/dist/jest/mocks/gesture-handler.js +37 -0
  192. package/dist/jest/mocks/gesture-handler.js.map +1 -0
  193. package/dist/jest/mocks/react-native.cjs +14 -0
  194. package/dist/jest/mocks/react-native.d.cts +29 -1
  195. package/dist/jest/mocks/react-native.d.cts.map +1 -1
  196. package/dist/jest/mocks/react-native.d.ts +29 -1
  197. package/dist/jest/mocks/react-native.d.ts.map +1 -1
  198. package/dist/jest/mocks/react-native.js +13 -1
  199. package/dist/jest/mocks/react-native.js.map +1 -1
  200. package/dist/jest/mocks/safe-area-context.cjs +35 -0
  201. package/dist/jest/mocks/safe-area-context.d.cts +43 -0
  202. package/dist/jest/mocks/safe-area-context.d.cts.map +1 -0
  203. package/dist/jest/mocks/safe-area-context.d.ts +43 -0
  204. package/dist/jest/mocks/safe-area-context.d.ts.map +1 -0
  205. package/dist/jest/mocks/safe-area-context.js +32 -0
  206. package/dist/jest/mocks/safe-area-context.js.map +1 -0
  207. package/dist/jest/mocks/screens.cjs +8 -0
  208. package/dist/jest/mocks/screens.d.cts +12 -0
  209. package/dist/jest/mocks/screens.d.cts.map +1 -0
  210. package/dist/jest/mocks/screens.d.ts +12 -0
  211. package/dist/jest/mocks/screens.d.ts.map +1 -0
  212. package/dist/jest/mocks/screens.js +9 -0
  213. package/dist/jest/mocks/screens.js.map +1 -0
  214. package/dist/jest/mocks/styles.cjs +98 -1
  215. package/dist/jest/mocks/styles.d.cts +6 -2
  216. package/dist/jest/mocks/styles.d.cts.map +1 -1
  217. package/dist/jest/mocks/styles.d.ts +6 -2
  218. package/dist/jest/mocks/styles.d.ts.map +1 -1
  219. package/dist/jest/mocks/styles.js +95 -2
  220. package/dist/jest/mocks/styles.js.map +1 -1
  221. package/dist/jest/setup.cjs +46 -3
  222. package/dist/jest/setup.d.cts.map +1 -1
  223. package/dist/jest/setup.d.ts.map +1 -1
  224. package/dist/jest/setup.js +46 -3
  225. package/dist/jest/setup.js.map +1 -1
  226. package/dist/types/dist/index.d.cts +4 -1
  227. package/dist/types/dist/index.d.cts.map +1 -1
  228. package/dist/types/dist/index.d.ts +4 -1
  229. package/dist/types/dist/index.d.ts.map +1 -1
  230. package/fonts/index.cjs +211 -211
  231. package/fonts/index.mjs +211 -211
  232. package/generated/styles.cjs +6 -0
  233. package/generated/styles.d.ts +13 -1
  234. package/generated/styles.mjs +6 -0
  235. package/generated/unistyles.d.ts +13 -0
  236. package/package.json +21 -1
@@ -0,0 +1,286 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("../../_virtual/_rolldown/runtime.cjs");
4
+ const require_components_Toast_utils = require("./utils.cjs");
5
+ let react = require("react");
6
+ //#region src/components/Toast/useToastController.ts
7
+ function useToastController({ autoClose, limit, placement, shouldReduceMotion }) {
8
+ const [toasts, baseDispatch] = (0, react.useReducer)(require_components_Toast_utils.toastReducer, []);
9
+ const [waitingToastCount, setWaitingToastCount] = (0, react.useState)(0);
10
+ const toastsRef = (0, react.useRef)(toasts);
11
+ const limitRef = (0, react.useRef)(limit);
12
+ const waitingQueueRef = (0, react.useRef)([]);
13
+ const timeoutRefs = (0, react.useRef)(/* @__PURE__ */ new Map());
14
+ const exitTimeoutRefs = (0, react.useRef)(/* @__PURE__ */ new Map());
15
+ const hideRef = (0, react.useRef)(null);
16
+ (0, react.useEffect)(() => {
17
+ toastsRef.current = toasts;
18
+ }, [toasts]);
19
+ const dispatchToastAction = (0, react.useCallback)((action) => {
20
+ toastsRef.current = require_components_Toast_utils.toastReducer(toastsRef.current, action);
21
+ baseDispatch(action);
22
+ }, [baseDispatch]);
23
+ const clearToastTimer = (0, react.useCallback)((id) => {
24
+ const timeout = timeoutRefs.current.get(id);
25
+ if (timeout) {
26
+ clearTimeout(timeout);
27
+ timeoutRefs.current.delete(id);
28
+ }
29
+ }, []);
30
+ const clearAllToastTimers = (0, react.useCallback)(() => {
31
+ timeoutRefs.current.forEach((timeout) => clearTimeout(timeout));
32
+ timeoutRefs.current.clear();
33
+ }, []);
34
+ const clearToastExitTimer = (0, react.useCallback)((id) => {
35
+ const timeout = exitTimeoutRefs.current.get(id);
36
+ if (timeout) {
37
+ clearTimeout(timeout);
38
+ exitTimeoutRefs.current.delete(id);
39
+ }
40
+ }, []);
41
+ const clearAllToastExitTimers = (0, react.useCallback)(() => {
42
+ exitTimeoutRefs.current.forEach((timeout) => clearTimeout(timeout));
43
+ exitTimeoutRefs.current.clear();
44
+ }, []);
45
+ const syncWaitingToastCount = (0, react.useCallback)(() => {
46
+ setWaitingToastCount(waitingQueueRef.current.length);
47
+ }, []);
48
+ const clearWaitingQueue = (0, react.useCallback)(() => {
49
+ waitingQueueRef.current = [];
50
+ syncWaitingToastCount();
51
+ }, [syncWaitingToastCount]);
52
+ const getQueuedToastIndex = (0, react.useCallback)((id) => waitingQueueRef.current.findIndex((toast) => toast.id === id), []);
53
+ const removeQueuedToast = (0, react.useCallback)((id) => {
54
+ const queuedToastIndex = getQueuedToastIndex(id);
55
+ if (queuedToastIndex === -1) return false;
56
+ waitingQueueRef.current.splice(queuedToastIndex, 1);
57
+ syncWaitingToastCount();
58
+ return true;
59
+ }, [getQueuedToastIndex, syncWaitingToastCount]);
60
+ const scheduleToast = (0, react.useCallback)((toast) => {
61
+ clearToastTimer(toast.id);
62
+ if (require_components_Toast_utils.isPersistentAutoClose(toast.autoClose)) return;
63
+ if (!Number.isFinite(toast.autoClose)) return;
64
+ if (toast.autoClose <= 0) {
65
+ hideRef.current?.(toast.id);
66
+ return;
67
+ }
68
+ const timeout = setTimeout(() => {
69
+ hideRef.current?.(toast.id);
70
+ timeoutRefs.current.delete(toast.id);
71
+ }, toast.autoClose);
72
+ timeoutRefs.current.set(toast.id, timeout);
73
+ }, [clearToastTimer]);
74
+ const showVisibleToast = (0, react.useCallback)((toast, shouldCallOnShow) => {
75
+ clearToastExitTimer(toast.id);
76
+ removeQueuedToast(toast.id);
77
+ dispatchToastAction({
78
+ type: "upsert",
79
+ toast
80
+ });
81
+ if (shouldCallOnShow) toast.onShow?.();
82
+ scheduleToast(toast);
83
+ }, [
84
+ clearToastExitTimer,
85
+ dispatchToastAction,
86
+ removeQueuedToast,
87
+ scheduleToast
88
+ ]);
89
+ const flushWaitingQueue = (0, react.useCallback)(() => {
90
+ let availableSlots = limitRef.current - toastsRef.current.length;
91
+ while (availableSlots > 0 && waitingQueueRef.current.length > 0) {
92
+ const toast = waitingQueueRef.current.shift();
93
+ if (toast) {
94
+ showVisibleToast(toast, true);
95
+ availableSlots -= 1;
96
+ }
97
+ }
98
+ syncWaitingToastCount();
99
+ }, [showVisibleToast, syncWaitingToastCount]);
100
+ const removeToast = (0, react.useCallback)((id) => {
101
+ clearToastTimer(id);
102
+ clearToastExitTimer(id);
103
+ dispatchToastAction({
104
+ type: "remove",
105
+ id
106
+ });
107
+ flushWaitingQueue();
108
+ }, [
109
+ clearToastExitTimer,
110
+ clearToastTimer,
111
+ dispatchToastAction,
112
+ flushWaitingQueue
113
+ ]);
114
+ const beginHideToast = (0, react.useCallback)((toast) => {
115
+ clearToastTimer(toast.id);
116
+ if (toast.isExiting) return;
117
+ toast.onHide?.();
118
+ if (shouldReduceMotion) {
119
+ removeToast(toast.id);
120
+ return;
121
+ }
122
+ dispatchToastAction({
123
+ type: "update",
124
+ id: toast.id,
125
+ toast: { isExiting: true }
126
+ });
127
+ clearToastExitTimer(toast.id);
128
+ const timeout = setTimeout(() => {
129
+ exitTimeoutRefs.current.delete(toast.id);
130
+ removeToast(toast.id);
131
+ }, 150);
132
+ exitTimeoutRefs.current.set(toast.id, timeout);
133
+ }, [
134
+ clearToastExitTimer,
135
+ clearToastTimer,
136
+ dispatchToastAction,
137
+ removeToast,
138
+ shouldReduceMotion
139
+ ]);
140
+ const hide = (0, react.useCallback)((id) => {
141
+ if (id === "all") {
142
+ clearWaitingQueue();
143
+ toastsRef.current.forEach(beginHideToast);
144
+ return;
145
+ }
146
+ const toastId = id ?? toastsRef.current.at(-1)?.id;
147
+ if (!toastId) return;
148
+ const toast = toastsRef.current.find((item) => item.id === toastId);
149
+ if (!toast) {
150
+ removeQueuedToast(toastId);
151
+ return;
152
+ }
153
+ beginHideToast(toast);
154
+ }, [
155
+ beginHideToast,
156
+ clearWaitingQueue,
157
+ removeQueuedToast
158
+ ]);
159
+ (0, react.useEffect)(() => {
160
+ hideRef.current = hide;
161
+ }, [hide]);
162
+ const createToastRecord = (0, react.useCallback)((options, existingToast) => {
163
+ const id = options.id ?? existingToast?.id ?? require_components_Toast_utils.createToastId();
164
+ return {
165
+ ...existingToast,
166
+ ...options,
167
+ id,
168
+ size: options.size ?? existingToast?.size ?? "default",
169
+ variant: options.variant ?? existingToast?.variant ?? "info",
170
+ placement: options.placement ?? existingToast?.placement ?? placement,
171
+ autoClose: options.autoClose ?? existingToast?.autoClose ?? autoClose,
172
+ createdAt: existingToast?.createdAt ?? Date.now(),
173
+ closeOnAction: options.closeOnAction ?? existingToast?.closeOnAction ?? false,
174
+ isExiting: false
175
+ };
176
+ }, [autoClose, placement]);
177
+ const upsertToast = (0, react.useCallback)((toast, shouldCallOnShow) => {
178
+ if (toastsRef.current.find((item) => item.id === toast.id) || toastsRef.current.length < limitRef.current) {
179
+ showVisibleToast(toast, shouldCallOnShow);
180
+ return;
181
+ }
182
+ const queuedToastIndex = getQueuedToastIndex(toast.id);
183
+ if (queuedToastIndex === -1) {
184
+ waitingQueueRef.current.push(toast);
185
+ syncWaitingToastCount();
186
+ return;
187
+ }
188
+ waitingQueueRef.current[queuedToastIndex] = toast;
189
+ }, [
190
+ getQueuedToastIndex,
191
+ showVisibleToast,
192
+ syncWaitingToastCount
193
+ ]);
194
+ const update = (0, react.useCallback)((id, options) => {
195
+ const existingToast = toastsRef.current.find((toast) => toast.id === id);
196
+ const queuedToastIndex = getQueuedToastIndex(id);
197
+ const queuedToast = queuedToastIndex === -1 ? void 0 : waitingQueueRef.current[queuedToastIndex];
198
+ upsertToast(createToastRecord({
199
+ ...options,
200
+ id
201
+ }, existingToast ?? queuedToast), false);
202
+ return {
203
+ id,
204
+ update: (nextOptions) => update(id, nextOptions),
205
+ close: () => hide(id)
206
+ };
207
+ }, [
208
+ createToastRecord,
209
+ getQueuedToastIndex,
210
+ hide,
211
+ upsertToast
212
+ ]);
213
+ const show = (0, react.useCallback)((input) => {
214
+ const options = require_components_Toast_utils.resolveToastInput(input);
215
+ const id = options.id ?? require_components_Toast_utils.createToastId();
216
+ const existingToast = toastsRef.current.find((toast) => toast.id === id);
217
+ const queuedToastIndex = getQueuedToastIndex(id);
218
+ const queuedToast = queuedToastIndex === -1 ? void 0 : waitingQueueRef.current[queuedToastIndex];
219
+ upsertToast(createToastRecord({
220
+ ...options,
221
+ id
222
+ }, existingToast ?? queuedToast), true);
223
+ return {
224
+ id,
225
+ update: (nextOptions) => update(id, nextOptions),
226
+ close: () => hide(id)
227
+ };
228
+ }, [
229
+ createToastRecord,
230
+ getQueuedToastIndex,
231
+ hide,
232
+ update,
233
+ upsertToast
234
+ ]);
235
+ const hideAll = (0, react.useCallback)(() => hide("all"), [hide]);
236
+ (0, react.useEffect)(() => {
237
+ limitRef.current = limit;
238
+ if (toastsRef.current.length > limit) {
239
+ const visibleToasts = toastsRef.current.slice(0, limit);
240
+ const queuedToasts = toastsRef.current.slice(limit).map((toast) => ({
241
+ ...toast,
242
+ isExiting: false
243
+ }));
244
+ queuedToasts.forEach((toast) => {
245
+ clearToastTimer(toast.id);
246
+ clearToastExitTimer(toast.id);
247
+ });
248
+ waitingQueueRef.current = [...queuedToasts, ...waitingQueueRef.current];
249
+ syncWaitingToastCount();
250
+ dispatchToastAction({
251
+ type: "set",
252
+ toasts: visibleToasts
253
+ });
254
+ return;
255
+ }
256
+ flushWaitingQueue();
257
+ }, [
258
+ clearToastExitTimer,
259
+ clearToastTimer,
260
+ dispatchToastAction,
261
+ flushWaitingQueue,
262
+ limit,
263
+ syncWaitingToastCount
264
+ ]);
265
+ return {
266
+ clearAllToastExitTimers,
267
+ clearAllToastTimers,
268
+ controller: (0, react.useMemo)(() => ({
269
+ show,
270
+ update,
271
+ hide,
272
+ hideAll,
273
+ clearWaitingQueue
274
+ }), [
275
+ clearWaitingQueue,
276
+ hide,
277
+ hideAll,
278
+ show,
279
+ update
280
+ ]),
281
+ toasts,
282
+ waitingToastCount
283
+ };
284
+ }
285
+ //#endregion
286
+ exports.useToastController = useToastController;
@@ -0,0 +1,25 @@
1
+
2
+ import { ToastAutoClose, ToastController, ToastPlacement, ToastRecord } from "./types.cjs";
3
+
4
+ //#region src/components/Toast/useToastController.d.ts
5
+ interface UseToastControllerOptions {
6
+ autoClose: ToastAutoClose;
7
+ limit: number;
8
+ placement: ToastPlacement;
9
+ shouldReduceMotion: boolean;
10
+ }
11
+ declare function useToastController({
12
+ autoClose,
13
+ limit,
14
+ placement,
15
+ shouldReduceMotion
16
+ }: UseToastControllerOptions): {
17
+ clearAllToastExitTimers: () => void;
18
+ clearAllToastTimers: () => void;
19
+ controller: ToastController;
20
+ toasts: ToastRecord[];
21
+ waitingToastCount: number;
22
+ };
23
+ //#endregion
24
+ export { useToastController };
25
+ //# sourceMappingURL=useToastController.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToastController.d.cts","names":[],"sources":["../../../src/components/Toast/useToastController.ts"],"mappings":";;;;UAoBU,yBAAA;EACR,SAAA,EAAW,cAAA;EACX,KAAA;EACA,SAAA,EAAW,cAAA;EACX,kBAAA;AAAA;AAAA,iBAGO,kBAAA,CAAA;EACP,SAAA;EACA,KAAA;EACA,SAAA;EACA;AAAA,GACC,yBAAA"}
@@ -0,0 +1,25 @@
1
+
2
+ import { ToastAutoClose, ToastController, ToastPlacement, ToastRecord } from "./types.js";
3
+
4
+ //#region src/components/Toast/useToastController.d.ts
5
+ interface UseToastControllerOptions {
6
+ autoClose: ToastAutoClose;
7
+ limit: number;
8
+ placement: ToastPlacement;
9
+ shouldReduceMotion: boolean;
10
+ }
11
+ declare function useToastController({
12
+ autoClose,
13
+ limit,
14
+ placement,
15
+ shouldReduceMotion
16
+ }: UseToastControllerOptions): {
17
+ clearAllToastExitTimers: () => void;
18
+ clearAllToastTimers: () => void;
19
+ controller: ToastController;
20
+ toasts: ToastRecord[];
21
+ waitingToastCount: number;
22
+ };
23
+ //#endregion
24
+ export { useToastController };
25
+ //# sourceMappingURL=useToastController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToastController.d.ts","names":[],"sources":["../../../src/components/Toast/useToastController.ts"],"mappings":";;;;UAoBU,yBAAA;EACR,SAAA,EAAW,cAAA;EACX,KAAA;EACA,SAAA,EAAW,cAAA;EACX,kBAAA;AAAA;AAAA,iBAGO,kBAAA,CAAA;EACP,SAAA;EACA,KAAA;EACA,SAAA;EACA;AAAA,GACC,yBAAA"}
@@ -0,0 +1,286 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
2
+ import { createToastId, isPersistentAutoClose, resolveToastInput, toastReducer } from "./utils.js";
3
+ import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react";
4
+ //#region src/components/Toast/useToastController.ts
5
+ function useToastController({ autoClose, limit, placement, shouldReduceMotion }) {
6
+ const [toasts, baseDispatch] = useReducer(toastReducer, []);
7
+ const [waitingToastCount, setWaitingToastCount] = useState(0);
8
+ const toastsRef = useRef(toasts);
9
+ const limitRef = useRef(limit);
10
+ const waitingQueueRef = useRef([]);
11
+ const timeoutRefs = useRef(/* @__PURE__ */ new Map());
12
+ const exitTimeoutRefs = useRef(/* @__PURE__ */ new Map());
13
+ const hideRef = useRef(null);
14
+ useEffect(() => {
15
+ toastsRef.current = toasts;
16
+ }, [toasts]);
17
+ const dispatchToastAction = useCallback((action) => {
18
+ toastsRef.current = toastReducer(toastsRef.current, action);
19
+ baseDispatch(action);
20
+ }, [baseDispatch]);
21
+ const clearToastTimer = useCallback((id) => {
22
+ const timeout = timeoutRefs.current.get(id);
23
+ if (timeout) {
24
+ clearTimeout(timeout);
25
+ timeoutRefs.current.delete(id);
26
+ }
27
+ }, []);
28
+ const clearAllToastTimers = useCallback(() => {
29
+ timeoutRefs.current.forEach((timeout) => clearTimeout(timeout));
30
+ timeoutRefs.current.clear();
31
+ }, []);
32
+ const clearToastExitTimer = useCallback((id) => {
33
+ const timeout = exitTimeoutRefs.current.get(id);
34
+ if (timeout) {
35
+ clearTimeout(timeout);
36
+ exitTimeoutRefs.current.delete(id);
37
+ }
38
+ }, []);
39
+ const clearAllToastExitTimers = useCallback(() => {
40
+ exitTimeoutRefs.current.forEach((timeout) => clearTimeout(timeout));
41
+ exitTimeoutRefs.current.clear();
42
+ }, []);
43
+ const syncWaitingToastCount = useCallback(() => {
44
+ setWaitingToastCount(waitingQueueRef.current.length);
45
+ }, []);
46
+ const clearWaitingQueue = useCallback(() => {
47
+ waitingQueueRef.current = [];
48
+ syncWaitingToastCount();
49
+ }, [syncWaitingToastCount]);
50
+ const getQueuedToastIndex = useCallback((id) => waitingQueueRef.current.findIndex((toast) => toast.id === id), []);
51
+ const removeQueuedToast = useCallback((id) => {
52
+ const queuedToastIndex = getQueuedToastIndex(id);
53
+ if (queuedToastIndex === -1) return false;
54
+ waitingQueueRef.current.splice(queuedToastIndex, 1);
55
+ syncWaitingToastCount();
56
+ return true;
57
+ }, [getQueuedToastIndex, syncWaitingToastCount]);
58
+ const scheduleToast = useCallback((toast) => {
59
+ clearToastTimer(toast.id);
60
+ if (isPersistentAutoClose(toast.autoClose)) return;
61
+ if (!Number.isFinite(toast.autoClose)) return;
62
+ if (toast.autoClose <= 0) {
63
+ hideRef.current?.(toast.id);
64
+ return;
65
+ }
66
+ const timeout = setTimeout(() => {
67
+ hideRef.current?.(toast.id);
68
+ timeoutRefs.current.delete(toast.id);
69
+ }, toast.autoClose);
70
+ timeoutRefs.current.set(toast.id, timeout);
71
+ }, [clearToastTimer]);
72
+ const showVisibleToast = useCallback((toast, shouldCallOnShow) => {
73
+ clearToastExitTimer(toast.id);
74
+ removeQueuedToast(toast.id);
75
+ dispatchToastAction({
76
+ type: "upsert",
77
+ toast
78
+ });
79
+ if (shouldCallOnShow) toast.onShow?.();
80
+ scheduleToast(toast);
81
+ }, [
82
+ clearToastExitTimer,
83
+ dispatchToastAction,
84
+ removeQueuedToast,
85
+ scheduleToast
86
+ ]);
87
+ const flushWaitingQueue = useCallback(() => {
88
+ let availableSlots = limitRef.current - toastsRef.current.length;
89
+ while (availableSlots > 0 && waitingQueueRef.current.length > 0) {
90
+ const toast = waitingQueueRef.current.shift();
91
+ if (toast) {
92
+ showVisibleToast(toast, true);
93
+ availableSlots -= 1;
94
+ }
95
+ }
96
+ syncWaitingToastCount();
97
+ }, [showVisibleToast, syncWaitingToastCount]);
98
+ const removeToast = useCallback((id) => {
99
+ clearToastTimer(id);
100
+ clearToastExitTimer(id);
101
+ dispatchToastAction({
102
+ type: "remove",
103
+ id
104
+ });
105
+ flushWaitingQueue();
106
+ }, [
107
+ clearToastExitTimer,
108
+ clearToastTimer,
109
+ dispatchToastAction,
110
+ flushWaitingQueue
111
+ ]);
112
+ const beginHideToast = useCallback((toast) => {
113
+ clearToastTimer(toast.id);
114
+ if (toast.isExiting) return;
115
+ toast.onHide?.();
116
+ if (shouldReduceMotion) {
117
+ removeToast(toast.id);
118
+ return;
119
+ }
120
+ dispatchToastAction({
121
+ type: "update",
122
+ id: toast.id,
123
+ toast: { isExiting: true }
124
+ });
125
+ clearToastExitTimer(toast.id);
126
+ const timeout = setTimeout(() => {
127
+ exitTimeoutRefs.current.delete(toast.id);
128
+ removeToast(toast.id);
129
+ }, 150);
130
+ exitTimeoutRefs.current.set(toast.id, timeout);
131
+ }, [
132
+ clearToastExitTimer,
133
+ clearToastTimer,
134
+ dispatchToastAction,
135
+ removeToast,
136
+ shouldReduceMotion
137
+ ]);
138
+ const hide = useCallback((id) => {
139
+ if (id === "all") {
140
+ clearWaitingQueue();
141
+ toastsRef.current.forEach(beginHideToast);
142
+ return;
143
+ }
144
+ const toastId = id ?? toastsRef.current.at(-1)?.id;
145
+ if (!toastId) return;
146
+ const toast = toastsRef.current.find((item) => item.id === toastId);
147
+ if (!toast) {
148
+ removeQueuedToast(toastId);
149
+ return;
150
+ }
151
+ beginHideToast(toast);
152
+ }, [
153
+ beginHideToast,
154
+ clearWaitingQueue,
155
+ removeQueuedToast
156
+ ]);
157
+ useEffect(() => {
158
+ hideRef.current = hide;
159
+ }, [hide]);
160
+ const createToastRecord = useCallback((options, existingToast) => {
161
+ const id = options.id ?? existingToast?.id ?? createToastId();
162
+ return {
163
+ ...existingToast,
164
+ ...options,
165
+ id,
166
+ size: options.size ?? existingToast?.size ?? "default",
167
+ variant: options.variant ?? existingToast?.variant ?? "info",
168
+ placement: options.placement ?? existingToast?.placement ?? placement,
169
+ autoClose: options.autoClose ?? existingToast?.autoClose ?? autoClose,
170
+ createdAt: existingToast?.createdAt ?? Date.now(),
171
+ closeOnAction: options.closeOnAction ?? existingToast?.closeOnAction ?? false,
172
+ isExiting: false
173
+ };
174
+ }, [autoClose, placement]);
175
+ const upsertToast = useCallback((toast, shouldCallOnShow) => {
176
+ if (toastsRef.current.find((item) => item.id === toast.id) || toastsRef.current.length < limitRef.current) {
177
+ showVisibleToast(toast, shouldCallOnShow);
178
+ return;
179
+ }
180
+ const queuedToastIndex = getQueuedToastIndex(toast.id);
181
+ if (queuedToastIndex === -1) {
182
+ waitingQueueRef.current.push(toast);
183
+ syncWaitingToastCount();
184
+ return;
185
+ }
186
+ waitingQueueRef.current[queuedToastIndex] = toast;
187
+ }, [
188
+ getQueuedToastIndex,
189
+ showVisibleToast,
190
+ syncWaitingToastCount
191
+ ]);
192
+ const update = useCallback((id, options) => {
193
+ const existingToast = toastsRef.current.find((toast) => toast.id === id);
194
+ const queuedToastIndex = getQueuedToastIndex(id);
195
+ const queuedToast = queuedToastIndex === -1 ? void 0 : waitingQueueRef.current[queuedToastIndex];
196
+ upsertToast(createToastRecord({
197
+ ...options,
198
+ id
199
+ }, existingToast ?? queuedToast), false);
200
+ return {
201
+ id,
202
+ update: (nextOptions) => update(id, nextOptions),
203
+ close: () => hide(id)
204
+ };
205
+ }, [
206
+ createToastRecord,
207
+ getQueuedToastIndex,
208
+ hide,
209
+ upsertToast
210
+ ]);
211
+ const show = useCallback((input) => {
212
+ const options = resolveToastInput(input);
213
+ const id = options.id ?? createToastId();
214
+ const existingToast = toastsRef.current.find((toast) => toast.id === id);
215
+ const queuedToastIndex = getQueuedToastIndex(id);
216
+ const queuedToast = queuedToastIndex === -1 ? void 0 : waitingQueueRef.current[queuedToastIndex];
217
+ upsertToast(createToastRecord({
218
+ ...options,
219
+ id
220
+ }, existingToast ?? queuedToast), true);
221
+ return {
222
+ id,
223
+ update: (nextOptions) => update(id, nextOptions),
224
+ close: () => hide(id)
225
+ };
226
+ }, [
227
+ createToastRecord,
228
+ getQueuedToastIndex,
229
+ hide,
230
+ update,
231
+ upsertToast
232
+ ]);
233
+ const hideAll = useCallback(() => hide("all"), [hide]);
234
+ useEffect(() => {
235
+ limitRef.current = limit;
236
+ if (toastsRef.current.length > limit) {
237
+ const visibleToasts = toastsRef.current.slice(0, limit);
238
+ const queuedToasts = toastsRef.current.slice(limit).map((toast) => ({
239
+ ...toast,
240
+ isExiting: false
241
+ }));
242
+ queuedToasts.forEach((toast) => {
243
+ clearToastTimer(toast.id);
244
+ clearToastExitTimer(toast.id);
245
+ });
246
+ waitingQueueRef.current = [...queuedToasts, ...waitingQueueRef.current];
247
+ syncWaitingToastCount();
248
+ dispatchToastAction({
249
+ type: "set",
250
+ toasts: visibleToasts
251
+ });
252
+ return;
253
+ }
254
+ flushWaitingQueue();
255
+ }, [
256
+ clearToastExitTimer,
257
+ clearToastTimer,
258
+ dispatchToastAction,
259
+ flushWaitingQueue,
260
+ limit,
261
+ syncWaitingToastCount
262
+ ]);
263
+ return {
264
+ clearAllToastExitTimers,
265
+ clearAllToastTimers,
266
+ controller: useMemo(() => ({
267
+ show,
268
+ update,
269
+ hide,
270
+ hideAll,
271
+ clearWaitingQueue
272
+ }), [
273
+ clearWaitingQueue,
274
+ hide,
275
+ hideAll,
276
+ show,
277
+ update
278
+ ]),
279
+ toasts,
280
+ waitingToastCount
281
+ };
282
+ }
283
+ //#endregion
284
+ export { useToastController };
285
+
286
+ //# sourceMappingURL=useToastController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToastController.js","names":[],"sources":["../../../src/components/Toast/useToastController.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';\n\nimport type {\n ToastAction,\n ToastAutoClose,\n ToastController,\n ToastHandle,\n ToastPlacement,\n ToastRecord,\n ToastShowInput,\n ToastShowOptions,\n} from './types';\nimport {\n createToastId,\n isPersistentAutoClose,\n resolveToastInput,\n TOAST_EXIT_ANIMATION_DURATION,\n toastReducer,\n} from './utils';\n\ninterface UseToastControllerOptions {\n autoClose: ToastAutoClose;\n limit: number;\n placement: ToastPlacement;\n shouldReduceMotion: boolean;\n}\n\nfunction useToastController({\n autoClose,\n limit,\n placement,\n shouldReduceMotion,\n}: UseToastControllerOptions) {\n const [toasts, baseDispatch] = useReducer(toastReducer, [] as ToastRecord[]);\n const [waitingToastCount, setWaitingToastCount] = useState(0);\n const toastsRef = useRef<ToastRecord[]>(toasts);\n const limitRef = useRef(limit);\n const waitingQueueRef = useRef<ToastRecord[]>([]);\n const timeoutRefs = useRef(new Map<string, ReturnType<typeof setTimeout>>());\n const exitTimeoutRefs = useRef(new Map<string, ReturnType<typeof setTimeout>>());\n const hideRef = useRef<ToastController['hide'] | null>(null);\n\n useEffect(() => {\n toastsRef.current = toasts;\n }, [toasts]);\n\n const dispatchToastAction = useCallback(\n (action: ToastAction) => {\n toastsRef.current = toastReducer(toastsRef.current, action);\n baseDispatch(action);\n },\n [baseDispatch],\n );\n\n const clearToastTimer = useCallback((id: string) => {\n const timeout = timeoutRefs.current.get(id);\n\n if (timeout) {\n clearTimeout(timeout);\n timeoutRefs.current.delete(id);\n }\n }, []);\n\n const clearAllToastTimers = useCallback(() => {\n timeoutRefs.current.forEach((timeout) => clearTimeout(timeout));\n timeoutRefs.current.clear();\n }, []);\n\n const clearToastExitTimer = useCallback((id: string) => {\n const timeout = exitTimeoutRefs.current.get(id);\n\n if (timeout) {\n clearTimeout(timeout);\n exitTimeoutRefs.current.delete(id);\n }\n }, []);\n\n const clearAllToastExitTimers = useCallback(() => {\n exitTimeoutRefs.current.forEach((timeout) => clearTimeout(timeout));\n exitTimeoutRefs.current.clear();\n }, []);\n\n const syncWaitingToastCount = useCallback(() => {\n setWaitingToastCount(waitingQueueRef.current.length);\n }, []);\n\n const clearWaitingQueue = useCallback(() => {\n waitingQueueRef.current = [];\n syncWaitingToastCount();\n }, [syncWaitingToastCount]);\n\n const getQueuedToastIndex = useCallback(\n (id: string) => waitingQueueRef.current.findIndex((toast) => toast.id === id),\n [],\n );\n\n const removeQueuedToast = useCallback(\n (id: string) => {\n const queuedToastIndex = getQueuedToastIndex(id);\n\n if (queuedToastIndex === -1) {\n return false;\n }\n\n waitingQueueRef.current.splice(queuedToastIndex, 1);\n syncWaitingToastCount();\n return true;\n },\n [getQueuedToastIndex, syncWaitingToastCount],\n );\n\n const scheduleToast = useCallback(\n (toast: ToastRecord) => {\n clearToastTimer(toast.id);\n\n if (isPersistentAutoClose(toast.autoClose)) {\n return;\n }\n\n if (!Number.isFinite(toast.autoClose)) {\n return;\n }\n\n if (toast.autoClose <= 0) {\n hideRef.current?.(toast.id);\n return;\n }\n\n const timeout = setTimeout(() => {\n hideRef.current?.(toast.id);\n timeoutRefs.current.delete(toast.id);\n }, toast.autoClose);\n\n timeoutRefs.current.set(toast.id, timeout);\n },\n [clearToastTimer],\n );\n\n const showVisibleToast = useCallback(\n (toast: ToastRecord, shouldCallOnShow: boolean) => {\n clearToastExitTimer(toast.id);\n removeQueuedToast(toast.id);\n dispatchToastAction({ type: 'upsert', toast });\n\n if (shouldCallOnShow) {\n toast.onShow?.();\n }\n\n scheduleToast(toast);\n },\n [clearToastExitTimer, dispatchToastAction, removeQueuedToast, scheduleToast],\n );\n\n const flushWaitingQueue = useCallback(() => {\n let availableSlots = limitRef.current - toastsRef.current.length;\n\n while (availableSlots > 0 && waitingQueueRef.current.length > 0) {\n const toast = waitingQueueRef.current.shift();\n\n if (toast) {\n showVisibleToast(toast, true);\n availableSlots -= 1;\n }\n }\n\n syncWaitingToastCount();\n }, [showVisibleToast, syncWaitingToastCount]);\n\n const removeToast = useCallback(\n (id: string) => {\n clearToastTimer(id);\n clearToastExitTimer(id);\n dispatchToastAction({ type: 'remove', id });\n flushWaitingQueue();\n },\n [clearToastExitTimer, clearToastTimer, dispatchToastAction, flushWaitingQueue],\n );\n\n const beginHideToast = useCallback(\n (toast: ToastRecord) => {\n clearToastTimer(toast.id);\n\n if (toast.isExiting) {\n return;\n }\n\n toast.onHide?.();\n\n if (shouldReduceMotion) {\n removeToast(toast.id);\n return;\n }\n\n dispatchToastAction({ type: 'update', id: toast.id, toast: { isExiting: true } });\n clearToastExitTimer(toast.id);\n\n const timeout = setTimeout(() => {\n exitTimeoutRefs.current.delete(toast.id);\n removeToast(toast.id);\n }, TOAST_EXIT_ANIMATION_DURATION);\n\n exitTimeoutRefs.current.set(toast.id, timeout);\n },\n [clearToastExitTimer, clearToastTimer, dispatchToastAction, removeToast, shouldReduceMotion],\n );\n\n const hide = useCallback(\n (id?: string | 'all') => {\n if (id === 'all') {\n clearWaitingQueue();\n toastsRef.current.forEach(beginHideToast);\n return;\n }\n\n const toastId = id ?? toastsRef.current.at(-1)?.id;\n\n if (!toastId) {\n return;\n }\n\n const toast = toastsRef.current.find((item) => item.id === toastId);\n\n if (!toast) {\n removeQueuedToast(toastId);\n return;\n }\n\n beginHideToast(toast);\n },\n [beginHideToast, clearWaitingQueue, removeQueuedToast],\n );\n\n useEffect(() => {\n hideRef.current = hide;\n }, [hide]);\n\n const createToastRecord = useCallback(\n (options: Partial<ToastRecord>, existingToast?: ToastRecord): ToastRecord => {\n const id = options.id ?? existingToast?.id ?? createToastId();\n\n return {\n ...existingToast,\n ...options,\n id,\n size: options.size ?? existingToast?.size ?? 'default',\n variant: options.variant ?? existingToast?.variant ?? 'info',\n placement: options.placement ?? existingToast?.placement ?? placement,\n autoClose: options.autoClose ?? existingToast?.autoClose ?? autoClose,\n createdAt: existingToast?.createdAt ?? Date.now(),\n closeOnAction: options.closeOnAction ?? existingToast?.closeOnAction ?? false,\n isExiting: false,\n };\n },\n [autoClose, placement],\n );\n\n const upsertToast = useCallback(\n (toast: ToastRecord, shouldCallOnShow: boolean) => {\n const visibleToast = toastsRef.current.find((item) => item.id === toast.id);\n\n if (visibleToast || toastsRef.current.length < limitRef.current) {\n showVisibleToast(toast, shouldCallOnShow);\n return;\n }\n\n const queuedToastIndex = getQueuedToastIndex(toast.id);\n\n if (queuedToastIndex === -1) {\n waitingQueueRef.current.push(toast);\n syncWaitingToastCount();\n return;\n }\n\n waitingQueueRef.current[queuedToastIndex] = toast;\n },\n [getQueuedToastIndex, showVisibleToast, syncWaitingToastCount],\n );\n\n const update = useCallback(\n (id: string, options: Partial<ToastShowOptions>): ToastHandle => {\n const existingToast = toastsRef.current.find((toast) => toast.id === id);\n const queuedToastIndex = getQueuedToastIndex(id);\n const queuedToast =\n queuedToastIndex === -1 ? undefined : waitingQueueRef.current[queuedToastIndex];\n const toast = createToastRecord({ ...options, id }, existingToast ?? queuedToast);\n\n upsertToast(toast, false);\n\n return {\n id,\n update: (nextOptions) => update(id, nextOptions),\n close: () => hide(id),\n };\n },\n [createToastRecord, getQueuedToastIndex, hide, upsertToast],\n );\n\n const show = useCallback(\n (input: ToastShowInput): ToastHandle => {\n const options = resolveToastInput(input);\n const id = options.id ?? createToastId();\n const existingToast = toastsRef.current.find((toast) => toast.id === id);\n const queuedToastIndex = getQueuedToastIndex(id);\n const queuedToast =\n queuedToastIndex === -1 ? undefined : waitingQueueRef.current[queuedToastIndex];\n const toast = createToastRecord({ ...options, id }, existingToast ?? queuedToast);\n\n upsertToast(toast, true);\n\n return {\n id,\n update: (nextOptions) => update(id, nextOptions),\n close: () => hide(id),\n };\n },\n [createToastRecord, getQueuedToastIndex, hide, update, upsertToast],\n );\n\n const hideAll = useCallback(() => hide('all'), [hide]);\n\n useEffect(() => {\n limitRef.current = limit;\n\n if (toastsRef.current.length > limit) {\n const visibleToasts = toastsRef.current.slice(0, limit);\n const queuedToasts = toastsRef.current.slice(limit).map((toast) => ({\n ...toast,\n isExiting: false,\n }));\n\n queuedToasts.forEach((toast) => {\n clearToastTimer(toast.id);\n clearToastExitTimer(toast.id);\n });\n\n waitingQueueRef.current = [...queuedToasts, ...waitingQueueRef.current];\n syncWaitingToastCount();\n dispatchToastAction({ type: 'set', toasts: visibleToasts });\n return;\n }\n\n flushWaitingQueue();\n }, [\n clearToastExitTimer,\n clearToastTimer,\n dispatchToastAction,\n flushWaitingQueue,\n limit,\n syncWaitingToastCount,\n ]);\n\n const controller = useMemo<ToastController>(\n () => ({\n show,\n update,\n hide,\n hideAll,\n clearWaitingQueue,\n }),\n [clearWaitingQueue, hide, hideAll, show, update],\n );\n\n return {\n clearAllToastExitTimers,\n clearAllToastTimers,\n controller,\n toasts,\n waitingToastCount,\n };\n}\n\nexport { useToastController };\n"],"mappings":";;;;AA2BA,SAAS,mBAAmB,EAC1B,WACA,OACA,WACA,sBAC4B;CAC5B,MAAM,CAAC,QAAQ,gBAAgB,WAAW,cAAc,EAAE,CAAkB;CAC5E,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,EAAE;CAC7D,MAAM,YAAY,OAAsB,OAAO;CAC/C,MAAM,WAAW,OAAO,MAAM;CAC9B,MAAM,kBAAkB,OAAsB,EAAE,CAAC;CACjD,MAAM,cAAc,uBAAO,IAAI,KAA4C,CAAC;CAC5E,MAAM,kBAAkB,uBAAO,IAAI,KAA4C,CAAC;CAChF,MAAM,UAAU,OAAuC,KAAK;CAE5D,gBAAgB;EACd,UAAU,UAAU;IACnB,CAAC,OAAO,CAAC;CAEZ,MAAM,sBAAsB,aACzB,WAAwB;EACvB,UAAU,UAAU,aAAa,UAAU,SAAS,OAAO;EAC3D,aAAa,OAAO;IAEtB,CAAC,aAAa,CACf;CAED,MAAM,kBAAkB,aAAa,OAAe;EAClD,MAAM,UAAU,YAAY,QAAQ,IAAI,GAAG;EAE3C,IAAI,SAAS;GACX,aAAa,QAAQ;GACrB,YAAY,QAAQ,OAAO,GAAG;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