@yahoo/uds-mobile 2.15.0 → 2.17.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 (150) hide show
  1. package/README.md +27 -24
  2. package/dist/bin/fixtures/dist/index.mjs +14 -0
  3. package/dist/components/Input.cjs +16 -13
  4. package/dist/components/Input.d.cts.map +1 -1
  5. package/dist/components/Input.d.ts.map +1 -1
  6. package/dist/components/Input.js +16 -13
  7. package/dist/components/Input.js.map +1 -1
  8. package/dist/components/InputHelpText.cjs +52 -0
  9. package/dist/components/InputHelpText.d.cts +37 -0
  10. package/dist/components/InputHelpText.d.cts.map +1 -0
  11. package/dist/components/InputHelpText.d.ts +37 -0
  12. package/dist/components/InputHelpText.d.ts.map +1 -0
  13. package/dist/components/InputHelpText.js +52 -0
  14. package/dist/components/InputHelpText.js.map +1 -0
  15. package/dist/components/Toast/Toast.cjs +141 -0
  16. package/dist/components/Toast/Toast.d.cts +38 -0
  17. package/dist/components/Toast/Toast.d.cts.map +1 -0
  18. package/dist/components/Toast/Toast.d.ts +38 -0
  19. package/dist/components/Toast/Toast.d.ts.map +1 -0
  20. package/dist/components/Toast/Toast.js +141 -0
  21. package/dist/components/Toast/Toast.js.map +1 -0
  22. package/dist/components/Toast/ToastAnimatedItem.cjs +88 -0
  23. package/dist/components/Toast/ToastAnimatedItem.d.cts +27 -0
  24. package/dist/components/Toast/ToastAnimatedItem.d.cts.map +1 -0
  25. package/dist/components/Toast/ToastAnimatedItem.d.ts +27 -0
  26. package/dist/components/Toast/ToastAnimatedItem.d.ts.map +1 -0
  27. package/dist/components/Toast/ToastAnimatedItem.js +87 -0
  28. package/dist/components/Toast/ToastAnimatedItem.js.map +1 -0
  29. package/dist/components/Toast/ToastItem.cjs +35 -0
  30. package/dist/components/Toast/ToastItem.d.cts +25 -0
  31. package/dist/components/Toast/ToastItem.d.cts.map +1 -0
  32. package/dist/components/Toast/ToastItem.d.ts +25 -0
  33. package/dist/components/Toast/ToastItem.d.ts.map +1 -0
  34. package/dist/components/Toast/ToastItem.js +35 -0
  35. package/dist/components/Toast/ToastItem.js.map +1 -0
  36. package/dist/components/Toast/ToastProvider.cjs +144 -0
  37. package/dist/components/Toast/ToastProvider.d.cts +58 -0
  38. package/dist/components/Toast/ToastProvider.d.cts.map +1 -0
  39. package/dist/components/Toast/ToastProvider.d.ts +58 -0
  40. package/dist/components/Toast/ToastProvider.d.ts.map +1 -0
  41. package/dist/components/Toast/ToastProvider.js +143 -0
  42. package/dist/components/Toast/ToastProvider.js.map +1 -0
  43. package/dist/components/Toast/ToastViewport.cjs +48 -0
  44. package/dist/components/Toast/ToastViewport.d.cts +42 -0
  45. package/dist/components/Toast/ToastViewport.d.cts.map +1 -0
  46. package/dist/components/Toast/ToastViewport.d.ts +42 -0
  47. package/dist/components/Toast/ToastViewport.d.ts.map +1 -0
  48. package/dist/components/Toast/ToastViewport.js +48 -0
  49. package/dist/components/Toast/ToastViewport.js.map +1 -0
  50. package/dist/components/Toast/createToast.cjs +21 -0
  51. package/dist/components/Toast/createToast.d.cts +10 -0
  52. package/dist/components/Toast/createToast.d.cts.map +1 -0
  53. package/dist/components/Toast/createToast.d.ts +10 -0
  54. package/dist/components/Toast/createToast.d.ts.map +1 -0
  55. package/dist/components/Toast/createToast.js +20 -0
  56. package/dist/components/Toast/createToast.js.map +1 -0
  57. package/dist/components/Toast/index.cjs +10 -0
  58. package/dist/components/Toast/index.d.cts +6 -0
  59. package/dist/components/Toast/index.d.ts +6 -0
  60. package/dist/components/Toast/index.js +5 -0
  61. package/dist/components/Toast/types.cjs +1 -0
  62. package/dist/components/Toast/types.d.cts +113 -0
  63. package/dist/components/Toast/types.d.cts.map +1 -0
  64. package/dist/components/Toast/types.d.ts +113 -0
  65. package/dist/components/Toast/types.d.ts.map +1 -0
  66. package/dist/components/Toast/types.js +1 -0
  67. package/dist/components/Toast/useToastController.cjs +286 -0
  68. package/dist/components/Toast/useToastController.d.cts +25 -0
  69. package/dist/components/Toast/useToastController.d.cts.map +1 -0
  70. package/dist/components/Toast/useToastController.d.ts +25 -0
  71. package/dist/components/Toast/useToastController.d.ts.map +1 -0
  72. package/dist/components/Toast/useToastController.js +286 -0
  73. package/dist/components/Toast/useToastController.js.map +1 -0
  74. package/dist/components/Toast/utils.cjs +69 -0
  75. package/dist/components/Toast/utils.d.cts +27 -0
  76. package/dist/components/Toast/utils.d.cts.map +1 -0
  77. package/dist/components/Toast/utils.d.ts +27 -0
  78. package/dist/components/Toast/utils.d.ts.map +1 -0
  79. package/dist/components/Toast/utils.js +55 -0
  80. package/dist/components/Toast/utils.js.map +1 -0
  81. package/dist/components/internal/Overlay/OverlayPortal.cjs +20 -0
  82. package/dist/components/internal/Overlay/OverlayPortal.d.cts +17 -0
  83. package/dist/components/internal/Overlay/OverlayPortal.d.cts.map +1 -0
  84. package/dist/components/internal/Overlay/OverlayPortal.d.ts +17 -0
  85. package/dist/components/internal/Overlay/OverlayPortal.d.ts.map +1 -0
  86. package/dist/components/internal/Overlay/OverlayPortal.js +20 -0
  87. package/dist/components/internal/Overlay/OverlayPortal.js.map +1 -0
  88. package/dist/components/internal/Overlay/index.cjs +6 -0
  89. package/dist/components/internal/Overlay/index.d.cts +5 -0
  90. package/dist/components/internal/Overlay/index.d.ts +5 -0
  91. package/dist/components/internal/Overlay/index.js +4 -0
  92. package/dist/components/internal/Overlay/types.cjs +1 -0
  93. package/dist/components/internal/Overlay/types.d.cts +21 -0
  94. package/dist/components/internal/Overlay/types.d.cts.map +1 -0
  95. package/dist/components/internal/Overlay/types.d.ts +21 -0
  96. package/dist/components/internal/Overlay/types.d.ts.map +1 -0
  97. package/dist/components/internal/Overlay/types.js +1 -0
  98. package/dist/components/internal/Overlay/useControllableState.cjs +34 -0
  99. package/dist/components/internal/Overlay/useControllableState.d.cts +18 -0
  100. package/dist/components/internal/Overlay/useControllableState.d.cts.map +1 -0
  101. package/dist/components/internal/Overlay/useControllableState.d.ts +18 -0
  102. package/dist/components/internal/Overlay/useControllableState.d.ts.map +1 -0
  103. package/dist/components/internal/Overlay/useControllableState.js +34 -0
  104. package/dist/components/internal/Overlay/useControllableState.js.map +1 -0
  105. package/dist/jest/mocks/gesture-handler.cjs +38 -0
  106. package/dist/jest/mocks/gesture-handler.d.cts +41 -0
  107. package/dist/jest/mocks/gesture-handler.d.cts.map +1 -0
  108. package/dist/jest/mocks/gesture-handler.d.ts +41 -0
  109. package/dist/jest/mocks/gesture-handler.d.ts.map +1 -0
  110. package/dist/jest/mocks/gesture-handler.js +37 -0
  111. package/dist/jest/mocks/gesture-handler.js.map +1 -0
  112. package/dist/jest/mocks/safe-area-context.cjs +35 -0
  113. package/dist/jest/mocks/safe-area-context.d.cts +43 -0
  114. package/dist/jest/mocks/safe-area-context.d.cts.map +1 -0
  115. package/dist/jest/mocks/safe-area-context.d.ts +43 -0
  116. package/dist/jest/mocks/safe-area-context.d.ts.map +1 -0
  117. package/dist/jest/mocks/safe-area-context.js +32 -0
  118. package/dist/jest/mocks/safe-area-context.js.map +1 -0
  119. package/dist/jest/mocks/screens.cjs +8 -0
  120. package/dist/jest/mocks/screens.d.cts +12 -0
  121. package/dist/jest/mocks/screens.d.cts.map +1 -0
  122. package/dist/jest/mocks/screens.d.ts +12 -0
  123. package/dist/jest/mocks/screens.d.ts.map +1 -0
  124. package/dist/jest/mocks/screens.js +9 -0
  125. package/dist/jest/mocks/screens.js.map +1 -0
  126. package/dist/jest/mocks/styles.cjs +38 -1
  127. package/dist/jest/mocks/styles.d.cts +3 -2
  128. package/dist/jest/mocks/styles.d.cts.map +1 -1
  129. package/dist/jest/mocks/styles.d.ts +3 -2
  130. package/dist/jest/mocks/styles.d.ts.map +1 -1
  131. package/dist/jest/mocks/styles.js +38 -2
  132. package/dist/jest/mocks/styles.js.map +1 -1
  133. package/dist/portal.cjs +1 -0
  134. package/dist/portal.d.cts +6 -1
  135. package/dist/portal.d.cts.map +1 -1
  136. package/dist/portal.d.ts +6 -1
  137. package/dist/portal.d.ts.map +1 -1
  138. package/dist/portal.js +1 -1
  139. package/dist/portal.js.map +1 -1
  140. package/dist/types/dist/index.d.cts +4 -1
  141. package/dist/types/dist/index.d.cts.map +1 -1
  142. package/dist/types/dist/index.d.ts +4 -1
  143. package/dist/types/dist/index.d.ts.map +1 -1
  144. package/fonts/index.cjs +209 -209
  145. package/fonts/index.mjs +209 -209
  146. package/generated/styles.cjs +114 -0
  147. package/generated/styles.d.ts +29 -0
  148. package/generated/styles.mjs +114 -0
  149. package/generated/unistyles.d.ts +110 -0
  150. package/package.json +21 -1
@@ -0,0 +1,144 @@
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
+ const require_components_internal_Overlay_OverlayPortal = require("../internal/Overlay/OverlayPortal.cjs");
6
+ const require_components_Toast_createToast = require("./createToast.cjs");
7
+ const require_components_Toast_ToastViewport = require("./ToastViewport.cjs");
8
+ const require_components_Toast_useToastController = require("./useToastController.cjs");
9
+ let react = require("react");
10
+ let react_native = require("react-native");
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ let react_native_safe_area_context = require("react-native-safe-area-context");
13
+ //#region src/components/Toast/ToastProvider.tsx
14
+ const ToastContext = (0, react.createContext)(null);
15
+ /**
16
+ * Returns the active toast controller and provider state.
17
+ *
18
+ * @description
19
+ * useToast exposes methods for showing, updating, hiding, and clearing queued
20
+ * toasts from components rendered under ToastProvider.
21
+ *
22
+ * @platform mobile
23
+ */
24
+ function useToast() {
25
+ const context = (0, react.useContext)(ToastContext);
26
+ if (!context) throw new Error("useToast must be used within a ToastProvider.");
27
+ return context;
28
+ }
29
+ /**
30
+ * **A provider for floating mobile toast notifications.**
31
+ *
32
+ * @description
33
+ * ToastProvider owns the mobile toast controller, auto-close timers, visible
34
+ * toast limit, waiting queue, safe-area aware viewport placement, and reduced
35
+ * motion configuration.
36
+ *
37
+ * Use ToastProvider with useToast or createToast to render floating toasts.
38
+ *
39
+ * @category Feedback
40
+ * @platform mobile
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * import { ToastProvider, useToast } from '@yahoo/uds-mobile/Toast';
45
+ *
46
+ * function App() {
47
+ * return <ToastProvider><Screen /></ToastProvider>;
48
+ * }
49
+ *
50
+ * function Screen() {
51
+ * const { toast } = useToast();
52
+ *
53
+ * return (
54
+ * <Button onPress={() => toast.show({ message: 'Draft saved' })}>
55
+ * Save
56
+ * </Button>
57
+ * );
58
+ * }
59
+ * ```
60
+ *
61
+ * @see {@link Toast} for the visual toast renderer
62
+ */
63
+ const ToastProvider = (0, react.memo)(function ToastProvider({ children, placement = require_components_Toast_utils.DEFAULT_TOAST_PLACEMENT, autoClose = require_components_Toast_utils.DEFAULT_TOAST_AUTO_CLOSE, limit, insets = require_components_Toast_utils.DEFAULT_TOAST_INSETS, viewportStyle, useFullWindowOverlay = true, reduceMotion = false }) {
64
+ const [prefersReducedMotion, setPrefersReducedMotion] = (0, react.useState)(false);
65
+ const safeAreaInsets = (0, react_native_safe_area_context.useSafeAreaInsets)();
66
+ const prefersReducedMotionRef = (0, react.useRef)(prefersReducedMotion);
67
+ const shouldReduceMotion = reduceMotion || prefersReducedMotion;
68
+ (0, react.useEffect)(() => {
69
+ if (reduceMotion) return;
70
+ let isMounted = true;
71
+ const checkReducedMotion = async () => {
72
+ const isReduceMotionEnabled = await react_native.AccessibilityInfo.isReduceMotionEnabled();
73
+ if (isMounted && prefersReducedMotionRef.current !== isReduceMotionEnabled) {
74
+ prefersReducedMotionRef.current = isReduceMotionEnabled;
75
+ setPrefersReducedMotion(isReduceMotionEnabled);
76
+ }
77
+ };
78
+ checkReducedMotion();
79
+ const handleReduceMotionChanged = (isReduceMotionEnabled) => {
80
+ prefersReducedMotionRef.current = isReduceMotionEnabled;
81
+ setPrefersReducedMotion(isReduceMotionEnabled);
82
+ };
83
+ const subscription = react_native.AccessibilityInfo.addEventListener("reduceMotionChanged", handleReduceMotionChanged);
84
+ return () => {
85
+ isMounted = false;
86
+ subscription.remove();
87
+ };
88
+ }, [reduceMotion]);
89
+ const { clearAllToastExitTimers, clearAllToastTimers, controller, toasts, waitingToastCount } = require_components_Toast_useToastController.useToastController({
90
+ autoClose,
91
+ limit: Math.max(limit ?? 3, 1),
92
+ placement,
93
+ shouldReduceMotion
94
+ });
95
+ const { hide } = controller;
96
+ (0, react.useEffect)(() => require_components_Toast_createToast.setToastController(controller), [controller]);
97
+ (0, react.useEffect)(() => () => {
98
+ clearAllToastTimers();
99
+ clearAllToastExitTimers();
100
+ }, [clearAllToastExitTimers, clearAllToastTimers]);
101
+ const contextValue = (0, react.useMemo)(() => ({
102
+ toast: controller,
103
+ isToastVisible: toasts.length > 0,
104
+ waitingToastCount
105
+ }), [
106
+ controller,
107
+ toasts.length,
108
+ waitingToastCount
109
+ ]);
110
+ const topToasts = toasts.filter((toast) => toast.placement === "top-center");
111
+ const bottomToasts = toasts.filter((toast) => toast.placement === "bottom-center");
112
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToastContext.Provider, {
113
+ value: contextValue,
114
+ children: [children, toasts.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_internal_Overlay_OverlayPortal.OverlayPortal, {
115
+ useFullWindowOverlay,
116
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
117
+ pointerEvents: "box-none",
118
+ style: styles.overlay,
119
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Toast_ToastViewport.ToastViewport, {
120
+ insets,
121
+ placement: "top-center",
122
+ style: viewportStyle,
123
+ toasts: topToasts,
124
+ hide,
125
+ reduceMotion: shouldReduceMotion,
126
+ safeAreaInsets
127
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Toast_ToastViewport.ToastViewport, {
128
+ insets,
129
+ placement: "bottom-center",
130
+ style: viewportStyle,
131
+ toasts: bottomToasts,
132
+ hide,
133
+ reduceMotion: shouldReduceMotion,
134
+ safeAreaInsets
135
+ })]
136
+ })
137
+ })]
138
+ });
139
+ });
140
+ ToastProvider.displayName = "ToastProvider";
141
+ const styles = react_native.StyleSheet.create({ overlay: { ...react_native.StyleSheet.absoluteFillObject } });
142
+ //#endregion
143
+ exports.ToastProvider = ToastProvider;
144
+ exports.useToast = useToast;
@@ -0,0 +1,58 @@
1
+
2
+ import { ToastController, ToastProviderProps } from "./types.cjs";
3
+ import * as _$react from "react";
4
+
5
+ //#region src/components/Toast/ToastProvider.d.ts
6
+ interface ToastContextValue {
7
+ toast: ToastController;
8
+ isToastVisible: boolean;
9
+ waitingToastCount: number;
10
+ }
11
+ /**
12
+ * Returns the active toast controller and provider state.
13
+ *
14
+ * @description
15
+ * useToast exposes methods for showing, updating, hiding, and clearing queued
16
+ * toasts from components rendered under ToastProvider.
17
+ *
18
+ * @platform mobile
19
+ */
20
+ declare function useToast(): ToastContextValue;
21
+ /**
22
+ * **A provider for floating mobile toast notifications.**
23
+ *
24
+ * @description
25
+ * ToastProvider owns the mobile toast controller, auto-close timers, visible
26
+ * toast limit, waiting queue, safe-area aware viewport placement, and reduced
27
+ * motion configuration.
28
+ *
29
+ * Use ToastProvider with useToast or createToast to render floating toasts.
30
+ *
31
+ * @category Feedback
32
+ * @platform mobile
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * import { ToastProvider, useToast } from '@yahoo/uds-mobile/Toast';
37
+ *
38
+ * function App() {
39
+ * return <ToastProvider><Screen /></ToastProvider>;
40
+ * }
41
+ *
42
+ * function Screen() {
43
+ * const { toast } = useToast();
44
+ *
45
+ * return (
46
+ * <Button onPress={() => toast.show({ message: 'Draft saved' })}>
47
+ * Save
48
+ * </Button>
49
+ * );
50
+ * }
51
+ * ```
52
+ *
53
+ * @see {@link Toast} for the visual toast renderer
54
+ */
55
+ declare const ToastProvider: _$react.NamedExoticComponent<ToastProviderProps>;
56
+ //#endregion
57
+ export { ToastProvider, useToast };
58
+ //# sourceMappingURL=ToastProvider.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastProvider.d.cts","names":[],"sources":["../../../src/components/Toast/ToastProvider.tsx"],"mappings":";;;;;UAgBU,iBAAA;EACR,KAAA,EAAO,eAAA;EACP,cAAA;EACA,iBAAA;AAAA;;;;;;;;;AAAiB;iBAcV,QAAA,CAAA,GAAY,iBAAA;;;;AAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4ChC,aAAA,EAAa,OAAA,CAAA,oBAAA,CAAA,kBAAA"}
@@ -0,0 +1,58 @@
1
+
2
+ import { ToastController, ToastProviderProps } from "./types.js";
3
+ import * as _$react from "react";
4
+
5
+ //#region src/components/Toast/ToastProvider.d.ts
6
+ interface ToastContextValue {
7
+ toast: ToastController;
8
+ isToastVisible: boolean;
9
+ waitingToastCount: number;
10
+ }
11
+ /**
12
+ * Returns the active toast controller and provider state.
13
+ *
14
+ * @description
15
+ * useToast exposes methods for showing, updating, hiding, and clearing queued
16
+ * toasts from components rendered under ToastProvider.
17
+ *
18
+ * @platform mobile
19
+ */
20
+ declare function useToast(): ToastContextValue;
21
+ /**
22
+ * **A provider for floating mobile toast notifications.**
23
+ *
24
+ * @description
25
+ * ToastProvider owns the mobile toast controller, auto-close timers, visible
26
+ * toast limit, waiting queue, safe-area aware viewport placement, and reduced
27
+ * motion configuration.
28
+ *
29
+ * Use ToastProvider with useToast or createToast to render floating toasts.
30
+ *
31
+ * @category Feedback
32
+ * @platform mobile
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * import { ToastProvider, useToast } from '@yahoo/uds-mobile/Toast';
37
+ *
38
+ * function App() {
39
+ * return <ToastProvider><Screen /></ToastProvider>;
40
+ * }
41
+ *
42
+ * function Screen() {
43
+ * const { toast } = useToast();
44
+ *
45
+ * return (
46
+ * <Button onPress={() => toast.show({ message: 'Draft saved' })}>
47
+ * Save
48
+ * </Button>
49
+ * );
50
+ * }
51
+ * ```
52
+ *
53
+ * @see {@link Toast} for the visual toast renderer
54
+ */
55
+ declare const ToastProvider: _$react.NamedExoticComponent<ToastProviderProps>;
56
+ //#endregion
57
+ export { ToastProvider, useToast };
58
+ //# sourceMappingURL=ToastProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastProvider.d.ts","names":[],"sources":["../../../src/components/Toast/ToastProvider.tsx"],"mappings":";;;;;UAgBU,iBAAA;EACR,KAAA,EAAO,eAAA;EACP,cAAA;EACA,iBAAA;AAAA;;;;;;;;;AAAiB;iBAcV,QAAA,CAAA,GAAY,iBAAA;;;;AAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4ChC,aAAA,EAAa,OAAA,CAAA,oBAAA,CAAA,kBAAA"}
@@ -0,0 +1,143 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
2
+ import { DEFAULT_TOAST_AUTO_CLOSE, DEFAULT_TOAST_INSETS, DEFAULT_TOAST_PLACEMENT } from "./utils.js";
3
+ import { OverlayPortal } from "../internal/Overlay/OverlayPortal.js";
4
+ import { setToastController } from "./createToast.js";
5
+ import { ToastViewport } from "./ToastViewport.js";
6
+ import { useToastController } from "./useToastController.js";
7
+ import { createContext, memo, useContext, useEffect, useMemo, useRef, useState } from "react";
8
+ import { AccessibilityInfo, StyleSheet, View } from "react-native";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
11
+ //#region src/components/Toast/ToastProvider.tsx
12
+ const ToastContext = createContext(null);
13
+ /**
14
+ * Returns the active toast controller and provider state.
15
+ *
16
+ * @description
17
+ * useToast exposes methods for showing, updating, hiding, and clearing queued
18
+ * toasts from components rendered under ToastProvider.
19
+ *
20
+ * @platform mobile
21
+ */
22
+ function useToast() {
23
+ const context = useContext(ToastContext);
24
+ if (!context) throw new Error("useToast must be used within a ToastProvider.");
25
+ return context;
26
+ }
27
+ /**
28
+ * **A provider for floating mobile toast notifications.**
29
+ *
30
+ * @description
31
+ * ToastProvider owns the mobile toast controller, auto-close timers, visible
32
+ * toast limit, waiting queue, safe-area aware viewport placement, and reduced
33
+ * motion configuration.
34
+ *
35
+ * Use ToastProvider with useToast or createToast to render floating toasts.
36
+ *
37
+ * @category Feedback
38
+ * @platform mobile
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * import { ToastProvider, useToast } from '@yahoo/uds-mobile/Toast';
43
+ *
44
+ * function App() {
45
+ * return <ToastProvider><Screen /></ToastProvider>;
46
+ * }
47
+ *
48
+ * function Screen() {
49
+ * const { toast } = useToast();
50
+ *
51
+ * return (
52
+ * <Button onPress={() => toast.show({ message: 'Draft saved' })}>
53
+ * Save
54
+ * </Button>
55
+ * );
56
+ * }
57
+ * ```
58
+ *
59
+ * @see {@link Toast} for the visual toast renderer
60
+ */
61
+ const ToastProvider = memo(function ToastProvider({ children, placement = DEFAULT_TOAST_PLACEMENT, autoClose = DEFAULT_TOAST_AUTO_CLOSE, limit, insets = DEFAULT_TOAST_INSETS, viewportStyle, useFullWindowOverlay = true, reduceMotion = false }) {
62
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
63
+ const safeAreaInsets = useSafeAreaInsets();
64
+ const prefersReducedMotionRef = useRef(prefersReducedMotion);
65
+ const shouldReduceMotion = reduceMotion || prefersReducedMotion;
66
+ useEffect(() => {
67
+ if (reduceMotion) return;
68
+ let isMounted = true;
69
+ const checkReducedMotion = async () => {
70
+ const isReduceMotionEnabled = await AccessibilityInfo.isReduceMotionEnabled();
71
+ if (isMounted && prefersReducedMotionRef.current !== isReduceMotionEnabled) {
72
+ prefersReducedMotionRef.current = isReduceMotionEnabled;
73
+ setPrefersReducedMotion(isReduceMotionEnabled);
74
+ }
75
+ };
76
+ checkReducedMotion();
77
+ const handleReduceMotionChanged = (isReduceMotionEnabled) => {
78
+ prefersReducedMotionRef.current = isReduceMotionEnabled;
79
+ setPrefersReducedMotion(isReduceMotionEnabled);
80
+ };
81
+ const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", handleReduceMotionChanged);
82
+ return () => {
83
+ isMounted = false;
84
+ subscription.remove();
85
+ };
86
+ }, [reduceMotion]);
87
+ const { clearAllToastExitTimers, clearAllToastTimers, controller, toasts, waitingToastCount } = useToastController({
88
+ autoClose,
89
+ limit: Math.max(limit ?? 3, 1),
90
+ placement,
91
+ shouldReduceMotion
92
+ });
93
+ const { hide } = controller;
94
+ useEffect(() => setToastController(controller), [controller]);
95
+ useEffect(() => () => {
96
+ clearAllToastTimers();
97
+ clearAllToastExitTimers();
98
+ }, [clearAllToastExitTimers, clearAllToastTimers]);
99
+ const contextValue = useMemo(() => ({
100
+ toast: controller,
101
+ isToastVisible: toasts.length > 0,
102
+ waitingToastCount
103
+ }), [
104
+ controller,
105
+ toasts.length,
106
+ waitingToastCount
107
+ ]);
108
+ const topToasts = toasts.filter((toast) => toast.placement === "top-center");
109
+ const bottomToasts = toasts.filter((toast) => toast.placement === "bottom-center");
110
+ return /* @__PURE__ */ jsxs(ToastContext.Provider, {
111
+ value: contextValue,
112
+ children: [children, toasts.length > 0 && /* @__PURE__ */ jsx(OverlayPortal, {
113
+ useFullWindowOverlay,
114
+ children: /* @__PURE__ */ jsxs(View, {
115
+ pointerEvents: "box-none",
116
+ style: styles.overlay,
117
+ children: [/* @__PURE__ */ jsx(ToastViewport, {
118
+ insets,
119
+ placement: "top-center",
120
+ style: viewportStyle,
121
+ toasts: topToasts,
122
+ hide,
123
+ reduceMotion: shouldReduceMotion,
124
+ safeAreaInsets
125
+ }), /* @__PURE__ */ jsx(ToastViewport, {
126
+ insets,
127
+ placement: "bottom-center",
128
+ style: viewportStyle,
129
+ toasts: bottomToasts,
130
+ hide,
131
+ reduceMotion: shouldReduceMotion,
132
+ safeAreaInsets
133
+ })]
134
+ })
135
+ })]
136
+ });
137
+ });
138
+ ToastProvider.displayName = "ToastProvider";
139
+ const styles = StyleSheet.create({ overlay: { ...StyleSheet.absoluteFillObject } });
140
+ //#endregion
141
+ export { ToastProvider, useToast };
142
+
143
+ //# sourceMappingURL=ToastProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastProvider.js","names":[],"sources":["../../../src/components/Toast/ToastProvider.tsx"],"sourcesContent":["import { createContext, memo, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { AccessibilityInfo, StyleSheet, View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { OverlayPortal } from '../internal/Overlay';\nimport { setToastController } from './createToast';\nimport { ToastViewport } from './ToastViewport';\nimport type { ToastController, ToastProviderProps } from './types';\nimport { useToastController } from './useToastController';\nimport {\n DEFAULT_MAX_VISIBLE_TOASTS,\n DEFAULT_TOAST_AUTO_CLOSE,\n DEFAULT_TOAST_INSETS,\n DEFAULT_TOAST_PLACEMENT,\n} from './utils';\n\ninterface ToastContextValue {\n toast: ToastController;\n isToastVisible: boolean;\n waitingToastCount: number;\n}\n\nconst ToastContext = createContext<ToastContextValue | null>(null);\n\n/**\n * Returns the active toast controller and provider state.\n *\n * @description\n * useToast exposes methods for showing, updating, hiding, and clearing queued\n * toasts from components rendered under ToastProvider.\n *\n * @platform mobile\n */\nfunction useToast(): ToastContextValue {\n const context = useContext(ToastContext);\n\n if (!context) {\n throw new Error('useToast must be used within a ToastProvider.');\n }\n\n return context;\n}\n\n/**\n * **A provider for floating mobile toast notifications.**\n *\n * @description\n * ToastProvider owns the mobile toast controller, auto-close timers, visible\n * toast limit, waiting queue, safe-area aware viewport placement, and reduced\n * motion configuration.\n *\n * Use ToastProvider with useToast or createToast to render floating toasts.\n *\n * @category Feedback\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { ToastProvider, useToast } from '@yahoo/uds-mobile/Toast';\n *\n * function App() {\n * return <ToastProvider><Screen /></ToastProvider>;\n * }\n *\n * function Screen() {\n * const { toast } = useToast();\n *\n * return (\n * <Button onPress={() => toast.show({ message: 'Draft saved' })}>\n * Save\n * </Button>\n * );\n * }\n * ```\n *\n * @see {@link Toast} for the visual toast renderer\n */\nconst ToastProvider = memo(function ToastProvider({\n children,\n placement = DEFAULT_TOAST_PLACEMENT,\n autoClose = DEFAULT_TOAST_AUTO_CLOSE,\n limit,\n insets = DEFAULT_TOAST_INSETS,\n viewportStyle,\n useFullWindowOverlay = true,\n reduceMotion = false,\n}: ToastProviderProps) {\n const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);\n const safeAreaInsets = useSafeAreaInsets();\n const prefersReducedMotionRef = useRef(prefersReducedMotion);\n const shouldReduceMotion = reduceMotion || prefersReducedMotion;\n\n useEffect(() => {\n if (reduceMotion) {\n return;\n }\n\n let isMounted = true;\n\n const checkReducedMotion = async () => {\n const isReduceMotionEnabled = await AccessibilityInfo.isReduceMotionEnabled();\n if (isMounted && prefersReducedMotionRef.current !== isReduceMotionEnabled) {\n prefersReducedMotionRef.current = isReduceMotionEnabled;\n setPrefersReducedMotion(isReduceMotionEnabled);\n }\n };\n\n checkReducedMotion();\n\n const handleReduceMotionChanged = (isReduceMotionEnabled: boolean) => {\n prefersReducedMotionRef.current = isReduceMotionEnabled;\n setPrefersReducedMotion(isReduceMotionEnabled);\n };\n\n const subscription = AccessibilityInfo.addEventListener(\n 'reduceMotionChanged',\n handleReduceMotionChanged,\n );\n\n return () => {\n isMounted = false;\n subscription.remove();\n };\n }, [reduceMotion]);\n\n const { clearAllToastExitTimers, clearAllToastTimers, controller, toasts, waitingToastCount } =\n useToastController({\n autoClose,\n limit: Math.max(limit ?? DEFAULT_MAX_VISIBLE_TOASTS, 1),\n placement,\n shouldReduceMotion,\n });\n const { hide } = controller;\n\n // Keep controller registration separate from timer cleanup. The controller can change while\n // the provider is mounted, but clearing timers should only happen when the provider unmounts.\n useEffect(() => setToastController(controller), [controller]);\n\n useEffect(\n () => () => {\n clearAllToastTimers();\n clearAllToastExitTimers();\n },\n [clearAllToastExitTimers, clearAllToastTimers],\n );\n\n const contextValue = useMemo<ToastContextValue>(\n () => ({\n toast: controller,\n isToastVisible: toasts.length > 0,\n waitingToastCount,\n }),\n [controller, toasts.length, waitingToastCount],\n );\n\n const topToasts = toasts.filter((toast) => toast.placement === 'top-center');\n const bottomToasts = toasts.filter((toast) => toast.placement === 'bottom-center');\n\n return (\n <ToastContext.Provider value={contextValue}>\n {children}\n {toasts.length > 0 && (\n <OverlayPortal useFullWindowOverlay={useFullWindowOverlay}>\n <View pointerEvents=\"box-none\" style={styles.overlay}>\n <ToastViewport\n insets={insets}\n placement=\"top-center\"\n style={viewportStyle}\n toasts={topToasts}\n hide={hide}\n reduceMotion={shouldReduceMotion}\n safeAreaInsets={safeAreaInsets}\n />\n <ToastViewport\n insets={insets}\n placement=\"bottom-center\"\n style={viewportStyle}\n toasts={bottomToasts}\n hide={hide}\n reduceMotion={shouldReduceMotion}\n safeAreaInsets={safeAreaInsets}\n />\n </View>\n </OverlayPortal>\n )}\n </ToastContext.Provider>\n );\n});\n\nToastProvider.displayName = 'ToastProvider';\n\nconst styles = StyleSheet.create({\n overlay: {\n ...StyleSheet.absoluteFillObject,\n },\n});\n\nexport { ToastProvider, useToast };\n"],"mappings":";;;;;;;;;;;AAsBA,MAAM,eAAe,cAAwC,KAAK;;;;;;;;;;AAWlE,SAAS,WAA8B;CACrC,MAAM,UAAU,WAAW,aAAa;CAExC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,gDAAgD;CAGlE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCT,MAAM,gBAAgB,KAAK,SAAS,cAAc,EAChD,UACA,YAAY,yBACZ,YAAY,0BACZ,OACA,SAAS,sBACT,eACA,uBAAuB,MACvB,eAAe,SACM;CACrB,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,MAAM;CACvE,MAAM,iBAAiB,mBAAmB;CAC1C,MAAM,0BAA0B,OAAO,qBAAqB;CAC5D,MAAM,qBAAqB,gBAAgB;CAE3C,gBAAgB;EACd,IAAI,cACF;EAGF,IAAI,YAAY;EAEhB,MAAM,qBAAqB,YAAY;GACrC,MAAM,wBAAwB,MAAM,kBAAkB,uBAAuB;GAC7E,IAAI,aAAa,wBAAwB,YAAY,uBAAuB;IAC1E,wBAAwB,UAAU;IAClC,wBAAwB,sBAAsB;;;EAIlD,oBAAoB;EAEpB,MAAM,6BAA6B,0BAAmC;GACpE,wBAAwB,UAAU;GAClC,wBAAwB,sBAAsB;;EAGhD,MAAM,eAAe,kBAAkB,iBACrC,uBACA,0BACD;EAED,aAAa;GACX,YAAY;GACZ,aAAa,QAAQ;;IAEtB,CAAC,aAAa,CAAC;CAElB,MAAM,EAAE,yBAAyB,qBAAqB,YAAY,QAAQ,sBACxE,mBAAmB;EACjB;EACA,OAAO,KAAK,IAAI,SAAA,GAAqC,EAAE;EACvD;EACA;EACD,CAAC;CACJ,MAAM,EAAE,SAAS;CAIjB,gBAAgB,mBAAmB,WAAW,EAAE,CAAC,WAAW,CAAC;CAE7D,sBACc;EACV,qBAAqB;EACrB,yBAAyB;IAE3B,CAAC,yBAAyB,oBAAoB,CAC/C;CAED,MAAM,eAAe,eACZ;EACL,OAAO;EACP,gBAAgB,OAAO,SAAS;EAChC;EACD,GACD;EAAC;EAAY,OAAO;EAAQ;EAAkB,CAC/C;CAED,MAAM,YAAY,OAAO,QAAQ,UAAU,MAAM,cAAc,aAAa;CAC5E,MAAM,eAAe,OAAO,QAAQ,UAAU,MAAM,cAAc,gBAAgB;CAElF,OACE,qBAAC,aAAa,UAAd;EAAuB,OAAO;YAA9B,CACG,UACA,OAAO,SAAS,KACf,oBAAC,eAAD;GAAqC;aACnC,qBAAC,MAAD;IAAM,eAAc;IAAW,OAAO,OAAO;cAA7C,CACE,oBAAC,eAAD;KACU;KACR,WAAU;KACV,OAAO;KACP,QAAQ;KACF;KACN,cAAc;KACE;KAChB,CAAA,EACF,oBAAC,eAAD;KACU;KACR,WAAU;KACV,OAAO;KACP,QAAQ;KACF;KACN,cAAc;KACE;KAChB,CAAA,CACG;;GACO,CAAA,CAEI;;EAE1B;AAEF,cAAc,cAAc;AAE5B,MAAM,SAAS,WAAW,OAAO,EAC/B,SAAS,EACP,GAAG,WAAW,oBACf,EACF,CAAC"}
@@ -0,0 +1,48 @@
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
+ const require_components_Toast_ToastAnimatedItem = require("./ToastAnimatedItem.cjs");
6
+ let react_native = require("react-native");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+ //#region src/components/Toast/ToastViewport.tsx
9
+ /**
10
+ * Internal viewport for one toast placement.
11
+ *
12
+ * @description
13
+ * ToastViewport applies safe-area and configured viewport insets, positions the
14
+ * stack for top-center or bottom-center placement, and renders each visible
15
+ * toast record.
16
+ *
17
+ * @internal
18
+ */
19
+ function ToastViewport({ insets, placement, style, toasts, hide, reduceMotion, safeAreaInsets }) {
20
+ if (toasts.length === 0) return null;
21
+ const isTop = placement === "top-center";
22
+ const horizontalInset = insets?.horizontal ?? require_components_Toast_utils.DEFAULT_TOAST_INSETS.horizontal;
23
+ const viewportInset = isTop ? { top: safeAreaInsets.top + (insets?.top ?? require_components_Toast_utils.DEFAULT_TOAST_INSETS.top) } : { bottom: safeAreaInsets.bottom + (insets?.bottom ?? require_components_Toast_utils.DEFAULT_TOAST_INSETS.bottom) };
24
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
25
+ pointerEvents: "box-none",
26
+ style: [
27
+ styles.viewport,
28
+ viewportInset,
29
+ {
30
+ left: safeAreaInsets.left + horizontalInset,
31
+ right: safeAreaInsets.right + horizontalInset
32
+ },
33
+ style
34
+ ],
35
+ children: toasts.map((toast) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Toast_ToastAnimatedItem.ToastAnimatedItem, {
36
+ toast,
37
+ hide,
38
+ reduceMotion
39
+ }, toast.id))
40
+ });
41
+ }
42
+ const styles = react_native.StyleSheet.create({ viewport: {
43
+ alignItems: "center",
44
+ gap: 8,
45
+ position: "absolute"
46
+ } });
47
+ //#endregion
48
+ exports.ToastViewport = ToastViewport;
@@ -0,0 +1,42 @@
1
+
2
+ import { ToastController, ToastPlacement, ToastProviderProps, ToastRecord } from "./types.cjs";
3
+ import * as _$react from "react";
4
+
5
+ //#region src/components/Toast/ToastViewport.d.ts
6
+ interface ToastSafeAreaInsets {
7
+ top: number;
8
+ bottom: number;
9
+ left: number;
10
+ right: number;
11
+ }
12
+ interface ToastViewportProps {
13
+ insets?: ToastProviderProps['insets'];
14
+ placement: ToastPlacement;
15
+ style?: ToastProviderProps['viewportStyle'];
16
+ toasts: ToastRecord[];
17
+ hide: ToastController['hide'];
18
+ reduceMotion: boolean;
19
+ safeAreaInsets: ToastSafeAreaInsets;
20
+ }
21
+ /**
22
+ * Internal viewport for one toast placement.
23
+ *
24
+ * @description
25
+ * ToastViewport applies safe-area and configured viewport insets, positions the
26
+ * stack for top-center or bottom-center placement, and renders each visible
27
+ * toast record.
28
+ *
29
+ * @internal
30
+ */
31
+ declare function ToastViewport({
32
+ insets,
33
+ placement,
34
+ style,
35
+ toasts,
36
+ hide,
37
+ reduceMotion,
38
+ safeAreaInsets
39
+ }: ToastViewportProps): _$react.JSX.Element | null;
40
+ //#endregion
41
+ export { ToastViewport };
42
+ //# sourceMappingURL=ToastViewport.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastViewport.d.cts","names":[],"sources":["../../../src/components/Toast/ToastViewport.tsx"],"mappings":";;;;;UAMU,mBAAA;EACR,GAAA;EACA,MAAA;EACA,IAAA;EACA,KAAA;AAAA;AAAA,UAGQ,kBAAA;EACR,MAAA,GAAS,kBAAA;EACT,SAAA,EAAW,cAAA;EACX,KAAA,GAAQ,kBAAA;EACR,MAAA,EAAQ,WAAA;EACR,IAAA,EAAM,eAAA;EACN,YAAA;EACA,cAAA,EAAgB,mBAAA;AAAA;;;;;;;;;;;iBAaT,aAAA,CAAA;EACP,MAAA;EACA,SAAA;EACA,KAAA;EACA,MAAA;EACA,IAAA;EACA,YAAA;EACA;AAAA,GACC,kBAAA,GAAkB,OAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -0,0 +1,42 @@
1
+
2
+ import { ToastController, ToastPlacement, ToastProviderProps, ToastRecord } from "./types.js";
3
+ import * as _$react from "react";
4
+
5
+ //#region src/components/Toast/ToastViewport.d.ts
6
+ interface ToastSafeAreaInsets {
7
+ top: number;
8
+ bottom: number;
9
+ left: number;
10
+ right: number;
11
+ }
12
+ interface ToastViewportProps {
13
+ insets?: ToastProviderProps['insets'];
14
+ placement: ToastPlacement;
15
+ style?: ToastProviderProps['viewportStyle'];
16
+ toasts: ToastRecord[];
17
+ hide: ToastController['hide'];
18
+ reduceMotion: boolean;
19
+ safeAreaInsets: ToastSafeAreaInsets;
20
+ }
21
+ /**
22
+ * Internal viewport for one toast placement.
23
+ *
24
+ * @description
25
+ * ToastViewport applies safe-area and configured viewport insets, positions the
26
+ * stack for top-center or bottom-center placement, and renders each visible
27
+ * toast record.
28
+ *
29
+ * @internal
30
+ */
31
+ declare function ToastViewport({
32
+ insets,
33
+ placement,
34
+ style,
35
+ toasts,
36
+ hide,
37
+ reduceMotion,
38
+ safeAreaInsets
39
+ }: ToastViewportProps): _$react.JSX.Element | null;
40
+ //#endregion
41
+ export { ToastViewport };
42
+ //# sourceMappingURL=ToastViewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastViewport.d.ts","names":[],"sources":["../../../src/components/Toast/ToastViewport.tsx"],"mappings":";;;;;UAMU,mBAAA;EACR,GAAA;EACA,MAAA;EACA,IAAA;EACA,KAAA;AAAA;AAAA,UAGQ,kBAAA;EACR,MAAA,GAAS,kBAAA;EACT,SAAA,EAAW,cAAA;EACX,KAAA,GAAQ,kBAAA;EACR,MAAA,EAAQ,WAAA;EACR,IAAA,EAAM,eAAA;EACN,YAAA;EACA,cAAA,EAAgB,mBAAA;AAAA;;;;;;;;;;;iBAaT,aAAA,CAAA;EACP,MAAA;EACA,SAAA;EACA,KAAA;EACA,MAAA;EACA,IAAA;EACA,YAAA;EACA;AAAA,GACC,kBAAA,GAAkB,OAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -0,0 +1,48 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
2
+ import { DEFAULT_TOAST_INSETS } from "./utils.js";
3
+ import { ToastAnimatedItem } from "./ToastAnimatedItem.js";
4
+ import { StyleSheet, View } from "react-native";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/components/Toast/ToastViewport.tsx
7
+ /**
8
+ * Internal viewport for one toast placement.
9
+ *
10
+ * @description
11
+ * ToastViewport applies safe-area and configured viewport insets, positions the
12
+ * stack for top-center or bottom-center placement, and renders each visible
13
+ * toast record.
14
+ *
15
+ * @internal
16
+ */
17
+ function ToastViewport({ insets, placement, style, toasts, hide, reduceMotion, safeAreaInsets }) {
18
+ if (toasts.length === 0) return null;
19
+ const isTop = placement === "top-center";
20
+ const horizontalInset = insets?.horizontal ?? DEFAULT_TOAST_INSETS.horizontal;
21
+ const viewportInset = isTop ? { top: safeAreaInsets.top + (insets?.top ?? DEFAULT_TOAST_INSETS.top) } : { bottom: safeAreaInsets.bottom + (insets?.bottom ?? DEFAULT_TOAST_INSETS.bottom) };
22
+ return /* @__PURE__ */ jsx(View, {
23
+ pointerEvents: "box-none",
24
+ style: [
25
+ styles.viewport,
26
+ viewportInset,
27
+ {
28
+ left: safeAreaInsets.left + horizontalInset,
29
+ right: safeAreaInsets.right + horizontalInset
30
+ },
31
+ style
32
+ ],
33
+ children: toasts.map((toast) => /* @__PURE__ */ jsx(ToastAnimatedItem, {
34
+ toast,
35
+ hide,
36
+ reduceMotion
37
+ }, toast.id))
38
+ });
39
+ }
40
+ const styles = StyleSheet.create({ viewport: {
41
+ alignItems: "center",
42
+ gap: 8,
43
+ position: "absolute"
44
+ } });
45
+ //#endregion
46
+ export { ToastViewport };
47
+
48
+ //# sourceMappingURL=ToastViewport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastViewport.js","names":[],"sources":["../../../src/components/Toast/ToastViewport.tsx"],"sourcesContent":["import { StyleSheet, View } from 'react-native';\n\nimport { ToastAnimatedItem } from './ToastAnimatedItem';\nimport type { ToastController, ToastPlacement, ToastProviderProps, ToastRecord } from './types';\nimport { DEFAULT_TOAST_INSETS } from './utils';\n\ninterface ToastSafeAreaInsets {\n top: number;\n bottom: number;\n left: number;\n right: number;\n}\n\ninterface ToastViewportProps {\n insets?: ToastProviderProps['insets'];\n placement: ToastPlacement;\n style?: ToastProviderProps['viewportStyle'];\n toasts: ToastRecord[];\n hide: ToastController['hide'];\n reduceMotion: boolean;\n safeAreaInsets: ToastSafeAreaInsets;\n}\n\n/**\n * Internal viewport for one toast placement.\n *\n * @description\n * ToastViewport applies safe-area and configured viewport insets, positions the\n * stack for top-center or bottom-center placement, and renders each visible\n * toast record.\n *\n * @internal\n */\nfunction ToastViewport({\n insets,\n placement,\n style,\n toasts,\n hide,\n reduceMotion,\n safeAreaInsets,\n}: ToastViewportProps) {\n if (toasts.length === 0) {\n return null;\n }\n\n const isTop = placement === 'top-center';\n const horizontalInset = insets?.horizontal ?? DEFAULT_TOAST_INSETS.horizontal;\n const viewportInset = isTop\n ? { top: safeAreaInsets.top + (insets?.top ?? DEFAULT_TOAST_INSETS.top) }\n : { bottom: safeAreaInsets.bottom + (insets?.bottom ?? DEFAULT_TOAST_INSETS.bottom) };\n\n return (\n <View\n pointerEvents=\"box-none\"\n style={[\n styles.viewport,\n viewportInset,\n {\n left: safeAreaInsets.left + horizontalInset,\n right: safeAreaInsets.right + horizontalInset,\n },\n style,\n ]}\n >\n {toasts.map((toast) => (\n <ToastAnimatedItem key={toast.id} toast={toast} hide={hide} reduceMotion={reduceMotion} />\n ))}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n viewport: {\n alignItems: 'center',\n gap: 8,\n position: 'absolute',\n },\n});\n\nexport { ToastViewport };\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,SAAS,cAAc,EACrB,QACA,WACA,OACA,QACA,MACA,cACA,kBACqB;CACrB,IAAI,OAAO,WAAW,GACpB,OAAO;CAGT,MAAM,QAAQ,cAAc;CAC5B,MAAM,kBAAkB,QAAQ,cAAc,qBAAqB;CACnE,MAAM,gBAAgB,QAClB,EAAE,KAAK,eAAe,OAAO,QAAQ,OAAO,qBAAqB,MAAM,GACvE,EAAE,QAAQ,eAAe,UAAU,QAAQ,UAAU,qBAAqB,SAAS;CAEvF,OACE,oBAAC,MAAD;EACE,eAAc;EACd,OAAO;GACL,OAAO;GACP;GACA;IACE,MAAM,eAAe,OAAO;IAC5B,OAAO,eAAe,QAAQ;IAC/B;GACD;GACD;YAEA,OAAO,KAAK,UACX,oBAAC,mBAAD;GAAyC;GAAa;GAAoB;GAAgB,EAAlE,MAAM,GAA4D,CAC1F;EACG,CAAA;;AAIX,MAAM,SAAS,WAAW,OAAO,EAC/B,UAAU;CACR,YAAY;CACZ,KAAK;CACL,UAAU;CACX,EACF,CAAC"}
@@ -0,0 +1,21 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ //#region src/components/Toast/createToast.ts
4
+ let activeToastController = null;
5
+ function setToastController(controller) {
6
+ activeToastController = controller;
7
+ return () => {
8
+ if (activeToastController === controller) activeToastController = null;
9
+ };
10
+ }
11
+ function createToast(input) {
12
+ if (!activeToastController) throw new Error("createToast must be called after a ToastProvider has been mounted.");
13
+ return activeToastController.show(input);
14
+ }
15
+ function clearWaitingQueue() {
16
+ activeToastController?.clearWaitingQueue();
17
+ }
18
+ //#endregion
19
+ exports.clearWaitingQueue = clearWaitingQueue;
20
+ exports.createToast = createToast;
21
+ exports.setToastController = setToastController;
@@ -0,0 +1,10 @@
1
+
2
+ import { ToastController, ToastHandle, ToastShowInput } from "./types.cjs";
3
+
4
+ //#region src/components/Toast/createToast.d.ts
5
+ declare function setToastController(controller: ToastController): () => void;
6
+ declare function createToast(input: ToastShowInput): ToastHandle;
7
+ declare function clearWaitingQueue(): void;
8
+ //#endregion
9
+ export { clearWaitingQueue, createToast, setToastController };
10
+ //# sourceMappingURL=createToast.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createToast.d.cts","names":[],"sources":["../../../src/components/Toast/createToast.ts"],"mappings":";;;;iBAIS,kBAAA,CAAmB,UAAA,EAAY,eAAA;AAAA,iBAU/B,WAAA,CAAY,KAAA,EAAO,cAAA,GAAiB,WAAA;AAAA,iBAQpC,iBAAA,CAAA"}