@umriss-ui/core 0.37.0 → 0.39.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/index.d.ts CHANGED
@@ -2140,8 +2140,10 @@ export declare interface ToastConfig {
2140
2140
  stand in different places are not read as one.
2141
2141
  @default "bottom-end" */
2142
2142
  position?: ToastPosition;
2143
- /** How many toasts stand at once; the oldest gives way to a new one, as if
2144
- it had been closed.
2143
+ /** How many toasts that leave by themselves stand at once; the oldest of
2144
+ them gives way to a new one, as if it had been closed. A toast that
2145
+ stays (`duration: 0`) or is still at work (`loading`) neither counts nor
2146
+ gives way.
2145
2147
  @default 3 */
2146
2148
  limit?: number;
2147
2149
  }
@@ -2151,8 +2153,10 @@ declare interface ToastContextValue {
2151
2153
  toast: (options: ToastOptions) => number;
2152
2154
  /** Changes a standing toast. A new tone or a new `duration` starts its time
2153
2155
  afresh - so a `loading` toast turned into `success` begins to count then.
2154
- An id that no longer stands is ignored: a toast that gave way to newer
2155
- ones - a `loading` one too - has said so through `onClose`. */
2156
+ An id that no longer stands is ignored: a timed toast that gave way
2157
+ to newer ones has said so through `onClose`. A `loading` toast turned into
2158
+ its outcome counts toward the limit from the next arrival on; `update`
2159
+ itself pushes nothing out. */
2156
2160
  update: (id: number, options: Partial<ToastOptions>) => void;
2157
2161
  /** Closes a toast, with the reason `dismiss`. */
2158
2162
  dismiss: (id: number) => void;
@@ -2190,11 +2194,21 @@ export declare interface ToastOptions {
2190
2194
  export declare type ToastPosition = "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end";
2191
2195
 
2192
2196
  /** Holds the toasts and draws them; `useToast` works only below it. Put it
2193
- once at the root of the application. Duration, position and limit come from
2194
- `UmrissProvider`'s `toast` where one stands around it. */
2195
- export declare function ToastProvider({ children }: {
2197
+ once at the root of the application: a second one draws a second deck at
2198
+ the same place, and the two lie on each other. Duration, position and limit
2199
+ come from `UmrissProvider`'s `toast` where one stands around it. */
2200
+ export declare function ToastProvider({ children, held }: ToastProviderProps): JSX.Element;
2201
+
2202
+ /** The props of `ToastProvider`. */
2203
+ export declare interface ToastProviderProps {
2196
2204
  children: ReactNode;
2197
- }): JSX.Element;
2205
+ /** While true, the toasts are held back: none is seen or heard, no time runs
2206
+ out, and a new one waits. When false again they come back with the time
2207
+ they had left. For a surface the toasts must not cover for a while, where
2208
+ there is no room beside it: nothing is lost, as it would be by dismissing.
2209
+ @default false */
2210
+ held?: boolean;
2211
+ }
2198
2212
 
2199
2213
  /** How the message turns out; `loading` is a toast still at work. */
2200
2214
  export declare type ToastTone = "neutral" | "success" | "warning" | "danger" | "loading";
package/docs/llms-full.md CHANGED
@@ -1,4 +1,4 @@
1
- # @umriss-ui/core 0.37.0
1
+ # @umriss-ui/core 0.39.0
2
2
 
3
3
  > React component library for data-dense dashboards and tools - forms, date pickers, overlays, a tree view and a command palette. Precise, quiet, professional.
4
4
 
@@ -506,7 +506,6 @@ import {
506
506
  Stack,
507
507
  Switch,
508
508
  Text,
509
- ToastProvider,
510
509
  TreeView,
511
510
  useToast,
512
511
  useTree,
@@ -848,11 +847,7 @@ function Content() {
848
847
  /* `useToast` needs a `ToastProvider` above it; at the root of an application
849
848
  one provider serves every screen. */
850
849
  export default function DispatchATour() {
851
- return (
852
- <ToastProvider>
853
- <Content />
854
- </ToastProvider>
855
- );
850
+ return <Content />;
856
851
  }
857
852
  ```
858
853
 
@@ -2450,13 +2445,14 @@ Wrap the application once; here `toast` keeps every toast on screen for eight se
2450
2445
  ```tsx
2451
2446
  import { Button, ToastProvider, UmrissProvider, useToast, type ToastConfig } from "@umriss-ui/core";
2452
2447
 
2448
+ type ToastFn = ReturnType<typeof useToast>["toast"];
2449
+
2450
+ const deploy = (toast: ToastFn) => toast({ title: "Checkout 4.12.0 deployed", description: "Rolled out to all regions.", tone: "success" });
2451
+
2453
2452
  function DeployButton() {
2454
2453
  const { toast } = useToast();
2455
2454
  return (
2456
- <Button
2457
- variant="primary"
2458
- onClick={() => toast({ title: "Checkout 4.12.0 deployed", description: "Rolled out to all regions.", tone: "success" })}
2459
- >
2455
+ <Button variant="primary" onClick={() => deploy(toast)}>
2460
2456
  Deploy Checkout
2461
2457
  </Button>
2462
2458
  );
@@ -2534,15 +2530,20 @@ import { GERMAN_FORMATS, GERMAN_WORDING } from "@umriss-ui/core/wording/de";
2534
2530
  const LANGUAGE: UmrissProviderProps["language"] = { wording: GERMAN_WORDING, formats: GERMAN_FORMATS };
2535
2531
  const TOAST: ToastConfig = { duration: 3000 };
2536
2532
 
2533
+ type ToastFn = ReturnType<typeof useToast>["toast"];
2534
+
2535
+ const rebook = (toast: ToastFn) => toast({ title: "Shipment SH-1042 rebooked" });
2536
+
2537
2537
  function DeliveryDate() {
2538
2538
  const { toast } = useToast();
2539
+ const rebookNow = () => rebook(toast);
2539
2540
  const [date, setDate] = useState<Date | null>(new Date(2026, 2, 18));
2540
2541
  return (
2541
2542
  <Stack gap={3} align="flex-start">
2542
2543
  <FormField label="Delivery date">
2543
2544
  <DatePicker value={date} onChange={setDate} clearable />
2544
2545
  </FormField>
2545
- <Button size="sm" disabled={date === null} onClick={() => toast({ title: "Shipment SH-1042 rebooked" })}>
2546
+ <Button size="sm" disabled={date === null} onClick={rebookNow}>
2546
2547
  Rebook
2547
2548
  </Button>
2548
2549
  </Stack>
@@ -2586,7 +2587,7 @@ Where a `ToastProvider` stands inside it, the toasts' two live regions stand whe
2586
2587
  | `portalTarget` | [`PortalTarget`](#type-PortalTarget) | `null` | Where overlays portal to, unless an open dialog takes them. A function is evaluated on every opening - a target that only enters the tree later cannot be given otherwise; `null` means "as before". The callers' own rules take precedence: the popover seam portals into the nearest `<dialog>` ancestor, because a portal at the body does not reach the top layer, and the toasts follow the topmost modal dialog, because a toast outside it lies behind it and is inert.<br>Shown in: [Open overlays inside a full-screen panel](#/umrissprovider/portal-target), [Set up an application](#/umrissprovider/everything-at-once) |
2587
2588
  | `toast` | [`ToastConfig`](#type-ToastConfig) | — | The setting for toasts: the display duration where the individual toast names none, where they stand, and how many stand at once.<br>Shown in: [At the root](#/umrissprovider/at-the-root), [Set up an application](#/umrissprovider/everything-at-once), [Where they stand (Toast)](#/toast/where-they-stand) and 1 more |
2588
2589
  | `language` | [`LanguageOptions`](#/language/type-LanguageOptions) | none - the surrounding language holds, English at the root | Formats and wording, entry by entry - see [Language](#/language).<br>Shown in: [Set up an application](#/umrissprovider/everything-at-once) |
2589
- | `children` *required* | `ReactNode` | — | The subtree the settings apply to.<br>Shown in: [At the root](#/umrissprovider/at-the-root), [Open overlays inside a full-screen panel](#/umrissprovider/portal-target), [Set up an application](#/umrissprovider/everything-at-once) and 2 more |
2590
+ | `children` *required* | `ReactNode` | — | The subtree the settings apply to.<br>Shown in: [Open overlays inside a full-screen panel](#/umrissprovider/portal-target), [Set up an application](#/umrissprovider/everything-at-once) |
2590
2591
 
2591
2592
  ##### `ToastConfig`
2592
2593
 
@@ -2594,7 +2595,7 @@ Where a `ToastProvider` stands inside it, the toasts' two live regions stand whe
2594
2595
  |---|---|---|---|
2595
2596
  | `duration` | `number` | `5000` | Display duration in ms, where the individual toast names none.<br>Shown in: [At the root](#/umrissprovider/at-the-root), [Set up an application](#/umrissprovider/everything-at-once) |
2596
2597
  | `position` | [`ToastPosition`](#type-ToastPosition)<br>`"top-start" \| "top-center" \| "top-end" \| "bottom-start" \| "bottom-center" \| "bottom-end"` | `"bottom-end"` | Where the toasts stand. There is no position per toast - toasts that stand in different places are not read as one.<br>Shown in: [Where they stand (Toast)](#/toast/where-they-stand) |
2597
- | `limit` | `number` | `3` | How many toasts stand at once; the oldest gives way to a new one, as if it had been closed.<br>Shown in: [How many stand at once (Toast)](#/toast/how-many-stand) |
2598
+ | `limit` | `number` | `3` | How many toasts that leave by themselves stand at once; the oldest of them gives way to a new one, as if it had been closed. A toast that stays (`duration: 0`) or is still at work (`loading`) neither counts nor gives way.<br>Shown in: [How many stand at once (Toast)](#/toast/how-many-stand) |
2598
2599
 
2599
2600
  ##### Types on this page
2600
2601
 
@@ -2917,7 +2918,7 @@ One look for every component. A soft glow would read as a second, shadowy border
2917
2918
 
2918
2919
  ##### Toast
2919
2920
 
2920
- How far the toasts stand from the window's top and bottom edge and from its sides - set it to keep them clear of a fixed header, a toolbar at the bottom or a navigation rail at the side. The region hangs in `body`, so set them on `:root`; a media query of your own may set another value per width. The center positions stand in the middle of the window whatever the side tokens are.
2921
+ How far the toasts stand from the window's top and bottom edge and from its sides - set it to keep them clear of a fixed header, a toolbar at the bottom or a navigation rail at the side - and how wide a toast is. The region hangs in `body`, so set them on `:root`; a media query of your own may set another value per width. The center positions stand in the middle of the window whatever the side tokens are.
2921
2922
 
2922
2923
  | Token | Light | Dark | Description |
2923
2924
  |---|---|---|---|
@@ -2925,6 +2926,7 @@ How far the toasts stand from the window's top and bottom edge and from its side
2925
2926
  | `--u-toast-inset-bottom` | `var(`[--u-space-5](#token-u-space-5)`)` | same | for the three `bottom-*` positions; `var(--u-space-4)` up to 600 px wide |
2926
2927
  | `--u-toast-inset-start` | `var(`[--u-space-5](#token-u-space-5)`)` | same | for the `*-start` positions, and on a phone the room at the start side; `var(--u-space-4)` up to 600 px wide |
2927
2928
  | `--u-toast-inset-end` | `var(`[--u-space-5](#token-u-space-5)`)` | same | for the `*-end` positions, and on a phone the room at the end side; `var(--u-space-4)` up to 600 px wide |
2929
+ | `--u-toast-width` | `360px` | same | a plain length, read it to know whether the deck has room beside a surface; up to 600 px wide the toast takes the window's width less the side tokens instead |
2928
2930
 
2929
2931
  ##### Shadow stacks: every step has one job
2930
2932
 
@@ -4774,9 +4776,9 @@ The keys of [Button](#/button/keyboard-button) apply here.
4774
4776
 
4775
4777
  | Prop | Type | Default | Description |
4776
4778
  |---|---|---|---|
4777
- | `direction` | `"row" \| "column"` | `"column"` | Below one another or beside one another. Below is the direction content stands in anyway, without being asked.<br>Shown in: [A row](#/stack-and-grid/a-row), [Gaps](#/stack-and-grid/gaps), [Wrapping](#/stack-and-grid/wrapping) and 68 more |
4778
- | `gap` | [`SpaceStep`](#type-SpaceStep)<br>`1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8` | `3` | Spacing as a step of the 4 px spacing steps (1–8).<br>Shown in: [A column](#/stack-and-grid/a-column), [A row](#/stack-and-grid/a-row), [Gaps](#/stack-and-grid/gaps) and 163 more |
4779
- | `align` | `CSSProperties["alignItems"]` | — | Alignment across the direction – `alignItems` unchanged.<br>Shown in: [A row](#/stack-and-grid/a-row), [Gaps](#/stack-and-grid/gaps), [A tour summary](#/stack-and-grid/a-tour-summary) and 77 more |
4779
+ | `direction` | `"row" \| "column"` | `"column"` | Below one another or beside one another. Below is the direction content stands in anyway, without being asked.<br>Shown in: [A row](#/stack-and-grid/a-row), [Gaps](#/stack-and-grid/gaps), [Wrapping](#/stack-and-grid/wrapping) and 69 more |
4780
+ | `gap` | [`SpaceStep`](#type-SpaceStep)<br>`1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8` | `3` | Spacing as a step of the 4 px spacing steps (1–8).<br>Shown in: [A column](#/stack-and-grid/a-column), [A row](#/stack-and-grid/a-row), [Gaps](#/stack-and-grid/gaps) and 164 more |
4781
+ | `align` | `CSSProperties["alignItems"]` | — | Alignment across the direction – `alignItems` unchanged.<br>Shown in: [A row](#/stack-and-grid/a-row), [Gaps](#/stack-and-grid/gaps), [A tour summary](#/stack-and-grid/a-tour-summary) and 78 more |
4780
4782
  | `justify` | `CSSProperties["justifyContent"]` | — | Distribution along the direction – `justifyContent` unchanged.<br>Shown in: [A row](#/stack-and-grid/a-row), [A tour summary](#/stack-and-grid/a-tour-summary), [Name the same action in every row (VisuallyHidden)](#/visuallyhidden/actions-in-rows) and 9 more |
4781
4783
  | `wrap` | `boolean` | `false` | Lets the children wrap when the line does not suffice.<br>Shown in: [Gaps](#/stack-and-grid/gaps), [Wrapping](#/stack-and-grid/wrapping), [Sized to the value (Sizes)](#/sizes/sized-to-the-value) and 32 more |
4782
4784
  | `ref` | `Ref<HTMLDivElement>` | — | Receives the component's root element. From `RefProp`.<br>Shown in: [A row that holds still (Sizes)](#/sizes/a-row-that-holds-still), [An anchored surface (Popover)](#/popover/anchored-surface), [Take the width of the trigger (Popover)](#/popover/width-from-anchor) and 2 more |
@@ -8698,7 +8700,7 @@ export default function SettingsOfAService() {
8698
8700
 
8699
8701
  | Prop | Type | Default | Description |
8700
8702
  |---|---|---|---|
8701
- | `label` | `ReactNode` | — | Label to the right of the switch.<br>Shown in: [Configurator](#/switch/configurator-switch), [On and off](#/switch/on-and-off), [States and sizes](#/switch/states-and-sizes) and 12 more |
8703
+ | `label` | `ReactNode` | — | Label to the right of the switch.<br>Shown in: [Configurator](#/switch/configurator-switch), [On and off](#/switch/on-and-off), [States and sizes](#/switch/states-and-sizes) and 13 more |
8702
8704
  | `size` | `"sm" \| "md"` | the size of a `ControlSizeProvider` around it, else `"md"` | `sm` for a toolbar and dense forms, `md` otherwise.<br>Shown in: [Configurator](#/switch/configurator-switch), [States and sizes](#/switch/states-and-sizes) |
8703
8705
  | `invalid` | `boolean` | — | Marks the switch as invalid. `FormField` sets it itself as soon as it carries an `error` - by hand only necessary without `FormField`.<br>Shown in: [Configurator](#/switch/configurator-switch), [With an error](#/switch/with-an-error) |
8704
8706
  | `ref` | `Ref<HTMLInputElement>` | — | Receives the component's root element. From `RefProp`.<br>Shown in: [A row that holds still (Sizes)](#/sizes/a-row-that-holds-still), [An anchored surface (Popover)](#/popover/anchored-surface), [Take the width of the trigger (Popover)](#/popover/width-from-anchor) and 2 more |
@@ -11692,6 +11694,8 @@ Demo page: https://romanhaendler.github.io/umriss-ui/core/toast/
11692
11694
 
11693
11695
  Toasts stand above an open modal dialog and can be used there: they are seen, pressed and heard, and stay where they were while a dialog opens or closes.
11694
11696
 
11697
+ `held` on the `ToastProvider` holds them back while a surface they must not cover is open: none is seen or heard, their time stands still, and they come back with the time they had left, so nothing is lost.
11698
+
11695
11699
  A toast stays five seconds by default. Its clock stops while the deck is open – under the pointer, with the focus inside it – and runs on with the time that was left.
11696
11700
 
11697
11701
  The title says what has happened, in about one line: “Invoice not sent”. Why, and what to do next, go in the description.
@@ -11700,7 +11704,7 @@ Nothing that must be read goes in a toast: whoever looked elsewhere has missed i
11700
11704
 
11701
11705
  Several toasts stand as a deck: the newest in front, a count on it, two edges behind it. It opens under the pointer, on the count, with the focus inside it, or with Alt+T; Escape gives the focus back.
11702
11706
 
11703
- At most three stand at once (`toast.limit` in the [UmrissProvider](#/umrissprovider)); the oldest gives way to a new one, as if closed.
11707
+ At most three that leave by themselves stand at once (`toast.limit` in the [UmrissProvider](#/umrissprovider)); the oldest of them gives way to a new one, as if closed. A toast with `duration: 0` and a `loading` toast never give way and do not count.
11704
11708
 
11705
11709
  #### Examples
11706
11710
 
@@ -11709,7 +11713,7 @@ At most three stand at once (`toast.limit` in the [UmrissProvider](#/umrissprovi
11709
11713
  Call `toast()` from [`useToast`](#/api/useToast) with what has happened; a `ToastProvider` at the root of the application holds them.
11710
11714
 
11711
11715
  ```tsx
11712
- import { Button, ToastProvider, useToast } from "@umriss-ui/core";
11716
+ import { Button, useToast } from "@umriss-ui/core";
11713
11717
 
11714
11718
  function Content() {
11715
11719
  const { toast } = useToast();
@@ -11724,11 +11728,7 @@ function Content() {
11724
11728
  /* `useToast` needs a `ToastProvider` above it; at the root of an application
11725
11729
  one provider serves every screen. */
11726
11730
  export default function ShowAToast() {
11727
- return (
11728
- <ToastProvider>
11729
- <Content />
11730
- </ToastProvider>
11731
- );
11731
+ return <Content />;
11732
11732
  }
11733
11733
  ```
11734
11734
 
@@ -11737,7 +11737,7 @@ export default function ShowAToast() {
11737
11737
  The `tone` says how it turned out; a symbol and the words say the same, so the colour is never alone.
11738
11738
 
11739
11739
  ```tsx
11740
- import { Button, Stack, ToastProvider, useToast } from "@umriss-ui/core";
11740
+ import { Button, Stack, useToast } from "@umriss-ui/core";
11741
11741
 
11742
11742
  function Content() {
11743
11743
  const { toast } = useToast();
@@ -11760,11 +11760,7 @@ function Content() {
11760
11760
  /* `useToast` needs a `ToastProvider` above it; at the root of an application
11761
11761
  one provider serves every screen. */
11762
11762
  export default function Tones() {
11763
- return (
11764
- <ToastProvider>
11765
- <Content />
11766
- </ToastProvider>
11767
- );
11763
+ return <Content />;
11768
11764
  }
11769
11765
  ```
11770
11766
 
@@ -11774,7 +11770,7 @@ One `action` reverses what just happened; `onClose` says whether the time ran ou
11774
11770
 
11775
11771
  ```tsx
11776
11772
  import { useState } from "react";
11777
- import { Button, Stack, Text, ToastProvider, useToast } from "@umriss-ui/core";
11773
+ import { Button, Stack, Text, useToast } from "@umriss-ui/core";
11778
11774
  import type { ToastCloseReason } from "@umriss-ui/core";
11779
11775
 
11780
11776
  const BOOKINGS = ["Room 2.14 · Tue 10:00 · Design review", "Room 3.02 · Tue 14:00 · Quarterly planning", "Room 1.05 · Wed 09:30 · Onboarding"];
@@ -11825,11 +11821,7 @@ function Content() {
11825
11821
  /* `useToast` needs a `ToastProvider` above it; at the root of an application
11826
11822
  one provider serves every screen. */
11827
11823
  export default function Undo() {
11828
- return (
11829
- <ToastProvider>
11830
- <Content />
11831
- </ToastProvider>
11832
- );
11824
+ return <Content />;
11833
11825
  }
11834
11826
  ```
11835
11827
 
@@ -11838,7 +11830,7 @@ export default function Undo() {
11838
11830
  `duration: 0` keeps a toast until the reader closes it – for the rare message whose loss costs something.
11839
11831
 
11840
11832
  ```tsx
11841
- import { Button, ToastProvider, useToast } from "@umriss-ui/core";
11833
+ import { Button, useToast } from "@umriss-ui/core";
11842
11834
 
11843
11835
  function Content() {
11844
11836
  const { toast } = useToast();
@@ -11862,11 +11854,7 @@ function Content() {
11862
11854
  /* `useToast` needs a `ToastProvider` above it; at the root of an application
11863
11855
  one provider serves every screen. */
11864
11856
  export default function UntilClosed() {
11865
- return (
11866
- <ToastProvider>
11867
- <Content />
11868
- </ToastProvider>
11869
- );
11857
+ return <Content />;
11870
11858
  }
11871
11859
  ```
11872
11860
 
@@ -11876,7 +11864,7 @@ A `loading` toast shows a spinner, has no close button and does not leave by its
11876
11864
 
11877
11865
  ```tsx
11878
11866
  import { useEffect, useRef, useState } from "react";
11879
- import { Button, Stack, Switch, ToastProvider, useToast } from "@umriss-ui/core";
11867
+ import { Button, Stack, Switch, useToast } from "@umriss-ui/core";
11880
11868
 
11881
11869
  function Content() {
11882
11870
  const { toast, update } = useToast();
@@ -11918,11 +11906,7 @@ function Content() {
11918
11906
  /* `useToast` needs a `ToastProvider` above it; at the root of an application
11919
11907
  one provider serves every screen. */
11920
11908
  export default function SaveWithLoading() {
11921
- return (
11922
- <ToastProvider>
11923
- <Content />
11924
- </ToastProvider>
11925
- );
11909
+ return <Content />;
11926
11910
  }
11927
11911
  ```
11928
11912
 
@@ -11932,7 +11916,7 @@ The row changes where the reader looks; the toast confirms it in passing, so a s
11932
11916
 
11933
11917
  ```tsx
11934
11918
  import { useState } from "react";
11935
- import { Badge, Button, Stack, Text, ToastProvider, useToast } from "@umriss-ui/core";
11919
+ import { Badge, Button, Stack, Text, useToast } from "@umriss-ui/core";
11936
11920
 
11937
11921
  const INVOICES = [
11938
11922
  { id: "INV-26-0318", supplier: "Brandlow Office Supply", amount: "€ 1,965.84" },
@@ -11981,11 +11965,7 @@ function Content() {
11981
11965
  /* `useToast` needs a `ToastProvider` above it; at the root of an application
11982
11966
  one provider serves every screen. */
11983
11967
  export default function AfterAnAction() {
11984
- return (
11985
- <ToastProvider>
11986
- <Content />
11987
- </ToastProvider>
11988
- );
11968
+ return <Content />;
11989
11969
  }
11990
11970
  ```
11991
11971
 
@@ -12044,20 +12024,23 @@ export default function WhereTheyStand() {
12044
12024
 
12045
12025
  ##### How many stand at once
12046
12026
 
12047
- `toast.limit` in the `UmrissProvider` caps the deck: here two stand, and each new toast pushes out the oldest as if it had been closed. Scan four parcels in a row and only the last two remain.
12027
+ `toast.limit` in the `UmrissProvider` caps the toasts that leave by themselves: here two stand, and each new one pushes out the oldest of them as if it had been closed. Scan four parcels in a row and only the last two remain.
12048
12028
 
12049
12029
  ```tsx
12050
12030
  import { Button, ToastProvider, UmrissProvider, useToast, type ToastConfig } from "@umriss-ui/core";
12051
12031
 
12032
+ type ToastFn = ReturnType<typeof useToast>["toast"];
12033
+
12052
12034
  const PARCELS = ["FP-2081", "FP-2082", "FP-2083", "FP-2084"];
12053
12035
 
12036
+ function scan(toast: ToastFn) {
12037
+ PARCELS.forEach((parcel) => toast({ title: `Parcel ${parcel} scanned`, description: "Loaded onto tour T-03.", tone: "success" }));
12038
+ }
12039
+
12054
12040
  function ScanButton() {
12055
12041
  const { toast } = useToast();
12056
12042
  return (
12057
- <Button
12058
- variant="primary"
12059
- onClick={() => PARCELS.forEach((parcel) => toast({ title: `Parcel ${parcel} scanned`, description: "Loaded onto tour T-03.", tone: "success" }))}
12060
- >
12043
+ <Button variant="primary" onClick={() => scan(toast)}>
12061
12044
  Scan four parcels
12062
12045
  </Button>
12063
12046
  );
@@ -12084,7 +12067,7 @@ A toast stands above an open modal dialog and can be pressed there: the dialog's
12084
12067
 
12085
12068
  ```tsx
12086
12069
  import { useState } from "react";
12087
- import { Button, FormField, Input, Modal, ModalBody, ModalFooter, ModalHeader, Select, Text, ToastProvider, Tooltip, useToast } from "@umriss-ui/core";
12070
+ import { Button, FormField, Input, Modal, ModalBody, ModalFooter, ModalHeader, Select, Text, Tooltip, useToast } from "@umriss-ui/core";
12088
12071
 
12089
12072
  function Content() {
12090
12073
  const { toast } = useToast();
@@ -12138,9 +12121,35 @@ function Content() {
12138
12121
  }
12139
12122
 
12140
12123
  export default function InsideAModal() {
12124
+ return <Content />;
12125
+ }
12126
+ ```
12127
+
12128
+ ##### Hold the toasts
12129
+
12130
+ `held` on the `ToastProvider` keeps every toast out of sight and hearing while a surface is open that they must not cover and there is no room beside it. Their time stands still, a new one waits, and when the hold ends they come back with the time they had left: nothing is lost, as it would be by dismissing them.
12131
+
12132
+ ```tsx
12133
+ import { useState } from "react";
12134
+ import { Button, Stack, Switch, ToastProvider, useToast } from "@umriss-ui/core";
12135
+
12136
+ function SendButton() {
12137
+ const { toast } = useToast();
12141
12138
  return (
12142
- <ToastProvider>
12143
- <Content />
12139
+ <Button onClick={() => toast({ title: "Route T-03 planned", description: "12 stops, back by 16:40.", tone: "success" })}>
12140
+ Send a toast
12141
+ </Button>
12142
+ );
12143
+ }
12144
+
12145
+ export default function HoldTheToasts() {
12146
+ const [held, setHeld] = useState(false);
12147
+ return (
12148
+ <ToastProvider held={held}>
12149
+ <Stack direction="row" gap={4} align="center">
12150
+ <Switch label="Hold the toasts" checked={held} onChange={(event) => setHeld(event.target.checked)} />
12151
+ <SendButton />
12152
+ </Stack>
12144
12153
  </ToastProvider>
12145
12154
  );
12146
12155
  }
@@ -12155,7 +12164,7 @@ export default function InsideAModal() {
12155
12164
 
12156
12165
  | Key | Action |
12157
12166
  |---|---|
12158
- | `Alt + T` | While a toast stands, moves the focus into the messages and opens the deck. |
12167
+ | `Alt + T` | While a toast stands and is not held back, moves the focus into the messages and opens the deck. |
12159
12168
  | `Tab / Shift + Tab` | Moves through the toasts' actions and close crosses; a keyboard focus inside opens the deck and holds every toast's clock. |
12160
12169
  | `Enter / Space` | On an action, runs it and closes its toast; on a cross, closes the toast. |
12161
12170
  | `Escape` | Closes the deck; after Alt + T, the focus goes back to where it was. |
@@ -12178,9 +12187,9 @@ Inside a modal dialog the live regions move with the toasts, so a message is hea
12178
12187
 
12179
12188
  | Prop | Type | Default | Description |
12180
12189
  |---|---|---|---|
12181
- | `title` *required* | `string` | — | What has happened – short, about one line (some 45 characters), in the perfect tense and not a request: "Invoice not sent". Why, and what to do next, belong in the description. A longer title wraps; it is never cut.<br>Shown in: [Show a toast](#/toast/show-a-toast), [Tones](#/toast/tones), [Undo](#/toast/undo) and 12 more |
12182
- | `description` | `string` | — | One more sentence where the title alone is too little. Nothing the reader MUST read: the toast goes away by itself.<br>Shown in: [Show a toast](#/toast/show-a-toast), [Tones](#/toast/tones), [Undo](#/toast/undo) and 10 more |
12183
- | `tone` | [`ToastTone`](#type-ToastTone)<br>`"neutral" \| "success" \| "warning" \| "danger" \| "loading"` | — | How the message turns out. The tone is never the only information – the glyph beside it and the text say the same thing once more. `loading` shows a spinner, has no close button and does not leave by itself: turn it into its outcome with `update`.<br>Shown in: [Tones](#/toast/tones), [Keep it until it is closed](#/toast/until-closed), [Save, and say how it went](#/toast/save-with-loading) and 9 more |
12190
+ | `title` *required* | `string` | — | What has happened – short, about one line (some 45 characters), in the perfect tense and not a request: "Invoice not sent". Why, and what to do next, belong in the description. A longer title wraps; it is never cut.<br>Shown in: [Show a toast](#/toast/show-a-toast), [Tones](#/toast/tones), [Undo](#/toast/undo) and 13 more |
12191
+ | `description` | `string` | — | One more sentence where the title alone is too little. Nothing the reader MUST read: the toast goes away by itself.<br>Shown in: [Show a toast](#/toast/show-a-toast), [Tones](#/toast/tones), [Undo](#/toast/undo) and 11 more |
12192
+ | `tone` | [`ToastTone`](#type-ToastTone)<br>`"neutral" \| "success" \| "warning" \| "danger" \| "loading"` | — | How the message turns out. The tone is never the only information – the glyph beside it and the text say the same thing once more. `loading` shows a spinner, has no close button and does not leave by itself: turn it into its outcome with `update`.<br>Shown in: [Tones](#/toast/tones), [Keep it until it is closed](#/toast/until-closed), [Save, and say how it went](#/toast/save-with-loading) and 10 more |
12184
12193
  | `duration` | `number` | the provider's `duration`, else `5000` | Display duration in ms; 0 = stays until closed by hand.<br>Shown in: [Keep it until it is closed](#/toast/until-closed), [Inside a modal](#/toast/inside-a-modal) |
12185
12194
  | `action` | [`ToastAction`](#type-ToastAction) | — | One action - "Undo". Never the only way to do what it offers: the toast leaves by itself, and not everybody reaches it in time. More than one action is a dialog.<br>Shown in: [Undo](#/toast/undo), [Save, and say how it went](#/toast/save-with-loading), [Inside a modal](#/toast/inside-a-modal) |
12186
12195
 
@@ -12225,7 +12234,8 @@ type ToastCloseReason = "timeout" | "dismiss" | "action";
12225
12234
 
12226
12235
  - One action at most, and never the only way to what it offers: the toast leaves by itself. What needs a decision needs an [Alert](#/alert) or a [ConfirmDialog](#/confirmdialog).
12227
12236
  - One position for the whole application, set in the [UmrissProvider](#/umrissprovider); none per toast.
12228
- - No queue: a toast over the limit pushes the oldest out rather than waiting.
12237
+ - One `ToastProvider` per application, at its root. A second one in the same document draws a second deck at the same place and the two lie on each other; in development it is reported on the console.
12238
+ - No queue: a toast over the limit pushes the oldest timed one out rather than waiting. Lasting and `loading` toasts are not capped: the deck holds every one of them beside the timed ones.
12229
12239
  - Without the Popover API the deck moves with a dialog that transforms itself: inside a dialog the toasts stand in the top layer only where the browser has it, and elsewhere they are a fixed box in the dialog.
12230
12240
 
12231
12241
  What umriss deliberately does not build, and why: [ADR-0032](https://romanhaendler.github.io/umriss-ui/what-umriss-ui-is-not/).
@@ -18709,13 +18719,12 @@ Used on [Scenarios](#/), [Sizes](#/sizes), [Textarea](#/textarea) and [CommandPa
18709
18719
  ##### `ToastProvider`
18710
18720
 
18711
18721
  Holds the toasts and draws them; [`useToast`](#/api/useToast) works only below it. Put it
18712
- once at the root of the application. Duration, position and limit come from
18713
- `UmrissProvider`'s `toast` where one stands around it.
18722
+ once at the root of the application: a second one draws a second deck at
18723
+ the same place, and the two lie on each other. Duration, position and limit
18724
+ come from `UmrissProvider`'s `toast` where one stands around it.
18714
18725
 
18715
18726
  ```ts
18716
- function ToastProvider({ children }: {
18717
- children: ReactNode;
18718
- }): import("react").JSX.Element;
18727
+ function ToastProvider({ children, held }: ToastProviderProps): import("react").JSX.Element;
18719
18728
  ```
18720
18729
 
18721
18730
  Used on [Scenarios](#/), [UmrissProvider](#/umrissprovider) and [Toast](#/toast).
@@ -19918,6 +19927,15 @@ type ToastPosition = "top-start" | "top-center" | "top-end" | "bottom-start" | "
19918
19927
 
19919
19928
  Used on [Toast](#/toast).
19920
19929
 
19930
+ ##### `ToastProviderProps`
19931
+
19932
+ The props of `ToastProvider`.
19933
+
19934
+ | Prop | Type | Default | Description |
19935
+ |---|---|---|---|
19936
+ | `children` *required* | `ReactNode` | — | <br>Shown in: [Resolve an incident (Scenarios)](#/scenarios/resolve-an-incident), [Approve spending against a budget (Scenarios)](#/scenarios/approve-spending), [Set up a team (Scenarios)](#/scenarios/set-up-a-team) |
19937
+ | `held` | `boolean` | `false` | While true, the toasts are held back: none is seen or heard, no time runs out, and a new one waits. When false again they come back with the time they had left. For a surface the toasts must not cover for a while, where there is no room beside it: nothing is lost, as it would be by dismissing.<br>Shown in: [Hold the toasts (Toast)](#/toast/hold-the-toasts) |
19938
+
19921
19939
  ##### `ToastTone`
19922
19940
 
19923
19941
  How the message turns out; `loading` is a toast still at work.
@@ -20395,8 +20413,8 @@ Used on [UmrissProvider](#/umrissprovider) and [Language](#/language).
20395
20413
 
20396
20414
  | Prop | Type | Default | Description |
20397
20415
  |---|---|---|---|
20398
- | `toast` *required* | `(options: `[`ToastOptions`](#/toast/type-ToastOptions)`) => number` | — | Shows a toast and returns its id.<br>Shown in: [At the root (UmrissProvider)](#/umrissprovider/at-the-root), [Set up an application (UmrissProvider)](#/umrissprovider/everything-at-once), [Show a toast (Toast)](#/toast/show-a-toast) and 12 more |
20399
- | `update` *required* | `(id: number, options: Partial<`[`ToastOptions`](#/toast/type-ToastOptions)`>) => void` | — | Changes a standing toast. A new tone or a new `duration` starts its time afresh - so a `loading` toast turned into `success` begins to count then. An id that no longer stands is ignored: a toast that gave way to newer ones - a `loading` one too - has said so through `onClose`.<br>Shown in: [Save, and say how it went (Toast)](#/toast/save-with-loading) |
20416
+ | `toast` *required* | `(options: `[`ToastOptions`](#/toast/type-ToastOptions)`) => number` | — | Shows a toast and returns its id.<br>Shown in: [Show a toast (Toast)](#/toast/show-a-toast), [Tones (Toast)](#/toast/tones), [Undo (Toast)](#/toast/undo) and 10 more |
20417
+ | `update` *required* | `(id: number, options: Partial<`[`ToastOptions`](#/toast/type-ToastOptions)`>) => void` | — | Changes a standing toast. A new tone or a new `duration` starts its time afresh - so a `loading` toast turned into `success` begins to count then. An id that no longer stands is ignored: a timed toast that gave way to newer ones has said so through `onClose`. A `loading` toast turned into its outcome counts toward the limit from the next arrival on; `update` itself pushes nothing out.<br>Shown in: [Save, and say how it went (Toast)](#/toast/save-with-loading) |
20400
20418
  | `dismiss` *required* | `(id: number) => void` | — | Closes a toast, with the reason `dismiss`. |
20401
20419
 
20402
20420
  ##### `Instant`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umriss-ui/core",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "description": "React component library for data-dense dashboards and tools - forms, date pickers, overlays, a tree view and a command palette. Precise, quiet, professional.",
5
5
  "license": "MIT",
6
6
  "author": "Roman Händler",