@tamagui/toast 2.0.0-rc.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Toast.cjs +149 -141
- package/dist/cjs/Toast.native.js +149 -142
- package/dist/cjs/Toast.native.js.map +1 -1
- package/dist/cjs/ToastAnnounce.cjs +78 -72
- package/dist/cjs/ToastAnnounce.native.js +85 -79
- package/dist/cjs/ToastAnnounce.native.js.map +1 -1
- package/dist/cjs/ToastComposable.cjs +780 -591
- package/dist/cjs/ToastComposable.native.js +863 -706
- package/dist/cjs/ToastComposable.native.js.map +1 -1
- package/dist/cjs/ToastImperative.cjs +99 -80
- package/dist/cjs/ToastImperative.native.js +104 -96
- package/dist/cjs/ToastImperative.native.js.map +1 -1
- package/dist/cjs/ToastImpl.cjs +300 -238
- package/dist/cjs/ToastImpl.native.js +309 -271
- package/dist/cjs/ToastImpl.native.js.map +1 -1
- package/dist/cjs/ToastItemFrame.cjs +143 -0
- package/dist/cjs/ToastItemFrame.native.js +148 -0
- package/dist/cjs/ToastItemFrame.native.js.map +1 -0
- package/dist/cjs/ToastPortal.cjs +23 -18
- package/dist/cjs/ToastPortal.native.js +27 -22
- package/dist/cjs/ToastPortal.native.js.map +1 -1
- package/dist/cjs/ToastProvider.cjs +102 -98
- package/dist/cjs/ToastProvider.native.js +108 -106
- package/dist/cjs/ToastProvider.native.js.map +1 -1
- package/dist/cjs/ToastState.cjs +218 -155
- package/dist/cjs/ToastState.native.js +270 -203
- package/dist/cjs/ToastState.native.js.map +1 -1
- package/dist/cjs/ToastViewport.cjs +274 -233
- package/dist/cjs/ToastViewport.native.js +301 -273
- package/dist/cjs/ToastViewport.native.js.map +1 -1
- package/dist/cjs/Toaster.cjs +71 -233
- package/dist/cjs/Toaster.native.js +72 -289
- package/dist/cjs/Toaster.native.js.map +1 -1
- package/dist/cjs/constants.cjs +14 -12
- package/dist/cjs/constants.native.js +14 -12
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/createNativeToast.cjs +43 -35
- package/dist/cjs/createNativeToast.native.js +42 -30
- package/dist/cjs/createNativeToast.native.js.map +1 -1
- package/dist/cjs/dispatchNativeToast.cjs +47 -0
- package/dist/cjs/dispatchNativeToast.native.js +52 -0
- package/dist/cjs/dispatchNativeToast.native.js.map +1 -0
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/types.native.js +7 -5
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useAnimatedDragGesture.cjs +184 -83
- package/dist/cjs/useAnimatedDragGesture.native.js +193 -79
- package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/cjs/useReducedMotion.cjs +44 -30
- package/dist/cjs/useReducedMotion.native.js +52 -43
- package/dist/cjs/useReducedMotion.native.js.map +1 -1
- package/dist/cjs/useToastAnimations.cjs +233 -155
- package/dist/cjs/useToastAnimations.native.js +246 -170
- package/dist/cjs/useToastAnimations.native.js.map +1 -1
- package/dist/cjs/v2.cjs +36 -0
- package/dist/cjs/v2.native.js +39 -0
- package/dist/cjs/v2.native.js.map +1 -0
- package/dist/esm/Toast.mjs +112 -106
- package/dist/esm/Toast.mjs.map +1 -1
- package/dist/esm/Toast.native.js +112 -107
- package/dist/esm/Toast.native.js.map +1 -1
- package/dist/esm/ToastAnnounce.mjs +46 -42
- package/dist/esm/ToastAnnounce.mjs.map +1 -1
- package/dist/esm/ToastAnnounce.native.js +52 -48
- package/dist/esm/ToastAnnounce.native.js.map +1 -1
- package/dist/esm/ToastComposable.mjs +742 -555
- package/dist/esm/ToastComposable.mjs.map +1 -1
- package/dist/esm/ToastComposable.native.js +825 -670
- package/dist/esm/ToastComposable.native.js.map +1 -1
- package/dist/esm/ToastImperative.mjs +71 -54
- package/dist/esm/ToastImperative.mjs.map +1 -1
- package/dist/esm/ToastImperative.native.js +76 -70
- package/dist/esm/ToastImperative.native.js.map +1 -1
- package/dist/esm/ToastImpl.mjs +261 -201
- package/dist/esm/ToastImpl.mjs.map +1 -1
- package/dist/esm/ToastImpl.native.js +270 -234
- package/dist/esm/ToastImpl.native.js.map +1 -1
- package/dist/esm/ToastItemFrame.mjs +114 -0
- package/dist/esm/ToastItemFrame.mjs.map +1 -0
- package/dist/esm/ToastItemFrame.native.js +116 -0
- package/dist/esm/ToastItemFrame.native.js.map +1 -0
- package/dist/esm/ToastPortal.mjs +8 -5
- package/dist/esm/ToastPortal.mjs.map +1 -1
- package/dist/esm/ToastPortal.native.js +12 -9
- package/dist/esm/ToastPortal.native.js.map +1 -1
- package/dist/esm/ToastProvider.mjs +71 -69
- package/dist/esm/ToastProvider.mjs.map +1 -1
- package/dist/esm/ToastProvider.native.js +77 -77
- package/dist/esm/ToastProvider.native.js.map +1 -1
- package/dist/esm/ToastState.mjs +205 -144
- package/dist/esm/ToastState.mjs.map +1 -1
- package/dist/esm/ToastState.native.js +258 -193
- package/dist/esm/ToastState.native.js.map +1 -1
- package/dist/esm/ToastViewport.mjs +238 -199
- package/dist/esm/ToastViewport.mjs.map +1 -1
- package/dist/esm/ToastViewport.native.js +265 -239
- package/dist/esm/ToastViewport.native.js.map +1 -1
- package/dist/esm/Toaster.mjs +45 -209
- package/dist/esm/Toaster.mjs.map +1 -1
- package/dist/esm/Toaster.native.js +46 -265
- package/dist/esm/Toaster.native.js.map +1 -1
- package/dist/esm/constants.mjs +2 -2
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +2 -2
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/createNativeToast.mjs +29 -24
- package/dist/esm/createNativeToast.mjs.map +1 -1
- package/dist/esm/createNativeToast.native.js +27 -18
- package/dist/esm/createNativeToast.native.js.map +1 -1
- package/dist/esm/dispatchNativeToast.mjs +22 -0
- package/dist/esm/dispatchNativeToast.mjs.map +1 -0
- package/dist/esm/dispatchNativeToast.native.js +24 -0
- package/dist/esm/dispatchNativeToast.native.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useAnimatedDragGesture.mjs +160 -61
- package/dist/esm/useAnimatedDragGesture.mjs.map +1 -1
- package/dist/esm/useAnimatedDragGesture.native.js +167 -55
- package/dist/esm/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/esm/useReducedMotion.mjs +18 -6
- package/dist/esm/useReducedMotion.mjs.map +1 -1
- package/dist/esm/useReducedMotion.native.js +25 -18
- package/dist/esm/useReducedMotion.native.js.map +1 -1
- package/dist/esm/useToastAnimations.mjs +206 -130
- package/dist/esm/useToastAnimations.mjs.map +1 -1
- package/dist/esm/useToastAnimations.native.js +218 -144
- package/dist/esm/useToastAnimations.native.js.map +1 -1
- package/dist/esm/v2.mjs +6 -0
- package/dist/esm/v2.mjs.map +1 -0
- package/dist/esm/v2.native.js +6 -0
- package/dist/esm/v2.native.js.map +1 -0
- package/dist/jsx/Toast.mjs +112 -106
- package/dist/jsx/Toast.mjs.map +1 -1
- package/dist/jsx/Toast.native.js +149 -142
- package/dist/jsx/Toast.native.js.map +1 -1
- package/dist/jsx/ToastAnnounce.mjs +46 -42
- package/dist/jsx/ToastAnnounce.mjs.map +1 -1
- package/dist/jsx/ToastAnnounce.native.js +85 -79
- package/dist/jsx/ToastAnnounce.native.js.map +1 -1
- package/dist/jsx/ToastComposable.mjs +742 -555
- package/dist/jsx/ToastComposable.mjs.map +1 -1
- package/dist/jsx/ToastComposable.native.js +863 -706
- package/dist/jsx/ToastComposable.native.js.map +1 -1
- package/dist/jsx/ToastImperative.mjs +71 -54
- package/dist/jsx/ToastImperative.mjs.map +1 -1
- package/dist/jsx/ToastImperative.native.js +104 -96
- package/dist/jsx/ToastImperative.native.js.map +1 -1
- package/dist/jsx/ToastImpl.mjs +261 -201
- package/dist/jsx/ToastImpl.mjs.map +1 -1
- package/dist/jsx/ToastImpl.native.js +309 -271
- package/dist/jsx/ToastImpl.native.js.map +1 -1
- package/dist/jsx/ToastItemFrame.mjs +114 -0
- package/dist/jsx/ToastItemFrame.mjs.map +1 -0
- package/dist/jsx/ToastItemFrame.native.js +148 -0
- package/dist/jsx/ToastItemFrame.native.js.map +1 -0
- package/dist/jsx/ToastPortal.mjs +8 -5
- package/dist/jsx/ToastPortal.mjs.map +1 -1
- package/dist/jsx/ToastPortal.native.js +27 -22
- package/dist/jsx/ToastPortal.native.js.map +1 -1
- package/dist/jsx/ToastProvider.mjs +71 -69
- package/dist/jsx/ToastProvider.mjs.map +1 -1
- package/dist/jsx/ToastProvider.native.js +108 -106
- package/dist/jsx/ToastProvider.native.js.map +1 -1
- package/dist/jsx/ToastState.mjs +205 -144
- package/dist/jsx/ToastState.mjs.map +1 -1
- package/dist/jsx/ToastState.native.js +270 -203
- package/dist/jsx/ToastState.native.js.map +1 -1
- package/dist/jsx/ToastViewport.mjs +238 -199
- package/dist/jsx/ToastViewport.mjs.map +1 -1
- package/dist/jsx/ToastViewport.native.js +301 -273
- package/dist/jsx/ToastViewport.native.js.map +1 -1
- package/dist/jsx/Toaster.mjs +45 -209
- package/dist/jsx/Toaster.mjs.map +1 -1
- package/dist/jsx/Toaster.native.js +72 -289
- package/dist/jsx/Toaster.native.js.map +1 -1
- package/dist/jsx/constants.mjs +2 -2
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/constants.native.js +14 -12
- package/dist/jsx/constants.native.js.map +1 -1
- package/dist/jsx/createNativeToast.mjs +29 -24
- package/dist/jsx/createNativeToast.mjs.map +1 -1
- package/dist/jsx/createNativeToast.native.js +42 -30
- package/dist/jsx/createNativeToast.native.js.map +1 -1
- package/dist/jsx/dispatchNativeToast.mjs +22 -0
- package/dist/jsx/dispatchNativeToast.mjs.map +1 -0
- package/dist/jsx/dispatchNativeToast.native.js +52 -0
- package/dist/jsx/dispatchNativeToast.native.js.map +1 -0
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/types.native.js +7 -5
- package/dist/jsx/useAnimatedDragGesture.mjs +160 -61
- package/dist/jsx/useAnimatedDragGesture.mjs.map +1 -1
- package/dist/jsx/useAnimatedDragGesture.native.js +193 -79
- package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/jsx/useReducedMotion.mjs +18 -6
- package/dist/jsx/useReducedMotion.mjs.map +1 -1
- package/dist/jsx/useReducedMotion.native.js +52 -43
- package/dist/jsx/useReducedMotion.native.js.map +1 -1
- package/dist/jsx/useToastAnimations.mjs +206 -130
- package/dist/jsx/useToastAnimations.mjs.map +1 -1
- package/dist/jsx/useToastAnimations.native.js +246 -170
- package/dist/jsx/useToastAnimations.native.js.map +1 -1
- package/dist/jsx/v2.mjs +6 -0
- package/dist/jsx/v2.mjs.map +1 -0
- package/dist/jsx/v2.native.js +39 -0
- package/dist/jsx/v2.native.js.map +1 -0
- package/package.json +42 -29
- package/src/ToastComposable.tsx +1380 -0
- package/src/ToastImpl.tsx +14 -2
- package/src/ToastItemFrame.tsx +136 -0
- package/src/ToastPortal.tsx +2 -2
- package/src/ToastProvider.tsx +8 -1
- package/src/ToastState.ts +398 -0
- package/src/ToastViewport.tsx +4 -3
- package/src/Toaster.tsx +181 -0
- package/src/createNativeToast.native.tsx +4 -0
- package/src/createNativeToast.tsx +18 -24
- package/src/dispatchNativeToast.ts +43 -0
- package/src/useAnimatedDragGesture.native.ts +255 -0
- package/src/useAnimatedDragGesture.ts +319 -0
- package/src/useReducedMotion.ts +59 -0
- package/src/useToastAnimations.ts +372 -0
- package/src/v2.ts +31 -0
- package/types/ToastComposable.d.ts +199 -0
- package/types/ToastComposable.d.ts.map +1 -1
- package/types/ToastImpl.d.ts.map +1 -1
- package/types/ToastItemFrame.d.ts +25 -0
- package/types/ToastItemFrame.d.ts.map +1 -0
- package/types/ToastPortal.d.ts.map +1 -1
- package/types/ToastProvider.d.ts +1 -1
- package/types/ToastProvider.d.ts.map +1 -1
- package/types/ToastState.d.ts +179 -0
- package/types/ToastState.d.ts.map +1 -1
- package/types/ToastViewport.d.ts.map +1 -1
- package/types/Toaster.d.ts +112 -0
- package/types/Toaster.d.ts.map +1 -1
- package/types/createNativeToast.d.ts +5 -0
- package/types/createNativeToast.d.ts.map +1 -1
- package/types/createNativeToast.native.d.ts +1 -0
- package/types/createNativeToast.native.d.ts.map +1 -1
- package/types/dispatchNativeToast.d.ts +12 -0
- package/types/dispatchNativeToast.d.ts.map +1 -0
- package/types/useAnimatedDragGesture.d.ts +33 -0
- package/types/useAnimatedDragGesture.d.ts.map +1 -1
- package/types/useAnimatedDragGesture.native.d.ts +33 -0
- package/types/useAnimatedDragGesture.native.d.ts.map +1 -1
- package/types/useReducedMotion.d.ts +6 -0
- package/types/useToastAnimations.d.ts +50 -0
- package/types/useToastAnimations.d.ts.map +1 -1
- package/types/v2.d.ts +10 -0
- package/types/v2.d.ts.map +1 -0
- package/v2/index.cjs +2 -0
- package/v2/index.js +2 -0
- package/v2/index.native.cjs +2 -0
- package/v2/index.native.js +2 -0
- package/LICENSE +0 -21
- package/dist/cjs/Toast.js +0 -119
- package/dist/cjs/Toast.js.map +0 -6
- package/dist/cjs/ToastAnnounce.js +0 -72
- package/dist/cjs/ToastAnnounce.js.map +0 -6
- package/dist/cjs/ToastComposable.js +0 -548
- package/dist/cjs/ToastComposable.js.map +0 -6
- package/dist/cjs/ToastImperative.js +0 -71
- package/dist/cjs/ToastImperative.js.map +0 -6
- package/dist/cjs/ToastImpl.js +0 -227
- package/dist/cjs/ToastImpl.js.map +0 -6
- package/dist/cjs/ToastItem.cjs +0 -526
- package/dist/cjs/ToastItem.js +0 -409
- package/dist/cjs/ToastItem.js.map +0 -6
- package/dist/cjs/ToastItem.native.js +0 -614
- package/dist/cjs/ToastItem.native.js.map +0 -1
- package/dist/cjs/ToastPortal.js +0 -26
- package/dist/cjs/ToastPortal.js.map +0 -6
- package/dist/cjs/ToastProvider.js +0 -105
- package/dist/cjs/ToastProvider.js.map +0 -6
- package/dist/cjs/ToastState.js +0 -160
- package/dist/cjs/ToastState.js.map +0 -6
- package/dist/cjs/ToastViewport.js +0 -263
- package/dist/cjs/ToastViewport.js.map +0 -6
- package/dist/cjs/Toaster.js +0 -204
- package/dist/cjs/Toaster.js.map +0 -6
- package/dist/cjs/constants.js +0 -22
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/createNativeToast.js +0 -44
- package/dist/cjs/createNativeToast.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/useAnimatedDragGesture.js +0 -97
- package/dist/cjs/useAnimatedDragGesture.js.map +0 -6
- package/dist/cjs/useDragGesture.cjs +0 -129
- package/dist/cjs/useDragGesture.js +0 -100
- package/dist/cjs/useDragGesture.js.map +0 -6
- package/dist/cjs/useDragGesture.native.js +0 -146
- package/dist/cjs/useDragGesture.native.js.map +0 -1
- package/dist/cjs/useReducedMotion.js +0 -53
- package/dist/cjs/useReducedMotion.js.map +0 -6
- package/dist/cjs/useToastAnimations.js +0 -144
- package/dist/cjs/useToastAnimations.js.map +0 -6
- package/dist/cjs/v1.cjs +0 -31
- package/dist/cjs/v1.js +0 -26
- package/dist/cjs/v1.js.map +0 -6
- package/dist/cjs/v1.native.js +0 -34
- package/dist/cjs/v1.native.js.map +0 -1
- package/dist/esm/Toast.js +0 -107
- package/dist/esm/Toast.js.map +0 -6
- package/dist/esm/ToastAnnounce.js +0 -55
- package/dist/esm/ToastAnnounce.js.map +0 -6
- package/dist/esm/ToastComposable.js +0 -543
- package/dist/esm/ToastComposable.js.map +0 -6
- package/dist/esm/ToastImperative.js +0 -50
- package/dist/esm/ToastImperative.js.map +0 -6
- package/dist/esm/ToastImpl.js +0 -225
- package/dist/esm/ToastImpl.js.map +0 -6
- package/dist/esm/ToastItem.js +0 -393
- package/dist/esm/ToastItem.js.map +0 -6
- package/dist/esm/ToastItem.mjs +0 -492
- package/dist/esm/ToastItem.mjs.map +0 -1
- package/dist/esm/ToastItem.native.js +0 -577
- package/dist/esm/ToastItem.native.js.map +0 -1
- package/dist/esm/ToastPortal.js +0 -13
- package/dist/esm/ToastPortal.js.map +0 -6
- package/dist/esm/ToastProvider.js +0 -87
- package/dist/esm/ToastProvider.js.map +0 -6
- package/dist/esm/ToastState.js +0 -144
- package/dist/esm/ToastState.js.map +0 -6
- package/dist/esm/ToastViewport.js +0 -250
- package/dist/esm/ToastViewport.js.map +0 -6
- package/dist/esm/Toaster.js +0 -188
- package/dist/esm/Toaster.js.map +0 -6
- package/dist/esm/constants.js +0 -6
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/createNativeToast.js +0 -28
- package/dist/esm/createNativeToast.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/useAnimatedDragGesture.js +0 -73
- package/dist/esm/useAnimatedDragGesture.js.map +0 -6
- package/dist/esm/useDragGesture.js +0 -76
- package/dist/esm/useDragGesture.js.map +0 -6
- package/dist/esm/useDragGesture.mjs +0 -95
- package/dist/esm/useDragGesture.mjs.map +0 -1
- package/dist/esm/useDragGesture.native.js +0 -109
- package/dist/esm/useDragGesture.native.js.map +0 -1
- package/dist/esm/useReducedMotion.js +0 -30
- package/dist/esm/useReducedMotion.js.map +0 -6
- package/dist/esm/useToastAnimations.js +0 -122
- package/dist/esm/useToastAnimations.js.map +0 -6
- package/dist/esm/v1.js +0 -17
- package/dist/esm/v1.js.map +0 -6
- package/dist/esm/v1.mjs +0 -3
- package/dist/esm/v1.mjs.map +0 -1
- package/dist/esm/v1.native.js +0 -3
- package/dist/esm/v1.native.js.map +0 -1
- package/dist/jsx/Toast.js +0 -107
- package/dist/jsx/Toast.js.map +0 -6
- package/dist/jsx/ToastAnnounce.js +0 -55
- package/dist/jsx/ToastAnnounce.js.map +0 -6
- package/dist/jsx/ToastComposable.js +0 -543
- package/dist/jsx/ToastComposable.js.map +0 -6
- package/dist/jsx/ToastImperative.js +0 -50
- package/dist/jsx/ToastImperative.js.map +0 -6
- package/dist/jsx/ToastImpl.js +0 -225
- package/dist/jsx/ToastImpl.js.map +0 -6
- package/dist/jsx/ToastItem.js +0 -393
- package/dist/jsx/ToastItem.js.map +0 -6
- package/dist/jsx/ToastItem.mjs +0 -492
- package/dist/jsx/ToastItem.mjs.map +0 -1
- package/dist/jsx/ToastItem.native.js +0 -614
- package/dist/jsx/ToastItem.native.js.map +0 -1
- package/dist/jsx/ToastPortal.js +0 -13
- package/dist/jsx/ToastPortal.js.map +0 -6
- package/dist/jsx/ToastProvider.js +0 -87
- package/dist/jsx/ToastProvider.js.map +0 -6
- package/dist/jsx/ToastState.js +0 -144
- package/dist/jsx/ToastState.js.map +0 -6
- package/dist/jsx/ToastViewport.js +0 -250
- package/dist/jsx/ToastViewport.js.map +0 -6
- package/dist/jsx/Toaster.js +0 -188
- package/dist/jsx/Toaster.js.map +0 -6
- package/dist/jsx/constants.js +0 -6
- package/dist/jsx/constants.js.map +0 -6
- package/dist/jsx/createNativeToast.js +0 -28
- package/dist/jsx/createNativeToast.js.map +0 -6
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -6
- package/dist/jsx/useAnimatedDragGesture.js +0 -73
- package/dist/jsx/useAnimatedDragGesture.js.map +0 -6
- package/dist/jsx/useDragGesture.js +0 -76
- package/dist/jsx/useDragGesture.js.map +0 -6
- package/dist/jsx/useDragGesture.mjs +0 -95
- package/dist/jsx/useDragGesture.mjs.map +0 -1
- package/dist/jsx/useDragGesture.native.js +0 -146
- package/dist/jsx/useDragGesture.native.js.map +0 -1
- package/dist/jsx/useReducedMotion.js +0 -30
- package/dist/jsx/useReducedMotion.js.map +0 -6
- package/dist/jsx/useToastAnimations.js +0 -122
- package/dist/jsx/useToastAnimations.js.map +0 -6
- package/dist/jsx/v1.js +0 -17
- package/dist/jsx/v1.js.map +0 -6
- package/dist/jsx/v1.mjs +0 -3
- package/dist/jsx/v1.mjs.map +0 -1
- package/dist/jsx/v1.native.js +0 -34
- package/dist/jsx/v1.native.js.map +0 -1
- package/types/ToastItem.d.ts.map +0 -1
- package/types/useDragGesture.d.ts.map +0 -1
- package/types/useDragGesture.native.d.ts.map +0 -1
- package/types/v1.d.ts.map +0 -1
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web implementation of drag gesture handling with animation driver integration.
|
|
3
|
+
* Uses pointer events for smooth drag tracking, animation driver for transforms.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as React from 'react'
|
|
7
|
+
import type { SwipeDirection } from './ToastProvider'
|
|
8
|
+
|
|
9
|
+
export interface UseAnimatedDragGestureOptions {
|
|
10
|
+
direction: SwipeDirection
|
|
11
|
+
threshold: number
|
|
12
|
+
disabled?: boolean
|
|
13
|
+
/** when collapsed, allow drag in all directions with resistance except exit direction */
|
|
14
|
+
expanded?: boolean
|
|
15
|
+
/** called during drag with offset values */
|
|
16
|
+
onDragMove: (x: number, y: number) => void
|
|
17
|
+
/** called when drag starts */
|
|
18
|
+
onDragStart?: () => void
|
|
19
|
+
/** called when drag ends with successful dismiss - includes exit direction and velocity */
|
|
20
|
+
onDismiss: (exitDirection: 'left' | 'right' | 'up' | 'down', velocity: number) => void
|
|
21
|
+
/** called when drag ends without dismiss - spring back */
|
|
22
|
+
onCancel: () => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface DragStartData {
|
|
26
|
+
startX: number
|
|
27
|
+
startY: number
|
|
28
|
+
startTime: number
|
|
29
|
+
pointerId: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const VELOCITY_THRESHOLD = 0.11
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Apply resistance when dragging past a boundary.
|
|
36
|
+
* Uses a square root curve for natural-feeling resistance (same as Sheet).
|
|
37
|
+
*/
|
|
38
|
+
function resisted(delta: number, maxResist = 25): number {
|
|
39
|
+
if (delta >= 0) return delta
|
|
40
|
+
const pastBoundary = Math.abs(delta)
|
|
41
|
+
const resistedDistance = Math.sqrt(pastBoundary) * 2
|
|
42
|
+
return -Math.min(resistedDistance, maxResist)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Cap the exit-direction drag distance so the toast doesn't fly across the screen.
|
|
47
|
+
* Allows free movement up to the limit, then applies gentle resistance beyond it.
|
|
48
|
+
*/
|
|
49
|
+
const EXIT_DRAG_CAP = 80
|
|
50
|
+
|
|
51
|
+
function cappedExit(delta: number): number {
|
|
52
|
+
if (Math.abs(delta) <= EXIT_DRAG_CAP) return delta
|
|
53
|
+
const sign = delta > 0 ? 1 : -1
|
|
54
|
+
const overshoot = Math.abs(delta) - EXIT_DRAG_CAP
|
|
55
|
+
return sign * (EXIT_DRAG_CAP + Math.sqrt(overshoot) * 2)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function useAnimatedDragGesture(options: UseAnimatedDragGestureOptions) {
|
|
59
|
+
const {
|
|
60
|
+
direction,
|
|
61
|
+
threshold,
|
|
62
|
+
disabled,
|
|
63
|
+
expanded,
|
|
64
|
+
onDragMove,
|
|
65
|
+
onDragStart,
|
|
66
|
+
onDismiss,
|
|
67
|
+
onCancel,
|
|
68
|
+
} = options
|
|
69
|
+
|
|
70
|
+
const [isDragging, setIsDragging] = React.useState(false)
|
|
71
|
+
|
|
72
|
+
const dragStartRef = React.useRef<DragStartData | null>(null)
|
|
73
|
+
const lockedDirectionRef = React.useRef<'x' | 'y' | null>(null)
|
|
74
|
+
// Stable ref for pointer capture - avoids issues with event.target changing
|
|
75
|
+
const captureElementRef = React.useRef<HTMLElement | null>(null)
|
|
76
|
+
|
|
77
|
+
const isHorizontal =
|
|
78
|
+
direction === 'left' || direction === 'right' || direction === 'horizontal'
|
|
79
|
+
const isVertical =
|
|
80
|
+
direction === 'up' || direction === 'down' || direction === 'vertical'
|
|
81
|
+
|
|
82
|
+
// block native text selection during drag — works in Safari where
|
|
83
|
+
// userSelect style alone doesn't prevent fast-swipe selection
|
|
84
|
+
const preventSelectRef = React.useRef<((e: Event) => void) | null>(null)
|
|
85
|
+
|
|
86
|
+
function startPreventingSelection() {
|
|
87
|
+
if (typeof document === 'undefined') return
|
|
88
|
+
// clear any selection that already started
|
|
89
|
+
window.getSelection()?.removeAllRanges()
|
|
90
|
+
// block future selection attempts at the event level
|
|
91
|
+
const handler = (e: Event) => e.preventDefault()
|
|
92
|
+
preventSelectRef.current = handler
|
|
93
|
+
document.addEventListener('selectstart', handler, true)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function stopPreventingSelection() {
|
|
97
|
+
if (preventSelectRef.current) {
|
|
98
|
+
document.removeEventListener('selectstart', preventSelectRef.current, true)
|
|
99
|
+
preventSelectRef.current = null
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Cleanup function to reset all drag state
|
|
104
|
+
const cleanup = React.useCallback(() => {
|
|
105
|
+
dragStartRef.current = null
|
|
106
|
+
lockedDirectionRef.current = null
|
|
107
|
+
setIsDragging(false)
|
|
108
|
+
stopPreventingSelection()
|
|
109
|
+
}, [])
|
|
110
|
+
|
|
111
|
+
// Defensive cleanup on unmount - if toast unmounts while dragging
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
return () => {
|
|
114
|
+
if (dragStartRef.current) {
|
|
115
|
+
// Release pointer capture if we have it
|
|
116
|
+
if (captureElementRef.current && dragStartRef.current.pointerId) {
|
|
117
|
+
try {
|
|
118
|
+
captureElementRef.current.releasePointerCapture(
|
|
119
|
+
dragStartRef.current.pointerId
|
|
120
|
+
)
|
|
121
|
+
} catch {
|
|
122
|
+
// ignore
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
cleanup()
|
|
126
|
+
// Note: can't call onCancel here as component is unmounting
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [cleanup])
|
|
130
|
+
|
|
131
|
+
const handlePointerDown = React.useCallback(
|
|
132
|
+
(event: React.PointerEvent) => {
|
|
133
|
+
if (disabled) return
|
|
134
|
+
if (event.button !== 0) return
|
|
135
|
+
|
|
136
|
+
// don't start drag if clicking on interactive elements (buttons, links, inputs)
|
|
137
|
+
const target = event.target as HTMLElement
|
|
138
|
+
if (target.closest('button, a, input, textarea, select, [role="button"]')) {
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// don't start drag if user has text selected (let them copy it)
|
|
143
|
+
const hasSelection = (window.getSelection()?.toString().length ?? 0) > 0
|
|
144
|
+
if (hasSelection) return
|
|
145
|
+
|
|
146
|
+
// Use currentTarget (the element with the handler) for stable capture
|
|
147
|
+
const captureElement = event.currentTarget as HTMLElement
|
|
148
|
+
captureElementRef.current = captureElement
|
|
149
|
+
captureElement.setPointerCapture(event.pointerId)
|
|
150
|
+
|
|
151
|
+
dragStartRef.current = {
|
|
152
|
+
startX: event.clientX,
|
|
153
|
+
startY: event.clientY,
|
|
154
|
+
startTime: Date.now(),
|
|
155
|
+
pointerId: event.pointerId,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// prevent text selection on the page during drag
|
|
159
|
+
startPreventingSelection()
|
|
160
|
+
|
|
161
|
+
setIsDragging(true)
|
|
162
|
+
onDragStart?.()
|
|
163
|
+
},
|
|
164
|
+
[disabled, onDragStart]
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
const handlePointerMove = React.useCallback(
|
|
168
|
+
(event: React.PointerEvent) => {
|
|
169
|
+
if (!dragStartRef.current || disabled) return
|
|
170
|
+
|
|
171
|
+
const deltaX = event.clientX - dragStartRef.current.startX
|
|
172
|
+
const deltaY = event.clientY - dragStartRef.current.startY
|
|
173
|
+
|
|
174
|
+
// detect direction lock on first significant movement
|
|
175
|
+
if (!lockedDirectionRef.current && (Math.abs(deltaX) > 1 || Math.abs(deltaY) > 1)) {
|
|
176
|
+
lockedDirectionRef.current = Math.abs(deltaX) > Math.abs(deltaY) ? 'x' : 'y'
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let offsetX = 0
|
|
180
|
+
let offsetY = 0
|
|
181
|
+
|
|
182
|
+
// only allow movement along the exit axis with capped distance
|
|
183
|
+
// cross-axis is locked to zero for clean swipes
|
|
184
|
+
if (direction === 'right') {
|
|
185
|
+
offsetX = deltaX > 0 ? cappedExit(deltaX) : resisted(deltaX)
|
|
186
|
+
} else if (direction === 'left') {
|
|
187
|
+
offsetX = deltaX < 0 ? cappedExit(deltaX) : -resisted(-deltaX)
|
|
188
|
+
} else if (direction === 'down') {
|
|
189
|
+
offsetY = deltaY > 0 ? cappedExit(deltaY) : resisted(deltaY)
|
|
190
|
+
} else if (direction === 'up') {
|
|
191
|
+
offsetY = deltaY < 0 ? cappedExit(deltaY) : -resisted(-deltaY)
|
|
192
|
+
} else if (direction === 'horizontal') {
|
|
193
|
+
offsetX = cappedExit(deltaX)
|
|
194
|
+
} else if (direction === 'vertical') {
|
|
195
|
+
offsetY = cappedExit(deltaY)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// directly update animated values (no React state update during drag)
|
|
199
|
+
onDragMove(offsetX, offsetY)
|
|
200
|
+
},
|
|
201
|
+
[disabled, direction, expanded, isHorizontal, isVertical, onDragMove]
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
const handlePointerUp = React.useCallback(
|
|
205
|
+
(event: React.PointerEvent) => {
|
|
206
|
+
if (!dragStartRef.current || disabled) return
|
|
207
|
+
|
|
208
|
+
const deltaX = event.clientX - dragStartRef.current.startX
|
|
209
|
+
const deltaY = event.clientY - dragStartRef.current.startY
|
|
210
|
+
const timeTaken = Date.now() - dragStartRef.current.startTime
|
|
211
|
+
|
|
212
|
+
const velocityX = Math.abs(deltaX) / timeTaken
|
|
213
|
+
const velocityY = Math.abs(deltaY) / timeTaken
|
|
214
|
+
|
|
215
|
+
const lockedDirection = lockedDirectionRef.current
|
|
216
|
+
|
|
217
|
+
// if locked to wrong axis for the swipe direction, don't dismiss
|
|
218
|
+
// e.g., if drag started vertical but swipe direction is horizontal
|
|
219
|
+
const isLockedToWrongAxis =
|
|
220
|
+
(lockedDirection === 'y' && isHorizontal) ||
|
|
221
|
+
(lockedDirection === 'x' && isVertical)
|
|
222
|
+
|
|
223
|
+
const relevantDelta = isHorizontal ? deltaX : deltaY
|
|
224
|
+
const relevantVelocity = isHorizontal ? velocityX : velocityY
|
|
225
|
+
|
|
226
|
+
const passedThreshold = Math.abs(relevantDelta) >= threshold
|
|
227
|
+
const hasVelocity = relevantVelocity > VELOCITY_THRESHOLD
|
|
228
|
+
|
|
229
|
+
// determine exit direction based on actual drag direction
|
|
230
|
+
let exitDirection: 'left' | 'right' | 'up' | 'down' | null = null
|
|
231
|
+
|
|
232
|
+
// only set exit direction if not locked to wrong axis
|
|
233
|
+
if (!isLockedToWrongAxis) {
|
|
234
|
+
if (direction === 'right' && deltaX > 0) exitDirection = 'right'
|
|
235
|
+
else if (direction === 'left' && deltaX < 0) exitDirection = 'left'
|
|
236
|
+
else if (direction === 'horizontal') {
|
|
237
|
+
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
|
238
|
+
exitDirection = deltaX > 0 ? 'right' : 'left'
|
|
239
|
+
}
|
|
240
|
+
} else if (direction === 'down' && deltaY > 0) exitDirection = 'down'
|
|
241
|
+
else if (direction === 'up' && deltaY < 0) exitDirection = 'up'
|
|
242
|
+
else if (direction === 'vertical') {
|
|
243
|
+
if (Math.abs(deltaY) > Math.abs(deltaX)) {
|
|
244
|
+
exitDirection = deltaY > 0 ? 'down' : 'up'
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const shouldDismiss = exitDirection && (passedThreshold || hasVelocity)
|
|
250
|
+
|
|
251
|
+
// release pointer capture using stable ref
|
|
252
|
+
if (captureElementRef.current) {
|
|
253
|
+
try {
|
|
254
|
+
captureElementRef.current.releasePointerCapture(event.pointerId)
|
|
255
|
+
} catch {
|
|
256
|
+
// ignore if already released
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// reset state
|
|
261
|
+
cleanup()
|
|
262
|
+
|
|
263
|
+
if (shouldDismiss && exitDirection) {
|
|
264
|
+
onDismiss(exitDirection, relevantVelocity)
|
|
265
|
+
} else {
|
|
266
|
+
onCancel()
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
[
|
|
270
|
+
disabled,
|
|
271
|
+
direction,
|
|
272
|
+
threshold,
|
|
273
|
+
isHorizontal,
|
|
274
|
+
isVertical,
|
|
275
|
+
onDismiss,
|
|
276
|
+
onCancel,
|
|
277
|
+
cleanup,
|
|
278
|
+
]
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
const handlePointerCancel = React.useCallback(
|
|
282
|
+
(event: React.PointerEvent) => {
|
|
283
|
+
// release pointer capture using stable ref
|
|
284
|
+
if (captureElementRef.current) {
|
|
285
|
+
try {
|
|
286
|
+
captureElementRef.current.releasePointerCapture(event.pointerId)
|
|
287
|
+
} catch {
|
|
288
|
+
// ignore if already released
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
cleanup()
|
|
293
|
+
onCancel()
|
|
294
|
+
},
|
|
295
|
+
[onCancel, cleanup]
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
// Handle lost pointer capture - treat like cancel
|
|
299
|
+
const handleLostPointerCapture = React.useCallback(() => {
|
|
300
|
+
if (dragStartRef.current) {
|
|
301
|
+
cleanup()
|
|
302
|
+
onCancel()
|
|
303
|
+
}
|
|
304
|
+
}, [onCancel, cleanup])
|
|
305
|
+
|
|
306
|
+
const gestureHandlers = {
|
|
307
|
+
onPointerDown: handlePointerDown,
|
|
308
|
+
onPointerMove: handlePointerMove,
|
|
309
|
+
onPointerUp: handlePointerUp,
|
|
310
|
+
onPointerCancel: handlePointerCancel,
|
|
311
|
+
onLostPointerCapture: handleLostPointerCapture,
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
isDragging,
|
|
316
|
+
gestureHandlers,
|
|
317
|
+
gesture: null as any,
|
|
318
|
+
}
|
|
319
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to detect reduced motion preference.
|
|
3
|
+
* Returns true if user prefers reduced motion (via system settings or forced).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { isWeb } from '@tamagui/constants'
|
|
7
|
+
import * as React from 'react'
|
|
8
|
+
|
|
9
|
+
let cachedResult: boolean | null = null
|
|
10
|
+
|
|
11
|
+
function getReducedMotion(): boolean {
|
|
12
|
+
if (cachedResult !== null) return cachedResult
|
|
13
|
+
|
|
14
|
+
if (!isWeb) {
|
|
15
|
+
// on native, we could use AccessibilityInfo.isReduceMotionEnabled()
|
|
16
|
+
// but that requires async, so default to false
|
|
17
|
+
cachedResult = false
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof window === 'undefined') {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
cachedResult = window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ?? false
|
|
26
|
+
return cachedResult
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useReducedMotion(forceReducedMotion?: boolean): boolean {
|
|
30
|
+
const [reducedMotion, setReducedMotion] = React.useState(
|
|
31
|
+
() => forceReducedMotion ?? getReducedMotion()
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
// if forced, use that value
|
|
36
|
+
if (forceReducedMotion !== undefined) {
|
|
37
|
+
setReducedMotion(forceReducedMotion)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// listen for changes to system preference
|
|
42
|
+
if (!isWeb || typeof window === 'undefined') return
|
|
43
|
+
|
|
44
|
+
const mediaQuery = window.matchMedia?.('(prefers-reduced-motion: reduce)')
|
|
45
|
+
if (!mediaQuery) return
|
|
46
|
+
|
|
47
|
+
const handleChange = (e: MediaQueryListEvent) => {
|
|
48
|
+
cachedResult = e.matches
|
|
49
|
+
setReducedMotion(e.matches)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
mediaQuery.addEventListener?.('change', handleChange)
|
|
53
|
+
return () => {
|
|
54
|
+
mediaQuery.removeEventListener?.('change', handleChange)
|
|
55
|
+
}
|
|
56
|
+
}, [forceReducedMotion])
|
|
57
|
+
|
|
58
|
+
return reducedMotion
|
|
59
|
+
}
|