@sdxc/ui 2026.11.1 → 2026.11.3

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 (190) 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 +1 -1
  162. package/dist/docs/docs-nav-tools.js +2 -2
  163. package/dist/docs/docs-nav.d.ts +6 -2
  164. package/dist/docs/docs-nav.js +2 -2
  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 +2 -2
  168. package/dist/docs/mixins/docs-nav-tools.js +32 -5
  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/mixins/confirm-phrase.d.ts +19 -0
  175. package/dist/mixins/confirm-phrase.js +56 -0
  176. package/dist/mixins/index.d.ts +2 -0
  177. package/dist/mixins/index.js +2 -0
  178. package/dist/mixins/viewer-time.d.ts +20 -0
  179. package/dist/mixins/viewer-time.js +40 -0
  180. package/dist/styles/index.d.ts +1 -0
  181. package/dist/styles/index.js +1 -0
  182. package/dist/styles/segmented-control.d.ts +49 -0
  183. package/dist/styles/segmented-control.js +71 -0
  184. package/dist/test/table.d.ts +65 -0
  185. package/dist/test/table.js +108 -0
  186. package/dist/utils/index.d.ts +1 -0
  187. package/dist/utils/index.js +1 -0
  188. package/dist/utils/relative-time.d.ts +44 -0
  189. package/dist/utils/relative-time.js +69 -0
  190. package/package.json +6 -6
@@ -0,0 +1,297 @@
1
+ /**
2
+ * The browser half of the command palette: filters the server-rendered commands by title and
3
+ * keywords, moves the active row, opens nested pages, fills Recent, and binds the palette's
4
+ * toggle key and every command's own key. Why JS: filtering, active-descendant movement and
5
+ * page stacks need script. No-JS baseline: a trigger opens the dialog and every command works.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { createMixin } from "remix/component";
11
+ import { isApplePlatform, shortcutGlyphs, shortcutRegistry } from "../behaviors/shortcuts.js";
12
+ /** How many recent commands the palette offers before anything is typed. */
13
+ export const PALETTE_RECENT_LIMIT = 5;
14
+ /** Marks each row with its command's id, which `recent` and the remembered list name. */
15
+ export const PALETTE_ITEM_ATTRIBUTE = "data-palette-item";
16
+ /** Marks the link or button a row presses. */
17
+ export const PALETTE_CONTROL_ATTRIBUTE = "data-palette-control";
18
+ /** Names the page a row's control opens instead of acting. */
19
+ export const PALETTE_GOTO_ATTRIBUTE = "data-palette-goto";
20
+ /** Marks a page of commands with its id. */
21
+ export const PALETTE_PAGE_ATTRIBUTE = "data-palette-page";
22
+ /** Marks a row the island copied into the Recent group. */
23
+ export const PALETTE_CLONE_ATTRIBUTE = "data-palette-clone";
24
+ /** Marks a shortcut hint with the combo it prints, so the island reprints it per platform. */
25
+ export const PALETTE_HINT_ATTRIBUTE = "data-shortcut-hint";
26
+ /**
27
+ * Lower-cases text and strips its accents, so "cafe" finds "Café" and "Équipe" finds "equipe".
28
+ *
29
+ * @param value Text to fold.
30
+ * @returns The folded text.
31
+ */
32
+ export function foldSearchText(value) {
33
+ return value
34
+ .normalize("NFD")
35
+ .replace(/\p{Diacritic}/gu, "")
36
+ .toLowerCase()
37
+ .trim();
38
+ }
39
+ /** The page a row or group sits on, `null` for the root list. */
40
+ function pageOf(element) {
41
+ return (element.closest(`[${PALETTE_PAGE_ATTRIBUTE}]`)?.getAttribute(PALETTE_PAGE_ATTRIBUTE) ?? null);
42
+ }
43
+ /** Reads the remembered command ids, newest first, empty when storage is unavailable. */
44
+ function readRemembered(key) {
45
+ if (key === undefined)
46
+ return [];
47
+ try {
48
+ let parsed = JSON.parse(localStorage.getItem(key) ?? "[]");
49
+ return Array.isArray(parsed) ? parsed.filter((id) => typeof id === "string") : [];
50
+ }
51
+ catch {
52
+ return [];
53
+ }
54
+ }
55
+ /**
56
+ * Puts `id` first in the remembered list, answering whether it was stored. Where storage is
57
+ * refused the palette keeps working, offering only the recents the server passed.
58
+ */
59
+ function remember(key, id) {
60
+ if (key === undefined)
61
+ return false;
62
+ try {
63
+ let ids = [id, ...readRemembered(key).filter((other) => other !== id)].slice(0, PALETTE_RECENT_LIMIT);
64
+ localStorage.setItem(key, JSON.stringify(ids));
65
+ return true;
66
+ }
67
+ catch {
68
+ return false;
69
+ }
70
+ }
71
+ /** Reprints every hint under `root` for a keyboard without the Apple glyphs. */
72
+ function reprintHints(root) {
73
+ if (isApplePlatform())
74
+ return;
75
+ for (let hint of root.querySelectorAll(`[${PALETTE_HINT_ATTRIBUTE}]`)) {
76
+ let template = hint.querySelector("kbd");
77
+ if (template === null)
78
+ continue;
79
+ let caps = shortcutGlyphs(hint.getAttribute(PALETTE_HINT_ATTRIBUTE) ?? "", false).map((glyph) => {
80
+ let cap = template.cloneNode();
81
+ cap.textContent = glyph;
82
+ return cap;
83
+ });
84
+ hint.replaceChildren(...caps);
85
+ }
86
+ }
87
+ /**
88
+ * Wires a palette dialog: filtering, the active row, pages, recents, the toggle key and every
89
+ * item's own key.
90
+ */
91
+ function attach(dialog, props, signal) {
92
+ let input = dialog.querySelector("[data-command-input]");
93
+ let list = dialog.querySelector('[data-slot="list"]');
94
+ let empty = dialog.querySelector("[data-command-empty]");
95
+ let status = dialog.querySelector("[data-palette-status]");
96
+ let back = dialog.querySelector("[data-palette-back]");
97
+ let recentGroup = dialog.querySelector("[data-palette-recent]");
98
+ let recentItems = dialog.querySelector("[data-palette-recent-items]");
99
+ let rootPlaceholder = input.placeholder;
100
+ let stack = [];
101
+ let current = null;
102
+ let active = null;
103
+ let registry = shortcutRegistry(dialog.ownerDocument);
104
+ let items = () => [...list.querySelectorAll(`[${PALETTE_ITEM_ATTRIBUTE}]`)];
105
+ let visible = () => items().filter((item) => item.closest("[hidden]") === null);
106
+ let setActive = (item) => {
107
+ active = item;
108
+ for (let other of items())
109
+ other.setAttribute("aria-selected", String(other === item));
110
+ input.setAttribute("aria-activedescendant", item?.id ?? "");
111
+ item?.scrollIntoView({ block: "nearest" });
112
+ };
113
+ let apply = () => {
114
+ let tokens = foldSearchText(input.value).split(/\s+/).filter(Boolean);
115
+ for (let child of list.children) {
116
+ if (!(child instanceof HTMLElement) || child === recentGroup)
117
+ continue;
118
+ let page = child.getAttribute(PALETTE_PAGE_ATTRIBUTE);
119
+ child.hidden = page === null ? current !== null : page !== current;
120
+ }
121
+ for (let item of items()) {
122
+ if (item.hasAttribute(PALETTE_CLONE_ATTRIBUTE) || pageOf(item) !== current)
123
+ continue;
124
+ let haystack = foldSearchText(`${item.getAttribute("data-value") ?? ""} ${item.getAttribute("data-keywords") ?? ""}`);
125
+ item.hidden = !tokens.every((token) => haystack.includes(token));
126
+ }
127
+ for (let group of list.querySelectorAll("[data-palette-group]")) {
128
+ if (pageOf(group) !== current)
129
+ continue;
130
+ group.hidden = group.querySelector(`[${PALETTE_ITEM_ATTRIBUTE}]:not([hidden])`) === null;
131
+ }
132
+ if (recentGroup !== null) {
133
+ recentGroup.hidden =
134
+ current !== null || tokens.length > 0 || recentItems?.childElementCount === 0;
135
+ }
136
+ let shown = visible();
137
+ if (empty !== null) {
138
+ empty.hidden = shown.length > 0;
139
+ let quoted = empty.querySelector("[data-palette-query]");
140
+ if (quoted !== null)
141
+ quoted.textContent = input.value;
142
+ }
143
+ if (status !== null)
144
+ status.textContent = props.results.replace("{count}", String(shown.length));
145
+ setActive(shown[0] ?? null);
146
+ };
147
+ let fillRecent = () => {
148
+ if (recentItems === null)
149
+ return;
150
+ let ids = [...new Set([...props.recent, ...readRemembered(props.remember)])];
151
+ let clones = [];
152
+ for (let id of ids) {
153
+ if (clones.length === PALETTE_RECENT_LIMIT)
154
+ break;
155
+ let source = items().find((item) => item.getAttribute(PALETTE_ITEM_ATTRIBUTE) === id &&
156
+ !item.hasAttribute(PALETTE_CLONE_ATTRIBUTE));
157
+ if (source === undefined || source.querySelector(`[${PALETTE_GOTO_ATTRIBUTE}]`) !== null)
158
+ continue;
159
+ let clone = source.cloneNode(true);
160
+ clone.id = `${source.id}-recent`;
161
+ clone.hidden = false;
162
+ clone.setAttribute(PALETTE_CLONE_ATTRIBUTE, "");
163
+ clones.push(clone);
164
+ }
165
+ recentItems.replaceChildren(...clones);
166
+ };
167
+ let showPage = (page, query) => {
168
+ current = page;
169
+ input.value = query;
170
+ let element = page === null
171
+ ? null
172
+ : list.querySelector(`[${PALETTE_PAGE_ATTRIBUTE}="${CSS.escape(page)}"]`);
173
+ input.placeholder = element?.getAttribute("data-palette-placeholder") ?? rootPlaceholder;
174
+ if (back !== null) {
175
+ back.hidden = page === null;
176
+ let crumb = back.querySelector("[data-palette-crumb]");
177
+ if (crumb !== null)
178
+ crumb.textContent = element?.getAttribute("data-palette-title") ?? "";
179
+ }
180
+ apply();
181
+ input.focus();
182
+ };
183
+ let push = (page) => {
184
+ stack.push({ page: current, query: input.value });
185
+ showPage(page, "");
186
+ };
187
+ let pop = () => {
188
+ let previous = stack.pop();
189
+ if (previous !== undefined)
190
+ showPage(previous.page, previous.query);
191
+ };
192
+ let reset = () => {
193
+ stack = [];
194
+ fillRecent();
195
+ showPage(null, "");
196
+ };
197
+ /** Presses a row: a page opener opens its page; any other command runs and closes the palette. */
198
+ let run = (item) => {
199
+ item.querySelector(`[${PALETTE_CONTROL_ATTRIBUTE}]`)?.click();
200
+ };
201
+ dialog.addEventListener("click", (event) => {
202
+ let target = event.target instanceof Element ? event.target : null;
203
+ if (target?.closest("[data-palette-back]"))
204
+ return pop();
205
+ let control = target?.closest(`[${PALETTE_CONTROL_ATTRIBUTE}]`);
206
+ if (control == null)
207
+ return;
208
+ let page = control.getAttribute(PALETTE_GOTO_ATTRIBUTE);
209
+ if (page !== null) {
210
+ if (!dialog.open)
211
+ dialog.showModal();
212
+ return push(page);
213
+ }
214
+ let id = control.closest(`[${PALETTE_ITEM_ATTRIBUTE}]`)?.getAttribute(PALETTE_ITEM_ATTRIBUTE);
215
+ if (id != null)
216
+ remember(props.remember, id);
217
+ dialog.close();
218
+ }, { signal });
219
+ dialog.addEventListener("pointermove", (event) => {
220
+ let item = event.target instanceof Element
221
+ ? event.target.closest(`[${PALETTE_ITEM_ATTRIBUTE}]`)
222
+ : null;
223
+ if (item !== null && item !== active)
224
+ setActive(item);
225
+ }, { signal });
226
+ dialog.addEventListener("keydown", (event) => {
227
+ let shown = visible();
228
+ let index = active === null ? -1 : shown.indexOf(active);
229
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
230
+ event.preventDefault();
231
+ if (shown.length === 0)
232
+ return;
233
+ let step = event.key === "ArrowDown" ? 1 : -1;
234
+ setActive(shown[(index + step + shown.length) % shown.length] ?? null);
235
+ }
236
+ else if (event.key === "Enter" && event.target === input && active !== null) {
237
+ event.preventDefault();
238
+ run(active);
239
+ }
240
+ else if (event.key === "Backspace" && input.value === "" && stack.length > 0) {
241
+ event.preventDefault();
242
+ pop();
243
+ }
244
+ }, { signal });
245
+ input.addEventListener("input", apply, { signal });
246
+ dialog.addEventListener("close", reset, { signal });
247
+ registry.register({
248
+ keys: props.shortcut,
249
+ label: props.open,
250
+ global: true,
251
+ whileTyping: true,
252
+ run: () => {
253
+ if (dialog.open)
254
+ dialog.close();
255
+ else
256
+ dialog.showModal();
257
+ return true;
258
+ },
259
+ signal,
260
+ });
261
+ for (let item of items()) {
262
+ let keys = item.getAttribute("data-palette-shortcut");
263
+ if (keys === null || item.hasAttribute(PALETTE_CLONE_ATTRIBUTE))
264
+ continue;
265
+ let group = item.closest("[data-palette-group]")?.querySelector("[id]")?.textContent ?? undefined;
266
+ registry.register({
267
+ keys,
268
+ label: item.getAttribute("data-value") ?? undefined,
269
+ group,
270
+ run: () => {
271
+ run(item);
272
+ return true;
273
+ },
274
+ signal,
275
+ });
276
+ }
277
+ reprintHints(dialog);
278
+ reprintHints(dialog.ownerDocument.querySelector(`[commandfor="${CSS.escape(dialog.id)}"]`) ?? dialog);
279
+ reset();
280
+ }
281
+ /**
282
+ * Wires the palette `<dialog>` the host sits in, for as long as the host stays mounted.
283
+ *
284
+ * @param options The toggle key, the copy it announces with, and where recents come from.
285
+ * @example <div hidden mix={[paletteController({ shortcut: "mod+k", open: "Open command menu", results: "{count} results", recent: [] })]} />
286
+ */
287
+ export const paletteController = createMixin((handle) => {
288
+ let options;
289
+ handle.addEventListener("insert", (event) => {
290
+ let dialog = event.node.closest("dialog");
291
+ if (dialog !== null && options !== undefined)
292
+ attach(dialog, options, handle.signal);
293
+ });
294
+ return (next) => {
295
+ options = next;
296
+ };
297
+ });
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Why JS: a copy-link button writes a record's URL to the clipboard, which only script
3
+ * reaches. No-JS baseline: the button is inert and the record's URL is still the page's
4
+ * own address bar, or the link the list renders for it.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { ElementProps, MixinFactory } from "remix/component";
10
+ /**
11
+ * Writes `permalink`, resolved against the page's URL so a relative path copies as a full
12
+ * address, to the clipboard on every press. A successful write sets `data-copied` on the
13
+ * button and writes `copiedLabel` into its `[role="status"]` element for two seconds.
14
+ *
15
+ * @param permalink The record's URL, absolute or relative to the page.
16
+ * @param copiedLabel What a screen reader announces once the link is copied.
17
+ * @returns A mixin descriptor for the button's `mix` prop.
18
+ * @example
19
+ * <button type="button" mix={[copyPermalink("/monitors/42", t("linkCopied"))]}>
20
+ * <LinkIcon /><span role="status" mix={[visuallyHidden()]} />
21
+ * </button>
22
+ */
23
+ export declare const copyPermalink: MixinFactory<HTMLButtonElement, [
24
+ permalink: string,
25
+ copiedLabel: string
26
+ ], ElementProps>;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Why JS: a copy-link button writes a record's URL to the clipboard, which only script
3
+ * reaches. No-JS baseline: the button is inert and the record's URL is still the page's
4
+ * own address bar, or the link the list renders for it.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createElement, createMixin, on } from "remix/component";
10
+ /** How long the button reads as copied after a successful write. */
11
+ const COPIED_MS = 2000;
12
+ /**
13
+ * Writes `permalink`, resolved against the page's URL so a relative path copies as a full
14
+ * address, to the clipboard on every press. A successful write sets `data-copied` on the
15
+ * button and writes `copiedLabel` into its `[role="status"]` element for two seconds.
16
+ *
17
+ * @param permalink The record's URL, absolute or relative to the page.
18
+ * @param copiedLabel What a screen reader announces once the link is copied.
19
+ * @returns A mixin descriptor for the button's `mix` prop.
20
+ * @example
21
+ * <button type="button" mix={[copyPermalink("/monitors/42", t("linkCopied"))]}>
22
+ * <LinkIcon /><span role="status" mix={[visuallyHidden()]} />
23
+ * </button>
24
+ */
25
+ export const copyPermalink = createMixin((handle) => {
26
+ let timer;
27
+ handle.addEventListener("remove", () => clearTimeout(timer));
28
+ return (permalink, copiedLabel) => createElement(handle.element, {
29
+ mix: [
30
+ on("click", async (event, signal) => {
31
+ let button = event.currentTarget;
32
+ let url = new URL(permalink, button.ownerDocument.location.href).href;
33
+ try {
34
+ await navigator.clipboard.writeText(url);
35
+ }
36
+ catch {
37
+ return;
38
+ }
39
+ if (signal.aborted)
40
+ return;
41
+ let status = button.querySelector('[role="status"]');
42
+ button.setAttribute("data-copied", "");
43
+ if (status)
44
+ status.textContent = copiedLabel;
45
+ clearTimeout(timer);
46
+ timer = setTimeout(() => {
47
+ button.removeAttribute("data-copied");
48
+ if (status)
49
+ status.textContent = "";
50
+ }, COPIED_MS);
51
+ }),
52
+ ],
53
+ });
54
+ });
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Why JS: a detail sheet whose open record lives in the URL answers Esc and ↑/↓ (k/j) by
3
+ * following its own Close and previous/next links, and moves focus into itself on open;
4
+ * HTML wires neither a keystroke to a link nor focus to a server-opened region.
5
+ * No-JS baseline: every link stays a link, reachable by Tab and the pointer.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import type { MixinFactory } from "remix/component";
11
+ /** Attribute naming which of the sheet's links a control is, read by {@link detailSheetKeys}. */
12
+ export declare const DETAIL_SHEET_LINK_ATTRIBUTE = "data-detail-sheet-link";
13
+ /**
14
+ * Where the sheet's keys answer: `"page"` anywhere in the document, with focus moved into
15
+ * the sheet on open; `"sheet"` only while focus is inside the sheet, for a sheet shown on
16
+ * a page whose own keys come first, such as a catalogue.
17
+ */
18
+ export type DetailSheetKeyScope = "page" | "sheet";
19
+ /**
20
+ * Binds the sheet's keys for as long as the controls stay mounted: Esc follows Close
21
+ * unless a popover is open (the popover takes it), k/j and ↑/↓ follow previous/next.
22
+ * Keys typed in a field, or claimed nearer their target, pass through.
23
+ *
24
+ * @param scope Where the keys answer.
25
+ * @returns A mixin descriptor for the sheet's controls.
26
+ * @example <div mix={[detailSheetKeys("page")]}>{links}</div>
27
+ */
28
+ export declare const detailSheetKeys: MixinFactory<HTMLElement, [scope: DetailSheetKeyScope]>;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Why JS: a detail sheet whose open record lives in the URL answers Esc and ↑/↓ (k/j) by
3
+ * following its own Close and previous/next links, and moves focus into itself on open;
4
+ * HTML wires neither a keystroke to a link nor focus to a server-opened region.
5
+ * No-JS baseline: every link stays a link, reachable by Tab and the pointer.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { createMixin } from "remix/component";
11
+ import { isClaimedKeystroke } from "../../mixins/keymap.js";
12
+ import { matchesKeyCombo } from "../../utils/key-combo.js";
13
+ /** Attribute naming which of the sheet's links a control is, read by {@link detailSheetKeys}. */
14
+ export const DETAIL_SHEET_LINK_ATTRIBUTE = "data-detail-sheet-link";
15
+ /** Selector of the region the sheet scrolls, where ↑/↓ keep scrolling it. */
16
+ const SCROLL_REGION_SELECTOR = '[data-slot="detail-sheet-body"]';
17
+ /** The sheet's host, found from the controls the mixin sits on. */
18
+ const SHEET_SELECTOR = '[data-slot="detail-sheet"]';
19
+ /** Which link each keystroke follows; the arrows defer to the sheet's body while it has focus. */
20
+ const KEY_LINKS = [
21
+ ["Escape", "close", false],
22
+ ["k", "previous", false],
23
+ ["j", "next", false],
24
+ ["ArrowUp", "previous", true],
25
+ ["ArrowDown", "next", true],
26
+ ];
27
+ /**
28
+ * Follows the `link` control inside `controls` by clicking it, so a router or frame that
29
+ * intercepts link clicks takes the navigation exactly as it would a pointer press.
30
+ *
31
+ * @returns Whether a link with an `href` was there to follow.
32
+ */
33
+ function follow(controls, link) {
34
+ let anchor = controls.querySelector(`a[${DETAIL_SHEET_LINK_ATTRIBUTE}="${link}"][href]`);
35
+ if (anchor === null)
36
+ return false;
37
+ anchor.click();
38
+ return true;
39
+ }
40
+ /**
41
+ * Moves focus to the sheet when nothing else holds it, which is the state a page loads
42
+ * in; a reader already working in the list keeps their place.
43
+ */
44
+ function focusSheet(controls) {
45
+ let sheet = controls.closest(SHEET_SELECTOR);
46
+ let active = controls.ownerDocument.activeElement;
47
+ if (sheet === null || (active !== null && active !== controls.ownerDocument.body))
48
+ return;
49
+ sheet.focus({ preventScroll: true });
50
+ }
51
+ /**
52
+ * Binds the sheet's keys for as long as the controls stay mounted: Esc follows Close
53
+ * unless a popover is open (the popover takes it), k/j and ↑/↓ follow previous/next.
54
+ * Keys typed in a field, or claimed nearer their target, pass through.
55
+ *
56
+ * @param scope Where the keys answer.
57
+ * @returns A mixin descriptor for the sheet's controls.
58
+ * @example <div mix={[detailSheetKeys("page")]}>{links}</div>
59
+ */
60
+ export const detailSheetKeys = createMixin((handle) => {
61
+ let current = "page";
62
+ handle.addEventListener("insert", (event) => {
63
+ let controls = event.node;
64
+ let document = controls.ownerDocument;
65
+ if (current === "page")
66
+ focusSheet(controls);
67
+ document.addEventListener("keydown", (keystroke) => {
68
+ if (isClaimedKeystroke(keystroke))
69
+ return;
70
+ let target = keystroke.target instanceof Element ? keystroke.target : null;
71
+ if (current === "sheet" && !target?.closest(SHEET_SELECTOR))
72
+ return;
73
+ let match = KEY_LINKS.find(([combo]) => matchesKeyCombo(keystroke, combo));
74
+ if (match === undefined)
75
+ return;
76
+ let [, link, arrow] = match;
77
+ if (link === "close" && document.querySelector(":popover-open") !== null)
78
+ return;
79
+ if (arrow && target?.closest(SCROLL_REGION_SELECTOR))
80
+ return;
81
+ if (follow(controls, link))
82
+ keystroke.preventDefault();
83
+ }, { signal: handle.signal });
84
+ });
85
+ return (scope) => {
86
+ current = scope;
87
+ };
88
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Why JS: a page-wide Escape shortcut needs a key listener. No-JS baseline: the host is a
3
+ * plain link that clears the filters when clicked. It listens last, so a selection, an open
4
+ * dialog or popover, or a text field each takes Escape first.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { MixinFactory } from "remix/component";
10
+ /**
11
+ * Clicks the host `<a>` on an unclaimed Escape, so navigation, prefetch and frame targeting
12
+ * stay the link's own. The listener sits on the document in the bubble phase, which lets any
13
+ * handler that stops the key earlier (a selection bar clearing its rows) keep it.
14
+ *
15
+ * @example <a href={clearHref} mix={[escapeLink()]}>Clear filters</a>
16
+ */
17
+ export declare const escapeLink: MixinFactory<HTMLAnchorElement, []>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Why JS: a page-wide Escape shortcut needs a key listener. No-JS baseline: the host is a
3
+ * plain link that clears the filters when clicked. It listens last, so a selection, an open
4
+ * dialog or popover, or a text field each takes Escape first.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createMixin } from "remix/component";
10
+ import { isListKey } from "../utils/key-target.js";
11
+ /**
12
+ * Clicks the host `<a>` on an unclaimed Escape, so navigation, prefetch and frame targeting
13
+ * stay the link's own. The listener sits on the document in the bubble phase, which lets any
14
+ * handler that stops the key earlier (a selection bar clearing its rows) keep it.
15
+ *
16
+ * @example <a href={clearHref} mix={[escapeLink()]}>Clear filters</a>
17
+ */
18
+ export const escapeLink = createMixin((handle) => {
19
+ let controller;
20
+ handle.addEventListener("insert", (event) => {
21
+ controller?.abort();
22
+ controller = new AbortController();
23
+ let link = event.node;
24
+ link.ownerDocument.addEventListener("keydown", (key) => {
25
+ if (key.key !== "Escape" || key.shiftKey || !isListKey(key))
26
+ return;
27
+ key.preventDefault();
28
+ link.click();
29
+ }, { signal: controller.signal });
30
+ });
31
+ handle.addEventListener("remove", () => {
32
+ controller?.abort();
33
+ controller = undefined;
34
+ });
35
+ });
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The browser half of the keyboard help sheet: binds the key that opens the sheet, and reads
3
+ * the page's shortcut registry whenever it changes or the sheet opens, so the sheet lists the
4
+ * shortcuts the page has right now. Why JS: a key opening a dialog needs a listener. No-JS
5
+ * baseline: a `commandfor` button opens the sheet with the server-rendered groups.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import type { MixinFactory } from "remix/component";
11
+ import type { Shortcuts } from "../behaviors/shortcuts.js";
12
+ /**
13
+ * Types for {@link keyboardHelp}.
14
+ */
15
+ export declare namespace KeyboardHelpController {
16
+ /** Options for {@link keyboardHelp}. */
17
+ interface Options {
18
+ /** The combo that opens the sheet, e.g. `"?"`. */
19
+ shortcut: string;
20
+ /** What that combo lists as in the sheet. */
21
+ label: string;
22
+ /** The group that combo lists under. */
23
+ group?: string;
24
+ /**
25
+ * Receives the registry's rows and whether the keyboard prints Apple glyphs, once on
26
+ * mount and again whenever the rows may have changed.
27
+ */
28
+ onChange(entries: Shortcuts.Entry[], apple: boolean): void;
29
+ }
30
+ }
31
+ /**
32
+ * Binds the sheet's key on the `<dialog>` it is mixed onto, and reports the registry's rows on
33
+ * mount, on every registry change, and as the dialog opens.
34
+ *
35
+ * @param options The key, its label and group, and where the rows go.
36
+ * @example <Modal id="keys" mix={[keyboardHelp({ shortcut: "?", label: "Show shortcuts", onChange })]}>…</Modal>
37
+ */
38
+ export declare const keyboardHelp: MixinFactory<HTMLElement, [options: KeyboardHelpController.Options]>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The browser half of the keyboard help sheet: binds the key that opens the sheet, and reads
3
+ * the page's shortcut registry whenever it changes or the sheet opens, so the sheet lists the
4
+ * shortcuts the page has right now. Why JS: a key opening a dialog needs a listener. No-JS
5
+ * baseline: a `commandfor` button opens the sheet with the server-rendered groups.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { createMixin } from "remix/component";
11
+ import { isApplePlatform, shortcutRegistry } from "../behaviors/shortcuts.js";
12
+ /**
13
+ * Binds the sheet's key on the `<dialog>` it is mixed onto, and reports the registry's rows on
14
+ * mount, on every registry change, and as the dialog opens.
15
+ *
16
+ * @param options The key, its label and group, and where the rows go.
17
+ * @example <Modal id="keys" mix={[keyboardHelp({ shortcut: "?", label: "Show shortcuts", onChange })]}>…</Modal>
18
+ */
19
+ export const keyboardHelp = createMixin((handle) => {
20
+ let options;
21
+ handle.addEventListener("insert", (event) => {
22
+ let dialog = event.node;
23
+ let document = dialog.ownerDocument;
24
+ let registry = shortcutRegistry(document);
25
+ let signal = handle.signal;
26
+ let report = () => options?.onChange(registry.list(document), isApplePlatform());
27
+ if (options !== undefined && dialog instanceof HTMLDialogElement) {
28
+ registry.register({
29
+ keys: options.shortcut,
30
+ label: options.label,
31
+ group: options.group,
32
+ scope: null,
33
+ run: () => {
34
+ if (dialog.open)
35
+ return false;
36
+ report();
37
+ dialog.showModal();
38
+ return true;
39
+ },
40
+ signal,
41
+ });
42
+ }
43
+ registry.addEventListener("change", report, { signal });
44
+ dialog.addEventListener("command", report, { signal });
45
+ dialog.addEventListener("toggle", report, { signal });
46
+ report();
47
+ });
48
+ return (next) => {
49
+ options = next;
50
+ };
51
+ });