@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
package/dist/esm/Toaster.mjs
CHANGED
|
@@ -1,215 +1,51 @@
|
|
|
1
|
-
import { AnimatePresence } from "@tamagui/animate-presence";
|
|
2
|
-
import { isWeb } from "@tamagui/constants";
|
|
3
|
-
import { Theme, View, styled, useThemeName } from "@tamagui/core";
|
|
4
|
-
import { Portal } from "@tamagui/portal";
|
|
5
1
|
import * as React from "react";
|
|
6
|
-
import {
|
|
7
|
-
import { ToastState } from "./ToastState.mjs";
|
|
8
|
-
import { useReducedMotion } from "./useReducedMotion.mjs";
|
|
2
|
+
import { Toast } from "./ToastComposable.mjs";
|
|
9
3
|
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
icons,
|
|
54
|
-
toastOptions,
|
|
55
|
-
containerAriaLabel = "Notifications",
|
|
56
|
-
disableNative = !1,
|
|
57
|
-
burntOptions,
|
|
58
|
-
notificationOptions,
|
|
59
|
-
className,
|
|
60
|
-
style,
|
|
61
|
-
reducedMotion: reducedMotionProp
|
|
62
|
-
} = props,
|
|
63
|
-
reducedMotion = useReducedMotion(reducedMotionProp),
|
|
64
|
-
[toasts, setToasts] = React.useState([]),
|
|
65
|
-
[heights, setHeights] = React.useState([]),
|
|
66
|
-
[expanded, setExpanded] = React.useState(!1),
|
|
67
|
-
[interacting, setInteracting] = React.useState(!1),
|
|
68
|
-
listRef = React.useRef(null),
|
|
69
|
-
lastFocusedElementRef = React.useRef(null),
|
|
70
|
-
isFocusWithinRef = React.useRef(!1),
|
|
71
|
-
hoverTimeoutRef = React.useRef(null),
|
|
72
|
-
hoverCooldownRef = React.useRef(!1);
|
|
73
|
-
React.useEffect(() => ToastState.subscribe(toast => {
|
|
74
|
-
if (toast.dismiss) {
|
|
75
|
-
setToasts(toasts2 => toasts2.map(t => t.id === toast.id ? {
|
|
76
|
-
...t,
|
|
77
|
-
delete: !0
|
|
78
|
-
} : t));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
setToasts(toasts2 => {
|
|
82
|
-
const indexOfExistingToast = toasts2.findIndex(t => t.id === toast.id);
|
|
83
|
-
return indexOfExistingToast !== -1 ? [...toasts2.slice(0, indexOfExistingToast), {
|
|
84
|
-
...toasts2[indexOfExistingToast],
|
|
85
|
-
...toast
|
|
86
|
-
}, ...toasts2.slice(indexOfExistingToast + 1)] : [toast, ...toasts2];
|
|
87
|
-
});
|
|
88
|
-
}), []), React.useEffect(() => {
|
|
89
|
-
toasts.length <= 1 && setExpanded(!1);
|
|
90
|
-
}, [toasts.length]), React.useEffect(() => {
|
|
91
|
-
if (!isWeb) return;
|
|
92
|
-
const handleKeyDown = event => {
|
|
93
|
-
hotkey.length > 0 && hotkey.every(key => event[key] || event.code === key) && (setExpanded(!0), listRef.current?.focus()), event.code === "Escape" && (document.activeElement === listRef.current || listRef.current?.contains(document.activeElement)) && setExpanded(!1);
|
|
94
|
-
};
|
|
95
|
-
return document.addEventListener("keydown", handleKeyDown), () => document.removeEventListener("keydown", handleKeyDown);
|
|
96
|
-
}, [hotkey]), React.useEffect(() => {
|
|
97
|
-
if (!(!isWeb || !listRef.current)) return () => {
|
|
98
|
-
lastFocusedElementRef.current && (lastFocusedElementRef.current.focus({
|
|
99
|
-
preventScroll: !0
|
|
100
|
-
}), lastFocusedElementRef.current = null, isFocusWithinRef.current = !1);
|
|
101
|
-
};
|
|
102
|
-
}, []), React.useEffect(() => () => {
|
|
103
|
-
hoverTimeoutRef.current && clearTimeout(hoverTimeoutRef.current);
|
|
104
|
-
}, []);
|
|
105
|
-
const removeToast = React.useCallback(toastToRemove => {
|
|
106
|
-
hoverCooldownRef.current = !0, setTimeout(() => {
|
|
107
|
-
hoverCooldownRef.current = !1;
|
|
108
|
-
}, 300), setToasts(toasts2 => (toasts2.find(toast => toast.id === toastToRemove.id)?.delete || ToastState.dismiss(toastToRemove.id), toasts2.filter(({
|
|
109
|
-
id
|
|
110
|
-
}) => id !== toastToRemove.id)));
|
|
111
|
-
}, []),
|
|
112
|
-
[yPosition, xPosition] = position.split("-"),
|
|
113
|
-
offsetStyles = React.useMemo(() => {
|
|
114
|
-
const styles = {},
|
|
115
|
-
defaultOffset = typeof offset == "number" ? offset : VIEWPORT_OFFSET,
|
|
116
|
-
offsetObj = typeof offset == "object" ? offset : {
|
|
117
|
-
top: defaultOffset,
|
|
118
|
-
right: defaultOffset,
|
|
119
|
-
bottom: defaultOffset,
|
|
120
|
-
left: defaultOffset
|
|
121
|
-
};
|
|
122
|
-
return yPosition === "top" ? styles.top = offsetObj.top ?? defaultOffset : styles.bottom = offsetObj.bottom ?? defaultOffset, xPosition === "left" ? styles.left = offsetObj.left ?? defaultOffset : xPosition === "right" ? styles.right = offsetObj.right ?? defaultOffset : (styles.left = "50%", styles.transform = "translateX(-50%)"), styles;
|
|
123
|
-
}, [offset, yPosition, xPosition]),
|
|
124
|
-
currentTheme = useThemeName(),
|
|
125
|
-
resolvedTheme = themeProp === "system" || !themeProp ? currentTheme?.includes("dark") ? "dark" : "light" : themeProp,
|
|
126
|
-
hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
127
|
-
if (toasts.length === 0) return null;
|
|
128
|
-
const content = /* @__PURE__ */jsx(ToasterFrame, {
|
|
129
|
-
ref: listRef,
|
|
130
|
-
width,
|
|
131
|
-
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
132
|
-
tabIndex: -1,
|
|
133
|
-
"aria-live": "polite",
|
|
134
|
-
"aria-relevant": "additions text",
|
|
135
|
-
"aria-atomic": !1,
|
|
136
|
-
style: {
|
|
137
|
-
...offsetStyles,
|
|
138
|
-
...style
|
|
139
|
-
},
|
|
140
|
-
className,
|
|
141
|
-
"data-y-position": yPosition,
|
|
142
|
-
"data-x-position": xPosition,
|
|
143
|
-
onMouseEnter: () => {
|
|
144
|
-
toasts.length > 1 && !interacting && !hoverCooldownRef.current && (hoverTimeoutRef.current = setTimeout(() => {
|
|
145
|
-
setExpanded(!0);
|
|
146
|
-
}, 50));
|
|
147
|
-
},
|
|
148
|
-
onMouseMove: () => {
|
|
149
|
-
toasts.length > 1 && !interacting && !expanded && !hoverCooldownRef.current && (hoverTimeoutRef.current || (hoverTimeoutRef.current = setTimeout(() => {
|
|
150
|
-
setExpanded(!0);
|
|
151
|
-
}, 50)));
|
|
152
|
-
},
|
|
153
|
-
onMouseLeave: () => {
|
|
154
|
-
hoverTimeoutRef.current && (clearTimeout(hoverTimeoutRef.current), hoverTimeoutRef.current = null), interacting || setExpanded(!1);
|
|
155
|
-
},
|
|
156
|
-
onPointerDown: () => {
|
|
157
|
-
hoverTimeoutRef.current && (clearTimeout(hoverTimeoutRef.current), hoverTimeoutRef.current = null), setInteracting(!0);
|
|
158
|
-
},
|
|
159
|
-
onPointerUp: () => setInteracting(!1),
|
|
160
|
-
...(isWeb && {
|
|
161
|
-
onBlur: event => {
|
|
162
|
-
isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget) && (isFocusWithinRef.current = !1, lastFocusedElementRef.current && (lastFocusedElementRef.current.focus({
|
|
163
|
-
preventScroll: !0
|
|
164
|
-
}), lastFocusedElementRef.current = null));
|
|
165
|
-
},
|
|
166
|
-
onFocus: event => {
|
|
167
|
-
isFocusWithinRef.current || (isFocusWithinRef.current = !0, lastFocusedElementRef.current = event.relatedTarget);
|
|
168
|
-
}
|
|
169
|
-
}),
|
|
170
|
-
children: /* @__PURE__ */jsx(AnimatePresence, {
|
|
171
|
-
children: toasts.map((toast, index) => {
|
|
172
|
-
const isVisible = index < visibleToasts,
|
|
173
|
-
isFront = index === 0,
|
|
174
|
-
heightBeforeMe = toasts.slice(0, index).reduce((sum, t) => {
|
|
175
|
-
const h = heights.find(h2 => h2.toastId === t.id);
|
|
176
|
-
return sum + (h?.height ?? 55);
|
|
177
|
-
}, 0);
|
|
178
|
-
return /* @__PURE__ */jsx(ToastItem, {
|
|
179
|
-
toast,
|
|
180
|
-
index,
|
|
181
|
-
expanded: expanded || expand,
|
|
182
|
-
interacting,
|
|
183
|
-
position,
|
|
184
|
-
visibleToasts,
|
|
185
|
-
removeToast,
|
|
186
|
-
heights,
|
|
187
|
-
setHeights,
|
|
188
|
-
heightBeforeMe,
|
|
189
|
-
duration: toast.duration ?? toastOptions?.duration ?? duration,
|
|
190
|
-
gap,
|
|
191
|
-
swipeDirection: resolveSwipeDirection(swipeDirection, position),
|
|
192
|
-
swipeThreshold,
|
|
193
|
-
closeButton: toast.closeButton ?? closeButton,
|
|
194
|
-
icons,
|
|
195
|
-
disableNative,
|
|
196
|
-
burntOptions,
|
|
197
|
-
notificationOptions,
|
|
198
|
-
reducedMotion
|
|
199
|
-
}, toast.id);
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
});
|
|
203
|
-
return isWeb ? /* @__PURE__ */jsx(Portal, {
|
|
204
|
-
children: /* @__PURE__ */jsx(Theme, {
|
|
205
|
-
name: resolvedTheme,
|
|
206
|
-
children: content
|
|
207
|
-
})
|
|
208
|
-
}) : /* @__PURE__ */jsx(Theme, {
|
|
209
|
-
name: resolvedTheme,
|
|
210
|
-
children: content
|
|
211
|
-
});
|
|
4
|
+
const Toaster = React.forwardRef(function Toaster2(props, ref) {
|
|
5
|
+
const {
|
|
6
|
+
position = "bottom-right",
|
|
7
|
+
expand = false,
|
|
8
|
+
visibleToasts,
|
|
9
|
+
gap,
|
|
10
|
+
duration,
|
|
11
|
+
offset,
|
|
12
|
+
hotkey,
|
|
13
|
+
swipeDirection,
|
|
14
|
+
swipeThreshold,
|
|
15
|
+
closeButton,
|
|
16
|
+
theme,
|
|
17
|
+
icons,
|
|
18
|
+
toastOptions,
|
|
19
|
+
containerAriaLabel = "Notifications",
|
|
20
|
+
native,
|
|
21
|
+
burntOptions,
|
|
22
|
+
notificationOptions,
|
|
23
|
+
reducedMotion
|
|
24
|
+
} = props;
|
|
25
|
+
return /* @__PURE__ */jsx(Toast, {
|
|
26
|
+
position,
|
|
27
|
+
expand,
|
|
28
|
+
visibleToasts,
|
|
29
|
+
gap,
|
|
30
|
+
duration: toastOptions?.duration ?? duration,
|
|
31
|
+
swipeDirection,
|
|
32
|
+
swipeThreshold,
|
|
33
|
+
closeButton,
|
|
34
|
+
theme,
|
|
35
|
+
icons,
|
|
36
|
+
native,
|
|
37
|
+
burntOptions,
|
|
38
|
+
notificationOptions,
|
|
39
|
+
reducedMotion,
|
|
40
|
+
children: /* @__PURE__ */jsx(Toast.Viewport, {
|
|
41
|
+
ref,
|
|
42
|
+
offset,
|
|
43
|
+
hotkey,
|
|
44
|
+
label: containerAriaLabel,
|
|
45
|
+
children: /* @__PURE__ */jsx(Toast.List, {})
|
|
46
|
+
})
|
|
212
47
|
});
|
|
48
|
+
});
|
|
213
49
|
Toaster.displayName = "Toaster";
|
|
214
50
|
export { Toaster };
|
|
215
51
|
//# sourceMappingURL=Toaster.mjs.map
|
package/dist/esm/Toaster.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","Toast","jsx","Toaster","forwardRef","Toaster2","props","ref","position","expand","visibleToasts","gap","duration","offset","hotkey","swipeDirection","swipeThreshold","closeButton","theme","icons","toastOptions","containerAriaLabel","native","burntOptions","notificationOptions","reducedMotion","children","Viewport","label","List","displayName"],"sources":["../../src/Toaster.tsx"],"sourcesContent":[null],"mappings":"AAMA,YAAYA,KAAA,MAAW;AACvB,SAASC,KAAA,QAAa;AAsKZ,SAAAC,GAAA;AA9CH,MAAMC,OAAA,GAAUH,KAAA,CAAMI,UAAA,CAC3B,SAASC,SAAQC,KAAA,EAAOC,GAAA,EAAK;EAC3B,MAAM;IACJC,QAAA,GAAW;IACXC,MAAA,GAAS;IACTC,aAAA;IACAC,GAAA;IACAC,QAAA;IACAC,MAAA;IACAC,MAAA;IACAC,cAAA;IACAC,cAAA;IACAC,WAAA;IACAC,KAAA;IACAC,KAAA;IACAC,YAAA;IACAC,kBAAA,GAAqB;IACrBC,MAAA;IACAC,YAAA;IACAC,mBAAA;IACAC;EACF,IAAInB,KAAA;EAEJ,OACE,eAAAJ,GAAA,CAACD,KAAA;IACCO,QAAA;IACAC,MAAA;IACAC,aAAA;IACAC,GAAA;IACAC,QAAA,EAAUQ,YAAA,EAAcR,QAAA,IAAYA,QAAA;IACpCG,cAAA;IACAC,cAAA;IACAC,WAAA;IACAC,KAAA;IACAC,KAAA;IACAG,MAAA;IACAC,YAAA;IACAC,mBAAA;IACAC,aAAA;IAEAC,QAAA,iBAAAxB,GAAA,CAACD,KAAA,CAAM0B,QAAA,EAAN;MACCpB,GAAA;MACAM,MAAA;MACAC,MAAA;MACAc,KAAA,EAAOP,kBAAA;MAEPK,QAAA,iBAAAxB,GAAA,CAACD,KAAA,CAAM4B,IAAA,EAAN,EAAW;IAAA,CACd;EAAA,CACF;AAEJ,CACF;AAEA1B,OAAA,CAAQ2B,WAAA,GAAc","ignoreList":[]}
|
|
@@ -1,271 +1,52 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { AnimatePresence } from "@tamagui/animate-presence";
|
|
3
|
-
import { isWeb } from "@tamagui/constants";
|
|
4
|
-
import { Theme, View, styled, useThemeName } from "@tamagui/core";
|
|
5
|
-
import { Portal } from "@tamagui/portal";
|
|
6
2
|
import * as React from "react";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
offset = VIEWPORT_OFFSET,
|
|
53
|
-
hotkey = ["altKey", "KeyT"],
|
|
54
|
-
swipeDirection = "auto",
|
|
55
|
-
swipeThreshold = 50,
|
|
56
|
-
closeButton = !1,
|
|
57
|
-
theme: themeProp,
|
|
58
|
-
icons,
|
|
59
|
-
toastOptions,
|
|
60
|
-
containerAriaLabel = "Notifications",
|
|
61
|
-
disableNative = !1,
|
|
62
|
-
burntOptions,
|
|
63
|
-
notificationOptions,
|
|
64
|
-
className,
|
|
65
|
-
style,
|
|
66
|
-
reducedMotion: reducedMotionProp
|
|
67
|
-
} = props,
|
|
68
|
-
reducedMotion = useReducedMotion(reducedMotionProp),
|
|
69
|
-
[toasts, setToasts] = React.useState([]),
|
|
70
|
-
[heights, setHeights] = React.useState([]),
|
|
71
|
-
[expanded, setExpanded] = React.useState(!1),
|
|
72
|
-
[interacting, setInteracting] = React.useState(!1),
|
|
73
|
-
listRef = React.useRef(null),
|
|
74
|
-
lastFocusedElementRef = React.useRef(null),
|
|
75
|
-
isFocusWithinRef = React.useRef(!1),
|
|
76
|
-
hoverTimeoutRef = React.useRef(null),
|
|
77
|
-
hoverCooldownRef = React.useRef(!1);
|
|
78
|
-
React.useEffect(function () {
|
|
79
|
-
return ToastState.subscribe(function (toast) {
|
|
80
|
-
if (toast.dismiss) {
|
|
81
|
-
setToasts(function (toasts2) {
|
|
82
|
-
return toasts2.map(function (t) {
|
|
83
|
-
return t.id === toast.id ? {
|
|
84
|
-
...t,
|
|
85
|
-
delete: !0
|
|
86
|
-
} : t;
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
setToasts(function (toasts2) {
|
|
92
|
-
var indexOfExistingToast = toasts2.findIndex(function (t) {
|
|
93
|
-
return t.id === toast.id;
|
|
94
|
-
});
|
|
95
|
-
return indexOfExistingToast !== -1 ? [...toasts2.slice(0, indexOfExistingToast), {
|
|
96
|
-
...toasts2[indexOfExistingToast],
|
|
97
|
-
...toast
|
|
98
|
-
}, ...toasts2.slice(indexOfExistingToast + 1)] : [toast, ...toasts2];
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}, []), React.useEffect(function () {
|
|
102
|
-
toasts.length <= 1 && setExpanded(!1);
|
|
103
|
-
}, [toasts.length]), React.useEffect(function () {
|
|
104
|
-
if (isWeb) {
|
|
105
|
-
var handleKeyDown = function (event) {
|
|
106
|
-
var _listRef_current,
|
|
107
|
-
isHotkeyPressed = hotkey.length > 0 && hotkey.every(function (key) {
|
|
108
|
-
return event[key] || event.code === key;
|
|
109
|
-
});
|
|
110
|
-
if (isHotkeyPressed) {
|
|
111
|
-
var _listRef_current1;
|
|
112
|
-
setExpanded(!0), (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 || _listRef_current1.focus();
|
|
113
|
-
}
|
|
114
|
-
event.code === "Escape" && (document.activeElement === listRef.current || !((_listRef_current = listRef.current) === null || _listRef_current === void 0) && _listRef_current.contains(document.activeElement)) && setExpanded(!1);
|
|
115
|
-
};
|
|
116
|
-
return document.addEventListener("keydown", handleKeyDown), function () {
|
|
117
|
-
return document.removeEventListener("keydown", handleKeyDown);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}, [hotkey]), React.useEffect(function () {
|
|
121
|
-
if (!(!isWeb || !listRef.current)) return function () {
|
|
122
|
-
lastFocusedElementRef.current && (lastFocusedElementRef.current.focus({
|
|
123
|
-
preventScroll: !0
|
|
124
|
-
}), lastFocusedElementRef.current = null, isFocusWithinRef.current = !1);
|
|
125
|
-
};
|
|
126
|
-
}, []), React.useEffect(function () {
|
|
127
|
-
return function () {
|
|
128
|
-
hoverTimeoutRef.current && clearTimeout(hoverTimeoutRef.current);
|
|
129
|
-
};
|
|
130
|
-
}, []);
|
|
131
|
-
var removeToast = React.useCallback(function (toastToRemove) {
|
|
132
|
-
hoverCooldownRef.current = !0, setTimeout(function () {
|
|
133
|
-
hoverCooldownRef.current = !1;
|
|
134
|
-
}, 300), setToasts(function (toasts2) {
|
|
135
|
-
var _toasts_find;
|
|
136
|
-
return !((_toasts_find = toasts2.find(function (toast) {
|
|
137
|
-
return toast.id === toastToRemove.id;
|
|
138
|
-
})) === null || _toasts_find === void 0) && _toasts_find.delete || ToastState.dismiss(toastToRemove.id), toasts2.filter(function (param) {
|
|
139
|
-
var {
|
|
140
|
-
id
|
|
141
|
-
} = param;
|
|
142
|
-
return id !== toastToRemove.id;
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
}, []),
|
|
146
|
-
[yPosition, xPosition] = position.split("-"),
|
|
147
|
-
offsetStyles = React.useMemo(function () {
|
|
148
|
-
var styles = {},
|
|
149
|
-
defaultOffset = typeof offset == "number" ? offset : VIEWPORT_OFFSET,
|
|
150
|
-
offsetObj = (typeof offset > "u" ? "undefined" : _type_of(offset)) === "object" ? offset : {
|
|
151
|
-
top: defaultOffset,
|
|
152
|
-
right: defaultOffset,
|
|
153
|
-
bottom: defaultOffset,
|
|
154
|
-
left: defaultOffset
|
|
155
|
-
};
|
|
156
|
-
if (yPosition === "top") {
|
|
157
|
-
var _offsetObj_top;
|
|
158
|
-
styles.top = (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset;
|
|
159
|
-
} else {
|
|
160
|
-
var _offsetObj_bottom;
|
|
161
|
-
styles.bottom = (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset;
|
|
162
|
-
}
|
|
163
|
-
if (xPosition === "left") {
|
|
164
|
-
var _offsetObj_left;
|
|
165
|
-
styles.left = (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset;
|
|
166
|
-
} else if (xPosition === "right") {
|
|
167
|
-
var _offsetObj_right;
|
|
168
|
-
styles.right = (_offsetObj_right = offsetObj.right) !== null && _offsetObj_right !== void 0 ? _offsetObj_right : defaultOffset;
|
|
169
|
-
} else styles.left = "50%", styles.transform = "translateX(-50%)";
|
|
170
|
-
return styles;
|
|
171
|
-
}, [offset, yPosition, xPosition]),
|
|
172
|
-
currentTheme = useThemeName(),
|
|
173
|
-
resolvedTheme = themeProp === "system" || !themeProp ? currentTheme?.includes("dark") ? "dark" : "light" : themeProp,
|
|
174
|
-
hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
175
|
-
if (toasts.length === 0) return null;
|
|
176
|
-
var content = /* @__PURE__ */_jsx(ToasterFrame, {
|
|
177
|
-
ref: listRef,
|
|
178
|
-
width,
|
|
179
|
-
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
180
|
-
tabIndex: -1,
|
|
181
|
-
"aria-live": "polite",
|
|
182
|
-
"aria-relevant": "additions text",
|
|
183
|
-
"aria-atomic": !1,
|
|
184
|
-
style: {
|
|
185
|
-
...offsetStyles,
|
|
186
|
-
...style
|
|
187
|
-
},
|
|
188
|
-
className,
|
|
189
|
-
"data-y-position": yPosition,
|
|
190
|
-
"data-x-position": xPosition,
|
|
191
|
-
onMouseEnter: function () {
|
|
192
|
-
toasts.length > 1 && !interacting && !hoverCooldownRef.current && (hoverTimeoutRef.current = setTimeout(function () {
|
|
193
|
-
setExpanded(!0);
|
|
194
|
-
}, 50));
|
|
195
|
-
},
|
|
196
|
-
onMouseMove: function () {
|
|
197
|
-
toasts.length > 1 && !interacting && !expanded && !hoverCooldownRef.current && (hoverTimeoutRef.current || (hoverTimeoutRef.current = setTimeout(function () {
|
|
198
|
-
setExpanded(!0);
|
|
199
|
-
}, 50)));
|
|
200
|
-
},
|
|
201
|
-
onMouseLeave: function () {
|
|
202
|
-
hoverTimeoutRef.current && (clearTimeout(hoverTimeoutRef.current), hoverTimeoutRef.current = null), interacting || setExpanded(!1);
|
|
203
|
-
},
|
|
204
|
-
onPointerDown: function () {
|
|
205
|
-
hoverTimeoutRef.current && (clearTimeout(hoverTimeoutRef.current), hoverTimeoutRef.current = null), setInteracting(!0);
|
|
206
|
-
},
|
|
207
|
-
onPointerUp: function () {
|
|
208
|
-
return setInteracting(!1);
|
|
209
|
-
},
|
|
210
|
-
...(isWeb && {
|
|
211
|
-
onBlur: function (event) {
|
|
212
|
-
isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget) && (isFocusWithinRef.current = !1, lastFocusedElementRef.current && (lastFocusedElementRef.current.focus({
|
|
213
|
-
preventScroll: !0
|
|
214
|
-
}), lastFocusedElementRef.current = null));
|
|
215
|
-
},
|
|
216
|
-
onFocus: function (event) {
|
|
217
|
-
isFocusWithinRef.current || (isFocusWithinRef.current = !0, lastFocusedElementRef.current = event.relatedTarget);
|
|
218
|
-
}
|
|
219
|
-
}),
|
|
220
|
-
children: /* @__PURE__ */_jsx(AnimatePresence, {
|
|
221
|
-
children: toasts.map(function (toast, index) {
|
|
222
|
-
var isVisible = index < visibleToasts,
|
|
223
|
-
isFront = index === 0,
|
|
224
|
-
heightBeforeMe = toasts.slice(0, index).reduce(function (sum, t) {
|
|
225
|
-
var h = heights.find(function (h2) {
|
|
226
|
-
return h2.toastId === t.id;
|
|
227
|
-
}),
|
|
228
|
-
_h_height;
|
|
229
|
-
return sum + ((_h_height = h?.height) !== null && _h_height !== void 0 ? _h_height : 55);
|
|
230
|
-
}, 0),
|
|
231
|
-
_toast_duration,
|
|
232
|
-
_ref2,
|
|
233
|
-
_toast_closeButton;
|
|
234
|
-
return /* @__PURE__ */_jsx(ToastItem, {
|
|
235
|
-
toast,
|
|
236
|
-
index,
|
|
237
|
-
expanded: expanded || expand,
|
|
238
|
-
interacting,
|
|
239
|
-
position,
|
|
240
|
-
visibleToasts,
|
|
241
|
-
removeToast,
|
|
242
|
-
heights,
|
|
243
|
-
setHeights,
|
|
244
|
-
heightBeforeMe,
|
|
245
|
-
duration: (_ref2 = (_toast_duration = toast.duration) !== null && _toast_duration !== void 0 ? _toast_duration : toastOptions?.duration) !== null && _ref2 !== void 0 ? _ref2 : duration,
|
|
246
|
-
gap,
|
|
247
|
-
swipeDirection: resolveSwipeDirection(swipeDirection, position),
|
|
248
|
-
swipeThreshold,
|
|
249
|
-
closeButton: (_toast_closeButton = toast.closeButton) !== null && _toast_closeButton !== void 0 ? _toast_closeButton : closeButton,
|
|
250
|
-
icons,
|
|
251
|
-
disableNative,
|
|
252
|
-
burntOptions,
|
|
253
|
-
notificationOptions,
|
|
254
|
-
reducedMotion
|
|
255
|
-
}, toast.id);
|
|
256
|
-
})
|
|
257
|
-
})
|
|
258
|
-
});
|
|
259
|
-
return isWeb ? /* @__PURE__ */_jsx(Portal, {
|
|
260
|
-
children: /* @__PURE__ */_jsx(Theme, {
|
|
261
|
-
name: resolvedTheme,
|
|
262
|
-
children: content
|
|
263
|
-
})
|
|
264
|
-
}) : /* @__PURE__ */_jsx(Theme, {
|
|
265
|
-
name: resolvedTheme,
|
|
266
|
-
children: content
|
|
267
|
-
});
|
|
3
|
+
import { Toast } from "./ToastComposable.native.js";
|
|
4
|
+
var Toaster = /* @__PURE__ */React.forwardRef(function Toaster2(props, ref) {
|
|
5
|
+
var {
|
|
6
|
+
position = "bottom-right",
|
|
7
|
+
expand = false,
|
|
8
|
+
visibleToasts,
|
|
9
|
+
gap,
|
|
10
|
+
duration,
|
|
11
|
+
offset,
|
|
12
|
+
hotkey,
|
|
13
|
+
swipeDirection,
|
|
14
|
+
swipeThreshold,
|
|
15
|
+
closeButton,
|
|
16
|
+
theme,
|
|
17
|
+
icons,
|
|
18
|
+
toastOptions,
|
|
19
|
+
containerAriaLabel = "Notifications",
|
|
20
|
+
native,
|
|
21
|
+
burntOptions,
|
|
22
|
+
notificationOptions,
|
|
23
|
+
reducedMotion
|
|
24
|
+
} = props;
|
|
25
|
+
var _toastOptions_duration;
|
|
26
|
+
return /* @__PURE__ */_jsx(Toast, {
|
|
27
|
+
position,
|
|
28
|
+
expand,
|
|
29
|
+
visibleToasts,
|
|
30
|
+
gap,
|
|
31
|
+
duration: (_toastOptions_duration = toastOptions === null || toastOptions === void 0 ? void 0 : toastOptions.duration) !== null && _toastOptions_duration !== void 0 ? _toastOptions_duration : duration,
|
|
32
|
+
swipeDirection,
|
|
33
|
+
swipeThreshold,
|
|
34
|
+
closeButton,
|
|
35
|
+
theme,
|
|
36
|
+
icons,
|
|
37
|
+
native,
|
|
38
|
+
burntOptions,
|
|
39
|
+
notificationOptions,
|
|
40
|
+
reducedMotion,
|
|
41
|
+
children: /* @__PURE__ */_jsx(Toast.Viewport, {
|
|
42
|
+
ref,
|
|
43
|
+
offset,
|
|
44
|
+
hotkey,
|
|
45
|
+
label: containerAriaLabel,
|
|
46
|
+
children: /* @__PURE__ */_jsx(Toast.List, {})
|
|
47
|
+
})
|
|
268
48
|
});
|
|
49
|
+
});
|
|
269
50
|
Toaster.displayName = "Toaster";
|
|
270
51
|
export { Toaster };
|
|
271
52
|
//# sourceMappingURL=Toaster.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","React","Toast","Toaster","forwardRef","Toaster2","props","ref","position","expand","visibleToasts","gap","duration","offset","hotkey","swipeDirection","swipeThreshold","closeButton","theme","icons","toastOptions","containerAriaLabel","native","burntOptions","notificationOptions","reducedMotion","_toastOptions_duration","children","Viewport","label","List","displayName"],"sources":["../../src/Toaster.tsx"],"sourcesContent":[null],"mappings":"AAMA,SAAAA,GAAY,IAAAC,IAAA,QAAW;AACvB,YAASC,KAAA,MAAa;AAsKZ,SAAAC,KAAA;AA9CH,IAAAC,OAAM,kBAAgBF,KAAA,CAAAG,UAAA,UAAAC,SAAAC,KAAA,EAAAC,GAAA;EAC3B;IAAAC,QAAS,iBAAoB;IAAAC,MAAA;IAAAC,aAAA;IAAAC,GAAA;IAAAC,QAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,cAAA;IAAAC,cAAA;IAAAC,WAAA;IAAAC,KAAA;IAAAC,KAAA;IAAAC,YAAA;IAAAC,kBAAA;IAAAC,MAAA;IAAAC,YAAA;IAAAC,mBAAA;IAAAC;EAAA,IAAAnB,KAAA;EAC3B,IAAAoB,sBAAM;EAAA,OACJ,eAAW1B,IAAA,CAAAE,KAAA;IAAAM,QACX;IAASC,MACT;IAAAC,aACA;IAAAC,GACA;IAAAC,QACA,GAAAc,sBAAA,GAAAN,YAAA,aAAAA,YAAA,uBAAAA,YAAA,CAAAR,QAAA,cAAAc,sBAAA,cAAAA,sBAAA,GAAAd,QAAA;IAAAG,cACA;IAAAC,cACA;IAAAC,WACA;IAAAC,KACA;IAAAC,KACA;IAAAG,MACA;IAAAC,YACA;IAAAC,mBACA;IAAqBC,aACrB;IAAAE,QACA,iBAAA3B,IAAA,CAAAE,KAAA,CAAA0B,QAAA;MACArB,GAAA;MACAM,MAAA;MACFC,MAAI;MAEJe,KACE,EAAAR,kBAAA;MAACM,QAAA,iBAAA3B,IAAA,CAAAE,KAAA,CAAA4B,IAAA;IAAA;EAAA;AACC;AACA3B,OAAA,CACA4B,WAAA;AAAA,SACA5B,OACA","ignoreList":[]}
|
package/dist/esm/constants.mjs
CHANGED