@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
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Splits the time left until a moment into days, hours, minutes and seconds, the arithmetic
3
+ * a launch, a sale or an event countdown shares between its server render and its island,
4
+ * so the two always agree on what the page reads.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Milliseconds in each unit the countdown shows, largest first. */
10
+ const UNIT_MS = { days: 86_400_000, hours: 3_600_000, minutes: 60_000, seconds: 1_000 };
11
+ /**
12
+ * The whole units left from `now` until `to`, rounded down, so a countdown reads "0 days" only
13
+ * in the last day and never jumps ahead of the clock. A moment that does not parse counts as
14
+ * already reached.
15
+ *
16
+ * @param to The moment counted down to.
17
+ * @param now The moment counted from.
18
+ * @returns The days, hours, minutes and seconds left, and whether none are.
19
+ * @example countdownParts("2027-04-15T07:00:00Z", "2027-04-14T05:30:00Z") // { done: false, days: 1, hours: 1, minutes: 30, seconds: 0 }
20
+ */
21
+ export function countdownParts(to, now) {
22
+ let left = toTime(to) - toTime(now);
23
+ if (!Number.isFinite(left) || left <= 0) {
24
+ return { done: true, days: 0, hours: 0, minutes: 0, seconds: 0 };
25
+ }
26
+ let days = Math.floor(left / UNIT_MS.days);
27
+ left -= days * UNIT_MS.days;
28
+ let hours = Math.floor(left / UNIT_MS.hours);
29
+ left -= hours * UNIT_MS.hours;
30
+ let minutes = Math.floor(left / UNIT_MS.minutes);
31
+ left -= minutes * UNIT_MS.minutes;
32
+ let seconds = Math.floor(left / UNIT_MS.seconds);
33
+ return { done: false, days, hours, minutes, seconds };
34
+ }
35
+ /** Epoch milliseconds of a moment, `NaN` when it does not parse. */
36
+ function toTime(value) {
37
+ if (value instanceof Date)
38
+ return value.getTime();
39
+ if (typeof value === "number")
40
+ return value;
41
+ return Date.parse(value);
42
+ }
@@ -6,6 +6,7 @@
6
6
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
7
  * @copyright Sergio Xalambrí 2026
8
8
  */
9
+ import type { UtilityMixin } from "@sdxc/u";
9
10
  import type { Handle, Props as TagProps } from "remix/component";
10
11
  /**
11
12
  * Prop types for {@link PauseToggle}.
@@ -34,4 +35,4 @@ export declare function PauseToggle(handle: Handle<PauseToggle.Props>): () => im
34
35
  * @param target A descendant selector that also pauses on hover and focus.
35
36
  * @returns A `css()` mixin for the element that holds both the toggle and the loop.
36
37
  */
37
- export declare function pausedWhenChecked(target?: string): import("packages/u/src").UtilityMixin<Element>;
38
+ export declare function pausedWhenChecked(target?: string): UtilityMixin;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Why JS: a field's length changes with every keystroke and HTML has no live count, so
3
+ * script redraws a `CharacterCount`'s ring and number as the field is typed in.
4
+ * No-JS baseline: the count drawn for the field's server-rendered text, and the server's check.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { MixinFactory } from "remix/component";
10
+ /** Where a field stands against its limit, which the count's `data-state` carries. */
11
+ export type CharacterCountState = "empty" | "ok" | "warn" | "over";
12
+ /** Types for {@link characterCount}. */
13
+ export declare namespace CharacterCountSync {
14
+ /** Configuration for {@link characterCount}. */
15
+ interface Options {
16
+ /** The `id` of the field counted. */
17
+ for: string;
18
+ max: number;
19
+ /** How many characters left show the number. */
20
+ warn: number;
21
+ /** Disables the field's form's submit buttons while it is empty or over the limit. */
22
+ holdSubmit: boolean;
23
+ /** Announcements, with `{count}` replaced by the characters left or over. */
24
+ labels: {
25
+ remaining: string;
26
+ over: string;
27
+ };
28
+ }
29
+ }
30
+ /**
31
+ * Counts what a reader sees as characters: grapheme clusters, so an emoji with skin tone or a
32
+ * flag counts once. A server checking the same limit calls this, so the two never disagree.
33
+ *
34
+ * @param text The field's text.
35
+ * @returns Its length in user-perceived characters.
36
+ */
37
+ export declare function countCharacters(text: string): number;
38
+ /**
39
+ * Places a length against its limit.
40
+ *
41
+ * @param length The characters typed.
42
+ * @param max The limit.
43
+ * @param warn How many characters left start the warning.
44
+ * @returns The state the count draws.
45
+ */
46
+ export declare function characterCountState(length: number, max: number, warn: number): CharacterCountState;
47
+ /**
48
+ * Whether a count is far enough over its limit to show the number alone.
49
+ *
50
+ * @param left Characters left; negative past the limit.
51
+ * @returns `true` from ten over on.
52
+ */
53
+ export declare function isRingHidden(left: number): boolean;
54
+ /**
55
+ * Applied to a `CharacterCount`'s host: follows the field named by `for`, and on every
56
+ * input sets the host's `data-state` and `--ui-character-count-progress`, writes the number
57
+ * left into `[data-character-count-number]`, and announces a change of state only, so a screen
58
+ * reader hears "20 characters left" once rather than at every key.
59
+ *
60
+ * @example <span mix={[characterCount({ for: "draft", max: 280, warn: 20, holdSubmit: true, labels })]} />
61
+ */
62
+ export declare const characterCount: MixinFactory<HTMLElement, [options: CharacterCountSync.Options]>;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Why JS: a field's length changes with every keystroke and HTML has no live count, so
3
+ * script redraws a `CharacterCount`'s ring and number as the field is typed in.
4
+ * No-JS baseline: the count drawn for the field's server-rendered text, and the server's check.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createMixin } from "remix/component";
10
+ /**
11
+ * Counts what a reader sees as characters: grapheme clusters, so an emoji with skin tone or a
12
+ * flag counts once. A server checking the same limit calls this, so the two never disagree.
13
+ *
14
+ * @param text The field's text.
15
+ * @returns Its length in user-perceived characters.
16
+ */
17
+ export function countCharacters(text) {
18
+ if (typeof Intl !== "undefined" && "Segmenter" in Intl) {
19
+ return Array.from(new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text))
20
+ .length;
21
+ }
22
+ return Array.from(text).length;
23
+ }
24
+ /**
25
+ * Places a length against its limit.
26
+ *
27
+ * @param length The characters typed.
28
+ * @param max The limit.
29
+ * @param warn How many characters left start the warning.
30
+ * @returns The state the count draws.
31
+ */
32
+ export function characterCountState(length, max, warn) {
33
+ if (length === 0)
34
+ return "empty";
35
+ if (length > max)
36
+ return "over";
37
+ return max - length <= warn ? "warn" : "ok";
38
+ }
39
+ /** How far over the limit the ring gives way to the number alone, having nothing left to fill. */
40
+ const RING_GONE_OVER = 10;
41
+ /**
42
+ * Whether a count is far enough over its limit to show the number alone.
43
+ *
44
+ * @param left Characters left; negative past the limit.
45
+ * @returns `true` from ten over on.
46
+ */
47
+ export function isRingHidden(left) {
48
+ return left <= -RING_GONE_OVER;
49
+ }
50
+ /**
51
+ * Applied to a `CharacterCount`'s host: follows the field named by `for`, and on every
52
+ * input sets the host's `data-state` and `--ui-character-count-progress`, writes the number
53
+ * left into `[data-character-count-number]`, and announces a change of state only, so a screen
54
+ * reader hears "20 characters left" once rather than at every key.
55
+ *
56
+ * @example <span mix={[characterCount({ for: "draft", max: 280, warn: 20, holdSubmit: true, labels })]} />
57
+ */
58
+ export const characterCount = createMixin((handle) => {
59
+ let options;
60
+ let controller;
61
+ handle.addEventListener("insert", (event) => {
62
+ controller?.abort();
63
+ controller = new AbortController();
64
+ let host = event.node;
65
+ let signal = controller.signal;
66
+ handle.queueTask(() => {
67
+ if (!signal.aborted)
68
+ connect(host, () => options, signal);
69
+ });
70
+ });
71
+ handle.addEventListener("remove", () => {
72
+ controller?.abort();
73
+ controller = undefined;
74
+ });
75
+ return (next) => {
76
+ options = next;
77
+ };
78
+ });
79
+ /**
80
+ * Keeps `host` in step with its field until `signal` aborts.
81
+ *
82
+ * @param host The count's host element.
83
+ * @param read Reads the latest options.
84
+ * @param signal Ends the listener once the count leaves the document.
85
+ */
86
+ function connect(host, read, signal) {
87
+ let options = read();
88
+ if (!options)
89
+ return;
90
+ let field = host.ownerDocument.getElementById(options.for);
91
+ if (!(field instanceof HTMLTextAreaElement || field instanceof HTMLInputElement))
92
+ return;
93
+ let number = host.querySelector("[data-character-count-number]");
94
+ let status = host.querySelector("[data-character-count-status]");
95
+ let announced = host.dataset.state;
96
+ /** Draws the field's current length onto the count, and holds or frees the submit. */
97
+ let sync = () => {
98
+ let current = read();
99
+ if (!current || !field)
100
+ return;
101
+ let length = countCharacters(field.value);
102
+ let left = current.max - length;
103
+ let state = characterCountState(length, current.max, current.warn);
104
+ host.dataset.state = state;
105
+ host.toggleAttribute("data-ring-hidden", isRingHidden(left));
106
+ host.style.setProperty("--ui-character-count-progress", String(Math.min(1, length / current.max)));
107
+ if (number)
108
+ number.textContent = state === "warn" || state === "over" ? String(left) : "";
109
+ field.toggleAttribute("aria-invalid", state === "over");
110
+ if (current.holdSubmit && field.form) {
111
+ for (let button of field.form.querySelectorAll("button[type='submit'], button:not([type])")) {
112
+ button.disabled = state === "empty" || state === "over";
113
+ }
114
+ }
115
+ if (status && state !== announced) {
116
+ status.textContent = announcement(state, left, current.labels);
117
+ }
118
+ announced = state;
119
+ };
120
+ field.addEventListener("input", sync, { signal });
121
+ field.form?.addEventListener("reset", () => queueMicrotask(sync), { signal });
122
+ sync();
123
+ }
124
+ /**
125
+ * The live region's copy for a state: silent while there is room, the characters left once
126
+ * the warning starts, and how far over once past the limit.
127
+ *
128
+ * @param state Where the field stands.
129
+ * @param left Characters left; negative past the limit.
130
+ * @param labels The templates to fill.
131
+ * @returns What the live region says.
132
+ */
133
+ function announcement(state, left, labels) {
134
+ if (state === "warn")
135
+ return labels.remaining.replace("{count}", String(left));
136
+ if (state === "over")
137
+ return labels.over.replace("{count}", String(-left));
138
+ return "";
139
+ }
@@ -10,10 +10,12 @@ export * from "./active-descendant-keys.js";
10
10
  export * from "./aria-checked.js";
11
11
  export * from "./calendar-keys.js";
12
12
  export * from "./carousel-controls.js";
13
+ export * from "./character-count.js";
13
14
  export * from "./clear-field.js";
14
15
  export * from "./combobox-filter.js";
15
16
  export * from "./command-filter.js";
16
17
  export * from "./command-keys.js";
18
+ export * from "./confirm-phrase.js";
17
19
  export * from "./copy-to-clipboard.js";
18
20
  export * from "./dialog-dismiss.js";
19
21
  export * from "./dismiss.js";
@@ -23,22 +25,24 @@ export * from "./frame-submit.js";
23
25
  export * from "./heading-level-fallback.js";
24
26
  export * from "./hotkey.js";
25
27
  export * from "./image-fallback.js";
28
+ export * from "./invoker-fields.js";
26
29
  export * from "./keymap.js";
27
30
  export * from "./listbox-keys.js";
28
31
  export * from "./live-frame.js";
29
32
  export * from "./long-press.js";
33
+ export * from "./media-sync.js";
30
34
  export * from "./menu-keys.js";
31
35
  export * from "./mirror-selected-option.js";
32
36
  export * from "./otp-slots.js";
33
37
  export * from "./persist.js";
34
38
  export * from "./press-toggle.js";
35
39
  export * from "./range-preview.js";
40
+ export * from "./sortable.js";
36
41
  export * from "./stepper.js";
37
42
  export * from "./tab-keys.js";
38
43
  export * from "./theme-toggle.js";
39
44
  export * from "./track-host-node.js";
40
45
  export * from "./validate.js";
41
46
  export * from "./view-transition.js";
42
- export * from "./while-live.js";
43
- export * from "./confirm-phrase.js";
44
47
  export * from "./viewer-time.js";
48
+ export * from "./while-live.js";
@@ -10,10 +10,12 @@ export * from "./active-descendant-keys.js";
10
10
  export * from "./aria-checked.js";
11
11
  export * from "./calendar-keys.js";
12
12
  export * from "./carousel-controls.js";
13
+ export * from "./character-count.js";
13
14
  export * from "./clear-field.js";
14
15
  export * from "./combobox-filter.js";
15
16
  export * from "./command-filter.js";
16
17
  export * from "./command-keys.js";
18
+ export * from "./confirm-phrase.js";
17
19
  export * from "./copy-to-clipboard.js";
18
20
  export * from "./dialog-dismiss.js";
19
21
  export * from "./dismiss.js";
@@ -23,22 +25,24 @@ export * from "./frame-submit.js";
23
25
  export * from "./heading-level-fallback.js";
24
26
  export * from "./hotkey.js";
25
27
  export * from "./image-fallback.js";
28
+ export * from "./invoker-fields.js";
26
29
  export * from "./keymap.js";
27
30
  export * from "./listbox-keys.js";
28
31
  export * from "./live-frame.js";
29
32
  export * from "./long-press.js";
33
+ export * from "./media-sync.js";
30
34
  export * from "./menu-keys.js";
31
35
  export * from "./mirror-selected-option.js";
32
36
  export * from "./otp-slots.js";
33
37
  export * from "./persist.js";
34
38
  export * from "./press-toggle.js";
35
39
  export * from "./range-preview.js";
40
+ export * from "./sortable.js";
36
41
  export * from "./stepper.js";
37
42
  export * from "./tab-keys.js";
38
43
  export * from "./theme-toggle.js";
39
44
  export * from "./track-host-node.js";
40
45
  export * from "./validate.js";
41
46
  export * from "./view-transition.js";
42
- export * from "./while-live.js";
43
- export * from "./confirm-phrase.js";
44
47
  export * from "./viewer-time.js";
48
+ export * from "./while-live.js";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Why JS: a dialog or popover opened by an invoker button cannot read that button's value. No-JS
3
+ * baseline: the button still opens its target, whose fields start at their own defaults.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import type { MixinFactory } from "remix/component";
9
+ /**
10
+ * Presets the fields of the dialog or popover around the host from the button that opens it: an
11
+ * invoker carrying `name` and `value` sets the target's field of that name to that value. Once
12
+ * the target closes, each preset field returns to the value it held before, so the next opener
13
+ * starts where the form was.
14
+ *
15
+ * @example <button commandfor="new-issue" command="show-modal" name="status" value="done">+</button>
16
+ * @example <span hidden mix={[invokerFields()]} />
17
+ */
18
+ export declare const invokerFields: MixinFactory<HTMLElement, []>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Why JS: a dialog or popover opened by an invoker button cannot read that button's value. No-JS
3
+ * baseline: the button still opens its target, whose fields start at their own defaults.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { createMixin } from "remix/component";
9
+ import { asCommandEvent } from "../utils/command-event.js";
10
+ /**
11
+ * Presets the fields of the dialog or popover around the host from the button that opens it: an
12
+ * invoker carrying `name` and `value` sets the target's field of that name to that value. Once
13
+ * the target closes, each preset field returns to the value it held before, so the next opener
14
+ * starts where the form was.
15
+ *
16
+ * @example <button commandfor="new-issue" command="show-modal" name="status" value="done">+</button>
17
+ * @example <span hidden mix={[invokerFields()]} />
18
+ */
19
+ export const invokerFields = createMixin((handle) => {
20
+ let controller;
21
+ handle.addEventListener("insert", (event) => {
22
+ controller?.abort();
23
+ controller = new AbortController();
24
+ let target = event.node.closest("dialog, [popover]");
25
+ if (!target)
26
+ return;
27
+ let preset = new Map();
28
+ /** Sets the field the invoking button names to the button's value. */
29
+ function presetFromInvoker(command) {
30
+ let source = asCommandEvent(command).source;
31
+ if (!(source instanceof HTMLButtonElement) || !source.name)
32
+ return;
33
+ for (let field of fieldsNamed(target, source.name)) {
34
+ if (!preset.has(field))
35
+ preset.set(field, field.value);
36
+ field.value = source.value;
37
+ }
38
+ }
39
+ /** Returns each preset field to the value it held before, once the target closes. */
40
+ function restoreDefaults() {
41
+ for (let [field, value] of preset)
42
+ field.value = value;
43
+ preset.clear();
44
+ }
45
+ target.addEventListener("command", presetFromInvoker, { signal: controller.signal });
46
+ target.addEventListener("close", restoreDefaults, { signal: controller.signal });
47
+ target.addEventListener("toggle", (toggle) => {
48
+ if (toggle.newState === "closed")
49
+ restoreDefaults();
50
+ }, { signal: controller.signal });
51
+ });
52
+ handle.addEventListener("remove", () => {
53
+ controller?.abort();
54
+ controller = undefined;
55
+ });
56
+ });
57
+ /** The fields named `name` in every form inside `target`. */
58
+ function fieldsNamed(target, name) {
59
+ return [...target.querySelectorAll("input, select, textarea")].filter((field) => field.name === name);
60
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Why JS: seeking a media element in place and marking what plays need its API.
3
+ * No-JS baseline: every time is a link carrying `#t=` into the file, which opens it
4
+ * playing from that moment, and the server marks the moment it renders as now.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { ElementProps, MixinFactory } from "remix/component";
10
+ /** Types associated with {@link mediaSync} and {@link installMediaSync}. */
11
+ export declare namespace MediaSync {
12
+ /** What one player's sync marks and reports. */
13
+ interface Options {
14
+ /**
15
+ * Selectors, each matching one playing-order list under the player whose items carry
16
+ * their start in `data-start` or `data-cue`; the item playing carries `aria-current="true"`.
17
+ */
18
+ marks: readonly string[];
19
+ /** Runs after every seek and time update, with the items that newly became current. */
20
+ onTime?: (time: number, changed: HTMLElement[]) => void;
21
+ }
22
+ /** Configuration accepted by {@link mediaSync}. */
23
+ interface MixinOptions extends Options {
24
+ /** Selector of the player's root, the closest ancestor of the host that matches. */
25
+ root: string;
26
+ }
27
+ }
28
+ /**
29
+ * Sets `aria-current="true"` on the last item of a playing-order list whose start is at or
30
+ * before `time`, and removes it from the rest, writing only what changes.
31
+ *
32
+ * @param items The list's items in playing order, each with `data-start` or `data-cue`.
33
+ * @param time The media's current time in seconds.
34
+ * @returns The item that newly became current, or `undefined` when no item became current.
35
+ */
36
+ export declare function markPlaying(items: Iterable<HTMLElement>, time: number): HTMLElement | undefined;
37
+ /**
38
+ * Keeps a player's time links and marks in step with its media until `signal` aborts: a
39
+ * plain click on an `a[data-start]` seeks and plays, a modified click still opens the file,
40
+ * and every seek and time update marks the item playing in each list.
41
+ *
42
+ * @param root The player's root, which holds the links and the lists.
43
+ * @param media The `<audio>` or `<video>` the links seek.
44
+ * @param signal Ends the listeners when it aborts.
45
+ * @param options The lists to mark, and what to run after each update.
46
+ * @example installMediaSync(root, audio, signal, { marks: ['[data-slot="chapters"] a'] });
47
+ */
48
+ export declare function installMediaSync(root: HTMLElement, media: HTMLMediaElement, signal: AbortSignal, options: MediaSync.Options): void;
49
+ /**
50
+ * Makes a player's `a[data-start]` time links seek and play its first `<audio>` or `<video>`,
51
+ * and marks the playing item of each `marks` list, as {@link installMediaSync} does. The player
52
+ * is the host's closest `root` match; the host is usually a hidden marker in the player's island.
53
+ *
54
+ * @param options The player's root selector and the lists to mark.
55
+ * @returns A mixin descriptor for an element inside the player.
56
+ * @example <span hidden mix={[mediaSync({ root: '[data-slot="episode"]', marks: ["[data-cue]"] })]} />
57
+ */
58
+ export declare const mediaSync: MixinFactory<HTMLElement, [options: MediaSync.MixinOptions], ElementProps>;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Why JS: seeking a media element in place and marking what plays need its API.
3
+ * No-JS baseline: every time is a link carrying `#t=` into the file, which opens it
4
+ * playing from that moment, and the server marks the moment it renders as now.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createMixin } from "remix/component";
10
+ /** How far, in seconds, a moment may run ahead of a start and still count as reaching it. */
11
+ const SEEK_SLACK = 0.25;
12
+ /**
13
+ * Sets `aria-current="true"` on the last item of a playing-order list whose start is at or
14
+ * before `time`, and removes it from the rest, writing only what changes.
15
+ *
16
+ * @param items The list's items in playing order, each with `data-start` or `data-cue`.
17
+ * @param time The media's current time in seconds.
18
+ * @returns The item that newly became current, or `undefined` when no item became current.
19
+ */
20
+ export function markPlaying(items, time) {
21
+ let list = [...items];
22
+ let current;
23
+ for (let item of list) {
24
+ if (Number(item.dataset.start ?? item.dataset.cue) <= time + SEEK_SLACK)
25
+ current = item;
26
+ }
27
+ let changed;
28
+ for (let item of list) {
29
+ let isCurrent = item === current;
30
+ if (isCurrent === (item.getAttribute("aria-current") === "true"))
31
+ continue;
32
+ if (isCurrent) {
33
+ item.setAttribute("aria-current", "true");
34
+ changed = item;
35
+ }
36
+ else
37
+ item.removeAttribute("aria-current");
38
+ }
39
+ return changed;
40
+ }
41
+ /**
42
+ * Keeps a player's time links and marks in step with its media until `signal` aborts: a
43
+ * plain click on an `a[data-start]` seeks and plays, a modified click still opens the file,
44
+ * and every seek and time update marks the item playing in each list.
45
+ *
46
+ * @param root The player's root, which holds the links and the lists.
47
+ * @param media The `<audio>` or `<video>` the links seek.
48
+ * @param signal Ends the listeners when it aborts.
49
+ * @param options The lists to mark, and what to run after each update.
50
+ * @example installMediaSync(root, audio, signal, { marks: ['[data-slot="chapters"] a'] });
51
+ */
52
+ export function installMediaSync(root, media, signal, options) {
53
+ let sync = () => {
54
+ let changed = options.marks
55
+ .map((selector) => markPlaying(root.querySelectorAll(selector), media.currentTime))
56
+ .filter((item) => item !== undefined);
57
+ options.onTime?.(media.currentTime, changed);
58
+ };
59
+ root.addEventListener("click", (click) => {
60
+ if (click.defaultPrevented || click.button !== 0)
61
+ return;
62
+ if (click.metaKey || click.ctrlKey || click.shiftKey || click.altKey)
63
+ return;
64
+ let link = click.target?.closest("a[data-start]");
65
+ if (!link)
66
+ return;
67
+ click.preventDefault();
68
+ media.currentTime = Number(link.dataset.start);
69
+ void media.play().catch(() => undefined);
70
+ sync();
71
+ }, { signal });
72
+ media.addEventListener("timeupdate", sync, { signal });
73
+ }
74
+ /**
75
+ * Makes a player's `a[data-start]` time links seek and play its first `<audio>` or `<video>`,
76
+ * and marks the playing item of each `marks` list, as {@link installMediaSync} does. The player
77
+ * is the host's closest `root` match; the host is usually a hidden marker in the player's island.
78
+ *
79
+ * @param options The player's root selector and the lists to mark.
80
+ * @returns A mixin descriptor for an element inside the player.
81
+ * @example <span hidden mix={[mediaSync({ root: '[data-slot="episode"]', marks: ["[data-cue]"] })]} />
82
+ */
83
+ export const mediaSync = createMixin((handle) => {
84
+ let controller;
85
+ let options;
86
+ handle.addEventListener("insert", (event) => {
87
+ controller?.abort();
88
+ let root = options ? event.node.closest(options.root) : null;
89
+ let media = root?.querySelector("audio, video");
90
+ if (!options || !root || !media)
91
+ return;
92
+ controller = new AbortController();
93
+ installMediaSync(root, media, controller.signal, options);
94
+ });
95
+ handle.addEventListener("remove", () => {
96
+ controller?.abort();
97
+ controller = undefined;
98
+ });
99
+ return (next) => {
100
+ options = next;
101
+ };
102
+ });
@@ -24,6 +24,17 @@ export declare namespace MenuKeys {
24
24
  itemSelector?: string;
25
25
  }
26
26
  }
27
+ /**
28
+ * Runs the WAI-ARIA menu keyboard pattern on `host` until `signal` aborts: roving tabindex,
29
+ * arrow keys, Home/End and typeahead across its items. Script that owns server-rendered
30
+ * markup calls it directly; components reach it through {@link menuKeys}.
31
+ *
32
+ * @param host The Menu surface, usually a `role="menu"` element.
33
+ * @param signal Ends the listeners when it aborts.
34
+ * @param options Item-selector override for non-standard markup.
35
+ * @example installMenuKeys(panel, controller.signal, { itemSelector: "[data-item]" });
36
+ */
37
+ export declare function installMenuKeys(host: HTMLElement, signal: AbortSignal, options?: MenuKeys.Options): void;
27
38
  /**
28
39
  * Adapts the WAI-ARIA menu keyboard pattern — roving tabindex, arrow-key
29
40
  * navigation, Home/End, and typeahead — onto a Menu surface's