@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,485 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/toast.tsx:39-437
|
|
3
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* The animated shell around a row: stack offset + scale, enter/exit animation,
|
|
6
|
+
* height measurement, swipe wrapper and the imperative wiggle handle. The visual
|
|
7
|
+
* row itself is `ToastContent` (or the consumer's `jsx`).
|
|
8
|
+
*
|
|
9
|
+
* W6 — INVARIANT: THE MEASURED `Animated.View` IS `style`-ONLY, NEVER
|
|
10
|
+
* `className`'d. Under react-native-css on web, `onLayout` never fires for a
|
|
11
|
+
* className'd component, which would strand every row at
|
|
12
|
+
* `ESTIMATED_TOAST_HEIGHT` and pile the stack on top of itself. Measurement runs
|
|
13
|
+
* a three-tier ladder — `getBoundingClientRect()` (RN >= 0.83 refs and RN-Web),
|
|
14
|
+
* then `measureInWindow` (older New Arch), then `onLayout` as the safety net —
|
|
15
|
+
* so no single platform quirk can silently degrade it. A consumer's `toast.custom`
|
|
16
|
+
* JSX is unaffected: the ref sits on this engine wrapper, not on their element.
|
|
17
|
+
*
|
|
18
|
+
* W3 — the animated style READS two shared values and returns only the transform.
|
|
19
|
+
* `position`, `width` and the `top`/`bottom` anchor are static `StyleSheet` entries:
|
|
20
|
+
* upstream writes the anchor conditionally INSIDE the mapper, so the previous
|
|
21
|
+
* anchor is never cleared when `position` changes and the static keys are
|
|
22
|
+
* re-committed every frame. Both shared values are driven imperatively from plain-JS
|
|
23
|
+
* targets (`useAnimatedTarget`), never returned from a mapper.
|
|
24
|
+
*
|
|
25
|
+
* W5 — this row does NOT subscribe to `AppState`. `Toaster` holds one
|
|
26
|
+
* subscription for the whole stack (upstream creates one per row, so N toasts
|
|
27
|
+
* meant N `visibilitychange` listeners).
|
|
28
|
+
*
|
|
29
|
+
* THE EXIT IS ALWAYS A LAYOUT ANIMATION; THE ENTER DEPENDS ON THE PLATFORM.
|
|
30
|
+
* `animations.ts` returns EITHER an `entering` builder (native, and any consumer
|
|
31
|
+
* override) OR an `enterTranslateY` for `rowStyle` below to fade and slide the row
|
|
32
|
+
* in imperatively (web default) — never both. When `enterTranslateY` is
|
|
33
|
+
* `undefined`, `enterProgress` is seeded at 1 and `rowStyle` collapses to the
|
|
34
|
+
* wiggle scale alone, so nothing here competes with `entering`. Both halves of
|
|
35
|
+
* that split are load-bearing and neither may be "simplified" into the other:
|
|
36
|
+
* `animations.ts` documents the web pin that forbids `entering` on web and the
|
|
37
|
+
* native regression that forbids the imperative driver on native.
|
|
38
|
+
*/
|
|
39
|
+
import * as React from 'react';
|
|
40
|
+
import {
|
|
41
|
+
StyleSheet,
|
|
42
|
+
View,
|
|
43
|
+
useWindowDimensions,
|
|
44
|
+
type LayoutChangeEvent,
|
|
45
|
+
} from 'react-native';
|
|
46
|
+
import Animated, {
|
|
47
|
+
useAnimatedStyle,
|
|
48
|
+
useSharedValue,
|
|
49
|
+
withRepeat,
|
|
50
|
+
withTiming,
|
|
51
|
+
} from 'react-native-reanimated';
|
|
52
|
+
|
|
53
|
+
import { easeOutQuartFn, useToastLayoutAnimations } from './animations';
|
|
54
|
+
import {
|
|
55
|
+
CLOSE_BUTTON_HIT_AREA,
|
|
56
|
+
ENTERING_ANIMATION_DURATION,
|
|
57
|
+
STACKING_ANIMATION_DURATION,
|
|
58
|
+
toastDefaults,
|
|
59
|
+
} from './constants';
|
|
60
|
+
import { useDynamicToastContext, useToastContext } from './context';
|
|
61
|
+
import { calculateStackScaleX } from './position-utils';
|
|
62
|
+
import { useAnimatedTarget } from './use-animated-target';
|
|
63
|
+
import { ToastContent } from './ToastContent';
|
|
64
|
+
import { ToastSwipeHandler } from './ToastSwipeHandler';
|
|
65
|
+
import { toastStore } from './toast-store';
|
|
66
|
+
import type {
|
|
67
|
+
ToasterProps,
|
|
68
|
+
ToastPosition,
|
|
69
|
+
ToastProps,
|
|
70
|
+
ToastRef,
|
|
71
|
+
ToastStyles,
|
|
72
|
+
} from './types';
|
|
73
|
+
import { useToastPosition } from './use-toast-position';
|
|
74
|
+
|
|
75
|
+
/** How much a wiggle grows the row, and for how long per half-cycle. */
|
|
76
|
+
const WIGGLE_SCALE = 1.035;
|
|
77
|
+
const WIGGLE_DURATION = 150;
|
|
78
|
+
const WIGGLE_REPEATS = 4;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Fold the outlet-level `toastOptions` style slots into the per-toast
|
|
82
|
+
* `ToastStyles` shape so the renderer has ONE styles object to apply. Upstream
|
|
83
|
+
* threads all fifteen slots down as separate props; collapsing them here keeps
|
|
84
|
+
* `ToastContent` to a single `styles` prop while honouring the same API. The
|
|
85
|
+
* per-toast value always wins over the outlet's.
|
|
86
|
+
*/
|
|
87
|
+
function mergeToastStyles(
|
|
88
|
+
toastOptions: NonNullable<ToasterProps['toastOptions']>,
|
|
89
|
+
perToast: ToastStyles | undefined,
|
|
90
|
+
variantStyle: ToastStyles['toast'],
|
|
91
|
+
): ToastStyles {
|
|
92
|
+
return {
|
|
93
|
+
toastContainer: {
|
|
94
|
+
...toastOptions.toastContainerStyle,
|
|
95
|
+
...perToast?.toastContainer,
|
|
96
|
+
},
|
|
97
|
+
toast: {
|
|
98
|
+
...toastOptions.style,
|
|
99
|
+
...variantStyle,
|
|
100
|
+
...perToast?.toast,
|
|
101
|
+
},
|
|
102
|
+
toastContent: {
|
|
103
|
+
...toastOptions.toastContentStyle,
|
|
104
|
+
...perToast?.toastContent,
|
|
105
|
+
},
|
|
106
|
+
textContainer: {
|
|
107
|
+
...toastOptions.textContainerStyle,
|
|
108
|
+
...perToast?.textContainer,
|
|
109
|
+
},
|
|
110
|
+
title: { ...toastOptions.titleStyle, ...perToast?.title },
|
|
111
|
+
description: { ...toastOptions.descriptionStyle, ...perToast?.description },
|
|
112
|
+
buttons: { ...toastOptions.buttonsStyle, ...perToast?.buttons },
|
|
113
|
+
closeButton: {
|
|
114
|
+
...toastOptions.closeButtonStyle,
|
|
115
|
+
...perToast?.closeButton,
|
|
116
|
+
},
|
|
117
|
+
closeButtonIcon: {
|
|
118
|
+
...toastOptions.closeButtonIconStyle,
|
|
119
|
+
...perToast?.closeButtonIcon,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type ToastRowProps = ToastProps & {
|
|
125
|
+
onDismiss: (id: string | number) => void;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const ToastRow = React.forwardRef<ToastRef, ToastRowProps>(
|
|
129
|
+
function ToastRow(
|
|
130
|
+
{
|
|
131
|
+
id,
|
|
132
|
+
title,
|
|
133
|
+
jsx,
|
|
134
|
+
description,
|
|
135
|
+
icon,
|
|
136
|
+
duration,
|
|
137
|
+
variant,
|
|
138
|
+
action,
|
|
139
|
+
cancel,
|
|
140
|
+
close,
|
|
141
|
+
onDismiss,
|
|
142
|
+
dismissible = toastDefaults.dismissible,
|
|
143
|
+
closeButton: closeButtonProp,
|
|
144
|
+
actionButtonStyle,
|
|
145
|
+
actionButtonTextStyle,
|
|
146
|
+
cancelButtonStyle,
|
|
147
|
+
cancelButtonTextStyle,
|
|
148
|
+
style,
|
|
149
|
+
styles: styleOverrides,
|
|
150
|
+
promiseOptions,
|
|
151
|
+
position: positionProp,
|
|
152
|
+
animation,
|
|
153
|
+
unstyled: unstyledProp,
|
|
154
|
+
important,
|
|
155
|
+
richColors: richColorsProp,
|
|
156
|
+
onPress,
|
|
157
|
+
allowFontScaling: allowFontScalingProp,
|
|
158
|
+
maxFontSizeMultiplier: maxFontSizeMultiplierProp,
|
|
159
|
+
backgroundComponent: backgroundComponentProp,
|
|
160
|
+
numberOfToasts,
|
|
161
|
+
index,
|
|
162
|
+
orderedToastIds,
|
|
163
|
+
},
|
|
164
|
+
ref,
|
|
165
|
+
) {
|
|
166
|
+
const {
|
|
167
|
+
closeButton: closeButtonCtx,
|
|
168
|
+
icons,
|
|
169
|
+
richColors: richColorsCtx,
|
|
170
|
+
allowFontScaling: allowFontScalingCtx,
|
|
171
|
+
maxFontSizeMultiplier: maxFontSizeMultiplierCtx,
|
|
172
|
+
enableStacking,
|
|
173
|
+
gap,
|
|
174
|
+
position: positionCtx,
|
|
175
|
+
visibleToasts,
|
|
176
|
+
unstyled: unstyledCtx,
|
|
177
|
+
toastOptions,
|
|
178
|
+
} = useToastContext();
|
|
179
|
+
const { toastHeights, isExpanded, toggleExpand } = useDynamicToastContext();
|
|
180
|
+
|
|
181
|
+
const position = positionProp ?? positionCtx;
|
|
182
|
+
const unstyled = unstyledProp ?? toastOptions.unstyled ?? unstyledCtx;
|
|
183
|
+
const richColors = richColorsProp ?? richColorsCtx;
|
|
184
|
+
const closeButton = closeButtonProp ?? closeButtonCtx;
|
|
185
|
+
const allowFontScaling = allowFontScalingProp ?? allowFontScalingCtx;
|
|
186
|
+
const maxFontSizeMultiplier =
|
|
187
|
+
maxFontSizeMultiplierProp ?? maxFontSizeMultiplierCtx;
|
|
188
|
+
const backgroundComponent =
|
|
189
|
+
backgroundComponentProp ?? toastOptions.backgroundComponent;
|
|
190
|
+
const stackGap = gap ?? toastDefaults.stackGap;
|
|
191
|
+
|
|
192
|
+
const mergedStyles = React.useMemo(
|
|
193
|
+
() =>
|
|
194
|
+
mergeToastStyles(
|
|
195
|
+
toastOptions,
|
|
196
|
+
styleOverrides,
|
|
197
|
+
variant ? toastOptions[variant] : undefined,
|
|
198
|
+
),
|
|
199
|
+
[toastOptions, styleOverrides, variant],
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
// For top-center the array is reversed, so the front row is index 0.
|
|
203
|
+
const distanceFromFront =
|
|
204
|
+
position === 'top-center' ? index : numberOfToasts - 1 - index;
|
|
205
|
+
const isHiddenByLimit = enableStacking && distanceFromFront >= visibleToasts;
|
|
206
|
+
|
|
207
|
+
const { entering, exiting, enterTranslateY } = useToastLayoutAnimations(
|
|
208
|
+
positionProp,
|
|
209
|
+
animation,
|
|
210
|
+
isHiddenByLimit,
|
|
211
|
+
numberOfToasts,
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const yPosition = useToastPosition({
|
|
215
|
+
index,
|
|
216
|
+
numberOfToasts,
|
|
217
|
+
enableStacking,
|
|
218
|
+
position,
|
|
219
|
+
allToastHeights: toastHeights,
|
|
220
|
+
gap,
|
|
221
|
+
orderedToastIds,
|
|
222
|
+
isExpanded,
|
|
223
|
+
stackGap,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const { width: screenWidth } = useWindowDimensions();
|
|
227
|
+
|
|
228
|
+
const stackScaleX = useAnimatedTarget(
|
|
229
|
+
calculateStackScaleX({
|
|
230
|
+
index,
|
|
231
|
+
numberOfToasts,
|
|
232
|
+
enableStacking,
|
|
233
|
+
position,
|
|
234
|
+
isExpanded,
|
|
235
|
+
stackGap,
|
|
236
|
+
screenWidth,
|
|
237
|
+
}),
|
|
238
|
+
{ duration: STACKING_ANIMATION_DURATION, easing: easeOutQuartFn },
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const stackTransformStyle = useAnimatedStyle(
|
|
242
|
+
() => ({
|
|
243
|
+
transform: [
|
|
244
|
+
{ translateY: yPosition.value },
|
|
245
|
+
{ scaleX: stackScaleX.value },
|
|
246
|
+
],
|
|
247
|
+
}),
|
|
248
|
+
[yPosition, stackScaleX],
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
// 0 -> 1 over the enter animation. Seeded at 1 with NO mount-time `withTiming`
|
|
252
|
+
// whenever `enterTranslateY` is undefined — i.e. whenever `entering` is playing
|
|
253
|
+
// the enter instead, or reduced motion is on — leaving this style the identity.
|
|
254
|
+
const enterProgress = useAnimatedTarget(1, {
|
|
255
|
+
duration: ENTERING_ANIMATION_DURATION,
|
|
256
|
+
easing: easeOutQuartFn,
|
|
257
|
+
from: enterTranslateY === undefined ? undefined : 0,
|
|
258
|
+
});
|
|
259
|
+
const enterDistance = enterTranslateY ?? 0;
|
|
260
|
+
|
|
261
|
+
const wiggleScale = useSharedValue(1);
|
|
262
|
+
// ONE mapper for both transforms: two animated styles on the same view would
|
|
263
|
+
// each return a `transform` array and the later one would win outright.
|
|
264
|
+
const rowStyle = useAnimatedStyle(
|
|
265
|
+
() => ({
|
|
266
|
+
opacity: enterProgress.value,
|
|
267
|
+
transform: [
|
|
268
|
+
{ translateY: (1 - enterProgress.value) * enterDistance },
|
|
269
|
+
{ scale: wiggleScale.value },
|
|
270
|
+
],
|
|
271
|
+
}),
|
|
272
|
+
[enterProgress, enterDistance, wiggleScale],
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
const wiggle = React.useCallback(() => {
|
|
276
|
+
'worklet';
|
|
277
|
+
wiggleScale.value = withRepeat(
|
|
278
|
+
withTiming(Math.min(wiggleScale.value * WIGGLE_SCALE, WIGGLE_SCALE), {
|
|
279
|
+
duration: WIGGLE_DURATION,
|
|
280
|
+
}),
|
|
281
|
+
WIGGLE_REPEATS,
|
|
282
|
+
true,
|
|
283
|
+
);
|
|
284
|
+
}, [wiggleScale]);
|
|
285
|
+
|
|
286
|
+
const handleWiggle = React.useCallback(() => {
|
|
287
|
+
// A toast that never auto-closes has no timer to draw attention back to.
|
|
288
|
+
if (duration === Infinity) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (wiggleScale.value !== 1) {
|
|
292
|
+
// Settle back to rest first, otherwise the scale compounds.
|
|
293
|
+
wiggleScale.value = withTiming(1, { duration: WIGGLE_DURATION }, wiggle);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
wiggle();
|
|
297
|
+
}, [wiggle, wiggleScale, duration]);
|
|
298
|
+
|
|
299
|
+
React.useImperativeHandle(ref, () => ({ wiggle: handleWiggle }));
|
|
300
|
+
|
|
301
|
+
const measuredRef = React.useRef<
|
|
302
|
+
(View & { getBoundingClientRect?: () => DOMRect }) | null
|
|
303
|
+
>(null);
|
|
304
|
+
|
|
305
|
+
// Tiers 1 and 2 of the ladder — see the W6 note in the file header.
|
|
306
|
+
React.useLayoutEffect(() => {
|
|
307
|
+
const node = measuredRef.current;
|
|
308
|
+
if (!node) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (typeof node.getBoundingClientRect === 'function') {
|
|
313
|
+
toastStore.setToastHeight(id, node.getBoundingClientRect().height);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let stale = false;
|
|
318
|
+
node.measureInWindow((_x, _y, _width, height) => {
|
|
319
|
+
if (!stale) {
|
|
320
|
+
toastStore.setToastHeight(id, height);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
return () => {
|
|
324
|
+
stale = true;
|
|
325
|
+
};
|
|
326
|
+
}, [id, variant, title, description, jsx]);
|
|
327
|
+
|
|
328
|
+
// Tier 3. Also the only tier that reports a LATER resize (a wrapped line, a
|
|
329
|
+
// font swap) on platforms without a synchronous read.
|
|
330
|
+
const handleLayout = React.useCallback(
|
|
331
|
+
({ nativeEvent }: LayoutChangeEvent) => {
|
|
332
|
+
const { height } = nativeEvent.layout;
|
|
333
|
+
if (height > 0) {
|
|
334
|
+
toastStore.setToastHeight(id, height);
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
[id],
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
const onRemove = React.useCallback(() => {
|
|
341
|
+
onDismiss(id);
|
|
342
|
+
}, [onDismiss, id]);
|
|
343
|
+
|
|
344
|
+
const onSwipeBegin = React.useCallback(() => {
|
|
345
|
+
toastStore.pauseTimer(id);
|
|
346
|
+
}, [id]);
|
|
347
|
+
|
|
348
|
+
const onSwipeFinalize = React.useCallback(() => {
|
|
349
|
+
if (!isExpanded) {
|
|
350
|
+
toastStore.resumeTimer(id);
|
|
351
|
+
}
|
|
352
|
+
}, [id, isExpanded]);
|
|
353
|
+
|
|
354
|
+
const onSwipePress = React.useCallback(
|
|
355
|
+
({ x }: { x: number; y: number }) => {
|
|
356
|
+
if (enableStacking && numberOfToasts > 1 && position !== 'center') {
|
|
357
|
+
// On Android the RNGH tap wins the race against the nested Pressable,
|
|
358
|
+
// so a press in the close-button strip has to dismiss explicitly.
|
|
359
|
+
if (x > screenWidth - CLOSE_BUTTON_HIT_AREA) {
|
|
360
|
+
if (isExpanded && closeButton && dismissible) {
|
|
361
|
+
onDismiss(id);
|
|
362
|
+
}
|
|
363
|
+
} else {
|
|
364
|
+
toggleExpand();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
onPress?.();
|
|
368
|
+
},
|
|
369
|
+
[
|
|
370
|
+
enableStacking,
|
|
371
|
+
numberOfToasts,
|
|
372
|
+
position,
|
|
373
|
+
screenWidth,
|
|
374
|
+
isExpanded,
|
|
375
|
+
closeButton,
|
|
376
|
+
dismissible,
|
|
377
|
+
onDismiss,
|
|
378
|
+
id,
|
|
379
|
+
toggleExpand,
|
|
380
|
+
onPress,
|
|
381
|
+
],
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
// Front row on top: later rows in the stack sit progressively behind.
|
|
385
|
+
const stackZIndex =
|
|
386
|
+
position === 'top-center' ? -(index + 1) : -(numberOfToasts - index);
|
|
387
|
+
|
|
388
|
+
return (
|
|
389
|
+
<Animated.View
|
|
390
|
+
style={[
|
|
391
|
+
styles.anchor,
|
|
392
|
+
anchorFor(position),
|
|
393
|
+
{ zIndex: stackZIndex },
|
|
394
|
+
stackTransformStyle,
|
|
395
|
+
]}
|
|
396
|
+
>
|
|
397
|
+
<ToastSwipeHandler
|
|
398
|
+
onRemove={onRemove}
|
|
399
|
+
onBegin={onSwipeBegin}
|
|
400
|
+
onFinalize={onSwipeFinalize}
|
|
401
|
+
onPress={onSwipePress}
|
|
402
|
+
// A pending promise toast cannot be swiped away mid-flight.
|
|
403
|
+
enabled={!promiseOptions && dismissible}
|
|
404
|
+
style={mergedStyles.toastContainer}
|
|
405
|
+
unstyled={unstyled}
|
|
406
|
+
important={important}
|
|
407
|
+
position={positionProp}
|
|
408
|
+
>
|
|
409
|
+
<Animated.View style={rowStyle}>
|
|
410
|
+
<Animated.View
|
|
411
|
+
ref={measuredRef}
|
|
412
|
+
onLayout={handleLayout}
|
|
413
|
+
entering={entering}
|
|
414
|
+
exiting={exiting}
|
|
415
|
+
>
|
|
416
|
+
{jsx ?? (
|
|
417
|
+
<ToastContent
|
|
418
|
+
id={id}
|
|
419
|
+
title={title}
|
|
420
|
+
description={description}
|
|
421
|
+
variant={variant}
|
|
422
|
+
icon={icon}
|
|
423
|
+
icons={icons}
|
|
424
|
+
action={action}
|
|
425
|
+
cancel={cancel}
|
|
426
|
+
close={close}
|
|
427
|
+
closeButton={closeButton}
|
|
428
|
+
dismissible={dismissible}
|
|
429
|
+
richColors={richColors}
|
|
430
|
+
promiseOptions={promiseOptions}
|
|
431
|
+
styles={mergedStyles}
|
|
432
|
+
style={style}
|
|
433
|
+
unstyled={unstyled}
|
|
434
|
+
onDismiss={onDismiss}
|
|
435
|
+
actionButtonStyle={
|
|
436
|
+
actionButtonStyle ?? toastOptions.actionButtonStyle
|
|
437
|
+
}
|
|
438
|
+
actionButtonTextStyle={
|
|
439
|
+
actionButtonTextStyle ?? toastOptions.actionButtonTextStyle
|
|
440
|
+
}
|
|
441
|
+
cancelButtonStyle={
|
|
442
|
+
cancelButtonStyle ?? toastOptions.cancelButtonStyle
|
|
443
|
+
}
|
|
444
|
+
cancelButtonTextStyle={
|
|
445
|
+
cancelButtonTextStyle ?? toastOptions.cancelButtonTextStyle
|
|
446
|
+
}
|
|
447
|
+
allowFontScaling={allowFontScaling}
|
|
448
|
+
maxFontSizeMultiplier={maxFontSizeMultiplier}
|
|
449
|
+
backgroundComponent={backgroundComponent}
|
|
450
|
+
/>
|
|
451
|
+
)}
|
|
452
|
+
</Animated.View>
|
|
453
|
+
</Animated.View>
|
|
454
|
+
</ToastSwipeHandler>
|
|
455
|
+
</Animated.View>
|
|
456
|
+
);
|
|
457
|
+
},
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
const styles = StyleSheet.create({
|
|
461
|
+
anchor: {
|
|
462
|
+
position: 'absolute',
|
|
463
|
+
width: '100%',
|
|
464
|
+
},
|
|
465
|
+
anchorTop: { top: 0 },
|
|
466
|
+
anchorBottom: { bottom: 0 },
|
|
467
|
+
/**
|
|
468
|
+
* The container is full-bleed for every position, so the vertical midpoint lives
|
|
469
|
+
* on the ROW rather than on the container. `calculateToastPosition` then shifts
|
|
470
|
+
* the front row up by half its height to sit ON the line rather than below it —
|
|
471
|
+
* see its `centerShift`.
|
|
472
|
+
*/
|
|
473
|
+
anchorCenter: { top: '50%' },
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
/** Which edge of the (full-bleed, padded) container the row hangs from. */
|
|
477
|
+
function anchorFor(position: ToastPosition) {
|
|
478
|
+
if (position === 'bottom-center') {
|
|
479
|
+
return styles.anchorBottom;
|
|
480
|
+
}
|
|
481
|
+
if (position === 'center') {
|
|
482
|
+
return styles.anchorCenter;
|
|
483
|
+
}
|
|
484
|
+
return styles.anchorTop;
|
|
485
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from sonner-native v0.26.4 — src/gestures.tsx
|
|
3
|
+
* (MIT © Gunnar Torfi Steinarsson). See the top-level NOTICE.
|
|
4
|
+
*
|
|
5
|
+
* W2 — the animated style reads `translate`, `direction`, `position`,
|
|
6
|
+
* `windowWidth` and `isAndroid`; ALL of them are in the dependency array. On web
|
|
7
|
+
* without the worklets babel plugin reanimated re-runs the mapper on its deps
|
|
8
|
+
* rather than on auto-tracked reads, so a missing dep freezes the swipe transform
|
|
9
|
+
* at its first frame (upstream omits `position` and `isAndroid`, so a toast that
|
|
10
|
+
* changes position mid-life swipes the wrong way).
|
|
11
|
+
*/
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import {
|
|
14
|
+
Platform,
|
|
15
|
+
StyleSheet,
|
|
16
|
+
useWindowDimensions,
|
|
17
|
+
type ViewStyle,
|
|
18
|
+
} from 'react-native';
|
|
19
|
+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
20
|
+
import Animated, {
|
|
21
|
+
Easing,
|
|
22
|
+
LinearTransition,
|
|
23
|
+
interpolate,
|
|
24
|
+
runOnJS,
|
|
25
|
+
useAnimatedStyle,
|
|
26
|
+
useSharedValue,
|
|
27
|
+
withTiming,
|
|
28
|
+
} from 'react-native-reanimated';
|
|
29
|
+
|
|
30
|
+
import { easeInOutCircFn } from './animations';
|
|
31
|
+
import { useToastContext } from './context';
|
|
32
|
+
import type { ToastPosition, ToastProps } from './types';
|
|
33
|
+
|
|
34
|
+
/** Fraction of the screen a horizontal swipe must cross to dismiss. */
|
|
35
|
+
const HORIZONTAL_DISMISS_FRACTION = 0.25;
|
|
36
|
+
/** Below this the gesture reads as a tap, so the row springs back. */
|
|
37
|
+
const TAP_SLOP = 16;
|
|
38
|
+
/** Vertical travel that fades a row fully out. */
|
|
39
|
+
const VERTICAL_FADE_DISTANCE = 60;
|
|
40
|
+
const SPRING_BACK_EASING_BOUNCINESS = 0.8;
|
|
41
|
+
const WRONG_DIRECTION_SPRING_DURATION = 400;
|
|
42
|
+
|
|
43
|
+
type ToastSwipeHandlerProps = Pick<ToastProps, 'important'> & {
|
|
44
|
+
onRemove: () => void;
|
|
45
|
+
style?: ViewStyle | (ViewStyle | undefined)[];
|
|
46
|
+
onBegin: () => void;
|
|
47
|
+
onFinalize: () => void;
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
unstyled?: boolean;
|
|
50
|
+
position?: ToastPosition;
|
|
51
|
+
onPress: (args: { x: number; y: number }) => void;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const ToastSwipeHandler: React.FC<
|
|
55
|
+
React.PropsWithChildren<ToastSwipeHandlerProps>
|
|
56
|
+
> = ({
|
|
57
|
+
children,
|
|
58
|
+
onRemove,
|
|
59
|
+
style,
|
|
60
|
+
onBegin,
|
|
61
|
+
onFinalize,
|
|
62
|
+
enabled,
|
|
63
|
+
unstyled,
|
|
64
|
+
important,
|
|
65
|
+
position: positionProps,
|
|
66
|
+
onPress,
|
|
67
|
+
}) => {
|
|
68
|
+
const { width: windowWidth } = useWindowDimensions();
|
|
69
|
+
const translate = useSharedValue(0);
|
|
70
|
+
const { swipeToDismissDirection: direction, position: positionCtx } =
|
|
71
|
+
useToastContext();
|
|
72
|
+
const position = positionProps ?? positionCtx;
|
|
73
|
+
const isAndroid = Platform.OS === 'android';
|
|
74
|
+
|
|
75
|
+
const pan = Gesture.Pan()
|
|
76
|
+
.onBegin(() => {
|
|
77
|
+
'worklet';
|
|
78
|
+
|
|
79
|
+
if (!enabled) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
runOnJS(onBegin)();
|
|
83
|
+
})
|
|
84
|
+
.onChange((event) => {
|
|
85
|
+
'worklet';
|
|
86
|
+
|
|
87
|
+
if (!enabled) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (direction === 'left' && event.translationX < 0) {
|
|
92
|
+
translate.value = event.translationX;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (direction === 'up') {
|
|
97
|
+
const isBottomPosition = position === 'bottom-center';
|
|
98
|
+
const rawTranslation = event.translationY * (isBottomPosition ? -1 : 1);
|
|
99
|
+
|
|
100
|
+
// Negative is the dismissal direction; dragging the other way meets
|
|
101
|
+
// progressive resistance instead of moving freely.
|
|
102
|
+
if (rawTranslation < 0) {
|
|
103
|
+
translate.value = rawTranslation;
|
|
104
|
+
} else if (rawTranslation > 0) {
|
|
105
|
+
translate.value = elasticResistance(rawTranslation);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
.onFinalize(() => {
|
|
110
|
+
'worklet';
|
|
111
|
+
|
|
112
|
+
if (!enabled) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const springBack = (duration?: number) => {
|
|
117
|
+
'worklet';
|
|
118
|
+
translate.value = withTiming(0, {
|
|
119
|
+
easing: Easing.elastic(SPRING_BACK_EASING_BOUNCINESS),
|
|
120
|
+
duration,
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const dismiss = () => {
|
|
125
|
+
'worklet';
|
|
126
|
+
translate.value = withTiming(
|
|
127
|
+
-windowWidth,
|
|
128
|
+
{ easing: Easing.inOut(Easing.ease) },
|
|
129
|
+
(isDone) => {
|
|
130
|
+
if (isDone) {
|
|
131
|
+
runOnJS(onRemove)();
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
if (direction === 'left') {
|
|
138
|
+
if (Math.abs(translate.value) < TAP_SLOP) {
|
|
139
|
+
springBack();
|
|
140
|
+
} else if (translate.value < -windowWidth * HORIZONTAL_DISMISS_FRACTION) {
|
|
141
|
+
dismiss();
|
|
142
|
+
} else {
|
|
143
|
+
springBack();
|
|
144
|
+
}
|
|
145
|
+
} else if (direction === 'up') {
|
|
146
|
+
if (translate.value > 0) {
|
|
147
|
+
// Dragged against the dismissal direction — always settle back.
|
|
148
|
+
springBack(WRONG_DIRECTION_SPRING_DURATION);
|
|
149
|
+
} else if (Math.abs(translate.value) < TAP_SLOP) {
|
|
150
|
+
springBack();
|
|
151
|
+
} else {
|
|
152
|
+
dismiss();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
runOnJS(onFinalize)();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const tap = Gesture.Tap().onEnd((event) => {
|
|
160
|
+
'worklet';
|
|
161
|
+
runOnJS(onPress)({ x: event.x, y: event.y });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
165
|
+
const transform =
|
|
166
|
+
direction === 'left'
|
|
167
|
+
? { translateX: translate.value }
|
|
168
|
+
: { translateY: translate.value * (position === 'bottom-center' ? -1 : 1) };
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
transform: [transform],
|
|
172
|
+
// Android composites the fade poorly against the elevation shadow, so the
|
|
173
|
+
// row stays opaque there and relies on the translate alone.
|
|
174
|
+
opacity: isAndroid
|
|
175
|
+
? 1
|
|
176
|
+
: interpolate(
|
|
177
|
+
translate.value,
|
|
178
|
+
[0, direction === 'left' ? -windowWidth : -VERTICAL_FADE_DISTANCE],
|
|
179
|
+
[1, 0],
|
|
180
|
+
),
|
|
181
|
+
};
|
|
182
|
+
}, [direction, translate, windowWidth, position, isAndroid]);
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<GestureDetector gesture={Gesture.Race(tap, pan)}>
|
|
186
|
+
<Animated.View
|
|
187
|
+
style={[
|
|
188
|
+
animatedStyle,
|
|
189
|
+
unstyled ? undefined : styles.centered,
|
|
190
|
+
styles.fullWidth,
|
|
191
|
+
style,
|
|
192
|
+
]}
|
|
193
|
+
// W9 — on web `LinearTransition`'s easing degrades to CSS `ease` because
|
|
194
|
+
// a `bezierFn` result carries no easing-name symbol for the CSS mapper.
|
|
195
|
+
// Accepted: the transition still runs, only its curve differs.
|
|
196
|
+
layout={LinearTransition.easing(easeInOutCircFn)}
|
|
197
|
+
// https://reactnative.dev/docs/accessibility#aria-live-android
|
|
198
|
+
aria-live={important ? 'assertive' : 'polite'}
|
|
199
|
+
>
|
|
200
|
+
{children}
|
|
201
|
+
</Animated.View>
|
|
202
|
+
</GestureDetector>
|
|
203
|
+
);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const styles = StyleSheet.create({
|
|
207
|
+
centered: { justifyContent: 'center' },
|
|
208
|
+
fullWidth: { width: '100%' },
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Apple-style progressive resistance: the further the drag goes the less the row
|
|
213
|
+
* follows it.
|
|
214
|
+
*/
|
|
215
|
+
function elasticResistance(distance: number) {
|
|
216
|
+
'worklet';
|
|
217
|
+
const BASE_RESISTANCE = 0.4;
|
|
218
|
+
const PROGRESSIVE_DAMPENING = 0.02;
|
|
219
|
+
return (
|
|
220
|
+
distance * BASE_RESISTANCE * (1 / (1 + distance * PROGRESSIVE_DAMPENING))
|
|
221
|
+
);
|
|
222
|
+
}
|