@yahoo/uds-mobile 2.16.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/fixtures/dist/index.mjs +14 -0
- package/dist/bin/generateTheme.mjs +7 -2
- package/dist/bin/mobile/scripts/utils/configToRNMappings.mjs +4 -0
- package/dist/components/Popover/Popover.cjs +92 -0
- package/dist/components/Popover/Popover.d.cts +26 -0
- package/dist/components/Popover/Popover.d.cts.map +1 -0
- package/dist/components/Popover/Popover.d.ts +26 -0
- package/dist/components/Popover/Popover.d.ts.map +1 -0
- package/dist/components/Popover/Popover.js +92 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Popover/PopoverContent.cjs +124 -0
- package/dist/components/Popover/PopoverContent.d.cts +15 -0
- package/dist/components/Popover/PopoverContent.d.cts.map +1 -0
- package/dist/components/Popover/PopoverContent.d.ts +15 -0
- package/dist/components/Popover/PopoverContent.d.ts.map +1 -0
- package/dist/components/Popover/PopoverContent.js +124 -0
- package/dist/components/Popover/PopoverContent.js.map +1 -0
- package/dist/components/Popover/PopoverContext.cjs +14 -0
- package/dist/components/Popover/PopoverContext.d.cts +10 -0
- package/dist/components/Popover/PopoverContext.d.cts.map +1 -0
- package/dist/components/Popover/PopoverContext.d.ts +10 -0
- package/dist/components/Popover/PopoverContext.d.ts.map +1 -0
- package/dist/components/Popover/PopoverContext.js +13 -0
- package/dist/components/Popover/PopoverContext.js.map +1 -0
- package/dist/components/Popover/PopoverDescription.cjs +23 -0
- package/dist/components/Popover/PopoverDescription.d.cts +15 -0
- package/dist/components/Popover/PopoverDescription.d.cts.map +1 -0
- package/dist/components/Popover/PopoverDescription.d.ts +15 -0
- package/dist/components/Popover/PopoverDescription.d.ts.map +1 -0
- package/dist/components/Popover/PopoverDescription.js +23 -0
- package/dist/components/Popover/PopoverDescription.js.map +1 -0
- package/dist/components/Popover/PopoverDismiss.cjs +22 -0
- package/dist/components/Popover/PopoverDismiss.d.cts +15 -0
- package/dist/components/Popover/PopoverDismiss.d.cts.map +1 -0
- package/dist/components/Popover/PopoverDismiss.d.ts +15 -0
- package/dist/components/Popover/PopoverDismiss.d.ts.map +1 -0
- package/dist/components/Popover/PopoverDismiss.js +22 -0
- package/dist/components/Popover/PopoverDismiss.js.map +1 -0
- package/dist/components/Popover/PopoverFrame.cjs +56 -0
- package/dist/components/Popover/PopoverFrame.d.cts +23 -0
- package/dist/components/Popover/PopoverFrame.d.cts.map +1 -0
- package/dist/components/Popover/PopoverFrame.d.ts +23 -0
- package/dist/components/Popover/PopoverFrame.d.ts.map +1 -0
- package/dist/components/Popover/PopoverFrame.js +55 -0
- package/dist/components/Popover/PopoverFrame.js.map +1 -0
- package/dist/components/Popover/PopoverPortalLayer.cjs +45 -0
- package/dist/components/Popover/PopoverPortalLayer.d.cts +15 -0
- package/dist/components/Popover/PopoverPortalLayer.d.cts.map +1 -0
- package/dist/components/Popover/PopoverPortalLayer.d.ts +15 -0
- package/dist/components/Popover/PopoverPortalLayer.d.ts.map +1 -0
- package/dist/components/Popover/PopoverPortalLayer.js +45 -0
- package/dist/components/Popover/PopoverPortalLayer.js.map +1 -0
- package/dist/components/Popover/PopoverSurface.cjs +228 -0
- package/dist/components/Popover/PopoverSurface.d.cts +26 -0
- package/dist/components/Popover/PopoverSurface.d.cts.map +1 -0
- package/dist/components/Popover/PopoverSurface.d.ts +26 -0
- package/dist/components/Popover/PopoverSurface.d.ts.map +1 -0
- package/dist/components/Popover/PopoverSurface.js +227 -0
- package/dist/components/Popover/PopoverSurface.js.map +1 -0
- package/dist/components/Popover/PopoverTitle.cjs +23 -0
- package/dist/components/Popover/PopoverTitle.d.cts +15 -0
- package/dist/components/Popover/PopoverTitle.d.cts.map +1 -0
- package/dist/components/Popover/PopoverTitle.d.ts +15 -0
- package/dist/components/Popover/PopoverTitle.d.ts.map +1 -0
- package/dist/components/Popover/PopoverTitle.js +23 -0
- package/dist/components/Popover/PopoverTitle.js.map +1 -0
- package/dist/components/Popover/PopoverTrigger.cjs +88 -0
- package/dist/components/Popover/PopoverTrigger.d.cts +15 -0
- package/dist/components/Popover/PopoverTrigger.d.cts.map +1 -0
- package/dist/components/Popover/PopoverTrigger.d.ts +15 -0
- package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -0
- package/dist/components/Popover/PopoverTrigger.js +88 -0
- package/dist/components/Popover/PopoverTrigger.js.map +1 -0
- package/dist/components/Popover/index.cjs +14 -0
- package/dist/components/Popover/index.d.cts +9 -0
- package/dist/components/Popover/index.d.ts +9 -0
- package/dist/components/Popover/index.js +8 -0
- package/dist/components/Popover/popoverFrameGeometry.cjs +177 -0
- package/dist/components/Popover/popoverFrameGeometry.d.cts +48 -0
- package/dist/components/Popover/popoverFrameGeometry.d.cts.map +1 -0
- package/dist/components/Popover/popoverFrameGeometry.d.ts +48 -0
- package/dist/components/Popover/popoverFrameGeometry.d.ts.map +1 -0
- package/dist/components/Popover/popoverFrameGeometry.js +177 -0
- package/dist/components/Popover/popoverFrameGeometry.js.map +1 -0
- package/dist/components/Popover/popoverLayer.cjs +16 -0
- package/dist/components/Popover/popoverLayer.d.cts +8 -0
- package/dist/components/Popover/popoverLayer.d.cts.map +1 -0
- package/dist/components/Popover/popoverLayer.d.ts +8 -0
- package/dist/components/Popover/popoverLayer.d.ts.map +1 -0
- package/dist/components/Popover/popoverLayer.js +16 -0
- package/dist/components/Popover/popoverLayer.js.map +1 -0
- package/dist/components/Popover/types.cjs +1 -0
- package/dist/components/Popover/types.d.cts +170 -0
- package/dist/components/Popover/types.d.cts.map +1 -0
- package/dist/components/Popover/types.d.ts +170 -0
- package/dist/components/Popover/types.d.ts.map +1 -0
- package/dist/components/Popover/types.js +1 -0
- package/dist/components/Toast/Toast.cjs +141 -0
- package/dist/components/Toast/Toast.d.cts +38 -0
- package/dist/components/Toast/Toast.d.cts.map +1 -0
- package/dist/components/Toast/Toast.d.ts +38 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/Toast.js +141 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Toast/ToastAnimatedItem.cjs +88 -0
- package/dist/components/Toast/ToastAnimatedItem.d.cts +27 -0
- package/dist/components/Toast/ToastAnimatedItem.d.cts.map +1 -0
- package/dist/components/Toast/ToastAnimatedItem.d.ts +27 -0
- package/dist/components/Toast/ToastAnimatedItem.d.ts.map +1 -0
- package/dist/components/Toast/ToastAnimatedItem.js +87 -0
- package/dist/components/Toast/ToastAnimatedItem.js.map +1 -0
- package/dist/components/Toast/ToastItem.cjs +35 -0
- package/dist/components/Toast/ToastItem.d.cts +25 -0
- package/dist/components/Toast/ToastItem.d.cts.map +1 -0
- package/dist/components/Toast/ToastItem.d.ts +25 -0
- package/dist/components/Toast/ToastItem.d.ts.map +1 -0
- package/dist/components/Toast/ToastItem.js +35 -0
- package/dist/components/Toast/ToastItem.js.map +1 -0
- package/dist/components/Toast/ToastProvider.cjs +144 -0
- package/dist/components/Toast/ToastProvider.d.cts +58 -0
- package/dist/components/Toast/ToastProvider.d.cts.map +1 -0
- package/dist/components/Toast/ToastProvider.d.ts +58 -0
- package/dist/components/Toast/ToastProvider.d.ts.map +1 -0
- package/dist/components/Toast/ToastProvider.js +143 -0
- package/dist/components/Toast/ToastProvider.js.map +1 -0
- package/dist/components/Toast/ToastViewport.cjs +48 -0
- package/dist/components/Toast/ToastViewport.d.cts +42 -0
- package/dist/components/Toast/ToastViewport.d.cts.map +1 -0
- package/dist/components/Toast/ToastViewport.d.ts +42 -0
- package/dist/components/Toast/ToastViewport.d.ts.map +1 -0
- package/dist/components/Toast/ToastViewport.js +48 -0
- package/dist/components/Toast/ToastViewport.js.map +1 -0
- package/dist/components/Toast/createToast.cjs +21 -0
- package/dist/components/Toast/createToast.d.cts +10 -0
- package/dist/components/Toast/createToast.d.cts.map +1 -0
- package/dist/components/Toast/createToast.d.ts +10 -0
- package/dist/components/Toast/createToast.d.ts.map +1 -0
- package/dist/components/Toast/createToast.js +20 -0
- package/dist/components/Toast/createToast.js.map +1 -0
- package/dist/components/Toast/index.cjs +10 -0
- package/dist/components/Toast/index.d.cts +6 -0
- package/dist/components/Toast/index.d.ts +6 -0
- package/dist/components/Toast/index.js +5 -0
- package/dist/components/Toast/types.cjs +1 -0
- package/dist/components/Toast/types.d.cts +113 -0
- package/dist/components/Toast/types.d.cts.map +1 -0
- package/dist/components/Toast/types.d.ts +113 -0
- package/dist/components/Toast/types.d.ts.map +1 -0
- package/dist/components/Toast/types.js +1 -0
- package/dist/components/Toast/useToastController.cjs +286 -0
- package/dist/components/Toast/useToastController.d.cts +25 -0
- package/dist/components/Toast/useToastController.d.cts.map +1 -0
- package/dist/components/Toast/useToastController.d.ts +25 -0
- package/dist/components/Toast/useToastController.d.ts.map +1 -0
- package/dist/components/Toast/useToastController.js +286 -0
- package/dist/components/Toast/useToastController.js.map +1 -0
- package/dist/components/Toast/utils.cjs +69 -0
- package/dist/components/Toast/utils.d.cts +27 -0
- package/dist/components/Toast/utils.d.cts.map +1 -0
- package/dist/components/Toast/utils.d.ts +27 -0
- package/dist/components/Toast/utils.d.ts.map +1 -0
- package/dist/components/Toast/utils.js +55 -0
- package/dist/components/Toast/utils.js.map +1 -0
- package/dist/components/internal/Overlay/index.cjs +4 -0
- package/dist/components/internal/Overlay/index.d.cts +4 -2
- package/dist/components/internal/Overlay/index.d.ts +4 -2
- package/dist/components/internal/Overlay/index.js +3 -1
- package/dist/components/internal/Overlay/types.d.cts +47 -1
- package/dist/components/internal/Overlay/types.d.cts.map +1 -1
- package/dist/components/internal/Overlay/types.d.ts +47 -1
- package/dist/components/internal/Overlay/types.d.ts.map +1 -1
- package/dist/components/internal/Overlay/useAnchoredPosition.cjs +225 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.cts +22 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.cts.map +1 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.ts +22 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.ts.map +1 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.js +225 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.js.map +1 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.cjs +22 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.cts +12 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.cts.map +1 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.ts +12 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.ts.map +1 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.js +22 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.js.map +1 -0
- package/dist/jest/mocks/gesture-handler.cjs +38 -0
- package/dist/jest/mocks/gesture-handler.d.cts +41 -0
- package/dist/jest/mocks/gesture-handler.d.cts.map +1 -0
- package/dist/jest/mocks/gesture-handler.d.ts +41 -0
- package/dist/jest/mocks/gesture-handler.d.ts.map +1 -0
- package/dist/jest/mocks/gesture-handler.js +37 -0
- package/dist/jest/mocks/gesture-handler.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +14 -0
- package/dist/jest/mocks/react-native.d.cts +29 -1
- package/dist/jest/mocks/react-native.d.cts.map +1 -1
- package/dist/jest/mocks/react-native.d.ts +29 -1
- package/dist/jest/mocks/react-native.d.ts.map +1 -1
- package/dist/jest/mocks/react-native.js +13 -1
- package/dist/jest/mocks/react-native.js.map +1 -1
- package/dist/jest/mocks/safe-area-context.cjs +35 -0
- package/dist/jest/mocks/safe-area-context.d.cts +43 -0
- package/dist/jest/mocks/safe-area-context.d.cts.map +1 -0
- package/dist/jest/mocks/safe-area-context.d.ts +43 -0
- package/dist/jest/mocks/safe-area-context.d.ts.map +1 -0
- package/dist/jest/mocks/safe-area-context.js +32 -0
- package/dist/jest/mocks/safe-area-context.js.map +1 -0
- package/dist/jest/mocks/screens.cjs +8 -0
- package/dist/jest/mocks/screens.d.cts +12 -0
- package/dist/jest/mocks/screens.d.cts.map +1 -0
- package/dist/jest/mocks/screens.d.ts +12 -0
- package/dist/jest/mocks/screens.d.ts.map +1 -0
- package/dist/jest/mocks/screens.js +9 -0
- package/dist/jest/mocks/screens.js.map +1 -0
- package/dist/jest/mocks/styles.cjs +98 -1
- package/dist/jest/mocks/styles.d.cts +6 -2
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts +6 -2
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +95 -2
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/jest/setup.cjs +46 -3
- package/dist/jest/setup.d.cts.map +1 -1
- package/dist/jest/setup.d.ts.map +1 -1
- package/dist/jest/setup.js +46 -3
- package/dist/jest/setup.js.map +1 -1
- package/dist/types/dist/index.d.cts +4 -1
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts +4 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/fonts/index.cjs +211 -211
- package/fonts/index.mjs +211 -211
- package/generated/styles.cjs +6 -0
- package/generated/styles.d.ts +13 -1
- package/generated/styles.mjs +6 -0
- package/generated/unistyles.d.ts +13 -0
- package/package.json +21 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import { ToastController, ToastRecord } from "./types.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Toast/ToastItem.d.ts
|
|
6
|
+
interface ToastItemProps {
|
|
7
|
+
toast: ToastRecord;
|
|
8
|
+
hide: ToastController['hide'];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Internal adapter from a ToastRecord to the public Toast renderer.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* ToastItem removes provider-only fields from a toast record, wires action and
|
|
15
|
+
* close callbacks to the toast controller, and passes renderable props to Toast.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
declare function ToastItem({
|
|
20
|
+
toast,
|
|
21
|
+
hide
|
|
22
|
+
}: ToastItemProps): _$react.JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ToastItem };
|
|
25
|
+
//# sourceMappingURL=ToastItem.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastItem.d.cts","names":[],"sources":["../../../src/components/Toast/ToastItem.tsx"],"mappings":";;;;;UAGU,cAAA;EACR,KAAA,EAAO,WAAA;EACP,IAAA,EAAM,eAAA;AAAA;;;;;;;;;;iBAYC,SAAA,CAAA;EAAY,KAAA;EAAO;AAAA,GAAQ,cAAA,GAAc,OAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import { ToastController, ToastRecord } from "./types.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Toast/ToastItem.d.ts
|
|
6
|
+
interface ToastItemProps {
|
|
7
|
+
toast: ToastRecord;
|
|
8
|
+
hide: ToastController['hide'];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Internal adapter from a ToastRecord to the public Toast renderer.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* ToastItem removes provider-only fields from a toast record, wires action and
|
|
15
|
+
* close callbacks to the toast controller, and passes renderable props to Toast.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
declare function ToastItem({
|
|
20
|
+
toast,
|
|
21
|
+
hide
|
|
22
|
+
}: ToastItemProps): _$react.JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ToastItem };
|
|
25
|
+
//# sourceMappingURL=ToastItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastItem.d.ts","names":[],"sources":["../../../src/components/Toast/ToastItem.tsx"],"mappings":";;;;;UAGU,cAAA;EACR,KAAA,EAAO,WAAA;EACP,IAAA,EAAM,eAAA;AAAA;;;;;;;;;;iBAYC,SAAA,CAAA;EAAY,KAAA;EAAO;AAAA,GAAQ,cAAA,GAAc,OAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { Toast } from "./Toast.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Toast/ToastItem.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Internal adapter from a ToastRecord to the public Toast renderer.
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* ToastItem removes provider-only fields from a toast record, wires action and
|
|
10
|
+
* close callbacks to the toast controller, and passes renderable props to Toast.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function ToastItem({ toast, hide }) {
|
|
15
|
+
const { closeOnAction, createdAt: _createdAt, autoClose: _autoClose, isExiting: _isExiting, onActionPress, onClickActionButton, onClickCloseButton, onClose, onHide: _onHide, onShow: _onShow, placement: _placement, ...toastProps } = toast;
|
|
16
|
+
const handleActionPress = () => {
|
|
17
|
+
onActionPress?.();
|
|
18
|
+
onClickActionButton?.();
|
|
19
|
+
if (closeOnAction) hide(toast.id);
|
|
20
|
+
};
|
|
21
|
+
const handleClose = (id) => {
|
|
22
|
+
onClose?.(id);
|
|
23
|
+
onClickCloseButton?.(id);
|
|
24
|
+
hide(toast.id);
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ jsx(Toast, {
|
|
27
|
+
...toastProps,
|
|
28
|
+
onActionPress: handleActionPress,
|
|
29
|
+
onClose: handleClose
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ToastItem };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=ToastItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastItem.js","names":[],"sources":["../../../src/components/Toast/ToastItem.tsx"],"sourcesContent":["import { Toast } from './Toast';\nimport type { ToastController, ToastRecord } from './types';\n\ninterface ToastItemProps {\n toast: ToastRecord;\n hide: ToastController['hide'];\n}\n\n/**\n * Internal adapter from a ToastRecord to the public Toast renderer.\n *\n * @description\n * ToastItem removes provider-only fields from a toast record, wires action and\n * close callbacks to the toast controller, and passes renderable props to Toast.\n *\n * @internal\n */\nfunction ToastItem({ toast, hide }: ToastItemProps) {\n const {\n closeOnAction,\n createdAt: _createdAt,\n autoClose: _autoClose,\n isExiting: _isExiting,\n onActionPress,\n onClickActionButton,\n onClickCloseButton,\n onClose,\n onHide: _onHide,\n onShow: _onShow,\n placement: _placement,\n ...toastProps\n } = toast;\n\n const handleActionPress = () => {\n onActionPress?.();\n onClickActionButton?.();\n\n if (closeOnAction) {\n hide(toast.id);\n }\n };\n\n const handleClose = (id?: string) => {\n onClose?.(id);\n onClickCloseButton?.(id);\n hide(toast.id);\n };\n\n return <Toast {...toastProps} onActionPress={handleActionPress} onClose={handleClose} />;\n}\n\nexport { ToastItem };\n"],"mappings":";;;;;;;;;;;;;AAiBA,SAAS,UAAU,EAAE,OAAO,QAAwB;CAClD,MAAM,EACJ,eACA,WAAW,YACX,WAAW,YACX,WAAW,YACX,eACA,qBACA,oBACA,SACA,QAAQ,SACR,QAAQ,SACR,WAAW,YACX,GAAG,eACD;CAEJ,MAAM,0BAA0B;EAC9B,iBAAiB;EACjB,uBAAuB;EAEvB,IAAI,eACF,KAAK,MAAM,GAAG;;CAIlB,MAAM,eAAe,OAAgB;EACnC,UAAU,GAAG;EACb,qBAAqB,GAAG;EACxB,KAAK,MAAM,GAAG;;CAGhB,OAAO,oBAAC,OAAD;EAAO,GAAI;EAAY,eAAe;EAAmB,SAAS;EAAe,CAAA"}
|
|
@@ -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_internal_Overlay_OverlayPortal = require("../internal/Overlay/OverlayPortal.cjs");
|
|
5
|
+
const require_components_Toast_utils = require("./utils.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 { OverlayPortal } from "../internal/Overlay/OverlayPortal.js";
|
|
3
|
+
import { DEFAULT_TOAST_AUTO_CLOSE, DEFAULT_TOAST_INSETS, DEFAULT_TOAST_PLACEMENT } from "./utils.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"}
|