@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,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/toast-store.ts
|
|
3
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* The auto-close timers were lifted out into `toast-timers.ts`. Everything this
|
|
6
|
+
* module touches is pure JavaScript — `react` (for `createRef`), `./constants`,
|
|
7
|
+
* `./toast-comparator`, `./toast-timers` and type-only `./types`. Keep it that
|
|
8
|
+
* way: nothing here may reach React Native or Reanimated, or the store stops
|
|
9
|
+
* being testable without a platform.
|
|
10
|
+
*/
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { ENTERING_ANIMATION_DURATION, toastDefaults } from './constants';
|
|
13
|
+
import { areToastsEqual } from './toast-comparator';
|
|
14
|
+
import { ToastTimerRegistry } from './toast-timers';
|
|
15
|
+
import type {
|
|
16
|
+
ToastProps,
|
|
17
|
+
ToastRef,
|
|
18
|
+
ToastStoreConfig,
|
|
19
|
+
ToastStoreState,
|
|
20
|
+
} from './types';
|
|
21
|
+
|
|
22
|
+
type Subscriber = () => void;
|
|
23
|
+
|
|
24
|
+
/** How long the collapse gesture stays latched, so the same tap cannot re-expand. */
|
|
25
|
+
const COLLAPSE_COOLDOWN = 100;
|
|
26
|
+
|
|
27
|
+
class ToastStore {
|
|
28
|
+
private state: ToastStoreState = {
|
|
29
|
+
toasts: [],
|
|
30
|
+
toastsById: new Map(),
|
|
31
|
+
toastsCounter: 1,
|
|
32
|
+
toastRefs: {},
|
|
33
|
+
shouldShowOverlay: false,
|
|
34
|
+
toastHeights: {},
|
|
35
|
+
isExpanded: false,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
private subscribers = new Set<Subscriber>();
|
|
39
|
+
private config: ToastStoreConfig = {};
|
|
40
|
+
private timers = new ToastTimerRegistry();
|
|
41
|
+
private hideOverlayTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
42
|
+
private pendingPromises = new Set<string | number>();
|
|
43
|
+
private collapseCooldown = false;
|
|
44
|
+
private collapseCooldownTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
45
|
+
|
|
46
|
+
subscribe = (callback: Subscriber) => {
|
|
47
|
+
this.subscribers.add(callback);
|
|
48
|
+
return () => {
|
|
49
|
+
this.subscribers.delete(callback);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Stable while nothing has changed — safe as a `useSyncExternalStore` snapshot. */
|
|
54
|
+
getSnapshot = (): ToastStoreState => {
|
|
55
|
+
return this.state;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
setConfig = (config: ToastStoreConfig) => {
|
|
59
|
+
this.config = config;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
private notify = () => {
|
|
63
|
+
this.subscribers.forEach((callback) => callback());
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
private cloneIndex = (): Map<string | number, ToastProps> => {
|
|
67
|
+
return new Map(this.state.toastsById);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
private resolveDuration = (duration: number | undefined): number => {
|
|
71
|
+
return duration ?? this.config.duration ?? toastDefaults.duration;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
private scheduleAutoClose = (id: string | number, duration: number) => {
|
|
75
|
+
this.timers.start({
|
|
76
|
+
id,
|
|
77
|
+
duration,
|
|
78
|
+
onComplete: () => {
|
|
79
|
+
this.dismissToast(id, 'onAutoClose');
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
pauseTimer = (id: string | number) => {
|
|
85
|
+
this.timers.pause(id);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
resumeTimer = (id: string | number) => {
|
|
89
|
+
this.timers.resume(id);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
pauseAllTimers = () => {
|
|
93
|
+
this.timers.pauseAll();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
resumeAllTimers = () => {
|
|
97
|
+
this.timers.resumeAll();
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
private handlePromise = async (toast: ToastProps) => {
|
|
101
|
+
const { id, promiseOptions } = toast;
|
|
102
|
+
|
|
103
|
+
if (!promiseOptions || this.pendingPromises.has(id)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.pendingPromises.add(id);
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
// Already the success title — see `PromiseOptions`.
|
|
111
|
+
const title = await promiseOptions.promise;
|
|
112
|
+
|
|
113
|
+
if (!this.state.toastsById.has(id)) return;
|
|
114
|
+
|
|
115
|
+
this.addToast({
|
|
116
|
+
title,
|
|
117
|
+
id,
|
|
118
|
+
variant: 'success',
|
|
119
|
+
promiseOptions: undefined,
|
|
120
|
+
duration: toast.duration,
|
|
121
|
+
styles: promiseOptions.styles?.success,
|
|
122
|
+
});
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (!this.state.toastsById.has(id)) return;
|
|
125
|
+
|
|
126
|
+
this.addToast({
|
|
127
|
+
title:
|
|
128
|
+
typeof promiseOptions.error === 'function'
|
|
129
|
+
? promiseOptions.error(error)
|
|
130
|
+
: promiseOptions.error,
|
|
131
|
+
id,
|
|
132
|
+
variant: 'error',
|
|
133
|
+
promiseOptions: undefined,
|
|
134
|
+
duration: toast.duration,
|
|
135
|
+
styles: promiseOptions.styles?.error,
|
|
136
|
+
});
|
|
137
|
+
} finally {
|
|
138
|
+
this.pendingPromises.delete(id);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
addToast = (
|
|
143
|
+
options: Omit<
|
|
144
|
+
ToastProps,
|
|
145
|
+
'id' | 'numberOfToasts' | 'index' | 'orderedToastIds'
|
|
146
|
+
> & {
|
|
147
|
+
id?: string | number;
|
|
148
|
+
},
|
|
149
|
+
): string | number => {
|
|
150
|
+
const providedId =
|
|
151
|
+
typeof options.id === 'number' ||
|
|
152
|
+
(typeof options.id === 'string' && options.id.length > 0)
|
|
153
|
+
? options.id
|
|
154
|
+
: undefined;
|
|
155
|
+
|
|
156
|
+
const id: string | number = providedId ?? this.state.toastsCounter;
|
|
157
|
+
const nextCounter =
|
|
158
|
+
providedId === undefined
|
|
159
|
+
? this.state.toastsCounter + 1
|
|
160
|
+
: this.state.toastsCounter;
|
|
161
|
+
|
|
162
|
+
const duration = this.resolveDuration(options.duration);
|
|
163
|
+
|
|
164
|
+
const newToast: ToastProps = {
|
|
165
|
+
...options,
|
|
166
|
+
id,
|
|
167
|
+
variant: options.variant ?? toastDefaults.variant,
|
|
168
|
+
duration,
|
|
169
|
+
// Assigned by the Toaster at render time from the live position group.
|
|
170
|
+
numberOfToasts: 0,
|
|
171
|
+
index: 0,
|
|
172
|
+
orderedToastIds: [],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const existingToast = this.state.toastsById.get(id);
|
|
176
|
+
|
|
177
|
+
if (existingToast && providedId !== undefined) {
|
|
178
|
+
const shouldWiggle =
|
|
179
|
+
this.config.autoWiggleOnUpdate === 'always' ||
|
|
180
|
+
(this.config.autoWiggleOnUpdate === 'toast-change' &&
|
|
181
|
+
!areToastsEqual(newToast, existingToast));
|
|
182
|
+
|
|
183
|
+
if (shouldWiggle) {
|
|
184
|
+
this.wiggleToast(providedId);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const updatedToasts = this.state.toasts.map((currentToast) =>
|
|
188
|
+
currentToast.id === providedId
|
|
189
|
+
? { ...currentToast, ...newToast }
|
|
190
|
+
: currentToast,
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
// The update may have changed the duration, so the timer restarts.
|
|
194
|
+
if (!newToast.promiseOptions) {
|
|
195
|
+
this.scheduleAutoClose(id, duration);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const updatedIndex = this.cloneIndex();
|
|
199
|
+
const updatedEntry = updatedToasts.find((t) => t.id === providedId);
|
|
200
|
+
if (updatedEntry) {
|
|
201
|
+
updatedIndex.set(providedId, updatedEntry);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
this.state = {
|
|
205
|
+
...this.state,
|
|
206
|
+
toasts: updatedToasts,
|
|
207
|
+
toastsById: updatedIndex,
|
|
208
|
+
shouldShowOverlay: true,
|
|
209
|
+
};
|
|
210
|
+
} else {
|
|
211
|
+
const newToasts: ToastProps[] = [...this.state.toasts, newToast];
|
|
212
|
+
|
|
213
|
+
const newToastRefs = { ...this.state.toastRefs };
|
|
214
|
+
if (!(id in newToastRefs)) {
|
|
215
|
+
newToastRefs[id] = React.createRef<ToastRef>();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const visibleToasts =
|
|
219
|
+
this.config.visibleToasts ?? toastDefaults.visibleToasts;
|
|
220
|
+
const newIndex = this.cloneIndex();
|
|
221
|
+
newIndex.set(id, newToast);
|
|
222
|
+
const updatedHeights = { ...this.state.toastHeights };
|
|
223
|
+
let heightsChanged = false;
|
|
224
|
+
|
|
225
|
+
if (newToasts.length > visibleToasts) {
|
|
226
|
+
const removedToast = newToasts.shift();
|
|
227
|
+
if (removedToast) {
|
|
228
|
+
this.timers.clear(removedToast.id);
|
|
229
|
+
newIndex.delete(removedToast.id);
|
|
230
|
+
delete newToastRefs[removedToast.id];
|
|
231
|
+
if (removedToast.id in updatedHeights) {
|
|
232
|
+
delete updatedHeights[removedToast.id];
|
|
233
|
+
heightsChanged = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.state = {
|
|
239
|
+
...this.state,
|
|
240
|
+
toasts: newToasts,
|
|
241
|
+
toastsById: newIndex,
|
|
242
|
+
toastRefs: newToastRefs,
|
|
243
|
+
toastHeights: heightsChanged ? updatedHeights : this.state.toastHeights,
|
|
244
|
+
toastsCounter: nextCounter,
|
|
245
|
+
shouldShowOverlay: true,
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
if (newToast.promiseOptions) {
|
|
249
|
+
// A promise toast has no auto-close timer until it settles.
|
|
250
|
+
void this.handlePromise(newToast);
|
|
251
|
+
} else {
|
|
252
|
+
this.scheduleAutoClose(id, duration);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (this.hideOverlayTimeout) {
|
|
257
|
+
clearTimeout(this.hideOverlayTimeout);
|
|
258
|
+
this.hideOverlayTimeout = null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
this.notify();
|
|
262
|
+
return id;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
/** Omit `id` to dismiss every toast. */
|
|
266
|
+
dismissToast = (
|
|
267
|
+
id: string | number | undefined,
|
|
268
|
+
origin?: 'onDismiss' | 'onAutoClose',
|
|
269
|
+
): string | number | undefined => {
|
|
270
|
+
if (id == null) {
|
|
271
|
+
this.timers.clearAll();
|
|
272
|
+
this.state.toasts.forEach((currentToast) => {
|
|
273
|
+
if (origin === 'onDismiss') {
|
|
274
|
+
currentToast.onDismiss?.(currentToast.id);
|
|
275
|
+
} else {
|
|
276
|
+
currentToast.onAutoClose?.(currentToast.id);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
this.state = {
|
|
281
|
+
...this.state,
|
|
282
|
+
toasts: [],
|
|
283
|
+
toastsById: new Map(),
|
|
284
|
+
toastsCounter: 1,
|
|
285
|
+
toastRefs: {},
|
|
286
|
+
toastHeights: {},
|
|
287
|
+
isExpanded: false,
|
|
288
|
+
};
|
|
289
|
+
this.scheduleHideOverlay();
|
|
290
|
+
this.notify();
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
this.timers.clear(id);
|
|
295
|
+
|
|
296
|
+
const toastForCallback = this.state.toastsById.get(id);
|
|
297
|
+
|
|
298
|
+
const filteredToasts = this.state.toasts.filter(
|
|
299
|
+
(currentToast) => currentToast.id !== id,
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
const updatedHeights = { ...this.state.toastHeights };
|
|
303
|
+
delete updatedHeights[id];
|
|
304
|
+
|
|
305
|
+
const updatedRefs = { ...this.state.toastRefs };
|
|
306
|
+
delete updatedRefs[id];
|
|
307
|
+
|
|
308
|
+
const shouldAutoCollapse =
|
|
309
|
+
filteredToasts.length <= 1 && this.state.isExpanded;
|
|
310
|
+
|
|
311
|
+
const updatedIndex = this.cloneIndex();
|
|
312
|
+
updatedIndex.delete(id);
|
|
313
|
+
|
|
314
|
+
this.state = {
|
|
315
|
+
...this.state,
|
|
316
|
+
toasts: filteredToasts,
|
|
317
|
+
toastsById: updatedIndex,
|
|
318
|
+
toastRefs: updatedRefs,
|
|
319
|
+
toastHeights: updatedHeights,
|
|
320
|
+
isExpanded: shouldAutoCollapse ? false : this.state.isExpanded,
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
if (shouldAutoCollapse) {
|
|
324
|
+
this.timers.resumeAll();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (origin === 'onDismiss') {
|
|
328
|
+
toastForCallback?.onDismiss?.(id);
|
|
329
|
+
} else {
|
|
330
|
+
toastForCallback?.onAutoClose?.(id);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (filteredToasts.length === 0) {
|
|
334
|
+
this.scheduleHideOverlay();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this.notify();
|
|
338
|
+
return id;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/** Keeps the overlay mounted until the last exit animation has finished. */
|
|
342
|
+
private scheduleHideOverlay = () => {
|
|
343
|
+
if (this.hideOverlayTimeout) {
|
|
344
|
+
clearTimeout(this.hideOverlayTimeout);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.hideOverlayTimeout = setTimeout(() => {
|
|
348
|
+
this.state = {
|
|
349
|
+
...this.state,
|
|
350
|
+
shouldShowOverlay: false,
|
|
351
|
+
};
|
|
352
|
+
this.hideOverlayTimeout = null;
|
|
353
|
+
this.notify();
|
|
354
|
+
}, ENTERING_ANIMATION_DURATION);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
wiggleToast = (id: string | number) => {
|
|
358
|
+
const toast = this.state.toastsById.get(id);
|
|
359
|
+
if (!toast) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
this.state.toastRefs[id]?.current?.wiggle();
|
|
364
|
+
|
|
365
|
+
// A wiggle re-draws attention, so the reading time starts over — except for
|
|
366
|
+
// toasts that never auto-close.
|
|
367
|
+
if (!toast.promiseOptions) {
|
|
368
|
+
this.scheduleAutoClose(id, this.resolveDuration(toast.duration));
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
getToastRef = (
|
|
373
|
+
id: string | number,
|
|
374
|
+
): React.RefObject<ToastRef | null> | undefined => {
|
|
375
|
+
return this.state.toastRefs[id];
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
setToastHeight = (id: string | number, height: number) => {
|
|
379
|
+
if (this.state.toastHeights[id] === height) return;
|
|
380
|
+
// A NEW object, never an in-place write — see `ToastStoreState.toastHeights`.
|
|
381
|
+
this.state = {
|
|
382
|
+
...this.state,
|
|
383
|
+
toastHeights: {
|
|
384
|
+
...this.state.toastHeights,
|
|
385
|
+
[id]: height,
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
this.notify();
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
expand = () => {
|
|
392
|
+
this.state = {
|
|
393
|
+
...this.state,
|
|
394
|
+
isExpanded: true,
|
|
395
|
+
};
|
|
396
|
+
this.timers.pauseAll();
|
|
397
|
+
this.notify();
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
collapse = () => {
|
|
401
|
+
this.state = {
|
|
402
|
+
...this.state,
|
|
403
|
+
isExpanded: false,
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
this.collapseCooldown = true;
|
|
407
|
+
if (this.collapseCooldownTimeout) {
|
|
408
|
+
clearTimeout(this.collapseCooldownTimeout);
|
|
409
|
+
}
|
|
410
|
+
this.collapseCooldownTimeout = setTimeout(() => {
|
|
411
|
+
this.collapseCooldown = false;
|
|
412
|
+
this.collapseCooldownTimeout = null;
|
|
413
|
+
}, COLLAPSE_COOLDOWN);
|
|
414
|
+
|
|
415
|
+
this.timers.resumeAll();
|
|
416
|
+
this.notify();
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
toggleExpand = () => {
|
|
420
|
+
if (!this.state.isExpanded && this.collapseCooldown) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (this.state.isExpanded) {
|
|
425
|
+
this.collapse();
|
|
426
|
+
} else {
|
|
427
|
+
this.expand();
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export const toastStore = new ToastStore();
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/toast-store.ts:78-154
|
|
3
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* Upstream keeps auto-close timers inside the store's React state even though no
|
|
6
|
+
* renderer ever reads them. Extracting them keeps the store's snapshot free of
|
|
7
|
+
* mutable side-channel data and makes the timing rules testable on their own.
|
|
8
|
+
*/
|
|
9
|
+
import { ENTERING_ANIMATION_DURATION } from './constants';
|
|
10
|
+
|
|
11
|
+
type ToastTimer = {
|
|
12
|
+
timeout: ReturnType<typeof setTimeout>;
|
|
13
|
+
startTime: number;
|
|
14
|
+
remainingTime: number;
|
|
15
|
+
isPaused: boolean;
|
|
16
|
+
onComplete: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A toast resumed after the app came back to the foreground always gets at least
|
|
21
|
+
* this long on screen — whatever was left of its duration when it was paused is
|
|
22
|
+
* usually too short to read on re-entry.
|
|
23
|
+
*/
|
|
24
|
+
const MIN_RESUMED_DURATION = 1000;
|
|
25
|
+
|
|
26
|
+
export class ToastTimerRegistry {
|
|
27
|
+
private timers = new Map<string | number, ToastTimer>();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Non-finite durations (`Infinity`, `NaN`) mean "never auto-close" — starting a
|
|
31
|
+
* timer for them would either be pointless or fire immediately.
|
|
32
|
+
*/
|
|
33
|
+
start = ({
|
|
34
|
+
id,
|
|
35
|
+
duration,
|
|
36
|
+
onComplete,
|
|
37
|
+
}: {
|
|
38
|
+
id: string | number;
|
|
39
|
+
duration: number;
|
|
40
|
+
onComplete: () => void;
|
|
41
|
+
}) => {
|
|
42
|
+
if (!Number.isFinite(duration)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.clear(id);
|
|
47
|
+
|
|
48
|
+
// The toast is not fully on screen until the enter animation lands, so the
|
|
49
|
+
// readable duration starts there.
|
|
50
|
+
const timeout = setTimeout(() => {
|
|
51
|
+
this.timers.delete(id);
|
|
52
|
+
onComplete();
|
|
53
|
+
}, ENTERING_ANIMATION_DURATION + duration);
|
|
54
|
+
|
|
55
|
+
this.timers.set(id, {
|
|
56
|
+
timeout,
|
|
57
|
+
startTime: Date.now(),
|
|
58
|
+
remainingTime: duration,
|
|
59
|
+
isPaused: false,
|
|
60
|
+
onComplete,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
clear = (id: string | number) => {
|
|
65
|
+
const timer = this.timers.get(id);
|
|
66
|
+
if (!timer) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
clearTimeout(timer.timeout);
|
|
70
|
+
this.timers.delete(id);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
clearAll = () => {
|
|
74
|
+
for (const timer of this.timers.values()) {
|
|
75
|
+
clearTimeout(timer.timeout);
|
|
76
|
+
}
|
|
77
|
+
this.timers.clear();
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Banks the time left. The enter animation's head start is intentionally not
|
|
82
|
+
* subtracted, so a paused toast keeps up to `ENTERING_ANIMATION_DURATION` of
|
|
83
|
+
* slack — the same as upstream.
|
|
84
|
+
*/
|
|
85
|
+
pause = (id: string | number) => {
|
|
86
|
+
const timer = this.timers.get(id);
|
|
87
|
+
if (!timer || timer.isPaused) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
clearTimeout(timer.timeout);
|
|
91
|
+
timer.remainingTime = timer.remainingTime - (Date.now() - timer.startTime);
|
|
92
|
+
timer.isPaused = true;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
resume = (id: string | number) => {
|
|
96
|
+
const timer = this.timers.get(id);
|
|
97
|
+
if (!timer || !timer.isPaused) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const { onComplete } = timer;
|
|
102
|
+
timer.isPaused = false;
|
|
103
|
+
timer.startTime = Date.now();
|
|
104
|
+
timer.timeout = setTimeout(
|
|
105
|
+
() => {
|
|
106
|
+
this.timers.delete(id);
|
|
107
|
+
onComplete();
|
|
108
|
+
},
|
|
109
|
+
Math.max(timer.remainingTime, MIN_RESUMED_DURATION),
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
pauseAll = () => {
|
|
114
|
+
for (const id of [...this.timers.keys()]) {
|
|
115
|
+
this.pause(id);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
resumeAll = () => {
|
|
120
|
+
for (const id of [...this.timers.keys()]) {
|
|
121
|
+
this.resume(id);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|