@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,230 @@
1
+ import type { ReactNode } from 'react';
2
+ import { useCallback, useEffect, useMemo, useRef } from 'react';
3
+ import { Platform, View } from 'react-native';
4
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
+ import { FullWindowOverlay } from '@cdx-ui/primitives';
6
+ import type { ToastInsets } from './types';
7
+
8
+ interface InsetsContainerProps {
9
+ /**
10
+ * When true, uses a regular View instead of FullWindowOverlay on iOS.
11
+ * Enables element inspector but toasts won't appear above native modals.
12
+ * @default false
13
+ */
14
+ disableFullWindowOverlay: boolean;
15
+ /**
16
+ * Controls whether VoiceOver treats the overlay window as a modal container.
17
+ * When `false`, VoiceOver can still access elements behind the overlay.
18
+ * When `true`, VoiceOver is restricted to elements inside the overlay.
19
+ * @default false
20
+ * @platform ios
21
+ * @unstable This prop maps directly to the native `accessibilityViewIsModal`
22
+ * on the container view and may change in a future react-native-screens release.
23
+ */
24
+ unstable_accessibilityContainerViewIsModal?: boolean;
25
+ /**
26
+ * Optional inset values for all edges
27
+ * If not provided, defaults to platform-specific values:
28
+ * - iOS: safe area insets + 0px (top), + 6px (bottom), + 12px (left/right)
29
+ * - Android: safe area insets + 12px (all edges)
30
+ */
31
+ insets?: ToastInsets;
32
+ /**
33
+ * Accessible label for the toast notification region on web.
34
+ * @default 'Notifications'
35
+ * @platform web
36
+ */
37
+ announceLabel?: string;
38
+ /**
39
+ * Custom wrapper function to wrap the toast content
40
+ * Receives children and should return a component that wraps them
41
+ * The wrapper should apply flex: 1 (via className or style) to ensure proper layout
42
+ * Can be any component wrapper - KeyboardAvoidingView, View, or any custom component
43
+ */
44
+ contentWrapper?: (children: ReactNode) => React.ReactElement;
45
+ /**
46
+ * Pause all auto-dismiss timers (WCAG 2.2.1).
47
+ */
48
+ pauseAll: () => void;
49
+ /**
50
+ * Resume all auto-dismiss timers.
51
+ */
52
+ resumeAll: () => void;
53
+ /**
54
+ * Hide the front-most toast. Used by the Escape key handler on web.
55
+ */
56
+ hide: () => void;
57
+ /**
58
+ * Children to render inside the container
59
+ */
60
+ children: ReactNode;
61
+ }
62
+
63
+ /**
64
+ * Container component that applies inset padding to position toasts
65
+ * away from screen edges and safe areas
66
+ *
67
+ * Combines custom insets with safe area insets:
68
+ * - If custom inset is provided, it overrides safe area + default padding
69
+ * - If not provided, uses platform-specific defaults:
70
+ * - iOS: safe area inset + 0px for top, + 6px for bottom, + 12px for left/right
71
+ * - Android: safe area inset + 12px for all edges
72
+ *
73
+ * On web, wires pointer/focus/visibility listeners to pause/resume timers
74
+ * per WCAG 2.2.1 (keyboard/pointer/hidden-tab pausing).
75
+ */
76
+ export function InsetsContainer({
77
+ insets,
78
+ announceLabel = 'Notifications',
79
+ contentWrapper,
80
+ children,
81
+ disableFullWindowOverlay,
82
+ unstable_accessibilityContainerViewIsModal,
83
+ pauseAll,
84
+ resumeAll,
85
+ hide,
86
+ }: Readonly<InsetsContainerProps>) {
87
+ const safeAreaInsets = useSafeAreaInsets();
88
+
89
+ const finalInsets = useMemo(() => {
90
+ return {
91
+ top: insets?.top ?? safeAreaInsets.top + (Platform.OS === 'ios' ? 0 : 12),
92
+ bottom: insets?.bottom ?? safeAreaInsets.bottom + (Platform.OS === 'ios' ? 6 : 12),
93
+ left: insets?.left ?? safeAreaInsets.left + 12,
94
+ right: insets?.right ?? safeAreaInsets.right + 12,
95
+ };
96
+ }, [safeAreaInsets, insets]);
97
+
98
+ // Track pause sources independently so overlapping pointer + focus
99
+ // don't accidentally resume while the other source is still active.
100
+ const pauseSourcesRef = useRef<Set<string>>(new Set());
101
+ const pauseAllRef = useRef(pauseAll);
102
+ const resumeAllRef = useRef(resumeAll);
103
+ pauseAllRef.current = pauseAll;
104
+ resumeAllRef.current = resumeAll;
105
+
106
+ const addPauseSource = useCallback((source: string) => {
107
+ const wasEmpty = pauseSourcesRef.current.size === 0;
108
+ pauseSourcesRef.current.add(source);
109
+ if (wasEmpty) pauseAllRef.current();
110
+ }, []);
111
+
112
+ const removePauseSource = useCallback((source: string) => {
113
+ pauseSourcesRef.current.delete(source);
114
+ if (pauseSourcesRef.current.size === 0) resumeAllRef.current();
115
+ }, []);
116
+
117
+ // Ref for the container so we can attach native DOM listeners on web.
118
+ const containerRef = useRef<View | null>(null);
119
+ const hideRef = useRef(hide);
120
+ hideRef.current = hide;
121
+
122
+ // Web-only: attach pointer, focus, visibility, and keyboard listeners
123
+ // via native DOM APIs to avoid RNW making the container focusable
124
+ // (RNW adds tabIndex when React onFocus/onBlur handlers are present).
125
+ useEffect(() => {
126
+ if (Platform.OS !== 'web') return;
127
+
128
+ const node = containerRef.current as unknown as HTMLElement | null;
129
+ const sources = pauseSourcesRef.current;
130
+
131
+ const handleVisibilityChange = () => {
132
+ if (document.hidden) {
133
+ addPauseSource('visibility');
134
+ } else {
135
+ removePauseSource('visibility');
136
+ }
137
+ };
138
+
139
+ // The container is `absolute inset-0` (full viewport). Using
140
+ // pointerenter/pointerleave here would pause as soon as the cursor
141
+ // is anywhere on the page — far too aggressive. Instead use
142
+ // pointerover/pointerout (which bubble) and gate on whether the
143
+ // pointer is actually over a toast element (identified by the
144
+ // `data-state` attribute emitted on every toast wrapper).
145
+ const isInsideToast = (el: EventTarget | null): boolean => {
146
+ if (!el || !(el instanceof HTMLElement)) return false;
147
+ return !!el.closest('[data-state]');
148
+ };
149
+
150
+ const handlePointerOver = (e: PointerEvent) => {
151
+ if (isInsideToast(e.target)) addPauseSource('pointer');
152
+ };
153
+ const handlePointerOut = (e: PointerEvent) => {
154
+ if (!isInsideToast(e.relatedTarget)) removePauseSource('pointer');
155
+ };
156
+
157
+ const handleFocusIn = (e: FocusEvent) => {
158
+ if (isInsideToast(e.target)) addPauseSource('focus');
159
+ };
160
+ const handleFocusOut = (e: FocusEvent) => {
161
+ if (!isInsideToast(e.relatedTarget)) removePauseSource('focus');
162
+ };
163
+
164
+ const handleKeyDown = (event: KeyboardEvent) => {
165
+ if (event.key === 'Escape') {
166
+ event.stopPropagation();
167
+ hideRef.current();
168
+ }
169
+ };
170
+
171
+ document.addEventListener('visibilitychange', handleVisibilityChange);
172
+
173
+ if (node && typeof node.addEventListener === 'function') {
174
+ node.addEventListener('pointerover', handlePointerOver);
175
+ node.addEventListener('pointerout', handlePointerOut);
176
+ node.addEventListener('focusin', handleFocusIn);
177
+ node.addEventListener('focusout', handleFocusOut);
178
+ node.addEventListener('keydown', handleKeyDown);
179
+ }
180
+
181
+ return () => {
182
+ document.removeEventListener('visibilitychange', handleVisibilityChange);
183
+ if (node && typeof node.removeEventListener === 'function') {
184
+ node.removeEventListener('pointerover', handlePointerOver);
185
+ node.removeEventListener('pointerout', handlePointerOut);
186
+ node.removeEventListener('focusin', handleFocusIn);
187
+ node.removeEventListener('focusout', handleFocusOut);
188
+ node.removeEventListener('keydown', handleKeyDown);
189
+ }
190
+ if (sources.size > 0) {
191
+ sources.clear();
192
+ resumeAllRef.current();
193
+ }
194
+ };
195
+ }, [addPauseSource, removePauseSource]);
196
+
197
+ const content = (
198
+ <View
199
+ ref={containerRef}
200
+ className="absolute inset-0 pointer-events-box-none"
201
+ role="region"
202
+ aria-label={announceLabel}
203
+ {...(Platform.OS === 'web' && {
204
+ 'aria-live': 'polite',
205
+ 'aria-atomic': false,
206
+ })}
207
+ style={{
208
+ paddingTop: finalInsets.top,
209
+ paddingBottom: finalInsets.bottom,
210
+ paddingLeft: finalInsets.left,
211
+ paddingRight: finalInsets.right,
212
+ }}
213
+ >
214
+ {contentWrapper ? contentWrapper(children) : children}
215
+ </View>
216
+ );
217
+
218
+ if (Platform.OS !== 'ios') {
219
+ return content;
220
+ }
221
+
222
+ return (
223
+ <FullWindowOverlay
224
+ disableFullWindowOverlay={disableFullWindowOverlay}
225
+ unstable_accessibilityContainerViewIsModal={unstable_accessibilityContainerViewIsModal}
226
+ >
227
+ {content}
228
+ </FullWindowOverlay>
229
+ );
230
+ }
@@ -0,0 +1,37 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ /**
4
+ * Internal context that exposes the pending-removal lifecycle for web toasts.
5
+ *
6
+ * Web toasts stay mounted after `hide()` is dispatched so the CSS exit
7
+ * transition can play. The toast component reads `pendingRemovalIds` to
8
+ * flip its `data-state="closed"` attribute and calls `remove(id)` when
9
+ * the CSS transition completes (or a safety timeout fires).
10
+ *
11
+ * On native this context is provided but effectively unused — Reanimated's
12
+ * `exiting` layout animation plays before unmount, so nothing lingers.
13
+ *
14
+ * @internal
15
+ */
16
+ export interface ToastLifecycleContextValue {
17
+ /** Force-remove a toast from the array once its exit transition has played. */
18
+ remove: (id: string) => void;
19
+ /** IDs of toasts that have been marked closed but are still mounted. */
20
+ pendingRemovalIds: ReadonlySet<string>;
21
+ /** ID of the front-most (last non-pending) toast, or null if none. */
22
+ frontmostId: string | null;
23
+ }
24
+
25
+ export const ToastLifecycleContext = createContext<ToastLifecycleContextValue | null>(null);
26
+
27
+ /**
28
+ * Access the toast lifecycle context.
29
+ *
30
+ * Returns `null` when the styled Toast is rendered outside a `ToastProvider`
31
+ * (e.g. in isolated unit tests) so callers must handle the null case.
32
+ *
33
+ * @internal
34
+ */
35
+ export function useToastLifecycle(): ToastLifecycleContextValue | null {
36
+ return useContext(ToastLifecycleContext);
37
+ }