@sdxc/ui 2026.11.1 → 2026.11.4

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.
Files changed (192) hide show
  1. package/README.md +1 -1
  2. package/dist/app/app-shell-toggle.d.ts +31 -0
  3. package/dist/app/app-shell-toggle.js +43 -0
  4. package/dist/app/app-shell.d.ts +131 -0
  5. package/dist/app/app-shell.js +542 -0
  6. package/dist/app/auto-refresh.d.ts +104 -0
  7. package/dist/app/auto-refresh.js +126 -0
  8. package/dist/app/behaviors/refresh-schedule.d.ts +53 -0
  9. package/dist/app/behaviors/refresh-schedule.js +95 -0
  10. package/dist/app/behaviors/shortcuts.d.ts +175 -0
  11. package/dist/app/behaviors/shortcuts.js +401 -0
  12. package/dist/app/behaviors/toaster.d.ts +31 -2
  13. package/dist/app/behaviors/toaster.js +62 -5
  14. package/dist/app/chart.d.ts +62 -8
  15. package/dist/app/chart.js +207 -9
  16. package/dist/app/command-palette.d.ts +132 -0
  17. package/dist/app/command-palette.js +181 -0
  18. package/dist/app/danger-zone.d.ts +66 -0
  19. package/dist/app/danger-zone.js +66 -0
  20. package/dist/app/detail-sheet.d.ts +119 -0
  21. package/dist/app/detail-sheet.js +173 -0
  22. package/dist/app/drop-zone.d.ts +2 -1
  23. package/dist/app/drop-zone.js +6 -3
  24. package/dist/app/editor-layout.d.ts +69 -0
  25. package/dist/app/editor-layout.js +143 -0
  26. package/dist/app/empty.d.ts +56 -19
  27. package/dist/app/empty.js +129 -22
  28. package/dist/app/filter-bar.d.ts +169 -0
  29. package/dist/app/filter-bar.js +346 -0
  30. package/dist/app/index.d.ts +51 -0
  31. package/dist/app/index.js +51 -0
  32. package/dist/app/keyboard-help.d.ts +66 -0
  33. package/dist/app/keyboard-help.js +56 -0
  34. package/dist/app/mixins/app-shell-controls.d.ts +46 -0
  35. package/dist/app/mixins/app-shell-controls.js +131 -0
  36. package/dist/app/mixins/auto-refresh.d.ts +29 -0
  37. package/dist/app/mixins/auto-refresh.js +66 -0
  38. package/dist/app/mixins/command-palette.d.ts +56 -0
  39. package/dist/app/mixins/command-palette.js +297 -0
  40. package/dist/app/mixins/copy-permalink.d.ts +26 -0
  41. package/dist/app/mixins/copy-permalink.js +54 -0
  42. package/dist/app/mixins/detail-sheet-keys.d.ts +28 -0
  43. package/dist/app/mixins/detail-sheet-keys.js +88 -0
  44. package/dist/app/mixins/escape-link.d.ts +17 -0
  45. package/dist/app/mixins/escape-link.js +35 -0
  46. package/dist/app/mixins/keyboard-help.d.ts +38 -0
  47. package/dist/app/mixins/keyboard-help.js +51 -0
  48. package/dist/app/mixins/optimistic-toggle-sync.d.ts +80 -0
  49. package/dist/app/mixins/optimistic-toggle-sync.js +153 -0
  50. package/dist/app/mixins/range-picker-keys.d.ts +18 -0
  51. package/dist/app/mixins/range-picker-keys.js +94 -0
  52. package/dist/app/mixins/row-navigation.d.ts +85 -0
  53. package/dist/app/mixins/row-navigation.js +208 -0
  54. package/dist/app/mixins/save-bar-sync.d.ts +27 -0
  55. package/dist/app/mixins/save-bar-sync.js +106 -0
  56. package/dist/app/mixins/save-shortcut.d.ts +47 -0
  57. package/dist/app/mixins/save-shortcut.js +101 -0
  58. package/dist/app/mixins/save-status-sync.d.ts +77 -0
  59. package/dist/app/mixins/save-status-sync.js +159 -0
  60. package/dist/app/mixins/selection-bar-sync.d.ts +32 -0
  61. package/dist/app/mixins/selection-bar-sync.js +151 -0
  62. package/dist/app/mixins/split-view.d.ts +66 -0
  63. package/dist/app/mixins/split-view.js +319 -0
  64. package/dist/app/mixins/status-strip-keys.d.ts +17 -0
  65. package/dist/app/mixins/status-strip-keys.js +79 -0
  66. package/dist/app/mixins/submit-on-change.d.ts +16 -0
  67. package/dist/app/mixins/submit-on-change.js +28 -0
  68. package/dist/app/mixins/table-selection.d.ts +39 -0
  69. package/dist/app/mixins/table-selection.js +272 -0
  70. package/dist/app/mixins/toast-queue.d.ts +36 -0
  71. package/dist/app/mixins/toast-queue.js +77 -0
  72. package/dist/app/mixins/toast-stack.d.ts +20 -0
  73. package/dist/app/mixins/toast-stack.js +55 -0
  74. package/dist/app/optimistic-toggle.d.ts +48 -0
  75. package/dist/app/optimistic-toggle.js +38 -0
  76. package/dist/app/page-header.d.ts +71 -0
  77. package/dist/app/page-header.js +249 -0
  78. package/dist/app/range-picker.d.ts +102 -0
  79. package/dist/app/range-picker.js +118 -0
  80. package/dist/app/save-bar.d.ts +54 -0
  81. package/dist/app/save-bar.js +64 -0
  82. package/dist/app/save-status.d.ts +50 -0
  83. package/dist/app/save-status.js +54 -0
  84. package/dist/app/selection-bar.d.ts +101 -0
  85. package/dist/app/selection-bar.js +157 -0
  86. package/dist/app/settings-layout.d.ts +70 -0
  87. package/dist/app/settings-layout.js +112 -0
  88. package/dist/app/settings-section.d.ts +140 -0
  89. package/dist/app/settings-section.js +182 -0
  90. package/dist/app/skeleton.d.ts +47 -4
  91. package/dist/app/skeleton.js +149 -2
  92. package/dist/app/sparkline.d.ts +61 -0
  93. package/dist/app/sparkline.js +145 -0
  94. package/dist/app/split-view.d.ts +154 -0
  95. package/dist/app/split-view.js +272 -0
  96. package/dist/app/stat-card.d.ts +109 -0
  97. package/dist/app/stat-card.js +379 -0
  98. package/dist/app/status-strip.d.ts +70 -0
  99. package/dist/app/status-strip.js +155 -0
  100. package/dist/app/styles/action-row.d.ts +41 -0
  101. package/dist/app/styles/action-row.js +59 -0
  102. package/dist/app/styles/stat-delta.d.ts +29 -0
  103. package/dist/app/styles/stat-delta.js +36 -0
  104. package/dist/app/styles/toast-stack.d.ts +21 -0
  105. package/dist/app/styles/toast-stack.js +54 -0
  106. package/dist/app/table.d.ts +199 -24
  107. package/dist/app/table.js +640 -36
  108. package/dist/app/toast.d.ts +105 -5
  109. package/dist/app/toast.js +89 -17
  110. package/dist/app/toasts.d.ts +49 -0
  111. package/dist/app/toasts.js +103 -0
  112. package/dist/app/utils/app-shell-cookie.d.ts +21 -0
  113. package/dist/app/utils/app-shell-cookie.js +33 -0
  114. package/dist/app/utils/chart-marker-indices.d.ts +9 -5
  115. package/dist/app/utils/chart-marker-indices.js +9 -8
  116. package/dist/app/utils/chart-path.d.ts +14 -10
  117. package/dist/app/utils/chart-path.js +46 -18
  118. package/dist/app/utils/edited-time.d.ts +19 -0
  119. package/dist/app/utils/edited-time.js +35 -0
  120. package/dist/app/utils/key-target.d.ts +23 -0
  121. package/dist/app/utils/key-target.js +48 -0
  122. package/dist/app/utils/search-params.d.ts +69 -0
  123. package/dist/app/utils/search-params.js +132 -0
  124. package/dist/app/utils/shortcut-groups.d.ts +21 -0
  125. package/dist/app/utils/shortcut-groups.js +53 -0
  126. package/dist/app/utils/split-view-layout.d.ts +48 -0
  127. package/dist/app/utils/split-view-layout.js +71 -0
  128. package/dist/app/view-options.d.ts +99 -0
  129. package/dist/app/view-options.js +182 -0
  130. package/dist/components/banner.d.ts +61 -0
  131. package/dist/components/banner.js +101 -0
  132. package/dist/components/confirm.d.ts +54 -5
  133. package/dist/components/confirm.js +44 -5
  134. package/dist/components/group.d.ts +14 -0
  135. package/dist/components/group.js +66 -11
  136. package/dist/components/index.d.ts +5 -0
  137. package/dist/components/index.js +5 -0
  138. package/dist/components/input.js +9 -3
  139. package/dist/components/link-button.js +8 -2
  140. package/dist/components/property-list.d.ts +76 -0
  141. package/dist/components/property-list.js +175 -0
  142. package/dist/components/relative-time.d.ts +72 -0
  143. package/dist/components/relative-time.js +45 -0
  144. package/dist/components/status-dot.d.ts +62 -0
  145. package/dist/components/status-dot.js +99 -0
  146. package/dist/components/text-field.d.ts +17 -2
  147. package/dist/components/text-field.js +13 -4
  148. package/dist/components/timeline.d.ts +67 -0
  149. package/dist/components/timeline.js +159 -0
  150. package/dist/components/typeset.d.ts +2 -1
  151. package/dist/components/typeset.js +4 -1
  152. package/dist/docs/code-tabs-sync.d.ts +1 -1
  153. package/dist/docs/code-tabs-sync.js +2 -2
  154. package/dist/docs/copy-button.d.ts +1 -1
  155. package/dist/docs/copy-button.js +2 -2
  156. package/dist/docs/docs-feedback.d.ts +12 -0
  157. package/dist/docs/docs-feedback.js +4 -2
  158. package/dist/docs/docs-hub.js +4 -4
  159. package/dist/docs/docs-layout.d.ts +1 -1
  160. package/dist/docs/docs-layout.js +1 -1
  161. package/dist/docs/docs-nav-tools.d.ts +11 -5
  162. package/dist/docs/docs-nav-tools.js +5 -4
  163. package/dist/docs/docs-nav.d.ts +12 -5
  164. package/dist/docs/docs-nav.js +20 -8
  165. package/dist/docs/docs-pager.d.ts +5 -1
  166. package/dist/docs/docs-pager.js +7 -6
  167. package/dist/docs/mixins/docs-nav-tools.d.ts +3 -3
  168. package/dist/docs/mixins/docs-nav-tools.js +42 -17
  169. package/dist/docs/next-steps.js +3 -2
  170. package/dist/docs/page-actions.d.ts +1 -1
  171. package/dist/docs/page-actions.js +2 -2
  172. package/dist/docs/table-of-contents.d.ts +1 -1
  173. package/dist/docs/table-of-contents.js +2 -2
  174. package/dist/docs/utils/docs-filter.d.ts +26 -0
  175. package/dist/docs/utils/docs-filter.js +53 -0
  176. package/dist/mixins/confirm-phrase.d.ts +19 -0
  177. package/dist/mixins/confirm-phrase.js +56 -0
  178. package/dist/mixins/index.d.ts +2 -0
  179. package/dist/mixins/index.js +2 -0
  180. package/dist/mixins/viewer-time.d.ts +20 -0
  181. package/dist/mixins/viewer-time.js +40 -0
  182. package/dist/styles/index.d.ts +1 -0
  183. package/dist/styles/index.js +1 -0
  184. package/dist/styles/segmented-control.d.ts +49 -0
  185. package/dist/styles/segmented-control.js +71 -0
  186. package/dist/test/table.d.ts +65 -0
  187. package/dist/test/table.js +108 -0
  188. package/dist/utils/index.d.ts +1 -0
  189. package/dist/utils/index.js +1 -0
  190. package/dist/utils/relative-time.d.ts +44 -0
  191. package/dist/utils/relative-time.js +69 -0
  192. package/package.json +6 -6
@@ -1,13 +1,21 @@
1
1
  /**
2
- * A transient notification panel that floats above page content to report
3
- * the outcome of an action, colored by one of five semantic tones and
4
- * structured like an inline status panel: an optional leading icon or
5
- * loading graphic, a title/description block, and trailing actions.
2
+ * A transient notification panel reporting the outcome of an action, in one of
3
+ * five semantic tones, plus the region that stacks them and the page queue the
4
+ * `Toasts` island draws, shared by server flash toasts and client toasts alike.
6
5
  *
7
6
  * @author [Sergio Xalambrí](https://sergiodxa.com)
8
7
  * @copyright Sergio Xalambrí 2026
9
8
  */
10
9
  import type { Handle, Props as TagProps, RemixNode } from "remix/component";
10
+ import { Toaster } from "./behaviors/toaster.js";
11
+ /**
12
+ * How long a toast offering Undo stays, in milliseconds: long enough to read
13
+ * the outcome and reach the button, short enough that the change settles soon.
14
+ *
15
+ * @example
16
+ * pageToaster().add({ title: "Monitor deleted", action: { label: "Undo", onAction: restore } }, { duration: TOAST_UNDO_DURATION });
17
+ */
18
+ export declare const TOAST_UNDO_DURATION = 8000;
11
19
  /**
12
20
  * Prop types for {@link Toast} and its compound parts, including
13
21
  * {@link Toast.Region}.
@@ -106,8 +114,87 @@ export declare namespace Toast {
106
114
  interface RegionProps extends TagProps<"div"> {
107
115
  /** Corner of the viewport the stack renders in. Default: `"bottom-end"`. */
108
116
  placement?: Placement;
117
+ /**
118
+ * Most toasts shown at once; older ones wait out of sight until a newer
119
+ * one leaves. Default: `3`.
120
+ */
121
+ max?: number;
122
+ /**
123
+ * `"peek"` folds older toasts behind the newest, scaled to 0.95 and 0.9,
124
+ * and fans them out while the pointer or focus is on the stack; `"list"`
125
+ * always shows them one under another. Default: `"peek"`.
126
+ */
127
+ stack?: Stack;
109
128
  /** Every currently queued {@link Toast}. */
110
- children: RemixNode;
129
+ children?: RemixNode;
130
+ }
131
+ /** How {@link Toast.Region} lays out more than one toast. */
132
+ type Stack = "peek" | "list";
133
+ /**
134
+ * One toast as data, the shape {@link Toasts} draws and {@link pageToaster}
135
+ * queues. Copy reads as an outcome: "Monitor deleted", six words at most,
136
+ * and an error ends with its recovery step ("Couldn't save. Try again.").
137
+ */
138
+ interface Message {
139
+ /** Semantic tone. Default: `"neutral"`. */
140
+ color?: Color;
141
+ /** The outcome, as a noun and a past participle. */
142
+ title: string;
143
+ /** A second line, only when it adds something the title cannot. */
144
+ description?: string;
145
+ /** Draws a spinner in place of the icon while the work is still running. */
146
+ loading?: boolean;
147
+ /** One action: Undo for a reversible destructive change, Retry for a failure. */
148
+ action?: MessageAction;
149
+ }
150
+ /**
151
+ * The single action a {@link Message} offers. `form` posts from server
152
+ * HTML with or without JavaScript; `onAction` runs in the browser, after
153
+ * which the toast leaves.
154
+ */
155
+ interface MessageAction {
156
+ /** Visible label, a verb: "Undo", "Retry", "View". */
157
+ label: string;
158
+ /** Runs on click in the browser; a function survives only a client-side {@link Toaster.add}. */
159
+ onAction?: () => void;
160
+ /** Submits a form, so the action works from a server-rendered flash toast. */
161
+ form?: MessageForm;
162
+ }
163
+ /** The form a {@link MessageAction} submits. */
164
+ interface MessageForm {
165
+ /** URL the form submits to. */
166
+ action: string;
167
+ /** Default: `"post"`. */
168
+ method?: "get" | "post";
169
+ /** Hidden fields sent with it, such as the id of the record to restore. */
170
+ fields?: Record<string, string>;
171
+ }
172
+ /**
173
+ * A toast the server rendered from a session flash. The `id` keys the
174
+ * element the browser adopts on hydration, so it must be stable within
175
+ * the response and safe inside an HTML id.
176
+ */
177
+ interface Flash extends Omit<Message, "action"> {
178
+ /** A form-backed action, the kind that survives the trip from the server. */
179
+ action?: FlashAction;
180
+ /** Stable id, such as a `generateUUID()` minted when the flash was set. */
181
+ id: string;
182
+ /** Milliseconds it stays once hydrated, or `null` to wait for the close button. */
183
+ duration?: number | null;
184
+ }
185
+ /** The action a {@link Flash} offers: a labelled form, such as Undo posting the record id back. */
186
+ interface FlashAction {
187
+ /** Visible label, a verb: "Undo", "Retry", "View". */
188
+ label: string;
189
+ /** The form the action submits. */
190
+ form: MessageForm;
191
+ }
192
+ /** Strings {@link Toasts} announces. */
193
+ interface Labels {
194
+ /** Accessible name of the region landmark, such as "Notifications". */
195
+ region: string;
196
+ /** Accessible name of each toast's close button, such as "Dismiss". */
197
+ dismiss: string;
111
198
  }
112
199
  }
113
200
  /**
@@ -147,3 +234,16 @@ export declare namespace Toast {
147
234
  var Close: (handle: Handle<Toast.CloseProps>) => () => import("remix/component").RemixElement;
148
235
  var Region: (handle: Handle<Toast.RegionProps>) => () => import("remix/component").RemixElement;
149
236
  }
237
+ /**
238
+ * The page's toast queue, shared by every island in the document so a toast
239
+ * raised anywhere lands in the one {@link Toasts} stack. On the server each
240
+ * call returns a fresh queue, keeping one request's toasts out of another's.
241
+ *
242
+ * @param queue Name of the queue, matching {@link Toasts.Props.queue}. Default: `"page"`.
243
+ * @returns The queue {@link Toasts} draws.
244
+ * @example
245
+ * pageToaster().add({ color: "success", title: "Monitor saved" });
246
+ * @example
247
+ * pageToaster().promise(save(), { loading: { title: "Saving monitor", loading: true }, success: { title: "Monitor saved", color: "success" }, error: { title: "Couldn't save monitor. Try again.", color: "danger" } });
248
+ */
249
+ export declare function pageToaster(queue?: string): Toaster<Toast.Message>;
package/dist/app/toast.js CHANGED
@@ -2,17 +2,18 @@ import { jsx as _jsx } from "remix/component/jsx-runtime";
2
2
  import { XIcon } from "@sdxc/icons";
3
3
  import { bg, border, colorMix, fg } from "@sdxc/u/color";
4
4
  import { backdropBlur, backdropSaturate, rounded, shadow, transition } from "@sdxc/u/effects";
5
- import { pointerEvents, raw, mergeMix } from "@sdxc/u/general";
6
- import { absolute, basis, fixed, flex, flexCol, gap, grow, inlineFlex, insBe, insBs, insIe, insIs, items, justify, relative, shrink, } from "@sdxc/u/layout";
5
+ import { combine, pointerEvents, raw, mergeMix } from "@sdxc/u/general";
6
+ import { basis, fixed, flex, flexCol, gap, grow, inlineFlex, insBe, insBs, insIe, insIs, items, justify, relative, shrink, } from "@sdxc/u/layout";
7
7
  import { media, supports } from "@sdxc/u/responsive";
8
- import { is, bs, maxIs, minIs, pb, pi, pie } from "@sdxc/u/size";
8
+ import { is, bs, maxIs, mb, mie, minIs, pb, pi } from "@sdxc/u/size";
9
9
  import { active, data, hover, when } from "@sdxc/u/state";
10
10
  import { translateX } from "@sdxc/u/transform";
11
11
  import { balance, fontSize, leading, pretty, weight } from "@sdxc/u/typography";
12
12
  import { attrs } from "remix/component";
13
13
  import { hitArea } from "../styles/hit-area.js";
14
14
  import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
15
- import { graphicHostStyle } from "./styles/graphic-host.js";
15
+ import { Toaster } from "./behaviors/toaster.js";
16
+ import { toastStackStyle } from "./styles/toast-stack.js";
16
17
  /**
17
18
  * `role` applied to {@link Toast} through {@link attrs} unless a consumer
18
19
  * supplies its own, announcing the panel as a status update that assistive
@@ -48,10 +49,38 @@ const DEFAULT_GRAPHIC_ARIA_HIDDEN = "true";
48
49
  * actions run; pass `type="submit"` for a form control.
49
50
  */
50
51
  const DEFAULT_BUTTON_TYPE = "button";
52
+ /**
53
+ * Block size of a toast's first line of text, the centre line its icon,
54
+ * action and close button sit on; an app overrides `--ui-toast-line`.
55
+ */
56
+ const LINE = "var(--ui-toast-line, 1.25rem)";
57
+ /** Block size of a toast's action, cancel and close buttons. */
58
+ const CONTROL = "1.5rem";
59
+ /**
60
+ * Block margin that centres a {@link CONTROL}-tall button on the first line
61
+ * while letting it overhang that line evenly, so it never pushes the text down.
62
+ */
63
+ const CONTROL_MARGIN = `calc((${LINE} - ${CONTROL}) / 2)`;
51
64
  /**
52
65
  * Corner {@link Toast.Region} renders in when `placement` is left unset.
53
66
  */
54
67
  const DEFAULT_PLACEMENT = "bottom-end";
68
+ /** Default {@link Toast.RegionProps.max}: three toasts show, the rest wait. */
69
+ const DEFAULT_MAX = 3;
70
+ /** Default {@link Toast.RegionProps.stack}: older toasts fold behind the newest. */
71
+ const DEFAULT_STACK = "peek";
72
+ /**
73
+ * How long a toast offering Undo stays, in milliseconds: long enough to read
74
+ * the outcome and reach the button, short enough that the change settles soon.
75
+ *
76
+ * @example
77
+ * pageToaster().add({ title: "Monitor deleted", action: { label: "Undo", onAction: restore } }, { duration: TOAST_UNDO_DURATION });
78
+ */
79
+ export const TOAST_UNDO_DURATION = 8000;
80
+ /** One queue per document and name, so every island on a page raises toasts into the same stack. */
81
+ const PAGE_TOASTERS = new WeakMap();
82
+ /** Name of the queue {@link pageToaster} and {@link Toasts} share when none is given. */
83
+ const DEFAULT_QUEUE = "page";
55
84
  /**
56
85
  * `role` applied to {@link Toast.Region} through {@link attrs} unless a
57
86
  * consumer supplies its own, exposing the stack of toasts as a landmark
@@ -98,7 +127,6 @@ export function Toast(handle) {
98
127
  fg("neutral.fg-emphasis"),
99
128
  pb("1rem"),
100
129
  pi("1rem"),
101
- when('&:has(> [data-slot="close"])', pie("2.5rem")),
102
130
  when('&[data-color="brand"]', [border("brand"), fg("brand.fg-emphasis")]),
103
131
  when('&[data-color="neutral"]', [border("neutral"), fg("neutral.fg-emphasis")]),
104
132
  when('&[data-color="success"]', [border("success"), fg("success.fg-emphasis")]),
@@ -140,6 +168,15 @@ export function Toast(handle) {
140
168
  ], mix), children: children }));
141
169
  };
142
170
  }
171
+ /**
172
+ * Lays out {@link Toast.Icon} and {@link Toast.Loader} identically, centring
173
+ * the graphic on the toast's first line so swapping them never moves it.
174
+ *
175
+ * @returns A mixin ready for the graphic slot's `mix` prop.
176
+ */
177
+ function graphicSlotStyle() {
178
+ return combine([shrink(), inlineFlex(), items("center"), bs(LINE), fg("currentcolor")]);
179
+ }
143
180
  /**
144
181
  * Renders {@link Toast.IconProps.children} as the toast's leading icon,
145
182
  * hidden from assistive technology since the toast's color and text already
@@ -151,7 +188,7 @@ export function Toast(handle) {
151
188
  Toast.Icon = function ToastIcon(handle) {
152
189
  return () => {
153
190
  let { children, mix, ...rest } = handle.props;
154
- return (_jsx("div", { ...rest, "data-slot": "icon", mix: mergeMix([attrs({ "aria-hidden": DEFAULT_GRAPHIC_ARIA_HIDDEN }), graphicHostStyle()], mix), children: children }));
191
+ return (_jsx("div", { ...rest, "data-slot": "icon", mix: mergeMix([attrs({ "aria-hidden": DEFAULT_GRAPHIC_ARIA_HIDDEN }), graphicSlotStyle()], mix), children: children }));
155
192
  };
156
193
  };
157
194
  /**
@@ -165,7 +202,7 @@ Toast.Icon = function ToastIcon(handle) {
165
202
  Toast.Loader = function ToastLoader(handle) {
166
203
  return () => {
167
204
  let { children, mix, ...rest } = handle.props;
168
- return (_jsx("div", { ...rest, "data-slot": "loader", mix: mergeMix([attrs({ "aria-hidden": DEFAULT_GRAPHIC_ARIA_HIDDEN }), graphicHostStyle()], mix), children: children }));
205
+ return (_jsx("div", { ...rest, "data-slot": "loader", mix: mergeMix([attrs({ "aria-hidden": DEFAULT_GRAPHIC_ARIA_HIDDEN }), graphicSlotStyle()], mix), children: children }));
169
206
  };
170
207
  };
171
208
  /**
@@ -193,7 +230,7 @@ Toast.Content = function ToastContent(handle) {
193
230
  Toast.Title = function ToastTitle(handle) {
194
231
  return () => {
195
232
  let { children, mix, ...rest } = handle.props;
196
- return (_jsx("h3", { ...rest, "data-slot": "title", mix: mergeMix([weight(500), leading(1), fontSize("sm"), balance()], mix), children: children }));
233
+ return (_jsx("h3", { ...rest, "data-slot": "title", mix: mergeMix([weight(500), leading(LINE), fontSize("sm"), balance()], mix), children: children }));
197
234
  };
198
235
  };
199
236
  /**
@@ -209,6 +246,7 @@ Toast.Description = function ToastDescription(handle) {
209
246
  let { children, mix, ...rest } = handle.props;
210
247
  return (_jsx("p", { ...rest, "data-slot": "description", mix: mergeMix([
211
248
  fontSize("sm"),
249
+ leading(LINE),
212
250
  pretty(),
213
251
  fg(colorMix("oklab", { color: "currentcolor", weight: 70 }, "transparent")),
214
252
  ], mix), children: children }));
@@ -235,7 +273,9 @@ Toast.Action = function ToastAction(handle) {
235
273
  rounded("md"),
236
274
  border({ width: 1 }),
237
275
  pi("0.75rem"),
238
- pb("0.25rem"),
276
+ bs(CONTROL),
277
+ mb(CONTROL_MARGIN),
278
+ leading(1),
239
279
  weight(500),
240
280
  shrink(),
241
281
  transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),
@@ -268,7 +308,9 @@ Toast.Cancel = function ToastCancel(handle) {
268
308
  rounded("md"),
269
309
  border({ color: "neutral", width: 1 }),
270
310
  pi("0.75rem"),
271
- pb("0.25rem"),
311
+ bs(CONTROL),
312
+ mb(CONTROL_MARGIN),
313
+ leading(1),
272
314
  weight(500),
273
315
  fg("neutral.fg"),
274
316
  hover([bg("neutral.bg-tint-hover"), fg("neutral.fg-emphasis")]),
@@ -293,18 +335,20 @@ Toast.Close = function ToastClose(handle) {
293
335
  return () => {
294
336
  let { mix, ...rest } = handle.props;
295
337
  return (_jsx("button", { type: "button", ...rest, "data-slot": "close", mix: mergeMix([
296
- absolute(),
338
+ relative(),
297
339
  inlineFlex(),
298
340
  items("center"),
299
341
  justify("center"),
300
- is("1.5rem"),
301
- bs("1.5rem"),
342
+ shrink(),
343
+ is(CONTROL),
344
+ bs(CONTROL),
345
+ mb(CONTROL_MARGIN),
346
+ mie("-0.5rem"),
347
+ raw({ order: "1" }),
302
348
  rounded("md"),
303
349
  fg("neutral.fg-muted"),
304
350
  hover([bg("neutral.bg-tint-hover"), fg("neutral.fg-emphasis")]),
305
351
  transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),
306
- insBs("0.5rem"),
307
- insIe("0.5rem"),
308
352
  hitArea(),
309
353
  ], mix), children: _jsx(XIcon, { size: 16 }) }));
310
354
  };
@@ -337,10 +381,10 @@ Toast.Close = function ToastClose(handle) {
337
381
  */
338
382
  Toast.Region = function ToastRegion(handle) {
339
383
  return () => {
340
- let { placement, children, mix, ...rest } = handle.props;
384
+ let { placement, max = DEFAULT_MAX, stack = DEFAULT_STACK, children, mix, ...rest } = handle.props;
341
385
  let resolvedPlacement = placement ?? DEFAULT_PLACEMENT;
342
386
  warnIfNoAccessibleLabel(handle.props, 'Toast.Region: needs an "aria-label" or "aria-labelledby" identifying this landmark for assistive technology.');
343
- return (_jsx("div", { ...rest, "data-placement": resolvedPlacement, "data-slot": "region", mix: mergeMix([
387
+ return (_jsx("div", { ...rest, "data-placement": resolvedPlacement, "data-stack": stack, "data-slot": "region", mix: mergeMix([
344
388
  attrs({ role: DEFAULT_REGION_ROLE }),
345
389
  fixed(),
346
390
  flex(),
@@ -357,6 +401,34 @@ Toast.Region = function ToastRegion(handle) {
357
401
  when('&[data-placement$="start"]', insIs("0")),
358
402
  when('&[data-placement$="end"]', insIe("0")),
359
403
  when('&[data-placement$="center"]', [insIs("50%"), translateX("-50%")]),
404
+ toastStackStyle(max),
360
405
  ], mix), children: children }));
361
406
  };
362
407
  };
408
+ /**
409
+ * The page's toast queue, shared by every island in the document so a toast
410
+ * raised anywhere lands in the one {@link Toasts} stack. On the server each
411
+ * call returns a fresh queue, keeping one request's toasts out of another's.
412
+ *
413
+ * @param queue Name of the queue, matching {@link Toasts.Props.queue}. Default: `"page"`.
414
+ * @returns The queue {@link Toasts} draws.
415
+ * @example
416
+ * pageToaster().add({ color: "success", title: "Monitor saved" });
417
+ * @example
418
+ * pageToaster().promise(save(), { loading: { title: "Saving monitor", loading: true }, success: { title: "Monitor saved", color: "success" }, error: { title: "Couldn't save monitor. Try again.", color: "danger" } });
419
+ */
420
+ export function pageToaster(queue = DEFAULT_QUEUE) {
421
+ if (typeof document === "undefined")
422
+ return new Toaster();
423
+ let queues = PAGE_TOASTERS.get(document);
424
+ if (!queues) {
425
+ queues = new Map();
426
+ PAGE_TOASTERS.set(document, queues);
427
+ }
428
+ let toaster = queues.get(queue);
429
+ if (!toaster) {
430
+ toaster = new Toaster();
431
+ queues.set(queue, toaster);
432
+ }
433
+ return toaster;
434
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The island that draws the page's one toast stack: server flash toasts and
3
+ * toasts raised through `pageToaster()` share a region, timing, pause on hover
4
+ * or focus, and close, so an app runs a single toast system.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { EntryComponent } from "remix/component";
10
+ import type { Toaster } from "./behaviors/toaster.js";
11
+ import { Toast } from "./toast.js";
12
+ /** Prop types for {@link Toasts}. */
13
+ export declare namespace Toasts {
14
+ /** Props accepted by {@link Toasts}. */
15
+ interface Props {
16
+ /** Strings the region and its close buttons announce. */
17
+ labels: Toast.Labels;
18
+ /** Toasts the server rendered from a session flash; hydration adopts each element and starts its timer. */
19
+ initial?: Toast.Flash[];
20
+ /** Corner of the viewport. Default: `"bottom-end"`. */
21
+ placement?: Toast.Placement;
22
+ /** Most toasts shown at once. Default: `3`. */
23
+ max?: number;
24
+ /** Peek stack or plain list. Default: `"peek"`. */
25
+ stack?: Toast.Stack;
26
+ /** Which `pageToaster()` queue to draw; a page normally has one. Default: `"page"`. */
27
+ queue?: string;
28
+ }
29
+ /** Props of one drawn toast inside {@link Toasts}. */
30
+ interface ItemProps {
31
+ /** Queue id, also the base of the element id the close button targets. */
32
+ id: string;
33
+ /** What the toast says and offers. */
34
+ message: Toast.Message;
35
+ /** Strings the close button announces. */
36
+ labels: Toast.Labels;
37
+ /** The queue the toast belongs to, which its close and action report to. */
38
+ toaster: Toaster<Toast.Message>;
39
+ }
40
+ }
41
+ /**
42
+ * The app's one toast stack. A flash toast shows and closes without JavaScript;
43
+ * hydration adopts the same element and only then starts its timer. Reach for a
44
+ * toast last, after an inline message or a banner.
45
+ *
46
+ * @example
47
+ * <Toasts labels={{ region: t("toasts.region"), dismiss: t("toasts.dismiss") }} initial={flash ? [flash] : []} />
48
+ */
49
+ export declare const Toasts: EntryComponent<Toasts.Props>;
@@ -0,0 +1,103 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { CircleAlertIcon, CircleCheckIcon, InfoIcon, LoaderCircleIcon, TriangleAlertIcon, } from "@sdxc/icons";
3
+ import { raw } from "@sdxc/u/general";
4
+ import { clientEntry } from "remix/component";
5
+ import { spin } from "../animations/keyframes.js";
6
+ import { whileLive } from "../mixins/while-live.js";
7
+ import { toastAction, toastClose, toastHold } from "./mixins/toast-queue.js";
8
+ import { toastStack } from "./mixins/toast-stack.js";
9
+ import { pageToaster, Toast } from "./toast.js";
10
+ /** Tone a {@link Toast.Message} takes when it names none. */
11
+ const DEFAULT_COLOR = "neutral";
12
+ /**
13
+ * The app's one toast stack. A flash toast shows and closes without JavaScript;
14
+ * hydration adopts the same element and only then starts its timer. Reach for a
15
+ * toast last, after an inline message or a banner.
16
+ *
17
+ * @example
18
+ * <Toasts labels={{ region: t("toasts.region"), dismiss: t("toasts.dismiss") }} initial={flash ? [flash] : []} />
19
+ */
20
+ export const Toasts = clientEntry("@sdxc/ui/app/toasts#Toasts", function Toasts(handle) {
21
+ let toaster = pageToaster(handle.props.queue);
22
+ let adopted = false;
23
+ let seen = new Set();
24
+ whileLive(handle, (queue, signal) => {
25
+ queue.addEventListener("change", () => void handle.update(), { signal });
26
+ })(toaster);
27
+ /**
28
+ * Queues every flash not seen before, so one a later render brings (a page the client
29
+ * runtime fetched after a form post) shows too, and a dismissed one never comes back.
30
+ */
31
+ function adopt() {
32
+ for (let flash of handle.props.initial ?? []) {
33
+ if (seen.has(flash.id))
34
+ continue;
35
+ seen.add(flash.id);
36
+ if (toaster.get(flash.id))
37
+ continue;
38
+ toaster.add(flash, { id: flash.id, duration: flash.duration });
39
+ }
40
+ }
41
+ handle.queueTask(() => {
42
+ adopt();
43
+ adopted = true;
44
+ void handle.update();
45
+ });
46
+ return () => {
47
+ let { labels, initial = [], placement, max, stack } = handle.props;
48
+ if (adopted && initial.some((flash) => !seen.has(flash.id)))
49
+ handle.queueTask(adopt);
50
+ let items = adopted
51
+ ? toaster.toasts.map((toast) => ({ id: toast.id, message: toast.data }))
52
+ : initial.map((flash) => ({ id: flash.id, message: flash }));
53
+ return (_jsx(Toast.Region, { "aria-label": labels.region, placement: placement, max: max, stack: stack, mix: [toastHold(toaster), toastStack()], children: items.map((item) => (_jsx(ToastItem, { id: item.id, message: item.message, labels: labels, toaster: toaster }, item.id))) }));
54
+ };
55
+ });
56
+ /**
57
+ * Draws one queued {@link Toast.Message} inside an open, non-modal `<dialog>`,
58
+ * whose close button uses the native `close` command, so a server-rendered
59
+ * toast closes without JavaScript and the queue hears the same `close` event.
60
+ *
61
+ * @param handle Runtime handle carrying {@link Toasts.ItemProps}.
62
+ * @returns The render function producing the toast's markup.
63
+ */
64
+ function ToastItem(handle) {
65
+ return () => {
66
+ let { id, message, labels, toaster } = handle.props;
67
+ let domId = `toast-${id}`;
68
+ let color = message.color ?? DEFAULT_COLOR;
69
+ let action = message.action;
70
+ return (_jsx("dialog", { open: true, id: domId, "aria-labelledby": `${domId}-title`, "data-slot": "toast-item", mix: [
71
+ toastClose(toaster, id),
72
+ raw({
73
+ position: "relative",
74
+ inset: "auto",
75
+ inlineSize: "100%",
76
+ margin: "0",
77
+ padding: "0",
78
+ border: "0",
79
+ background: "transparent",
80
+ color: "inherit",
81
+ }),
82
+ ], children: _jsxs(Toast, { color: color, live: color === "danger" ? "assertive" : "polite", "aria-busy": message.loading ? "true" : undefined, children: [message.loading ? (_jsx(Toast.Loader, { mix: [spin()], children: _jsx(LoaderCircleIcon, { size: 16 }) })) : (_jsx(Toast.Icon, { children: _jsx(ToastColorIcon, { color: color }) })), _jsxs(Toast.Content, { children: [_jsx(Toast.Title, { id: `${domId}-title`, children: message.title }), message.description ? (_jsx(Toast.Description, { children: message.description })) : null] }), action?.form ? (_jsxs("form", { method: action.form.method ?? "post", action: action.form.action, mix: [raw({ display: "contents" })], children: [Object.entries(action.form.fields ?? {}).map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }, name))), _jsx(Toast.Action, { type: "submit", mix: [toastAction(toaster, id, action.onAction)], children: action.label })] })) : null, action && !action.form ? (_jsx(Toast.Action, { mix: [toastAction(toaster, id, action.onAction)], children: action.label })) : null, _jsx(Toast.Close, { "aria-label": labels.dismiss, commandfor: domId, command: "close" })] }) }));
83
+ };
84
+ }
85
+ /**
86
+ * Picks the icon a tone carries, so a success, warning and failure read apart
87
+ * at a glance before the title is read.
88
+ *
89
+ * @param handle Runtime handle carrying the toast's tone.
90
+ * @returns The render function producing the icon.
91
+ */
92
+ function ToastColorIcon(handle) {
93
+ return () => {
94
+ let { color } = handle.props;
95
+ if (color === "success")
96
+ return _jsx(CircleCheckIcon, { size: 16 });
97
+ if (color === "danger")
98
+ return _jsx(CircleAlertIcon, { size: 16 });
99
+ if (color === "warning")
100
+ return _jsx(TriangleAlertIcon, { size: 16 });
101
+ return _jsx(InfoIcon, { size: 16 });
102
+ };
103
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The cookie an app shell keeps its collapsed sidebar in, and the server-side reader for it.
3
+ * The browser writes it when the sidebar toggles; the server reads it before rendering, so the
4
+ * first paint already has the width the person left it at.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** The cookie the shell's toggle writes `"true"` or `"false"` under. */
10
+ export declare const APP_SHELL_COOKIE = "ui-app-shell-collapsed";
11
+ /**
12
+ * Whether the sidebar was left collapsed, read from a request's `Cookie` header. A missing
13
+ * header, a missing cookie or any value other than `"true"` reads as expanded.
14
+ *
15
+ * @param cookieHeader The request's `Cookie` header.
16
+ * @param name The cookie name, for an app that renamed it on the shell.
17
+ * @returns `true` when the sidebar renders as the icon rail.
18
+ * @example
19
+ * <AppShell collapsed={readAppShellCookie(request.headers.get("Cookie"))} … />
20
+ */
21
+ export declare function readAppShellCookie(cookieHeader: string | null | undefined, name?: string): boolean;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The cookie an app shell keeps its collapsed sidebar in, and the server-side reader for it.
3
+ * The browser writes it when the sidebar toggles; the server reads it before rendering, so the
4
+ * first paint already has the width the person left it at.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** The cookie the shell's toggle writes `"true"` or `"false"` under. */
10
+ export const APP_SHELL_COOKIE = "ui-app-shell-collapsed";
11
+ /**
12
+ * Whether the sidebar was left collapsed, read from a request's `Cookie` header. A missing
13
+ * header, a missing cookie or any value other than `"true"` reads as expanded.
14
+ *
15
+ * @param cookieHeader The request's `Cookie` header.
16
+ * @param name The cookie name, for an app that renamed it on the shell.
17
+ * @returns `true` when the sidebar renders as the icon rail.
18
+ * @example
19
+ * <AppShell collapsed={readAppShellCookie(request.headers.get("Cookie"))} … />
20
+ */
21
+ export function readAppShellCookie(cookieHeader, name = APP_SHELL_COOKIE) {
22
+ if (!cookieHeader)
23
+ return false;
24
+ for (let part of cookieHeader.split(";")) {
25
+ let index = part.indexOf("=");
26
+ if (index === -1)
27
+ continue;
28
+ if (part.slice(0, index).trim() !== name)
29
+ continue;
30
+ return part.slice(index + 1).trim() === "true";
31
+ }
32
+ return false;
33
+ }
@@ -7,16 +7,20 @@
7
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
8
8
  * @copyright Sergio Xalambrí 2026
9
9
  */
10
+ /** A point a marker can snap to; one whose `y` is `null` recorded no data and gets no marker. */
11
+ interface MarkerCandidate {
12
+ x: number;
13
+ y?: number | null;
14
+ }
10
15
  /**
11
16
  * Picks which of a plotted series' points get an accessible, hoverable
12
17
  * marker by snapping evenly spread "nice" values across `xDomain` onto the
13
- * nearest actual point; duplicate snaps collapse into one marker.
18
+ * nearest point with data; duplicate snaps collapse into one marker.
14
19
  *
15
20
  * @param points The series' data points, in draw order along `x`.
16
21
  * @param xDomain The `[start, end]` domain {@link ticks} generates its "nice" values across.
17
22
  * @param markerCount Approximate number of markers to place.
18
- * @returns The deduplicated indices into `points` to render a marker for, or `[]` when `points` is empty.
23
+ * @returns The deduplicated indices into `points` to render a marker for, or `[]` when no point has data.
19
24
  */
20
- export declare function computeMarkerIndices(points: readonly {
21
- x: number;
22
- }[], xDomain: readonly [number, number], markerCount: number): number[];
25
+ export declare function computeMarkerIndices(points: readonly MarkerCandidate[], xDomain: readonly [number, number], markerCount: number): number[];
26
+ export {};
@@ -10,16 +10,18 @@
10
10
  import { ticks } from "./chart-scale.js";
11
11
  /**
12
12
  * Finds the index of the point in `points` whose `x` value sits closest to
13
- * `target`, favoring the earlier point on an exact tie.
13
+ * `target`, skipping points with no data and favoring the earlier point on an exact tie.
14
14
  *
15
15
  * @param points The points to search, in their own original order.
16
16
  * @param target The `x` value to find the nearest point to.
17
- * @returns The index into `points` of the closest match, or `0` when `points` is empty.
17
+ * @returns The index into `points` of the closest match, or `-1` when no point has data.
18
18
  */
19
19
  function nearestPointIndex(points, target) {
20
- let closestIndex = 0;
20
+ let closestIndex = -1;
21
21
  let closestDistance = Infinity;
22
22
  for (let [index, point] of points.entries()) {
23
+ if (point.y === null)
24
+ continue;
23
25
  let distance = Math.abs(point.x - target);
24
26
  if (distance < closestDistance) {
25
27
  closestDistance = distance;
@@ -31,15 +33,14 @@ function nearestPointIndex(points, target) {
31
33
  /**
32
34
  * Picks which of a plotted series' points get an accessible, hoverable
33
35
  * marker by snapping evenly spread "nice" values across `xDomain` onto the
34
- * nearest actual point; duplicate snaps collapse into one marker.
36
+ * nearest point with data; duplicate snaps collapse into one marker.
35
37
  *
36
38
  * @param points The series' data points, in draw order along `x`.
37
39
  * @param xDomain The `[start, end]` domain {@link ticks} generates its "nice" values across.
38
40
  * @param markerCount Approximate number of markers to place.
39
- * @returns The deduplicated indices into `points` to render a marker for, or `[]` when `points` is empty.
41
+ * @returns The deduplicated indices into `points` to render a marker for, or `[]` when no point has data.
40
42
  */
41
43
  export function computeMarkerIndices(points, xDomain, markerCount) {
42
- if (points.length === 0)
43
- return [];
44
- return [...new Set(ticks(xDomain, markerCount).map((value) => nearestPointIndex(points, value)))];
44
+ let indices = ticks(xDomain, markerCount).map((value) => nearestPointIndex(points, value));
45
+ return [...new Set(indices.filter((index) => index !== -1))];
45
46
  }