@tamagui/toast 1.8.5 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Toast.js +2 -4
- package/dist/cjs/Toast.js.map +2 -2
- package/dist/cjs/ToastImperative.js +119 -0
- package/dist/cjs/ToastImperative.js.map +7 -0
- package/dist/cjs/ToastImpl.js +0 -1
- package/dist/cjs/ToastImpl.js.map +2 -2
- package/dist/cjs/ToastViewport.js +2 -1
- package/dist/cjs/ToastViewport.js.map +2 -2
- package/dist/cjs/createNativeToast.js +30 -9
- package/dist/cjs/createNativeToast.js.map +2 -2
- package/dist/cjs/createNativeToast.native.js +13 -6
- package/dist/cjs/createNativeToast.native.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/Toast.js +2 -3
- package/dist/esm/Toast.js.map +2 -2
- package/dist/esm/Toast.mjs +2 -3
- package/dist/esm/Toast.mjs.map +2 -2
- package/dist/esm/ToastImperative.js +84 -0
- package/dist/esm/ToastImperative.js.map +7 -0
- package/dist/esm/ToastImperative.mjs +84 -0
- package/dist/esm/ToastImperative.mjs.map +7 -0
- package/dist/esm/ToastImpl.js +0 -1
- package/dist/esm/ToastImpl.js.map +2 -2
- package/dist/esm/ToastImpl.mjs +0 -1
- package/dist/esm/ToastImpl.mjs.map +2 -2
- package/dist/esm/ToastViewport.js +2 -1
- package/dist/esm/ToastViewport.js.map +2 -2
- package/dist/esm/ToastViewport.mjs +2 -1
- package/dist/esm/ToastViewport.mjs.map +2 -2
- package/dist/esm/createNativeToast.js +28 -8
- package/dist/esm/createNativeToast.js.map +2 -2
- package/dist/esm/createNativeToast.mjs +28 -8
- package/dist/esm/createNativeToast.mjs.map +2 -2
- package/dist/esm/createNativeToast.native.js +11 -5
- package/dist/esm/createNativeToast.native.js.map +2 -2
- package/dist/esm/createNativeToast.native.mjs +11 -5
- package/dist/esm/createNativeToast.native.mjs.map +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +2 -2
- package/dist/jsx/Toast.js +2 -3
- package/dist/jsx/Toast.js.map +2 -2
- package/dist/jsx/Toast.mjs +2 -3
- package/dist/jsx/Toast.mjs.map +2 -2
- package/dist/jsx/ToastImperative.js +79 -0
- package/dist/jsx/ToastImperative.js.map +7 -0
- package/dist/jsx/ToastImperative.mjs +79 -0
- package/dist/jsx/ToastImperative.mjs.map +7 -0
- package/dist/jsx/ToastImpl.js +0 -1
- package/dist/jsx/ToastImpl.js.map +2 -2
- package/dist/jsx/ToastImpl.mjs +0 -1
- package/dist/jsx/ToastImpl.mjs.map +2 -2
- package/dist/jsx/ToastViewport.js +2 -1
- package/dist/jsx/ToastViewport.js.map +2 -2
- package/dist/jsx/ToastViewport.mjs +2 -1
- package/dist/jsx/ToastViewport.mjs.map +2 -2
- package/dist/jsx/createNativeToast.js +28 -8
- package/dist/jsx/createNativeToast.js.map +2 -2
- package/dist/jsx/createNativeToast.mjs +28 -8
- package/dist/jsx/createNativeToast.mjs.map +2 -2
- package/dist/jsx/createNativeToast.native.js +11 -5
- package/dist/jsx/createNativeToast.native.js.map +2 -2
- package/dist/jsx/createNativeToast.native.mjs +11 -5
- package/dist/jsx/createNativeToast.native.mjs.map +2 -2
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/index.js.map +2 -2
- package/dist/jsx/index.mjs +1 -0
- package/dist/jsx/index.mjs.map +2 -2
- package/package.json +13 -13
- package/src/Toast.tsx +3 -5
- package/src/ToastImperative.tsx +150 -0
- package/src/ToastImpl.tsx +13 -10
- package/src/ToastViewport.tsx +10 -2
- package/src/createNativeToast.native.tsx +18 -7
- package/src/createNativeToast.tsx +32 -8
- package/src/index.ts +1 -0
- package/src/types.ts +31 -9
- package/types/Toast.d.ts +1 -2
- package/types/Toast.d.ts.map +1 -1
- package/types/ToastImperative.d.ts +57 -0
- package/types/ToastImperative.d.ts.map +1 -0
- package/types/ToastImpl.d.ts +8 -0
- package/types/ToastImpl.d.ts.map +1 -1
- package/types/ToastViewport.d.ts +12 -0
- package/types/ToastViewport.d.ts.map +1 -1
- package/types/createNativeToast.d.ts +3 -2
- package/types/createNativeToast.d.ts.map +1 -1
- package/types/createNativeToast.native.d.ts +3 -2
- package/types/createNativeToast.native.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +24 -7
- package/types/types.d.ts.map +1 -1
- package/src/createToast.tsx +0 -93
- package/types/createToast.d.ts +0 -42
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Toast'\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './Toast'\nexport * from './ToastImperative'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/toast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/animate-presence": "1.
|
|
35
|
-
"@tamagui/compose-refs": "1.
|
|
36
|
-
"@tamagui/core": "1.
|
|
37
|
-
"@tamagui/create-context": "1.
|
|
38
|
-
"@tamagui/dismissable": "1.
|
|
39
|
-
"@tamagui/polyfill-dev": "1.
|
|
40
|
-
"@tamagui/portal": "1.
|
|
41
|
-
"@tamagui/stacks": "1.
|
|
42
|
-
"@tamagui/text": "1.
|
|
43
|
-
"@tamagui/use-controllable-state": "1.
|
|
44
|
-
"@tamagui/visually-hidden": "1.
|
|
34
|
+
"@tamagui/animate-presence": "1.9.1",
|
|
35
|
+
"@tamagui/compose-refs": "1.9.1",
|
|
36
|
+
"@tamagui/core": "1.9.1",
|
|
37
|
+
"@tamagui/create-context": "1.9.1",
|
|
38
|
+
"@tamagui/dismissable": "1.9.1",
|
|
39
|
+
"@tamagui/polyfill-dev": "1.9.1",
|
|
40
|
+
"@tamagui/portal": "1.9.1",
|
|
41
|
+
"@tamagui/stacks": "1.9.1",
|
|
42
|
+
"@tamagui/text": "1.9.1",
|
|
43
|
+
"@tamagui/use-controllable-state": "1.9.1",
|
|
44
|
+
"@tamagui/visually-hidden": "1.9.1",
|
|
45
45
|
"burnt": "^0.10.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-native": "*"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@tamagui/build": "1.
|
|
52
|
+
"@tamagui/build": "1.9.1",
|
|
53
53
|
"react": "^18.2.0",
|
|
54
54
|
"react-native": "^0.71.4"
|
|
55
55
|
},
|
package/src/Toast.tsx
CHANGED
|
@@ -14,7 +14,6 @@ import { useControllableState } from '@tamagui/use-controllable-state'
|
|
|
14
14
|
import * as React from 'react'
|
|
15
15
|
|
|
16
16
|
import { TOAST_NAME } from './constants'
|
|
17
|
-
import { createToast } from './createToast'
|
|
18
17
|
import { ToastAnnounceExclude } from './ToastAnnounce'
|
|
19
18
|
import {
|
|
20
19
|
ToastImpl,
|
|
@@ -182,8 +181,9 @@ const ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(
|
|
|
182
181
|
const id = useId()
|
|
183
182
|
const onPause = useEvent(props.onPause)
|
|
184
183
|
const onResume = useEvent(props.onResume)
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
const shouldShow = forceMount || open
|
|
185
|
+
|
|
186
|
+
if (!shouldShow) return null
|
|
187
187
|
|
|
188
188
|
return (
|
|
189
189
|
<ToastImpl
|
|
@@ -221,8 +221,6 @@ export {
|
|
|
221
221
|
ToastProvider,
|
|
222
222
|
ToastViewport,
|
|
223
223
|
//
|
|
224
|
-
createToast,
|
|
225
|
-
//
|
|
226
224
|
createToastScope,
|
|
227
225
|
}
|
|
228
226
|
export type {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { isWeb } from '@tamagui/core'
|
|
2
|
+
import { Scope, createContextScope } from '@tamagui/create-context'
|
|
3
|
+
import React, { useRef } from 'react'
|
|
4
|
+
import { Platform } from 'react-native'
|
|
5
|
+
|
|
6
|
+
import { createNativeToast } from './createNativeToast'
|
|
7
|
+
import {
|
|
8
|
+
CreateNativeToastOptions,
|
|
9
|
+
NativeToastRef,
|
|
10
|
+
ToastNativePlatform,
|
|
11
|
+
ToastNativeValue,
|
|
12
|
+
} from './types'
|
|
13
|
+
|
|
14
|
+
interface ToastImperativeOptions extends Omit<CreateNativeToastOptions, "message"> {
|
|
15
|
+
/**
|
|
16
|
+
* Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.
|
|
17
|
+
*/
|
|
18
|
+
native?: ToastNativeValue
|
|
19
|
+
}
|
|
20
|
+
interface ShowToastOptions extends CreateNativeToastOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Used when need custom data
|
|
23
|
+
*/
|
|
24
|
+
additionalInfo?: Record<string, any>
|
|
25
|
+
/**
|
|
26
|
+
* Overrides the native option on `ToastImperativeProvider`
|
|
27
|
+
*/
|
|
28
|
+
native?: ToastNativeValue
|
|
29
|
+
}
|
|
30
|
+
type ScopedProps<P> = P & { __scopeToast?: Scope }
|
|
31
|
+
|
|
32
|
+
type ToastData = { title: string; id: string } & CreateNativeToastOptions & {
|
|
33
|
+
isHandledNatively: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface ImperativeToastContextValue {
|
|
37
|
+
currentToast: ToastData | null
|
|
38
|
+
nativeToast: NativeToastRef | null
|
|
39
|
+
showToast: (title: string, options?: ShowToastOptions) => boolean
|
|
40
|
+
hideToast: () => void
|
|
41
|
+
options?: ToastImperativeOptions
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const [createImperativeToastContext, createImperativeToastScope] =
|
|
45
|
+
createContextScope('ImperativeToast')
|
|
46
|
+
|
|
47
|
+
const [ToastImperativeProviderProvider, useToastProviderContext] =
|
|
48
|
+
createImperativeToastContext<ImperativeToastContextValue>('ToastImperativeProvider')
|
|
49
|
+
|
|
50
|
+
const useToast = () => {
|
|
51
|
+
const context = useToastProviderContext('useToast', undefined)
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
/**
|
|
55
|
+
* The currently displaying toast
|
|
56
|
+
*/
|
|
57
|
+
currentToast: context.currentToast,
|
|
58
|
+
/**
|
|
59
|
+
* Call it to show a new toast. If you're using native toasts, you can pass native options using \`burntOptions\` or \`notificationOptions\` depending on the native platform (mobile/web).
|
|
60
|
+
*/
|
|
61
|
+
show: context.showToast,
|
|
62
|
+
/**
|
|
63
|
+
* Call it to hide the currently displayed toast.
|
|
64
|
+
*
|
|
65
|
+
* _NOTE_: does not work on Android native toasts
|
|
66
|
+
*
|
|
67
|
+
* _NOTE_: hides the last toast on web notification toasts
|
|
68
|
+
*/
|
|
69
|
+
hide: context.hideToast,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface ToastImperativeProviderProps {
|
|
74
|
+
children: React.ReactNode
|
|
75
|
+
/**
|
|
76
|
+
* Used to provide defaults to imperative API. Options can be overwritten when calling `show()`.
|
|
77
|
+
*/
|
|
78
|
+
options: ToastImperativeOptions
|
|
79
|
+
}
|
|
80
|
+
const ToastImperativeProvider = ({
|
|
81
|
+
children,
|
|
82
|
+
options,
|
|
83
|
+
__scopeToast,
|
|
84
|
+
}: ScopedProps<ToastImperativeProviderProps>) => {
|
|
85
|
+
const counterRef = useRef(0)
|
|
86
|
+
const [toast, setToast] =
|
|
87
|
+
React.useState<ImperativeToastContextValue['currentToast']>(null)
|
|
88
|
+
const [lastNativeToastRef, setLastNativeToastRef] =
|
|
89
|
+
React.useState<ImperativeToastContextValue['nativeToast']>(null)
|
|
90
|
+
const showToast = React.useCallback<ImperativeToastContextValue['showToast']>(
|
|
91
|
+
(title, showToastOptions) => {
|
|
92
|
+
const native = showToastOptions?.native ?? options.native
|
|
93
|
+
const isWebNative = Array.isArray(native)
|
|
94
|
+
? native.includes('web')
|
|
95
|
+
: native === 'web'
|
|
96
|
+
const isMobileNative = Array.isArray(native)
|
|
97
|
+
? native.includes('mobile')
|
|
98
|
+
: native === 'mobile'
|
|
99
|
+
const isAndroidNative =
|
|
100
|
+
isMobileNative ||
|
|
101
|
+
(Array.isArray(native) ? native.includes('android') : native === 'android')
|
|
102
|
+
const isIosNative =
|
|
103
|
+
isMobileNative ||
|
|
104
|
+
(Array.isArray(native) ? native.includes('ios') : native === 'ios')
|
|
105
|
+
|
|
106
|
+
const isHandledNatively =
|
|
107
|
+
native === true ||
|
|
108
|
+
(isWeb && isWebNative) ||
|
|
109
|
+
(!isWeb && isMobileNative) ||
|
|
110
|
+
(Platform.OS === 'android' && isAndroidNative) ||
|
|
111
|
+
(Platform.OS === 'ios' && isIosNative)
|
|
112
|
+
|
|
113
|
+
if (isHandledNatively) {
|
|
114
|
+
const nativeToastResult = createNativeToast(title, showToastOptions ?? {})
|
|
115
|
+
if (typeof nativeToastResult === 'object' && nativeToastResult.nativeToastRef) {
|
|
116
|
+
setLastNativeToastRef(nativeToastResult.nativeToastRef)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
counterRef.current++
|
|
120
|
+
setToast({
|
|
121
|
+
title,
|
|
122
|
+
id: counterRef.current.toString(),
|
|
123
|
+
...showToastOptions,
|
|
124
|
+
isHandledNatively,
|
|
125
|
+
})
|
|
126
|
+
return true
|
|
127
|
+
},
|
|
128
|
+
[setToast, options.native]
|
|
129
|
+
)
|
|
130
|
+
const hideToast = React.useCallback(() => {
|
|
131
|
+
lastNativeToastRef?.close()
|
|
132
|
+
setToast(null)
|
|
133
|
+
}, [setToast, lastNativeToastRef])
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<ToastImperativeProviderProvider
|
|
137
|
+
scope={__scopeToast}
|
|
138
|
+
showToast={showToast}
|
|
139
|
+
hideToast={hideToast}
|
|
140
|
+
currentToast={toast}
|
|
141
|
+
nativeToast={lastNativeToastRef}
|
|
142
|
+
options={options}
|
|
143
|
+
>
|
|
144
|
+
{children}
|
|
145
|
+
</ToastImperativeProviderProvider>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { ToastImperativeProvider, useToast }
|
|
150
|
+
export type { ToastImperativeProviderProps, ToastNativePlatform, ToastNativeValue }
|
package/src/ToastImpl.tsx
CHANGED
|
@@ -131,6 +131,10 @@ type ToastImplProps = ToastImplPrivateProps &
|
|
|
131
131
|
* @default "default"
|
|
132
132
|
*/
|
|
133
133
|
viewportName?: string
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
id?: string
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
const ToastImpl = React.forwardRef<TamaguiElement, ToastImplProps>(
|
|
@@ -162,15 +166,15 @@ const ToastImpl = React.forwardRef<TamaguiElement, ToastImplProps>(
|
|
|
162
166
|
const { onToastAdd, onToastRemove } = context
|
|
163
167
|
const handleClose = useEvent(() => {
|
|
164
168
|
if (!isPresent) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
// already removed from the react tree
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
// focus viewport if focus is within toast to read the remaining toast
|
|
173
|
+
// count to SR users and ensure focus isn't lost
|
|
174
|
+
if (isWeb) {
|
|
175
|
+
const isFocusInToast = (node as HTMLDivElement)?.contains(document.activeElement)
|
|
176
|
+
if (isFocusInToast) context.viewport?.focus()
|
|
177
|
+
}
|
|
174
178
|
onClose()
|
|
175
179
|
})
|
|
176
180
|
|
|
@@ -318,7 +322,6 @@ const ToastImpl = React.forwardRef<TamaguiElement, ToastImplProps>(
|
|
|
318
322
|
key={props.id}
|
|
319
323
|
scope={__scopeToast}
|
|
320
324
|
onClose={() => {
|
|
321
|
-
console.log('hellooow')
|
|
322
325
|
handleClose()
|
|
323
326
|
}}
|
|
324
327
|
>
|
package/src/ToastViewport.tsx
CHANGED
|
@@ -56,6 +56,10 @@ type ToastViewportProps = ToastViewportFrameProps & {
|
|
|
56
56
|
* Used to reference the viewport if you want to have multiple viewports in the same provider.
|
|
57
57
|
*/
|
|
58
58
|
name?: string
|
|
59
|
+
/**
|
|
60
|
+
* Pass this when you want to have multiple/duplicated toasts.
|
|
61
|
+
*/
|
|
62
|
+
multipleToasts?: boolean
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
const ToastViewport = React.forwardRef<HTMLDivElement, ToastViewportProps>(
|
|
@@ -65,6 +69,7 @@ const ToastViewport = React.forwardRef<HTMLDivElement, ToastViewportProps>(
|
|
|
65
69
|
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
66
70
|
label = 'Notifications ({hotkey})',
|
|
67
71
|
name,
|
|
72
|
+
multipleToasts,
|
|
68
73
|
...viewportProps
|
|
69
74
|
} = props
|
|
70
75
|
const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast)
|
|
@@ -243,8 +248,11 @@ const ToastViewport = React.forwardRef<HTMLDivElement, ToastViewportProps>(
|
|
|
243
248
|
<Collection.Slot scope={__scopeToast}>
|
|
244
249
|
<ToastViewportFrame ref={composedRefs} {...viewportProps}>
|
|
245
250
|
<PortalHost
|
|
246
|
-
|
|
247
|
-
|
|
251
|
+
render={(children) => (
|
|
252
|
+
<AnimatePresence exitBeforeEnter={!multipleToasts}>
|
|
253
|
+
{children}
|
|
254
|
+
</AnimatePresence>
|
|
255
|
+
)}
|
|
248
256
|
name={name ?? 'default'}
|
|
249
257
|
/>
|
|
250
258
|
</ToastViewportFrame>
|
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseToastOptions as BurntToastOptions } from 'burnt/build/types'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import {
|
|
4
|
+
CreateNativeToastsFn,
|
|
5
|
+
HideNativeToastsFn
|
|
6
|
+
} from './types'
|
|
7
|
+
|
|
8
|
+
export const createNativeToast: CreateNativeToastsFn = (
|
|
4
9
|
title,
|
|
5
|
-
{ message, duration,
|
|
10
|
+
{ message, duration, burntOptions }
|
|
6
11
|
) => {
|
|
7
12
|
// import inline to allow lazy usage of native dependecy:
|
|
8
|
-
const Burnt = require('burnt')
|
|
13
|
+
const Burnt: { toast: (options: BurntToastOptions) => any } = require('burnt')
|
|
9
14
|
|
|
10
15
|
Burnt.toast({
|
|
11
16
|
title,
|
|
12
|
-
message
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
message,
|
|
18
|
+
duration: duration ? duration * 1000 : undefined,
|
|
19
|
+
...burntOptions,
|
|
15
20
|
})
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const hideNativeToast: HideNativeToastsFn = () => {
|
|
25
|
+
const Burnt: { dismissAllAlerts: () => any } = require('burnt')
|
|
26
|
+
Burnt.dismissAllAlerts()
|
|
16
27
|
}
|
|
@@ -1,25 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateNativeToastsFn, HideNativeToastsFn } from './types'
|
|
2
2
|
|
|
3
|
-
export const createNativeToast:
|
|
3
|
+
export const createNativeToast: CreateNativeToastsFn = (
|
|
4
|
+
title,
|
|
5
|
+
{ message, notificationOptions }
|
|
6
|
+
) => {
|
|
4
7
|
if (!('Notification' in window)) {
|
|
5
|
-
|
|
8
|
+
console.error('This browser does not support notifications')
|
|
9
|
+
return false
|
|
6
10
|
}
|
|
7
11
|
|
|
8
|
-
if (Notification.permission === 'denied')
|
|
9
|
-
|
|
12
|
+
if (Notification.permission === 'denied') false
|
|
10
13
|
const showNotification = () => {
|
|
11
|
-
new Notification(title, {
|
|
14
|
+
const notification = new Notification(title, {
|
|
12
15
|
body: message,
|
|
16
|
+
...notificationOptions,
|
|
13
17
|
})
|
|
18
|
+
|
|
19
|
+
return notification
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
if (Notification.permission === 'granted') {
|
|
17
|
-
showNotification()
|
|
23
|
+
const notification = showNotification()
|
|
24
|
+
return {
|
|
25
|
+
nativeToastRef: notification,
|
|
26
|
+
}
|
|
18
27
|
} else {
|
|
19
28
|
Notification.requestPermission().then((permission) => {
|
|
20
29
|
if (permission === 'granted') {
|
|
21
|
-
showNotification()
|
|
30
|
+
const notification = showNotification()
|
|
31
|
+
return {
|
|
32
|
+
nativeToastRef: notification,
|
|
33
|
+
}
|
|
22
34
|
}
|
|
23
35
|
})
|
|
24
36
|
}
|
|
37
|
+
return true
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const hideNativeToast: HideNativeToastsFn = (ref) => {
|
|
41
|
+
if (!('Notification' in window)) {
|
|
42
|
+
console.error('This browser does not support notifications')
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (ref) {
|
|
47
|
+
ref.close()
|
|
48
|
+
}
|
|
25
49
|
}
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,21 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseToastOptions as BurntToastOptions } from 'burnt/build/types'
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface CreateNativeToastOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Body of the toast
|
|
6
6
|
*/
|
|
7
7
|
message?: BurntToastOptions['message']
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Duration of toast in ms
|
|
10
|
+
*
|
|
11
|
+
* @example 1000
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
duration?: BurntToastOptions['duration']
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
15
|
+
* Options for the burnt package if you're using native toasts on mobile
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>
|
|
18
|
+
/**
|
|
19
|
+
* Options for the notification API if you're using native toasts on web
|
|
20
|
+
*/
|
|
21
|
+
notificationOptions?: NotificationOptions
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NativeToastRef {
|
|
25
|
+
/**
|
|
26
|
+
* Used to close web notifications
|
|
27
|
+
*/
|
|
28
|
+
close: () => void
|
|
16
29
|
}
|
|
17
30
|
|
|
18
|
-
export type
|
|
31
|
+
export type CreateNativeToastsFn = (
|
|
19
32
|
title: string,
|
|
20
|
-
options:
|
|
21
|
-
) =>
|
|
33
|
+
options: CreateNativeToastOptions
|
|
34
|
+
) =>
|
|
35
|
+
| {
|
|
36
|
+
nativeToastRef?: NativeToastRef
|
|
37
|
+
}
|
|
38
|
+
| boolean
|
|
39
|
+
|
|
40
|
+
export type HideNativeToastsFn = (ref?: NativeToastRef) => void
|
|
41
|
+
|
|
42
|
+
export type ToastNativePlatform = 'web' | 'mobile' | 'android' | 'ios'
|
|
43
|
+
export type ToastNativeValue = boolean | ToastNativePlatform | ToastNativePlatform[]
|
package/types/Toast.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GetProps, TamaguiElement } from '@tamagui/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { createToast } from './createToast';
|
|
4
3
|
import { ToastProps } from './ToastImpl';
|
|
5
4
|
import { ToastProvider, ToastProviderProps, createToastScope } from './ToastProvider';
|
|
6
5
|
import { ToastViewport, ToastViewportProps } from './ToastViewport';
|
|
@@ -433,6 +432,6 @@ declare const Toast: ((props: Omit<ToastProps & React.RefAttributes<TamaguiEleme
|
|
|
433
432
|
[x: string]: undefined;
|
|
434
433
|
}>>, "ref">) & React.RefAttributes<TamaguiElement>>;
|
|
435
434
|
};
|
|
436
|
-
export { Toast, ToastProvider, ToastViewport,
|
|
435
|
+
export { Toast, ToastProvider, ToastViewport, createToastScope, };
|
|
437
436
|
export type { ToastActionProps, ToastCloseProps, ToastDescriptionProps, ToastProps, ToastProviderProps, ToastTitleProps, ToastViewportProps, };
|
|
438
437
|
//# sourceMappingURL=Toast.d.ts.map
|
package/types/Toast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,cAAc,EAOf,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,cAAc,EAOf,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAGL,UAAU,EAEX,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAQnE,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;GAanB,CAAA;AACF,KAAK,iBAAiB,GAAG,QAAQ,CAAC,OAAO,eAAe,CAAC,CAAA;AACzD,KAAK,eAAe,GAAG,iBAAiB,GAAG,EAAE,CAAA;AAiB7C,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;GAazB,CAAA;AACF,KAAK,0BAA0B,GAAG,QAAQ,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACxE,KAAK,qBAAqB,GAAG,0BAA0B,GAAG,EAAE,CAAA;AAiB5D,KAAK,gBAAgB,GAAG,eAAe,GAAG;IACxC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AA+BD,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGnB,CAAA;AACF,KAAK,oBAAoB,GAAG,QAAQ,CAAC,OAAO,eAAe,CAAC,CAAA;AAC5D,KAAK,eAAe,GAAG,oBAAoB,GAAG,EAAE,CAAA;AA6DhD,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAxGT;;;;;WAKG;iBACM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QANf;;;;;WAKG;iBACM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0GhB,CAAA;AAID,OAAO,EACL,KAAK,EACL,aAAa,EACb,aAAa,EAEb,gBAAgB,GACjB,CAAA;AACD,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,kBAAkB,GACnB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Scope } from '@tamagui/create-context';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CreateNativeToastOptions, ToastNativePlatform, ToastNativeValue } from './types';
|
|
4
|
+
interface ToastImperativeOptions extends Omit<CreateNativeToastOptions, "message"> {
|
|
5
|
+
/**
|
|
6
|
+
* Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.
|
|
7
|
+
*/
|
|
8
|
+
native?: ToastNativeValue;
|
|
9
|
+
}
|
|
10
|
+
interface ShowToastOptions extends CreateNativeToastOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Used when need custom data
|
|
13
|
+
*/
|
|
14
|
+
additionalInfo?: Record<string, any>;
|
|
15
|
+
/**
|
|
16
|
+
* Overrides the native option on `ToastImperativeProvider`
|
|
17
|
+
*/
|
|
18
|
+
native?: ToastNativeValue;
|
|
19
|
+
}
|
|
20
|
+
type ScopedProps<P> = P & {
|
|
21
|
+
__scopeToast?: Scope;
|
|
22
|
+
};
|
|
23
|
+
type ToastData = {
|
|
24
|
+
title: string;
|
|
25
|
+
id: string;
|
|
26
|
+
} & CreateNativeToastOptions & {
|
|
27
|
+
isHandledNatively: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare const useToast: () => {
|
|
30
|
+
/**
|
|
31
|
+
* The currently displaying toast
|
|
32
|
+
*/
|
|
33
|
+
currentToast: ToastData | null;
|
|
34
|
+
/**
|
|
35
|
+
* Call it to show a new toast. If you're using native toasts, you can pass native options using \`burntOptions\` or \`notificationOptions\` depending on the native platform (mobile/web).
|
|
36
|
+
*/
|
|
37
|
+
show: (title: string, options?: ShowToastOptions) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Call it to hide the currently displayed toast.
|
|
40
|
+
*
|
|
41
|
+
* _NOTE_: does not work on Android native toasts
|
|
42
|
+
*
|
|
43
|
+
* _NOTE_: hides the last toast on web notification toasts
|
|
44
|
+
*/
|
|
45
|
+
hide: () => void;
|
|
46
|
+
};
|
|
47
|
+
interface ToastImperativeProviderProps {
|
|
48
|
+
children: React.ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Used to provide defaults to imperative API. Options can be overwritten when calling `show()`.
|
|
51
|
+
*/
|
|
52
|
+
options: ToastImperativeOptions;
|
|
53
|
+
}
|
|
54
|
+
declare const ToastImperativeProvider: ({ children, options, __scopeToast, }: ScopedProps<ToastImperativeProviderProps>) => JSX.Element;
|
|
55
|
+
export { ToastImperativeProvider, useToast };
|
|
56
|
+
export type { ToastImperativeProviderProps, ToastNativePlatform, ToastNativeValue };
|
|
57
|
+
//# sourceMappingURL=ToastImperative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastImperative.d.ts","sourceRoot":"","sources":["../src/ToastImperative.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAsB,MAAM,yBAAyB,CAAA;AACnE,OAAO,KAAiB,MAAM,OAAO,CAAA;AAIrC,OAAO,EACL,wBAAwB,EAExB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAEhB,UAAU,sBAAuB,SAAQ,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC;IAChF;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAA;CAC1B;AACD,UAAU,gBAAiB,SAAQ,wBAAwB;IACzD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAA;CAC1B;AACD,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,KAAK,CAAA;CAAE,CAAA;AAElD,KAAK,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,wBAAwB,GAAG;IACxE,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAAA;AAgBH,QAAA,MAAM,QAAQ;IAIV;;OAEG;;IAEH;;OAEG;kBArBc,MAAM,YAAY,gBAAgB,KAAK,OAAO;IAuB/D;;;;;;OAMG;gBA5BY,IAAI;CA+BtB,CAAA;AAED,UAAU,4BAA4B;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;OAEG;IACH,OAAO,EAAE,sBAAsB,CAAA;CAChC;AACD,QAAA,MAAM,uBAAuB,yCAI1B,YAAY,4BAA4B,CAAC,gBA+D3C,CAAA;AAED,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,CAAA;AAC5C,YAAY,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,CAAA"}
|
package/types/ToastImpl.d.ts
CHANGED
|
@@ -158,6 +158,10 @@ type ToastImplProps = ToastImplPrivateProps & ToastImplFrameProps & {
|
|
|
158
158
|
* @default "default"
|
|
159
159
|
*/
|
|
160
160
|
viewportName?: string;
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
id?: string;
|
|
161
165
|
};
|
|
162
166
|
declare const ToastImpl: React.ForwardRefExoticComponent<ToastImplPrivateProps & Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{
|
|
163
167
|
readonly fullscreen?: boolean | undefined;
|
|
@@ -261,6 +265,10 @@ declare const ToastImpl: React.ForwardRefExoticComponent<ToastImplPrivateProps &
|
|
|
261
265
|
* @default "default"
|
|
262
266
|
*/
|
|
263
267
|
viewportName?: string | undefined;
|
|
268
|
+
/**
|
|
269
|
+
*
|
|
270
|
+
*/
|
|
271
|
+
id?: string | undefined;
|
|
264
272
|
} & React.RefAttributes<TamaguiElement>>;
|
|
265
273
|
export { ToastImpl, ToastImplFrame, ToastImplProps, useToastInteractiveContext };
|
|
266
274
|
export type { ToastProps };
|
package/types/ToastImpl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastImpl.d.ts","sourceRoot":"","sources":["../src/ToastImpl.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,cAAc,EAQf,MAAM,eAAe,CAAA;AACtB,OAAO,EAAe,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGpE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAY,qBAAqB,EAAgB,MAAM,cAAc,CAAA;AAa5E,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBlB,CAAA;AACF,UAAU,UAAW,SAAQ,IAAI,CAAC,cAAc,EAAE,MAAM,qBAAqB,CAAC;IAC5E;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAA;CAClB;AAED,KAAK,UAAU,GAAG,qBAAqB,CAAA;AAEvC,QAAA,MAAiC,0BAA0B;;;;;;;;;CAK1D,CAAA;AAED,KAAK,qBAAqB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,IAAI,IAAI,CAAA;CAAE,CAAA;AAC/D,KAAK,mBAAmB,GAAG,QAAQ,CAAC,OAAO,cAAc,CAAC,CAAA;AAC1D,KAAK,cAAc,GAAG,qBAAqB,GACzC,mBAAmB,GAAG;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,CAAA;IAClC;;OAEG;IACH,QAAQ,CA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;OAEG;yBACkB,UAAU,GAAG,IAAI;IACtC;;OAEG;wBACiB,UAAU,GAAG,IAAI;IACrC;;OAEG;0BACmB,UAAU,GAAG,IAAI;IACvC;;OAEG;uBACgB,UAAU,GAAG,IAAI;IACpC;;;;OAIG;;IAEH;;OAEG;;wCAoPN,CAAA;AA6DD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,0BAA0B,EAAE,CAAA;AAChF,YAAY,EAAE,UAAU,EAAE,CAAA"}
|
package/types/ToastViewport.d.ts
CHANGED
|
@@ -53,6 +53,10 @@ type ToastViewportProps = ToastViewportFrameProps & {
|
|
|
53
53
|
* Used to reference the viewport if you want to have multiple viewports in the same provider.
|
|
54
54
|
*/
|
|
55
55
|
name?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Pass this when you want to have multiple/duplicated toasts.
|
|
58
|
+
*/
|
|
59
|
+
multipleToasts?: boolean;
|
|
56
60
|
};
|
|
57
61
|
declare const ToastViewport: React.ForwardRefExoticComponent<((Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
58
62
|
readonly fullscreen?: boolean | undefined;
|
|
@@ -79,6 +83,10 @@ declare const ToastViewport: React.ForwardRefExoticComponent<((Omit<import("reac
|
|
|
79
83
|
* Used to reference the viewport if you want to have multiple viewports in the same provider.
|
|
80
84
|
*/
|
|
81
85
|
name?: string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Pass this when you want to have multiple/duplicated toasts.
|
|
88
|
+
*/
|
|
89
|
+
multipleToasts?: boolean | undefined;
|
|
82
90
|
}) | Omit<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{
|
|
83
91
|
readonly fullscreen?: boolean | undefined;
|
|
84
92
|
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
@@ -110,6 +118,10 @@ declare const ToastViewport: React.ForwardRefExoticComponent<((Omit<import("reac
|
|
|
110
118
|
* Used to reference the viewport if you want to have multiple viewports in the same provider.
|
|
111
119
|
*/
|
|
112
120
|
name?: string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Pass this when you want to have multiple/duplicated toasts.
|
|
123
|
+
*/
|
|
124
|
+
multipleToasts?: boolean | undefined;
|
|
113
125
|
}, "ref">) & React.RefAttributes<HTMLDivElement>>;
|
|
114
126
|
export { ToastViewport, ToastViewportProps, VIEWPORT_DEFAULT_HOTKEY, VIEWPORT_PAUSE, VIEWPORT_RESUME, };
|
|
115
127
|
//# sourceMappingURL=ToastViewport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastViewport.d.ts","sourceRoot":"","sources":["../src/ToastViewport.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAiB,MAAM,eAAe,CAAA;AAIvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,QAAA,MAAM,uBAAuB,UAAS,CAAA;AACtC,QAAA,MAAM,cAAc,wBAAwB,CAAA;AAC5C,QAAA,MAAM,eAAe,yBAAyB,CAAA;AAgB9C,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMtB,CAAA;AACF,KAAK,uBAAuB,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|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const createNativeToast:
|
|
1
|
+
import { CreateNativeToastsFn, HideNativeToastsFn } from './types';
|
|
2
|
+
export declare const createNativeToast: CreateNativeToastsFn;
|
|
3
|
+
export declare const hideNativeToast: HideNativeToastsFn;
|
|
3
4
|
//# sourceMappingURL=createNativeToast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNativeToast.d.ts","sourceRoot":"","sources":["../src/createNativeToast.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"createNativeToast.d.ts","sourceRoot":"","sources":["../src/createNativeToast.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAElE,eAAO,MAAM,iBAAiB,EAAE,oBAmC/B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,kBAS7B,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const createNativeToast:
|
|
1
|
+
import { CreateNativeToastsFn, HideNativeToastsFn } from './types';
|
|
2
|
+
export declare const createNativeToast: CreateNativeToastsFn;
|
|
3
|
+
export declare const hideNativeToast: HideNativeToastsFn;
|
|
3
4
|
//# sourceMappingURL=createNativeToast.native.d.ts.map
|