@cdx-ui/components 0.0.1-beta.79 → 0.0.1-beta.80

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 (214) hide show
  1. package/lib/commonjs/animation/hooks/index.js +17 -0
  2. package/lib/commonjs/animation/hooks/index.js.map +1 -0
  3. package/lib/commonjs/animation/hooks/useCombinedAnimationDisabledState.js +50 -0
  4. package/lib/commonjs/animation/hooks/useCombinedAnimationDisabledState.js.map +1 -0
  5. package/lib/commonjs/animation/index.js +39 -0
  6. package/lib/commonjs/animation/index.js.map +1 -0
  7. package/lib/commonjs/animation/types.js +6 -0
  8. package/lib/commonjs/animation/types.js.map +1 -0
  9. package/lib/commonjs/animation/utils.js +223 -0
  10. package/lib/commonjs/animation/utils.js.map +1 -0
  11. package/lib/commonjs/components/CLAUDE.md +1 -1
  12. package/lib/commonjs/components/Card/index.js +45 -17
  13. package/lib/commonjs/components/Card/index.js.map +1 -1
  14. package/lib/commonjs/components/Toast/animation.js +329 -0
  15. package/lib/commonjs/components/Toast/animation.js.map +1 -0
  16. package/lib/commonjs/components/Toast/hooks.js +66 -0
  17. package/lib/commonjs/components/Toast/hooks.js.map +1 -0
  18. package/lib/commonjs/components/Toast/index.js +493 -0
  19. package/lib/commonjs/components/Toast/index.js.map +1 -0
  20. package/lib/commonjs/components/Toast/styles.js +141 -0
  21. package/lib/commonjs/components/Toast/styles.js.map +1 -0
  22. package/lib/commonjs/components/Toast/types.js +6 -0
  23. package/lib/commonjs/components/Toast/types.js.map +1 -0
  24. package/lib/commonjs/components/index.js +12 -0
  25. package/lib/commonjs/components/index.js.map +1 -1
  26. package/lib/commonjs/index.js +15 -0
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/providers/animation-settings/index.js +31 -0
  29. package/lib/commonjs/providers/animation-settings/index.js.map +1 -0
  30. package/lib/commonjs/providers/animation-settings/provider.js +59 -0
  31. package/lib/commonjs/providers/animation-settings/provider.js.map +1 -0
  32. package/lib/commonjs/providers/animation-settings/types.js +6 -0
  33. package/lib/commonjs/providers/animation-settings/types.js.map +1 -0
  34. package/lib/commonjs/providers/forge-design/index.js +29 -0
  35. package/lib/commonjs/providers/forge-design/index.js.map +1 -0
  36. package/lib/commonjs/providers/forge-design/provider.js +71 -0
  37. package/lib/commonjs/providers/forge-design/provider.js.map +1 -0
  38. package/lib/commonjs/providers/forge-design/types.js +6 -0
  39. package/lib/commonjs/providers/forge-design/types.js.map +1 -0
  40. package/lib/commonjs/providers/text-component/index.js +28 -0
  41. package/lib/commonjs/providers/text-component/index.js.map +1 -0
  42. package/lib/commonjs/providers/text-component/provider.js +11 -0
  43. package/lib/commonjs/providers/text-component/provider.js.map +1 -0
  44. package/lib/commonjs/providers/text-component/types.js +6 -0
  45. package/lib/commonjs/providers/text-component/types.js.map +1 -0
  46. package/lib/commonjs/providers/toast/index.js +33 -0
  47. package/lib/commonjs/providers/toast/index.js.map +1 -0
  48. package/lib/commonjs/providers/toast/insets-container.js +160 -0
  49. package/lib/commonjs/providers/toast/insets-container.js.map +1 -0
  50. package/lib/commonjs/providers/toast/lifecycle.context.js +36 -0
  51. package/lib/commonjs/providers/toast/lifecycle.context.js.map +1 -0
  52. package/lib/commonjs/providers/toast/provider.js +508 -0
  53. package/lib/commonjs/providers/toast/provider.js.map +1 -0
  54. package/lib/commonjs/providers/toast/reducer.js +46 -0
  55. package/lib/commonjs/providers/toast/reducer.js.map +1 -0
  56. package/lib/commonjs/providers/toast/toast-config.context.js +29 -0
  57. package/lib/commonjs/providers/toast/toast-config.context.js.map +1 -0
  58. package/lib/commonjs/providers/toast/toast-item-renderer.js +43 -0
  59. package/lib/commonjs/providers/toast/toast-item-renderer.js.map +1 -0
  60. package/lib/commonjs/providers/toast/types.js +6 -0
  61. package/lib/commonjs/providers/toast/types.js.map +1 -0
  62. package/lib/module/animation/hooks/index.js +4 -0
  63. package/lib/module/animation/hooks/index.js.map +1 -0
  64. package/lib/module/animation/hooks/useCombinedAnimationDisabledState.js +47 -0
  65. package/lib/module/animation/hooks/useCombinedAnimationDisabledState.js.map +1 -0
  66. package/lib/module/animation/index.js +6 -0
  67. package/lib/module/animation/index.js.map +1 -0
  68. package/lib/module/animation/types.js +4 -0
  69. package/lib/module/animation/types.js.map +1 -0
  70. package/lib/module/animation/utils.js +212 -0
  71. package/lib/module/animation/utils.js.map +1 -0
  72. package/lib/module/components/CLAUDE.md +1 -1
  73. package/lib/module/components/Card/index.js +47 -19
  74. package/lib/module/components/Card/index.js.map +1 -1
  75. package/lib/module/components/Toast/animation.js +324 -0
  76. package/lib/module/components/Toast/animation.js.map +1 -0
  77. package/lib/module/components/Toast/hooks.js +61 -0
  78. package/lib/module/components/Toast/hooks.js.map +1 -0
  79. package/lib/module/components/Toast/index.js +487 -0
  80. package/lib/module/components/Toast/index.js.map +1 -0
  81. package/lib/module/components/Toast/styles.js +138 -0
  82. package/lib/module/components/Toast/styles.js.map +1 -0
  83. package/lib/module/components/Toast/types.js +4 -0
  84. package/lib/module/components/Toast/types.js.map +1 -0
  85. package/lib/module/components/index.js +1 -0
  86. package/lib/module/components/index.js.map +1 -1
  87. package/lib/module/index.js +1 -0
  88. package/lib/module/index.js.map +1 -1
  89. package/lib/module/providers/animation-settings/index.js +4 -0
  90. package/lib/module/providers/animation-settings/index.js.map +1 -0
  91. package/lib/module/providers/animation-settings/provider.js +52 -0
  92. package/lib/module/providers/animation-settings/provider.js.map +1 -0
  93. package/lib/module/providers/animation-settings/types.js +4 -0
  94. package/lib/module/providers/animation-settings/types.js.map +1 -0
  95. package/lib/module/providers/forge-design/index.js +5 -0
  96. package/lib/module/providers/forge-design/index.js.map +1 -0
  97. package/lib/module/providers/forge-design/provider.js +66 -0
  98. package/lib/module/providers/forge-design/provider.js.map +1 -0
  99. package/lib/module/providers/forge-design/types.js +4 -0
  100. package/lib/module/providers/forge-design/types.js.map +1 -0
  101. package/lib/module/providers/text-component/index.js +5 -0
  102. package/lib/module/providers/text-component/index.js.map +1 -0
  103. package/lib/module/providers/text-component/provider.js +6 -0
  104. package/lib/module/providers/text-component/provider.js.map +1 -0
  105. package/lib/module/providers/text-component/types.js +4 -0
  106. package/lib/module/providers/text-component/types.js.map +1 -0
  107. package/lib/module/providers/toast/index.js +6 -0
  108. package/lib/module/providers/toast/index.js.map +1 -0
  109. package/lib/module/providers/toast/insets-container.js +156 -0
  110. package/lib/module/providers/toast/insets-container.js.map +1 -0
  111. package/lib/module/providers/toast/lifecycle.context.js +32 -0
  112. package/lib/module/providers/toast/lifecycle.context.js.map +1 -0
  113. package/lib/module/providers/toast/provider.js +503 -0
  114. package/lib/module/providers/toast/provider.js.map +1 -0
  115. package/lib/module/providers/toast/reducer.js +42 -0
  116. package/lib/module/providers/toast/reducer.js.map +1 -0
  117. package/lib/module/providers/toast/toast-config.context.js +25 -0
  118. package/lib/module/providers/toast/toast-config.context.js.map +1 -0
  119. package/lib/module/providers/toast/toast-item-renderer.js +39 -0
  120. package/lib/module/providers/toast/toast-item-renderer.js.map +1 -0
  121. package/lib/module/providers/toast/types.js +4 -0
  122. package/lib/module/providers/toast/types.js.map +1 -0
  123. package/lib/typescript/animation/hooks/index.d.ts +2 -0
  124. package/lib/typescript/animation/hooks/index.d.ts.map +1 -0
  125. package/lib/typescript/animation/hooks/useCombinedAnimationDisabledState.d.ts +22 -0
  126. package/lib/typescript/animation/hooks/useCombinedAnimationDisabledState.d.ts.map +1 -0
  127. package/lib/typescript/animation/index.d.ts +4 -0
  128. package/lib/typescript/animation/index.d.ts.map +1 -0
  129. package/lib/typescript/animation/types.d.ts +105 -0
  130. package/lib/typescript/animation/types.d.ts.map +1 -0
  131. package/lib/typescript/animation/utils.d.ts +120 -0
  132. package/lib/typescript/animation/utils.d.ts.map +1 -0
  133. package/lib/typescript/components/Card/index.d.ts +4 -0
  134. package/lib/typescript/components/Card/index.d.ts.map +1 -1
  135. package/lib/typescript/components/Toast/animation.d.ts +21 -0
  136. package/lib/typescript/components/Toast/animation.d.ts.map +1 -0
  137. package/lib/typescript/components/Toast/hooks.d.ts +17 -0
  138. package/lib/typescript/components/Toast/hooks.d.ts.map +1 -0
  139. package/lib/typescript/components/Toast/index.d.ts +28 -0
  140. package/lib/typescript/components/Toast/index.d.ts.map +1 -0
  141. package/lib/typescript/components/Toast/styles.d.ts +73 -0
  142. package/lib/typescript/components/Toast/styles.d.ts.map +1 -0
  143. package/lib/typescript/components/Toast/types.d.ts +303 -0
  144. package/lib/typescript/components/Toast/types.d.ts.map +1 -0
  145. package/lib/typescript/components/index.d.ts +1 -0
  146. package/lib/typescript/components/index.d.ts.map +1 -1
  147. package/lib/typescript/index.d.ts +2 -0
  148. package/lib/typescript/index.d.ts.map +1 -1
  149. package/lib/typescript/providers/animation-settings/index.d.ts +3 -0
  150. package/lib/typescript/providers/animation-settings/index.d.ts.map +1 -0
  151. package/lib/typescript/providers/animation-settings/provider.d.ts +28 -0
  152. package/lib/typescript/providers/animation-settings/provider.d.ts.map +1 -0
  153. package/lib/typescript/providers/animation-settings/types.d.ts +35 -0
  154. package/lib/typescript/providers/animation-settings/types.d.ts.map +1 -0
  155. package/lib/typescript/providers/forge-design/index.d.ts +3 -0
  156. package/lib/typescript/providers/forge-design/index.d.ts.map +1 -0
  157. package/lib/typescript/providers/forge-design/provider.d.ts +24 -0
  158. package/lib/typescript/providers/forge-design/provider.d.ts.map +1 -0
  159. package/lib/typescript/providers/forge-design/types.d.ts +82 -0
  160. package/lib/typescript/providers/forge-design/types.d.ts.map +1 -0
  161. package/lib/typescript/providers/text-component/index.d.ts +3 -0
  162. package/lib/typescript/providers/text-component/index.d.ts.map +1 -0
  163. package/lib/typescript/providers/text-component/provider.d.ts +7 -0
  164. package/lib/typescript/providers/text-component/provider.d.ts.map +1 -0
  165. package/lib/typescript/providers/text-component/types.d.ts +51 -0
  166. package/lib/typescript/providers/text-component/types.d.ts.map +1 -0
  167. package/lib/typescript/providers/toast/index.d.ts +5 -0
  168. package/lib/typescript/providers/toast/index.d.ts.map +1 -0
  169. package/lib/typescript/providers/toast/insets-container.d.ts +72 -0
  170. package/lib/typescript/providers/toast/insets-container.d.ts.map +1 -0
  171. package/lib/typescript/providers/toast/lifecycle.context.d.ts +32 -0
  172. package/lib/typescript/providers/toast/lifecycle.context.d.ts.map +1 -0
  173. package/lib/typescript/providers/toast/provider.d.ts +32 -0
  174. package/lib/typescript/providers/toast/provider.d.ts.map +1 -0
  175. package/lib/typescript/providers/toast/reducer.d.ts +14 -0
  176. package/lib/typescript/providers/toast/reducer.d.ts.map +1 -0
  177. package/lib/typescript/providers/toast/toast-config.context.d.ts +20 -0
  178. package/lib/typescript/providers/toast/toast-config.context.d.ts.map +1 -0
  179. package/lib/typescript/providers/toast/toast-item-renderer.d.ts +7 -0
  180. package/lib/typescript/providers/toast/toast-item-renderer.d.ts.map +1 -0
  181. package/lib/typescript/providers/toast/types.d.ts +422 -0
  182. package/lib/typescript/providers/toast/types.d.ts.map +1 -0
  183. package/package.json +4 -4
  184. package/src/animation/hooks/index.ts +1 -0
  185. package/src/animation/hooks/useCombinedAnimationDisabledState.ts +46 -0
  186. package/src/animation/index.ts +3 -0
  187. package/src/animation/types.ts +128 -0
  188. package/src/animation/utils.ts +249 -0
  189. package/src/components/CLAUDE.md +1 -1
  190. package/src/components/Card/index.tsx +58 -28
  191. package/src/components/Toast/animation.ts +387 -0
  192. package/src/components/Toast/hooks.ts +92 -0
  193. package/src/components/Toast/index.tsx +520 -0
  194. package/src/components/Toast/styles.ts +186 -0
  195. package/src/components/Toast/types.ts +332 -0
  196. package/src/components/index.ts +1 -0
  197. package/src/index.ts +2 -0
  198. package/src/providers/animation-settings/index.ts +11 -0
  199. package/src/providers/animation-settings/provider.tsx +54 -0
  200. package/src/providers/animation-settings/types.ts +37 -0
  201. package/src/providers/forge-design/index.ts +2 -0
  202. package/src/providers/forge-design/provider.tsx +61 -0
  203. package/src/providers/forge-design/types.ts +84 -0
  204. package/src/providers/text-component/index.ts +2 -0
  205. package/src/providers/text-component/provider.tsx +7 -0
  206. package/src/providers/text-component/types.ts +52 -0
  207. package/src/providers/toast/index.ts +4 -0
  208. package/src/providers/toast/insets-container.tsx +230 -0
  209. package/src/providers/toast/lifecycle.context.tsx +37 -0
  210. package/src/providers/toast/provider.tsx +567 -0
  211. package/src/providers/toast/reducer.ts +40 -0
  212. package/src/providers/toast/toast-config.context.ts +25 -0
  213. package/src/providers/toast/toast-item-renderer.tsx +40 -0
  214. package/src/providers/toast/types.ts +431 -0
@@ -0,0 +1,503 @@
1
+ "use strict";
2
+
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef } from 'react';
4
+ import { Platform, View } from 'react-native';
5
+ import { useSharedValue } from 'react-native-reanimated';
6
+ import { DefaultToast } from '../../components/Toast';
7
+ import { InsetsContainer } from './insets-container';
8
+ import { ToastLifecycleContext } from './lifecycle.context';
9
+ import { toastReducer } from './reducer';
10
+ import { ToastConfigContext } from './toast-config.context';
11
+ import { ToastItemRenderer } from './toast-item-renderer';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ const DEFAULT_DURATION = 4000;
14
+
15
+ /**
16
+ * Context for toast manager
17
+ */
18
+ const ToasterContext = /*#__PURE__*/createContext(null);
19
+
20
+ /**
21
+ * Merges global config with local config, ensuring local config takes precedence
22
+ * Only includes defined values from localConfig to avoid overriding global config with undefined
23
+ */
24
+ function mergeToastConfig(globalConfig, localConfig) {
25
+ const result = {
26
+ ...globalConfig
27
+ };
28
+
29
+ // Only override with defined values from localConfig
30
+ if (localConfig.color !== undefined) {
31
+ result.color = localConfig.color;
32
+ }
33
+ if (localConfig.placement !== undefined) {
34
+ result.placement = localConfig.placement;
35
+ }
36
+ if (localConfig.isSwipeable !== undefined) {
37
+ result.isSwipeable = localConfig.isSwipeable;
38
+ }
39
+ if (localConfig.animation !== undefined) {
40
+ result.animation = localConfig.animation;
41
+ }
42
+ return result;
43
+ }
44
+
45
+ /**
46
+ * Creates a component function for simple string toast
47
+ */
48
+ function createStringToastComponent(label, globalConfig) {
49
+ return props => {
50
+ const mergedConfig = mergeToastConfig(globalConfig, {
51
+ color: 'default'
52
+ });
53
+ return /*#__PURE__*/_jsx(DefaultToast, {
54
+ ...props,
55
+ label: label,
56
+ color: mergedConfig.color,
57
+ placement: mergedConfig.placement,
58
+ isSwipeable: mergedConfig.isSwipeable,
59
+ animation: mergedConfig.animation
60
+ });
61
+ };
62
+ }
63
+
64
+ /**
65
+ * Creates a component function for config-based toast
66
+ */
67
+ function createConfigToastComponent(config, globalConfig) {
68
+ return props => {
69
+ const mergedConfig = mergeToastConfig(globalConfig, {
70
+ color: config.color,
71
+ placement: config.placement,
72
+ isSwipeable: config.isSwipeable,
73
+ animation: config.animation
74
+ });
75
+ return /*#__PURE__*/_jsx(DefaultToast, {
76
+ ...props,
77
+ color: mergedConfig.color,
78
+ placement: mergedConfig.placement,
79
+ isSwipeable: mergedConfig.isSwipeable,
80
+ animation: mergedConfig.animation,
81
+ label: config.label,
82
+ description: config.description,
83
+ actionLabel: config.actionLabel,
84
+ onActionPress: config.onActionPress,
85
+ icon: config.icon
86
+ });
87
+ };
88
+ }
89
+
90
+ /**
91
+ * Toast provider component
92
+ * Wraps your app to enable toast functionality
93
+ */
94
+ export function ToastProvider({
95
+ defaultProps,
96
+ insets,
97
+ maxVisibleToasts = 3,
98
+ contentWrapper,
99
+ children,
100
+ disableFullWindowOverlay = false,
101
+ unstable_accessibilityContainerViewIsModal,
102
+ announceLabel
103
+ }) {
104
+ const [toasts, dispatch] = useReducer(toastReducer, []);
105
+
106
+ /**
107
+ * Memoize global config to prevent unnecessary re-renders
108
+ */
109
+ const globalConfig = useMemo(() => defaultProps, [defaultProps]);
110
+ const isToastVisible = toasts.length > 0;
111
+ const heights = useSharedValue({});
112
+ const total = useSharedValue(0);
113
+
114
+ /**
115
+ * Derive total from toasts.length so the animated opacity/scale/translateY
116
+ * interpolations always use the real count. Manual increment/decrement
117
+ * was prone to drift when hide + show ran in the same tick or when
118
+ * auto-dismiss raced with a manual hide (stale-closure mismatch).
119
+ */
120
+ useEffect(() => {
121
+ total.set(toasts.length);
122
+ }, [toasts.length, total]);
123
+ const idCounter = useRef(0);
124
+
125
+ /**
126
+ * Timer state per toast — tracks remaining time so pause/resume can
127
+ * restart with only the leftover duration (WCAG 2.2.1).
128
+ */
129
+ const timersRef = useRef(new Map());
130
+ const pausedRef = useRef(false);
131
+ const hideRef = useRef(null);
132
+
133
+ /**
134
+ * Safety reset: when all toasts are gone the InsetsContainer unmounts and
135
+ * no resume event can fire. Clear the paused flag and any orphaned timer
136
+ * entries so the next toast's timer starts normally.
137
+ */
138
+ useEffect(() => {
139
+ if (toasts.length === 0) {
140
+ pausedRef.current = false;
141
+ timersRef.current.forEach(entry => {
142
+ if (entry.timer) clearTimeout(entry.timer);
143
+ });
144
+ timersRef.current.clear();
145
+ }
146
+ }, [toasts.length]);
147
+
148
+ /**
149
+ * Remove one or more toasts from the array. On web this is the second half
150
+ * of the two-phase hide flow — the toast component calls it from
151
+ * `onTransitionEnd` (or a safety timeout) after the exit transition plays.
152
+ * Also cleans up per-id height state.
153
+ */
154
+ const remove = useCallback(ids => {
155
+ const idsArray = Array.isArray(ids) ? ids : [ids];
156
+ if (idsArray.length === 0) return;
157
+ dispatch({
158
+ type: 'REMOVE',
159
+ payload: {
160
+ ids: idsArray
161
+ }
162
+ });
163
+ heights.modify(value => {
164
+ 'worklet';
165
+
166
+ const result = {
167
+ ...value
168
+ };
169
+ for (const id of idsArray) {
170
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
171
+ delete result[id];
172
+ }
173
+ return result;
174
+ });
175
+ }, [heights]);
176
+
177
+ /**
178
+ * Hide one or more toasts
179
+ * - No argument: hides the last toast in the array
180
+ * - "all": hides all toasts
181
+ * - Single ID: hides that toast
182
+ * - Array of IDs: hides those toasts
183
+ *
184
+ * On web this only marks toasts as `pendingRemoval` so their CSS exit
185
+ * transition can play; the actual removal happens when the toast
186
+ * component calls `remove(id)` on transition end.
187
+ * On native this dispatches removal directly — Reanimated's `exiting`
188
+ * layout animation plays before unmount.
189
+ */
190
+ const hide = useCallback(ids => {
191
+ const isWeb = Platform.OS === 'web';
192
+ if (ids === undefined) {
193
+ if (toasts.length === 0) return;
194
+ // Hide the last non-pending toast in the array. Using the last
195
+ // pending toast would be a no-op on web.
196
+ let lastToast = null;
197
+ for (let i = toasts.length - 1; i >= 0; i--) {
198
+ const candidate = toasts[i];
199
+ if (!candidate.pendingRemoval) {
200
+ lastToast = candidate;
201
+ break;
202
+ }
203
+ }
204
+ if (!lastToast) return;
205
+ const timerEntry = timersRef.current.get(lastToast.id);
206
+ if (timerEntry?.timer) {
207
+ clearTimeout(timerEntry.timer);
208
+ }
209
+ timersRef.current.delete(lastToast.id);
210
+ if (lastToast.onHide) {
211
+ lastToast.onHide();
212
+ }
213
+ if (isWeb) {
214
+ dispatch({
215
+ type: 'MARK_CLOSED',
216
+ payload: {
217
+ ids: [lastToast.id]
218
+ }
219
+ });
220
+ } else {
221
+ remove([lastToast.id]);
222
+ }
223
+ } else if (ids === 'all') {
224
+ timersRef.current.forEach(entry => {
225
+ if (entry.timer) clearTimeout(entry.timer);
226
+ });
227
+ timersRef.current.clear();
228
+ const targetIds = [];
229
+ toasts.forEach(toast => {
230
+ if (toast.pendingRemoval) return;
231
+ targetIds.push(toast.id);
232
+ if (toast.onHide) {
233
+ toast.onHide();
234
+ }
235
+ });
236
+ if (targetIds.length === 0) return;
237
+ if (isWeb) {
238
+ dispatch({
239
+ type: 'MARK_CLOSED',
240
+ payload: {
241
+ ids: targetIds
242
+ }
243
+ });
244
+ } else {
245
+ remove(targetIds);
246
+ }
247
+ } else {
248
+ const idsArray = Array.isArray(ids) ? ids : [ids];
249
+ const targetIds = [];
250
+ idsArray.forEach(id => {
251
+ const toast = toasts.find(t => t.id === id);
252
+ if (!toast || toast.pendingRemoval) return;
253
+ const timerEntry = timersRef.current.get(id);
254
+ if (timerEntry?.timer) {
255
+ clearTimeout(timerEntry.timer);
256
+ }
257
+ timersRef.current.delete(id);
258
+ targetIds.push(id);
259
+ if (toast.onHide) {
260
+ toast.onHide();
261
+ }
262
+ });
263
+ if (targetIds.length === 0) return;
264
+ if (isWeb) {
265
+ dispatch({
266
+ type: 'MARK_CLOSED',
267
+ payload: {
268
+ ids: targetIds
269
+ }
270
+ });
271
+ } else {
272
+ remove(targetIds);
273
+ }
274
+ }
275
+ }, [remove, toasts]);
276
+
277
+ // Keep hide ref up to date
278
+ hideRef.current = hide;
279
+
280
+ /**
281
+ * Pause all running auto-dismiss timers (WCAG 2.2.1).
282
+ * Stores elapsed time so resumeAll can restart with the remainder.
283
+ */
284
+ const pauseAll = useCallback(() => {
285
+ if (pausedRef.current) return;
286
+ pausedRef.current = true;
287
+ const now = Date.now();
288
+ timersRef.current.forEach(entry => {
289
+ if (entry.timer) {
290
+ clearTimeout(entry.timer);
291
+ entry.timer = null;
292
+ }
293
+ const elapsed = now - entry.startedAt;
294
+ entry.remaining = Math.max(0, entry.remaining - elapsed);
295
+ });
296
+ }, []);
297
+
298
+ /**
299
+ * Resume all paused auto-dismiss timers with their remaining duration.
300
+ */
301
+ const resumeAll = useCallback(() => {
302
+ pausedRef.current = false;
303
+ const now = Date.now();
304
+ timersRef.current.forEach((entry, id) => {
305
+ if (entry.timer) return;
306
+ if (entry.remaining <= 0) {
307
+ if (hideRef.current) hideRef.current(id);
308
+ timersRef.current.delete(id);
309
+ return;
310
+ }
311
+ entry.startedAt = now;
312
+ entry.timer = setTimeout(() => {
313
+ if (hideRef.current) hideRef.current(id);
314
+ timersRef.current.delete(id);
315
+ }, entry.remaining);
316
+ });
317
+ }, []);
318
+ const lifecycleContextValue = useMemo(() => {
319
+ const pending = new Set();
320
+ let frontmostId = null;
321
+ for (const toast of toasts) {
322
+ if (toast.pendingRemoval) {
323
+ pending.add(toast.id);
324
+ } else {
325
+ frontmostId = toast.id;
326
+ }
327
+ }
328
+ return {
329
+ remove: id => remove([id]),
330
+ pendingRemovalIds: pending,
331
+ frontmostId
332
+ };
333
+ }, [remove, toasts]);
334
+
335
+ /**
336
+ * Show a toast
337
+ * Supports three usage patterns:
338
+ * 1. Simple string: toast.show('This is toast')
339
+ * 2. Config object: toast.show({ label, color, ... })
340
+ * 3. Custom component: toast.show({ component: (props) => <Toast>...</Toast> })
341
+ */
342
+ const show = useCallback(options => {
343
+ let normalizedOptions;
344
+ let duration = DEFAULT_DURATION; // Default duration
345
+ let explicitId;
346
+
347
+ // Case 1: Simple string
348
+ if (typeof options === 'string') {
349
+ normalizedOptions = {
350
+ id: undefined,
351
+ component: createStringToastComponent(options, globalConfig),
352
+ duration: DEFAULT_DURATION
353
+ };
354
+ duration = DEFAULT_DURATION;
355
+ explicitId = undefined;
356
+ }
357
+ // Case 2: Config object without component
358
+ else if (!('component' in options) || options.component === undefined) {
359
+ const config = options;
360
+ duration = config.duration ?? DEFAULT_DURATION;
361
+ explicitId = config.id;
362
+ normalizedOptions = {
363
+ id: config.id,
364
+ component: createConfigToastComponent(config, globalConfig),
365
+ duration,
366
+ onShow: config.onShow,
367
+ onHide: config.onHide
368
+ };
369
+ }
370
+ // Case 3: Config object with component (existing behavior)
371
+ else {
372
+ normalizedOptions = options;
373
+ duration = normalizedOptions.duration ?? DEFAULT_DURATION;
374
+ explicitId = normalizedOptions.id;
375
+ }
376
+ const id = normalizedOptions.id ?? `toast-${String(Date.now())}-${String(idCounter.current++)}`;
377
+
378
+ // If an explicit ID was provided, check if a toast with that ID already exists
379
+ // If it exists, skip adding a new toast and return the existing ID
380
+ if (explicitId !== undefined) {
381
+ const existingToast = toasts.find(toast => toast.id === explicitId);
382
+ if (existingToast) {
383
+ return existingToast.id;
384
+ }
385
+ }
386
+ dispatch({
387
+ type: 'SHOW',
388
+ payload: {
389
+ id,
390
+ component: normalizedOptions.component,
391
+ duration,
392
+ onShow: normalizedOptions.onShow,
393
+ onHide: normalizedOptions.onHide
394
+ }
395
+ });
396
+ if (normalizedOptions.onShow) {
397
+ normalizedOptions.onShow();
398
+ }
399
+
400
+ // Set up auto-dismiss timeout synchronously
401
+ if (duration !== 'persistent' && typeof duration === 'number' && !Number.isNaN(duration) && duration >= 0 && duration !== Infinity) {
402
+ // Handle immediate dismissal
403
+ if (duration === 0) {
404
+ if (hideRef.current) {
405
+ hideRef.current(id);
406
+ }
407
+ } else {
408
+ const now = Date.now();
409
+ const timer = setTimeout(() => {
410
+ if (hideRef.current) {
411
+ hideRef.current(id);
412
+ }
413
+ timersRef.current.delete(id);
414
+ }, duration);
415
+ const entry = {
416
+ startedAt: now,
417
+ remaining: duration,
418
+ timer: timer,
419
+ duration
420
+ };
421
+ timersRef.current.set(id, entry);
422
+ if (pausedRef.current) {
423
+ clearTimeout(timer);
424
+ entry.timer = null;
425
+ }
426
+ }
427
+ }
428
+ return id;
429
+ }, [toasts, globalConfig]);
430
+ const contextValue = useMemo(() => ({
431
+ toast: {
432
+ show,
433
+ hide,
434
+ pauseAll,
435
+ resumeAll
436
+ },
437
+ isToastVisible
438
+ }), [show, hide, pauseAll, resumeAll, isToastVisible]);
439
+ return /*#__PURE__*/_jsx(ToastConfigContext.Provider, {
440
+ value: globalConfig,
441
+ children: /*#__PURE__*/_jsx(ToasterContext.Provider, {
442
+ value: contextValue,
443
+ children: /*#__PURE__*/_jsxs(ToastLifecycleContext.Provider, {
444
+ value: lifecycleContextValue,
445
+ children: [children, toasts.length > 0 && /*#__PURE__*/_jsx(InsetsContainer, {
446
+ insets: insets,
447
+ announceLabel: announceLabel,
448
+ contentWrapper: contentWrapper,
449
+ disableFullWindowOverlay: disableFullWindowOverlay,
450
+ unstable_accessibilityContainerViewIsModal: unstable_accessibilityContainerViewIsModal,
451
+ pauseAll: pauseAll,
452
+ resumeAll: resumeAll,
453
+ hide: hide,
454
+ children: /*#__PURE__*/_jsx(View, {
455
+ className: "flex-1",
456
+ children: toasts.map((toastItem, index) => /*#__PURE__*/_jsx(ToastItemRenderer, {
457
+ toastItem: toastItem,
458
+ show: show,
459
+ hide: hide,
460
+ index: index,
461
+ total: total,
462
+ heights: heights,
463
+ maxVisibleToasts: maxVisibleToasts
464
+ }, toastItem.id))
465
+ })
466
+ })]
467
+ })
468
+ })
469
+ });
470
+ }
471
+
472
+ /**
473
+ * Hook to access toast functionality
474
+ *
475
+ * @returns Object containing toast manager and visibility state
476
+ *
477
+ * @example
478
+ * ```tsx
479
+ * const { toast, isToastVisible } = useToast();
480
+ *
481
+ * // Show a toast
482
+ * toast.show({ component: <Toast>Hello</Toast> });
483
+ *
484
+ * // Hide a toast
485
+ * toast.hide('my-toast');
486
+ *
487
+ * // Check if any toast is visible
488
+ * if (isToastVisible) {
489
+ * console.log('A toast is currently displayed');
490
+ * }
491
+ * ```
492
+ */
493
+ export function useToast() {
494
+ const context = useContext(ToasterContext);
495
+ if (!context) {
496
+ throw new Error('useToast must be used within a ToastProvider provider');
497
+ }
498
+ return {
499
+ toast: context.toast,
500
+ isToastVisible: context.isToastVisible
501
+ };
502
+ }
503
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useCallback","useContext","useEffect","useMemo","useReducer","useRef","Platform","View","useSharedValue","DefaultToast","InsetsContainer","ToastLifecycleContext","toastReducer","ToastConfigContext","ToastItemRenderer","jsx","_jsx","jsxs","_jsxs","DEFAULT_DURATION","ToasterContext","mergeToastConfig","globalConfig","localConfig","result","color","undefined","placement","isSwipeable","animation","createStringToastComponent","label","props","mergedConfig","createConfigToastComponent","config","description","actionLabel","onActionPress","icon","ToastProvider","defaultProps","insets","maxVisibleToasts","contentWrapper","children","disableFullWindowOverlay","unstable_accessibilityContainerViewIsModal","announceLabel","toasts","dispatch","isToastVisible","length","heights","total","set","idCounter","timersRef","Map","pausedRef","hideRef","current","forEach","entry","timer","clearTimeout","clear","remove","ids","idsArray","Array","isArray","type","payload","modify","value","id","hide","isWeb","OS","lastToast","i","candidate","pendingRemoval","timerEntry","get","delete","onHide","targetIds","toast","push","find","t","pauseAll","now","Date","elapsed","startedAt","remaining","Math","max","resumeAll","setTimeout","lifecycleContextValue","pending","Set","frontmostId","add","pendingRemovalIds","show","options","normalizedOptions","duration","explicitId","component","onShow","String","existingToast","Number","isNaN","Infinity","contextValue","Provider","className","map","toastItem","index","useToast","context","Error"],"sourceRoot":"../../../../src","sources":["providers/toast/provider.tsx"],"mappings":";;AAAA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,UAAU,EACVC,MAAM,QACD,OAAO;AACd,SAASC,QAAQ,EAAEC,IAAI,QAAQ,cAAc;AAC7C,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,qBAAqB,QAAyC,qBAAqB;AAC5F,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,SAASC,iBAAiB,QAAQ,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAW1D,MAAMC,gBAAgB,GAAG,IAAI;;AAE7B;AACA;AACA;AACA,MAAMC,cAAc,gBAAGrB,aAAa,CAA6B,IAAI,CAAC;;AAEtE;AACA;AACA;AACA;AACA,SAASsB,gBAAgBA,CACvBC,YAA2C,EAC3CC,WAAuC,EACX;EAC5B,MAAMC,MAAkC,GAAG;IAAE,GAAGF;EAAa,CAAC;;EAE9D;EACA,IAAIC,WAAW,CAACE,KAAK,KAAKC,SAAS,EAAE;IACnCF,MAAM,CAACC,KAAK,GAAGF,WAAW,CAACE,KAAK;EAClC;EACA,IAAIF,WAAW,CAACI,SAAS,KAAKD,SAAS,EAAE;IACvCF,MAAM,CAACG,SAAS,GAAGJ,WAAW,CAACI,SAAS;EAC1C;EACA,IAAIJ,WAAW,CAACK,WAAW,KAAKF,SAAS,EAAE;IACzCF,MAAM,CAACI,WAAW,GAAGL,WAAW,CAACK,WAAW;EAC9C;EACA,IAAIL,WAAW,CAACM,SAAS,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E;QAAC,CACQ,CAClB;MAAA,CAC6B;IAAC,CACV;EAAC,CACC,CAAC;AAElC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmD,QAAQA,CAAA,EAAG;EACzB,MAAMC,OAAO,GAAG/H,UAAU,CAACmB,cAAc,CAAC;EAE1C,IAAI,CAAC4G,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,uDAAuD,CAAC;EAC1E;EAEA,OAAO;IACLxC,KAAK,EAAEuC,OAAO,CAACvC,KAAK;IACpBtC,cAAc,EAAE6E,OAAO,CAAC7E;EAC1B,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Reducer for managing toast state
5
+ *
6
+ * Removal is a two-phase flow so web can play its CSS exit transition
7
+ * before the DOM node is unmounted:
8
+ * `MARK_CLOSED` → flips `pendingRemoval: true` (node stays mounted).
9
+ * `REMOVE` → filters the toast out of the array (node unmounts).
10
+ *
11
+ * Native dispatches `REMOVE` directly since Reanimated's `exiting`
12
+ * layout animation plays before unmount without a lingering state.
13
+ */
14
+ export function toastReducer(state, action) {
15
+ switch (action.type) {
16
+ case 'SHOW':
17
+ {
18
+ const filtered = state.filter(toast => toast.id !== action.payload.id);
19
+ return [...filtered, action.payload];
20
+ }
21
+ case 'MARK_CLOSED':
22
+ {
23
+ const idsSet = new Set(action.payload.ids);
24
+ // Early out preserves the array reference when nothing would change,
25
+ // which keeps `useMemo(..., [toasts])` consumers stable.
26
+ const hasChange = state.some(toast => idsSet.has(toast.id) && !toast.pendingRemoval);
27
+ if (!hasChange) return state;
28
+ return state.map(toast => idsSet.has(toast.id) && !toast.pendingRemoval ? {
29
+ ...toast,
30
+ pendingRemoval: true
31
+ } : toast);
32
+ }
33
+ case 'REMOVE':
34
+ {
35
+ const idsSet = new Set(action.payload.ids);
36
+ return state.filter(toast => !idsSet.has(toast.id));
37
+ }
38
+ default:
39
+ return state;
40
+ }
41
+ }
42
+ //# sourceMappingURL=reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toastReducer","state","action","type","filtered","filter","toast","id","payload","idsSet","Set","ids","hasChange","some","has","pendingRemoval","map"],"sourceRoot":"../../../../src","sources":["providers/toast/reducer.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAACC,KAAkB,EAAEC,MAAmB,EAAe;EACjF,QAAQA,MAAM,CAACC,IAAI;IACjB,KAAK,MAAM;MAAE;QACX,MAAMC,QAAQ,GAAGH,KAAK,CAACI,MAAM,CAAEC,KAAK,IAAKA,KAAK,CAACC,EAAE,KAAKL,MAAM,CAACM,OAAO,CAACD,EAAE,CAAC;QACxE,OAAO,CAAC,GAAGH,QAAQ,EAAEF,MAAM,CAACM,OAAO,CAAC;MACtC;IAEA,KAAK,aAAa;MAAE;QAClB,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAACR,MAAM,CAACM,OAAO,CAACG,GAAG,CAAC;QAC1C;QACA;QACA,MAAMC,SAAS,GAAGX,KAAK,CAACY,IAAI,CAAEP,KAAK,IAAKG,MAAM,CAACK,GAAG,CAACR,KAAK,CAACC,EAAE,CAAC,IAAI,CAACD,KAAK,CAACS,cAAc,CAAC;QACtF,IAAI,CAACH,SAAS,EAAE,OAAOX,KAAK;QAC5B,OAAOA,KAAK,CAACe,GAAG,CAAEV,KAAK,IACrBG,MAAM,CAACK,GAAG,CAACR,KAAK,CAACC,EAAE,CAAC,IAAI,CAACD,KAAK,CAACS,cAAc,GAAG;UAAE,GAAGT,KAAK;UAAES,cAAc,EAAE;QAAK,CAAC,GAAGT,KACvF,CAAC;MACH;IAEA,KAAK,QAAQ;MAAE;QACb,MAAMG,MAAM,GAAG,IAAIC,GAAG,CAACR,MAAM,CAACM,OAAO,CAACG,GAAG,CAAC;QAC1C,OAAOV,KAAK,CAACI,MAAM,CAAEC,KAAK,IAAK,CAACG,MAAM,CAACK,GAAG,CAACR,KAAK,CAACC,EAAE,CAAC,CAAC;MACvD;IAEA;MACE,OAAON,KAAK;EAChB;AACF","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ import { createContext, useContext } from 'react';
4
+ /**
5
+ * Context for global toast configuration
6
+ * Extracted to separate file to avoid circular dependencies with toast component
7
+ */
8
+ const ToastConfigContext = /*#__PURE__*/createContext(undefined);
9
+
10
+ /**
11
+ * Hook to access global toast configuration
12
+ *
13
+ * @returns Global toast configuration or undefined if not set
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const globalConfig = useToastConfig();
18
+ * // Use globalConfig.color, globalConfig.placement, etc.
19
+ * ```
20
+ */
21
+ export function useToastConfig() {
22
+ return useContext(ToastConfigContext);
23
+ }
24
+ export { ToastConfigContext };
25
+ //# sourceMappingURL=toast-config.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useContext","ToastConfigContext","undefined","useToastConfig"],"sourceRoot":"../../../../src","sources":["providers/toast/toast-config.context.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAGjD;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,gBAAGF,aAAa,CAAgCG,SAAS,CAAC;;AAElF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAA,EAAkC;EAC9D,OAAOH,UAAU,CAACC,kBAAkB,CAAC;AACvC;AAEA,SAASA,kBAAkB","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ import { memo } from 'react';
4
+ /**
5
+ * Memoized toast item component to prevent unnecessary re-renders
6
+ * Only re-renders when the toast item itself changes
7
+ */
8
+ export const ToastItemRenderer = /*#__PURE__*/memo(({
9
+ toastItem,
10
+ show,
11
+ hide,
12
+ index,
13
+ total,
14
+ heights,
15
+ maxVisibleToasts
16
+ }) => {
17
+ if (typeof toastItem.component !== 'function') {
18
+ throw new Error('Toast component must be a function that receives ToastComponentProps');
19
+ }
20
+ const content = toastItem.component({
21
+ id: toastItem.id,
22
+ index,
23
+ total,
24
+ heights,
25
+ maxVisibleToasts,
26
+ show,
27
+ hide
28
+ });
29
+ return content;
30
+ }, (prevProps, nextProps) => {
31
+ // Only re-render if the toast ID, component reference, index, or
32
+ // pending-removal flag changed. `pendingRemoval` flips when the
33
+ // provider marks a toast closed on web so the Toast component can
34
+ // play its exit transition — the renderer must propagate that
35
+ // change even though the id and component reference are unchanged.
36
+ // show, hide, total, and heights are stable references.
37
+ return prevProps.toastItem.id === nextProps.toastItem.id && prevProps.toastItem.component === nextProps.toastItem.component && prevProps.toastItem.pendingRemoval === nextProps.toastItem.pendingRemoval && prevProps.index === nextProps.index;
38
+ });
39
+ //# sourceMappingURL=toast-item-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["memo","ToastItemRenderer","toastItem","show","hide","index","total","heights","maxVisibleToasts","component","Error","content","id","prevProps","nextProps","pendingRemoval"],"sourceRoot":"../../../../src","sources":["providers/toast/toast-item-renderer.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,OAAO;AAG5B;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,gBAAGD,IAAI,CACnC,CAAC;EAAEE,SAAS;EAAEC,IAAI;EAAEC,IAAI;EAAEC,KAAK;EAAEC,KAAK;EAAEC,OAAO;EAAEC;AAAyC,CAAC,KAAK;EAC9F,IAAI,OAAON,SAAS,CAACO,SAAS,KAAK,UAAU,EAAE;IAC7C,MAAM,IAAIC,KAAK,CAAC,sEAAsE,CAAC;EACzF;EAEA,MAAMC,OAAO,GAAGT,SAAS,CAACO,SAAS,CAAC;IAClCG,EAAE,EAAEV,SAAS,CAACU,EAAE;IAChBP,KAAK;IACLC,KAAK;IACLC,OAAO;IACPC,gBAAgB;IAChBL,IAAI;IACJC;EACF,CAAC,CAAC;EAEF,OAAOO,OAAO;AAChB,CAAC,EACD,CAACE,SAAS,EAAEC,SAAS,KAAK;EACxB;EACA;EACA;EACA;EACA;EACA;EACA,OACED,SAAS,CAACX,SAAS,CAACU,EAAE,KAAKE,SAAS,CAACZ,SAAS,CAACU,EAAE,IACjDC,SAAS,CAACX,SAAS,CAACO,SAAS,KAAKK,SAAS,CAACZ,SAAS,CAACO,SAAS,IAC/DI,SAAS,CAACX,SAAS,CAACa,cAAc,KAAKD,SAAS,CAACZ,SAAS,CAACa,cAAc,IACzEF,SAAS,CAACR,KAAK,KAAKS,SAAS,CAACT,KAAK;AAEvC,CACF,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["providers/toast/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from './useCombinedAnimationDisabledState';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/animation/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC"}