@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
package/dist/app/index.js CHANGED
@@ -6,36 +6,87 @@
6
6
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
7
  * @copyright Sergio Xalambrí 2026
8
8
  */
9
+ export * from "./app-shell-toggle.js";
10
+ export * from "./app-shell.js";
11
+ export * from "./auto-refresh.js";
9
12
  export * from "./behaviors/drag-session.js";
13
+ export * from "./behaviors/refresh-schedule.js";
10
14
  export * from "./behaviors/resize-session.js";
11
15
  export * from "./behaviors/selection-model.js";
16
+ export * from "./behaviors/shortcuts.js";
12
17
  export * from "./behaviors/toaster.js";
13
18
  export * from "./chart.js";
19
+ export * from "./command-palette.js";
14
20
  export * from "./context-menu.js";
21
+ export * from "./danger-zone.js";
22
+ export * from "./detail-sheet.js";
15
23
  export * from "./drop-indicator.js";
16
24
  export * from "./drop-zone.js";
25
+ export * from "./editor-layout.js";
17
26
  export * from "./empty.js";
18
27
  export * from "./file-trigger.js";
28
+ export * from "./filter-bar.js";
19
29
  export * from "./grid-list.js";
30
+ export * from "./keyboard-help.js";
20
31
  export * from "./menubar.js";
32
+ export * from "./mixins/app-shell-controls.js";
33
+ export * from "./mixins/auto-refresh.js";
21
34
  export * from "./mixins/chart-tooltip.js";
35
+ export * from "./mixins/command-palette.js";
22
36
  export * from "./mixins/context-menu.js";
37
+ export * from "./mixins/copy-permalink.js";
38
+ export * from "./mixins/detail-sheet-keys.js";
23
39
  export * from "./mixins/drag-reorder.js";
24
40
  export * from "./mixins/drop-zone.js";
41
+ export * from "./mixins/escape-link.js";
25
42
  export * from "./mixins/grid-list-keys.js";
43
+ export * from "./mixins/keyboard-help.js";
26
44
  export * from "./mixins/menubar-keys.js";
45
+ export * from "./mixins/optimistic-toggle-sync.js";
46
+ export * from "./mixins/range-picker-keys.js";
27
47
  export * from "./mixins/resize-handle.js";
48
+ export * from "./mixins/row-navigation.js";
49
+ export * from "./mixins/save-bar-sync.js";
50
+ export * from "./mixins/save-shortcut.js";
51
+ export * from "./mixins/save-status-sync.js";
52
+ export * from "./mixins/selection-bar-sync.js";
53
+ export * from "./mixins/split-view.js";
54
+ export * from "./mixins/status-strip-keys.js";
55
+ export * from "./mixins/submit-on-change.js";
56
+ export * from "./mixins/table-selection.js";
57
+ export * from "./mixins/toast-queue.js";
58
+ export * from "./mixins/toast-stack.js";
28
59
  export * from "./mixins/tree-keys.js";
60
+ export * from "./optimistic-toggle.js";
61
+ export * from "./page-header.js";
62
+ export * from "./range-picker.js";
29
63
  export * from "./resizable.js";
64
+ export * from "./save-bar.js";
65
+ export * from "./save-status.js";
66
+ export * from "./selection-bar.js";
67
+ export * from "./settings-layout.js";
68
+ export * from "./settings-section.js";
30
69
  export * from "./shortcut-list.js";
31
70
  export * from "./skeleton.js";
71
+ export * from "./sparkline.js";
72
+ export * from "./split-view.js";
73
+ export * from "./stat-card.js";
74
+ export * from "./status-strip.js";
32
75
  export * from "./styles/chart-palette.js";
33
76
  export * from "./styles/graphic-host.js";
34
77
  export * from "./styles/legend-toggle.js";
78
+ export * from "./styles/toast-stack.js";
35
79
  export * from "./table.js";
36
80
  export * from "./toast.js";
81
+ export * from "./toasts.js";
37
82
  export * from "./toolbar.js";
38
83
  export * from "./tree.js";
39
84
  export * from "./utils/chart-marker-indices.js";
40
85
  export * from "./utils/chart-path.js";
41
86
  export * from "./utils/chart-scale.js";
87
+ export * from "./utils/edited-time.js";
88
+ export * from "./utils/key-target.js";
89
+ export * from "./utils/search-params.js";
90
+ export * from "./utils/shortcut-groups.js";
91
+ export * from "./utils/split-view-layout.js";
92
+ export * from "./view-options.js";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The keyboard cheat sheet `?` opens: a 640px dialog listing every shortcut on the page in
3
+ * titled groups, two columns wide where it fits. The server renders the groups it is given;
4
+ * in the browser it adds whatever the page's shortcut registry holds.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { EntryComponent } from "remix/component";
10
+ import type { HeadingLevel } from "../components/heading-scope.js";
11
+ /**
12
+ * Types for {@link KeyboardHelp}. Declared as `type`s, since the props cross into the
13
+ * browser with the island and are checked as serializable.
14
+ */
15
+ export declare namespace KeyboardHelp {
16
+ /** One row: the keys, or alternatives, and what they do. */
17
+ type Shortcut = {
18
+ /** A combo or `g`+key sequence, or several as alternatives, e.g. `["j", "arrowdown"]`. */
19
+ keys: string | string[];
20
+ label: string;
21
+ };
22
+ /** A titled group of rows. */
23
+ type Group = {
24
+ title: string;
25
+ shortcuts: Shortcut[];
26
+ };
27
+ /** Every string the sheet shows. */
28
+ type Labels = {
29
+ /** The dialog's heading, e.g. "Keyboard shortcuts". */
30
+ title: string;
31
+ description?: string;
32
+ /** Names the close control. */
33
+ close: string;
34
+ /** Joins alternatives, e.g. "or". */
35
+ or: string;
36
+ /** What the sheet's own key lists as, e.g. "Show keyboard shortcuts". */
37
+ open: string;
38
+ /** The group the sheet's own key lists under, e.g. "General". */
39
+ general: string;
40
+ /** The heading for registered shortcuts that name no group. */
41
+ other: string;
42
+ };
43
+ /** Props for {@link KeyboardHelp}. */
44
+ type Props = {
45
+ /** The dialog's `id`, which a button's `commandfor` names to open it. */
46
+ id: string;
47
+ labels: Labels;
48
+ /** Groups rendered on the server, before the page's registry is read. */
49
+ groups?: Group[];
50
+ /** The key that opens the sheet. @default "?" */
51
+ shortcut?: string;
52
+ /**
53
+ * The title's heading level, its groups one below. The sheet reads no ambient heading
54
+ * scope, so server and browser render the same tags. @default 2
55
+ */
56
+ level?: HeadingLevel;
57
+ };
58
+ }
59
+ /**
60
+ * Renders the sheet: a modal dialog with its close control, heading, and one {@link ShortcutList}
61
+ * per group in columns at least 16rem wide. Open it with its key, or from a button with
62
+ * `commandfor={id} command="show-modal"`; load `@sdxc/ui/app/keyboard-help` in the browser entry.
63
+ *
64
+ * @example <KeyboardHelp id="keys" labels={labels} groups={[{ title: "Navigation", shortcuts: [{ keys: "g m", label: "Go to Monitors" }] }]} />
65
+ */
66
+ export declare const KeyboardHelp: EntryComponent<KeyboardHelp.Props>;
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { fg } from "@sdxc/u/color";
3
+ import { contents, flex, gap, grid, gridTemplate, items, justify } from "@sdxc/u/layout";
4
+ import { m, maxIs, mbs } from "@sdxc/u/size";
5
+ import { pretty, text, weight } from "@sdxc/u/typography";
6
+ import { clientEntry } from "remix/component";
7
+ import { HeadingScope, TAG_BY_LEVEL } from "../components/heading-scope.js";
8
+ import { Keyboard } from "../components/keyboard.js";
9
+ import { Modal } from "../components/modal.js";
10
+ import { shortcutAlternatives, shortcutGlyphs } from "./behaviors/shortcuts.js";
11
+ import { keyboardHelp } from "./mixins/keyboard-help.js";
12
+ import { ShortcutList } from "./shortcut-list.js";
13
+ import { mergeShortcutGroups } from "./utils/shortcut-groups.js";
14
+ /** The key that opens the sheet when none is given. */
15
+ const DEFAULT_SHORTCUT = "?";
16
+ /** A dialog opens over a page that already has its `<h1>`, so its title sits one below. */
17
+ const DEFAULT_LEVEL = 2;
18
+ /**
19
+ * Renders the sheet: a modal dialog with its close control, heading, and one {@link ShortcutList}
20
+ * per group in columns at least 16rem wide. Open it with its key, or from a button with
21
+ * `commandfor={id} command="show-modal"`; load `@sdxc/ui/app/keyboard-help` in the browser entry.
22
+ *
23
+ * @example <KeyboardHelp id="keys" labels={labels} groups={[{ title: "Navigation", shortcuts: [{ keys: "g m", label: "Go to Monitors" }] }]} />
24
+ */
25
+ export const KeyboardHelp = clientEntry("@sdxc/ui/app/keyboard-help#KeyboardHelp", function KeyboardHelp(handle) {
26
+ let entries = [];
27
+ let apple = true;
28
+ /** Takes the registry's rows, re-rendering only when they or the platform changed. */
29
+ let onChange = (next, nextApple) => {
30
+ if (nextApple === apple && JSON.stringify(next) === JSON.stringify(entries))
31
+ return;
32
+ entries = next;
33
+ apple = nextApple;
34
+ void handle.update();
35
+ };
36
+ return () => {
37
+ let { id, labels, groups, shortcut, level = DEFAULT_LEVEL } = handle.props;
38
+ let GroupTitle = TAG_BY_LEVEL[Math.min(level + 1, 6)];
39
+ let titleId = `${id}-title`;
40
+ let shown = mergeShortcutGroups(groups ?? [], entries, labels.other);
41
+ return (_jsxs(Modal, { id: id, "aria-labelledby": titleId, closedby: "any", "data-slot": "keyboard-help", mix: [
42
+ maxIs("var(--ui-app-keyboard-help-width, 40rem)"),
43
+ keyboardHelp({
44
+ shortcut: shortcut ?? DEFAULT_SHORTCUT,
45
+ label: labels.open,
46
+ group: labels.general,
47
+ onChange,
48
+ }),
49
+ ], children: [_jsx(Modal.Close, { commandfor: id, "aria-label": labels.close }), _jsxs(Modal.Header, { children: [_jsx(HeadingScope, { level: level, children: _jsx(Modal.Title, { id: titleId, children: labels.title }) }), labels.description ? (_jsx(Modal.Description, { children: labels.description })) : null] }), _jsx("div", { mix: [
50
+ grid(),
51
+ gap(6, 8),
52
+ items("start"),
53
+ gridTemplate({ columns: "repeat(auto-fit, minmax(min(16rem, 100%), 1fr))" }),
54
+ ], children: shown.map((group) => (_jsxs("section", { "data-slot": "keyboard-help-group", children: [_jsx(GroupTitle, { mix: [m(0), text("sm"), weight("semibold"), fg("neutral.emphasis")], children: group.title }), _jsx(ShortcutList, { mix: [m(0), mbs(3)], children: group.shortcuts.map((row) => (_jsxs("div", { "data-slot": "shortcut", mix: [contents()], children: [_jsx("dt", { mix: [text("sm"), fg("neutral"), pretty()], children: row.label }), _jsx("dd", { mix: [m(0), flex(), gap(1), items("center"), justify("end"), text("xs")], children: shortcutAlternatives(row.keys).map((alternative, index) => (_jsxs("span", { mix: [flex(), gap(1), items("center")], children: [index > 0 ? (_jsx("span", { mix: [fg("neutral.muted")], children: labels.or })) : null, shortcutGlyphs(alternative, apple).map((glyph, cap) => (_jsx(Keyboard, { mix: [m(0), weight("medium")], children: glyph }, `${index}-${cap}`)))] }, alternative))) })] }, `${shortcutAlternatives(row.keys).join(",")}|${row.label}`))) })] }, group.title))) })] }));
55
+ };
56
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Why JS: writing the collapse cookie, a ⌘B shortcut, closing the phone sheet when a link is
3
+ * followed in place and following a back row on Esc have no HTML or CSS equivalent.
4
+ * No-JS baseline: the checkbox still collapses the sidebar through CSS and the sheet opens and
5
+ * closes through the Popover API; the collapse lasts until the next page load.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import type { ElementProps, MixinFactory } from "remix/component";
11
+ /** The shortcut that collapses and expands the sidebar, or opens the sheet on a phone. */
12
+ export declare const APP_SHELL_SHORTCUT = "mod+b";
13
+ /** The width under which an app shell's sidebar is a sheet behind the menu button. */
14
+ export type AppShellSheetBelow = "48rem" | "64rem";
15
+ /**
16
+ * The media queries on either side of `sheetBelow`, docked from it and a sheet under it, which
17
+ * the shell's styles, its toggle and these controls all read so they switch at the same width.
18
+ *
19
+ * @param sheetBelow The width under which the sidebar is a sheet.
20
+ * @returns The docked and sheet media queries.
21
+ * @example appShellQueries("64rem").docked // "(min-width: 64rem)"
22
+ */
23
+ export declare function appShellQueries(sheetBelow: AppShellSheetBelow): {
24
+ docked: string;
25
+ sheet: string;
26
+ };
27
+ /** Options for {@link appShellControls}. */
28
+ export interface AppShellControlsOptions {
29
+ /** The cookie the collapsed state is written to, as `"true"` or `"false"`. */
30
+ cookieName: string;
31
+ /** The sidebar element's id, which is also the sheet's popover. */
32
+ sidebarId: string;
33
+ /** @default "48rem" */
34
+ sheetBelow?: AppShellSheetBelow;
35
+ }
36
+ /**
37
+ * Wires the shell around the checkbox it is mixed onto until the checkbox leaves the page.
38
+ * ⌘B (Ctrl+B elsewhere) flips the checkbox while the sidebar is docked and opens or closes the
39
+ * sheet below `sheetBelow`; it stays the editor's bold inside a text area or rich editor.
40
+ *
41
+ * @example
42
+ * <input type="checkbox" data-app-shell-collapse mix={[appShellControls({ cookieName, sidebarId })]} />
43
+ */
44
+ export declare const appShellControls: MixinFactory<HTMLInputElement, [
45
+ options: AppShellControlsOptions
46
+ ], ElementProps>;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Why JS: writing the collapse cookie, a ⌘B shortcut, closing the phone sheet when a link is
3
+ * followed in place and following a back row on Esc have no HTML or CSS equivalent.
4
+ * No-JS baseline: the checkbox still collapses the sidebar through CSS and the sheet opens and
5
+ * closes through the Popover API; the collapse lasts until the next page load.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { createMixin } from "remix/component";
11
+ import { matchesKeyCombo } from "../../utils/key-combo.js";
12
+ import { writeCookie } from "../../utils/write-cookie.js";
13
+ /** The shortcut that collapses and expands the sidebar, or opens the sheet on a phone. */
14
+ export const APP_SHELL_SHORTCUT = "mod+b";
15
+ /** Where the sidebar becomes a sheet when `sheetBelow` is omitted. */
16
+ const DEFAULT_SHEET_BELOW = "48rem";
17
+ /** Where a ⌘B is the editor's bold and an Esc belongs to the field. */
18
+ const EDITING_SELECTOR = 'textarea, [contenteditable]:not([contenteditable="false"])';
19
+ /**
20
+ * The media queries on either side of `sheetBelow`, docked from it and a sheet under it, which
21
+ * the shell's styles, its toggle and these controls all read so they switch at the same width.
22
+ *
23
+ * @param sheetBelow The width under which the sidebar is a sheet.
24
+ * @returns The docked and sheet media queries.
25
+ * @example appShellQueries("64rem").docked // "(min-width: 64rem)"
26
+ */
27
+ export function appShellQueries(sheetBelow) {
28
+ let rem = Number.parseFloat(sheetBelow);
29
+ return { docked: `(min-width: ${rem}rem)`, sheet: `(max-width: ${rem - 0.0625}rem)` };
30
+ }
31
+ /**
32
+ * Wires the shell around the checkbox it is mixed onto until the checkbox leaves the page.
33
+ * ⌘B (Ctrl+B elsewhere) flips the checkbox while the sidebar is docked and opens or closes the
34
+ * sheet below `sheetBelow`; it stays the editor's bold inside a text area or rich editor.
35
+ *
36
+ * @example
37
+ * <input type="checkbox" data-app-shell-collapse mix={[appShellControls({ cookieName, sidebarId })]} />
38
+ */
39
+ export const appShellControls = createMixin((handle) => {
40
+ let options;
41
+ let controller;
42
+ handle.addEventListener("insert", (event) => {
43
+ controller?.abort();
44
+ controller = new AbortController();
45
+ enhance(event.node, () => options, controller.signal);
46
+ });
47
+ handle.addEventListener("remove", () => {
48
+ controller?.abort();
49
+ controller = undefined;
50
+ });
51
+ return (next) => {
52
+ options = next;
53
+ };
54
+ });
55
+ /** Attaches every listener the shell needs to `host`'s document until `signal` aborts. */
56
+ function enhance(host, readOptions, signal) {
57
+ let doc = host.ownerDocument;
58
+ let sidebar = () => {
59
+ let id = readOptions()?.sidebarId;
60
+ return id ? doc.getElementById(id) : null;
61
+ };
62
+ host.addEventListener("change", () => {
63
+ let name = readOptions()?.cookieName;
64
+ if (name)
65
+ writeCookie(name, host.checked);
66
+ }, { signal });
67
+ doc.addEventListener("keydown", (event) => {
68
+ if (event.defaultPrevented || event.repeat)
69
+ return;
70
+ if (matchesKeyCombo(event, APP_SHELL_SHORTCUT)) {
71
+ if (isEditing(event.target))
72
+ return;
73
+ event.preventDefault();
74
+ toggle(host, sidebar());
75
+ return;
76
+ }
77
+ if (event.key === "Escape")
78
+ followBackRow(event, sidebar());
79
+ }, { signal });
80
+ doc.addEventListener("click", (event) => {
81
+ let target = event.target;
82
+ let element = sidebar();
83
+ if (!element || !(target instanceof Element))
84
+ return;
85
+ if (!element.contains(target) || !target.closest("a[href]"))
86
+ return;
87
+ if (element.matches(":popover-open"))
88
+ element.hidePopover();
89
+ }, { signal });
90
+ let sheetBelow = readOptions()?.sheetBelow ?? DEFAULT_SHEET_BELOW;
91
+ let docked = doc.defaultView?.matchMedia(appShellQueries(sheetBelow).docked);
92
+ docked?.addEventListener("change", () => {
93
+ let element = sidebar();
94
+ if (docked.matches && element?.matches(":popover-open"))
95
+ element.hidePopover();
96
+ }, { signal });
97
+ }
98
+ /**
99
+ * Flips the docked sidebar between column and rail through the checkbox, so the change event
100
+ * writes the cookie; with the checkbox hidden (a phone), opens or closes the sheet instead.
101
+ */
102
+ function toggle(host, sidebar) {
103
+ if (host.closest("label")?.checkVisibility() ?? host.checkVisibility()) {
104
+ host.click();
105
+ return;
106
+ }
107
+ sidebar?.togglePopover();
108
+ }
109
+ /**
110
+ * Follows the sidebar's back row on Esc, the way a swapped settings panel returns to the app.
111
+ * Esc stays with whatever owns it first: an open dialog, menu or sheet, or a focused field.
112
+ */
113
+ function followBackRow(event, sidebar) {
114
+ if (!sidebar || isEditing(event.target))
115
+ return;
116
+ let target = event.target;
117
+ if (target instanceof Element && target.closest("input, select"))
118
+ return;
119
+ let doc = sidebar.ownerDocument;
120
+ if (doc.querySelector(":popover-open, dialog[open]"))
121
+ return;
122
+ let back = sidebar.querySelector("a[data-app-shell-back]");
123
+ if (!back)
124
+ return;
125
+ event.preventDefault();
126
+ back.click();
127
+ }
128
+ /** Whether `target` is a text area or rich editor, where ⌘B and Esc belong to the text. */
129
+ function isEditing(target) {
130
+ return target instanceof Element && target.closest(EDITING_SELECTOR) !== null;
131
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Why JS: reloading a list on an interval, and pausing while the tab is hidden, needs a timer
3
+ * and the Page Visibility API. No-JS baseline: the list shows what the page loaded with, and
4
+ * the host `<time>` keeps naming when that was, until the reader reloads.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { MixinFactory } from "remix/component";
10
+ /** Types for {@link autoRefresh}. */
11
+ export declare namespace AutoRefreshTimer {
12
+ /** Configuration for {@link autoRefresh}, read when the host is inserted. */
13
+ interface Options {
14
+ /** Milliseconds between reloads; 0 or less leaves the host as rendered. */
15
+ every: number;
16
+ /** Reloads the frame or page the list lives in. */
17
+ reload: () => Promise<unknown>;
18
+ /** Locale the refreshed time is written in. Defaults to the runtime's. */
19
+ locale?: string;
20
+ }
21
+ }
22
+ /**
23
+ * Runs a {@link RefreshSchedule} while the host `<time>` is in the document, counted from the
24
+ * host's own `datetime`. It pauses while the page is hidden, catches up with one reload when
25
+ * shown, sets `data-paused` meanwhile, and rewrites the host's `datetime` and text after each reload.
26
+ *
27
+ * @example <time dateTime={iso} mix={[autoRefresh({ every: 30_000, reload: () => handle.frames.top.reload() })]}>{text}</time>
28
+ */
29
+ export declare const autoRefresh: MixinFactory<HTMLTimeElement, [options: AutoRefreshTimer.Options]>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Why JS: reloading a list on an interval, and pausing while the tab is hidden, needs a timer
3
+ * and the Page Visibility API. No-JS baseline: the list shows what the page loaded with, and
4
+ * the host `<time>` keeps naming when that was, until the reader reloads.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createMixin } from "remix/component";
10
+ import { RefreshSchedule } from "../behaviors/refresh-schedule.js";
11
+ /**
12
+ * Runs a {@link RefreshSchedule} while the host `<time>` is in the document, counted from the
13
+ * host's own `datetime`. It pauses while the page is hidden, catches up with one reload when
14
+ * shown, sets `data-paused` meanwhile, and rewrites the host's `datetime` and text after each reload.
15
+ *
16
+ * @example <time dateTime={iso} mix={[autoRefresh({ every: 30_000, reload: () => handle.frames.top.reload() })]}>{text}</time>
17
+ */
18
+ export const autoRefresh = createMixin((handle) => {
19
+ let options;
20
+ let controller;
21
+ handle.addEventListener("insert", (event) => {
22
+ controller?.abort();
23
+ controller = new AbortController();
24
+ if (options)
25
+ follow(event.node, options, controller.signal);
26
+ });
27
+ handle.addEventListener("remove", () => {
28
+ controller?.abort();
29
+ controller = undefined;
30
+ });
31
+ return (next) => {
32
+ options = next;
33
+ };
34
+ });
35
+ /**
36
+ * Starts the schedule for `host` until `signal` aborts.
37
+ *
38
+ * @param host The `<time>` naming when the list was last fetched.
39
+ * @param options The interval, the reload and the locale.
40
+ * @param signal Ends the schedule and its listeners.
41
+ */
42
+ function follow(host, options, signal) {
43
+ let doc = host.ownerDocument;
44
+ let initial = new Date(host.dateTime);
45
+ let schedule = new RefreshSchedule({
46
+ every: options.every,
47
+ reload: options.reload,
48
+ refreshedAt: Number.isNaN(initial.getTime()) ? undefined : initial,
49
+ });
50
+ let format = new Intl.DateTimeFormat(options.locale, { timeStyle: "medium" });
51
+ schedule.addEventListener("refresh", () => {
52
+ host.dateTime = schedule.refreshedAt.toISOString();
53
+ host.textContent = format.format(schedule.refreshedAt);
54
+ }, { signal });
55
+ /** Pauses with the page and resumes once it is shown again. */
56
+ let sync = () => {
57
+ host.toggleAttribute("data-paused", doc.hidden);
58
+ if (doc.hidden)
59
+ schedule.pause();
60
+ else
61
+ schedule.resume();
62
+ };
63
+ doc.addEventListener("visibilitychange", sync, { signal });
64
+ signal.addEventListener("abort", () => schedule.stop());
65
+ sync();
66
+ }
@@ -0,0 +1,56 @@
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 type { MixinFactory } from "remix/component";
11
+ /** How many recent commands the palette offers before anything is typed. */
12
+ export declare const PALETTE_RECENT_LIMIT = 5;
13
+ /** Marks each row with its command's id, which `recent` and the remembered list name. */
14
+ export declare const PALETTE_ITEM_ATTRIBUTE = "data-palette-item";
15
+ /** Marks the link or button a row presses. */
16
+ export declare const PALETTE_CONTROL_ATTRIBUTE = "data-palette-control";
17
+ /** Names the page a row's control opens instead of acting. */
18
+ export declare const PALETTE_GOTO_ATTRIBUTE = "data-palette-goto";
19
+ /** Marks a page of commands with its id. */
20
+ export declare const PALETTE_PAGE_ATTRIBUTE = "data-palette-page";
21
+ /** Marks a row the island copied into the Recent group. */
22
+ export declare const PALETTE_CLONE_ATTRIBUTE = "data-palette-clone";
23
+ /** Marks a shortcut hint with the combo it prints, so the island reprints it per platform. */
24
+ export declare const PALETTE_HINT_ATTRIBUTE = "data-shortcut-hint";
25
+ /**
26
+ * Types for {@link paletteController}.
27
+ */
28
+ export declare namespace PaletteController {
29
+ /** Plain data only, since the options cross into the browser with the palette's island. */
30
+ type Options = {
31
+ /** The combo that toggles the palette. */
32
+ shortcut: string;
33
+ /** The help-sheet label of that combo. */
34
+ open: string;
35
+ /** The announced result count, with `{count}` replaced. */
36
+ results: string;
37
+ /** Ids of commands the server offers under Recent. */
38
+ recent: string[];
39
+ /** The `localStorage` key commands run from the palette are remembered under. */
40
+ remember?: string;
41
+ };
42
+ }
43
+ /**
44
+ * Lower-cases text and strips its accents, so "cafe" finds "Café" and "Équipe" finds "equipe".
45
+ *
46
+ * @param value Text to fold.
47
+ * @returns The folded text.
48
+ */
49
+ export declare function foldSearchText(value: string): string;
50
+ /**
51
+ * Wires the palette `<dialog>` the host sits in, for as long as the host stays mounted.
52
+ *
53
+ * @param options The toggle key, the copy it announces with, and where recents come from.
54
+ * @example <div hidden mix={[paletteController({ shortcut: "mod+k", open: "Open command menu", results: "{count} results", recent: [] })]} />
55
+ */
56
+ export declare const paletteController: MixinFactory<HTMLElement, [options: PaletteController.Options]>;