@tamagui/toast 2.0.0-rc.9 → 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 +41 -24
- 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
|
@@ -1,323 +1,473 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AnimatePresence } from "@tamagui/animate-presence";
|
|
3
3
|
import { isWeb } from "@tamagui/constants";
|
|
4
|
-
import {
|
|
4
|
+
import { getGestureHandler } from "@tamagui/native";
|
|
5
|
+
import { createStyledContext, styled, Theme, useConfiguration, useEvent, useThemeName, View } from "@tamagui/core";
|
|
5
6
|
import { withStaticProperties } from "@tamagui/helpers";
|
|
6
7
|
import { Portal } from "@tamagui/portal";
|
|
7
8
|
import { XStack, YStack } from "@tamagui/stacks";
|
|
8
9
|
import { SizableText } from "@tamagui/text";
|
|
9
10
|
import * as React from "react";
|
|
10
11
|
import { ToastState } from "./ToastState.native.js";
|
|
12
|
+
import { dispatchNativeToast } from "./dispatchNativeToast.native.js";
|
|
11
13
|
import { useAnimatedDragGesture } from "./useAnimatedDragGesture.native.js";
|
|
12
14
|
import { useToastAnimations } from "./useToastAnimations.native.js";
|
|
13
15
|
import { useReducedMotion } from "./useReducedMotion.native.js";
|
|
16
|
+
import { DefaultCloseIcon, ToastActionFrame, ToastCloseFrame, ToastItemFrame, ToastPositionWrapper } from "./ToastItemFrame.native.js";
|
|
14
17
|
function _type_of(obj) {
|
|
15
18
|
"@swc/helpers - typeof";
|
|
16
19
|
|
|
17
|
-
return obj && typeof Symbol
|
|
20
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
18
21
|
}
|
|
19
|
-
var VISIBLE_TOASTS_AMOUNT = 4
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
var VISIBLE_TOASTS_AMOUNT = 4;
|
|
23
|
+
var VIEWPORT_OFFSET = 16;
|
|
24
|
+
var TOAST_GAP = 14;
|
|
25
|
+
var TOAST_LIFETIME = 4e3;
|
|
26
|
+
var FIXED_TOAST_HEIGHT = 72;
|
|
27
|
+
var TIME_BEFORE_UNMOUNT = 200;
|
|
28
|
+
var DEFAULT_HOTKEY = ["altKey", "KeyT"];
|
|
29
|
+
var ToastContext = createStyledContext({}, "Toast__");
|
|
30
|
+
var useToastContext = ToastContext.useStyledContext;
|
|
31
|
+
var ToastItemContext = /* @__PURE__ */React.createContext(null);
|
|
27
32
|
function useToastItemContext() {
|
|
28
33
|
var ctx = React.useContext(ToastItemContext);
|
|
29
|
-
if (!ctx)
|
|
34
|
+
if (!ctx) {
|
|
35
|
+
throw new Error("useToastItemContext must be used within Toast.Item or Toast.List");
|
|
36
|
+
}
|
|
30
37
|
return ctx;
|
|
31
38
|
}
|
|
32
|
-
var DefaultSuccessIcon = function () {
|
|
33
|
-
return /* @__PURE__ */_jsx(SizableText, {
|
|
34
|
-
size: "$5",
|
|
35
|
-
color: "$green10",
|
|
36
|
-
children: "\u2713"
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
DefaultErrorIcon = function () {
|
|
40
|
-
return /* @__PURE__ */_jsx(SizableText, {
|
|
41
|
-
size: "$5",
|
|
42
|
-
color: "$red10",
|
|
43
|
-
children: "\u2715"
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
DefaultWarningIcon = function () {
|
|
47
|
-
return /* @__PURE__ */_jsx(SizableText, {
|
|
48
|
-
size: "$5",
|
|
49
|
-
color: "$yellow10",
|
|
50
|
-
children: "\u26A0"
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
DefaultInfoIcon = function () {
|
|
54
|
-
return /* @__PURE__ */_jsx(SizableText, {
|
|
55
|
-
size: "$5",
|
|
56
|
-
color: "$blue10",
|
|
57
|
-
children: "\u2139"
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
DefaultLoadingIcon = function () {
|
|
61
|
-
return /* @__PURE__ */_jsx(SizableText, {
|
|
62
|
-
size: "$5",
|
|
63
|
-
color: "$color11",
|
|
64
|
-
children: "\u27F3"
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
DefaultCloseIcon = function () {
|
|
68
|
-
return /* @__PURE__ */_jsx(SizableText, {
|
|
69
|
-
size: "$1",
|
|
70
|
-
color: "$color11",
|
|
71
|
-
children: "\u2715"
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
39
|
function resolveSwipeDirection(direction, position) {
|
|
75
40
|
if (direction !== "auto") return direction;
|
|
76
41
|
var [yPosition, xPosition] = position.split("-");
|
|
77
|
-
|
|
42
|
+
if (!isWeb) {
|
|
43
|
+
return yPosition === "top" ? "up" : "down";
|
|
44
|
+
}
|
|
45
|
+
if (xPosition === "left") return "left";
|
|
46
|
+
if (xPosition === "right") return "right";
|
|
47
|
+
return "horizontal";
|
|
78
48
|
}
|
|
79
|
-
var ToastRoot = /* @__PURE__ */React.forwardRef(function (props,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
49
|
+
var ToastRoot = /* @__PURE__ */React.forwardRef(function ToastRoot2(props, _ref) {
|
|
50
|
+
var {
|
|
51
|
+
children,
|
|
52
|
+
position = "bottom-right",
|
|
53
|
+
duration = TOAST_LIFETIME,
|
|
54
|
+
gap = TOAST_GAP,
|
|
55
|
+
visibleToasts = VISIBLE_TOASTS_AMOUNT,
|
|
56
|
+
swipeDirection: swipeDirectionProp = "auto",
|
|
57
|
+
swipeThreshold = 50,
|
|
58
|
+
toastHeight = FIXED_TOAST_HEIGHT,
|
|
59
|
+
closeButton = false,
|
|
60
|
+
expand = false,
|
|
61
|
+
theme: themeProp,
|
|
62
|
+
reducedMotion: reducedMotionProp,
|
|
63
|
+
native = false,
|
|
64
|
+
burntOptions,
|
|
65
|
+
notificationOptions,
|
|
66
|
+
icons
|
|
67
|
+
} = props;
|
|
68
|
+
var reducedMotion = useReducedMotion(reducedMotionProp);
|
|
69
|
+
var [toasts, setToasts] = React.useState([]);
|
|
70
|
+
var [heights, setHeights] = React.useState({});
|
|
71
|
+
var [localExpanded, setExpanded] = React.useState(false);
|
|
72
|
+
var expanded = expand || localExpanded;
|
|
73
|
+
var [interacting, setInteracting] = React.useState(false);
|
|
74
|
+
var heightsLockedRef = React.useRef(false);
|
|
75
|
+
var prevExpandedRef = React.useRef(expanded);
|
|
76
|
+
React.useLayoutEffect(function () {
|
|
77
|
+
if (prevExpandedRef.current !== expanded) {
|
|
78
|
+
heightsLockedRef.current = true;
|
|
79
|
+
prevExpandedRef.current = expanded;
|
|
80
|
+
}
|
|
81
|
+
var timer = setTimeout(function () {
|
|
82
|
+
heightsLockedRef.current = false;
|
|
83
|
+
}, 350);
|
|
84
|
+
return function () {
|
|
85
|
+
return clearTimeout(timer);
|
|
86
|
+
};
|
|
87
|
+
}, [expanded]);
|
|
88
|
+
var setToastHeight = React.useCallback(function (toastId, height) {
|
|
89
|
+
if (heightsLockedRef.current) return;
|
|
90
|
+
var rounded = Math.round(height);
|
|
91
|
+
setHeights(function (prev) {
|
|
92
|
+
var existing = prev[toastId];
|
|
93
|
+
if (existing != null && Math.abs(existing - rounded) <= 2) return prev;
|
|
94
|
+
return {
|
|
95
|
+
...prev,
|
|
96
|
+
[toastId]: rounded
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}, []);
|
|
100
|
+
var removeToastHeight = React.useCallback(function (toastId) {
|
|
101
|
+
setHeights(function (prev) {
|
|
102
|
+
if (!(toastId in prev)) return prev;
|
|
103
|
+
var next = {
|
|
104
|
+
...prev
|
|
105
|
+
};
|
|
106
|
+
delete next[toastId];
|
|
107
|
+
return next;
|
|
108
|
+
});
|
|
109
|
+
}, []);
|
|
110
|
+
var dismissCooldownRef = React.useRef(false);
|
|
111
|
+
var dismissCooldownTimerRef = React.useRef(null);
|
|
112
|
+
var triggerDismissCooldown = React.useCallback(function () {
|
|
113
|
+
dismissCooldownRef.current = true;
|
|
114
|
+
if (dismissCooldownTimerRef.current) {
|
|
115
|
+
clearTimeout(dismissCooldownTimerRef.current);
|
|
116
|
+
}
|
|
117
|
+
dismissCooldownTimerRef.current = setTimeout(function () {
|
|
118
|
+
dismissCooldownRef.current = false;
|
|
119
|
+
}, 800);
|
|
120
|
+
}, []);
|
|
121
|
+
var isInDismissCooldown = React.useCallback(function () {
|
|
122
|
+
return dismissCooldownRef.current;
|
|
123
|
+
}, []);
|
|
124
|
+
var burntOptionsRef = React.useRef(burntOptions);
|
|
125
|
+
var notificationOptionsRef = React.useRef(notificationOptions);
|
|
126
|
+
React.useEffect(function () {
|
|
127
|
+
burntOptionsRef.current = burntOptions;
|
|
128
|
+
}, [burntOptions]);
|
|
129
|
+
React.useEffect(function () {
|
|
130
|
+
notificationOptionsRef.current = notificationOptions;
|
|
131
|
+
}, [notificationOptions]);
|
|
132
|
+
React.useEffect(function () {
|
|
133
|
+
return ToastState.subscribe(function (toast) {
|
|
134
|
+
if (toast.dismiss) {
|
|
111
135
|
setToasts(function (toasts2) {
|
|
112
|
-
|
|
113
|
-
return t.id === toast.id
|
|
136
|
+
return toasts2.map(function (t) {
|
|
137
|
+
return t.id === toast.id ? {
|
|
138
|
+
...t,
|
|
139
|
+
delete: true
|
|
140
|
+
} : t;
|
|
114
141
|
});
|
|
115
|
-
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (native) {
|
|
146
|
+
var handled = dispatchNativeToast(toast, {
|
|
147
|
+
duration,
|
|
148
|
+
burntOptions: burntOptionsRef.current,
|
|
149
|
+
notificationOptions: notificationOptionsRef.current
|
|
150
|
+
});
|
|
151
|
+
if (handled) return;
|
|
152
|
+
}
|
|
153
|
+
setToasts(function (toasts2) {
|
|
154
|
+
var idx = toasts2.findIndex(function (t) {
|
|
155
|
+
return t.id === toast.id;
|
|
156
|
+
});
|
|
157
|
+
if (idx !== -1) {
|
|
158
|
+
return [...toasts2.slice(0, idx), {
|
|
116
159
|
...toasts2[idx],
|
|
117
160
|
...toast
|
|
118
|
-
}, ...toasts2.slice(idx + 1)]
|
|
119
|
-
}
|
|
161
|
+
}, ...toasts2.slice(idx + 1)];
|
|
162
|
+
}
|
|
163
|
+
return [toast, ...toasts2];
|
|
120
164
|
});
|
|
121
|
-
}, []), React.useEffect(function () {
|
|
122
|
-
toasts.length <= 1 && setExpanded(!1);
|
|
123
|
-
}, [toasts.length]);
|
|
124
|
-
var removeToast = React.useCallback(function (toastToRemove) {
|
|
125
|
-
setToasts(function (toasts2) {
|
|
126
|
-
var _toasts_find;
|
|
127
|
-
return !((_toasts_find = toasts2.find(function (t) {
|
|
128
|
-
return t.id === toastToRemove.id;
|
|
129
|
-
})) === null || _toasts_find === void 0) && _toasts_find.delete || ToastState.dismiss(toastToRemove.id), toasts2.filter(function (param) {
|
|
130
|
-
var {
|
|
131
|
-
id
|
|
132
|
-
} = param;
|
|
133
|
-
return id !== toastToRemove.id;
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
}, []),
|
|
137
|
-
swipeDirection = resolveSwipeDirection(swipeDirectionProp, position),
|
|
138
|
-
currentTheme = useThemeName(),
|
|
139
|
-
resolvedTheme = themeProp === "system" || !themeProp ? currentTheme?.includes("dark") ? "dark" : "light" : themeProp,
|
|
140
|
-
contextValue = {
|
|
141
|
-
toasts,
|
|
142
|
-
heights,
|
|
143
|
-
setHeights,
|
|
144
|
-
expanded,
|
|
145
|
-
setExpanded,
|
|
146
|
-
interacting,
|
|
147
|
-
setInteracting,
|
|
148
|
-
removeToast,
|
|
149
|
-
position,
|
|
150
|
-
duration,
|
|
151
|
-
gap,
|
|
152
|
-
visibleToasts,
|
|
153
|
-
swipeDirection,
|
|
154
|
-
swipeThreshold,
|
|
155
|
-
closeButton,
|
|
156
|
-
reducedMotion,
|
|
157
|
-
icons
|
|
158
|
-
};
|
|
159
|
-
return /* @__PURE__ */_jsx(ToastContext.Provider, {
|
|
160
|
-
...contextValue,
|
|
161
|
-
children: /* @__PURE__ */_jsx(Theme, {
|
|
162
|
-
name: resolvedTheme,
|
|
163
|
-
children
|
|
164
|
-
})
|
|
165
165
|
});
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
166
|
+
}, [native, duration]);
|
|
167
|
+
var prevToastCountRef = React.useRef(toasts.length);
|
|
168
|
+
React.useEffect(function () {
|
|
169
|
+
var prevCount = prevToastCountRef.current;
|
|
170
|
+
prevToastCountRef.current = toasts.length;
|
|
171
|
+
if (toasts.length <= 1 && !dismissCooldownRef.current) {
|
|
172
|
+
setExpanded(false);
|
|
173
|
+
} else if (toasts.length > prevCount && expanded) {
|
|
174
|
+
setExpanded(false);
|
|
175
|
+
}
|
|
176
|
+
}, [toasts.length, expanded]);
|
|
177
|
+
var removeToast = React.useCallback(function (toastToRemove) {
|
|
178
|
+
setToasts(function (toasts2) {
|
|
179
|
+
var _toasts_find;
|
|
180
|
+
if (!((_toasts_find = toasts2.find(function (t) {
|
|
181
|
+
return t.id === toastToRemove.id;
|
|
182
|
+
})) === null || _toasts_find === void 0 ? void 0 : _toasts_find.delete)) {
|
|
183
|
+
ToastState.dismiss(toastToRemove.id);
|
|
184
|
+
}
|
|
185
|
+
return toasts2.filter(function (param) {
|
|
186
|
+
var {
|
|
187
|
+
id
|
|
188
|
+
} = param;
|
|
189
|
+
return id !== toastToRemove.id;
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}, []);
|
|
193
|
+
var swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
|
|
194
|
+
var currentTheme = useThemeName();
|
|
195
|
+
var resolvedTheme = themeProp === "system" || !themeProp ? (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.includes("dark")) ? "dark" : "light" : themeProp;
|
|
196
|
+
var contextValue = {
|
|
197
|
+
toasts,
|
|
198
|
+
heights,
|
|
199
|
+
setToastHeight,
|
|
200
|
+
removeToastHeight,
|
|
201
|
+
expanded,
|
|
202
|
+
setExpanded,
|
|
203
|
+
interacting,
|
|
204
|
+
setInteracting,
|
|
205
|
+
triggerDismissCooldown,
|
|
206
|
+
isInDismissCooldown,
|
|
207
|
+
removeToast,
|
|
208
|
+
position,
|
|
209
|
+
duration,
|
|
210
|
+
gap,
|
|
211
|
+
visibleToasts,
|
|
212
|
+
swipeDirection,
|
|
213
|
+
swipeThreshold,
|
|
214
|
+
toastHeight,
|
|
215
|
+
closeButton,
|
|
216
|
+
reducedMotion,
|
|
217
|
+
native,
|
|
218
|
+
burntOptions,
|
|
219
|
+
notificationOptions,
|
|
220
|
+
icons
|
|
221
|
+
};
|
|
222
|
+
return /* @__PURE__ */_jsx(ToastContext.Provider, {
|
|
223
|
+
...contextValue,
|
|
224
|
+
children: /* @__PURE__ */_jsx(Theme, {
|
|
225
|
+
name: resolvedTheme,
|
|
226
|
+
children
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
var ToastViewportFrame = styled(View, {
|
|
231
|
+
name: "ToastViewport",
|
|
232
|
+
variants: {
|
|
233
|
+
unstyled: {
|
|
234
|
+
false: {
|
|
235
|
+
position: isWeb ? "fixed" : "absolute",
|
|
236
|
+
zIndex: 1e5,
|
|
237
|
+
pointerEvents: "box-none",
|
|
238
|
+
maxWidth: "100%",
|
|
239
|
+
...(isWeb && {
|
|
240
|
+
width: 356
|
|
241
|
+
}),
|
|
242
|
+
minHeight: 1
|
|
179
243
|
}
|
|
180
|
-
},
|
|
181
|
-
defaultVariants: {
|
|
182
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
183
244
|
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
245
|
+
},
|
|
246
|
+
defaultVariants: {
|
|
247
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
var ToastViewport = ToastViewportFrame.styleable(function ToastViewport2(props, ref) {
|
|
251
|
+
var {
|
|
252
|
+
offset = VIEWPORT_OFFSET,
|
|
253
|
+
hotkey = DEFAULT_HOTKEY,
|
|
254
|
+
label = "Notifications",
|
|
255
|
+
portalToRoot = true,
|
|
256
|
+
portalZIndex = Number.MAX_SAFE_INTEGER,
|
|
257
|
+
children,
|
|
258
|
+
...rest
|
|
259
|
+
} = props;
|
|
260
|
+
var ctx = useToastContext();
|
|
261
|
+
var listRef = React.useRef(null);
|
|
262
|
+
var hoverTimeoutRef = React.useRef(null);
|
|
263
|
+
var hoverCooldownRef = React.useRef(false);
|
|
264
|
+
var deferredCollapseRef = React.useRef(null);
|
|
265
|
+
var mouseInsideRef = React.useRef(false);
|
|
266
|
+
var [yPosition, xPosition] = ctx.position.split("-");
|
|
267
|
+
var {
|
|
268
|
+
insets: safeInsets
|
|
269
|
+
} = useConfiguration();
|
|
270
|
+
var offsetStyles = React.useMemo(function () {
|
|
271
|
+
var styles = {};
|
|
272
|
+
var defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
|
|
273
|
+
var offsetObj = (typeof offset === "undefined" ? "undefined" : _type_of(offset)) === "object" ? offset : {
|
|
274
|
+
top: defaultOffset,
|
|
275
|
+
right: defaultOffset,
|
|
276
|
+
bottom: defaultOffset,
|
|
277
|
+
left: defaultOffset
|
|
278
|
+
};
|
|
279
|
+
var _safeInsets_top;
|
|
280
|
+
var safeTop = (_safeInsets_top = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.top) !== null && _safeInsets_top !== void 0 ? _safeInsets_top : 0;
|
|
281
|
+
var _safeInsets_bottom;
|
|
282
|
+
var safeBottom = (_safeInsets_bottom = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.bottom) !== null && _safeInsets_bottom !== void 0 ? _safeInsets_bottom : 0;
|
|
283
|
+
var _offsetObj_top;
|
|
284
|
+
var topOffset = safeTop > 0 ? safeTop : (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset;
|
|
285
|
+
var _offsetObj_bottom;
|
|
286
|
+
var bottomOffset = safeBottom > 0 ? safeBottom : (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset;
|
|
287
|
+
if (yPosition === "top") styles.top = topOffset;else styles.bottom = bottomOffset;
|
|
288
|
+
if (isWeb) {
|
|
289
|
+
var _offsetObj_left, _offsetObj_right;
|
|
290
|
+
if (xPosition === "left") styles.left = (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset;else if (xPosition === "right") styles.right = (_offsetObj_right = offsetObj.right) !== null && _offsetObj_right !== void 0 ? _offsetObj_right : defaultOffset;else {
|
|
291
|
+
styles.left = "50%";
|
|
292
|
+
styles.transform = "translateX(-50%)";
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
var _offsetObj_left1;
|
|
296
|
+
styles.left = (_offsetObj_left1 = offsetObj.left) !== null && _offsetObj_left1 !== void 0 ? _offsetObj_left1 : defaultOffset;
|
|
297
|
+
var _offsetObj_right1;
|
|
298
|
+
styles.right = (_offsetObj_right1 = offsetObj.right) !== null && _offsetObj_right1 !== void 0 ? _offsetObj_right1 : defaultOffset;
|
|
299
|
+
}
|
|
300
|
+
return styles;
|
|
301
|
+
}, [offset, yPosition, xPosition]);
|
|
302
|
+
React.useEffect(function () {
|
|
303
|
+
if (!isWeb) return;
|
|
304
|
+
var handleKeyDown = function (event) {
|
|
305
|
+
var isHotkeyPressed = hotkey.length > 0 && hotkey.every(function (key) {
|
|
306
|
+
return event[key] || event.code === key;
|
|
307
|
+
});
|
|
308
|
+
if (isHotkeyPressed) {
|
|
309
|
+
var _listRef_current;
|
|
310
|
+
ctx.setExpanded(true);
|
|
311
|
+
(_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current.focus();
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
315
|
+
return function () {
|
|
316
|
+
return document.removeEventListener("keydown", handleKeyDown);
|
|
317
|
+
};
|
|
318
|
+
}, [hotkey]);
|
|
319
|
+
if (ctx.toasts.length === 0) return null;
|
|
320
|
+
var hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
321
|
+
var content = /* @__PURE__ */_jsx(ToastViewportFrame, {
|
|
322
|
+
ref: listRef,
|
|
323
|
+
"aria-label": `${label} ${hotkeyLabel}`,
|
|
324
|
+
tabIndex: -1,
|
|
325
|
+
"aria-live": "polite",
|
|
326
|
+
style: offsetStyles,
|
|
327
|
+
"data-y-position": yPosition,
|
|
328
|
+
"data-x-position": xPosition,
|
|
329
|
+
...(isWeb ? {
|
|
330
|
+
onMouseEnter: function () {
|
|
331
|
+
mouseInsideRef.current = true;
|
|
332
|
+
if (deferredCollapseRef.current) {
|
|
333
|
+
clearTimeout(deferredCollapseRef.current);
|
|
334
|
+
deferredCollapseRef.current = null;
|
|
335
|
+
}
|
|
336
|
+
if (ctx.toasts.length > 1 && !ctx.interacting && !hoverCooldownRef.current) {
|
|
337
|
+
hoverTimeoutRef.current = setTimeout(function () {
|
|
338
|
+
return ctx.setExpanded(true);
|
|
339
|
+
}, 50);
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
onMouseLeave: function () {
|
|
343
|
+
mouseInsideRef.current = false;
|
|
344
|
+
if (hoverTimeoutRef.current) {
|
|
345
|
+
clearTimeout(hoverTimeoutRef.current);
|
|
346
|
+
hoverTimeoutRef.current = null;
|
|
347
|
+
}
|
|
348
|
+
if (!ctx.interacting && !ctx.isInDismissCooldown()) {
|
|
349
|
+
ctx.setExpanded(false);
|
|
350
|
+
} else if (ctx.isInDismissCooldown()) {
|
|
351
|
+
if (deferredCollapseRef.current) {
|
|
352
|
+
clearTimeout(deferredCollapseRef.current);
|
|
353
|
+
}
|
|
354
|
+
deferredCollapseRef.current = setTimeout(function () {
|
|
355
|
+
deferredCollapseRef.current = null;
|
|
356
|
+
if (!mouseInsideRef.current) {
|
|
357
|
+
ctx.setExpanded(false);
|
|
358
|
+
}
|
|
359
|
+
}, 1200);
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
onPointerDown: function () {
|
|
363
|
+
if (hoverTimeoutRef.current) {
|
|
364
|
+
clearTimeout(hoverTimeoutRef.current);
|
|
365
|
+
hoverTimeoutRef.current = null;
|
|
366
|
+
}
|
|
367
|
+
ctx.setInteracting(true);
|
|
368
|
+
},
|
|
369
|
+
onPointerUp: function () {
|
|
370
|
+
return ctx.setInteracting(false);
|
|
371
|
+
},
|
|
372
|
+
onPointerCancel: function () {
|
|
373
|
+
return ctx.setInteracting(false);
|
|
374
|
+
}
|
|
375
|
+
} : {
|
|
376
|
+
onPress: function () {
|
|
377
|
+
if (ctx.toasts.length > 1) {
|
|
378
|
+
ctx.setExpanded(function (prev) {
|
|
379
|
+
return !prev;
|
|
219
380
|
});
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}),
|
|
384
|
+
...(isWeb && {
|
|
385
|
+
onFocus: function (event) {
|
|
386
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
387
|
+
if (ctx.toasts.length > 1) {
|
|
388
|
+
ctx.setExpanded(true);
|
|
223
389
|
}
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
390
|
+
ctx.setInteracting(true);
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
onBlur: function (event) {
|
|
394
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
395
|
+
ctx.setInteracting(false);
|
|
396
|
+
if (!ctx.isInDismissCooldown()) {
|
|
397
|
+
ctx.setExpanded(false);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
229
400
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
ref: listRef,
|
|
234
|
-
"aria-label": `${label} ${hotkeyLabel}`,
|
|
235
|
-
tabIndex: -1,
|
|
236
|
-
"aria-live": "polite",
|
|
237
|
-
style: offsetStyles,
|
|
238
|
-
"data-y-position": yPosition,
|
|
239
|
-
"data-x-position": xPosition,
|
|
240
|
-
onMouseEnter: function () {
|
|
241
|
-
ctx.toasts.length > 1 && !ctx.interacting && !hoverCooldownRef.current && (hoverTimeoutRef.current = setTimeout(function () {
|
|
242
|
-
return ctx.setExpanded(!0);
|
|
243
|
-
}, 50));
|
|
244
|
-
},
|
|
245
|
-
onMouseLeave: function () {
|
|
246
|
-
hoverTimeoutRef.current && (clearTimeout(hoverTimeoutRef.current), hoverTimeoutRef.current = null), ctx.interacting || ctx.setExpanded(!1);
|
|
247
|
-
},
|
|
248
|
-
onPointerDown: function () {
|
|
249
|
-
hoverTimeoutRef.current && (clearTimeout(hoverTimeoutRef.current), hoverTimeoutRef.current = null), ctx.setInteracting(!0);
|
|
250
|
-
},
|
|
251
|
-
onPointerUp: function () {
|
|
252
|
-
return ctx.setInteracting(!1);
|
|
253
|
-
},
|
|
254
|
-
...rest,
|
|
255
|
-
children
|
|
256
|
-
});
|
|
257
|
-
return portalToRoot && isWeb ? /* @__PURE__ */_jsx(Portal, {
|
|
258
|
-
children: content
|
|
259
|
-
}) : content;
|
|
401
|
+
}),
|
|
402
|
+
...rest,
|
|
403
|
+
children
|
|
260
404
|
});
|
|
405
|
+
if (portalToRoot) {
|
|
406
|
+
return /* @__PURE__ */_jsx(Portal, {
|
|
407
|
+
zIndex: portalZIndex,
|
|
408
|
+
children: content
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return content;
|
|
412
|
+
});
|
|
261
413
|
function ToastList(param) {
|
|
262
414
|
var {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
var heightIndex = ctx.heights.findIndex(function (h) {
|
|
268
|
-
var _ctx_toasts_index;
|
|
269
|
-
return h.toastId === ((_ctx_toasts_index = ctx.toasts[index]) === null || _ctx_toasts_index === void 0 ? void 0 : _ctx_toasts_index.id);
|
|
270
|
-
});
|
|
271
|
-
return heightIndex === -1 ? 0 : ctx.heights.reduce(function (prev, curr, i) {
|
|
272
|
-
return i >= heightIndex ? prev : prev + curr.height;
|
|
273
|
-
}, 0);
|
|
274
|
-
};
|
|
415
|
+
renderItem
|
|
416
|
+
} = param;
|
|
417
|
+
var ctx = useToastContext();
|
|
418
|
+
var maxRender = ctx.toasts.length;
|
|
275
419
|
return /* @__PURE__ */_jsx(AnimatePresence, {
|
|
276
|
-
children: ctx.toasts.map(function (toast, index) {
|
|
420
|
+
children: ctx.toasts.slice(0, maxRender).map(function (toast, index) {
|
|
277
421
|
var handleClose = function () {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
422
|
+
var _toast_onDismiss;
|
|
423
|
+
if (toast.dismissible === false) return;
|
|
424
|
+
(_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
|
|
425
|
+
ctx.removeToast(toast);
|
|
426
|
+
};
|
|
427
|
+
var itemContextValue = {
|
|
428
|
+
toast,
|
|
429
|
+
handleClose
|
|
430
|
+
};
|
|
431
|
+
if (!renderItem) {
|
|
432
|
+
return /* @__PURE__ */_jsx(ToastItemContext.Provider, {
|
|
433
|
+
value: itemContextValue,
|
|
434
|
+
children: /* @__PURE__ */_jsx(ToastItemInner, {
|
|
435
|
+
toast,
|
|
436
|
+
index,
|
|
437
|
+
children: /* @__PURE__ */_jsx(DefaultToastContent, {
|
|
438
|
+
toast
|
|
439
|
+
})
|
|
440
|
+
})
|
|
441
|
+
}, toast.id);
|
|
442
|
+
}
|
|
443
|
+
return /* @__PURE__ */_jsx(ToastItemContext.Provider, {
|
|
286
444
|
value: itemContextValue,
|
|
287
445
|
children: renderItem({
|
|
288
446
|
toast,
|
|
289
447
|
index,
|
|
290
448
|
handleClose
|
|
291
449
|
})
|
|
292
|
-
}, toast.id) : /* @__PURE__ */_jsx(ToastItemContext.Provider, {
|
|
293
|
-
value: itemContextValue,
|
|
294
|
-
children: /* @__PURE__ */_jsx(ToastItemInner, {
|
|
295
|
-
toast,
|
|
296
|
-
index,
|
|
297
|
-
children: /* @__PURE__ */_jsx(DefaultToastContent, {
|
|
298
|
-
toast
|
|
299
|
-
})
|
|
300
|
-
})
|
|
301
450
|
}, toast.id);
|
|
302
451
|
})
|
|
303
452
|
});
|
|
304
453
|
}
|
|
305
454
|
function DefaultToastContent(param) {
|
|
306
455
|
var {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
456
|
+
toast
|
|
457
|
+
} = param;
|
|
458
|
+
var ctx = useToastContext();
|
|
459
|
+
var {
|
|
460
|
+
handleClose
|
|
461
|
+
} = useToastItemContext();
|
|
462
|
+
var _toast_type;
|
|
463
|
+
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
464
|
+
var dismissible = toast.dismissible !== false;
|
|
465
|
+
var title = typeof toast.title === "function" ? toast.title() : toast.title;
|
|
466
|
+
var description = typeof toast.description === "function" ? toast.description() : toast.description;
|
|
317
467
|
return /* @__PURE__ */_jsxs(XStack, {
|
|
318
468
|
alignItems: "flex-start",
|
|
319
469
|
gap: "$3",
|
|
320
|
-
children: [
|
|
470
|
+
children: [/* @__PURE__ */_jsx(ToastIcon, {}), /* @__PURE__ */_jsxs(YStack, {
|
|
321
471
|
flex: 1,
|
|
322
472
|
gap: "$1",
|
|
323
473
|
children: [title && /* @__PURE__ */_jsx(ToastTitle, {
|
|
@@ -331,7 +481,8 @@ function DefaultToastContent(param) {
|
|
|
331
481
|
backgroundColor: "transparent",
|
|
332
482
|
onPress: function (e) {
|
|
333
483
|
var _toast_cancel_onClick, _toast_cancel;
|
|
334
|
-
(_toast_cancel = toast.cancel) === null || _toast_cancel === void 0
|
|
484
|
+
(_toast_cancel = toast.cancel) === null || _toast_cancel === void 0 ? void 0 : (_toast_cancel_onClick = _toast_cancel.onClick) === null || _toast_cancel_onClick === void 0 ? void 0 : _toast_cancel_onClick.call(_toast_cancel, e);
|
|
485
|
+
handleClose();
|
|
335
486
|
},
|
|
336
487
|
children: /* @__PURE__ */_jsx(SizableText, {
|
|
337
488
|
size: "$2",
|
|
@@ -348,7 +499,10 @@ function DefaultToastContent(param) {
|
|
|
348
499
|
},
|
|
349
500
|
onPress: function (e) {
|
|
350
501
|
var _toast_action_onClick, _toast_action;
|
|
351
|
-
(_toast_action = toast.action) === null || _toast_action === void 0
|
|
502
|
+
(_toast_action = toast.action) === null || _toast_action === void 0 ? void 0 : (_toast_action_onClick = _toast_action.onClick) === null || _toast_action_onClick === void 0 ? void 0 : _toast_action_onClick.call(_toast_action, e);
|
|
503
|
+
if (!e.defaultPrevented) {
|
|
504
|
+
handleClose();
|
|
505
|
+
}
|
|
352
506
|
},
|
|
353
507
|
children: /* @__PURE__ */_jsx(SizableText, {
|
|
354
508
|
size: "$2",
|
|
@@ -358,74 +512,58 @@ function DefaultToastContent(param) {
|
|
|
358
512
|
})
|
|
359
513
|
})]
|
|
360
514
|
})]
|
|
361
|
-
}), ctx.closeButton && /* @__PURE__ */_jsx(ToastClose, {})]
|
|
515
|
+
}), ctx.closeButton && dismissible && /* @__PURE__ */_jsx(ToastClose, {})]
|
|
362
516
|
});
|
|
363
517
|
}
|
|
364
|
-
var ToastPositionWrapper = styled(YStack, {
|
|
365
|
-
name: "ToastPositionWrapper",
|
|
366
|
-
pointerEvents: "auto",
|
|
367
|
-
position: "absolute",
|
|
368
|
-
left: 0,
|
|
369
|
-
right: 0,
|
|
370
|
-
opacity: 1,
|
|
371
|
-
scale: 1,
|
|
372
|
-
y: 0,
|
|
373
|
-
x: 0
|
|
374
|
-
}),
|
|
375
|
-
ToastItemFrame = styled(YStack, {
|
|
376
|
-
name: "ToastItem",
|
|
377
|
-
userSelect: "none",
|
|
378
|
-
cursor: "grab",
|
|
379
|
-
focusable: !0,
|
|
380
|
-
variants: {
|
|
381
|
-
unstyled: {
|
|
382
|
-
false: {
|
|
383
|
-
backgroundColor: "$background",
|
|
384
|
-
borderRadius: "$4",
|
|
385
|
-
paddingHorizontal: "$4",
|
|
386
|
-
paddingVertical: "$3",
|
|
387
|
-
borderWidth: 1,
|
|
388
|
-
borderColor: "$borderColor",
|
|
389
|
-
shadowColor: "rgba(0, 0, 0, 0.15)",
|
|
390
|
-
shadowOffset: {
|
|
391
|
-
width: 0,
|
|
392
|
-
height: 4
|
|
393
|
-
},
|
|
394
|
-
shadowRadius: 12,
|
|
395
|
-
focusVisibleStyle: {
|
|
396
|
-
outlineWidth: 2,
|
|
397
|
-
outlineColor: "$color8",
|
|
398
|
-
outlineStyle: "solid"
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
},
|
|
403
|
-
defaultVariants: {
|
|
404
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
518
|
function DragWrapper(param) {
|
|
408
519
|
var {
|
|
409
520
|
animatedStyle,
|
|
410
521
|
gestureHandlers,
|
|
522
|
+
gesture,
|
|
411
523
|
AnimatedView,
|
|
412
524
|
dragRef,
|
|
413
525
|
children
|
|
414
526
|
} = param;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
527
|
+
if (isWeb) {
|
|
528
|
+
return /* @__PURE__ */_jsx("div", {
|
|
529
|
+
ref: dragRef,
|
|
530
|
+
style: {
|
|
531
|
+
flex: 1,
|
|
532
|
+
display: "flex",
|
|
533
|
+
flexDirection: "column",
|
|
534
|
+
userSelect: "none",
|
|
535
|
+
WebkitUserSelect: "none",
|
|
536
|
+
touchAction: "none",
|
|
537
|
+
cursor: "default"
|
|
538
|
+
},
|
|
539
|
+
...gestureHandlers,
|
|
540
|
+
children
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
if (gesture) {
|
|
544
|
+
var gh = getGestureHandler();
|
|
545
|
+
var GestureDetector = gh.state.GestureDetector;
|
|
546
|
+
if (GestureDetector) {
|
|
547
|
+
return /* @__PURE__ */_jsx(GestureDetector, {
|
|
548
|
+
gesture,
|
|
549
|
+
children: /* @__PURE__ */_jsx(View, {
|
|
550
|
+
style: {
|
|
551
|
+
flex: 1
|
|
552
|
+
},
|
|
553
|
+
...{
|
|
554
|
+
collapsable: false
|
|
555
|
+
},
|
|
556
|
+
children: /* @__PURE__ */_jsx(AnimatedView, {
|
|
557
|
+
style: [{
|
|
558
|
+
flex: 1
|
|
559
|
+
}, animatedStyle],
|
|
560
|
+
children
|
|
561
|
+
})
|
|
562
|
+
})
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return /* @__PURE__ */_jsx(AnimatedView, {
|
|
429
567
|
style: [{
|
|
430
568
|
flex: 1
|
|
431
569
|
}, animatedStyle],
|
|
@@ -433,376 +571,392 @@ function DragWrapper(param) {
|
|
|
433
571
|
children
|
|
434
572
|
});
|
|
435
573
|
}
|
|
436
|
-
var ToastItemInner = ToastItemFrame.styleable(function (props, ref) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
574
|
+
var ToastItemInner = ToastItemFrame.styleable(function ToastItem(props, ref) {
|
|
575
|
+
var {
|
|
576
|
+
toast,
|
|
577
|
+
index,
|
|
578
|
+
children,
|
|
579
|
+
...rest
|
|
580
|
+
} = props;
|
|
581
|
+
var ctx = useToastContext();
|
|
582
|
+
var [mounted, setMounted] = React.useState(false);
|
|
583
|
+
var [removed, setRemoved] = React.useState(false);
|
|
584
|
+
var [swipeOut, setSwipeOut] = React.useState(false);
|
|
585
|
+
var [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);
|
|
586
|
+
var swipeExitYRef = React.useRef(null);
|
|
587
|
+
var closeTimerRef = React.useRef(null);
|
|
588
|
+
var closeTimerStartRef = React.useRef(0);
|
|
589
|
+
var lastPauseTimeRef = React.useRef(0);
|
|
590
|
+
var _toast_duration;
|
|
591
|
+
var remainingTimeRef = React.useRef((_toast_duration = toast.duration) !== null && _toast_duration !== void 0 ? _toast_duration : ctx.duration);
|
|
592
|
+
var isFront = index === 0;
|
|
593
|
+
var isVisible = index < ctx.visibleToasts;
|
|
594
|
+
var _toast_type;
|
|
595
|
+
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
596
|
+
var dismissible = toast.dismissible !== false;
|
|
597
|
+
var _toast_duration1;
|
|
598
|
+
var duration = (_toast_duration1 = toast.duration) !== null && _toast_duration1 !== void 0 ? _toast_duration1 : ctx.duration;
|
|
599
|
+
var [yPosition] = ctx.position.split("-");
|
|
600
|
+
var isTop = yPosition === "top";
|
|
601
|
+
var expandedOffset = isWeb ? function () {
|
|
602
|
+
var totalHeight = 0;
|
|
603
|
+
var activeCount = 0;
|
|
604
|
+
for (var i = 0; i < index; i++) {
|
|
605
|
+
var _ctx_toasts_i;
|
|
606
|
+
var toastId = (_ctx_toasts_i = ctx.toasts[i]) === null || _ctx_toasts_i === void 0 ? void 0 : _ctx_toasts_i.id;
|
|
607
|
+
if (toastId == null) continue;
|
|
608
|
+
var h2 = ctx.heights[toastId];
|
|
609
|
+
if (h2 === 0) continue;
|
|
610
|
+
totalHeight += h2 !== null && h2 !== void 0 ? h2 : ctx.toastHeight;
|
|
611
|
+
activeCount++;
|
|
612
|
+
}
|
|
613
|
+
return totalHeight + activeCount * ctx.gap;
|
|
614
|
+
}() : index * (ctx.toastHeight + ctx.gap);
|
|
615
|
+
var expandedOffsetRef = React.useRef(expandedOffset);
|
|
616
|
+
expandedOffsetRef.current = expandedOffset;
|
|
617
|
+
var isExpandedRef = React.useRef(ctx.expanded);
|
|
618
|
+
isExpandedRef.current = ctx.expanded;
|
|
619
|
+
var startTimer = React.useCallback(function () {
|
|
620
|
+
if (duration === Number.POSITIVE_INFINITY || toastType === "loading") return;
|
|
621
|
+
closeTimerStartRef.current = Date.now();
|
|
622
|
+
closeTimerRef.current = setTimeout(function () {
|
|
623
|
+
var _toast_onAutoClose;
|
|
624
|
+
(_toast_onAutoClose = toast.onAutoClose) === null || _toast_onAutoClose === void 0 ? void 0 : _toast_onAutoClose.call(toast, toast);
|
|
625
|
+
setRemoved(true);
|
|
626
|
+
setTimeout(function () {
|
|
627
|
+
return ctx.removeToast(toast);
|
|
628
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
629
|
+
}, remainingTimeRef.current);
|
|
630
|
+
}, [duration, toastType, toast, ctx.removeToast]);
|
|
631
|
+
var pauseTimer = useEvent(function () {
|
|
632
|
+
if (closeTimerRef.current) {
|
|
633
|
+
clearTimeout(closeTimerRef.current);
|
|
634
|
+
}
|
|
635
|
+
if (lastPauseTimeRef.current < closeTimerStartRef.current) {
|
|
636
|
+
var elapsed = Date.now() - closeTimerStartRef.current;
|
|
637
|
+
remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
|
|
638
|
+
}
|
|
639
|
+
lastPauseTimeRef.current = Date.now();
|
|
640
|
+
});
|
|
641
|
+
var resumeTimer = useEvent(function () {
|
|
642
|
+
if (ctx.expanded || ctx.interacting) return;
|
|
643
|
+
remainingTimeRef.current = duration;
|
|
644
|
+
startTimer();
|
|
645
|
+
});
|
|
646
|
+
React.useEffect(function () {
|
|
647
|
+
setMounted(true);
|
|
648
|
+
}, []);
|
|
649
|
+
React.useEffect(function () {
|
|
650
|
+
if (toast.delete) {
|
|
651
|
+
setRemoved(true);
|
|
652
|
+
if (isExpandedRef.current) {
|
|
653
|
+
setOffsetBeforeRemove(expandedOffsetRef.current);
|
|
654
|
+
}
|
|
655
|
+
setTimeout(function () {
|
|
656
|
+
return ctx.removeToast(toast);
|
|
657
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
658
|
+
}
|
|
659
|
+
}, [toast.delete, toast, ctx.removeToast]);
|
|
660
|
+
React.useEffect(function () {
|
|
661
|
+
if (ctx.expanded || ctx.interacting) {
|
|
662
|
+
pauseTimer();
|
|
663
|
+
} else {
|
|
664
|
+
startTimer();
|
|
665
|
+
}
|
|
666
|
+
return function () {
|
|
667
|
+
if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
|
|
668
|
+
};
|
|
669
|
+
}, [ctx.expanded, ctx.interacting, startTimer]);
|
|
670
|
+
React.useEffect(function () {
|
|
671
|
+
remainingTimeRef.current = duration;
|
|
672
|
+
}, [duration]);
|
|
673
|
+
var {
|
|
674
|
+
setDragOffset,
|
|
675
|
+
springBack,
|
|
676
|
+
animateOut,
|
|
677
|
+
animatedStyle,
|
|
678
|
+
AnimatedView,
|
|
679
|
+
dragRef
|
|
680
|
+
} = useToastAnimations({
|
|
681
|
+
reducedMotion: ctx.reducedMotion,
|
|
682
|
+
swipeAxis: ctx.swipeDirection === "up" || ctx.swipeDirection === "down" || ctx.swipeDirection === "vertical" ? "vertical" : "horizontal"
|
|
683
|
+
});
|
|
684
|
+
var {
|
|
685
|
+
isDragging,
|
|
686
|
+
gestureHandlers,
|
|
687
|
+
gesture
|
|
688
|
+
} = useAnimatedDragGesture({
|
|
689
|
+
direction: ctx.swipeDirection,
|
|
690
|
+
threshold: ctx.swipeThreshold,
|
|
691
|
+
disabled: !dismissible || toastType === "loading",
|
|
692
|
+
expanded: ctx.expanded,
|
|
693
|
+
onDragStart: pauseTimer,
|
|
694
|
+
onDragMove: setDragOffset,
|
|
695
|
+
onDismiss: function (exitDirection, velocity) {
|
|
696
|
+
var _toast_onDismiss;
|
|
697
|
+
ctx.triggerDismissCooldown();
|
|
698
|
+
setSwipeOut(true);
|
|
699
|
+
(_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
|
|
700
|
+
swipeExitYRef.current = isExpandedRef.current ? isTop ? expandedOffsetRef.current : -expandedOffsetRef.current : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
|
|
701
|
+
setRemoved(true);
|
|
702
|
+
ctx.removeToast(toast);
|
|
703
|
+
animateOut(exitDirection, velocity);
|
|
704
|
+
},
|
|
705
|
+
onCancel: function () {
|
|
706
|
+
springBack(function () {
|
|
707
|
+
resumeTimer();
|
|
489
708
|
});
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}, [toast.delete, toast, ctx.removeToast]), React.useEffect(function () {
|
|
497
|
-
return ctx.expanded || ctx.interacting ? pauseTimer() : startTimer(), function () {
|
|
498
|
-
closeTimerRef.current && clearTimeout(closeTimerRef.current);
|
|
499
|
-
};
|
|
500
|
-
}, [ctx.expanded, ctx.interacting, startTimer]), React.useEffect(function () {
|
|
501
|
-
remainingTimeRef.current = duration;
|
|
502
|
-
}, [duration]);
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
var handleLayout = React.useCallback(function (event) {
|
|
712
|
+
if (!isWeb) return;
|
|
713
|
+
if (removed) return;
|
|
714
|
+
if (!ctx.expanded && index !== 0) return;
|
|
503
715
|
var {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
716
|
+
height
|
|
717
|
+
} = event.nativeEvent.layout;
|
|
718
|
+
ctx.setToastHeight(toast.id, height);
|
|
719
|
+
}, [toast.id, ctx.setToastHeight, index, ctx.expanded, removed]);
|
|
720
|
+
React.useEffect(function () {
|
|
721
|
+
if (!isWeb) return;
|
|
722
|
+
return function () {
|
|
723
|
+
ctx.removeToastHeight(toast.id);
|
|
724
|
+
};
|
|
725
|
+
}, [toast.id, ctx.removeToastHeight]);
|
|
726
|
+
var handleClose = React.useCallback(function () {
|
|
727
|
+
var _toast_onDismiss;
|
|
728
|
+
if (!dismissible) return;
|
|
729
|
+
ctx.triggerDismissCooldown();
|
|
730
|
+
(_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
|
|
731
|
+
setRemoved(true);
|
|
732
|
+
if (isExpandedRef.current) {
|
|
733
|
+
setOffsetBeforeRemove(expandedOffsetRef.current);
|
|
734
|
+
}
|
|
735
|
+
setTimeout(function () {
|
|
736
|
+
return ctx.removeToast(toast);
|
|
737
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
738
|
+
}, [dismissible, toast, ctx.removeToast, ctx.triggerDismissCooldown]);
|
|
739
|
+
var itemContextValue = React.useMemo(function () {
|
|
740
|
+
return {
|
|
741
|
+
toast,
|
|
742
|
+
handleClose
|
|
743
|
+
};
|
|
744
|
+
}, [toast, handleClose]);
|
|
745
|
+
var frontToastHeight = -1;
|
|
746
|
+
if (isWeb) {
|
|
747
|
+
var _iteratorNormalCompletion = true,
|
|
748
|
+
_didIteratorError = false,
|
|
749
|
+
_iteratorError = void 0;
|
|
750
|
+
try {
|
|
751
|
+
for (var _iterator = ctx.toasts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
752
|
+
var t = _step.value;
|
|
753
|
+
var h = ctx.heights[t.id];
|
|
754
|
+
if (h != null && h > 0) {
|
|
755
|
+
frontToastHeight = h;
|
|
756
|
+
break;
|
|
537
757
|
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
});
|
|
547
|
-
return exists ? prev.map(function (h) {
|
|
548
|
-
return h.toastId === toast.id ? {
|
|
549
|
-
...h,
|
|
550
|
-
height
|
|
551
|
-
} : h;
|
|
552
|
-
}) : [{
|
|
553
|
-
toastId: toast.id,
|
|
554
|
-
height
|
|
555
|
-
}, ...prev];
|
|
556
|
-
});
|
|
557
|
-
}, [toast.id]);
|
|
558
|
-
React.useEffect(function () {
|
|
559
|
-
return function () {
|
|
560
|
-
ctx.setHeights(function (prev) {
|
|
561
|
-
return prev.filter(function (h) {
|
|
562
|
-
return h.toastId !== toast.id;
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
};
|
|
566
|
-
}, [toast.id]);
|
|
567
|
-
var handleClose = React.useCallback(function () {
|
|
568
|
-
var _toast_onDismiss;
|
|
569
|
-
dismissible && ((_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 || _toast_onDismiss.call(toast, toast), setRemoved(!0), setTimeout(function () {
|
|
570
|
-
return ctx.removeToast(toast);
|
|
571
|
-
}, TIME_BEFORE_UNMOUNT));
|
|
572
|
-
}, [dismissible, toast, ctx.removeToast]),
|
|
573
|
-
_ctx_heights__height,
|
|
574
|
-
frontToastHeight = ctx.heights.length > 0 && (_ctx_heights__height = (_ctx_heights_ = ctx.heights[0]) === null || _ctx_heights_ === void 0 ? void 0 : _ctx_heights_.height) !== null && _ctx_heights__height !== void 0 ? _ctx_heights__height : 55,
|
|
575
|
-
stackScale = !ctx.expanded && !isFront ? 1 - index * 0.05 : 1,
|
|
576
|
-
expandedOffset = toastsHeightBefore + index * ctx.gap,
|
|
577
|
-
peekVisible = 10,
|
|
578
|
-
stackY = ctx.expanded ? isTop ? expandedOffset : -expandedOffset : isFront ? 0 : isTop ? peekVisible * index : -peekVisible * index,
|
|
579
|
-
computedOpacity = index >= ctx.visibleToasts ? 0 : !ctx.expanded && index === ctx.visibleToasts - 1 ? 0.5 : 1,
|
|
580
|
-
computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1,
|
|
581
|
-
computedHeight = !ctx.expanded && !isFront ? frontToastHeight : void 0,
|
|
582
|
-
computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto",
|
|
583
|
-
gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0,
|
|
584
|
-
dataAttributes = {
|
|
585
|
-
"data-mounted": mounted ? "true" : "false",
|
|
586
|
-
"data-removed": removed ? "true" : "false",
|
|
587
|
-
"data-swipe-out": swipeOut ? "true" : "false",
|
|
588
|
-
"data-visible": isVisible ? "true" : "false",
|
|
589
|
-
"data-front": isFront ? "true" : "false",
|
|
590
|
-
"data-index": String(index),
|
|
591
|
-
"data-type": toastType,
|
|
592
|
-
"data-expanded": ctx.expanded ? "true" : "false"
|
|
593
|
-
};
|
|
594
|
-
return /* @__PURE__ */_jsx(ToastPositionWrapper, {
|
|
595
|
-
ref,
|
|
596
|
-
...dataAttributes,
|
|
597
|
-
onLayout: handleLayout,
|
|
598
|
-
transition: isDragging || ctx.reducedMotion ? void 0 : "200ms",
|
|
599
|
-
y: stackY,
|
|
600
|
-
scale: stackScale,
|
|
601
|
-
opacity: computedOpacity,
|
|
602
|
-
zIndex: computedZIndex,
|
|
603
|
-
height: computedHeight,
|
|
604
|
-
overflow: computedHeight ? "hidden" : void 0,
|
|
605
|
-
pointerEvents: computedPointerEvents,
|
|
606
|
-
top: isTop ? 0 : void 0,
|
|
607
|
-
bottom: isTop ? void 0 : 0,
|
|
608
|
-
...(isWeb && !isFront && !ctx.expanded && {
|
|
609
|
-
style: {
|
|
610
|
-
transformOrigin: isTop ? "top center" : "bottom center"
|
|
758
|
+
}
|
|
759
|
+
} catch (err) {
|
|
760
|
+
_didIteratorError = true;
|
|
761
|
+
_iteratorError = err;
|
|
762
|
+
} finally {
|
|
763
|
+
try {
|
|
764
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
765
|
+
_iterator.return();
|
|
611
766
|
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
} : {
|
|
616
|
-
opacity: 0,
|
|
617
|
-
y: isTop ? -10 : 10,
|
|
618
|
-
scale: 0.95
|
|
619
|
-
},
|
|
620
|
-
exitStyle: ctx.reducedMotion ? {
|
|
621
|
-
opacity: 0
|
|
622
|
-
} : {
|
|
623
|
-
opacity: 0,
|
|
624
|
-
x: 0,
|
|
625
|
-
y: swipeOut ? 0 : isTop ? -10 : 10,
|
|
626
|
-
scale: swipeOut ? 1 : 0.95
|
|
627
|
-
},
|
|
628
|
-
children: /* @__PURE__ */_jsx(DragWrapper, {
|
|
629
|
-
animatedStyle,
|
|
630
|
-
gestureHandlers,
|
|
631
|
-
AnimatedView,
|
|
632
|
-
dragRef,
|
|
633
|
-
children: /* @__PURE__ */_jsxs(ToastItemFrame, {
|
|
634
|
-
role: "status",
|
|
635
|
-
"aria-live": "polite",
|
|
636
|
-
"aria-atomic": !0,
|
|
637
|
-
tabIndex: 0,
|
|
638
|
-
...(isWeb && {
|
|
639
|
-
onKeyDown: function (event) {
|
|
640
|
-
event.key === "Escape" && dismissible && handleClose();
|
|
641
|
-
}
|
|
642
|
-
}),
|
|
643
|
-
...rest,
|
|
644
|
-
children: [/* gap filler to prevent hover flicker */
|
|
645
|
-
ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */_jsx(View, {
|
|
646
|
-
position: "absolute",
|
|
647
|
-
left: 0,
|
|
648
|
-
right: 0,
|
|
649
|
-
height: gapFillerHeight,
|
|
650
|
-
pointerEvents: "auto",
|
|
651
|
-
...(isTop ? {
|
|
652
|
-
top: "100%"
|
|
653
|
-
} : {
|
|
654
|
-
bottom: "100%"
|
|
655
|
-
})
|
|
656
|
-
}), children]
|
|
657
|
-
})
|
|
658
|
-
})
|
|
659
|
-
});
|
|
660
|
-
}),
|
|
661
|
-
ToastTitle = styled(SizableText, {
|
|
662
|
-
name: "ToastTitle",
|
|
663
|
-
variants: {
|
|
664
|
-
unstyled: {
|
|
665
|
-
false: {
|
|
666
|
-
color: "$color",
|
|
667
|
-
fontWeight: "600",
|
|
668
|
-
size: "$4"
|
|
767
|
+
} finally {
|
|
768
|
+
if (_didIteratorError) {
|
|
769
|
+
throw _iteratorError;
|
|
669
770
|
}
|
|
670
771
|
}
|
|
671
|
-
},
|
|
672
|
-
defaultVariants: {
|
|
673
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
674
772
|
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
773
|
+
}
|
|
774
|
+
var stackScale = !ctx.expanded && !isFront ? 1 - index * 0.05 : 1;
|
|
775
|
+
var activeExpandedOffset = removed ? offsetBeforeRemove : expandedOffset;
|
|
776
|
+
var stackY = ctx.expanded ? isTop ? activeExpandedOffset : -activeExpandedOffset : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
|
|
777
|
+
var computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
|
|
778
|
+
var computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
|
|
779
|
+
var computedHeight = isWeb ? ctx.expanded ? ctx.heights[toast.id] || void 0 : !isFront && frontToastHeight > 0 ? frontToastHeight : void 0 : void 0;
|
|
780
|
+
var computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto";
|
|
781
|
+
var gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
|
|
782
|
+
var dataAttributes = {
|
|
783
|
+
"data-mounted": mounted ? "true" : "false",
|
|
784
|
+
"data-removed": removed ? "true" : "false",
|
|
785
|
+
"data-swipe-out": swipeOut ? "true" : "false",
|
|
786
|
+
"data-visible": isVisible ? "true" : "false",
|
|
787
|
+
"data-front": isFront ? "true" : "false",
|
|
788
|
+
"data-index": String(index),
|
|
789
|
+
"data-type": toastType,
|
|
790
|
+
"data-expanded": ctx.expanded ? "true" : "false"
|
|
791
|
+
};
|
|
792
|
+
var _swipeExitYRef_current;
|
|
793
|
+
return /* @__PURE__ */_jsx(ToastPositionWrapper, {
|
|
794
|
+
ref,
|
|
795
|
+
testID: rest.testID,
|
|
796
|
+
accessibilityLabel: rest.accessibilityLabel,
|
|
797
|
+
...dataAttributes,
|
|
798
|
+
transition: isDragging || ctx.reducedMotion ? void 0 : removed ? "200ms" : "400ms",
|
|
799
|
+
animateOnly: isWeb ? ["transform", "opacity", "height"] : ["transform", "opacity"],
|
|
800
|
+
y: stackY,
|
|
801
|
+
scale: stackScale,
|
|
802
|
+
opacity: computedOpacity,
|
|
803
|
+
zIndex: computedZIndex,
|
|
804
|
+
height: computedHeight,
|
|
805
|
+
overflow: "visible",
|
|
806
|
+
pointerEvents: computedPointerEvents,
|
|
807
|
+
top: isTop ? 0 : void 0,
|
|
808
|
+
bottom: isTop ? void 0 : 0,
|
|
809
|
+
...(isWeb && !isFront && {
|
|
810
|
+
style: {
|
|
811
|
+
transformOrigin: isTop ? "top center" : "bottom center"
|
|
684
812
|
}
|
|
813
|
+
}),
|
|
814
|
+
enterStyle: ctx.reducedMotion ? {
|
|
815
|
+
opacity: 0
|
|
816
|
+
} : {
|
|
817
|
+
opacity: 0,
|
|
818
|
+
y: isTop ? -80 : 80
|
|
685
819
|
},
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
820
|
+
exitStyle: ctx.reducedMotion ? {
|
|
821
|
+
opacity: 0
|
|
822
|
+
} : swipeOut ? {
|
|
823
|
+
opacity: 0,
|
|
824
|
+
y: (_swipeExitYRef_current = swipeExitYRef.current) !== null && _swipeExitYRef_current !== void 0 ? _swipeExitYRef_current : stackY,
|
|
825
|
+
scale: stackScale
|
|
826
|
+
} : {
|
|
827
|
+
opacity: 0,
|
|
828
|
+
y: stackY,
|
|
829
|
+
scale: stackScale
|
|
830
|
+
},
|
|
831
|
+
children: /* @__PURE__ */_jsx(DragWrapper, {
|
|
832
|
+
animatedStyle,
|
|
833
|
+
gestureHandlers,
|
|
834
|
+
gesture,
|
|
835
|
+
AnimatedView,
|
|
836
|
+
dragRef,
|
|
837
|
+
children: /* @__PURE__ */_jsxs(ToastItemFrame, {
|
|
838
|
+
role: "status",
|
|
839
|
+
"aria-live": "polite",
|
|
840
|
+
"aria-atomic": true,
|
|
841
|
+
tabIndex: 0,
|
|
842
|
+
onLayout: handleLayout,
|
|
843
|
+
...(isWeb && {
|
|
844
|
+
onKeyDown: function (event) {
|
|
845
|
+
if (event.key === "Escape" && dismissible) {
|
|
846
|
+
var current = event.currentTarget;
|
|
847
|
+
var container = current.closest("[aria-label]");
|
|
848
|
+
if (container) {
|
|
849
|
+
var focusables = container.querySelectorAll('[tabindex="0"]');
|
|
850
|
+
var arr = Array.from(focusables);
|
|
851
|
+
var idx = arr.indexOf(current);
|
|
852
|
+
var next = arr[idx + 1] || arr[idx - 1];
|
|
853
|
+
next === null || next === void 0 ? void 0 : next.focus();
|
|
854
|
+
}
|
|
855
|
+
handleClose();
|
|
856
|
+
}
|
|
708
857
|
}
|
|
709
|
-
}
|
|
858
|
+
}),
|
|
859
|
+
...rest,
|
|
860
|
+
children: [/* gap filler to prevent hover flicker */
|
|
861
|
+
ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */_jsx(View, {
|
|
862
|
+
position: "absolute",
|
|
863
|
+
left: 0,
|
|
864
|
+
right: 0,
|
|
865
|
+
height: gapFillerHeight,
|
|
866
|
+
pointerEvents: "auto",
|
|
867
|
+
...(isTop ? {
|
|
868
|
+
top: "100%"
|
|
869
|
+
} : {
|
|
870
|
+
bottom: "100%"
|
|
871
|
+
})
|
|
872
|
+
}), /* @__PURE__ */_jsx(ToastItemContext.Provider, {
|
|
873
|
+
value: itemContextValue,
|
|
874
|
+
children
|
|
875
|
+
})]
|
|
876
|
+
})
|
|
877
|
+
})
|
|
878
|
+
});
|
|
879
|
+
});
|
|
880
|
+
var ToastTitle = styled(SizableText, {
|
|
881
|
+
name: "ToastTitle",
|
|
882
|
+
variants: {
|
|
883
|
+
unstyled: {
|
|
884
|
+
false: {
|
|
885
|
+
color: "$color",
|
|
886
|
+
fontWeight: "600",
|
|
887
|
+
size: "$4"
|
|
710
888
|
}
|
|
711
|
-
},
|
|
712
|
-
defaultVariants: {
|
|
713
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
714
889
|
}
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
"aria-label": "Close toast",
|
|
728
|
-
onPress: handleClose,
|
|
729
|
-
...props,
|
|
730
|
-
children: (_ref = (_props_children = props.children) !== null && _props_children !== void 0 ? _props_children : (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons.close) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */_jsx(DefaultCloseIcon, {})
|
|
731
|
-
});
|
|
732
|
-
}),
|
|
733
|
-
ToastActionFrame = styled(XStack, {
|
|
734
|
-
name: "ToastAction",
|
|
735
|
-
render: "button",
|
|
736
|
-
alignItems: "center",
|
|
737
|
-
justifyContent: "center",
|
|
738
|
-
cursor: "pointer",
|
|
739
|
-
variants: {
|
|
740
|
-
unstyled: {
|
|
741
|
-
false: {
|
|
742
|
-
borderRadius: "$2",
|
|
743
|
-
paddingHorizontal: "$2",
|
|
744
|
-
height: 24,
|
|
745
|
-
backgroundColor: "$color5",
|
|
746
|
-
hoverStyle: {
|
|
747
|
-
backgroundColor: "$color6"
|
|
748
|
-
},
|
|
749
|
-
pressStyle: {
|
|
750
|
-
backgroundColor: "$color7"
|
|
751
|
-
}
|
|
752
|
-
}
|
|
890
|
+
},
|
|
891
|
+
defaultVariants: {
|
|
892
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
var ToastDescription = styled(SizableText, {
|
|
896
|
+
name: "ToastDescription",
|
|
897
|
+
variants: {
|
|
898
|
+
unstyled: {
|
|
899
|
+
false: {
|
|
900
|
+
color: "$color11",
|
|
901
|
+
size: "$2"
|
|
753
902
|
}
|
|
754
|
-
},
|
|
755
|
-
defaultVariants: {
|
|
756
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
757
903
|
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
904
|
+
},
|
|
905
|
+
defaultVariants: {
|
|
906
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
var ToastClose = ToastCloseFrame.styleable(function ToastClose2(props, ref) {
|
|
910
|
+
var _ctx_icons;
|
|
911
|
+
var handleClose;
|
|
912
|
+
try {
|
|
913
|
+
var itemCtx = useToastItemContext();
|
|
914
|
+
handleClose = itemCtx.handleClose;
|
|
915
|
+
} catch (e) {}
|
|
916
|
+
var ctx = useToastContext();
|
|
917
|
+
var _props_children, _ref;
|
|
918
|
+
return /* @__PURE__ */_jsx(ToastCloseFrame, {
|
|
919
|
+
ref,
|
|
920
|
+
"aria-label": "Close toast",
|
|
921
|
+
onPress: handleClose,
|
|
922
|
+
...props,
|
|
923
|
+
children: (_ref = (_props_children = props.children) !== null && _props_children !== void 0 ? _props_children : (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons.close) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */_jsx(DefaultCloseIcon, {})
|
|
764
924
|
});
|
|
925
|
+
});
|
|
926
|
+
var ToastAction = ToastActionFrame.styleable(function ToastAction2(props, ref) {
|
|
927
|
+
return /* @__PURE__ */_jsx(ToastActionFrame, {
|
|
928
|
+
ref,
|
|
929
|
+
...props
|
|
930
|
+
});
|
|
931
|
+
});
|
|
765
932
|
function ToastIcon(props) {
|
|
766
|
-
var _ctx_icons
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
_ctx_icons3,
|
|
770
|
-
_ctx_icons4,
|
|
771
|
-
ctx = useToastContext(),
|
|
772
|
-
toast;
|
|
933
|
+
var _ctx_icons;
|
|
934
|
+
var ctx = useToastContext();
|
|
935
|
+
var toast;
|
|
773
936
|
try {
|
|
774
937
|
var itemCtx = useToastItemContext();
|
|
775
938
|
toast = itemCtx.toast;
|
|
776
|
-
} catch {
|
|
939
|
+
} catch (e) {
|
|
777
940
|
return null;
|
|
778
941
|
}
|
|
779
942
|
if (!toast) return null;
|
|
780
|
-
if (toast.icon !== void 0)
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
default: null,
|
|
794
|
-
success: (_ctx_icons_success = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons.success) !== null && _ctx_icons_success !== void 0 ? _ctx_icons_success : /* @__PURE__ */_jsx(DefaultSuccessIcon, {}),
|
|
795
|
-
error: (_ctx_icons_error = (_ctx_icons1 = ctx.icons) === null || _ctx_icons1 === void 0 ? void 0 : _ctx_icons1.error) !== null && _ctx_icons_error !== void 0 ? _ctx_icons_error : /* @__PURE__ */_jsx(DefaultErrorIcon, {}),
|
|
796
|
-
warning: (_ctx_icons_warning = (_ctx_icons2 = ctx.icons) === null || _ctx_icons2 === void 0 ? void 0 : _ctx_icons2.warning) !== null && _ctx_icons_warning !== void 0 ? _ctx_icons_warning : /* @__PURE__ */_jsx(DefaultWarningIcon, {}),
|
|
797
|
-
info: (_ctx_icons_info = (_ctx_icons3 = ctx.icons) === null || _ctx_icons3 === void 0 ? void 0 : _ctx_icons3.info) !== null && _ctx_icons_info !== void 0 ? _ctx_icons_info : /* @__PURE__ */_jsx(DefaultInfoIcon, {}),
|
|
798
|
-
loading: (_ctx_icons_loading = (_ctx_icons4 = ctx.icons) === null || _ctx_icons4 === void 0 ? void 0 : _ctx_icons4.loading) !== null && _ctx_icons_loading !== void 0 ? _ctx_icons_loading : /* @__PURE__ */_jsx(DefaultLoadingIcon, {})
|
|
799
|
-
},
|
|
800
|
-
icon = typeIcons[toastType];
|
|
801
|
-
return icon ? /* @__PURE__ */_jsx(View, {
|
|
943
|
+
if (toast.icon !== void 0) {
|
|
944
|
+
return /* @__PURE__ */_jsx(View, {
|
|
945
|
+
flexShrink: 0,
|
|
946
|
+
marginTop: "$0.5",
|
|
947
|
+
children: toast.icon
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
var _toast_type;
|
|
951
|
+
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
952
|
+
var _ctx_icons_toastType;
|
|
953
|
+
var icon = (_ctx_icons_toastType = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ctx_icons_toastType !== void 0 ? _ctx_icons_toastType : null;
|
|
954
|
+
if (!icon) return null;
|
|
955
|
+
return /* @__PURE__ */_jsx(View, {
|
|
802
956
|
flexShrink: 0,
|
|
803
957
|
marginTop: "$0.5",
|
|
804
958
|
children: icon
|
|
805
|
-
})
|
|
959
|
+
});
|
|
806
960
|
}
|
|
807
961
|
function useToasts() {
|
|
808
962
|
var ctx = useToastContext();
|
|
@@ -815,6 +969,7 @@ function useToasts() {
|
|
|
815
969
|
function useToastItem() {
|
|
816
970
|
return useToastItemContext();
|
|
817
971
|
}
|
|
972
|
+
ToastRoot.displayName = "Toast";
|
|
818
973
|
var Toast = withStaticProperties(ToastRoot, {
|
|
819
974
|
Viewport: ToastViewport,
|
|
820
975
|
List: ToastList,
|