@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNativeToast.native.d.ts","sourceRoot":"","sources":["../src/createNativeToast.native.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createNativeToast.native.d.ts","sourceRoot":"","sources":["../src/createNativeToast.native.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,iBAAiB,EAAE,oBAc/B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,kBAG7B,CAAA"}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA"}
|
package/types/types.d.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
1
|
+
import { BaseToastOptions as BurntToastOptions } from 'burnt/build/types';
|
|
2
|
+
export interface CreateNativeToastOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Body of the toast
|
|
5
5
|
*/
|
|
6
6
|
message?: BurntToastOptions['message'];
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Duration of toast in ms
|
|
9
|
+
*
|
|
10
|
+
* @example 1000
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
duration?: BurntToastOptions['duration'];
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* Options for the burnt package if you're using native toasts on mobile
|
|
13
15
|
*/
|
|
14
|
-
|
|
16
|
+
burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>;
|
|
17
|
+
/**
|
|
18
|
+
* Options for the notification API if you're using native toasts on web
|
|
19
|
+
*/
|
|
20
|
+
notificationOptions?: NotificationOptions;
|
|
21
|
+
}
|
|
22
|
+
export interface NativeToastRef {
|
|
23
|
+
/**
|
|
24
|
+
* Used to close web notifications
|
|
25
|
+
*/
|
|
26
|
+
close: () => void;
|
|
15
27
|
}
|
|
16
|
-
export type
|
|
28
|
+
export type CreateNativeToastsFn = (title: string, options: CreateNativeToastOptions) => {
|
|
29
|
+
nativeToastRef?: NativeToastRef;
|
|
30
|
+
} | boolean;
|
|
31
|
+
export type HideNativeToastsFn = (ref?: NativeToastRef) => void;
|
|
32
|
+
export type ToastNativePlatform = 'web' | 'mobile' | 'android' | 'ios';
|
|
33
|
+
export type ToastNativeValue = boolean | ToastNativePlatform | ToastNativePlatform[];
|
|
17
34
|
//# sourceMappingURL=types.d.ts.map
|
package/types/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAEzE,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;IACtC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACxC;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC,CAAA;IACxE;;OAEG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;CAC1C;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,MAAM,MAAM,oBAAoB,GAAG,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,wBAAwB,KAE/B;IACE,cAAc,CAAC,EAAE,cAAc,CAAA;CAChC,GACD,OAAO,CAAA;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;AAE/D,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAA;AACtE,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,mBAAmB,GAAG,mBAAmB,EAAE,CAAA"}
|
package/src/createToast.tsx
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { isWeb } from '@tamagui/core'
|
|
2
|
-
import { Scope, createContextScope } from '@tamagui/create-context'
|
|
3
|
-
import React, { useRef } from 'react'
|
|
4
|
-
|
|
5
|
-
import { createNativeToast } from './createNativeToast'
|
|
6
|
-
import { CreateNativeToastsOptions, CreateNativeToastsOptionsFn } from './types'
|
|
7
|
-
|
|
8
|
-
type NativeValue = boolean | 'web' | 'mobile'
|
|
9
|
-
interface CreateToastOptions {
|
|
10
|
-
/**
|
|
11
|
-
* 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`.
|
|
12
|
-
*/
|
|
13
|
-
native?: NativeValue
|
|
14
|
-
}
|
|
15
|
-
interface ToastOptions extends CreateNativeToastsOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Used when need custom data
|
|
18
|
-
*/
|
|
19
|
-
additionalInfo?: Record<string, any>
|
|
20
|
-
/**
|
|
21
|
-
* Overrides the native option on `createToast()`
|
|
22
|
-
*/
|
|
23
|
-
native?: NativeValue
|
|
24
|
-
}
|
|
25
|
-
type ScopedProps<P> = P & { __scopeToast?: Scope }
|
|
26
|
-
|
|
27
|
-
type ToastData = { title: string; id: string } & CreateNativeToastsOptions
|
|
28
|
-
|
|
29
|
-
interface ImperativeToastContextValue {
|
|
30
|
-
currentToast: ToastData | null
|
|
31
|
-
addToast: CreateNativeToastsOptionsFn
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const [createImperativeToastContext, createImperativeToastScope] =
|
|
35
|
-
createContextScope('ImperativeToast')
|
|
36
|
-
|
|
37
|
-
const [ImperativeToastProvider, useToastProviderContext] =
|
|
38
|
-
createImperativeToastContext<ImperativeToastContextValue>('ImperativeToastProvider')
|
|
39
|
-
|
|
40
|
-
const createToast = (options = {} as CreateToastOptions) => {
|
|
41
|
-
return {
|
|
42
|
-
ImperativeToastProvider: ({
|
|
43
|
-
__scopeToast,
|
|
44
|
-
children,
|
|
45
|
-
}: ScopedProps<{ children: React.ReactNode }>) => {
|
|
46
|
-
const counterRef = useRef(0)
|
|
47
|
-
const [toast, setToast] =
|
|
48
|
-
React.useState<ImperativeToastContextValue['currentToast']>(null)
|
|
49
|
-
const addToast = React.useCallback<CreateNativeToastsOptionsFn>(
|
|
50
|
-
(title, options) => {
|
|
51
|
-
counterRef.current++
|
|
52
|
-
setToast({ title, id: counterRef.current.toString(), ...options })
|
|
53
|
-
},
|
|
54
|
-
[setToast]
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<ImperativeToastProvider
|
|
59
|
-
scope={__scopeToast}
|
|
60
|
-
addToast={addToast}
|
|
61
|
-
currentToast={toast}
|
|
62
|
-
>
|
|
63
|
-
{children}
|
|
64
|
-
</ImperativeToastProvider>
|
|
65
|
-
)
|
|
66
|
-
},
|
|
67
|
-
useToast: () => {
|
|
68
|
-
const context = useToastProviderContext('useToast', undefined)
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
/**
|
|
72
|
-
* The toast to get and show if not using native
|
|
73
|
-
*/
|
|
74
|
-
currentToast: context.currentToast,
|
|
75
|
-
show(title: string, showOptions?: ToastOptions) {
|
|
76
|
-
const native = showOptions?.native || options.native
|
|
77
|
-
if (
|
|
78
|
-
native === true ||
|
|
79
|
-
(Array.isArray(options.native) &&
|
|
80
|
-
((isWeb && options.native.includes('web')) ||
|
|
81
|
-
(!isWeb && options.native.includes('mobile'))))
|
|
82
|
-
) {
|
|
83
|
-
return createNativeToast(title, showOptions ?? {})
|
|
84
|
-
}
|
|
85
|
-
context.addToast(title, showOptions ?? {})
|
|
86
|
-
},
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { createToast }
|
|
93
|
-
export type { CreateToastOptions }
|
package/types/createToast.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Scope } from '@tamagui/create-context';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { CreateNativeToastsOptions } from './types';
|
|
4
|
-
type NativeValue = boolean | 'web' | 'mobile';
|
|
5
|
-
interface CreateToastOptions {
|
|
6
|
-
/**
|
|
7
|
-
* 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`.
|
|
8
|
-
*/
|
|
9
|
-
native?: NativeValue;
|
|
10
|
-
}
|
|
11
|
-
interface ToastOptions extends CreateNativeToastsOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Used when need custom data
|
|
14
|
-
*/
|
|
15
|
-
additionalInfo?: Record<string, any>;
|
|
16
|
-
/**
|
|
17
|
-
* Overrides the native option on `createToast()`
|
|
18
|
-
*/
|
|
19
|
-
native?: NativeValue;
|
|
20
|
-
}
|
|
21
|
-
type ScopedProps<P> = P & {
|
|
22
|
-
__scopeToast?: Scope;
|
|
23
|
-
};
|
|
24
|
-
type ToastData = {
|
|
25
|
-
title: string;
|
|
26
|
-
id: string;
|
|
27
|
-
} & CreateNativeToastsOptions;
|
|
28
|
-
declare const createToast: (options?: CreateToastOptions) => {
|
|
29
|
-
ImperativeToastProvider: ({ __scopeToast, children, }: ScopedProps<{
|
|
30
|
-
children: React.ReactNode;
|
|
31
|
-
}>) => JSX.Element;
|
|
32
|
-
useToast: () => {
|
|
33
|
-
/**
|
|
34
|
-
* The toast to get and show if not using native
|
|
35
|
-
*/
|
|
36
|
-
currentToast: ToastData | null;
|
|
37
|
-
show(title: string, showOptions?: ToastOptions): void;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export { createToast };
|
|
41
|
-
export type { CreateToastOptions };
|
|
42
|
-
//# sourceMappingURL=createToast.d.ts.map
|