@oxyhq/bloom 0.50.2 → 0.51.1
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/NOTICE +89 -0
- package/README.md +12 -7
- package/lib/commonjs/avatar-group/AvatarGroup.web.js +2 -1
- package/lib/commonjs/avatar-group/AvatarGroup.web.js.map +1 -1
- package/lib/commonjs/bottom-sheet/index.web.js +2 -1
- package/lib/commonjs/bottom-sheet/index.web.js.map +1 -1
- package/lib/commonjs/context-menu/index.web.js +3 -2
- package/lib/commonjs/context-menu/index.web.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +4 -3
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/frosted-icon-button/shared.js +1 -1
- package/lib/commonjs/index.js +90 -83
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +116 -109
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/menu/index.web.js +2 -1
- package/lib/commonjs/menu/index.web.js.map +1 -1
- package/lib/commonjs/popover/index.web.js +3 -2
- package/lib/commonjs/popover/index.web.js.map +1 -1
- package/lib/commonjs/portal/index.js +4 -1
- package/lib/commonjs/portal/index.js.map +1 -1
- package/lib/commonjs/progressive-blur/index.js +79 -0
- package/lib/commonjs/progressive-blur/index.js.map +1 -0
- package/lib/commonjs/progressive-blur/index.web.js +67 -0
- package/lib/commonjs/progressive-blur/index.web.js.map +1 -0
- package/lib/commonjs/progressive-blur/shared.js +66 -0
- package/lib/commonjs/progressive-blur/shared.js.map +1 -0
- package/lib/commonjs/progressive-blur/types.js +6 -0
- package/lib/commonjs/progressive-blur/types.js.map +1 -0
- package/lib/commonjs/select/index.web.js +2 -1
- package/lib/commonjs/select/index.web.js.map +1 -1
- package/lib/commonjs/styles/web-view-style.js +26 -0
- package/lib/commonjs/styles/web-view-style.js.map +1 -0
- package/lib/commonjs/tab-bar/TabBarBase.js +415 -0
- package/lib/commonjs/tab-bar/TabBarBase.js.map +1 -0
- package/lib/commonjs/tab-bar/expo-router/RouterTabBar.js +83 -0
- package/lib/commonjs/tab-bar/expo-router/RouterTabBar.js.map +1 -0
- package/lib/commonjs/tab-bar/expo-router/fading-tab-screen.js +119 -0
- package/lib/commonjs/tab-bar/expo-router/fading-tab-screen.js.map +1 -0
- package/lib/commonjs/tab-bar/expo-router/index.js +26 -0
- package/lib/commonjs/tab-bar/expo-router/index.js.map +1 -0
- package/lib/commonjs/tab-bar/glyph.js +43 -0
- package/lib/commonjs/tab-bar/glyph.js.map +1 -0
- package/lib/commonjs/tab-bar/glyph.native.js +55 -0
- package/lib/commonjs/tab-bar/glyph.native.js.map +1 -0
- package/lib/commonjs/tab-bar/index.js +65 -0
- package/lib/commonjs/tab-bar/index.js.map +1 -0
- package/lib/commonjs/tab-bar/index.web.js +67 -0
- package/lib/commonjs/tab-bar/index.web.js.map +1 -0
- package/lib/commonjs/tab-bar/minimize-context.js +127 -0
- package/lib/commonjs/tab-bar/minimize-context.js.map +1 -0
- package/lib/commonjs/tab-bar/shared.js +139 -0
- package/lib/commonjs/tab-bar/shared.js.map +1 -0
- package/lib/commonjs/tab-bar/surface-solid.js +43 -0
- package/lib/commonjs/tab-bar/surface-solid.js.map +1 -0
- package/lib/commonjs/tab-bar/surface.js +13 -0
- package/lib/commonjs/tab-bar/surface.js.map +1 -0
- package/lib/commonjs/tab-bar/surface.native.js +113 -0
- package/lib/commonjs/tab-bar/surface.native.js.map +1 -0
- package/lib/commonjs/tab-bar/surface.web.js +59 -0
- package/lib/commonjs/tab-bar/surface.web.js.map +1 -0
- package/lib/commonjs/tab-bar/types.js +6 -0
- package/lib/commonjs/tab-bar/types.js.map +1 -0
- package/lib/commonjs/toast/Positioner.js +117 -0
- package/lib/commonjs/toast/Positioner.js.map +1 -0
- package/lib/commonjs/toast/ToastContent.js +301 -0
- package/lib/commonjs/toast/ToastContent.js.map +1 -0
- package/lib/commonjs/toast/ToastHost.js +69 -0
- package/lib/commonjs/toast/ToastHost.js.map +1 -0
- package/lib/commonjs/toast/ToastHost.native.js +44 -0
- package/lib/commonjs/toast/ToastHost.native.js.map +1 -0
- package/lib/commonjs/toast/ToastIcon.js +57 -0
- package/lib/commonjs/toast/ToastIcon.js.map +1 -0
- package/lib/commonjs/toast/ToastRow.js +411 -0
- package/lib/commonjs/toast/ToastRow.js.map +1 -0
- package/lib/commonjs/toast/ToastSwipeHandler.js +189 -0
- package/lib/commonjs/toast/ToastSwipeHandler.js.map +1 -0
- package/lib/commonjs/toast/Toaster.js +205 -0
- package/lib/commonjs/toast/Toaster.js.map +1 -0
- package/lib/commonjs/toast/animations.js +274 -0
- package/lib/commonjs/toast/animations.js.map +1 -0
- package/lib/commonjs/toast/constants.js +56 -0
- package/lib/commonjs/toast/constants.js.map +1 -0
- package/lib/commonjs/toast/context.js +42 -0
- package/lib/commonjs/toast/context.js.map +1 -0
- package/lib/commonjs/toast/index.js +32 -126
- package/lib/commonjs/toast/index.js.map +1 -1
- package/lib/commonjs/toast/position-utils.js +115 -0
- package/lib/commonjs/toast/position-utils.js.map +1 -0
- package/lib/commonjs/toast/positioner-utils.js +141 -0
- package/lib/commonjs/toast/positioner-utils.js.map +1 -0
- package/lib/commonjs/toast/toast-comparator.js +28 -0
- package/lib/commonjs/toast/toast-comparator.js.map +1 -0
- package/lib/commonjs/toast/toast-fns.js +90 -0
- package/lib/commonjs/toast/toast-fns.js.map +1 -0
- package/lib/commonjs/toast/toast-store.js +352 -0
- package/lib/commonjs/toast/toast-store.js.map +1 -0
- package/lib/commonjs/toast/toast-timers.js +110 -0
- package/lib/commonjs/toast/toast-timers.js.map +1 -0
- package/lib/commonjs/toast/types.js +42 -0
- package/lib/commonjs/toast/types.js.map +1 -1
- package/lib/commonjs/toast/use-animated-target.js +57 -0
- package/lib/commonjs/toast/use-animated-target.js.map +1 -0
- package/lib/commonjs/toast/use-app-state.js +76 -0
- package/lib/commonjs/toast/use-app-state.js.map +1 -0
- package/lib/commonjs/toast/use-toast-colors.js +114 -0
- package/lib/commonjs/toast/use-toast-colors.js.map +1 -0
- package/lib/commonjs/toast/use-toast-position.js +40 -0
- package/lib/commonjs/toast/use-toast-position.js.map +1 -0
- package/lib/commonjs/tooltip/index.web.js +2 -1
- package/lib/commonjs/tooltip/index.web.js.map +1 -1
- package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js +20 -8
- package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
- package/lib/module/avatar-group/AvatarGroup.web.js +2 -1
- package/lib/module/avatar-group/AvatarGroup.web.js.map +1 -1
- package/lib/module/bottom-sheet/index.web.js +2 -1
- package/lib/module/bottom-sheet/index.web.js.map +1 -1
- package/lib/module/context-menu/index.web.js +3 -2
- package/lib/module/context-menu/index.web.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +4 -3
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/frosted-icon-button/shared.js +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +3 -2
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/menu/index.web.js +2 -1
- package/lib/module/menu/index.web.js.map +1 -1
- package/lib/module/popover/index.web.js +3 -2
- package/lib/module/popover/index.web.js.map +1 -1
- package/lib/module/portal/index.js +4 -1
- package/lib/module/portal/index.js.map +1 -1
- package/lib/module/progressive-blur/index.js +74 -0
- package/lib/module/progressive-blur/index.js.map +1 -0
- package/lib/module/progressive-blur/index.web.js +62 -0
- package/lib/module/progressive-blur/index.web.js.map +1 -0
- package/lib/module/progressive-blur/shared.js +60 -0
- package/lib/module/progressive-blur/shared.js.map +1 -0
- package/lib/module/progressive-blur/types.js +4 -0
- package/lib/module/progressive-blur/types.js.map +1 -0
- package/lib/module/select/index.web.js +2 -1
- package/lib/module/select/index.web.js.map +1 -1
- package/lib/module/styles/web-view-style.js +22 -0
- package/lib/module/styles/web-view-style.js.map +1 -0
- package/lib/module/tab-bar/TabBarBase.js +408 -0
- package/lib/module/tab-bar/TabBarBase.js.map +1 -0
- package/lib/module/tab-bar/expo-router/RouterTabBar.js +78 -0
- package/lib/module/tab-bar/expo-router/RouterTabBar.js.map +1 -0
- package/lib/module/tab-bar/expo-router/fading-tab-screen.js +113 -0
- package/lib/module/tab-bar/expo-router/fading-tab-screen.js.map +1 -0
- package/lib/module/tab-bar/expo-router/index.js +15 -0
- package/lib/module/tab-bar/expo-router/index.js.map +1 -0
- package/lib/module/tab-bar/glyph.js +38 -0
- package/lib/module/tab-bar/glyph.js.map +1 -0
- package/lib/module/tab-bar/glyph.native.js +50 -0
- package/lib/module/tab-bar/glyph.native.js.map +1 -0
- package/lib/module/tab-bar/index.js +24 -0
- package/lib/module/tab-bar/index.js.map +1 -0
- package/lib/module/tab-bar/index.web.js +26 -0
- package/lib/module/tab-bar/index.web.js.map +1 -0
- package/lib/module/tab-bar/minimize-context.js +118 -0
- package/lib/module/tab-bar/minimize-context.js.map +1 -0
- package/lib/module/tab-bar/shared.js +132 -0
- package/lib/module/tab-bar/shared.js.map +1 -0
- package/lib/module/tab-bar/surface-solid.js +37 -0
- package/lib/module/tab-bar/surface-solid.js.map +1 -0
- package/lib/module/tab-bar/surface.js +31 -0
- package/lib/module/tab-bar/surface.js.map +1 -0
- package/lib/module/tab-bar/surface.native.js +109 -0
- package/lib/module/tab-bar/surface.native.js.map +1 -0
- package/lib/module/tab-bar/surface.web.js +53 -0
- package/lib/module/tab-bar/surface.web.js.map +1 -0
- package/lib/module/tab-bar/types.js +4 -0
- package/lib/module/tab-bar/types.js.map +1 -0
- package/lib/module/toast/Positioner.js +110 -0
- package/lib/module/toast/Positioner.js.map +1 -0
- package/lib/module/toast/ToastContent.js +295 -0
- package/lib/module/toast/ToastContent.js.map +1 -0
- package/lib/module/toast/ToastHost.js +63 -0
- package/lib/module/toast/ToastHost.js.map +1 -0
- package/lib/module/toast/ToastHost.native.js +38 -0
- package/lib/module/toast/ToastHost.native.js.map +1 -0
- package/lib/module/toast/ToastIcon.js +52 -0
- package/lib/module/toast/ToastIcon.js.map +1 -0
- package/lib/module/toast/ToastRow.js +407 -0
- package/lib/module/toast/ToastRow.js.map +1 -0
- package/lib/module/toast/ToastSwipeHandler.js +182 -0
- package/lib/module/toast/ToastSwipeHandler.js.map +1 -0
- package/lib/module/toast/Toaster.js +198 -0
- package/lib/module/toast/Toaster.js.map +1 -0
- package/lib/module/toast/animations.js +261 -0
- package/lib/module/toast/animations.js.map +1 -0
- package/lib/module/toast/constants.js +52 -0
- package/lib/module/toast/constants.js.map +1 -0
- package/lib/module/toast/context.js +34 -0
- package/lib/module/toast/context.js.map +1 -0
- package/lib/module/toast/index.js +27 -103
- package/lib/module/toast/index.js.map +1 -1
- package/lib/module/toast/position-utils.js +107 -0
- package/lib/module/toast/position-utils.js.map +1 -0
- package/lib/module/toast/positioner-utils.js +134 -0
- package/lib/module/toast/positioner-utils.js.map +1 -0
- package/lib/module/toast/toast-comparator.js +22 -0
- package/lib/module/toast/toast-comparator.js.map +1 -0
- package/lib/module/toast/toast-fns.js +85 -0
- package/lib/module/toast/toast-fns.js.map +1 -0
- package/lib/module/toast/toast-store.js +346 -0
- package/lib/module/toast/toast-store.js.map +1 -0
- package/lib/module/toast/toast-timers.js +104 -0
- package/lib/module/toast/toast-timers.js.map +1 -0
- package/lib/module/toast/types.js +38 -0
- package/lib/module/toast/types.js.map +1 -1
- package/lib/module/toast/use-animated-target.js +52 -0
- package/lib/module/toast/use-animated-target.js.map +1 -0
- package/lib/module/toast/use-app-state.js +70 -0
- package/lib/module/toast/use-app-state.js.map +1 -0
- package/lib/module/toast/use-toast-colors.js +109 -0
- package/lib/module/toast/use-toast-colors.js.map +1 -0
- package/lib/module/toast/use-toast-position.js +35 -0
- package/lib/module/toast/use-toast-position.js.map +1 -0
- package/lib/module/tooltip/index.web.js +2 -1
- package/lib/module/tooltip/index.web.js.map +1 -1
- package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js +20 -8
- package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
- package/lib/typescript/commonjs/avatar-group/AvatarGroup.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/benefit-list/types.d.ts +2 -1
- package/lib/typescript/commonjs/benefit-list/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/bottom-sheet/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/context-menu/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/fab/types.d.ts +4 -2
- package/lib/typescript/commonjs/fab/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/frosted-icon-button/shared.d.ts +1 -1
- package/lib/typescript/commonjs/frosted-icon-button/types.d.ts +2 -1
- package/lib/typescript/commonjs/frosted-icon-button/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +2 -1
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/menu/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/portal/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/progressive-blur/index.d.ts +23 -0
- package/lib/typescript/commonjs/progressive-blur/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/progressive-blur/index.web.d.ts +30 -0
- package/lib/typescript/commonjs/progressive-blur/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/progressive-blur/shared.d.ts +35 -0
- package/lib/typescript/commonjs/progressive-blur/shared.d.ts.map +1 -0
- package/lib/typescript/commonjs/progressive-blur/types.d.ts +21 -0
- package/lib/typescript/commonjs/progressive-blur/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/select/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/styles/web-view-style.d.ts +21 -0
- package/lib/typescript/commonjs/styles/web-view-style.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/TabBarBase.d.ts +36 -0
- package/lib/typescript/commonjs/tab-bar/TabBarBase.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/expo-router/RouterTabBar.d.ts +59 -0
- package/lib/typescript/commonjs/tab-bar/expo-router/RouterTabBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/expo-router/fading-tab-screen.d.ts +11 -0
- package/lib/typescript/commonjs/tab-bar/expo-router/fading-tab-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/expo-router/index.d.ts +14 -0
- package/lib/typescript/commonjs/tab-bar/expo-router/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/glyph.d.ts +6 -0
- package/lib/typescript/commonjs/tab-bar/glyph.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/glyph.native.d.ts +6 -0
- package/lib/typescript/commonjs/tab-bar/glyph.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/index.d.ts +12 -0
- package/lib/typescript/commonjs/tab-bar/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/index.web.d.ts +12 -0
- package/lib/typescript/commonjs/tab-bar/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/minimize-context.d.ts +51 -0
- package/lib/typescript/commonjs/tab-bar/minimize-context.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/shared.d.ts +93 -0
- package/lib/typescript/commonjs/tab-bar/shared.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/surface-solid.d.ts +6 -0
- package/lib/typescript/commonjs/tab-bar/surface-solid.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/surface.d.ts +29 -0
- package/lib/typescript/commonjs/tab-bar/surface.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/surface.native.d.ts +6 -0
- package/lib/typescript/commonjs/tab-bar/surface.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/surface.web.d.ts +6 -0
- package/lib/typescript/commonjs/tab-bar/surface.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/tab-bar/types.d.ts +88 -0
- package/lib/typescript/commonjs/tab-bar/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/Positioner.d.ts +21 -0
- package/lib/typescript/commonjs/toast/Positioner.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/ToastContent.d.ts +14 -0
- package/lib/typescript/commonjs/toast/ToastContent.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/ToastHost.d.ts +6 -0
- package/lib/typescript/commonjs/toast/ToastHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/ToastHost.native.d.ts +6 -0
- package/lib/typescript/commonjs/toast/ToastHost.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/ToastIcon.d.ts +9 -0
- package/lib/typescript/commonjs/toast/ToastIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/ToastRow.d.ts +80 -0
- package/lib/typescript/commonjs/toast/ToastRow.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/ToastSwipeHandler.d.ts +30 -0
- package/lib/typescript/commonjs/toast/ToastSwipeHandler.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/Toaster.d.ts +19 -0
- package/lib/typescript/commonjs/toast/Toaster.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/animations.d.ts +62 -0
- package/lib/typescript/commonjs/toast/animations.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/constants.d.ts +39 -0
- package/lib/typescript/commonjs/toast/constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/context.d.ts +19 -0
- package/lib/typescript/commonjs/toast/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/index.d.ts +23 -76
- package/lib/typescript/commonjs/toast/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/position-utils.d.ts +30 -0
- package/lib/typescript/commonjs/toast/position-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/positioner-utils.d.ts +72 -0
- package/lib/typescript/commonjs/toast/positioner-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/toast-comparator.d.ts +12 -0
- package/lib/typescript/commonjs/toast/toast-comparator.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/toast-fns.d.ts +3 -0
- package/lib/typescript/commonjs/toast/toast-fns.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/toast-store.d.ts +52 -0
- package/lib/typescript/commonjs/toast/toast-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/toast-timers.d.ts +24 -0
- package/lib/typescript/commonjs/toast/toast-timers.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/types.d.ts +222 -5
- package/lib/typescript/commonjs/toast/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/use-animated-target.d.ts +7 -0
- package/lib/typescript/commonjs/toast/use-animated-target.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/use-app-state.d.ts +18 -0
- package/lib/typescript/commonjs/toast/use-app-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/use-toast-colors.d.ts +22 -0
- package/lib/typescript/commonjs/toast/use-toast-colors.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/use-toast-position.d.ts +37 -0
- package/lib/typescript/commonjs/toast/use-toast-position.d.ts.map +1 -0
- package/lib/typescript/commonjs/tooltip/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
- package/lib/typescript/module/avatar-group/AvatarGroup.web.d.ts.map +1 -1
- package/lib/typescript/module/benefit-list/types.d.ts +2 -1
- package/lib/typescript/module/benefit-list/types.d.ts.map +1 -1
- package/lib/typescript/module/bottom-sheet/index.web.d.ts.map +1 -1
- package/lib/typescript/module/context-menu/index.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/fab/types.d.ts +4 -2
- package/lib/typescript/module/fab/types.d.ts.map +1 -1
- package/lib/typescript/module/frosted-icon-button/shared.d.ts +1 -1
- package/lib/typescript/module/frosted-icon-button/types.d.ts +2 -1
- package/lib/typescript/module/frosted-icon-button/types.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +2 -1
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/menu/index.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/module/portal/index.d.ts.map +1 -1
- package/lib/typescript/module/progressive-blur/index.d.ts +23 -0
- package/lib/typescript/module/progressive-blur/index.d.ts.map +1 -0
- package/lib/typescript/module/progressive-blur/index.web.d.ts +30 -0
- package/lib/typescript/module/progressive-blur/index.web.d.ts.map +1 -0
- package/lib/typescript/module/progressive-blur/shared.d.ts +35 -0
- package/lib/typescript/module/progressive-blur/shared.d.ts.map +1 -0
- package/lib/typescript/module/progressive-blur/types.d.ts +21 -0
- package/lib/typescript/module/progressive-blur/types.d.ts.map +1 -0
- package/lib/typescript/module/select/index.web.d.ts.map +1 -1
- package/lib/typescript/module/styles/web-view-style.d.ts +21 -0
- package/lib/typescript/module/styles/web-view-style.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/TabBarBase.d.ts +36 -0
- package/lib/typescript/module/tab-bar/TabBarBase.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/expo-router/RouterTabBar.d.ts +59 -0
- package/lib/typescript/module/tab-bar/expo-router/RouterTabBar.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/expo-router/fading-tab-screen.d.ts +11 -0
- package/lib/typescript/module/tab-bar/expo-router/fading-tab-screen.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/expo-router/index.d.ts +14 -0
- package/lib/typescript/module/tab-bar/expo-router/index.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/glyph.d.ts +6 -0
- package/lib/typescript/module/tab-bar/glyph.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/glyph.native.d.ts +6 -0
- package/lib/typescript/module/tab-bar/glyph.native.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/index.d.ts +12 -0
- package/lib/typescript/module/tab-bar/index.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/index.web.d.ts +12 -0
- package/lib/typescript/module/tab-bar/index.web.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/minimize-context.d.ts +51 -0
- package/lib/typescript/module/tab-bar/minimize-context.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/shared.d.ts +93 -0
- package/lib/typescript/module/tab-bar/shared.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/surface-solid.d.ts +6 -0
- package/lib/typescript/module/tab-bar/surface-solid.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/surface.d.ts +29 -0
- package/lib/typescript/module/tab-bar/surface.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/surface.native.d.ts +6 -0
- package/lib/typescript/module/tab-bar/surface.native.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/surface.web.d.ts +6 -0
- package/lib/typescript/module/tab-bar/surface.web.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/types.d.ts +88 -0
- package/lib/typescript/module/tab-bar/types.d.ts.map +1 -0
- package/lib/typescript/module/toast/Positioner.d.ts +21 -0
- package/lib/typescript/module/toast/Positioner.d.ts.map +1 -0
- package/lib/typescript/module/toast/ToastContent.d.ts +14 -0
- package/lib/typescript/module/toast/ToastContent.d.ts.map +1 -0
- package/lib/typescript/module/toast/ToastHost.d.ts +6 -0
- package/lib/typescript/module/toast/ToastHost.d.ts.map +1 -0
- package/lib/typescript/module/toast/ToastHost.native.d.ts +6 -0
- package/lib/typescript/module/toast/ToastHost.native.d.ts.map +1 -0
- package/lib/typescript/module/toast/ToastIcon.d.ts +9 -0
- package/lib/typescript/module/toast/ToastIcon.d.ts.map +1 -0
- package/lib/typescript/module/toast/ToastRow.d.ts +80 -0
- package/lib/typescript/module/toast/ToastRow.d.ts.map +1 -0
- package/lib/typescript/module/toast/ToastSwipeHandler.d.ts +30 -0
- package/lib/typescript/module/toast/ToastSwipeHandler.d.ts.map +1 -0
- package/lib/typescript/module/toast/Toaster.d.ts +19 -0
- package/lib/typescript/module/toast/Toaster.d.ts.map +1 -0
- package/lib/typescript/module/toast/animations.d.ts +62 -0
- package/lib/typescript/module/toast/animations.d.ts.map +1 -0
- package/lib/typescript/module/toast/constants.d.ts +39 -0
- package/lib/typescript/module/toast/constants.d.ts.map +1 -0
- package/lib/typescript/module/toast/context.d.ts +19 -0
- package/lib/typescript/module/toast/context.d.ts.map +1 -0
- package/lib/typescript/module/toast/index.d.ts +23 -76
- package/lib/typescript/module/toast/index.d.ts.map +1 -1
- package/lib/typescript/module/toast/position-utils.d.ts +30 -0
- package/lib/typescript/module/toast/position-utils.d.ts.map +1 -0
- package/lib/typescript/module/toast/positioner-utils.d.ts +72 -0
- package/lib/typescript/module/toast/positioner-utils.d.ts.map +1 -0
- package/lib/typescript/module/toast/toast-comparator.d.ts +12 -0
- package/lib/typescript/module/toast/toast-comparator.d.ts.map +1 -0
- package/lib/typescript/module/toast/toast-fns.d.ts +3 -0
- package/lib/typescript/module/toast/toast-fns.d.ts.map +1 -0
- package/lib/typescript/module/toast/toast-store.d.ts +52 -0
- package/lib/typescript/module/toast/toast-store.d.ts.map +1 -0
- package/lib/typescript/module/toast/toast-timers.d.ts +24 -0
- package/lib/typescript/module/toast/toast-timers.d.ts.map +1 -0
- package/lib/typescript/module/toast/types.d.ts +222 -5
- package/lib/typescript/module/toast/types.d.ts.map +1 -1
- package/lib/typescript/module/toast/use-animated-target.d.ts +7 -0
- package/lib/typescript/module/toast/use-animated-target.d.ts.map +1 -0
- package/lib/typescript/module/toast/use-app-state.d.ts +18 -0
- package/lib/typescript/module/toast/use-app-state.d.ts.map +1 -0
- package/lib/typescript/module/toast/use-toast-colors.d.ts +22 -0
- package/lib/typescript/module/toast/use-toast-colors.d.ts.map +1 -0
- package/lib/typescript/module/toast/use-toast-position.d.ts +37 -0
- package/lib/typescript/module/toast/use-toast-position.d.ts.map +1 -0
- package/lib/typescript/module/tooltip/index.web.d.ts.map +1 -1
- package/lib/typescript/module/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
- package/package.json +58 -26
- package/src/__tests__/TabBar.test.tsx +342 -0
- package/src/__tests__/TabBarGlassFallback.test.tsx +234 -0
- package/src/__tests__/TabBarReanimatedDeps.test.ts +130 -0
- package/src/__tests__/TabBarWebFork.test.ts +243 -0
- package/src/__tests__/ToastContent.test.tsx +192 -0
- package/src/__tests__/ToastHostWebFork.test.ts +155 -0
- package/src/__tests__/Toaster.test.tsx +527 -0
- package/src/__tests__/animated-style-deps.test.ts +156 -0
- package/src/__tests__/icon-references.test.ts +243 -0
- package/src/__tests__/toast-animations.test.ts +98 -0
- package/src/__tests__/toast-comparator.test.ts +131 -0
- package/src/__tests__/toast-enter-driver.test.ts +147 -0
- package/src/__tests__/toast-fns.test.ts +240 -0
- package/src/__tests__/toast-position-utils.test.ts +259 -0
- package/src/__tests__/toast-positioner-utils.test.ts +214 -0
- package/src/__tests__/toast-store.test.ts +622 -0
- package/src/__tests__/toast-timers.test.ts +163 -0
- package/src/__tests__/use-animated-target.test.tsx +60 -0
- package/src/__tests__/use-app-state.test.tsx +127 -0
- package/src/__tests__/use-toast-colors.test.tsx +189 -0
- package/src/__tests__/web-position-fixed.test.ts +70 -0
- package/src/avatar-group/AvatarGroup.web.tsx +2 -1
- package/src/benefit-list/types.ts +2 -1
- package/src/bottom-sheet/index.web.tsx +3 -2
- package/src/context-menu/index.web.tsx +3 -2
- package/src/dialog/Dialog.web.tsx +4 -3
- package/src/fab/types.ts +4 -2
- package/src/frosted-icon-button/shared.ts +1 -1
- package/src/frosted-icon-button/types.ts +2 -1
- package/src/index.ts +4 -1
- package/src/index.web.ts +4 -1
- package/src/menu/index.web.tsx +2 -1
- package/src/popover/index.web.tsx +3 -2
- package/src/portal/index.tsx +4 -1
- package/src/progressive-blur/index.tsx +78 -0
- package/src/progressive-blur/index.web.tsx +65 -0
- package/src/progressive-blur/shared.ts +81 -0
- package/src/progressive-blur/types.ts +21 -0
- package/src/select/index.web.tsx +2 -1
- package/src/styles/web-view-style.ts +21 -0
- package/src/tab-bar/TabBar.stories.tsx +217 -0
- package/src/tab-bar/TabBarBase.tsx +517 -0
- package/src/tab-bar/expo-router/RouterTabBar.tsx +80 -0
- package/src/tab-bar/expo-router/fading-tab-screen.tsx +109 -0
- package/src/tab-bar/expo-router/index.ts +13 -0
- package/src/tab-bar/glyph.native.tsx +46 -0
- package/src/tab-bar/glyph.tsx +31 -0
- package/src/tab-bar/index.ts +32 -0
- package/src/tab-bar/index.web.tsx +34 -0
- package/src/tab-bar/minimize-context.tsx +117 -0
- package/src/tab-bar/shared.ts +159 -0
- package/src/tab-bar/surface-solid.tsx +40 -0
- package/src/tab-bar/surface.native.tsx +122 -0
- package/src/tab-bar/surface.tsx +28 -0
- package/src/tab-bar/surface.web.tsx +56 -0
- package/src/tab-bar/types.ts +91 -0
- package/src/toast/Positioner.tsx +121 -0
- package/src/toast/Toast.stories.tsx +292 -65
- package/src/toast/ToastContent.tsx +405 -0
- package/src/toast/ToastHost.native.tsx +31 -0
- package/src/toast/ToastHost.tsx +67 -0
- package/src/toast/ToastIcon.tsx +55 -0
- package/src/toast/ToastRow.tsx +485 -0
- package/src/toast/ToastSwipeHandler.tsx +222 -0
- package/src/toast/Toaster.tsx +259 -0
- package/src/toast/animations.ts +313 -0
- package/src/toast/constants.ts +76 -0
- package/src/toast/context.tsx +44 -0
- package/src/toast/index.tsx +47 -123
- package/src/toast/position-utils.ts +149 -0
- package/src/toast/positioner-utils.ts +142 -0
- package/src/toast/toast-comparator.ts +41 -0
- package/src/toast/toast-fns.ts +104 -0
- package/src/toast/toast-store.ts +432 -0
- package/src/toast/toast-timers.ts +124 -0
- package/src/toast/types.ts +301 -5
- package/src/toast/use-animated-target.ts +61 -0
- package/src/toast/use-app-state.ts +77 -0
- package/src/toast/use-toast-colors.ts +133 -0
- package/src/toast/use-toast-position.ts +46 -0
- package/src/tooltip/index.web.tsx +2 -1
- package/src/zoomable-image-gallery/ZoomableImageGallery.stories.tsx +134 -0
- package/src/zoomable-image-gallery/ZoomableImageGallery.tsx +50 -27
- package/lib/commonjs/toast/Toast.js +0 -267
- package/lib/commonjs/toast/Toast.js.map +0 -1
- package/lib/commonjs/toast/const.js +0 -8
- package/lib/commonjs/toast/const.js.map +0 -1
- package/lib/commonjs/toast/index.web.js +0 -114
- package/lib/commonjs/toast/index.web.js.map +0 -1
- package/lib/commonjs/toast/sonner/index.js +0 -9
- package/lib/commonjs/toast/sonner/index.js.map +0 -1
- package/lib/commonjs/toast/sonner/index.web.js +0 -9
- package/lib/commonjs/toast/sonner/index.web.js.map +0 -1
- package/lib/module/toast/Toast.js +0 -258
- package/lib/module/toast/Toast.js.map +0 -1
- package/lib/module/toast/const.js +0 -4
- package/lib/module/toast/const.js.map +0 -1
- package/lib/module/toast/index.web.js +0 -74
- package/lib/module/toast/index.web.js.map +0 -1
- package/lib/module/toast/sonner/index.js +0 -5
- package/lib/module/toast/sonner/index.js.map +0 -1
- package/lib/module/toast/sonner/index.web.js +0 -5
- package/lib/module/toast/sonner/index.web.js.map +0 -1
- package/lib/typescript/commonjs/toast/Toast.d.ts +0 -23
- package/lib/typescript/commonjs/toast/Toast.d.ts.map +0 -1
- package/lib/typescript/commonjs/toast/const.d.ts +0 -2
- package/lib/typescript/commonjs/toast/const.d.ts.map +0 -1
- package/lib/typescript/commonjs/toast/index.web.d.ts +0 -29
- package/lib/typescript/commonjs/toast/index.web.d.ts.map +0 -1
- package/lib/typescript/commonjs/toast/sonner/index.d.ts +0 -2
- package/lib/typescript/commonjs/toast/sonner/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/toast/sonner/index.web.d.ts +0 -2
- package/lib/typescript/commonjs/toast/sonner/index.web.d.ts.map +0 -1
- package/lib/typescript/module/toast/Toast.d.ts +0 -23
- package/lib/typescript/module/toast/Toast.d.ts.map +0 -1
- package/lib/typescript/module/toast/const.d.ts +0 -2
- package/lib/typescript/module/toast/const.d.ts.map +0 -1
- package/lib/typescript/module/toast/index.web.d.ts +0 -29
- package/lib/typescript/module/toast/index.web.d.ts.map +0 -1
- package/lib/typescript/module/toast/sonner/index.d.ts +0 -2
- package/lib/typescript/module/toast/sonner/index.d.ts.map +0 -1
- package/lib/typescript/module/toast/sonner/index.web.d.ts +0 -2
- package/lib/typescript/module/toast/sonner/index.web.d.ts.map +0 -1
- package/src/toast/Toast.tsx +0 -269
- package/src/toast/const.ts +0 -1
- package/src/toast/index.web.tsx +0 -101
- package/src/toast/sonner/index.ts +0 -3
- package/src/toast/sonner/index.web.ts +0 -3
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/toaster.tsx
|
|
3
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* Subscribes to the store, resolves the outlet configuration once, groups rows by
|
|
6
|
+
* position and renders each group through `Positioner` inside the platform
|
|
7
|
+
* `ToastHost`.
|
|
8
|
+
*
|
|
9
|
+
* W5 — ONE `AppState` subscription for the whole stack. Upstream subscribes per
|
|
10
|
+
* row, so N toasts meant N `visibilitychange` listeners all doing the same work;
|
|
11
|
+
* the store already exposes stack-wide `pauseAllTimers`/`resumeAllTimers`.
|
|
12
|
+
*
|
|
13
|
+
* `react-native-screens` is not imported here either — the platform wrapper is
|
|
14
|
+
* `ToastHost`'s concern (D6).
|
|
15
|
+
*/
|
|
16
|
+
import * as React from 'react';
|
|
17
|
+
|
|
18
|
+
import { toastDefaults } from './constants';
|
|
19
|
+
import { DynamicToastContext, ToastContext } from './context';
|
|
20
|
+
import { getOrderedToastIds } from './position-utils';
|
|
21
|
+
import { Positioner } from './Positioner';
|
|
22
|
+
import { ToastHost } from './ToastHost';
|
|
23
|
+
import { ToastRow } from './ToastRow';
|
|
24
|
+
import { toastStore } from './toast-store';
|
|
25
|
+
import type {
|
|
26
|
+
DynamicToastContextType,
|
|
27
|
+
StableToastContextType,
|
|
28
|
+
ToasterProps,
|
|
29
|
+
ToastPosition,
|
|
30
|
+
ToastProps,
|
|
31
|
+
} from './types';
|
|
32
|
+
import { useAppStateChange } from './use-app-state';
|
|
33
|
+
|
|
34
|
+
const ALL_POSITIONS: ToastPosition[] = [
|
|
35
|
+
'top-center',
|
|
36
|
+
'bottom-center',
|
|
37
|
+
'center',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
// Stable identities so the context memos below do not invalidate every render.
|
|
41
|
+
const EMPTY_TOAST_OPTIONS: NonNullable<ToasterProps['toastOptions']> = {};
|
|
42
|
+
const EMPTY_ICONS: NonNullable<ToasterProps['icons']> = {};
|
|
43
|
+
const EMPTY_ANIMATION: NonNullable<ToasterProps['animation']> = {};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A top-anchored stack grows downward from the newest toast, so its rows render
|
|
47
|
+
* in reverse order.
|
|
48
|
+
*/
|
|
49
|
+
function orderToastsFromPosition(
|
|
50
|
+
toasts: ToastProps[],
|
|
51
|
+
position: ToastPosition,
|
|
52
|
+
): ToastProps[] {
|
|
53
|
+
return position === 'top-center' ? toasts.slice().reverse() : toasts;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const Toaster: React.FC<ToasterProps> = ({
|
|
57
|
+
ToasterOverlayWrapper,
|
|
58
|
+
ToastWrapper,
|
|
59
|
+
duration = toastDefaults.duration,
|
|
60
|
+
position = toastDefaults.position,
|
|
61
|
+
offset = toastDefaults.offset,
|
|
62
|
+
visibleToasts = toastDefaults.visibleToasts,
|
|
63
|
+
swipeToDismissDirection = toastDefaults.swipeToDismissDirection,
|
|
64
|
+
closeButton = toastDefaults.closeButton,
|
|
65
|
+
gap = toastDefaults.gap,
|
|
66
|
+
theme = toastDefaults.theme,
|
|
67
|
+
invert = toastDefaults.invert,
|
|
68
|
+
richColors = toastDefaults.richColors,
|
|
69
|
+
enableStacking = toastDefaults.enableStacking,
|
|
70
|
+
autoWiggleOnUpdate = toastDefaults.autoWiggleOnUpdate,
|
|
71
|
+
pauseWhenPageIsHidden = toastDefaults.pauseWhenPageIsHidden,
|
|
72
|
+
allowFontScaling = toastDefaults.allowFontScaling,
|
|
73
|
+
maxFontSizeMultiplier,
|
|
74
|
+
toastOptions = EMPTY_TOAST_OPTIONS,
|
|
75
|
+
icons = EMPTY_ICONS,
|
|
76
|
+
animation = EMPTY_ANIMATION,
|
|
77
|
+
unstyled,
|
|
78
|
+
positionerStyle,
|
|
79
|
+
style,
|
|
80
|
+
styles: styleOverrides,
|
|
81
|
+
}) => {
|
|
82
|
+
const { toasts, shouldShowOverlay, toastHeights, isExpanded } =
|
|
83
|
+
React.useSyncExternalStore(
|
|
84
|
+
toastStore.subscribe,
|
|
85
|
+
toastStore.getSnapshot,
|
|
86
|
+
toastStore.getSnapshot,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Runs even while idle: the store must know the outlet's limits BEFORE the
|
|
90
|
+
// first toast arrives, or that toast is resolved against the bare defaults.
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
toastStore.setConfig({
|
|
93
|
+
autoWiggleOnUpdate,
|
|
94
|
+
visibleToasts,
|
|
95
|
+
duration,
|
|
96
|
+
pauseWhenPageIsHidden,
|
|
97
|
+
});
|
|
98
|
+
}, [autoWiggleOnUpdate, visibleToasts, duration, pauseWhenPageIsHidden]);
|
|
99
|
+
|
|
100
|
+
const onBackground = React.useCallback(() => {
|
|
101
|
+
if (pauseWhenPageIsHidden) {
|
|
102
|
+
toastStore.pauseAllTimers();
|
|
103
|
+
}
|
|
104
|
+
}, [pauseWhenPageIsHidden]);
|
|
105
|
+
|
|
106
|
+
const onForeground = React.useCallback(() => {
|
|
107
|
+
if (pauseWhenPageIsHidden) {
|
|
108
|
+
toastStore.resumeAllTimers();
|
|
109
|
+
}
|
|
110
|
+
}, [pauseWhenPageIsHidden]);
|
|
111
|
+
|
|
112
|
+
useAppStateChange({ onBackground, onForeground });
|
|
113
|
+
|
|
114
|
+
const stableValue: StableToastContextType = React.useMemo(
|
|
115
|
+
() => ({
|
|
116
|
+
duration,
|
|
117
|
+
position,
|
|
118
|
+
offset,
|
|
119
|
+
visibleToasts,
|
|
120
|
+
swipeToDismissDirection,
|
|
121
|
+
closeButton,
|
|
122
|
+
gap,
|
|
123
|
+
theme,
|
|
124
|
+
invert,
|
|
125
|
+
richColors,
|
|
126
|
+
enableStacking,
|
|
127
|
+
autoWiggleOnUpdate,
|
|
128
|
+
pauseWhenPageIsHidden,
|
|
129
|
+
allowFontScaling,
|
|
130
|
+
maxFontSizeMultiplier,
|
|
131
|
+
toastOptions,
|
|
132
|
+
icons,
|
|
133
|
+
animation,
|
|
134
|
+
unstyled: unstyled ?? toastOptions.unstyled ?? toastDefaults.unstyled,
|
|
135
|
+
}),
|
|
136
|
+
[
|
|
137
|
+
duration,
|
|
138
|
+
position,
|
|
139
|
+
offset,
|
|
140
|
+
visibleToasts,
|
|
141
|
+
swipeToDismissDirection,
|
|
142
|
+
closeButton,
|
|
143
|
+
gap,
|
|
144
|
+
theme,
|
|
145
|
+
invert,
|
|
146
|
+
richColors,
|
|
147
|
+
enableStacking,
|
|
148
|
+
autoWiggleOnUpdate,
|
|
149
|
+
pauseWhenPageIsHidden,
|
|
150
|
+
allowFontScaling,
|
|
151
|
+
maxFontSizeMultiplier,
|
|
152
|
+
toastOptions,
|
|
153
|
+
icons,
|
|
154
|
+
animation,
|
|
155
|
+
unstyled,
|
|
156
|
+
],
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const dynamicValue: DynamicToastContextType = React.useMemo(
|
|
160
|
+
() => ({
|
|
161
|
+
toastHeights,
|
|
162
|
+
isExpanded,
|
|
163
|
+
expand: toastStore.expand,
|
|
164
|
+
collapse: toastStore.collapse,
|
|
165
|
+
toggleExpand: toastStore.toggleExpand,
|
|
166
|
+
}),
|
|
167
|
+
[toastHeights, isExpanded],
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Rows grouped by their EFFECTIVE position, which for a toast with no explicit
|
|
172
|
+
* `position` is the outlet's configured one — the same resolution `ToastRow`
|
|
173
|
+
* itself does (`positionProp ?? positionCtx`).
|
|
174
|
+
*
|
|
175
|
+
* It must NOT be "whichever group happens to come first". Grouping a
|
|
176
|
+
* position-less row by index put it in the top-center group the moment any
|
|
177
|
+
* top-center toast existed, because `ALL_POSITIONS` starts with `top-center`:
|
|
178
|
+
* a plain `toast('Saved')` then rendered against the top inset (visible only as
|
|
179
|
+
* a sliver above the screen edge), and an already-placed one JUMPED there when a
|
|
180
|
+
* top-center toast arrived.
|
|
181
|
+
*
|
|
182
|
+
* The configured position is always kept, even with no rows in it, so
|
|
183
|
+
* position-less rows always have a home. Each group is ordered by its OWN
|
|
184
|
+
* position: a top-anchored stack renders in reverse, and applying the outlet's
|
|
185
|
+
* ordering to every group reversed the wrong ones.
|
|
186
|
+
*/
|
|
187
|
+
const toastsByPosition = React.useMemo(() => {
|
|
188
|
+
const groups = new Map<ToastPosition, ToastProps[]>();
|
|
189
|
+
for (const candidate of ALL_POSITIONS) {
|
|
190
|
+
const group = toasts.filter(
|
|
191
|
+
(toast) => (toast.position ?? position) === candidate,
|
|
192
|
+
);
|
|
193
|
+
if (candidate === position || group.length > 0) {
|
|
194
|
+
groups.set(candidate, orderToastsFromPosition(group, candidate));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return groups;
|
|
198
|
+
}, [toasts, position]);
|
|
199
|
+
|
|
200
|
+
const onDismiss = React.useCallback((id: string | number) => {
|
|
201
|
+
toastStore.dismissToast(id, 'onDismiss');
|
|
202
|
+
}, []);
|
|
203
|
+
|
|
204
|
+
// Nothing to host while idle. `shouldShowOverlay` stays true for the length of
|
|
205
|
+
// the exit animation after the last dismissal, so this never cuts one short.
|
|
206
|
+
if (!shouldShowOverlay) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<ToastHost ToasterOverlayWrapper={ToasterOverlayWrapper}>
|
|
212
|
+
<ToastContext.Provider value={stableValue}>
|
|
213
|
+
<DynamicToastContext.Provider value={dynamicValue}>
|
|
214
|
+
{Array.from(toastsByPosition, ([currentPosition, toastsForPosition]) => {
|
|
215
|
+
const orderedToastIds = getOrderedToastIds(
|
|
216
|
+
toastsForPosition,
|
|
217
|
+
currentPosition,
|
|
218
|
+
enableStacking,
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<Positioner
|
|
223
|
+
key={currentPosition}
|
|
224
|
+
position={currentPosition}
|
|
225
|
+
style={positionerStyle}
|
|
226
|
+
>
|
|
227
|
+
{toastsForPosition.map((toast, index) => {
|
|
228
|
+
const row = (
|
|
229
|
+
<ToastRow
|
|
230
|
+
key={toast.id}
|
|
231
|
+
{...toast}
|
|
232
|
+
style={toast.style ?? style}
|
|
233
|
+
styles={toast.styles ?? styleOverrides}
|
|
234
|
+
index={index}
|
|
235
|
+
numberOfToasts={toastsForPosition.length}
|
|
236
|
+
orderedToastIds={orderedToastIds}
|
|
237
|
+
onDismiss={onDismiss}
|
|
238
|
+
ref={toastStore.getToastRef(toast.id)}
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return ToastWrapper ? (
|
|
243
|
+
<ToastWrapper key={toast.id} toastId={toast.id}>
|
|
244
|
+
{row}
|
|
245
|
+
</ToastWrapper>
|
|
246
|
+
) : (
|
|
247
|
+
row
|
|
248
|
+
);
|
|
249
|
+
})}
|
|
250
|
+
</Positioner>
|
|
251
|
+
);
|
|
252
|
+
})}
|
|
253
|
+
</DynamicToastContext.Provider>
|
|
254
|
+
</ToastContext.Provider>
|
|
255
|
+
</ToastHost>
|
|
256
|
+
);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
Toaster.displayName = 'Toaster';
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/animations.ts, src/animation-utils.ts
|
|
3
|
+
* and src/easings.ts (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* W1 — THE EXIT DEFAULT IS A `Keyframe` INSTANCE, NOT A WORKLET BUILDER.
|
|
6
|
+
*
|
|
7
|
+
* Upstream returns a custom `EntryExitAnimationFunction` for both directions. On
|
|
8
|
+
* web that produces NO animation at all: reanimated's web layout-animation
|
|
9
|
+
* manager looks the builder up by preset name, finds none, logs a warning per
|
|
10
|
+
* toast and falls through to `makeElementVisible`, so a toast simply appears and
|
|
11
|
+
* disappears. A `ReanimatedKeyframe` compiles to a real CSS `@keyframes` rule on
|
|
12
|
+
* web and to the same interpolation on native, so one definition covers both
|
|
13
|
+
* platforms — which is what the exit default below is.
|
|
14
|
+
*
|
|
15
|
+
* ON WEB THE ENTER IS NOT A LAYOUT ANIMATION — NEVER HAND IT TO `entering`
|
|
16
|
+
* THERE. This is the fix for a blocker where a second toast landed exactly on top
|
|
17
|
+
* of the first, and it MUST NOT be undone by "simplifying" the web enter back
|
|
18
|
+
* into a `Keyframe`:
|
|
19
|
+
*
|
|
20
|
+
* reanimated's web ENTERING path calls `setElementAnimation(element, config,
|
|
21
|
+
* true)`, whose third argument is `shouldSavePosition`. For any animation name
|
|
22
|
+
* that is not one of its own predefined presets — which is every `Keyframe`,
|
|
23
|
+
* since those mint a fresh `REA-ENTERING-n` rule — it also schedules
|
|
24
|
+
* `scheduleAnimationCleanup(name, duration, cb)`, and that callback runs
|
|
25
|
+
* `setElementPosition(element, snapshot)`: `position: absolute`, an explicit
|
|
26
|
+
* `top`/`left`/`width`/`height` and `transform: ''`, taken from a snapshot
|
|
27
|
+
* captured when the enter animation ENDED. The timeout is `duration * 5`, so at
|
|
28
|
+
* Bloom's 300ms enter the row is frozen in VIEWPORT coordinates 1500ms after it
|
|
29
|
+
* appeared, and its parent collapses to `height: 0`. A row that moves inside
|
|
30
|
+
* that window — i.e. any row that is still on screen when the next toast
|
|
31
|
+
* arrives — has its stack translate exactly cancelled and redraws on top of the
|
|
32
|
+
* newcomer. It is completely silent: no error, no warning.
|
|
33
|
+
*
|
|
34
|
+
* So on web the enter is driven imperatively instead: `ToastRow` seeds a shared
|
|
35
|
+
* value at 0 and animates it to 1 (`useAnimatedTarget`'s `from`), interpolating
|
|
36
|
+
* opacity and `ENTER_TRANSLATE_Y` to the same distances and curve the `Keyframe`
|
|
37
|
+
* uses, without touching reanimated's web layout-animation machinery.
|
|
38
|
+
*
|
|
39
|
+
* NATIVE KEEPS THE `Keyframe` ON `entering`. `ENTER_DRIVER` below is the ONE
|
|
40
|
+
* switch: there is no `setElementPosition` on native — that whole pin is a web-DOM
|
|
41
|
+
* behaviour — so native pays nothing for the web bug, and driving the enter
|
|
42
|
+
* imperatively there instead regressed it hard (a `bottom-center` toast stopped
|
|
43
|
+
* painting altogether). Native runs the device-verified layout-animation path and
|
|
44
|
+
* never starts a mount-time `withTiming` for the enter at all.
|
|
45
|
+
*
|
|
46
|
+
* The EXIT goes through `exiting` on BOTH platforms, which is safe: reanimated
|
|
47
|
+
* pins the throwaway dummy clone it animates (`shouldSavePosition` is false for
|
|
48
|
+
* the real element), and it is what keeps a dismissed row mounted long enough to
|
|
49
|
+
* animate.
|
|
50
|
+
*
|
|
51
|
+
* Consumer-supplied *predefined* builders (`FadeIn`, `SlideInUp`) keep working on
|
|
52
|
+
* both platforms for both enter and exit, and always go through `entering` /
|
|
53
|
+
* `exiting`. A consumer's own custom worklet builder still animates on native and
|
|
54
|
+
* is silently ignored on web, and a consumer's custom `Keyframe` passed as
|
|
55
|
+
* `animation.enter` will hit the pin described above on web — both are reanimated
|
|
56
|
+
* limitations Bloom cannot bridge.
|
|
57
|
+
*
|
|
58
|
+
* Exit instances are cached per animation shape because building one is not free
|
|
59
|
+
* and, more importantly, because `Keyframe.parseDefinitions()` MUTATES the
|
|
60
|
+
* definition object it was constructed with (it rewrites `from`/`to` into
|
|
61
|
+
* `0`/`100` and deletes them). Each cached instance therefore owns its own
|
|
62
|
+
* definition object; sharing one definition across two instances would make the
|
|
63
|
+
* second throw "Please provide 0 or 'from' keyframe". Re-parsing a single
|
|
64
|
+
* instance is idempotent, so one instance is safely shared by every row of the
|
|
65
|
+
* same shape.
|
|
66
|
+
*/
|
|
67
|
+
import { Platform } from 'react-native';
|
|
68
|
+
import {
|
|
69
|
+
Easing,
|
|
70
|
+
Keyframe,
|
|
71
|
+
useReducedMotion,
|
|
72
|
+
type ReanimatedKeyframe,
|
|
73
|
+
} from 'react-native-reanimated';
|
|
74
|
+
|
|
75
|
+
import { ENTERING_ANIMATION_DURATION, toastDefaults } from './constants';
|
|
76
|
+
import { useToastContext } from './context';
|
|
77
|
+
import type {
|
|
78
|
+
ToastAnimation,
|
|
79
|
+
ToastEntryExitAnimation,
|
|
80
|
+
ToastPosition,
|
|
81
|
+
} from './types';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* `Easing.bezier()` (not `bezierFn`) returns an easing *factory*, which is what
|
|
85
|
+
* `Keyframe` accepts on both platforms — reanimated's dev-only worklet assertion
|
|
86
|
+
* short-circuits on the `.factory` property, so these pass without the worklets
|
|
87
|
+
* babel plugin too.
|
|
88
|
+
*/
|
|
89
|
+
const EASE_OUT_QUART = Easing.bezier(0.165, 0.84, 0.44, 1);
|
|
90
|
+
const EASE_IN_OUT_CUBIC = Easing.bezier(0.645, 0.045, 0.355, 1);
|
|
91
|
+
|
|
92
|
+
export type ToastEnterDriver = 'imperative' | 'layoutAnimation';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* THE one platform switch in the toast engine: which mechanism plays Bloom's
|
|
96
|
+
* DEFAULT enter animation. See the header for why the two platforms cannot share
|
|
97
|
+
* one mechanism.
|
|
98
|
+
*/
|
|
99
|
+
export const TOAST_ENTER_DRIVER: ToastEnterDriver =
|
|
100
|
+
Platform.OS === 'web' ? 'imperative' : 'layoutAnimation';
|
|
101
|
+
|
|
102
|
+
/** Worklet-callable easing for `withTiming` inside mappers and layout transitions. */
|
|
103
|
+
export const easeOutQuartFn = Easing.bezierFn(0.165, 0.84, 0.44, 1);
|
|
104
|
+
export const easeInOutCircFn = Easing.bezierFn(0.785, 0.135, 0.15, 0.86);
|
|
105
|
+
|
|
106
|
+
/** How far a row travels on the way in, per position. */
|
|
107
|
+
const ENTER_TRANSLATE_Y: Record<ToastPosition, number> = {
|
|
108
|
+
'top-center': -20,
|
|
109
|
+
'bottom-center': 50,
|
|
110
|
+
center: 50,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** A lone row leaves the screen entirely; a stacked one only slides by `stackGap`. */
|
|
114
|
+
const EXIT_TRANSLATE_Y_SINGLE = 150;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Bounded so an animated `gap` cannot grow the cache without limit. The natural
|
|
118
|
+
* key space is 3 enter shapes + 3 positions x hidden x single x one stackGap = 15
|
|
119
|
+
* entries, so this leaves room for a few gap values while staying O(1) memory.
|
|
120
|
+
*/
|
|
121
|
+
export const MAX_CACHED_ANIMATIONS = 32;
|
|
122
|
+
|
|
123
|
+
const animationCache = new Map<string, ReanimatedKeyframe>();
|
|
124
|
+
|
|
125
|
+
function cachedAnimation(
|
|
126
|
+
key: string,
|
|
127
|
+
build: () => ReanimatedKeyframe,
|
|
128
|
+
): ReanimatedKeyframe {
|
|
129
|
+
const hit = animationCache.get(key);
|
|
130
|
+
if (hit) {
|
|
131
|
+
return hit;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (animationCache.size >= MAX_CACHED_ANIMATIONS) {
|
|
135
|
+
// Map iterates in insertion order, so this evicts the least recently added.
|
|
136
|
+
const oldest = animationCache.keys().next();
|
|
137
|
+
if (!oldest.done) {
|
|
138
|
+
animationCache.delete(oldest.value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const built = build();
|
|
143
|
+
animationCache.set(key, built);
|
|
144
|
+
return built;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Exported so the bounded-growth invariant above is testable. */
|
|
148
|
+
export function toastAnimationCacheSize(): number {
|
|
149
|
+
return animationCache.size;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Native only — on web the same shape is played imperatively by `ToastRow`. */
|
|
153
|
+
export function getToastEnterAnimation(
|
|
154
|
+
position: ToastPosition,
|
|
155
|
+
): ReanimatedKeyframe {
|
|
156
|
+
return cachedAnimation(
|
|
157
|
+
`enter|${position}`,
|
|
158
|
+
() =>
|
|
159
|
+
new Keyframe({
|
|
160
|
+
from: {
|
|
161
|
+
opacity: 0,
|
|
162
|
+
transform: [{ translateY: ENTER_TRANSLATE_Y[position] }],
|
|
163
|
+
},
|
|
164
|
+
to: {
|
|
165
|
+
opacity: 1,
|
|
166
|
+
transform: [{ translateY: 0 }],
|
|
167
|
+
easing: EASE_OUT_QUART,
|
|
168
|
+
},
|
|
169
|
+
}).duration(ENTERING_ANIMATION_DURATION),
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function getToastExitAnimation({
|
|
174
|
+
position,
|
|
175
|
+
isHiddenByLimit,
|
|
176
|
+
isSingle,
|
|
177
|
+
stackGap,
|
|
178
|
+
}: {
|
|
179
|
+
position: ToastPosition;
|
|
180
|
+
isHiddenByLimit: boolean;
|
|
181
|
+
isSingle: boolean;
|
|
182
|
+
stackGap: number;
|
|
183
|
+
}): ReanimatedKeyframe {
|
|
184
|
+
return cachedAnimation(
|
|
185
|
+
`exit|${position}|${isHiddenByLimit}|${isSingle}|${stackGap}`,
|
|
186
|
+
() => {
|
|
187
|
+
// A row culled by `visibleToasts` is buried under the stack; sliding it
|
|
188
|
+
// would look wrong, so it only fades.
|
|
189
|
+
if (isHiddenByLimit) {
|
|
190
|
+
return new Keyframe({
|
|
191
|
+
from: { opacity: 1 },
|
|
192
|
+
to: { opacity: 0, easing: EASE_IN_OUT_CUBIC },
|
|
193
|
+
}).duration(ENTERING_ANIMATION_DURATION);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const distance = isSingle ? EXIT_TRANSLATE_Y_SINGLE : stackGap;
|
|
197
|
+
const translateY = position === 'top-center' ? -distance : distance;
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
new Keyframe({
|
|
201
|
+
from: { opacity: 1, transform: [{ translateY: 0 }] },
|
|
202
|
+
to: { opacity: 0, transform: [{ translateY }], easing: EASE_IN_OUT_CUBIC },
|
|
203
|
+
})
|
|
204
|
+
// Matches the store's overlay teardown delay, which is also
|
|
205
|
+
// ENTERING_ANIMATION_DURATION — a longer exit would be cut off.
|
|
206
|
+
.duration(ENTERING_ANIMATION_DURATION)
|
|
207
|
+
);
|
|
208
|
+
},
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
type ResolvedAnimation = Exclude<ToastEntryExitAnimation, 'default'>;
|
|
213
|
+
|
|
214
|
+
export type ResolvedEnterAnimation = {
|
|
215
|
+
entering: ResolvedAnimation | undefined;
|
|
216
|
+
enterTranslateY: number | undefined;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Pure so the platform split is testable without a renderer.
|
|
221
|
+
*
|
|
222
|
+
* INVARIANT: exactly ONE of `entering` / `enterTranslateY` is ever set. Both
|
|
223
|
+
* would play the enter twice; neither would leave the row with no enter animation
|
|
224
|
+
* at all and — on the imperative path — parked at `opacity: 0`, one full
|
|
225
|
+
* `enterTranslateY` away from its slot. A consumer override always wins and always
|
|
226
|
+
* goes through `entering`, on both platforms.
|
|
227
|
+
*/
|
|
228
|
+
export function resolveToastEnterAnimation({
|
|
229
|
+
position,
|
|
230
|
+
enterOverride,
|
|
231
|
+
driver,
|
|
232
|
+
}: {
|
|
233
|
+
position: ToastPosition;
|
|
234
|
+
enterOverride: ToastEntryExitAnimation | undefined;
|
|
235
|
+
driver: ToastEnterDriver;
|
|
236
|
+
}): ResolvedEnterAnimation {
|
|
237
|
+
if (enterOverride !== undefined && enterOverride !== 'default') {
|
|
238
|
+
return { entering: enterOverride, enterTranslateY: undefined };
|
|
239
|
+
}
|
|
240
|
+
return driver === 'imperative'
|
|
241
|
+
? { entering: undefined, enterTranslateY: ENTER_TRANSLATE_Y[position] }
|
|
242
|
+
: { entering: getToastEnterAnimation(position), enterTranslateY: undefined };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Per-toast animation wins over the outlet's; `'default'` opts back in to Bloom's. */
|
|
246
|
+
export const resolveAnimationField = (
|
|
247
|
+
toastValue: ToastEntryExitAnimation | undefined,
|
|
248
|
+
toasterValue: ToastEntryExitAnimation | undefined,
|
|
249
|
+
defaultValue: ResolvedAnimation,
|
|
250
|
+
): ResolvedAnimation => {
|
|
251
|
+
const resolved = toastValue !== undefined ? toastValue : toasterValue;
|
|
252
|
+
if (resolved === undefined || resolved === 'default') {
|
|
253
|
+
return defaultValue;
|
|
254
|
+
}
|
|
255
|
+
return resolved;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export const useToastLayoutAnimations = (
|
|
259
|
+
positionProp: ToastPosition | undefined,
|
|
260
|
+
animationProp: ToastAnimation | undefined,
|
|
261
|
+
isHiddenByLimit: boolean,
|
|
262
|
+
numberOfToasts: number,
|
|
263
|
+
): {
|
|
264
|
+
entering: ResolvedAnimation | undefined;
|
|
265
|
+
exiting: ResolvedAnimation | undefined;
|
|
266
|
+
/**
|
|
267
|
+
* How far `ToastRow`'s imperative enter travels, or `undefined` when nothing
|
|
268
|
+
* should be driven imperatively — because `entering` is playing the enter
|
|
269
|
+
* instead (native, or a consumer override on either platform), or because
|
|
270
|
+
* reduced motion is on and there is no enter animation at all.
|
|
271
|
+
*/
|
|
272
|
+
enterTranslateY: number | undefined;
|
|
273
|
+
} => {
|
|
274
|
+
const {
|
|
275
|
+
position: positionCtx,
|
|
276
|
+
gap,
|
|
277
|
+
animation: animationCtx,
|
|
278
|
+
} = useToastContext();
|
|
279
|
+
const position = positionProp ?? positionCtx;
|
|
280
|
+
const stackGap = gap ?? toastDefaults.stackGap;
|
|
281
|
+
const reducedMotion = useReducedMotion();
|
|
282
|
+
|
|
283
|
+
if (reducedMotion) {
|
|
284
|
+
return { entering: undefined, exiting: undefined, enterTranslateY: undefined };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const defaultExiting = getToastExitAnimation({
|
|
288
|
+
position,
|
|
289
|
+
isHiddenByLimit,
|
|
290
|
+
isSingle: numberOfToasts <= 1,
|
|
291
|
+
stackGap,
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
...resolveToastEnterAnimation({
|
|
296
|
+
position,
|
|
297
|
+
enterOverride:
|
|
298
|
+
animationProp?.enter !== undefined
|
|
299
|
+
? animationProp.enter
|
|
300
|
+
: animationCtx?.enter,
|
|
301
|
+
driver: TOAST_ENTER_DRIVER,
|
|
302
|
+
}),
|
|
303
|
+
// An overflow-culled row always uses Bloom's fade: a consumer's custom exit
|
|
304
|
+
// would animate a row the user cannot even see.
|
|
305
|
+
exiting: isHiddenByLimit
|
|
306
|
+
? defaultExiting
|
|
307
|
+
: resolveAnimationField(
|
|
308
|
+
animationProp?.exit,
|
|
309
|
+
animationCtx?.exit,
|
|
310
|
+
defaultExiting,
|
|
311
|
+
),
|
|
312
|
+
};
|
|
313
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/constants.ts and src/animations.ts
|
|
3
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* The two animation durations live HERE rather than in `animations.ts` so
|
|
6
|
+
* `toast-store.ts` never has to import a Reanimated-dependent module: the store
|
|
7
|
+
* stays pure JS and its suite needs zero React Native mocks.
|
|
8
|
+
*/
|
|
9
|
+
import type {
|
|
10
|
+
AutoWiggle,
|
|
11
|
+
ToastPosition,
|
|
12
|
+
ToastSwipeDirection,
|
|
13
|
+
ToastTheme,
|
|
14
|
+
ToastVariant,
|
|
15
|
+
} from './types';
|
|
16
|
+
|
|
17
|
+
/** Fallback row height until a toast has been measured. */
|
|
18
|
+
export const ESTIMATED_TOAST_HEIGHT = 70;
|
|
19
|
+
export const CLOSE_BUTTON_HIT_AREA = 60;
|
|
20
|
+
export const OUTSIDE_PRESS_PADDING = 20;
|
|
21
|
+
/** However deep a stack gets, a buried row never narrows past this scale. */
|
|
22
|
+
export const MIN_STACK_SCALE_X = 0.8;
|
|
23
|
+
|
|
24
|
+
/** Enter animation length; also the auto-close timer's head start and the overlay teardown delay. */
|
|
25
|
+
export const ENTERING_ANIMATION_DURATION = 300;
|
|
26
|
+
export const STACKING_ANIMATION_DURATION = 600;
|
|
27
|
+
|
|
28
|
+
export const toastDefaults: {
|
|
29
|
+
duration: number;
|
|
30
|
+
position: ToastPosition;
|
|
31
|
+
offset: number;
|
|
32
|
+
swipeToDismissDirection: ToastSwipeDirection;
|
|
33
|
+
variant: ToastVariant | undefined;
|
|
34
|
+
visibleToasts: number;
|
|
35
|
+
closeButton: boolean;
|
|
36
|
+
dismissible: boolean;
|
|
37
|
+
unstyled: boolean;
|
|
38
|
+
invert: boolean;
|
|
39
|
+
pauseWhenPageIsHidden: boolean;
|
|
40
|
+
gap: number;
|
|
41
|
+
theme: ToastTheme;
|
|
42
|
+
autoWiggleOnUpdate: AutoWiggle;
|
|
43
|
+
richColors: boolean;
|
|
44
|
+
enableStacking: boolean;
|
|
45
|
+
stackGap: number;
|
|
46
|
+
allowFontScaling: boolean;
|
|
47
|
+
} = {
|
|
48
|
+
duration: 3000,
|
|
49
|
+
position: 'bottom-center',
|
|
50
|
+
/**
|
|
51
|
+
* 0 means "derive from the safe-area inset" — `getInsetValues` then yields
|
|
52
|
+
* `inset + 8`, or 16 when there is no inset. A non-zero default would pin the
|
|
53
|
+
* stack to a fixed offset and ignore the notch / home indicator entirely.
|
|
54
|
+
*/
|
|
55
|
+
offset: 0,
|
|
56
|
+
swipeToDismissDirection: 'left',
|
|
57
|
+
/**
|
|
58
|
+
* No default variant: a plain `toast('Saved')` must render neutral. Upstream
|
|
59
|
+
* defaults this to `'info'`, which silently gives every unqualified toast
|
|
60
|
+
* info styling.
|
|
61
|
+
*/
|
|
62
|
+
variant: undefined,
|
|
63
|
+
visibleToasts: 3,
|
|
64
|
+
closeButton: false,
|
|
65
|
+
dismissible: true,
|
|
66
|
+
unstyled: false,
|
|
67
|
+
invert: false,
|
|
68
|
+
pauseWhenPageIsHidden: true,
|
|
69
|
+
gap: 8,
|
|
70
|
+
theme: 'system',
|
|
71
|
+
autoWiggleOnUpdate: 'never',
|
|
72
|
+
richColors: false,
|
|
73
|
+
enableStacking: false,
|
|
74
|
+
stackGap: 8,
|
|
75
|
+
allowFontScaling: true,
|
|
76
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/context.tsx
|
|
3
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* Two contexts, split by change frequency: the resolved `Toaster` configuration
|
|
6
|
+
* (stable for the lifetime of the outlet) and the live stack state (changes on
|
|
7
|
+
* every measurement). Splitting them keeps a height measurement from
|
|
8
|
+
* re-rendering every row's config-derived memo.
|
|
9
|
+
*
|
|
10
|
+
* Upstream also passes `addToast` through the stable context; Bloom's rows talk
|
|
11
|
+
* to `toastStore` directly, which is the single authority.
|
|
12
|
+
*/
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import type {
|
|
15
|
+
DynamicToastContextType,
|
|
16
|
+
StableToastContextType,
|
|
17
|
+
} from './types';
|
|
18
|
+
|
|
19
|
+
export const ToastContext = React.createContext<StableToastContextType | null>(
|
|
20
|
+
null,
|
|
21
|
+
);
|
|
22
|
+
ToastContext.displayName = 'BloomToastContext';
|
|
23
|
+
|
|
24
|
+
export const DynamicToastContext =
|
|
25
|
+
React.createContext<DynamicToastContextType | null>(null);
|
|
26
|
+
DynamicToastContext.displayName = 'BloomDynamicToastContext';
|
|
27
|
+
|
|
28
|
+
export const useToastContext = (): StableToastContextType => {
|
|
29
|
+
const context = React.useContext(ToastContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error('useToastContext must be used within a <ToastOutlet>');
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const useDynamicToastContext = (): DynamicToastContextType => {
|
|
37
|
+
const context = React.useContext(DynamicToastContext);
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
'useDynamicToastContext must be used within a <ToastOutlet>',
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return context;
|
|
44
|
+
};
|