@xsolla/xui-toast 0.158.0 → 0.159.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/README.md +124 -166
- package/native/index.d.mts +48 -19
- package/native/index.d.ts +48 -19
- package/native/index.js +248 -86
- package/native/index.js.map +1 -1
- package/native/index.mjs +260 -87
- package/native/index.mjs.map +1 -1
- package/package.json +5 -4
- package/web/index.d.mts +48 -19
- package/web/index.d.ts +48 -19
- package/web/index.js +248 -86
- package/web/index.js.map +1 -1
- package/web/index.mjs +260 -87
- package/web/index.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Toast
|
|
2
2
|
|
|
3
|
-
A cross-platform toast notification system
|
|
3
|
+
A cross-platform toast notification system matching the base Figma toast. Use it for short, non-blocking feedback with a title, optional description, optional action, and automatic or manual dismissal.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
useToast,
|
|
20
20
|
type ToastProps,
|
|
21
21
|
type ToastOptions,
|
|
22
|
-
type
|
|
22
|
+
type ToastType,
|
|
23
23
|
type ToastPosition,
|
|
24
24
|
type ToastAlign,
|
|
25
25
|
type UseToastReturn,
|
|
26
|
-
} from
|
|
26
|
+
} from "@xsolla/xui-toast";
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Quick start
|
|
@@ -31,14 +31,16 @@ import {
|
|
|
31
31
|
Wrap your app with `ToastProvider`, then call `useToast` from any descendant.
|
|
32
32
|
|
|
33
33
|
```tsx
|
|
34
|
-
import * as React from
|
|
35
|
-
import { XUIProvider } from
|
|
36
|
-
import { ToastProvider, useToast } from
|
|
34
|
+
import * as React from "react";
|
|
35
|
+
import { XUIProvider } from "@xsolla/xui-core";
|
|
36
|
+
import { ToastProvider, useToast } from "@xsolla/xui-toast";
|
|
37
37
|
|
|
38
38
|
function SaveButton() {
|
|
39
39
|
const toast = useToast();
|
|
40
40
|
return (
|
|
41
|
-
<button onClick={() => toast.success(
|
|
41
|
+
<button onClick={() => toast.success({ title: "Saved successfully" })}>
|
|
42
|
+
Save
|
|
43
|
+
</button>
|
|
42
44
|
);
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -61,26 +63,31 @@ export default function App() {
|
|
|
61
63
|
|
|
62
64
|
Root provider. Manages toast state, auto-dismiss timers, and renders the `ToastGroup`.
|
|
63
65
|
|
|
64
|
-
| Prop
|
|
65
|
-
|
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
66
|
+
| Prop | Type | Default | Description |
|
|
67
|
+
| ----------------- | ------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `testID` | `string` | - | Test ID for testing frameworks. On web this renders as `data-testid`; on React Native it renders as `testID`. |
|
|
69
|
+
| `children` | `ReactNode` | - | Application content. |
|
|
70
|
+
| `position` | `"top" \| "bottom"` | `"top"` | Vertical anchor of the toast container. |
|
|
71
|
+
| `align` | `"left" \| "center" \| "right"` | `"center"` | Horizontal alignment of toasts within the container. |
|
|
72
|
+
| `defaultDuration` | `number` | `5000` | Default auto-dismiss duration in ms. Set `0` to disable auto-dismiss globally. |
|
|
73
|
+
| `maxWidth` | `number` | - | Maximum width in px of the toast stack. |
|
|
71
74
|
|
|
72
75
|
### `<Toast>`
|
|
73
76
|
|
|
74
77
|
The individual toast cell. Used internally by `ToastGroup`, but can be rendered standalone for static display.
|
|
75
78
|
|
|
76
|
-
| Prop
|
|
77
|
-
|
|
|
78
|
-
| `id`
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
79
|
+
| Prop | Type | Default | Description |
|
|
80
|
+
| ----------------- | ------------------------------------------------ | ----------- | ------------------------------------------------------------------ |
|
|
81
|
+
| `id` | `string` | - | Required unique identifier. |
|
|
82
|
+
| `type` | `"alert" \| "success" \| "neutral" \| "warning"` | `"neutral"` | Visual and accessibility type. |
|
|
83
|
+
| `title` | `string` | - | Short primary text, ideally 1 to 5 words. |
|
|
84
|
+
| `description` | `string` | - | Optional supporting text. |
|
|
85
|
+
| `icon` | `boolean \| ReactNode` | `true` | Show the default icon, hide it with `false`, or pass a custom one. |
|
|
86
|
+
| `action` | `ReactElement` | - | Optional action element, typically a `FlexButton`. |
|
|
87
|
+
| `showCloseButton` | `boolean` | `true` | Show the trailing dismiss control when `onClose` is provided. |
|
|
88
|
+
| `progress` | `boolean` | `false` | Show the bottom progress strip. |
|
|
89
|
+
| `duration` | `number` | - | Auto-dismiss duration in ms. `0` or omitted = no auto-dismiss. |
|
|
90
|
+
| `onClose` | `() => void` | - | Close handler. Required for the close button to render. |
|
|
84
91
|
|
|
85
92
|
Inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`).
|
|
86
93
|
|
|
@@ -88,13 +95,13 @@ Inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`).
|
|
|
88
95
|
|
|
89
96
|
Renders the stack of visible toasts. On web uses `ReactDOM.createPortal` to escape stacking contexts; on React Native uses absolute positioning.
|
|
90
97
|
|
|
91
|
-
| Prop
|
|
92
|
-
|
|
|
93
|
-
| `toasts`
|
|
94
|
-
| `position`
|
|
95
|
-
| `align`
|
|
96
|
-
| `maxWidth`
|
|
97
|
-
| `onDismiss` | `(id: string) => void`
|
|
98
|
+
| Prop | Type | Default | Description |
|
|
99
|
+
| ----------- | ------------------------------- | ---------- | --------------------------- |
|
|
100
|
+
| `toasts` | `ToastData[]` | - | Toasts to render. |
|
|
101
|
+
| `position` | `"top" \| "bottom"` | `"top"` | Vertical anchor. |
|
|
102
|
+
| `align` | `"left" \| "center" \| "right"` | `"center"` | Horizontal alignment. |
|
|
103
|
+
| `maxWidth` | `number` | - | Maximum width in px. |
|
|
104
|
+
| `onDismiss` | `(id: string) => void` | - | Dismiss callback per toast. |
|
|
98
105
|
|
|
99
106
|
Inherits `ThemeOverrideProps`.
|
|
100
107
|
|
|
@@ -102,87 +109,103 @@ Inherits `ThemeOverrideProps`.
|
|
|
102
109
|
|
|
103
110
|
Hook that returns toast helpers. Throws if called outside a `ToastProvider`.
|
|
104
111
|
|
|
105
|
-
| Method
|
|
106
|
-
|
|
|
107
|
-
| `toast`
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `dismiss`
|
|
113
|
-
| `dismissAll` | `() => void`
|
|
112
|
+
| Method | Signature | Description |
|
|
113
|
+
| ------------ | ------------------------------------------------- | ----------------------------------------------------- |
|
|
114
|
+
| `toast` | `(options: ToastOptions) => string` | Show a toast with full options. Returns the toast ID. |
|
|
115
|
+
| `alert` | `(options: Omit<ToastOptions, "type">) => string` | Show an alert toast. |
|
|
116
|
+
| `success` | `(options: Omit<ToastOptions, "type">) => string` | Show a success toast. |
|
|
117
|
+
| `neutral` | `(options: Omit<ToastOptions, "type">) => string` | Show a neutral toast. |
|
|
118
|
+
| `warning` | `(options: Omit<ToastOptions, "type">) => string` | Show a warning toast. |
|
|
119
|
+
| `dismiss` | `(id: string) => void` | Dismiss a specific toast by ID. |
|
|
120
|
+
| `dismissAll` | `() => void` | Dismiss all visible toasts. |
|
|
114
121
|
|
|
115
122
|
### `ToastOptions`
|
|
116
123
|
|
|
117
|
-
| Property
|
|
118
|
-
|
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
124
|
+
| Property | Type | Default | Description |
|
|
125
|
+
| ----------------- | ------------------------------------------------ | ---------------------------- | ------------------------------------------------------------------ |
|
|
126
|
+
| `type` | `"alert" \| "success" \| "neutral" \| "warning"` | `"neutral"` | Visual and accessibility type. |
|
|
127
|
+
| `title` | `string` | - | Short primary text. |
|
|
128
|
+
| `description` | `string` | - | Optional supporting text. |
|
|
129
|
+
| `icon` | `boolean \| ReactNode` | `true` | Show, hide, or override the icon. |
|
|
130
|
+
| `action` | `ReactElement` | - | Optional action element. |
|
|
131
|
+
| `showCloseButton` | `boolean` | `true` | Show the close button when the toast is dismissible. |
|
|
132
|
+
| `progress` | `boolean` | `false` | Show the bottom progress strip. |
|
|
133
|
+
| `duration` | `number` | provider's `defaultDuration` | Auto-dismiss duration. `0` keeps the toast until dismissed manually. |
|
|
123
134
|
|
|
124
135
|
### `ToastData`
|
|
125
136
|
|
|
126
137
|
Internal shape exposed via `ToastContext.toasts`.
|
|
127
138
|
|
|
128
|
-
| Property
|
|
129
|
-
|
|
|
130
|
-
| `id`
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
133
|
-
| `
|
|
134
|
-
| `duration`
|
|
139
|
+
| Property | Type | Description |
|
|
140
|
+
| ------------- | ----------- | -------------------------------------------- |
|
|
141
|
+
| `id` | `string` | Unique identifier generated by the provider. |
|
|
142
|
+
| `type` | `ToastType` | Toast type. |
|
|
143
|
+
| `title` | `string` | Primary text. |
|
|
144
|
+
| `description` | `string` | Supporting text. |
|
|
145
|
+
| `duration` | `number` | Auto-dismiss duration. |
|
|
135
146
|
|
|
136
147
|
### `ToastContext`
|
|
137
148
|
|
|
138
149
|
React context with `{ toasts, addToast, dismissToast, dismissAllToasts }`. Typically consumed via `useToast`; available for advanced use cases:
|
|
139
150
|
|
|
140
151
|
```tsx
|
|
141
|
-
import { useContext } from
|
|
142
|
-
import { ToastContext } from
|
|
152
|
+
import { useContext } from "react";
|
|
153
|
+
import { ToastContext } from "@xsolla/xui-toast";
|
|
143
154
|
|
|
144
155
|
function ActiveCount() {
|
|
145
156
|
const ctx = useContext(ToastContext);
|
|
146
|
-
if (!ctx) throw new Error(
|
|
157
|
+
if (!ctx) throw new Error("Must be within ToastProvider");
|
|
147
158
|
return <span>Active toasts: {ctx.toasts.length}</span>;
|
|
148
159
|
}
|
|
149
160
|
```
|
|
150
161
|
|
|
151
162
|
## Examples
|
|
152
163
|
|
|
153
|
-
###
|
|
164
|
+
### Types
|
|
154
165
|
|
|
155
166
|
```tsx
|
|
156
|
-
import * as React from
|
|
157
|
-
import { useToast } from
|
|
167
|
+
import * as React from "react";
|
|
168
|
+
import { useToast } from "@xsolla/xui-toast";
|
|
158
169
|
|
|
159
|
-
export default function
|
|
170
|
+
export default function Types() {
|
|
160
171
|
const toast = useToast();
|
|
161
172
|
return (
|
|
162
|
-
<div style={{ display:
|
|
163
|
-
<button onClick={() => toast.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<button onClick={() => toast.
|
|
173
|
+
<div style={{ display: "flex", gap: 8 }}>
|
|
174
|
+
<button onClick={() => toast.neutral({ title: "Reward claimed" })}>
|
|
175
|
+
Neutral
|
|
176
|
+
</button>
|
|
177
|
+
<button onClick={() => toast.success({ title: "Quest activated" })}>
|
|
178
|
+
Success
|
|
179
|
+
</button>
|
|
180
|
+
<button onClick={() => toast.warning({ title: "Session expires soon" })}>
|
|
181
|
+
Warning
|
|
182
|
+
</button>
|
|
183
|
+
<button onClick={() => toast.alert({ title: "Connection lost" })}>
|
|
184
|
+
Alert
|
|
185
|
+
</button>
|
|
167
186
|
</div>
|
|
168
187
|
);
|
|
169
188
|
}
|
|
170
189
|
```
|
|
171
190
|
|
|
172
|
-
### Standalone Toast
|
|
191
|
+
### Standalone Toast With Action
|
|
173
192
|
|
|
174
193
|
```tsx
|
|
175
|
-
import * as React from
|
|
176
|
-
import {
|
|
194
|
+
import * as React from "react";
|
|
195
|
+
import { FlexButton } from "@xsolla/xui-button";
|
|
196
|
+
import { Toast } from "@xsolla/xui-toast";
|
|
177
197
|
|
|
178
198
|
export default function Standalone() {
|
|
179
199
|
return (
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
200
|
+
<Toast
|
|
201
|
+
id="retry"
|
|
202
|
+
type="alert"
|
|
203
|
+
title="Connection lost"
|
|
204
|
+
description="Check your network and try again"
|
|
205
|
+
action={<FlexButton>Retry</FlexButton>}
|
|
206
|
+
progress
|
|
207
|
+
onClose={() => {}}
|
|
208
|
+
/>
|
|
186
209
|
);
|
|
187
210
|
}
|
|
188
211
|
```
|
|
@@ -190,134 +213,69 @@ export default function Standalone() {
|
|
|
190
213
|
### Custom duration
|
|
191
214
|
|
|
192
215
|
```tsx
|
|
193
|
-
import * as React from
|
|
194
|
-
import { useToast } from
|
|
216
|
+
import * as React from "react";
|
|
217
|
+
import { useToast } from "@xsolla/xui-toast";
|
|
195
218
|
|
|
196
219
|
export default function Duration() {
|
|
197
|
-
const toast = useToast();
|
|
198
|
-
return (
|
|
199
|
-
<div style={{ display: 'flex', gap: 8 }}>
|
|
200
|
-
<button onClick={() => toast.toast({ message: 'Stays 10s', duration: 10000 })}>10s</button>
|
|
201
|
-
<button onClick={() => toast.toast({ message: 'Stays 2s', duration: 2000 })}>2s</button>
|
|
202
|
-
<button onClick={() => toast.toast({ message: 'Manual dismiss', duration: 0 })}>No auto-dismiss</button>
|
|
203
|
-
</div>
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### Custom icon
|
|
209
|
-
|
|
210
|
-
```tsx
|
|
211
|
-
import * as React from 'react';
|
|
212
|
-
import { useToast } from '@xsolla/xui-toast';
|
|
213
|
-
import { Star } from '@xsolla/xui-icons-base';
|
|
214
|
-
|
|
215
|
-
export default function CustomIcon() {
|
|
216
220
|
const toast = useToast();
|
|
217
221
|
return (
|
|
218
222
|
<button
|
|
219
223
|
onClick={() =>
|
|
220
|
-
toast.toast({
|
|
224
|
+
toast.toast({
|
|
225
|
+
type: "neutral",
|
|
226
|
+
title: "Manual dismiss",
|
|
227
|
+
duration: 0,
|
|
228
|
+
})
|
|
221
229
|
}
|
|
222
230
|
>
|
|
223
|
-
Show
|
|
231
|
+
Show sticky toast
|
|
224
232
|
</button>
|
|
225
233
|
);
|
|
226
234
|
}
|
|
227
235
|
```
|
|
228
236
|
|
|
229
|
-
### Programmatic dismiss
|
|
230
|
-
|
|
231
|
-
```tsx
|
|
232
|
-
import * as React from 'react';
|
|
233
|
-
import { useToast } from '@xsolla/xui-toast';
|
|
234
|
-
|
|
235
|
-
export default function Dismiss() {
|
|
236
|
-
const toast = useToast();
|
|
237
|
-
const [lastId, setLastId] = React.useState<string | null>(null);
|
|
238
|
-
|
|
239
|
-
return (
|
|
240
|
-
<div style={{ display: 'flex', gap: 8 }}>
|
|
241
|
-
<button onClick={() => setLastId(toast.info('New notification'))}>Show</button>
|
|
242
|
-
<button onClick={() => lastId && toast.dismiss(lastId)}>Dismiss last</button>
|
|
243
|
-
<button onClick={() => toast.dismissAll()}>Dismiss all</button>
|
|
244
|
-
</div>
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
237
|
### Position and alignment
|
|
250
238
|
|
|
251
239
|
```tsx
|
|
252
|
-
import * as React from
|
|
253
|
-
import { ToastProvider, useToast } from
|
|
240
|
+
import * as React from "react";
|
|
241
|
+
import { ToastProvider, useToast } from "@xsolla/xui-toast";
|
|
254
242
|
|
|
255
243
|
function Trigger() {
|
|
256
244
|
const toast = useToast();
|
|
257
|
-
return
|
|
245
|
+
return (
|
|
246
|
+
<button onClick={() => toast.neutral({ title: "Bottom-right toast" })}>
|
|
247
|
+
Show
|
|
248
|
+
</button>
|
|
249
|
+
);
|
|
258
250
|
}
|
|
259
251
|
|
|
260
252
|
export default function BottomRight() {
|
|
261
253
|
return (
|
|
262
|
-
<ToastProvider position="bottom" align="right" maxWidth={
|
|
254
|
+
<ToastProvider position="bottom" align="right" maxWidth={440}>
|
|
263
255
|
<Trigger />
|
|
264
256
|
</ToastProvider>
|
|
265
257
|
);
|
|
266
258
|
}
|
|
267
259
|
```
|
|
268
260
|
|
|
269
|
-
### React Native
|
|
270
|
-
|
|
271
|
-
The `useToast` hook is identical on React Native; use `onPress` instead of `onClick`.
|
|
272
|
-
|
|
273
|
-
```tsx
|
|
274
|
-
import * as React from 'react';
|
|
275
|
-
import { View } from 'react-native';
|
|
276
|
-
import { Button } from '@xsolla/xui-button';
|
|
277
|
-
import { XUIProvider } from '@xsolla/xui-core';
|
|
278
|
-
import { ToastProvider, useToast } from '@xsolla/xui-toast';
|
|
279
|
-
|
|
280
|
-
function Trigger() {
|
|
281
|
-
const toast = useToast();
|
|
282
|
-
return <Button onPress={() => toast.success('Saved')}>Save</Button>;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export default function App() {
|
|
286
|
-
return (
|
|
287
|
-
<XUIProvider initialMode="dark">
|
|
288
|
-
<ToastProvider position="top">
|
|
289
|
-
<View style={{ flex: 1 }}>
|
|
290
|
-
<Trigger />
|
|
291
|
-
</View>
|
|
292
|
-
</ToastProvider>
|
|
293
|
-
</XUIProvider>
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
```
|
|
297
|
-
|
|
298
261
|
## Platform support
|
|
299
262
|
|
|
300
|
-
| Aspect
|
|
301
|
-
|
|
|
302
|
-
| Rendering
|
|
303
|
-
| Event handlers | `onClick`
|
|
304
|
-
| Root container | Any element
|
|
263
|
+
| Aspect | Web | React Native |
|
|
264
|
+
| -------------- | ------------------------------------------ | --------------------------------- |
|
|
265
|
+
| Rendering | `ReactDOM.createPortal` to `document.body` | Absolute-positioned `Box` in tree |
|
|
266
|
+
| Event handlers | `onClick` | `onPress` |
|
|
267
|
+
| Root container | Any element | Must have `flex: 1` |
|
|
305
268
|
|
|
306
269
|
## Accessibility
|
|
307
270
|
|
|
308
|
-
-
|
|
309
|
-
-
|
|
310
|
-
-
|
|
311
|
-
-
|
|
271
|
+
- Neutral and success toasts render with `role="status"` and polite announcements.
|
|
272
|
+
- Warning and alert toasts render with `role="alert"` and assertive announcements.
|
|
273
|
+
- The close button has `aria-label="Dismiss notification"`.
|
|
274
|
+
- Do not rely on color alone; the icon and text also communicate the type.
|
|
312
275
|
|
|
313
276
|
## Troubleshooting
|
|
314
277
|
|
|
315
|
-
- **"useToast must be used within a ToastProvider"**
|
|
316
|
-
- **Toasts hidden on React Native**
|
|
317
|
-
- **Toasts appear behind a modal (web)**
|
|
318
|
-
- **Auto-dismiss not working**
|
|
319
|
-
|
|
320
|
-
## Related
|
|
321
|
-
|
|
322
|
-
- [Notification](./notification.md) — declarative toast/inline notification.
|
|
323
|
-
- [NotificationPanel](./notification-panel.md) — full-width inline banner.
|
|
278
|
+
- **"useToast must be used within a ToastProvider"** - ensure the calling component is a descendant of `ToastProvider`.
|
|
279
|
+
- **Toasts hidden on React Native** - wrap content in `<View style={{ flex: 1 }}>` inside `ToastProvider`.
|
|
280
|
+
- **Toasts appear behind a modal (web)** - `ToastGroup` uses `z-index: 9999`. Place `ToastProvider` above the modal in the tree, or adjust z-index.
|
|
281
|
+
- **Auto-dismiss not working** - `duration: 0` disables auto-dismiss; check both per-toast and provider defaults.
|
package/native/index.d.mts
CHANGED
|
@@ -1,29 +1,54 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { ReactNode } from 'react';
|
|
2
|
+
import React__default, { ReactNode, ReactElement } from 'react';
|
|
3
3
|
import { ThemeOverrideProps } from '@xsolla/xui-core';
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type ToastType = "alert" | "success" | "neutral" | "warning";
|
|
6
6
|
type ToastPosition = "top" | "bottom";
|
|
7
7
|
type ToastAlign = "left" | "center" | "right";
|
|
8
8
|
interface ToastData {
|
|
9
9
|
id: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
type: ToastType;
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
icon?: boolean | ReactNode;
|
|
14
|
+
action?: ReactElement;
|
|
15
|
+
showCloseButton?: boolean;
|
|
16
|
+
progress?: boolean;
|
|
13
17
|
duration?: number;
|
|
14
18
|
}
|
|
19
|
+
interface ToastColorScheme {
|
|
20
|
+
background: string;
|
|
21
|
+
text: string;
|
|
22
|
+
descriptionText: string;
|
|
23
|
+
divider: string;
|
|
24
|
+
actionText: string;
|
|
25
|
+
shadow?: string;
|
|
26
|
+
backdropFilter?: string;
|
|
27
|
+
}
|
|
15
28
|
interface ToastProps extends ThemeOverrideProps {
|
|
16
29
|
id: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
type?: ToastType;
|
|
31
|
+
title?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
icon?: boolean | ReactNode;
|
|
34
|
+
action?: ReactElement;
|
|
35
|
+
showCloseButton?: boolean;
|
|
36
|
+
progress?: boolean;
|
|
20
37
|
duration?: number;
|
|
21
38
|
onClose?: () => void;
|
|
39
|
+
/** Internal color override for product-specific toast surfaces */
|
|
40
|
+
colorScheme?: ToastColorScheme;
|
|
41
|
+
/** Test ID for testing frameworks */
|
|
42
|
+
testID?: string;
|
|
22
43
|
}
|
|
23
44
|
interface ToastOptions {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
type?: ToastType;
|
|
46
|
+
title?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
icon?: boolean | ReactNode;
|
|
49
|
+
action?: ReactElement;
|
|
50
|
+
showCloseButton?: boolean;
|
|
51
|
+
progress?: boolean;
|
|
27
52
|
duration?: number;
|
|
28
53
|
}
|
|
29
54
|
interface ToastGroupProps extends ThemeOverrideProps {
|
|
@@ -32,6 +57,8 @@ interface ToastGroupProps extends ThemeOverrideProps {
|
|
|
32
57
|
align?: ToastAlign;
|
|
33
58
|
maxWidth?: number;
|
|
34
59
|
onDismiss: (id: string) => void;
|
|
60
|
+
/** Test ID for testing frameworks */
|
|
61
|
+
testID?: string;
|
|
35
62
|
}
|
|
36
63
|
interface ToastContextType {
|
|
37
64
|
toasts: ToastData[];
|
|
@@ -45,11 +72,13 @@ interface ToastProviderProps {
|
|
|
45
72
|
align?: ToastAlign;
|
|
46
73
|
defaultDuration?: number;
|
|
47
74
|
maxWidth?: number;
|
|
75
|
+
/** Test ID for testing frameworks */
|
|
76
|
+
testID?: string;
|
|
48
77
|
}
|
|
49
78
|
|
|
50
79
|
declare const Toast: React__default.FC<ToastProps>;
|
|
51
80
|
|
|
52
|
-
declare const ToastGroup: React__default.MemoExoticComponent<({ toasts, position, align, maxWidth, onDismiss, themeMode, themeProductContext, }: ToastGroupProps) => React__default.ReactPortal | null>;
|
|
81
|
+
declare const ToastGroup: React__default.MemoExoticComponent<({ toasts, position, align, maxWidth, onDismiss, testID, themeMode, themeProductContext, }: ToastGroupProps) => React__default.ReactPortal | null>;
|
|
53
82
|
|
|
54
83
|
declare const ToastProvider: React__default.FC<ToastProviderProps>;
|
|
55
84
|
|
|
@@ -58,14 +87,14 @@ declare const ToastContext: React.Context<ToastContextType | null>;
|
|
|
58
87
|
interface UseToastReturn {
|
|
59
88
|
/** Show a toast with custom options */
|
|
60
89
|
toast: (options: ToastOptions) => string;
|
|
90
|
+
/** Show an alert toast */
|
|
91
|
+
alert: (options: Omit<ToastOptions, "type">) => string;
|
|
61
92
|
/** Show a success toast */
|
|
62
|
-
success: (
|
|
63
|
-
/** Show
|
|
64
|
-
|
|
93
|
+
success: (options: Omit<ToastOptions, "type">) => string;
|
|
94
|
+
/** Show a neutral toast */
|
|
95
|
+
neutral: (options: Omit<ToastOptions, "type">) => string;
|
|
65
96
|
/** Show a warning toast */
|
|
66
|
-
warning: (
|
|
67
|
-
/** Show an error toast */
|
|
68
|
-
error: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => string;
|
|
97
|
+
warning: (options: Omit<ToastOptions, "type">) => string;
|
|
69
98
|
/** Dismiss a specific toast by ID */
|
|
70
99
|
dismiss: (id: string) => void;
|
|
71
100
|
/** Dismiss all toasts */
|
|
@@ -73,4 +102,4 @@ interface UseToastReturn {
|
|
|
73
102
|
}
|
|
74
103
|
declare const useToast: () => UseToastReturn;
|
|
75
104
|
|
|
76
|
-
export { Toast, type ToastAlign, ToastContext, type ToastContextType, type ToastData, ToastGroup, type ToastGroupProps, type ToastOptions, type ToastPosition, type ToastProps, ToastProvider, type ToastProviderProps, type
|
|
105
|
+
export { Toast, type ToastAlign, type ToastColorScheme, ToastContext, type ToastContextType, type ToastData, ToastGroup, type ToastGroupProps, type ToastOptions, type ToastPosition, type ToastProps, ToastProvider, type ToastProviderProps, type ToastType, type UseToastReturn, useToast };
|