@oxyhq/bloom 0.50.2 → 0.51.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/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/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.js +50 -0
- package/lib/commonjs/tab-bar/surface.js.map +1 -0
- package/lib/commonjs/tab-bar/surface.native.js +56 -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/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.js +44 -0
- package/lib/module/tab-bar/surface.js.map +1 -0
- package/lib/module/tab-bar/surface.native.js +50 -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/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/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.d.ts +6 -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 +85 -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/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/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.d.ts +6 -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 +85 -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 +63 -25
- package/src/__tests__/TabBar.test.tsx +342 -0
- package/src/__tests__/TabBarReanimatedDeps.test.ts +130 -0
- package/src/__tests__/TabBarWebFork.test.ts +197 -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__/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/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/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.native.tsx +60 -0
- package/src/tab-bar/surface.tsx +47 -0
- package/src/tab-bar/surface.web.tsx +56 -0
- package/src/tab-bar/types.ts +88 -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,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Derived from sonner-native v0.26.4 — src/toast-store.ts
|
|
5
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
6
|
+
*
|
|
7
|
+
* The auto-close timers were lifted out into `toast-timers.ts`. Everything this
|
|
8
|
+
* module touches is pure JavaScript — `react` (for `createRef`), `./constants`,
|
|
9
|
+
* `./toast-comparator`, `./toast-timers` and type-only `./types`. Keep it that
|
|
10
|
+
* way: nothing here may reach React Native or Reanimated, or the store stops
|
|
11
|
+
* being testable without a platform.
|
|
12
|
+
*/
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { ENTERING_ANIMATION_DURATION, toastDefaults } from "./constants.js";
|
|
15
|
+
import { areToastsEqual } from "./toast-comparator.js";
|
|
16
|
+
import { ToastTimerRegistry } from "./toast-timers.js";
|
|
17
|
+
/** How long the collapse gesture stays latched, so the same tap cannot re-expand. */
|
|
18
|
+
const COLLAPSE_COOLDOWN = 100;
|
|
19
|
+
class ToastStore {
|
|
20
|
+
state = {
|
|
21
|
+
toasts: [],
|
|
22
|
+
toastsById: new Map(),
|
|
23
|
+
toastsCounter: 1,
|
|
24
|
+
toastRefs: {},
|
|
25
|
+
shouldShowOverlay: false,
|
|
26
|
+
toastHeights: {},
|
|
27
|
+
isExpanded: false
|
|
28
|
+
};
|
|
29
|
+
subscribers = new Set();
|
|
30
|
+
config = {};
|
|
31
|
+
timers = new ToastTimerRegistry();
|
|
32
|
+
hideOverlayTimeout = null;
|
|
33
|
+
pendingPromises = new Set();
|
|
34
|
+
collapseCooldown = false;
|
|
35
|
+
collapseCooldownTimeout = null;
|
|
36
|
+
subscribe = callback => {
|
|
37
|
+
this.subscribers.add(callback);
|
|
38
|
+
return () => {
|
|
39
|
+
this.subscribers.delete(callback);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Stable while nothing has changed — safe as a `useSyncExternalStore` snapshot. */
|
|
44
|
+
getSnapshot = () => {
|
|
45
|
+
return this.state;
|
|
46
|
+
};
|
|
47
|
+
setConfig = config => {
|
|
48
|
+
this.config = config;
|
|
49
|
+
};
|
|
50
|
+
notify = () => {
|
|
51
|
+
this.subscribers.forEach(callback => callback());
|
|
52
|
+
};
|
|
53
|
+
cloneIndex = () => {
|
|
54
|
+
return new Map(this.state.toastsById);
|
|
55
|
+
};
|
|
56
|
+
resolveDuration = duration => {
|
|
57
|
+
return duration ?? this.config.duration ?? toastDefaults.duration;
|
|
58
|
+
};
|
|
59
|
+
scheduleAutoClose = (id, duration) => {
|
|
60
|
+
this.timers.start({
|
|
61
|
+
id,
|
|
62
|
+
duration,
|
|
63
|
+
onComplete: () => {
|
|
64
|
+
this.dismissToast(id, 'onAutoClose');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
pauseTimer = id => {
|
|
69
|
+
this.timers.pause(id);
|
|
70
|
+
};
|
|
71
|
+
resumeTimer = id => {
|
|
72
|
+
this.timers.resume(id);
|
|
73
|
+
};
|
|
74
|
+
pauseAllTimers = () => {
|
|
75
|
+
this.timers.pauseAll();
|
|
76
|
+
};
|
|
77
|
+
resumeAllTimers = () => {
|
|
78
|
+
this.timers.resumeAll();
|
|
79
|
+
};
|
|
80
|
+
handlePromise = async toast => {
|
|
81
|
+
const {
|
|
82
|
+
id,
|
|
83
|
+
promiseOptions
|
|
84
|
+
} = toast;
|
|
85
|
+
if (!promiseOptions || this.pendingPromises.has(id)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.pendingPromises.add(id);
|
|
89
|
+
try {
|
|
90
|
+
// Already the success title — see `PromiseOptions`.
|
|
91
|
+
const title = await promiseOptions.promise;
|
|
92
|
+
if (!this.state.toastsById.has(id)) return;
|
|
93
|
+
this.addToast({
|
|
94
|
+
title,
|
|
95
|
+
id,
|
|
96
|
+
variant: 'success',
|
|
97
|
+
promiseOptions: undefined,
|
|
98
|
+
duration: toast.duration,
|
|
99
|
+
styles: promiseOptions.styles?.success
|
|
100
|
+
});
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (!this.state.toastsById.has(id)) return;
|
|
103
|
+
this.addToast({
|
|
104
|
+
title: typeof promiseOptions.error === 'function' ? promiseOptions.error(error) : promiseOptions.error,
|
|
105
|
+
id,
|
|
106
|
+
variant: 'error',
|
|
107
|
+
promiseOptions: undefined,
|
|
108
|
+
duration: toast.duration,
|
|
109
|
+
styles: promiseOptions.styles?.error
|
|
110
|
+
});
|
|
111
|
+
} finally {
|
|
112
|
+
this.pendingPromises.delete(id);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
addToast = options => {
|
|
116
|
+
const providedId = typeof options.id === 'number' || typeof options.id === 'string' && options.id.length > 0 ? options.id : undefined;
|
|
117
|
+
const id = providedId ?? this.state.toastsCounter;
|
|
118
|
+
const nextCounter = providedId === undefined ? this.state.toastsCounter + 1 : this.state.toastsCounter;
|
|
119
|
+
const duration = this.resolveDuration(options.duration);
|
|
120
|
+
const newToast = {
|
|
121
|
+
...options,
|
|
122
|
+
id,
|
|
123
|
+
variant: options.variant ?? toastDefaults.variant,
|
|
124
|
+
duration,
|
|
125
|
+
// Assigned by the Toaster at render time from the live position group.
|
|
126
|
+
numberOfToasts: 0,
|
|
127
|
+
index: 0,
|
|
128
|
+
orderedToastIds: []
|
|
129
|
+
};
|
|
130
|
+
const existingToast = this.state.toastsById.get(id);
|
|
131
|
+
if (existingToast && providedId !== undefined) {
|
|
132
|
+
const shouldWiggle = this.config.autoWiggleOnUpdate === 'always' || this.config.autoWiggleOnUpdate === 'toast-change' && !areToastsEqual(newToast, existingToast);
|
|
133
|
+
if (shouldWiggle) {
|
|
134
|
+
this.wiggleToast(providedId);
|
|
135
|
+
}
|
|
136
|
+
const updatedToasts = this.state.toasts.map(currentToast => currentToast.id === providedId ? {
|
|
137
|
+
...currentToast,
|
|
138
|
+
...newToast
|
|
139
|
+
} : currentToast);
|
|
140
|
+
|
|
141
|
+
// The update may have changed the duration, so the timer restarts.
|
|
142
|
+
if (!newToast.promiseOptions) {
|
|
143
|
+
this.scheduleAutoClose(id, duration);
|
|
144
|
+
}
|
|
145
|
+
const updatedIndex = this.cloneIndex();
|
|
146
|
+
const updatedEntry = updatedToasts.find(t => t.id === providedId);
|
|
147
|
+
if (updatedEntry) {
|
|
148
|
+
updatedIndex.set(providedId, updatedEntry);
|
|
149
|
+
}
|
|
150
|
+
this.state = {
|
|
151
|
+
...this.state,
|
|
152
|
+
toasts: updatedToasts,
|
|
153
|
+
toastsById: updatedIndex,
|
|
154
|
+
shouldShowOverlay: true
|
|
155
|
+
};
|
|
156
|
+
} else {
|
|
157
|
+
const newToasts = [...this.state.toasts, newToast];
|
|
158
|
+
const newToastRefs = {
|
|
159
|
+
...this.state.toastRefs
|
|
160
|
+
};
|
|
161
|
+
if (!(id in newToastRefs)) {
|
|
162
|
+
newToastRefs[id] = /*#__PURE__*/React.createRef();
|
|
163
|
+
}
|
|
164
|
+
const visibleToasts = this.config.visibleToasts ?? toastDefaults.visibleToasts;
|
|
165
|
+
const newIndex = this.cloneIndex();
|
|
166
|
+
newIndex.set(id, newToast);
|
|
167
|
+
const updatedHeights = {
|
|
168
|
+
...this.state.toastHeights
|
|
169
|
+
};
|
|
170
|
+
let heightsChanged = false;
|
|
171
|
+
if (newToasts.length > visibleToasts) {
|
|
172
|
+
const removedToast = newToasts.shift();
|
|
173
|
+
if (removedToast) {
|
|
174
|
+
this.timers.clear(removedToast.id);
|
|
175
|
+
newIndex.delete(removedToast.id);
|
|
176
|
+
delete newToastRefs[removedToast.id];
|
|
177
|
+
if (removedToast.id in updatedHeights) {
|
|
178
|
+
delete updatedHeights[removedToast.id];
|
|
179
|
+
heightsChanged = true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
this.state = {
|
|
184
|
+
...this.state,
|
|
185
|
+
toasts: newToasts,
|
|
186
|
+
toastsById: newIndex,
|
|
187
|
+
toastRefs: newToastRefs,
|
|
188
|
+
toastHeights: heightsChanged ? updatedHeights : this.state.toastHeights,
|
|
189
|
+
toastsCounter: nextCounter,
|
|
190
|
+
shouldShowOverlay: true
|
|
191
|
+
};
|
|
192
|
+
if (newToast.promiseOptions) {
|
|
193
|
+
// A promise toast has no auto-close timer until it settles.
|
|
194
|
+
void this.handlePromise(newToast);
|
|
195
|
+
} else {
|
|
196
|
+
this.scheduleAutoClose(id, duration);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (this.hideOverlayTimeout) {
|
|
200
|
+
clearTimeout(this.hideOverlayTimeout);
|
|
201
|
+
this.hideOverlayTimeout = null;
|
|
202
|
+
}
|
|
203
|
+
this.notify();
|
|
204
|
+
return id;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/** Omit `id` to dismiss every toast. */
|
|
208
|
+
dismissToast = (id, origin) => {
|
|
209
|
+
if (id == null) {
|
|
210
|
+
this.timers.clearAll();
|
|
211
|
+
this.state.toasts.forEach(currentToast => {
|
|
212
|
+
if (origin === 'onDismiss') {
|
|
213
|
+
currentToast.onDismiss?.(currentToast.id);
|
|
214
|
+
} else {
|
|
215
|
+
currentToast.onAutoClose?.(currentToast.id);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
this.state = {
|
|
219
|
+
...this.state,
|
|
220
|
+
toasts: [],
|
|
221
|
+
toastsById: new Map(),
|
|
222
|
+
toastsCounter: 1,
|
|
223
|
+
toastRefs: {},
|
|
224
|
+
toastHeights: {},
|
|
225
|
+
isExpanded: false
|
|
226
|
+
};
|
|
227
|
+
this.scheduleHideOverlay();
|
|
228
|
+
this.notify();
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
this.timers.clear(id);
|
|
232
|
+
const toastForCallback = this.state.toastsById.get(id);
|
|
233
|
+
const filteredToasts = this.state.toasts.filter(currentToast => currentToast.id !== id);
|
|
234
|
+
const updatedHeights = {
|
|
235
|
+
...this.state.toastHeights
|
|
236
|
+
};
|
|
237
|
+
delete updatedHeights[id];
|
|
238
|
+
const updatedRefs = {
|
|
239
|
+
...this.state.toastRefs
|
|
240
|
+
};
|
|
241
|
+
delete updatedRefs[id];
|
|
242
|
+
const shouldAutoCollapse = filteredToasts.length <= 1 && this.state.isExpanded;
|
|
243
|
+
const updatedIndex = this.cloneIndex();
|
|
244
|
+
updatedIndex.delete(id);
|
|
245
|
+
this.state = {
|
|
246
|
+
...this.state,
|
|
247
|
+
toasts: filteredToasts,
|
|
248
|
+
toastsById: updatedIndex,
|
|
249
|
+
toastRefs: updatedRefs,
|
|
250
|
+
toastHeights: updatedHeights,
|
|
251
|
+
isExpanded: shouldAutoCollapse ? false : this.state.isExpanded
|
|
252
|
+
};
|
|
253
|
+
if (shouldAutoCollapse) {
|
|
254
|
+
this.timers.resumeAll();
|
|
255
|
+
}
|
|
256
|
+
if (origin === 'onDismiss') {
|
|
257
|
+
toastForCallback?.onDismiss?.(id);
|
|
258
|
+
} else {
|
|
259
|
+
toastForCallback?.onAutoClose?.(id);
|
|
260
|
+
}
|
|
261
|
+
if (filteredToasts.length === 0) {
|
|
262
|
+
this.scheduleHideOverlay();
|
|
263
|
+
}
|
|
264
|
+
this.notify();
|
|
265
|
+
return id;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/** Keeps the overlay mounted until the last exit animation has finished. */
|
|
269
|
+
scheduleHideOverlay = () => {
|
|
270
|
+
if (this.hideOverlayTimeout) {
|
|
271
|
+
clearTimeout(this.hideOverlayTimeout);
|
|
272
|
+
}
|
|
273
|
+
this.hideOverlayTimeout = setTimeout(() => {
|
|
274
|
+
this.state = {
|
|
275
|
+
...this.state,
|
|
276
|
+
shouldShowOverlay: false
|
|
277
|
+
};
|
|
278
|
+
this.hideOverlayTimeout = null;
|
|
279
|
+
this.notify();
|
|
280
|
+
}, ENTERING_ANIMATION_DURATION);
|
|
281
|
+
};
|
|
282
|
+
wiggleToast = id => {
|
|
283
|
+
const toast = this.state.toastsById.get(id);
|
|
284
|
+
if (!toast) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
this.state.toastRefs[id]?.current?.wiggle();
|
|
288
|
+
|
|
289
|
+
// A wiggle re-draws attention, so the reading time starts over — except for
|
|
290
|
+
// toasts that never auto-close.
|
|
291
|
+
if (!toast.promiseOptions) {
|
|
292
|
+
this.scheduleAutoClose(id, this.resolveDuration(toast.duration));
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
getToastRef = id => {
|
|
296
|
+
return this.state.toastRefs[id];
|
|
297
|
+
};
|
|
298
|
+
setToastHeight = (id, height) => {
|
|
299
|
+
if (this.state.toastHeights[id] === height) return;
|
|
300
|
+
// A NEW object, never an in-place write — see `ToastStoreState.toastHeights`.
|
|
301
|
+
this.state = {
|
|
302
|
+
...this.state,
|
|
303
|
+
toastHeights: {
|
|
304
|
+
...this.state.toastHeights,
|
|
305
|
+
[id]: height
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
this.notify();
|
|
309
|
+
};
|
|
310
|
+
expand = () => {
|
|
311
|
+
this.state = {
|
|
312
|
+
...this.state,
|
|
313
|
+
isExpanded: true
|
|
314
|
+
};
|
|
315
|
+
this.timers.pauseAll();
|
|
316
|
+
this.notify();
|
|
317
|
+
};
|
|
318
|
+
collapse = () => {
|
|
319
|
+
this.state = {
|
|
320
|
+
...this.state,
|
|
321
|
+
isExpanded: false
|
|
322
|
+
};
|
|
323
|
+
this.collapseCooldown = true;
|
|
324
|
+
if (this.collapseCooldownTimeout) {
|
|
325
|
+
clearTimeout(this.collapseCooldownTimeout);
|
|
326
|
+
}
|
|
327
|
+
this.collapseCooldownTimeout = setTimeout(() => {
|
|
328
|
+
this.collapseCooldown = false;
|
|
329
|
+
this.collapseCooldownTimeout = null;
|
|
330
|
+
}, COLLAPSE_COOLDOWN);
|
|
331
|
+
this.timers.resumeAll();
|
|
332
|
+
this.notify();
|
|
333
|
+
};
|
|
334
|
+
toggleExpand = () => {
|
|
335
|
+
if (!this.state.isExpanded && this.collapseCooldown) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (this.state.isExpanded) {
|
|
339
|
+
this.collapse();
|
|
340
|
+
} else {
|
|
341
|
+
this.expand();
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
export const toastStore = new ToastStore();
|
|
346
|
+
//# sourceMappingURL=toast-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","ENTERING_ANIMATION_DURATION","toastDefaults","areToastsEqual","ToastTimerRegistry","COLLAPSE_COOLDOWN","ToastStore","state","toasts","toastsById","Map","toastsCounter","toastRefs","shouldShowOverlay","toastHeights","isExpanded","subscribers","Set","config","timers","hideOverlayTimeout","pendingPromises","collapseCooldown","collapseCooldownTimeout","subscribe","callback","add","delete","getSnapshot","setConfig","notify","forEach","cloneIndex","resolveDuration","duration","scheduleAutoClose","id","start","onComplete","dismissToast","pauseTimer","pause","resumeTimer","resume","pauseAllTimers","pauseAll","resumeAllTimers","resumeAll","handlePromise","toast","promiseOptions","has","title","promise","addToast","variant","undefined","styles","success","error","options","providedId","length","nextCounter","newToast","numberOfToasts","index","orderedToastIds","existingToast","get","shouldWiggle","autoWiggleOnUpdate","wiggleToast","updatedToasts","map","currentToast","updatedIndex","updatedEntry","find","t","set","newToasts","newToastRefs","createRef","visibleToasts","newIndex","updatedHeights","heightsChanged","removedToast","shift","clear","clearTimeout","origin","clearAll","onDismiss","onAutoClose","scheduleHideOverlay","toastForCallback","filteredToasts","filter","updatedRefs","shouldAutoCollapse","setTimeout","current","wiggle","getToastRef","setToastHeight","height","expand","collapse","toggleExpand","toastStore"],"sourceRoot":"../../../src","sources":["toast/toast-store.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,2BAA2B,EAAEC,aAAa,QAAQ,gBAAa;AACxE,SAASC,cAAc,QAAQ,uBAAoB;AACnD,SAASC,kBAAkB,QAAQ,mBAAgB;AAUnD;AACA,MAAMC,iBAAiB,GAAG,GAAG;AAE7B,MAAMC,UAAU,CAAC;EACPC,KAAK,GAAoB;IAC/BC,MAAM,EAAE,EAAE;IACVC,UAAU,EAAE,IAAIC,GAAG,CAAC,CAAC;IACrBC,aAAa,EAAE,CAAC;IAChBC,SAAS,EAAE,CAAC,CAAC;IACbC,iBAAiB,EAAE,KAAK;IACxBC,YAAY,EAAE,CAAC,CAAC;IAChBC,UAAU,EAAE;EACd,CAAC;EAEOC,WAAW,GAAG,IAAIC,GAAG,CAAa,CAAC;EACnCC,MAAM,GAAqB,CAAC,CAAC;EAC7BC,MAAM,GAAG,IAAIf,kBAAkB,CAAC,CAAC;EACjCgB,kBAAkB,GAAyC,IAAI;EAC/DC,eAAe,GAAG,IAAIJ,GAAG,CAAkB,CAAC;EAC5CK,gBAAgB,GAAG,KAAK;EACxBC,uBAAuB,GAAyC,IAAI;EAE5EC,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,QAAQ,CAAC,CAAC;IACtB,IAAI,CAACf,MAAM,CAAC,CAAC;EACf,CAAC;EAED+E,QAAQ,GAAGA,CAAA,KAAM;IACf,IAAI,CAACtG,KAAK,GAAG;MACX,GAAG,IAAI,CAACA,KAAK;MACbQ,UAAU,EAAE;IACd,CAAC;IAED,IAAI,CAACO,gBAAgB,GAAG,IAAI;IAC5B,IAAI,IAAI,CAACC,uBAAuB,EAAE;MAChCoE,YAAY,CAAC,IAAI,CAACpE,uBAAuB,CAAC;IAC5C;IACA,IAAI,CAACA,uBAAuB,GAAG+E,UAAU,CAAC,MAAM;MAC9C,IAAI,CAAChF,gBAAgB,GAAG,KAAK;MAC7B,IAAI,CAACC,uBAAuB,GAAG,IAAI;IACrC,CAAC,EAAElB,iBAAiB,CAAC;IAErB,IAAI,CAACc,MAAM,CAAC4B,SAAS,CAAC,CAAC;IACvB,IAAI,CAACjB,MAAM,CAAC,CAAC;EACf,CAAC;EAEDgF,YAAY,GAAGA,CAAA,KAAM;IACnB,IAAI,CAAC,IAAI,CAACvG,KAAK,CAACQ,UAAU,IAAI,IAAI,CAACO,gBAAgB,EAAE;MACnD;IACF;IAEA,IAAI,IAAI,CAACf,KAAK,CAACQ,UAAU,EAAE;MACzB,IAAI,CAAC8F,QAAQ,CAAC,CAAC;IACjB,CAAC,MAAM;MACL,IAAI,CAACD,MAAM,CAAC,CAAC;IACf;EACF,CAAC;AACH;AAEA,OAAO,MAAMG,UAAU,GAAG,IAAIzG,UAAU,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Derived from sonner-native v0.26.4 — src/toast-store.ts:78-154
|
|
5
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
6
|
+
*
|
|
7
|
+
* Upstream keeps auto-close timers inside the store's React state even though no
|
|
8
|
+
* renderer ever reads them. Extracting them keeps the store's snapshot free of
|
|
9
|
+
* mutable side-channel data and makes the timing rules testable on their own.
|
|
10
|
+
*/
|
|
11
|
+
import { ENTERING_ANIMATION_DURATION } from "./constants.js";
|
|
12
|
+
/**
|
|
13
|
+
* A toast resumed after the app came back to the foreground always gets at least
|
|
14
|
+
* this long on screen — whatever was left of its duration when it was paused is
|
|
15
|
+
* usually too short to read on re-entry.
|
|
16
|
+
*/
|
|
17
|
+
const MIN_RESUMED_DURATION = 1000;
|
|
18
|
+
export class ToastTimerRegistry {
|
|
19
|
+
timers = new Map();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Non-finite durations (`Infinity`, `NaN`) mean "never auto-close" — starting a
|
|
23
|
+
* timer for them would either be pointless or fire immediately.
|
|
24
|
+
*/
|
|
25
|
+
start = ({
|
|
26
|
+
id,
|
|
27
|
+
duration,
|
|
28
|
+
onComplete
|
|
29
|
+
}) => {
|
|
30
|
+
if (!Number.isFinite(duration)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.clear(id);
|
|
34
|
+
|
|
35
|
+
// The toast is not fully on screen until the enter animation lands, so the
|
|
36
|
+
// readable duration starts there.
|
|
37
|
+
const timeout = setTimeout(() => {
|
|
38
|
+
this.timers.delete(id);
|
|
39
|
+
onComplete();
|
|
40
|
+
}, ENTERING_ANIMATION_DURATION + duration);
|
|
41
|
+
this.timers.set(id, {
|
|
42
|
+
timeout,
|
|
43
|
+
startTime: Date.now(),
|
|
44
|
+
remainingTime: duration,
|
|
45
|
+
isPaused: false,
|
|
46
|
+
onComplete
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
clear = id => {
|
|
50
|
+
const timer = this.timers.get(id);
|
|
51
|
+
if (!timer) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
clearTimeout(timer.timeout);
|
|
55
|
+
this.timers.delete(id);
|
|
56
|
+
};
|
|
57
|
+
clearAll = () => {
|
|
58
|
+
for (const timer of this.timers.values()) {
|
|
59
|
+
clearTimeout(timer.timeout);
|
|
60
|
+
}
|
|
61
|
+
this.timers.clear();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Banks the time left. The enter animation's head start is intentionally not
|
|
66
|
+
* subtracted, so a paused toast keeps up to `ENTERING_ANIMATION_DURATION` of
|
|
67
|
+
* slack — the same as upstream.
|
|
68
|
+
*/
|
|
69
|
+
pause = id => {
|
|
70
|
+
const timer = this.timers.get(id);
|
|
71
|
+
if (!timer || timer.isPaused) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
clearTimeout(timer.timeout);
|
|
75
|
+
timer.remainingTime = timer.remainingTime - (Date.now() - timer.startTime);
|
|
76
|
+
timer.isPaused = true;
|
|
77
|
+
};
|
|
78
|
+
resume = id => {
|
|
79
|
+
const timer = this.timers.get(id);
|
|
80
|
+
if (!timer || !timer.isPaused) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const {
|
|
84
|
+
onComplete
|
|
85
|
+
} = timer;
|
|
86
|
+
timer.isPaused = false;
|
|
87
|
+
timer.startTime = Date.now();
|
|
88
|
+
timer.timeout = setTimeout(() => {
|
|
89
|
+
this.timers.delete(id);
|
|
90
|
+
onComplete();
|
|
91
|
+
}, Math.max(timer.remainingTime, MIN_RESUMED_DURATION));
|
|
92
|
+
};
|
|
93
|
+
pauseAll = () => {
|
|
94
|
+
for (const id of [...this.timers.keys()]) {
|
|
95
|
+
this.pause(id);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
resumeAll = () => {
|
|
99
|
+
for (const id of [...this.timers.keys()]) {
|
|
100
|
+
this.resume(id);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=toast-timers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENTERING_ANIMATION_DURATION","MIN_RESUMED_DURATION","ToastTimerRegistry","timers","Map","start","id","duration","onComplete","Number","isFinite","clear","timeout","setTimeout","delete","set","startTime","Date","now","remainingTime","isPaused","timer","get","clearTimeout","clearAll","values","pause","resume","Math","max","pauseAll","keys","resumeAll"],"sourceRoot":"../../../src","sources":["toast/toast-timers.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,2BAA2B,QAAQ,gBAAa;AAUzD;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAG,IAAI;AAEjC,OAAO,MAAMC,kBAAkB,CAAC;EACtBC,MAAM,GAAG,IAAIC,GAAG,CAA8B,CAAC;;EAEvD;AACF;AACA;AACA;EACEC,KAAK,GAAGA,CAAC;IACPC,EAAE;IACFC,QAAQ;IACRC;EAKF,CAAC,KAAK;IACJ,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACH,QAAQ,CAAC,EAAE;MAC9B;IACF;IAEA,IAAI,CAACI,KAAK,CAACL,EAAE,CAAC;;IAEd;IACA;IACA,MAAMM,OAAO,GAAGC,UAAU,CAAC,MAAM;MAC/B,IAAI,CAACV,MAAM,CAACW,MAAM,CAACR,EAAE,CAAC;MACtBE,UAAU,CAAC,CAAC;IACd,CAAC,EAAER,2BAA2B,GAAGO,QAAQ,CAAC;IAE1C,IAAI,CAACJ,MAAM,CAACY,GAAG,CAACT,EAAE,EAAE;MAClBM,OAAO;MACPI,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC;MACrBC,aAAa,EAAEZ,QAAQ;MACvBa,QAAQ,EAAE,KAAK;MACfZ;IACF,CAAC,CAAC;EACJ,CAAC;EAEDG,KAAK,GAAIL,EAAmB,IAAK;IAC/B,MAAMe,KAAK,GAAG,IAAI,CAAClB,MAAM,CAACmB,GAAG,CAAChB,EAAE,CAAC;IACjC,IAAI,CAACe,KAAK,EAAE;MACV;IACF;IACAE,YAAY,CAACF,KAAK,CAACT,OAAO,CAAC;IAC3B,IAAI,CAACT,MAAM,CAACW,MAAM,CAACR,EAAE,CAAC;EACxB,CAAC;EAEDkB,QAAQ,GA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AK,MAAMxB,EAAE,IAAI,CAAC,GAAG,IAAI,CAACH,MAAM,CAAC4B,IAAI,CAAC,CAAC,CAAC,EAAE;MACxC,IAAI,CAACL,KAAK,CAACpB,EAAE,CAAC;IAChB;EACF,CAAC;EAED0B,SAAS,GAAGA,CAAA,KAAM;IAChB,KAAK,MAAM1B,EAAE,IAAI,CAAC,GAAG,IAAI,CAACH,MAAM,CAAC4B,IAAI,CAAC,CAAC,CAAC,EAAE;MACxC,IAAI,CAACJ,MAAM,CAACrB,EAAE,CAAC;IACjB;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,2 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Derived from sonner-native v0.26.4 — src/types.ts
|
|
5
|
+
* (MIT © Gunnar Torfi Steinarsson), absorbed into Bloom's own toast API.
|
|
6
|
+
* See the top-level NOTICE for full attribution.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Engine-internal variant. The PUBLIC knob is `ToastOptions['type']`; the single
|
|
11
|
+
* translation between the two lives in `toast-fns.ts`. `undefined` means "no
|
|
12
|
+
* variant" — a plain `toast('Saved')` renders with neutral surface colors.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Public variant knob. `'default'` maps to an ABSENT `ToastVariant`. */
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Light/dark is owned by `BloomThemeProvider`/`BloomColorScope`, so this is
|
|
19
|
+
* accepted and documented as a no-op rather than dropped from the surface.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The store's view of a pending promise toast. Non-generic on purpose: `promise`
|
|
24
|
+
* already resolves to the SUCCESS TITLE because `toast.promise` maps the caller's
|
|
25
|
+
* promise through their `success` formatter at the boundary. That is what lets
|
|
26
|
+
* the store await it without casting an `unknown` result back to the caller's
|
|
27
|
+
* type (upstream keeps `success` here and casts).
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** Everything a caller may pass alongside the toast content. */
|
|
31
|
+
|
|
32
|
+
/** The subset of `ToasterProps` the store needs to resolve a new toast. */
|
|
33
|
+
|
|
34
|
+
export function isToastAction(action) {
|
|
35
|
+
if (typeof action !== 'object' || action === null) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return 'label' in action && 'onClick' in action && typeof action.label === 'string' && typeof action.onClick === 'function';
|
|
39
|
+
}
|
|
2
40
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["toast/types.ts"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["isToastAction","action","label","onClick"],"sourceRoot":"../../../src","sources":["toast/types.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;;AAGA;;AASA;AACA;AACA;AACA;;AAwCA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqDA;;AAqGA;;AAyDA,OAAO,SAASA,aAAaA,CAC3BC,MAAqC,EACd;EACvB,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,KAAK,IAAI,EAAE;IACjD,OAAO,KAAK;EACd;EACA,OACE,OAAO,IAAIA,MAAM,IACjB,SAAS,IAAIA,MAAM,IACnB,OAAOA,MAAM,CAACC,KAAK,KAAK,QAAQ,IAChC,OAAOD,MAAM,CAACE,OAAO,KAAK,UAAU;AAExC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bloom-original — drives a shared value toward a plain-JS target.
|
|
5
|
+
*
|
|
6
|
+
* WHY THIS IS IMPERATIVE, AND MUST STAY THAT WAY.
|
|
7
|
+
*
|
|
8
|
+
* The obvious shape is `useDerivedValue(() => withTiming(target))`, which is what
|
|
9
|
+
* sonner-native does for both the stack offset and the stack scale. Returning an
|
|
10
|
+
* animation from a mapper does not tick on WEB (`~/Oxy/AGENTS.md`, reanimated web
|
|
11
|
+
* failure mode A): the value jumps to or freezes at a static frame, so the stack
|
|
12
|
+
* lands on the right numbers without ever animating. The pattern that works on
|
|
13
|
+
* every platform is to assign the animation from JS — `sv.value = withTiming(…)`
|
|
14
|
+
* — and to let `useAnimatedStyle` only READ shared values.
|
|
15
|
+
*
|
|
16
|
+
* A `useAnimatedReaction` keyed on the target would also fire (without the
|
|
17
|
+
* worklets plugin its inputs come from its own deps array, so keying it on a JS
|
|
18
|
+
* value works where keying it on a shared value would not), but a layout effect
|
|
19
|
+
* needs no reanimated machinery at all to be correct, so it is the smaller bet.
|
|
20
|
+
* It runs before paint, so a target change never shows a stale frame first.
|
|
21
|
+
* Precedent for the imperative drive: `bottom-sheet/BottomSheetBase.tsx`.
|
|
22
|
+
*
|
|
23
|
+
* By default the first render is seeded rather than animated: a row must appear
|
|
24
|
+
* AT its position, not fly in from zero. Pass `from` when the FIRST render is
|
|
25
|
+
* itself the animation — the value is then seeded at `from` and animated to
|
|
26
|
+
* `target` on mount. That is how the enter animation is driven; see the
|
|
27
|
+
* "Bloom owns the enter animation" note in `animations.ts`.
|
|
28
|
+
*/
|
|
29
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
30
|
+
import { useSharedValue, withTiming } from 'react-native-reanimated';
|
|
31
|
+
export function useAnimatedTarget(target, {
|
|
32
|
+
duration,
|
|
33
|
+
easing,
|
|
34
|
+
from
|
|
35
|
+
}) {
|
|
36
|
+
const value = useSharedValue(from ?? target);
|
|
37
|
+
const isSeeded = useRef(false);
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
if (!isSeeded.current) {
|
|
40
|
+
isSeeded.current = true;
|
|
41
|
+
if (from === undefined) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
value.value = withTiming(target, {
|
|
46
|
+
duration,
|
|
47
|
+
easing
|
|
48
|
+
});
|
|
49
|
+
}, [target, value, duration, easing, from]);
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=use-animated-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","useRef","useSharedValue","withTiming","useAnimatedTarget","target","duration","easing","from","value","isSeeded","current","undefined"],"sourceRoot":"../../../src","sources":["toast/use-animated-target.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAC/C,SACEC,cAAc,EACdC,UAAU,QAGL,yBAAyB;AAEhC,OAAO,SAASC,iBAAiBA,CAC/BC,MAAc,EACd;EACEC,QAAQ;EACRC,MAAM;EACNC;AAKF,CAAC,EACoB;EACrB,MAAMC,KAAK,GAAGP,cAAc,CAACM,IAAI,IAAIH,MAAM,CAAC;EAC5C,MAAMK,QAAQ,GAAGT,MAAM,CAAC,KAAK,CAAC;EAE9BD,eAAe,CAAC,MAAM;IACpB,IAAI,CAACU,QAAQ,CAACC,OAAO,EAAE;MACrBD,QAAQ,CAACC,OAAO,GAAG,IAAI;MACvB,IAAIH,IAAI,KAAKI,SAAS,EAAE;QACtB;MACF;IACF;IACAH,KAAK,CAACA,KAAK,GAAGN,UAAU,CAACE,MAAM,EAAE;MAAEC,QAAQ;MAAEC;IAAO,CAAC,CAAC;EACxD,CAAC,EAAE,CAACF,MAAM,EAAEI,KAAK,EAAEH,QAAQ,EAAEC,MAAM,EAAEC,IAAI,CAAC,CAAC;EAE3C,OAAOC,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Derived from sonner-native v0.26.4 — src/use-app-state.ts
|
|
5
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
6
|
+
*
|
|
7
|
+
* Owns the whole "did the app go away" concern in one place so callers never
|
|
8
|
+
* have to guard the platform themselves (W4). Two upstream problems are fixed
|
|
9
|
+
* here rather than at the call sites:
|
|
10
|
+
*
|
|
11
|
+
* 1. `AppState.addEventListener` is unavailable when react-native-web runs
|
|
12
|
+
* without a document (SSR / prerender / a non-DOM test environment), where
|
|
13
|
+
* RN reports `AppState.isAvailable === false`. Upstream subscribes
|
|
14
|
+
* unconditionally and then calls `subscription.remove()` on unmount, which
|
|
15
|
+
* throws a `TypeError` there. The absence of a subscription is a documented
|
|
16
|
+
* environment fact, not an error to catch and swallow — so this checks the
|
|
17
|
+
* flag the platform provides and returns a no-op unsubscribe.
|
|
18
|
+
* 2. Upstream treats every non-`active` transition as "backgrounded", so
|
|
19
|
+
* `background` → `inactive` fires `onBackground` a second time and re-pauses
|
|
20
|
+
* an already-paused timer. This compares active-ness on both sides of the
|
|
21
|
+
* transition and reports only real edges.
|
|
22
|
+
*/
|
|
23
|
+
import { useEffect, useRef } from 'react';
|
|
24
|
+
import { AppState } from 'react-native';
|
|
25
|
+
const NOOP = () => {};
|
|
26
|
+
const isActive = status => status === 'active';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Subscribe to app-state changes.
|
|
30
|
+
*
|
|
31
|
+
* @returns an unsubscribe function — a no-op when the platform provides no
|
|
32
|
+
* `AppState` subscription.
|
|
33
|
+
*/
|
|
34
|
+
export function subscribeToAppState(onChange) {
|
|
35
|
+
if (!AppState.isAvailable) {
|
|
36
|
+
return NOOP;
|
|
37
|
+
}
|
|
38
|
+
const subscription = AppState.addEventListener('change', onChange);
|
|
39
|
+
return () => {
|
|
40
|
+
subscription.remove();
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Call `onBackground` when the app leaves the foreground and `onForeground` when
|
|
46
|
+
* it comes back — once per edge, never on a transition between two inactive
|
|
47
|
+
* states.
|
|
48
|
+
*/
|
|
49
|
+
export function useAppStateChange({
|
|
50
|
+
onBackground,
|
|
51
|
+
onForeground
|
|
52
|
+
}) {
|
|
53
|
+
const previousStatus = useRef(AppState.currentState);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
return subscribeToAppState(nextStatus => {
|
|
56
|
+
const wasActive = isActive(previousStatus.current);
|
|
57
|
+
previousStatus.current = nextStatus;
|
|
58
|
+
if (isActive(nextStatus)) {
|
|
59
|
+
if (!wasActive) {
|
|
60
|
+
onForeground();
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (wasActive) {
|
|
65
|
+
onBackground();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}, [onBackground, onForeground]);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=use-app-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","AppState","NOOP","isActive","status","subscribeToAppState","onChange","isAvailable","subscription","addEventListener","remove","useAppStateChange","onBackground","onForeground","previousStatus","currentState","nextStatus","wasActive","current"],"sourceRoot":"../../../src","sources":["toast/use-app-state.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAA6B,cAAc;AAE5D,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,MAAMC,QAAQ,GAAIC,MAAsB,IAAKA,MAAM,KAAK,QAAQ;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjCC,QAA0C,EAC9B;EACZ,IAAI,CAACL,QAAQ,CAACM,WAAW,EAAE;IACzB,OAAOL,IAAI;EACb;EAEA,MAAMM,YAAY,GAAGP,QAAQ,CAACQ,gBAAgB,CAAC,QAAQ,EAAEH,QAAQ,CAAC;EAClE,OAAO,MAAM;IACXE,YAAY,CAACE,MAAM,CAAC,CAAC;EACvB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAC;EAChCC,YAAY;EACZC;AAIF,CAAC,EAAE;EACD,MAAMC,cAAc,GAAGd,MAAM,CAAiBC,QAAQ,CAACc,YAAY,CAAC;EAEpEhB,SAAS,CAAC,MAAM;IACd,OAAOM,mBAAmB,CAAEW,UAAU,IAAK;MACzC,MAAMC,SAAS,GAAGd,QAAQ,CAACW,cAAc,CAACI,OAAO,CAAC;MAClDJ,cAAc,CAACI,OAAO,GAAGF,UAAU;MAEnC,IAAIb,QAAQ,CAACa,UAAU,CAAC,EAAE;QACxB,IAAI,CAACC,SAAS,EAAE;UACdJ,YAAY,CAAC,CAAC;QAChB;QACA;MACF;MACA,IAAII,SAAS,EAAE;QACbL,YAAY,CAAC,CAAC;MAChB;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACA,YAAY,EAAEC,YAAY,CAAC,CAAC;AAClC","ignoreList":[]}
|