@sdxc/ui 2026.11.11 → 2026.11.14

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 (191) hide show
  1. package/README.md +89 -44
  2. package/dist/app/app-shell-toggle.d.ts +2 -0
  3. package/dist/app/app-shell-toggle.js +5 -2
  4. package/dist/app/app-shell.d.ts +25 -1
  5. package/dist/app/app-shell.js +73 -38
  6. package/dist/app/auto-refresh.d.ts +2 -0
  7. package/dist/app/auto-refresh.js +3 -3
  8. package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
  9. package/dist/app/behaviors/refresh-schedule.js +4 -3
  10. package/dist/app/board.d.ts +123 -0
  11. package/dist/app/board.js +224 -0
  12. package/dist/app/chart.d.ts +2 -2
  13. package/dist/app/chart.js +7 -3
  14. package/dist/app/check-runs.d.ts +116 -0
  15. package/dist/app/check-runs.js +201 -0
  16. package/dist/app/code-view.d.ts +172 -0
  17. package/dist/app/code-view.js +414 -0
  18. package/dist/app/command-palette.d.ts +38 -3
  19. package/dist/app/command-palette.js +53 -5
  20. package/dist/app/contribution-graph.d.ts +106 -0
  21. package/dist/app/contribution-graph.js +289 -0
  22. package/dist/app/detail-sheet.d.ts +7 -0
  23. package/dist/app/detail-sheet.js +7 -7
  24. package/dist/app/diff.d.ts +200 -0
  25. package/dist/app/diff.js +702 -0
  26. package/dist/app/filter-bar.d.ts +20 -0
  27. package/dist/app/filter-bar.js +35 -15
  28. package/dist/app/filter-menu.d.ts +144 -0
  29. package/dist/app/filter-menu.js +480 -0
  30. package/dist/app/gantt.d.ts +108 -0
  31. package/dist/app/gantt.js +420 -0
  32. package/dist/app/index.d.ts +19 -0
  33. package/dist/app/index.js +19 -0
  34. package/dist/app/log-viewer.d.ts +120 -0
  35. package/dist/app/log-viewer.js +384 -0
  36. package/dist/app/merge-box.d.ts +97 -0
  37. package/dist/app/merge-box.js +227 -0
  38. package/dist/app/mixins/app-shell-controls.d.ts +4 -1
  39. package/dist/app/mixins/app-shell-controls.js +64 -4
  40. package/dist/app/mixins/auto-refresh.d.ts +5 -2
  41. package/dist/app/mixins/auto-refresh.js +9 -3
  42. package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
  43. package/dist/app/mixins/close-popover-on-submit.js +32 -0
  44. package/dist/app/mixins/code-view-selection.d.ts +60 -0
  45. package/dist/app/mixins/code-view-selection.js +276 -0
  46. package/dist/app/mixins/command-palette.d.ts +15 -4
  47. package/dist/app/mixins/command-palette.js +94 -6
  48. package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
  49. package/dist/app/mixins/contribution-graph-keys.js +155 -0
  50. package/dist/app/mixins/diff-interactions.d.ts +72 -0
  51. package/dist/app/mixins/diff-interactions.js +269 -0
  52. package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
  53. package/dist/app/mixins/filter-menu-keys.js +91 -0
  54. package/dist/app/mixins/gantt-today.d.ts +17 -0
  55. package/dist/app/mixins/gantt-today.js +50 -0
  56. package/dist/app/mixins/log-viewer.d.ts +29 -0
  57. package/dist/app/mixins/log-viewer.js +333 -0
  58. package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
  59. package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
  60. package/dist/app/mixins/save-bar-sync.d.ts +7 -1
  61. package/dist/app/mixins/save-bar-sync.js +23 -4
  62. package/dist/app/mixins/save-status-sync.js +23 -1
  63. package/dist/app/mixins/split-view.js +1 -1
  64. package/dist/app/mixins/submit-on-close.d.ts +17 -0
  65. package/dist/app/mixins/submit-on-close.js +52 -0
  66. package/dist/app/mixins/tree-filter.d.ts +44 -0
  67. package/dist/app/mixins/tree-filter.js +111 -0
  68. package/dist/app/mixins/tree-navigation.d.ts +50 -0
  69. package/dist/app/mixins/tree-navigation.js +216 -0
  70. package/dist/app/optimistic-toggle.d.ts +8 -0
  71. package/dist/app/optimistic-toggle.js +3 -2
  72. package/dist/app/page-header.d.ts +18 -3
  73. package/dist/app/page-header.js +105 -50
  74. package/dist/app/review-thread.d.ts +115 -0
  75. package/dist/app/review-thread.js +116 -0
  76. package/dist/app/save-bar.d.ts +5 -0
  77. package/dist/app/save-bar.js +1 -1
  78. package/dist/app/settings-layout.d.ts +5 -0
  79. package/dist/app/settings-layout.js +5 -5
  80. package/dist/app/skeleton.d.ts +9 -0
  81. package/dist/app/skeleton.js +28 -0
  82. package/dist/app/split-view.d.ts +4 -0
  83. package/dist/app/split-view.js +3 -3
  84. package/dist/app/styles/code-tokens.d.ts +24 -0
  85. package/dist/app/styles/code-tokens.js +47 -0
  86. package/dist/app/tab-bar.d.ts +59 -0
  87. package/dist/app/tab-bar.js +111 -0
  88. package/dist/app/tree.d.ts +111 -14
  89. package/dist/app/tree.js +202 -15
  90. package/dist/app/utils/ansi.d.ts +55 -0
  91. package/dist/app/utils/ansi.js +157 -0
  92. package/dist/app/utils/diff-rows.d.ts +82 -0
  93. package/dist/app/utils/diff-rows.js +209 -0
  94. package/dist/app/utils/fuzzy-path.d.ts +58 -0
  95. package/dist/app/utils/fuzzy-path.js +202 -0
  96. package/dist/app/utils/line-range.d.ts +48 -0
  97. package/dist/app/utils/line-range.js +61 -0
  98. package/dist/app/utils/log-lines.d.ts +107 -0
  99. package/dist/app/utils/log-lines.js +170 -0
  100. package/dist/app/utils/tree-filter.d.ts +19 -0
  101. package/dist/app/utils/tree-filter.js +26 -0
  102. package/dist/app/view-options.d.ts +2 -0
  103. package/dist/app/view-options.js +2 -2
  104. package/dist/chat/activity.d.ts +72 -0
  105. package/dist/chat/activity.js +184 -0
  106. package/dist/chat/composer-submit.d.ts +38 -0
  107. package/dist/chat/composer-submit.js +44 -0
  108. package/dist/chat/composer.d.ts +47 -0
  109. package/dist/chat/composer.js +100 -0
  110. package/dist/chat/index.d.ts +6 -0
  111. package/dist/chat/index.js +6 -0
  112. package/dist/chat/mixins/composer-send.d.ts +32 -0
  113. package/dist/chat/mixins/composer-send.js +121 -0
  114. package/dist/chat/mixins/reveal-stream.d.ts +68 -0
  115. package/dist/chat/mixins/reveal-stream.js +184 -0
  116. package/dist/chat/mixins/stream-target.d.ts +18 -0
  117. package/dist/chat/mixins/stream-target.js +38 -0
  118. package/dist/components/button.js +7 -1
  119. package/dist/components/character-count.d.ts +44 -0
  120. package/dist/components/character-count.js +68 -0
  121. package/dist/components/index.d.ts +2 -0
  122. package/dist/components/index.js +2 -0
  123. package/dist/components/label-chip.d.ts +42 -0
  124. package/dist/components/label-chip.js +86 -0
  125. package/dist/components/property-list.d.ts +9 -2
  126. package/dist/components/property-list.js +11 -6
  127. package/dist/components/textarea.js +6 -1
  128. package/dist/components/timeline.d.ts +62 -5
  129. package/dist/components/timeline.js +124 -5
  130. package/dist/docs/code-block.js +8 -31
  131. package/dist/docs/file-tree.js +3 -48
  132. package/dist/landing/case-study.d.ts +79 -0
  133. package/dist/landing/case-study.js +162 -0
  134. package/dist/landing/contributor-wall.d.ts +72 -0
  135. package/dist/landing/contributor-wall.js +129 -0
  136. package/dist/landing/countdown.d.ts +88 -0
  137. package/dist/landing/countdown.js +91 -0
  138. package/dist/landing/episode-player.d.ts +87 -0
  139. package/dist/landing/episode-player.js +113 -0
  140. package/dist/landing/faq-band.d.ts +3 -2
  141. package/dist/landing/faq-band.js +4 -3
  142. package/dist/landing/index.d.ts +7 -0
  143. package/dist/landing/index.js +7 -0
  144. package/dist/landing/landing-header.js +15 -4
  145. package/dist/landing/mixins/countdown-tick.d.ts +29 -0
  146. package/dist/landing/mixins/countdown-tick.js +65 -0
  147. package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
  148. package/dist/landing/mixins/usage-estimate-live.js +120 -0
  149. package/dist/landing/phone-frame.d.ts +2 -1
  150. package/dist/landing/price-list.d.ts +68 -0
  151. package/dist/landing/price-list.js +125 -0
  152. package/dist/landing/scroll-scene.d.ts +59 -0
  153. package/dist/landing/scroll-scene.js +70 -0
  154. package/dist/landing/sponsor-wall.d.ts +30 -6
  155. package/dist/landing/sponsor-wall.js +70 -14
  156. package/dist/landing/typed-terminal.d.ts +24 -6
  157. package/dist/landing/typed-terminal.js +22 -14
  158. package/dist/landing/usage-estimate.d.ts +127 -0
  159. package/dist/landing/usage-estimate.js +164 -0
  160. package/dist/landing/utils/countdown.d.ts +33 -0
  161. package/dist/landing/utils/countdown.js +42 -0
  162. package/dist/landing/utils/pause-toggle.d.ts +2 -1
  163. package/dist/mixins/character-count.d.ts +62 -0
  164. package/dist/mixins/character-count.js +139 -0
  165. package/dist/mixins/index.d.ts +6 -2
  166. package/dist/mixins/index.js +6 -2
  167. package/dist/mixins/invoker-fields.d.ts +18 -0
  168. package/dist/mixins/invoker-fields.js +60 -0
  169. package/dist/mixins/media-sync.d.ts +58 -0
  170. package/dist/mixins/media-sync.js +102 -0
  171. package/dist/mixins/menu-keys.d.ts +11 -0
  172. package/dist/mixins/menu-keys.js +79 -70
  173. package/dist/mixins/sortable.d.ts +96 -0
  174. package/dist/mixins/sortable.js +433 -0
  175. package/dist/utils/code-lines.d.ts +26 -0
  176. package/dist/utils/code-lines.js +29 -0
  177. package/dist/utils/file-icon.d.ts +31 -0
  178. package/dist/utils/file-icon.js +60 -0
  179. package/dist/utils/index.d.ts +2 -0
  180. package/dist/utils/index.js +2 -0
  181. package/dist/utils/write-cookie.d.ts +15 -15
  182. package/dist/utils/write-cookie.js +10 -16
  183. package/dist/video/index.d.ts +11 -0
  184. package/dist/video/index.js +11 -0
  185. package/dist/video/mixins/video-player-sync.d.ts +27 -0
  186. package/dist/video/mixins/video-player-sync.js +413 -0
  187. package/dist/video/utils/timeline.d.ts +55 -0
  188. package/dist/video/utils/timeline.js +90 -0
  189. package/dist/video/video-player.d.ts +261 -0
  190. package/dist/video/video-player.js +927 -0
  191. package/package.json +6 -3
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Narrows a file tree as the reader types into its filter field: leaves that miss the query
3
+ * hide, every folder holding a match opens, folders with none hide, and a query matching no
4
+ * file shows the tree's no-matches line.
5
+ * Why JS: HTML has no live filtering of other elements. No-JS baseline: the field submits its
6
+ * GET form (`?filter=`) and the server renders the narrowed tree.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import { createElement, createMixin, on } from "remix/component";
12
+ import { treeFilterMatches } from "../utils/tree-filter.js";
13
+ /** Attribute every file row carries, holding the path the filter matches. */
14
+ export const TREE_FILTER_TEXT_ATTRIBUTE = "data-filter-text";
15
+ /** Selector for the file rows a filter narrows. */
16
+ const LEAF_SELECTOR = "[data-tree-leaf]";
17
+ /** Selector for the rows focus can move into from the field. */
18
+ const ROW_SELECTOR = '[role="treeitem"]';
19
+ /**
20
+ * Each folder's open state from before the filter changed it, so clearing the query puts
21
+ * every folder back the way the reader left it.
22
+ */
23
+ const OPEN_BEFORE_FILTER = new WeakMap();
24
+ /**
25
+ * Applies `query` to every row in `tree`. Folders are visited deepest first, so a folder
26
+ * reads its subfolders' final state when it decides whether it still holds a match; the
27
+ * tree's no-matches line shows only while a query leaves no file.
28
+ *
29
+ * @param tree The tree's root element.
30
+ * @param query What the reader typed; blank restores the whole tree.
31
+ * @returns How many files match.
32
+ */
33
+ export function applyTreeFilter(tree, query) {
34
+ let active = query.trim() !== "";
35
+ let matches = 0;
36
+ for (let leaf of tree.querySelectorAll(LEAF_SELECTOR)) {
37
+ let text = leaf.getAttribute(TREE_FILTER_TEXT_ATTRIBUTE) ?? leaf.textContent ?? "";
38
+ let match = !active || treeFilterMatches(text, query);
39
+ leaf.hidden = !match;
40
+ if (match)
41
+ matches += 1;
42
+ }
43
+ let folders = [...tree.querySelectorAll("details")].reverse();
44
+ for (let folder of folders) {
45
+ if (!active) {
46
+ folder.hidden = false;
47
+ let before = OPEN_BEFORE_FILTER.get(folder);
48
+ if (before !== undefined)
49
+ folder.open = before;
50
+ OPEN_BEFORE_FILTER.delete(folder);
51
+ continue;
52
+ }
53
+ let holdsMatch = folder.querySelector(`${LEAF_SELECTOR}:not([hidden])`) !== null;
54
+ folder.hidden = !holdsMatch;
55
+ if (!holdsMatch)
56
+ continue;
57
+ if (!OPEN_BEFORE_FILTER.has(folder))
58
+ OPEN_BEFORE_FILTER.set(folder, folder.open);
59
+ folder.open = true;
60
+ }
61
+ let notes = [
62
+ ...tree.querySelectorAll("[data-tree-no-matches]"),
63
+ ...(tree.id === ""
64
+ ? []
65
+ : tree.ownerDocument.querySelectorAll(`[data-tree-no-matches="${CSS.escape(tree.id)}"]`)),
66
+ ];
67
+ for (let note of notes) {
68
+ note.hidden = !active || matches > 0;
69
+ }
70
+ return matches;
71
+ }
72
+ /**
73
+ * Filters the tree named by `options.tree` on every keystroke in the field it is applied to,
74
+ * and moves focus from the field into the first visible row on ArrowDown, so a reader types,
75
+ * then walks the results.
76
+ *
77
+ * @param options The tree to narrow.
78
+ * @example <input type="search" name="filter" mix={[treeFilter({ tree: "files" })]} />
79
+ */
80
+ export const treeFilter = createMixin((handle) => {
81
+ let treeId = "";
82
+ /** The tree this field narrows, looked up when used so a swapped tree is still found. */
83
+ let treeFor = (input) => input.ownerDocument.getElementById(treeId);
84
+ handle.addEventListener("insert", (event) => {
85
+ let tree = treeFor(event.node);
86
+ if (tree !== null && event.node.value !== "")
87
+ applyTreeFilter(tree, event.node.value);
88
+ });
89
+ return (options) => {
90
+ treeId = options.tree;
91
+ return createElement(handle.element, {
92
+ mix: [
93
+ on("input", (event) => {
94
+ let tree = treeFor(event.currentTarget);
95
+ if (tree !== null)
96
+ applyTreeFilter(tree, event.currentTarget.value);
97
+ }),
98
+ on("keydown", (event) => {
99
+ if (event.key !== "ArrowDown")
100
+ return;
101
+ let rows = treeFor(event.currentTarget)?.querySelectorAll(ROW_SELECTOR) ?? [];
102
+ let row = [...rows].find((candidate) => candidate.closest("[hidden]") === null);
103
+ if (row === undefined)
104
+ return;
105
+ event.preventDefault();
106
+ row.focus();
107
+ }),
108
+ ],
109
+ });
110
+ };
111
+ });
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Keyboard navigation for a tree whose rows are links and folders: one roving Tab stop, ↑↓
3
+ * (and `j`/`k`) between visible rows, → opens a folder or enters it, ← closes it or goes to
4
+ * its parent, Home/End, and type-ahead over row names. The keys go through the page's
5
+ * shortcut registry under the tree's layer, so they answer only while focus is in the tree.
6
+ * Why JS: HTML has no arrow-key movement between rows. No-JS baseline: every folder toggles
7
+ * from its `<summary>` and every file link is reachable by Tab.
8
+ *
9
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
10
+ * @copyright Sergio Xalambrí 2026
11
+ */
12
+ import type { MixinFactory } from "remix/component";
13
+ /** Selector for the rows the keys walk: folder summaries and file links alike. */
14
+ export declare const TREE_NAVIGATION_ROW_SELECTOR = "[role=\"treeitem\"]";
15
+ /**
16
+ * Types for {@link treeNavigation}.
17
+ */
18
+ export declare namespace TreeNavigation {
19
+ /** The copy each key lists under in the help sheet; an omitted label keeps that key unlisted. */
20
+ interface Labels {
21
+ /** The help-sheet heading the keys list under. */
22
+ group?: string;
23
+ next?: string;
24
+ previous?: string;
25
+ /** What → does: open a folder or step into it. */
26
+ expand?: string;
27
+ /** What ← does: close a folder or step out to its parent. */
28
+ collapse?: string;
29
+ first?: string;
30
+ last?: string;
31
+ }
32
+ /** Options for {@link treeNavigation}. */
33
+ interface Options {
34
+ /**
35
+ * The nearest ancestor matching this selector becomes the tree whose rows are walked,
36
+ * for a mixin carried by a marker element inside the tree rather than the tree itself.
37
+ */
38
+ within?: string;
39
+ labels?: Labels;
40
+ }
41
+ }
42
+ /**
43
+ * Walks a tree's rows from the keyboard. Each key declines while focus is outside the tree,
44
+ * so the page's own `j`/`k` and arrows keep working there, and printable keys search row
45
+ * names (a row's `data-search-value`, else its text) from the focused row on.
46
+ *
47
+ * @param options Where the tree is, and the copy each key lists under.
48
+ * @example <div role="tree" aria-label="Files" mix={[treeNavigation({ labels: { group: "Files", next: "Next file" } })]}>…</div>
49
+ */
50
+ export declare const treeNavigation: MixinFactory<HTMLElement, [options?: TreeNavigation.Options]>;
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Keyboard navigation for a tree whose rows are links and folders: one roving Tab stop, ↑↓
3
+ * (and `j`/`k`) between visible rows, → opens a folder or enters it, ← closes it or goes to
4
+ * its parent, Home/End, and type-ahead over row names. The keys go through the page's
5
+ * shortcut registry under the tree's layer, so they answer only while focus is in the tree.
6
+ * Why JS: HTML has no arrow-key movement between rows. No-JS baseline: every folder toggles
7
+ * from its `<summary>` and every file link is reachable by Tab.
8
+ *
9
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
10
+ * @copyright Sergio Xalambrí 2026
11
+ */
12
+ import { createElement, createMixin } from "remix/component";
13
+ import { isPrintableKey, labelFor, setRovingTabindex } from "../../utils/keyboard-nav.js";
14
+ import { shortcutRegistry } from "../behaviors/shortcuts.js";
15
+ /** Selector for the rows the keys walk: folder summaries and file links alike. */
16
+ export const TREE_NAVIGATION_ROW_SELECTOR = '[role="treeitem"]';
17
+ /** Idle time after the last keystroke before the type-ahead buffer resets. */
18
+ const TYPEAHEAD_RESET_MS = 500;
19
+ /**
20
+ * Priority the tree's keys register at, above a list's row keys on the same layer, so `j`
21
+ * and `k` move through the tree while it holds focus and through the list otherwise.
22
+ */
23
+ const TREE_KEY_PRIORITY = 1;
24
+ /**
25
+ * How long focus keeps retrying a row that refused it. A folder opened a moment ago still
26
+ * holds its content hidden while its reveal starts, and a row inside refuses focus until then.
27
+ */
28
+ const FOCUS_RETRY_MS = 400;
29
+ /** Keys that always move rather than start a type-ahead search. */
30
+ const MOVEMENT_LETTERS = new Set(["j", "k"]);
31
+ /** The folder a row opens, when the row is a `<details>` element's own summary. */
32
+ function folderOf(element) {
33
+ let parent = element.parentElement;
34
+ return element.localName === "summary" && parent instanceof HTMLDetailsElement ? parent : null;
35
+ }
36
+ /**
37
+ * Whether a row is on screen in the tree: neither it nor any ancestor below `host` is
38
+ * hidden, and every folder around it is open. A folder's own summary shows while the folder
39
+ * is closed, so the walk starts above it.
40
+ */
41
+ function isReachable(host, element) {
42
+ if (element.hidden)
43
+ return false;
44
+ let node = folderOf(element) ?? element;
45
+ for (let current = node.parentElement; current && current !== host; current = current.parentElement) {
46
+ if (current.hidden)
47
+ return false;
48
+ if (current instanceof HTMLDetailsElement && !current.open)
49
+ return false;
50
+ }
51
+ return !(node instanceof HTMLDetailsElement && node.hidden);
52
+ }
53
+ /** The rows a reader can reach right now, in document order. */
54
+ function visibleRows(host) {
55
+ return [...host.querySelectorAll(TREE_NAVIGATION_ROW_SELECTOR)]
56
+ .filter((element) => element.getAttribute("aria-disabled") !== "true")
57
+ .filter((element) => isReachable(host, element))
58
+ .map((element) => ({
59
+ element,
60
+ level: Number(element.getAttribute("aria-level")) || 1,
61
+ folder: folderOf(element),
62
+ }));
63
+ }
64
+ /** The row holding focus, by index into `rows`, or `-1` when focus is elsewhere. */
65
+ function focusedIndex(host, rows) {
66
+ let active = host.ownerDocument.activeElement;
67
+ return rows.findIndex((row) => row.element === active);
68
+ }
69
+ /**
70
+ * Focuses `element`, retrying on a timer until it takes focus or `deadline` passes, so a
71
+ * row in a folder that has only just opened still receives it.
72
+ */
73
+ function focusWhenReady(element, deadline) {
74
+ element.focus();
75
+ if (element.ownerDocument.activeElement === element || Date.now() > deadline)
76
+ return;
77
+ setTimeout(() => {
78
+ if (element.isConnected)
79
+ focusWhenReady(element, deadline);
80
+ }, 16);
81
+ }
82
+ /** Makes `row` the tree's one Tab stop, focuses it and scrolls it into view. */
83
+ function focusRow(host, row) {
84
+ setRovingTabindex([...host.querySelectorAll(TREE_NAVIGATION_ROW_SELECTOR)], row.element);
85
+ focusWhenReady(row.element, Date.now() + FOCUS_RETRY_MS);
86
+ row.element.scrollIntoView({ block: "nearest", inline: "nearest" });
87
+ }
88
+ /**
89
+ * The row that starts as the Tab stop: the current file when the tree marks one, else the
90
+ * first row.
91
+ */
92
+ function initialRow(host) {
93
+ let rows = visibleRows(host);
94
+ let current = rows.find((row) => row.element.getAttribute("aria-current") === "page");
95
+ return (current ?? rows[0])?.element;
96
+ }
97
+ /**
98
+ * Walks a tree's rows from the keyboard. Each key declines while focus is outside the tree,
99
+ * so the page's own `j`/`k` and arrows keep working there, and printable keys search row
100
+ * names (a row's `data-search-value`, else its text) from the focused row on.
101
+ *
102
+ * @param options Where the tree is, and the copy each key lists under.
103
+ * @example <div role="tree" aria-label="Files" mix={[treeNavigation({ labels: { group: "Files", next: "Next file" } })]}>…</div>
104
+ */
105
+ export const treeNavigation = createMixin((handle) => {
106
+ let options = {};
107
+ handle.addEventListener("insert", (event) => {
108
+ let host = options.within === undefined
109
+ ? event.node
110
+ : (event.node.parentElement?.closest(options.within) ?? event.node);
111
+ let registry = shortcutRegistry(host.ownerDocument);
112
+ let signal = handle.signal;
113
+ let labels = () => options.labels ?? {};
114
+ let buffer = "";
115
+ let resetBuffer;
116
+ signal.addEventListener("abort", () => clearTimeout(resetBuffer));
117
+ let start = initialRow(host);
118
+ if (start !== undefined) {
119
+ setRovingTabindex([...host.querySelectorAll(TREE_NAVIGATION_ROW_SELECTOR)], start);
120
+ }
121
+ host.addEventListener("focusin", (focus) => {
122
+ if (!(focus.target instanceof HTMLElement))
123
+ return;
124
+ if (!focus.target.matches(TREE_NAVIGATION_ROW_SELECTOR))
125
+ return;
126
+ setRovingTabindex([...host.querySelectorAll(TREE_NAVIGATION_ROW_SELECTOR)], focus.target);
127
+ }, { signal });
128
+ /** Runs `move` with the visible rows and the focused one, declining when focus is outside the tree. */
129
+ let withFocus = (move) => () => {
130
+ let rows = visibleRows(host);
131
+ let index = focusedIndex(host, rows);
132
+ if (index === -1)
133
+ return false;
134
+ move(rows, index);
135
+ return true;
136
+ };
137
+ /** Registers one key binding scoped to the tree. */
138
+ let bind = (keys, label, run) => registry.register({
139
+ keys,
140
+ label,
141
+ group: labels().group,
142
+ scope: host,
143
+ priority: TREE_KEY_PRIORITY,
144
+ run,
145
+ signal,
146
+ });
147
+ bind(["arrowdown", "j"], labels().next, withFocus((rows, index) => {
148
+ let next = rows[index + 1];
149
+ if (next)
150
+ focusRow(host, next);
151
+ }));
152
+ bind(["arrowup", "k"], labels().previous, withFocus((rows, index) => {
153
+ let previous = rows[index - 1];
154
+ if (previous)
155
+ focusRow(host, previous);
156
+ }));
157
+ bind(["arrowright"], labels().expand, withFocus((rows, index) => {
158
+ let row = rows[index];
159
+ if (row.folder === null)
160
+ return;
161
+ if (!row.folder.open) {
162
+ row.folder.open = true;
163
+ return;
164
+ }
165
+ let child = rows[index + 1];
166
+ if (child && child.level > row.level)
167
+ focusRow(host, child);
168
+ }));
169
+ bind(["arrowleft"], labels().collapse, withFocus((rows, index) => {
170
+ let row = rows[index];
171
+ if (row.folder?.open) {
172
+ row.folder.open = false;
173
+ return;
174
+ }
175
+ let parent = rows
176
+ .slice(0, index)
177
+ .reverse()
178
+ .find((candidate) => candidate.level < row.level);
179
+ if (parent)
180
+ focusRow(host, parent);
181
+ }));
182
+ bind(["home"], labels().first, withFocus((rows) => focusRow(host, rows[0])));
183
+ bind(["end"], labels().last, withFocus((rows) => focusRow(host, rows[rows.length - 1])));
184
+ host.addEventListener("keydown", (key) => {
185
+ if (key.defaultPrevented || !isPrintableKey(key) || key.key === " ")
186
+ return;
187
+ if (buffer === "" && MOVEMENT_LETTERS.has(key.key))
188
+ return;
189
+ let rows = visibleRows(host);
190
+ let index = focusedIndex(host, rows);
191
+ if (index === -1)
192
+ return;
193
+ let order = [...rows.slice(index + 1), ...rows.slice(0, index + 1)];
194
+ let find = (prefix) => order.find((row) => labelFor(row.element).startsWith(prefix));
195
+ let query = buffer + key.key.toLowerCase();
196
+ let match = find(query);
197
+ if (match === undefined && buffer !== "") {
198
+ query = key.key.toLowerCase();
199
+ match = find(query);
200
+ }
201
+ if (match === undefined)
202
+ return;
203
+ key.preventDefault();
204
+ buffer = query;
205
+ clearTimeout(resetBuffer);
206
+ resetBuffer = setTimeout(() => {
207
+ buffer = "";
208
+ }, TYPEAHEAD_RESET_MS);
209
+ focusRow(host, match);
210
+ }, { signal });
211
+ });
212
+ return (next = {}) => {
213
+ options = next;
214
+ return createElement(handle.element, {});
215
+ };
216
+ });
@@ -8,6 +8,7 @@
8
8
  * @copyright Sergio Xalambrí 2026
9
9
  */
10
10
  import type { EntryComponent, RemixNode } from "remix/component";
11
+ import type { Button as ButtonTypes } from "../components/button.js";
11
12
  /**
12
13
  * Props {@link OptimisticToggle} serializes into the page for hydration, which is why they
13
14
  * are a `type`: `SerializableProps` rejects an interface.
@@ -35,6 +36,13 @@ export type OptimisticToggleProps = {
35
36
  pressedContent?: RemixNode;
36
37
  /** What the button shows while off, such as an outlined star; the label text when omitted. */
37
38
  unpressedContent?: RemixNode;
39
+ /**
40
+ * The button's look in both states, its tone still neutral while off and brand while on:
41
+ * `solid` for a Follow that should read as the row's one action. @default "ghost"
42
+ */
43
+ variant?: ButtonTypes.Variant;
44
+ /** @default "sm" */
45
+ size?: ButtonTypes.Size;
38
46
  };
39
47
  /**
40
48
  * Renders the form and its toggle button, with both states' content in the markup so a
@@ -17,7 +17,7 @@ import { optimisticToggleSync, toneOf } from "./mixins/optimistic-toggle-sync.js
17
17
  */
18
18
  export const OptimisticToggle = clientEntry("@sdxc/ui/app/optimistic-toggle#OptimisticToggle", function OptimisticToggle(handle) {
19
19
  return () => {
20
- let { action, name, pressed, fields, labels, pressedContent, unpressedContent } = handle.props;
20
+ let { action, name, pressed, fields, labels, pressedContent, unpressedContent, variant = "ghost", size = "sm", } = handle.props;
21
21
  let hasContent = pressedContent !== undefined || unpressedContent !== undefined;
22
22
  let pressedLabel = labels.pressed ?? labels.label;
23
23
  let currentLabel = pressed ? pressedLabel : labels.label;
@@ -27,12 +27,13 @@ export const OptimisticToggle = clientEntry("@sdxc/ui/app/optimistic-toggle#Opti
27
27
  refused: labels.refused,
28
28
  label: labels.label,
29
29
  pressedLabel,
30
+ pressed,
30
31
  }),
31
32
  inlineFlex(),
32
33
  items("center"),
33
34
  gap(1.5),
34
35
  when('&[data-pressed] [data-toggle-content="off"]', hidden()),
35
36
  when('&:not([data-pressed]) [data-toggle-content="on"]', hidden()),
36
- ], children: [Object.entries(fields ?? {}).map(([field, value]) => (_jsx("input", { type: "hidden", name: field, value: value }))), _jsx("input", { type: "hidden", name: name, value: pressed ? "false" : "true", "data-toggle-next": "" }), _jsxs(Button, { type: "submit", size: "sm", variant: "ghost", color: toneOf(pressed, false), "aria-pressed": pressed ? "true" : "false", "aria-label": hasContent ? currentLabel : undefined, title: currentLabel, children: [_jsx("span", { "data-toggle-content": "on", children: pressedContent ?? pressedLabel }), _jsx("span", { "data-toggle-content": "off", children: unpressedContent ?? labels.label })] }), _jsx("span", { role: "status", mix: [text("xs"), fg("danger")] })] }));
37
+ ], children: [Object.entries(fields ?? {}).map(([field, value]) => (_jsx("input", { type: "hidden", name: field, value: value }))), _jsx("input", { type: "hidden", name: name, value: pressed ? "false" : "true", "data-toggle-next": "" }), _jsxs(Button, { type: "submit", size: size, variant: variant, color: toneOf(pressed, false), "aria-pressed": pressed ? "true" : "false", "aria-label": hasContent ? currentLabel : undefined, title: currentLabel, children: [_jsx("span", { "data-toggle-content": "on", children: pressedContent ?? pressedLabel }), _jsx("span", { "data-toggle-content": "off", children: unpressedContent ?? labels.label })] }), _jsx("span", { role: "status", mix: [text("xs"), fg("danger")] })] }));
37
38
  };
38
39
  });
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The top of an app screen in one order: where it sits (a breadcrumb, or a parent link on a
3
3
  * narrow pane), the `<h1>` with its status and one-line description, the actions (secondary,
4
- * primary, then overflow), and an optional row of tabs. The sticky variant compacts once stuck.
4
+ * primary, then overflow), and an optional row of tabs that folds into "More ▾" on a narrow
5
+ * pane. The sticky variant compacts once stuck.
5
6
  *
6
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
8
  * @copyright Sergio Xalambrí 2026
@@ -50,6 +51,18 @@ export declare namespace PageHeader {
50
51
  tabs?: Tab[];
51
52
  /** The tabs landmark's name, such as "Monitor views". */
52
53
  tabsLabel?: string;
54
+ /**
55
+ * How many tabs stay in the row under 40rem of header width; the rest move into a
56
+ * "More ▾" menu, the current tab always stays in the row, and the row folds only when
57
+ * two or more tabs would move.
58
+ * @default 2
59
+ */
60
+ tabsNarrow?: number;
61
+ /**
62
+ * The "More ▾" button's text and its menu's accessible name, in the app's own language.
63
+ * @default "More"
64
+ */
65
+ tabsMore?: string;
53
66
  /**
54
67
  * Sticks the header at `--ui-app-sticky-top` and compacts it once stuck: the trail and the
55
68
  * description fold away and the title shrinks. Reduced motion keeps it full size.
@@ -60,12 +73,14 @@ export declare namespace PageHeader {
60
73
  }
61
74
  /**
62
75
  * Renders the header. From 40rem the actions end the title's row, the description under both;
63
- * narrower, they sit beside the title when they fit and after the description otherwise. A
64
- * sticky header spans the shell's gutter (`--ui-app-gutter`) so content never shows beside it.
76
+ * narrower, actions sit beside the title or after the description, and tabs past `tabsNarrow`
77
+ * fold into a popover "More ▾" menu that opens with no script. Sticky spans `--ui-app-gutter`.
65
78
  *
66
79
  * @param handle Runtime handle carrying the header's props.
67
80
  * @returns The render function producing the header's markup.
68
81
  * @example
69
82
  * <PageHeader crumbsLabel="Breadcrumb" crumbs={[{ label: "Monitors", href: "/monitors" }, { label: "api.acme.dev" }]} title="api.acme.dev" status={<Badge color="success">Up</Badge>} actions={<Button variant="outline">Pause</Button>} primaryAction={<Button>Edit monitor</Button>} />
83
+ * @example
84
+ * <PageHeader title="acme / delta" tabsLabel={t("repo.views")} tabsMore={t("repo.more")} tabs={[{ href: "/code", label: t("repo.code"), current: true }, { href: "/issues", label: t("repo.issues"), count: 26 }, { href: "/pulls", label: t("repo.pulls"), count: 71 }, { href: "/actions", label: t("repo.actions") }]} />
70
85
  */
71
86
  export declare function PageHeader(handle: Handle<PageHeader.Props>): () => import("remix/component").RemixElement;