@umriss-ui/core 0.15.0 → 0.17.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
@@ -170,7 +170,8 @@ export declare interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement>
170
170
 
171
171
  export declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
172
172
  /** How loud the button is. `primary` exactly once per surface - two main
173
- actions side by side are no longer a main action. */
173
+ actions side by side are no longer a main action. `ghost` is quiet in the
174
+ accent, `plain` quiet and neutral. */
174
175
  variant?: ButtonVariant;
175
176
  /** `sm` for buttons in header bars and table rows, `md` otherwise. */
176
177
  size?: ButtonSize;
@@ -180,7 +181,7 @@ export declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElem
180
181
 
181
182
  export declare type ButtonSize = "sm" | "md";
182
183
 
183
- export declare type ButtonVariant = "primary" | "secondary" | "ghost" | "danger";
184
+ export declare type ButtonVariant = "primary" | "secondary" | "ghost" | "plain" | "danger";
184
185
 
185
186
  /**
186
187
  * The cadence at which a display has to re-judge itself, in milliseconds -
@@ -936,6 +937,22 @@ export declare interface HeadingProps extends HTMLAttributes<HTMLHeadingElement>
936
937
  tone?: TextTone;
937
938
  }
938
939
 
940
+ /** A button that shows only an icon: square, named by its `aria-label`, and
941
+ that name shown as a tooltip. Everything else is a `Button`'s. */
942
+ export declare const IconButton: ForwardRefExoticComponent<IconButtonProps & RefAttributes<HTMLButtonElement>>;
943
+
944
+ export declare interface IconButtonProps extends Omit<ButtonProps, "aria-label" | "aria-labelledby" | "title" | "children"> {
945
+ /** The name: what a screen reader announces and the tooltip shows. Required -
946
+ an icon alone names nothing. */
947
+ "aria-label": string;
948
+ /** The icon: an SVG, a glyph of the set or an icon font's element. The
949
+ button sets its size - `--u-icon-size`, `--u-icon-size-sm` at `sm`. */
950
+ children: ReactNode;
951
+ /** How loud the button is; `plain` is quiet and neutral, and the rest mean
952
+ what they mean on a `Button`. Default: `plain` */
953
+ variant?: ButtonVariant;
954
+ }
955
+
939
956
  export declare const Input: ForwardRefExoticComponent<InputProps & RefAttributes<HTMLInputElement>>;
940
957
 
941
958
  export declare interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
@@ -1043,7 +1060,8 @@ export declare interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLBut
1043
1060
  }
1044
1061
 
1045
1062
  export declare interface MenuProps {
1046
- /** Trigger, e.g. a <Button>; must accept refs. */
1063
+ /** Trigger, e.g. a <Button>; must accept refs. Its own ref keeps its
1064
+ element: the menu holds the same one beside it. */
1047
1065
  trigger: ReactElement<Record<string, unknown>>;
1048
1066
  /** The entries – typically `MenuItem` and `MenuSeparator`. */
1049
1067
  children: ReactNode;
@@ -1824,34 +1842,74 @@ declare type TextTracking = "normal" | "tight" | "display" | "caps";
1824
1842
 
1825
1843
  export declare type TextWeight = "regular" | "medium" | "semibold";
1826
1844
 
1845
+ export declare interface ToastAction {
1846
+ /** A verb for what it does - "Undo", "Show". */
1847
+ label: string;
1848
+ /** Runs, and the toast goes with the reason `action`. */
1849
+ onClick: () => void;
1850
+ }
1851
+
1852
+ /** Why a toast went: its time ran out, it was closed (or gave way to a newer
1853
+ one), or its action was taken. */
1854
+ export declare type ToastCloseReason = "timeout" | "dismiss" | "action";
1855
+
1827
1856
  export declare interface ToastConfig {
1828
1857
  /** Display duration in ms, where the individual toast names none. */
1829
1858
  duration?: number;
1859
+ /** Where the toasts stand. Default: `bottom-end`. There is no position per
1860
+ toast - toasts that stand in different places are not read as one. */
1861
+ position?: ToastPosition;
1862
+ /** How many toasts stand at once; the oldest gives way to a new one, as if
1863
+ it had been closed. Default: 3. */
1864
+ limit?: number;
1830
1865
  }
1831
1866
 
1832
1867
  declare interface ToastContextValue {
1868
+ /** Shows a toast and returns its id. */
1833
1869
  toast: (options: ToastOptions) => number;
1870
+ /** Changes a standing toast. A new tone or a new `duration` starts its time
1871
+ afresh - so a `loading` toast turned into `success` begins to count then.
1872
+ An id that no longer stands is ignored: a toast that gave way to newer
1873
+ ones - a `loading` one too - has said so through `onClose`. */
1874
+ update: (id: number, options: Partial<ToastOptions>) => void;
1875
+ /** Closes a toast, with the reason `dismiss`. */
1834
1876
  dismiss: (id: number) => void;
1835
1877
  }
1836
1878
 
1837
1879
  export declare interface ToastOptions {
1838
- /** What has happened – a sentence in the perfect tense, not a request. */
1880
+ /** What has happened – short, about one line (some 45 characters), in the
1881
+ perfect tense and not a request: "Invoice not sent". Why, and
1882
+ what to do next, belong in the description. A longer title wraps; it is
1883
+ never cut. */
1839
1884
  title: string;
1840
1885
  /** One more sentence where the title alone is too little. Nothing the
1841
1886
  reader MUST read: the toast goes away by itself. */
1842
1887
  description?: string;
1843
1888
  /** 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. */
1889
+ glyph beside it and the text say the same thing once more. `loading`
1890
+ shows a spinner, has no close button and does not leave by itself: turn
1891
+ it into its outcome with `update`. */
1845
1892
  tone?: ToastTone;
1846
1893
  /** Display duration in ms; 0 = stays until closed by hand. Default: 5000. */
1847
1894
  duration?: number;
1895
+ /** One action - "Undo". Never the only way to do what it offers: the toast
1896
+ leaves by itself, and not everybody reaches it in time. More than one
1897
+ action is a dialog. */
1898
+ action?: ToastAction;
1899
+ /** Called once when the toast goes, with the reason. */
1900
+ onClose?: (reason: ToastCloseReason) => void;
1848
1901
  }
1849
1902
 
1903
+ /** Where the toasts stand: an edge of the window and a place along it. On a
1904
+ phone they take the width of the window, and only the edge counts. */
1905
+ export declare type ToastPosition = "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end";
1906
+
1850
1907
  export declare function ToastProvider({ children }: {
1851
1908
  children: ReactNode;
1852
1909
  }): JSX.Element;
1853
1910
 
1854
- export declare type ToastTone = "neutral" | "success" | "warning" | "danger";
1911
+ /** How the message turns out; `loading` is a toast still at work. */
1912
+ export declare type ToastTone = "neutral" | "success" | "warning" | "danger" | "loading";
1855
1913
 
1856
1914
  /** Everything checkable on - or empty, if everything is on already. */
1857
1915
  export declare function toggleAll<K, S extends Key = string>(roots: readonly K[], reader: NodeReader<K, S>, snapshot: TreeSnapshot<S>): TreeSnapshot<S>;
@@ -1873,8 +1931,7 @@ export declare interface TooltipProps {
1873
1931
  /** Short help text; no interaction, no long content. */
1874
1932
  content: ReactNode;
1875
1933
  /** Exactly one element that triggers the tooltip (must accept refs). Its
1876
- own ref is replaced by the tooltip's: a trigger that needs its element
1877
- takes it from its events. */
1934
+ own ref keeps its element: the tooltip holds the same one beside it. */
1878
1935
  children: ReactElement<Record<string, unknown>>;
1879
1936
  /** Delay in ms before the tooltip appears. */
1880
1937
  delay?: number;
@@ -2047,7 +2104,7 @@ export declare function UmrissProvider({ density, portalTarget, toast, language,
2047
2104
  export declare interface UmrissProviderProps {
2048
2105
  /**
2049
2106
  * The default for the `density` of every component that reads it with
2050
- * `useDensityFor` - in @umriss-ui/table `Table` and `AlarmList`
2107
+ * `useDensityFor` - in `@umriss-ui/table` `Table` and `AlarmList`
2051
2108
  * ("comfortable" means "regular"). Without a value the provider touches no
2052
2109
  * component: one that is compact of its own accord stays compact.
2053
2110
  */
@@ -2061,7 +2118,7 @@ export declare interface UmrissProviderProps {
2061
2118
  */
2062
2119
  portalTarget?: PortalTarget;
2063
2120
  /** The setting for toasts: the display duration where the individual toast
2064
- names none. */
2121
+ names none, where they stand, and how many stand at once. */
2065
2122
  toast?: ToastConfig;
2066
2123
  /** Formats and wording, entry by entry. See `lib/language`. */
2067
2124
  language?: LanguageOptions;
@@ -2119,7 +2176,7 @@ export declare const useLanguage: () => Language;
2119
2176
  */
2120
2177
  export declare function usePortalTarget(): () => HTMLElement | null;
2121
2178
 
2122
- /** Access to `toast()` and `dismiss()`; requires a ToastProvider. */
2179
+ /** Access to `toast()`, `update()` and `dismiss()`; requires a ToastProvider. */
2123
2180
  export declare function useToast(): ToastContextValue;
2124
2181
 
2125
2182
  /** The setting for toasts; without a provider, empty. */
@@ -2606,6 +2663,10 @@ export declare interface Wording {
2606
2663
  columnAvailability: string;
2607
2664
  close: string;
2608
2665
  closeToast: string;
2666
+ /** The count on the front toast of a closed deck; pressing it shows them all. */
2667
+ toastDeckCount: (count: number) => string;
2668
+ /** The name of the toasts' region, which Alt+T moves the focus into. */
2669
+ toastRegion: string;
2609
2670
  confirm: string;
2610
2671
  cancel: string;
2611
2672
  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",