@sdxc/ui 2026.11.11 → 2026.11.17

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 (204) hide show
  1. package/README.md +114 -61
  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 +20 -0
  33. package/dist/app/index.js +20 -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 +347 -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/profile-picker.d.ts +47 -0
  75. package/dist/app/profile-picker.js +104 -0
  76. package/dist/app/review-thread.d.ts +115 -0
  77. package/dist/app/review-thread.js +116 -0
  78. package/dist/app/save-bar.d.ts +5 -0
  79. package/dist/app/save-bar.js +1 -1
  80. package/dist/app/save-status.js +1 -1
  81. package/dist/app/settings-layout.d.ts +5 -0
  82. package/dist/app/settings-layout.js +5 -5
  83. package/dist/app/skeleton.d.ts +9 -0
  84. package/dist/app/skeleton.js +28 -0
  85. package/dist/app/split-view.d.ts +4 -0
  86. package/dist/app/split-view.js +3 -3
  87. package/dist/app/styles/code-tokens.d.ts +24 -0
  88. package/dist/app/styles/code-tokens.js +47 -0
  89. package/dist/app/tab-bar.d.ts +59 -0
  90. package/dist/app/tab-bar.js +111 -0
  91. package/dist/app/tree.d.ts +111 -14
  92. package/dist/app/tree.js +202 -15
  93. package/dist/app/utils/ansi.d.ts +55 -0
  94. package/dist/app/utils/ansi.js +157 -0
  95. package/dist/app/utils/diff-rows.d.ts +82 -0
  96. package/dist/app/utils/diff-rows.js +209 -0
  97. package/dist/app/utils/fuzzy-path.d.ts +58 -0
  98. package/dist/app/utils/fuzzy-path.js +202 -0
  99. package/dist/app/utils/line-range.d.ts +48 -0
  100. package/dist/app/utils/line-range.js +61 -0
  101. package/dist/app/utils/log-lines.d.ts +107 -0
  102. package/dist/app/utils/log-lines.js +170 -0
  103. package/dist/app/utils/tree-filter.d.ts +19 -0
  104. package/dist/app/utils/tree-filter.js +26 -0
  105. package/dist/app/view-options.d.ts +2 -0
  106. package/dist/app/view-options.js +2 -2
  107. package/dist/chat/activity.d.ts +72 -0
  108. package/dist/chat/activity.js +184 -0
  109. package/dist/chat/composer-submit.d.ts +38 -0
  110. package/dist/chat/composer-submit.js +44 -0
  111. package/dist/chat/composer.d.ts +47 -0
  112. package/dist/chat/composer.js +100 -0
  113. package/dist/chat/index.d.ts +6 -0
  114. package/dist/chat/index.js +6 -0
  115. package/dist/chat/mixins/composer-send.d.ts +32 -0
  116. package/dist/chat/mixins/composer-send.js +121 -0
  117. package/dist/chat/mixins/reveal-stream.d.ts +68 -0
  118. package/dist/chat/mixins/reveal-stream.js +184 -0
  119. package/dist/chat/mixins/stream-target.d.ts +18 -0
  120. package/dist/chat/mixins/stream-target.js +38 -0
  121. package/dist/components/button.js +7 -1
  122. package/dist/components/character-count.d.ts +44 -0
  123. package/dist/components/character-count.js +68 -0
  124. package/dist/components/index.d.ts +2 -0
  125. package/dist/components/index.js +2 -0
  126. package/dist/components/label-chip.d.ts +42 -0
  127. package/dist/components/label-chip.js +86 -0
  128. package/dist/components/property-list.d.ts +9 -2
  129. package/dist/components/property-list.js +37 -10
  130. package/dist/components/textarea.js +6 -1
  131. package/dist/components/timeline.d.ts +62 -5
  132. package/dist/components/timeline.js +124 -5
  133. package/dist/docs/code-block.js +8 -31
  134. package/dist/docs/file-tree.js +3 -48
  135. package/dist/landing/case-study.d.ts +79 -0
  136. package/dist/landing/case-study.js +162 -0
  137. package/dist/landing/contributor-wall.d.ts +72 -0
  138. package/dist/landing/contributor-wall.js +129 -0
  139. package/dist/landing/countdown.d.ts +88 -0
  140. package/dist/landing/countdown.js +91 -0
  141. package/dist/landing/episode-player.d.ts +87 -0
  142. package/dist/landing/episode-player.js +113 -0
  143. package/dist/landing/faq-band.d.ts +3 -2
  144. package/dist/landing/faq-band.js +4 -3
  145. package/dist/landing/index.d.ts +7 -0
  146. package/dist/landing/index.js +7 -0
  147. package/dist/landing/landing-header.js +15 -4
  148. package/dist/landing/mixins/countdown-tick.d.ts +29 -0
  149. package/dist/landing/mixins/countdown-tick.js +65 -0
  150. package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
  151. package/dist/landing/mixins/usage-estimate-live.js +120 -0
  152. package/dist/landing/phone-frame.d.ts +2 -1
  153. package/dist/landing/price-list.d.ts +68 -0
  154. package/dist/landing/price-list.js +125 -0
  155. package/dist/landing/scroll-scene.d.ts +59 -0
  156. package/dist/landing/scroll-scene.js +70 -0
  157. package/dist/landing/sponsor-wall.d.ts +30 -6
  158. package/dist/landing/sponsor-wall.js +70 -14
  159. package/dist/landing/typed-terminal.d.ts +24 -6
  160. package/dist/landing/typed-terminal.js +22 -14
  161. package/dist/landing/usage-estimate.d.ts +127 -0
  162. package/dist/landing/usage-estimate.js +164 -0
  163. package/dist/landing/utils/countdown.d.ts +33 -0
  164. package/dist/landing/utils/countdown.js +42 -0
  165. package/dist/landing/utils/pause-toggle.d.ts +2 -1
  166. package/dist/mixins/character-count.d.ts +62 -0
  167. package/dist/mixins/character-count.js +139 -0
  168. package/dist/mixins/index.d.ts +6 -2
  169. package/dist/mixins/index.js +6 -2
  170. package/dist/mixins/invoker-fields.d.ts +18 -0
  171. package/dist/mixins/invoker-fields.js +60 -0
  172. package/dist/mixins/media-sync.d.ts +58 -0
  173. package/dist/mixins/media-sync.js +102 -0
  174. package/dist/mixins/menu-keys.d.ts +11 -0
  175. package/dist/mixins/menu-keys.js +79 -70
  176. package/dist/mixins/sortable.d.ts +96 -0
  177. package/dist/mixins/sortable.js +433 -0
  178. package/dist/utils/code-lines.d.ts +26 -0
  179. package/dist/utils/code-lines.js +29 -0
  180. package/dist/utils/file-icon.d.ts +31 -0
  181. package/dist/utils/file-icon.js +60 -0
  182. package/dist/utils/index.d.ts +2 -0
  183. package/dist/utils/index.js +2 -0
  184. package/dist/utils/write-cookie.d.ts +15 -15
  185. package/dist/utils/write-cookie.js +10 -16
  186. package/dist/video/episode-list.d.ts +48 -0
  187. package/dist/video/episode-list.js +161 -0
  188. package/dist/video/index.d.ts +15 -0
  189. package/dist/video/index.js +15 -0
  190. package/dist/video/mixins/video-player-sync.d.ts +27 -0
  191. package/dist/video/mixins/video-player-sync.js +413 -0
  192. package/dist/video/mixins/video-shelf-steps.d.ts +20 -0
  193. package/dist/video/mixins/video-shelf-steps.js +79 -0
  194. package/dist/video/title-hero.d.ts +51 -0
  195. package/dist/video/title-hero.js +170 -0
  196. package/dist/video/utils/timeline.d.ts +55 -0
  197. package/dist/video/utils/timeline.js +90 -0
  198. package/dist/video/video-card.d.ts +51 -0
  199. package/dist/video/video-card.js +135 -0
  200. package/dist/video/video-player.d.ts +261 -0
  201. package/dist/video/video-player.js +927 -0
  202. package/dist/video/video-shelf.d.ts +58 -0
  203. package/dist/video/video-shelf.js +155 -0
  204. package/package.json +6 -3
package/dist/app/tree.js CHANGED
@@ -1,20 +1,26 @@
1
- import { jsx as _jsx } from "remix/component/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
2
  import { ChevronRightIcon } from "@sdxc/icons";
3
- import { bg, fg, outline } from "@sdxc/u/color";
3
+ import { visuallyHidden } from "@sdxc/u/a11y";
4
+ import { bg, border, fg, outline } from "@sdxc/u/color";
4
5
  import { opacity, rounded, transition, transitionDuration } from "@sdxc/u/effects";
5
6
  import { cursor, listStyle, raw, mergeMix } from "@sdxc/u/general";
6
- import { center, hidden, hstack, interpolateSize, shrink, vstack } from "@sdxc/u/layout";
7
+ import { center, hidden, hstack, interpolateSize, relative, shrink, vstack } from "@sdxc/u/layout";
7
8
  import { clip } from "@sdxc/u/overflow";
8
9
  import { media } from "@sdxc/u/responsive";
9
- import { bs, is, pb, pie, pi } from "@sdxc/u/size";
10
+ import { bs, is, mis, minIs, pb, pie, pi } from "@sdxc/u/size";
10
11
  import { detailsContent, when } from "@sdxc/u/state";
11
12
  import { rotate } from "@sdxc/u/transform";
12
- import { text } from "@sdxc/u/typography";
13
- import { attrs } from "remix/component";
13
+ import { nowrap, tabularNums, text, textDecoration, truncate, weight } from "@sdxc/u/typography";
14
+ import { attrs, clientEntry } from "remix/component";
15
+ import { SearchField } from "../components/search-field.js";
14
16
  import { SentinelRow } from "../components/sentinel-row.js";
15
17
  import { interactiveTransition } from "../styles/interactive-transition.js";
16
18
  import { panelChrome } from "../styles/panel-chrome.js";
19
+ import { fileIcon } from "../utils/file-icon.js";
17
20
  import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
21
+ import { TREE_FILTER_TEXT_ATTRIBUTE, treeFilter } from "./mixins/tree-filter.js";
22
+ import { treeNavigation } from "./mixins/tree-navigation.js";
23
+ export { treeFilterMatches } from "./utils/tree-filter.js";
18
24
  /** `role="tree"` applied to {@link Tree} through {@link attrs} unless a consumer supplies its own `role`. */
19
25
  const DEFAULT_ROLE = "tree";
20
26
  /**
@@ -43,6 +49,24 @@ const DEFAULT_EXPAND_BUTTON_SLOT = "expand-button";
43
49
  * the icons of the branches around it instead of under their chevrons.
44
50
  */
45
51
  const LEAF_GUTTER = "calc(var(--ui-spacing, 0.25rem) * 7)";
52
+ /** Search parameter {@link Tree.Filter} submits its query under when `name` is unset. */
53
+ const DEFAULT_FILTER_PARAM = "filter";
54
+ /** The letter each file status draws, the shape that tells statuses apart beside their tone. */
55
+ const STATUS_LETTERS = {
56
+ added: "A",
57
+ modified: "M",
58
+ deleted: "D",
59
+ renamed: "R",
60
+ };
61
+ /** The semantic tone each file status paints its letter in. */
62
+ const STATUS_TONES = {
63
+ added: "success",
64
+ modified: "warning",
65
+ deleted: "danger",
66
+ renamed: "brand",
67
+ };
68
+ /** Selector {@link Tree.Navigation} and {@link Tree.Filter} find their tree by. */
69
+ const TREE_SELECTOR = '[role="tree"]';
46
70
  /**
47
71
  * Reads the nesting depth published by the nearest ancestor {@link Tree.Item},
48
72
  * resolving to `undefined` when the lookup finds no ancestor item at all.
@@ -62,9 +86,10 @@ function readAmbientDepth(handle) {
62
86
  }
63
87
  }
64
88
  /**
65
- * Renders the tree's root host: a bordered `<div>` carrying `role="tree"`,
66
- * stacking {@link Tree.Item} nodes in block flow, with `data-empty`
67
- * centering a fallback message; an unlabeled tree logs a dev `console.warn`.
89
+ * Renders the bordered `role="tree"` panel; folders open and file links work with no script.
90
+ * Rows indent `--ui-tree-indent` per level, `frame` aims every {@link Tree.Leaf} at one frame,
91
+ * `data-empty` centers a fallback, {@link Tree.NoMatches} answers a filter that matches
92
+ * nothing, and {@link Tree.Filter} and {@link Tree.Navigation} add islands.
68
93
  *
69
94
  * @param handle Runtime handle carrying the host `<div>`'s props.
70
95
  * @returns The render function producing the tree's markup.
@@ -72,7 +97,7 @@ function readAmbientDepth(handle) {
72
97
  * <Tree aria-label={t("files.title")}>
73
98
  * <Tree.Item id="src">
74
99
  * <Tree.ItemContent>
75
- * <Tree.ExpandButton aria-label={t("files.expand")} />
100
+ * <Tree.ExpandButton />
76
101
  * {t("files.folder", { name: "src" })}
77
102
  * </Tree.ItemContent>
78
103
  * <Tree.Item id="src-index">
@@ -84,10 +109,19 @@ function readAmbientDepth(handle) {
84
109
  * <Tree aria-label={t("files.title")} data-empty>
85
110
  * {t("files.empty")}
86
111
  * </Tree>
112
+ * @example
113
+ * <Tree id="files" aria-label={t("files.title")} frame="main">
114
+ * <Tree.Navigation labels={{ group: t("keys.files"), next: t("keys.next") }} />
115
+ * <Tree.Item id="app" open>
116
+ * <Tree.ItemContent><Tree.ExpandButton />app</Tree.ItemContent>
117
+ * <Tree.Leaf href="/blob/main/app/routes.ts" name="routes.ts" path="app/routes.ts" current />
118
+ * </Tree.Item>
119
+ * </Tree>
87
120
  */
88
121
  export function Tree(handle) {
89
122
  return () => {
90
- let { children, mix, ...rest } = handle.props;
123
+ let { children, frame, mix, ...rest } = handle.props;
124
+ handle.context.set({ frame });
91
125
  warnIfNoAccessibleLabel(handle.props, 'Tree: needs an "aria-label" or "aria-labelledby" describing its contents for assistive technology.');
92
126
  return (_jsx("div", { ...rest, mix: mergeMix([
93
127
  attrs({ role: DEFAULT_ROLE }),
@@ -111,7 +145,7 @@ export function Tree(handle) {
111
145
  * @example
112
146
  * <Tree.Item id="src">
113
147
  * <Tree.ItemContent>
114
- * <Tree.ExpandButton aria-label={t("files.expand")} />
148
+ * <Tree.ExpandButton />
115
149
  * {t("files.folder", { name: "src" })}
116
150
  * </Tree.ItemContent>
117
151
  * <Tree.Item id="src-index">
@@ -121,7 +155,7 @@ export function Tree(handle) {
121
155
  * @example
122
156
  * <Tree.Item id="src" open>
123
157
  * <Tree.ItemContent>
124
- * <Tree.ExpandButton aria-label={t("files.collapse")} />
158
+ * <Tree.ExpandButton />
125
159
  * {t("files.folder", { name: "src" })}
126
160
  * </Tree.ItemContent>
127
161
  * </Tree.Item>
@@ -134,6 +168,7 @@ function TreeItem(handle) {
134
168
  handle.context.set({ depth });
135
169
  return (_jsx("details", { ...rest, id: id, "data-rmx-key": id, mix: mergeMix([
136
170
  attrs({ role: DEFAULT_ITEM_ROLE }),
171
+ when("&[hidden]", hidden()),
137
172
  interpolateSize(),
138
173
  detailsContent([
139
174
  clip(),
@@ -165,7 +200,7 @@ Tree.Item = TreeItem;
165
200
  * @returns The render function producing the row's markup.
166
201
  * @example
167
202
  * <Tree.ItemContent>
168
- * <Tree.ExpandButton aria-label={t("files.expand")} />
203
+ * <Tree.ExpandButton />
169
204
  * {t("files.folder", { name: "src" })}
170
205
  * </Tree.ItemContent>
171
206
  * @example
@@ -205,6 +240,7 @@ Tree.ItemContent = function TreeItemContent(handle) {
205
240
  when("&:hover", bg("neutral.bg-tint-hover")),
206
241
  when("&:active", bg("neutral.bg-tint-pressed")),
207
242
  when("&:focus", bg("neutral.bg-tint-hover")),
243
+ when("&:focus-visible", outline({ color: "brand.ring", width: 2, offset: -2 })),
208
244
  when('&[aria-selected="true"]', bg("brand.tint")),
209
245
  when('&[aria-disabled="true"]', opacity(50)),
210
246
  ], mix), children: children }));
@@ -233,7 +269,7 @@ Tree.LoadMoreItem = SentinelRow;
233
269
  * @returns The render function producing the chevron's markup.
234
270
  * @example
235
271
  * <Tree.ItemContent>
236
- * <Tree.ExpandButton aria-label={t("files.expand")} />
272
+ * <Tree.ExpandButton />
237
273
  * {t("files.folder", { name: "src" })}
238
274
  * </Tree.ItemContent>
239
275
  */
@@ -253,3 +289,154 @@ Tree.ExpandButton = function TreeExpandButton(handle) {
253
289
  ], mix), children: children ?? _jsx(ChevronRightIcon, { size: 16 }) }));
254
290
  };
255
291
  };
292
+ /**
293
+ * Reads the frame the nearest {@link Tree} names for its file links, `undefined` when the
294
+ * tree names none or the row renders outside one.
295
+ */
296
+ function readTreeFrame(handle) {
297
+ try {
298
+ let root = handle.context.get(Tree);
299
+ return root?.frame;
300
+ }
301
+ catch {
302
+ return undefined;
303
+ }
304
+ }
305
+ /**
306
+ * Renders a file: a link row with the file's icon and name, indented from the depth of the
307
+ * folders around it, as a `role="treeitem"` so arrow keys reach it beside the folders. The
308
+ * current file reads `aria-current="page"` with a tint and an accent bar; a diff's file adds
309
+ * a toned A/M/D/R letter and end-aligned `+n −n` counts in tabular figures.
310
+ *
311
+ * @param handle Runtime handle carrying the link's props.
312
+ * @returns The render function producing the row's markup.
313
+ * @example
314
+ * <Tree.Leaf href="/blob/main/app/routes.ts" name="routes.ts" path="app/routes.ts" current />
315
+ * @example
316
+ * <Tree.Leaf href="#diff-routes" name="routes.ts" status="modified" statusLabel={t("files.modified")} additions={12} deletions={3} />
317
+ */
318
+ Tree.Leaf = function TreeLeaf(handle) {
319
+ return () => {
320
+ let { additions, children, current, deletions, frame, href, mix, name, path, status, statusLabel, ...rest } = handle.props;
321
+ let ambient = readAmbientDepth(handle);
322
+ let depth = ambient === undefined ? DEFAULT_DEPTH : ambient + 1;
323
+ let target = frame ?? readTreeFrame(handle);
324
+ let Glyph = fileIcon(name);
325
+ let counted = additions !== undefined || deletions !== undefined;
326
+ return (_jsxs("a", { ...rest, href: href, role: DEFAULT_CONTENT_ROLE, "aria-level": depth + 1, "data-tree-leaf": "", "data-search-value": name, "data-status": status, "data-rmx-target": target, "aria-current": current ? "page" : undefined, [TREE_FILTER_TEXT_ATTRIBUTE]: path ?? name, mix: mergeMix([
327
+ interactiveTransition(),
328
+ relative(),
329
+ hstack({ gap: 2, align: "center" }),
330
+ rounded("md"),
331
+ pb(1.5),
332
+ pie(3),
333
+ raw({
334
+ paddingInlineStart: `calc(0.5rem + ${depth} * var(--ui-tree-indent, 1.25rem) + ${LEAF_GUTTER})`,
335
+ }),
336
+ fg("neutral.emphasis"),
337
+ textDecoration("none"),
338
+ outline("none"),
339
+ text("sm"),
340
+ media("(prefers-reduced-motion: reduce)", transitionDuration("0s")),
341
+ when("&[hidden]", hidden()),
342
+ when("& > svg", [shrink(), fg("neutral.muted")]),
343
+ when("&:hover", bg("neutral.bg-tint-hover")),
344
+ when("&:active", bg("neutral.bg-tint-pressed")),
345
+ when("&:focus-visible", outline({ color: "brand.ring", width: 2, offset: -2 })),
346
+ when('&[aria-current="page"]', [bg("brand.tint"), weight(500)]),
347
+ when('&[aria-current="page"] > svg', fg("brand")),
348
+ /** The accent bar marks the current file by shape, so it reads without its tint. */
349
+ when('&[aria-current="page"]::before', raw({
350
+ content: '""',
351
+ position: "absolute",
352
+ insetBlock: "0.375rem",
353
+ insetInlineStart: 0,
354
+ inlineSize: "2px",
355
+ borderRadius: "1px",
356
+ backgroundColor: "var(--ui-brand-fg)",
357
+ })),
358
+ when('&[data-status="deleted"] > [data-slot="tree-leaf-name"]', [
359
+ textDecoration("line-through"),
360
+ fg("neutral.muted"),
361
+ ]),
362
+ ], mix), children: [_jsx(Glyph, { size: 16, "aria-hidden": "true" }), _jsx("span", { "data-slot": "tree-leaf-name", mix: [minIs(0), truncate()], children: children ?? name }), status || counted ? (_jsxs("span", { "data-slot": "tree-leaf-meta", mix: [mis("auto"), hstack({ gap: 2, align: "center" }), shrink(), text("xs")], children: [counted ? (_jsxs("span", { "data-slot": "tree-counts", mix: [hstack({ gap: 1 }), tabularNums(), nowrap()], children: [additions !== undefined ? (_jsx("span", { mix: [fg("success")], children: `+${additions}` })) : null, deletions !== undefined ? (_jsx("span", { mix: [fg("danger")], children: `−${deletions}` })) : null] })) : null, status ? (_jsx("span", { "data-slot": "tree-status", "aria-hidden": "true", mix: [
363
+ center(),
364
+ is(4),
365
+ bs(4),
366
+ rounded("sm"),
367
+ border({ color: "currentColor", width: 1, style: "solid" }),
368
+ fg(STATUS_TONES[status]),
369
+ weight(600),
370
+ raw({ fontSize: "0.625rem", lineHeight: 1 }),
371
+ ], children: STATUS_LETTERS[status] })) : null, status && statusLabel ? _jsx("span", { mix: [visuallyHidden()], children: statusLabel }) : null] })) : null] }));
372
+ };
373
+ };
374
+ /**
375
+ * Renders a "Go to file" field over a tree: a GET form (`?filter=` by default), so without
376
+ * script the server renders the narrowed tree with {@link treeFilterMatches}. The
377
+ * {@link TreeFilterField} island applies {@link treeFilter} to narrow it on every keystroke.
378
+ *
379
+ * @param handle Runtime handle carrying the form's props.
380
+ * @returns The render function producing the form.
381
+ * @example
382
+ * <Tree.Filter tree="files" label={t("files.filter")} placeholder={t("files.goToFile")} value={url.searchParams.get("filter") ?? ""} />
383
+ */
384
+ Tree.Filter = function TreeFilterForm(handle) {
385
+ return () => {
386
+ let { label, name, params, placeholder, tree, value, ...rest } = handle.props;
387
+ return (_jsxs("form", { ...rest, method: "get", role: "search", "data-slot": "tree-filter", children: [Object.entries(params ?? {}).map(([key, param]) => (_jsx("input", { type: "hidden", name: key, value: param }))), _jsx(TreeFilterField, { tree: tree, label: label, name: name ?? DEFAULT_FILTER_PARAM, value: value, placeholder: placeholder })] }));
388
+ };
389
+ };
390
+ /**
391
+ * Renders the line a tree shows while its filter matches no file, such as "No file matches",
392
+ * inside the tree or beside it with `tree` naming the tree's id. It stays hidden until
393
+ * {@link treeFilter} narrows the tree to nothing, and is announced then.
394
+ *
395
+ * @param handle Runtime handle carrying the paragraph's props.
396
+ * @returns The render function producing the hidden message.
397
+ * @example <Tree.NoMatches tree="files">{t("files.noMatches")}</Tree.NoMatches>
398
+ */
399
+ Tree.NoMatches = function TreeNoMatches(handle) {
400
+ return () => {
401
+ let { children, mix, tree, ...rest } = handle.props;
402
+ return (_jsx("p", { ...rest, hidden: true, role: "status", "data-tree-no-matches": tree ?? "", mix: mergeMix([
403
+ raw({ margin: 0 }),
404
+ pi(2),
405
+ pb(3),
406
+ text("sm"),
407
+ fg("neutral.muted"),
408
+ when("&[hidden]", hidden()),
409
+ ], mix), children: children }));
410
+ };
411
+ };
412
+ /**
413
+ * Client island behind {@link Tree.Filter}: the search field, whose `treeFilter()` narrows
414
+ * the tree as the reader types. Loads from `@sdxc/ui/app/tree#TreeFilterField` once the
415
+ * app's browser entry maps it; until then the field submits its form.
416
+ */
417
+ export const TreeFilterField = clientEntry("@sdxc/ui/app/tree#TreeFilterField", function TreeFilterField(handle) {
418
+ return () => {
419
+ let { label, name, placeholder, tree, value } = handle.props;
420
+ return (_jsx(SearchField.Input, { name: name, defaultValue: value, "aria-label": label, "aria-controls": tree, placeholder: placeholder, autocomplete: "off", mix: [treeFilter({ tree })] }));
421
+ };
422
+ });
423
+ /**
424
+ * Client island behind {@link Tree.Navigation}: a hidden marker whose `treeNavigation()`
425
+ * walks the rows of the tree it sits in. Loads from `@sdxc/ui/app/tree#TreeNavigation` once
426
+ * the app's browser entry maps it; until then every row stays reachable by Tab.
427
+ */
428
+ export const TreeNavigation = clientEntry("@sdxc/ui/app/tree#TreeNavigation", function TreeNavigation(handle) {
429
+ return () => (_jsx("span", { mix: [hidden(), treeNavigation({ labels: handle.props.labels, within: TREE_SELECTOR })] }));
430
+ });
431
+ /**
432
+ * Adds the keys as the {@link TreeNavigation} island running {@link treeNavigation}: ↑↓ and
433
+ * `j`/`k` between visible rows, → opens or enters a folder, ← closes it or goes up, Home/End
434
+ * and type-ahead. Without script every row is a Tab stop. Place it first inside {@link Tree}.
435
+ *
436
+ * @param handle Runtime handle carrying the keys' help-sheet copy.
437
+ * @returns The render function producing the island.
438
+ * @example <Tree aria-label={t("files.title")} frame="main"><Tree.Navigation labels={{ group: t("keys.files") }} />…</Tree>
439
+ */
440
+ Tree.Navigation = function TreeNavigationPart(handle) {
441
+ return () => _jsx(TreeNavigation, { ...handle.props });
442
+ };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * A small parser for the ANSI SGR escapes CI logs colour their lines with: it splits a line
3
+ * into runs of text, each with the colour and weight in force, and drops every other escape
4
+ * (cursor moves, erases, OSC titles), so a log renders as styled text without terminal noise.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** The eight terminal colours; bright variants fold into their base colour. */
10
+ export type AnsiColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
11
+ /** The SGR attributes in force at a point in the text. */
12
+ export interface AnsiStyle {
13
+ fg?: AnsiColor;
14
+ bg?: AnsiColor;
15
+ bold?: boolean;
16
+ dim?: boolean;
17
+ italic?: boolean;
18
+ underline?: boolean;
19
+ }
20
+ /** One run of text and the style it is drawn in. */
21
+ export interface AnsiSpan extends AnsiStyle {
22
+ text: string;
23
+ }
24
+ /** A parsed line and the style still in force at its end, which the next line starts from. */
25
+ export interface AnsiLine {
26
+ spans: AnsiSpan[];
27
+ state: AnsiStyle;
28
+ }
29
+ /**
30
+ * Parses one line, starting from the style the previous line left in force. Adjacent runs in
31
+ * the same style merge, and a line with no escapes comes back as one unstyled span.
32
+ *
33
+ * @param text The raw line, escapes included.
34
+ * @param state The style in force at the line's start. @default {}
35
+ * @returns The line's spans and the style in force at its end.
36
+ * @example parseAnsiLine("\u001b[31merror\u001b[0m: failed") // spans: [{ text: "error", fg: "red" }, { text: ": failed" }]
37
+ */
38
+ export declare function parseAnsiLine(text: string, state?: AnsiStyle): AnsiLine;
39
+ /**
40
+ * Parses a whole block of text, line by line with the style carried across lines, into one
41
+ * list of spans per line.
42
+ *
43
+ * @param text Raw log text, lines separated by `\n`.
44
+ * @returns The spans of each line, in order.
45
+ * @example parseAnsi("\u001b[1mBuild\u001b[0m\nok").length // 2
46
+ */
47
+ export declare function parseAnsi(text: string): AnsiSpan[][];
48
+ /**
49
+ * Removes every escape from a line, leaving the text a reader sees.
50
+ *
51
+ * @param text The raw line.
52
+ * @returns The text without escapes.
53
+ * @example stripAnsi("\u001b[32mok\u001b[0m") // "ok"
54
+ */
55
+ export declare function stripAnsi(text: string): string;
@@ -0,0 +1,157 @@
1
+ /**
2
+ * A small parser for the ANSI SGR escapes CI logs colour their lines with: it splits a line
3
+ * into runs of text, each with the colour and weight in force, and drops every other escape
4
+ * (cursor moves, erases, OSC titles), so a log renders as styled text without terminal noise.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Colour names by SGR offset: 30–37 and 90–97 for the foreground, 40–47 and 100–107 behind it. */
10
+ const COLORS = [
11
+ "black",
12
+ "red",
13
+ "green",
14
+ "yellow",
15
+ "blue",
16
+ "magenta",
17
+ "cyan",
18
+ "white",
19
+ ];
20
+ /**
21
+ * Every escape a terminal log carries: CSI sequences (`ESC [ … final`), OSC strings ended by
22
+ * BEL or `ESC \`, and two-character escapes. Only CSI `m` (SGR) changes the style.
23
+ */
24
+ // oxlint-disable-next-line no-control-regex -- every terminal escape starts with the ESC control character
25
+ const ESCAPE = /\u001b(?:\[([0-9;:?]*)([@-~])|\][^\u0007\u001b]*(?:\u0007|\u001b\\)|[@-Z\\-_])/g;
26
+ /** The named colour for a 256-colour index, for the 16 indices that have one. */
27
+ function indexedColor(index) {
28
+ if (index >= 0 && index < 8)
29
+ return COLORS[index];
30
+ if (index >= 8 && index < 16)
31
+ return COLORS[index - 8];
32
+ return undefined;
33
+ }
34
+ /**
35
+ * Applies one SGR parameter list to `style`. Extended colours (`38;5;n`, `38;2;r;g;b`) consume
36
+ * their arguments; an index under 16 maps to its named colour and the rest leave it unset.
37
+ */
38
+ function applySgr(style, params) {
39
+ let codes = params === "" ? [0] : params.split(/[;:]/).map((code) => Number(code || "0"));
40
+ let next = { ...style };
41
+ for (let index = 0; index < codes.length; index++) {
42
+ let code = codes[index];
43
+ if (code === 0)
44
+ next = {};
45
+ else if (code === 1)
46
+ next.bold = true;
47
+ else if (code === 2)
48
+ next.dim = true;
49
+ else if (code === 3)
50
+ next.italic = true;
51
+ else if (code === 4)
52
+ next.underline = true;
53
+ else if (code === 22) {
54
+ delete next.bold;
55
+ delete next.dim;
56
+ }
57
+ else if (code === 23)
58
+ delete next.italic;
59
+ else if (code === 24)
60
+ delete next.underline;
61
+ else if (code >= 30 && code <= 37)
62
+ next.fg = COLORS[code - 30];
63
+ else if (code >= 90 && code <= 97)
64
+ next.fg = COLORS[code - 90];
65
+ else if (code === 39)
66
+ delete next.fg;
67
+ else if (code >= 40 && code <= 47)
68
+ next.bg = COLORS[code - 40];
69
+ else if (code >= 100 && code <= 107)
70
+ next.bg = COLORS[code - 100];
71
+ else if (code === 49)
72
+ delete next.bg;
73
+ else if (code === 38 || code === 48) {
74
+ let mode = codes[index + 1];
75
+ let color;
76
+ if (mode === 5) {
77
+ color = indexedColor(codes[index + 2] ?? -1);
78
+ index += 2;
79
+ }
80
+ else if (mode === 2) {
81
+ index += 4;
82
+ }
83
+ let key = code === 38 ? "fg" : "bg";
84
+ if (color === undefined)
85
+ delete next[key];
86
+ else
87
+ next[key] = color;
88
+ }
89
+ }
90
+ return next;
91
+ }
92
+ /** Whether two styles draw the same, an unset flag counting as off. */
93
+ function sameStyle(a, b) {
94
+ return (a.fg === b.fg &&
95
+ a.bg === b.bg &&
96
+ Boolean(a.bold) === Boolean(b.bold) &&
97
+ Boolean(a.dim) === Boolean(b.dim) &&
98
+ Boolean(a.italic) === Boolean(b.italic) &&
99
+ Boolean(a.underline) === Boolean(b.underline));
100
+ }
101
+ /**
102
+ * Parses one line, starting from the style the previous line left in force. Adjacent runs in
103
+ * the same style merge, and a line with no escapes comes back as one unstyled span.
104
+ *
105
+ * @param text The raw line, escapes included.
106
+ * @param state The style in force at the line's start. @default {}
107
+ * @returns The line's spans and the style in force at its end.
108
+ * @example parseAnsiLine("\u001b[31merror\u001b[0m: failed") // spans: [{ text: "error", fg: "red" }, { text: ": failed" }]
109
+ */
110
+ export function parseAnsiLine(text, state = {}) {
111
+ let spans = [];
112
+ let style = state;
113
+ let at = 0;
114
+ let push = (chunk) => {
115
+ if (chunk === "")
116
+ return;
117
+ let last = spans.at(-1);
118
+ if (last !== undefined && sameStyle(last, style))
119
+ last.text += chunk;
120
+ else
121
+ spans.push({ ...style, text: chunk });
122
+ };
123
+ for (let match of text.matchAll(ESCAPE)) {
124
+ push(text.slice(at, match.index));
125
+ at = match.index + match[0].length;
126
+ if (match[2] === "m")
127
+ style = applySgr(style, match[1] ?? "");
128
+ }
129
+ push(text.slice(at));
130
+ return { spans, state: style };
131
+ }
132
+ /**
133
+ * Parses a whole block of text, line by line with the style carried across lines, into one
134
+ * list of spans per line.
135
+ *
136
+ * @param text Raw log text, lines separated by `\n`.
137
+ * @returns The spans of each line, in order.
138
+ * @example parseAnsi("\u001b[1mBuild\u001b[0m\nok").length // 2
139
+ */
140
+ export function parseAnsi(text) {
141
+ let state = {};
142
+ return text.split("\n").map((line) => {
143
+ let parsed = parseAnsiLine(line, state);
144
+ state = parsed.state;
145
+ return parsed.spans;
146
+ });
147
+ }
148
+ /**
149
+ * Removes every escape from a line, leaving the text a reader sees.
150
+ *
151
+ * @param text The raw line.
152
+ * @returns The text without escapes.
153
+ * @example stripAnsi("\u001b[32mok\u001b[0m") // "ok"
154
+ */
155
+ export function stripAnsi(text) {
156
+ return text.replace(ESCAPE, "");
157
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The arithmetic a diff view draws from: hunk headers as git writes them, deleted and added
3
+ * lines paired for the split view, each side of a hunk highlighted as one run of source,
4
+ * word ranges cut into marked runs, and the five-block bar of a file's change.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Hunk, Line, WordRange } from "@sdxc/diff";
10
+ import type { CodeToken } from "../../utils/code-lines.js";
11
+ /** The side a line number counts on: `L` for the old file, `R` for the new one. */
12
+ export type DiffSide = "L" | "R";
13
+ /** One row of the split view: indices into `hunk.lines` for each side, absent for a filler. */
14
+ export interface SplitRow {
15
+ old?: number;
16
+ new?: number;
17
+ }
18
+ /** A run of source with whether it falls inside a changed word range. */
19
+ export interface MarkedRun extends CodeToken {
20
+ marked: boolean;
21
+ }
22
+ /** One block of a file's change bar. */
23
+ export type ChangeBlock = "add" | "del" | "neutral";
24
+ /** Blocks a file's change bar draws. */
25
+ export declare const CHANGE_BLOCKS = 5;
26
+ /**
27
+ * Writes a hunk's header line as git does: `@@ -20,7 +20,8 @@ section`, leaving out a count
28
+ * of 1, so the text matches the patch it came from.
29
+ *
30
+ * @param hunk The hunk to name.
31
+ * @returns The header text, section included when the hunk has one.
32
+ * @example hunkHeader({ oldStart: 20, oldLines: 7, newStart: 20, newLines: 8, lines: [] }) // "@@ -20,7 +20,8 @@"
33
+ */
34
+ export declare function hunkHeader(hunk: Hunk): string;
35
+ /**
36
+ * Pairs a hunk's lines for the split view: a context line fills both sides, and a run of
37
+ * deletions followed by a run of additions lines up row by row, the shorter run leaving
38
+ * fillers on its side.
39
+ *
40
+ * @param lines The hunk's lines, in patch order.
41
+ * @returns One row per drawn line pair.
42
+ */
43
+ export declare function splitRows(lines: readonly Line[]): SplitRow[];
44
+ /**
45
+ * Highlights a hunk as two runs of source, the old side (context and deletions) and the new
46
+ * side (context and additions), each tokenized in one pass, so a string or comment that
47
+ * spans lines inside the hunk paints whole. Context lines take the new side's runs.
48
+ *
49
+ * @param hunk The hunk to highlight.
50
+ * @param language The language its file highlights as; omitted, every line is one plain run.
51
+ * @returns One list of runs per entry of `hunk.lines`.
52
+ */
53
+ export declare function hunkTokens(hunk: Hunk, language: string | undefined): CodeToken[][];
54
+ /**
55
+ * Cuts a line's runs at the edges of its changed word ranges, so each piece is either all
56
+ * inside a range or all outside it, and neighbouring pieces of one type and marking merge.
57
+ *
58
+ * @param runs The line's highlighted runs, covering its text in order.
59
+ * @param words `[start, end)` offsets of the changed spans; absent or empty marks nothing.
60
+ * @returns The runs, each flagged as marked or not.
61
+ * @example markRuns([{ type: "plain", value: "let b = 3;" }], [[8, 9]]) // "let b = " | "3" (marked) | ";"
62
+ */
63
+ export declare function markRuns(runs: readonly CodeToken[], words: readonly WordRange[] | undefined): MarkedRun[];
64
+ /**
65
+ * The five blocks a file's change bar draws: additions and deletions in proportion to the
66
+ * change, each at least one block when nonzero, and neutral blocks for the rest when the
67
+ * change is smaller than the bar.
68
+ *
69
+ * @param additions Lines added.
70
+ * @param deletions Lines deleted.
71
+ * @returns {@link CHANGE_BLOCKS} blocks, additions first.
72
+ * @example changeBlocks(12, 3) // ["add", "add", "add", "add", "del"]
73
+ */
74
+ export declare function changeBlocks(additions: number, deletions: number): ChangeBlock[];
75
+ /**
76
+ * A short id derived from a path, so a file's card and line anchors keep the same ids on
77
+ * every render of the same change, and a link to `#diff-<hash>R12` survives a reload.
78
+ *
79
+ * @param path The file's path.
80
+ * @returns A base-36 hash, stable across runs.
81
+ */
82
+ export declare function pathHash(path: string): string;