@umriss-ui/core 0.14.1 → 0.16.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/de.d.ts CHANGED
@@ -424,6 +424,10 @@ declare interface Wording {
424
424
  columnAvailability: string;
425
425
  close: string;
426
426
  closeToast: string;
427
+ /** The count on the front toast of a closed deck; pressing it shows them all. */
428
+ toastDeckCount: (count: number) => string;
429
+ /** The name of the toasts' region, which Alt+T moves the focus into. */
430
+ toastRegion: string;
427
431
  confirm: string;
428
432
  cancel: string;
429
433
  loading: string;
package/dist/index.d.ts CHANGED
@@ -1824,34 +1824,74 @@ declare type TextTracking = "normal" | "tight" | "display" | "caps";
1824
1824
 
1825
1825
  export declare type TextWeight = "regular" | "medium" | "semibold";
1826
1826
 
1827
+ export declare interface ToastAction {
1828
+ /** A verb for what it does - "Undo", "Show". */
1829
+ label: string;
1830
+ /** Runs, and the toast goes with the reason `action`. */
1831
+ onClick: () => void;
1832
+ }
1833
+
1834
+ /** Why a toast went: its time ran out, it was closed (or gave way to a newer
1835
+ one), or its action was taken. */
1836
+ export declare type ToastCloseReason = "timeout" | "dismiss" | "action";
1837
+
1827
1838
  export declare interface ToastConfig {
1828
1839
  /** Display duration in ms, where the individual toast names none. */
1829
1840
  duration?: number;
1841
+ /** Where the toasts stand. Default: `bottom-end`. There is no position per
1842
+ toast - toasts that stand in different places are not read as one. */
1843
+ position?: ToastPosition;
1844
+ /** How many toasts stand at once; the oldest gives way to a new one, as if
1845
+ it had been closed. Default: 3. */
1846
+ limit?: number;
1830
1847
  }
1831
1848
 
1832
1849
  declare interface ToastContextValue {
1850
+ /** Shows a toast and returns its id. */
1833
1851
  toast: (options: ToastOptions) => number;
1852
+ /** Changes a standing toast. A new tone or a new `duration` starts its time
1853
+ afresh - so a `loading` toast turned into `success` begins to count then.
1854
+ An id that no longer stands is ignored: a toast that gave way to newer
1855
+ ones - a `loading` one too - has said so through `onClose`. */
1856
+ update: (id: number, options: Partial<ToastOptions>) => void;
1857
+ /** Closes a toast, with the reason `dismiss`. */
1834
1858
  dismiss: (id: number) => void;
1835
1859
  }
1836
1860
 
1837
1861
  export declare interface ToastOptions {
1838
- /** What has happened – a sentence in the perfect tense, not a request. */
1862
+ /** What has happened – short, about one line (some 45 characters), in the
1863
+ perfect tense and not a request: "Invoice not sent". Why, and
1864
+ what to do next, belong in the description. A longer title wraps; it is
1865
+ never cut. */
1839
1866
  title: string;
1840
1867
  /** One more sentence where the title alone is too little. Nothing the
1841
1868
  reader MUST read: the toast goes away by itself. */
1842
1869
  description?: string;
1843
1870
  /** How the message turns out. The tone is never the only information – the
1844
- symbol beside it and the text say the same thing once more. */
1871
+ glyph beside it and the text say the same thing once more. `loading`
1872
+ shows a spinner, has no close button and does not leave by itself: turn
1873
+ it into its outcome with `update`. */
1845
1874
  tone?: ToastTone;
1846
1875
  /** Display duration in ms; 0 = stays until closed by hand. Default: 5000. */
1847
1876
  duration?: number;
1877
+ /** One action - "Undo". Never the only way to do what it offers: the toast
1878
+ leaves by itself, and not everybody reaches it in time. More than one
1879
+ action is a dialog. */
1880
+ action?: ToastAction;
1881
+ /** Called once when the toast goes, with the reason. */
1882
+ onClose?: (reason: ToastCloseReason) => void;
1848
1883
  }
1849
1884
 
1885
+ /** Where the toasts stand: an edge of the window and a place along it. On a
1886
+ phone they take the width of the window, and only the edge counts. */
1887
+ export declare type ToastPosition = "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end";
1888
+
1850
1889
  export declare function ToastProvider({ children }: {
1851
1890
  children: ReactNode;
1852
1891
  }): JSX.Element;
1853
1892
 
1854
- export declare type ToastTone = "neutral" | "success" | "warning" | "danger";
1893
+ /** How the message turns out; `loading` is a toast still at work. */
1894
+ export declare type ToastTone = "neutral" | "success" | "warning" | "danger" | "loading";
1855
1895
 
1856
1896
  /** Everything checkable on - or empty, if everything is on already. */
1857
1897
  export declare function toggleAll<K, S extends Key = string>(roots: readonly K[], reader: NodeReader<K, S>, snapshot: TreeSnapshot<S>): TreeSnapshot<S>;
@@ -2047,7 +2087,7 @@ export declare function UmrissProvider({ density, portalTarget, toast, language,
2047
2087
  export declare interface UmrissProviderProps {
2048
2088
  /**
2049
2089
  * The default for the `density` of every component that reads it with
2050
- * `useDensityFor` - in @umriss-ui/table `Table` and `AlarmList`
2090
+ * `useDensityFor` - in `@umriss-ui/table` `Table` and `AlarmList`
2051
2091
  * ("comfortable" means "regular"). Without a value the provider touches no
2052
2092
  * component: one that is compact of its own accord stays compact.
2053
2093
  */
@@ -2061,7 +2101,7 @@ export declare interface UmrissProviderProps {
2061
2101
  */
2062
2102
  portalTarget?: PortalTarget;
2063
2103
  /** The setting for toasts: the display duration where the individual toast
2064
- names none. */
2104
+ names none, where they stand, and how many stand at once. */
2065
2105
  toast?: ToastConfig;
2066
2106
  /** Formats and wording, entry by entry. See `lib/language`. */
2067
2107
  language?: LanguageOptions;
@@ -2119,7 +2159,7 @@ export declare const useLanguage: () => Language;
2119
2159
  */
2120
2160
  export declare function usePortalTarget(): () => HTMLElement | null;
2121
2161
 
2122
- /** Access to `toast()` and `dismiss()`; requires a ToastProvider. */
2162
+ /** Access to `toast()`, `update()` and `dismiss()`; requires a ToastProvider. */
2123
2163
  export declare function useToast(): ToastContextValue;
2124
2164
 
2125
2165
  /** The setting for toasts; without a provider, empty. */
@@ -2606,6 +2646,10 @@ export declare interface Wording {
2606
2646
  columnAvailability: string;
2607
2647
  close: string;
2608
2648
  closeToast: string;
2649
+ /** The count on the front toast of a closed deck; pressing it shows them all. */
2650
+ toastDeckCount: (count: number) => string;
2651
+ /** The name of the toasts' region, which Alt+T moves the focus into. */
2652
+ toastRegion: string;
2609
2653
  confirm: string;
2610
2654
  cancel: string;
2611
2655
  loading: string;
@@ -231,6 +231,8 @@ const c = o("de-DE"), s = {
231
231
  columnAvailability: "Verfügbarkeit",
232
232
  close: "Schließen",
233
233
  closeToast: "Meldung schließen",
234
+ toastDeckCount: (e) => `${e} Meldungen, alle zeigen`,
235
+ toastRegion: "Meldungen (Alt+T)",
234
236
  confirm: "Bestätigen",
235
237
  cancel: "Abbrechen",
236
238
  loading: "Wird geladen",