@tamagui/toast 1.76.0 → 1.77.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.js +9 -12
- package/dist/cjs/Toast.js.map +1 -1
- package/dist/cjs/Toast.native.js +9 -12
- package/dist/cjs/Toast.native.js.map +1 -1
- package/dist/cjs/ToastImpl.js.map +1 -1
- package/dist/cjs/ToastImpl.native.js.map +1 -1
- package/dist/esm/Toast.js +9 -13
- package/dist/esm/Toast.js.map +1 -1
- package/dist/esm/Toast.native.js +9 -13
- package/dist/esm/Toast.native.js.map +1 -1
- package/dist/esm/ToastImpl.js.map +1 -1
- package/dist/esm/ToastImpl.native.js.map +1 -1
- package/dist/jsx/Toast.js +9 -13
- package/dist/jsx/Toast.js.map +1 -1
- package/dist/jsx/Toast.native.js +9 -13
- package/dist/jsx/Toast.native.js.map +1 -1
- package/dist/jsx/ToastImpl.js.map +1 -1
- package/dist/jsx/ToastImpl.native.js.map +1 -1
- package/package.json +14 -14
- package/src/Toast.tsx +11 -13
- package/src/ToastImpl.tsx +76 -66
- package/types/Toast.d.ts +536 -3
- package/types/Toast.d.ts.map +1 -1
- package/types/ToastImpl.d.ts +12 -12
- package/types/ToastImpl.d.ts.map +1 -1
package/src/Toast.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
TamaguiElement,
|
|
6
6
|
composeEventHandlers,
|
|
7
7
|
styled,
|
|
8
|
-
themeable,
|
|
9
8
|
useEvent,
|
|
10
9
|
withStaticProperties,
|
|
11
10
|
} from '@tamagui/core'
|
|
@@ -23,6 +22,7 @@ import {
|
|
|
23
22
|
useToastState,
|
|
24
23
|
} from './ToastImperative'
|
|
25
24
|
import {
|
|
25
|
+
ToastExtraProps,
|
|
26
26
|
ToastImpl,
|
|
27
27
|
ToastImplFrame,
|
|
28
28
|
ToastProps,
|
|
@@ -134,6 +134,7 @@ const ToastCloseFrame = styled(ThemeableStack, {
|
|
|
134
134
|
name: CLOSE_NAME,
|
|
135
135
|
tag: 'button',
|
|
136
136
|
})
|
|
137
|
+
|
|
137
138
|
type ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>
|
|
138
139
|
type ToastCloseProps = ToastCloseFrameProps & {}
|
|
139
140
|
|
|
@@ -161,8 +162,8 @@ ToastClose.displayName = CLOSE_NAME
|
|
|
161
162
|
* Toast
|
|
162
163
|
* -----------------------------------------------------------------------------------------------*/
|
|
163
164
|
|
|
164
|
-
const ToastComponent =
|
|
165
|
-
|
|
165
|
+
const ToastComponent = ToastImplFrame.styleable<ToastExtraProps>(
|
|
166
|
+
(props, forwardedRef) => {
|
|
166
167
|
const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props
|
|
167
168
|
const [open, setOpen] = useControllableState({
|
|
168
169
|
prop: openProp,
|
|
@@ -192,20 +193,17 @@ const ToastComponent = React.forwardRef<TamaguiElement, ScopedProps<ToastProps>>
|
|
|
192
193
|
})}
|
|
193
194
|
/>
|
|
194
195
|
)
|
|
195
|
-
}
|
|
196
|
+
}
|
|
196
197
|
)
|
|
197
198
|
|
|
198
199
|
ToastComponent.displayName = TOAST_NAME
|
|
199
200
|
|
|
200
|
-
const Toast = withStaticProperties(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
Close: ToastClose,
|
|
207
|
-
}
|
|
208
|
-
)
|
|
201
|
+
const Toast = withStaticProperties(ToastComponent, {
|
|
202
|
+
Title: ToastTitle,
|
|
203
|
+
Description: ToastDescription,
|
|
204
|
+
Action: ToastAction,
|
|
205
|
+
Close: ToastClose,
|
|
206
|
+
})
|
|
209
207
|
|
|
210
208
|
/* ---------------------------------------------------------------------------------------------- */
|
|
211
209
|
|
package/src/ToastImpl.tsx
CHANGED
|
@@ -36,6 +36,7 @@ import { VIEWPORT_PAUSE, VIEWPORT_RESUME } from './ToastViewport'
|
|
|
36
36
|
const ToastImplFrame = styled(ThemeableStack, {
|
|
37
37
|
name: 'ToastImpl',
|
|
38
38
|
focusable: true,
|
|
39
|
+
|
|
39
40
|
variants: {
|
|
40
41
|
unstyled: {
|
|
41
42
|
false: {
|
|
@@ -53,15 +54,36 @@ const ToastImplFrame = styled(ThemeableStack, {
|
|
|
53
54
|
},
|
|
54
55
|
},
|
|
55
56
|
} as const,
|
|
57
|
+
|
|
56
58
|
defaultVariants: {
|
|
57
59
|
unstyled: process.env.TAMAGUI_HEADLESS === '1' ? true : false,
|
|
58
60
|
},
|
|
59
61
|
})
|
|
60
|
-
|
|
62
|
+
|
|
63
|
+
type ToastProps = Omit<ToastImplProps, keyof ToastImplPrivateProps>
|
|
64
|
+
|
|
65
|
+
type SwipeEvent = GestureResponderEvent
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
Provider: ToastInteractiveProvider,
|
|
69
|
+
useStyledContext: useToastInteractiveContext,
|
|
70
|
+
} = createStyledContext({
|
|
71
|
+
onClose() {},
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
type ToastImplPrivateProps = {
|
|
75
|
+
open?: boolean
|
|
76
|
+
onClose(): void
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type ToastImplFrameProps = GetProps<typeof ToastImplFrame>
|
|
80
|
+
|
|
81
|
+
export type ToastExtraProps = {
|
|
61
82
|
/**
|
|
62
83
|
* The controlled open state of the dialog. Must be used in conjunction with `onOpenChange`.
|
|
63
84
|
*/
|
|
64
85
|
open?: boolean
|
|
86
|
+
|
|
65
87
|
/**
|
|
66
88
|
* The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
|
|
67
89
|
*/
|
|
@@ -75,73 +97,61 @@ interface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {
|
|
|
75
97
|
* controlling animation with React animation libraries.
|
|
76
98
|
*/
|
|
77
99
|
forceMount?: true
|
|
78
|
-
}
|
|
79
100
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Control the sensitivity of the toast for accessibility purposes.
|
|
103
|
+
* For toasts that are the result of a user action, choose foreground. Toasts generated from background tasks should use background.
|
|
104
|
+
*/
|
|
105
|
+
type?: 'foreground' | 'background'
|
|
106
|
+
/**
|
|
107
|
+
* Time in milliseconds that toast should remain visible for. Overrides value given to `ToastProvider`.
|
|
108
|
+
*/
|
|
109
|
+
duration?: number
|
|
110
|
+
/**
|
|
111
|
+
* Event handler called when the escape key is down. It can be prevented by calling `event.preventDefault`.
|
|
112
|
+
*/
|
|
113
|
+
onEscapeKeyDown?: DismissableProps['onEscapeKeyDown']
|
|
114
|
+
/**
|
|
115
|
+
* Event handler called when the dismiss timer is paused.
|
|
116
|
+
* On web, this occurs when the pointer is moved over the viewport, the viewport is focused or when the window is blurred.
|
|
117
|
+
* On mobile, this occurs when the toast is touched.
|
|
118
|
+
*/
|
|
119
|
+
onPause?(): void
|
|
120
|
+
/**
|
|
121
|
+
* Event handler called when the dismiss timer is resumed.
|
|
122
|
+
* On web, this occurs when the pointer is moved away from the viewport, the viewport is blurred or when the window is focused.
|
|
123
|
+
* On mobile, this occurs when the toast is released.
|
|
124
|
+
*/
|
|
125
|
+
onResume?(): void
|
|
126
|
+
/**
|
|
127
|
+
* Event handler called when starting a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
128
|
+
*/
|
|
129
|
+
onSwipeStart?(event: SwipeEvent): void
|
|
130
|
+
/**
|
|
131
|
+
* Event handler called during a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
132
|
+
*/
|
|
133
|
+
onSwipeMove?(event: SwipeEvent): void
|
|
134
|
+
/**
|
|
135
|
+
* Event handler called at the cancellation of a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
136
|
+
*/
|
|
137
|
+
onSwipeCancel?(event: SwipeEvent): void
|
|
138
|
+
/**
|
|
139
|
+
* Event handler called at the end of a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
140
|
+
*/
|
|
141
|
+
onSwipeEnd?(event: SwipeEvent): void
|
|
142
|
+
/**
|
|
143
|
+
* The viewport's name to send the toast to. Used when using multiple viewports and want to forward toasts to different ones.
|
|
144
|
+
*
|
|
145
|
+
* @default "default"
|
|
146
|
+
*/
|
|
147
|
+
viewportName?: string
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
id?: string
|
|
152
|
+
}
|
|
88
153
|
|
|
89
|
-
type
|
|
90
|
-
type ToastImplFrameProps = GetProps<typeof ToastImplFrame>
|
|
91
|
-
type ToastImplProps = ToastImplPrivateProps &
|
|
92
|
-
ToastImplFrameProps & {
|
|
93
|
-
/**
|
|
94
|
-
* Control the sensitivity of the toast for accessibility purposes.
|
|
95
|
-
* For toasts that are the result of a user action, choose foreground. Toasts generated from background tasks should use background.
|
|
96
|
-
*/
|
|
97
|
-
type?: 'foreground' | 'background'
|
|
98
|
-
/**
|
|
99
|
-
* Time in milliseconds that toast should remain visible for. Overrides value given to `ToastProvider`.
|
|
100
|
-
*/
|
|
101
|
-
duration?: number
|
|
102
|
-
/**
|
|
103
|
-
* Event handler called when the escape key is down. It can be prevented by calling `event.preventDefault`.
|
|
104
|
-
*/
|
|
105
|
-
onEscapeKeyDown?: DismissableProps['onEscapeKeyDown']
|
|
106
|
-
/**
|
|
107
|
-
* Event handler called when the dismiss timer is paused.
|
|
108
|
-
* On web, this occurs when the pointer is moved over the viewport, the viewport is focused or when the window is blurred.
|
|
109
|
-
* On mobile, this occurs when the toast is touched.
|
|
110
|
-
*/
|
|
111
|
-
onPause?(): void
|
|
112
|
-
/**
|
|
113
|
-
* Event handler called when the dismiss timer is resumed.
|
|
114
|
-
* On web, this occurs when the pointer is moved away from the viewport, the viewport is blurred or when the window is focused.
|
|
115
|
-
* On mobile, this occurs when the toast is released.
|
|
116
|
-
*/
|
|
117
|
-
onResume?(): void
|
|
118
|
-
/**
|
|
119
|
-
* Event handler called when starting a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
120
|
-
*/
|
|
121
|
-
onSwipeStart?(event: SwipeEvent): void
|
|
122
|
-
/**
|
|
123
|
-
* Event handler called during a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
124
|
-
*/
|
|
125
|
-
onSwipeMove?(event: SwipeEvent): void
|
|
126
|
-
/**
|
|
127
|
-
* Event handler called at the cancellation of a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
128
|
-
*/
|
|
129
|
-
onSwipeCancel?(event: SwipeEvent): void
|
|
130
|
-
/**
|
|
131
|
-
* Event handler called at the end of a swipe interaction. It can be prevented by calling `event.preventDefault`.
|
|
132
|
-
*/
|
|
133
|
-
onSwipeEnd?(event: SwipeEvent): void
|
|
134
|
-
/**
|
|
135
|
-
* The viewport's name to send the toast to. Used when using multiple viewports and want to forward toasts to different ones.
|
|
136
|
-
*
|
|
137
|
-
* @default "default"
|
|
138
|
-
*/
|
|
139
|
-
viewportName?: string
|
|
140
|
-
/**
|
|
141
|
-
*
|
|
142
|
-
*/
|
|
143
|
-
id?: string
|
|
144
|
-
}
|
|
154
|
+
type ToastImplProps = ToastImplPrivateProps & ToastImplFrameProps & ToastExtraProps
|
|
145
155
|
|
|
146
156
|
const ToastImpl = React.forwardRef<TamaguiElement, ToastImplProps>(
|
|
147
157
|
(props: ScopedProps<ToastImplProps>, forwardedRef) => {
|