@nxgt/material 3.99.0 → 3.100.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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/{components-DPmZnTlW.js → components-BxnPdm5s.js} +3334 -3287
- package/dist/components.js +33 -33
- package/dist/lib/components/ui/feedback/toast/index.d.ts +1 -0
- package/dist/lib/components/ui/feedback/toast/use-scoped-toasts.d.ts +22 -0
- package/dist/main.js +49 -49
- package/docs/components/feedback-and-status.md +23 -0
- package/package.json +1 -1
|
@@ -1184,6 +1184,29 @@ toasts.success({
|
|
|
1184
1184
|
});
|
|
1185
1185
|
```
|
|
1186
1186
|
|
|
1187
|
+
**Toasts that belong to a page.** `useScopedToasts()` returns the same API as
|
|
1188
|
+
`toasts`, and dismisses every toast it showed when the component unmounts, so a
|
|
1189
|
+
toast with an « Undo » action never outlives the page that can undo. `dismiss(id)`
|
|
1190
|
+
forgets the id; `dismiss()` without an id takes down only this scope's toasts.
|
|
1191
|
+
The returned object is stable, safe in a dependency array.
|
|
1192
|
+
|
|
1193
|
+
```tsx
|
|
1194
|
+
import { Button, useScopedToasts } from '@nxgt/material/components';
|
|
1195
|
+
|
|
1196
|
+
function Archive({ undo }: { undo: () => void }) {
|
|
1197
|
+
const toasts = useScopedToasts();
|
|
1198
|
+
return (
|
|
1199
|
+
<Button
|
|
1200
|
+
onClick={() =>
|
|
1201
|
+
toasts.success({ title: 'Archived', action: { label: 'Undo', onClick: undo } })
|
|
1202
|
+
}
|
|
1203
|
+
>
|
|
1204
|
+
Archive
|
|
1205
|
+
</Button>
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1187
1210
|
**An action keeps the toast open.** `toast()` itself does it, so a preset and a
|
|
1188
1211
|
direct call behave alike: any toast with an `action` is persistent by default
|
|
1189
1212
|
(`options.duration: Infinity`, WCAG 2.2.1: a timed toast can vanish before a
|