@sdxc/ui 2026.11.10 → 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 (196) hide show
  1. package/README.md +92 -45
  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/feature-band.d.ts +8 -0
  143. package/dist/landing/feature-band.js +9 -3
  144. package/dist/landing/index.d.ts +9 -0
  145. package/dist/landing/index.js +9 -0
  146. package/dist/landing/landing-header.js +15 -4
  147. package/dist/landing/mixins/countdown-tick.d.ts +29 -0
  148. package/dist/landing/mixins/countdown-tick.js +65 -0
  149. package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
  150. package/dist/landing/mixins/usage-estimate-live.js +120 -0
  151. package/dist/landing/phone-fan.d.ts +38 -0
  152. package/dist/landing/phone-fan.js +89 -0
  153. package/dist/landing/phone-frame.d.ts +48 -0
  154. package/dist/landing/phone-frame.js +41 -0
  155. package/dist/landing/price-list.d.ts +68 -0
  156. package/dist/landing/price-list.js +125 -0
  157. package/dist/landing/scroll-scene.d.ts +59 -0
  158. package/dist/landing/scroll-scene.js +70 -0
  159. package/dist/landing/sponsor-wall.d.ts +30 -6
  160. package/dist/landing/sponsor-wall.js +70 -14
  161. package/dist/landing/typed-terminal.d.ts +24 -6
  162. package/dist/landing/typed-terminal.js +22 -14
  163. package/dist/landing/usage-estimate.d.ts +127 -0
  164. package/dist/landing/usage-estimate.js +164 -0
  165. package/dist/landing/utils/countdown.d.ts +33 -0
  166. package/dist/landing/utils/countdown.js +42 -0
  167. package/dist/landing/utils/pause-toggle.d.ts +2 -1
  168. package/dist/mixins/character-count.d.ts +62 -0
  169. package/dist/mixins/character-count.js +139 -0
  170. package/dist/mixins/index.d.ts +6 -2
  171. package/dist/mixins/index.js +6 -2
  172. package/dist/mixins/invoker-fields.d.ts +18 -0
  173. package/dist/mixins/invoker-fields.js +60 -0
  174. package/dist/mixins/media-sync.d.ts +58 -0
  175. package/dist/mixins/media-sync.js +102 -0
  176. package/dist/mixins/menu-keys.d.ts +11 -0
  177. package/dist/mixins/menu-keys.js +79 -70
  178. package/dist/mixins/sortable.d.ts +96 -0
  179. package/dist/mixins/sortable.js +433 -0
  180. package/dist/utils/code-lines.d.ts +26 -0
  181. package/dist/utils/code-lines.js +29 -0
  182. package/dist/utils/file-icon.d.ts +31 -0
  183. package/dist/utils/file-icon.js +60 -0
  184. package/dist/utils/index.d.ts +2 -0
  185. package/dist/utils/index.js +2 -0
  186. package/dist/utils/write-cookie.d.ts +15 -15
  187. package/dist/utils/write-cookie.js +10 -16
  188. package/dist/video/index.d.ts +11 -0
  189. package/dist/video/index.js +11 -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/utils/timeline.d.ts +55 -0
  193. package/dist/video/utils/timeline.js +90 -0
  194. package/dist/video/video-player.d.ts +261 -0
  195. package/dist/video/video-player.js +927 -0
  196. package/package.json +6 -3
@@ -0,0 +1,164 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { mergeMix, raw } from "@sdxc/u/general";
3
+ import { container, hidden } from "@sdxc/u/layout";
4
+ import { at } from "@sdxc/u/responsive";
5
+ import { clientEntry, Frame } from "remix/component";
6
+ import { Button } from "../components/button.js";
7
+ import { landingCtaChrome, landingSurface } from "../styles/landing.js";
8
+ import { usageEstimateLive } from "./mixins/usage-estimate-live.js";
9
+ /** Container the card declares, which its two columns query. */
10
+ const CONTAINER_NAME = "ui-usage-estimate";
11
+ /** Milliseconds of quiet after the last input before a live bill is re-requested. */
12
+ const DEFAULT_DELAY = 250;
13
+ /**
14
+ * A GET form beside its bill on one card, side by side from 40rem, the sheet ruled in
15
+ * `--ui-landing-hairline`; with no script a submit reloads the page on the new bill. For `live`,
16
+ * map {@link UsageEstimateLive} (`@sdxc/ui/landing/usage-estimate`) to re-price while typing.
17
+ *
18
+ * @param handle Runtime handle carrying the host `<div>`'s props.
19
+ * @returns The render function producing the calculator's markup.
20
+ * @example
21
+ * <UsageEstimate
22
+ * action="#pricing"
23
+ * fields={<TextField label="Hours a month" type="number" name="hours" defaultValue="40" />}
24
+ * submitLabel="Estimate"
25
+ * bill={
26
+ * <UsageEstimate.Bill
27
+ * label="Estimated monthly bill"
28
+ * rows={[{ label: "Recorded hours", detail: "35 h × $0.36", amount: "$12.60" }]}
29
+ * total={{ label: "Per month", amount: "$12.60" }}
30
+ * />
31
+ * }
32
+ * />
33
+ * @example
34
+ * <UsageEstimate
35
+ * action="#pricing"
36
+ * fields={<TextField label="Hours a month" type="number" name="hours" defaultValue="40" />}
37
+ * submitLabel="Estimate"
38
+ * live={{ frame: "pricing-bill", src: "/?hours=40" }}
39
+ * />
40
+ */
41
+ export function UsageEstimate(handle) {
42
+ return () => {
43
+ let { action, bill, fields, live, mix, submitLabel, ...rest } = handle.props;
44
+ return (_jsx("div", { ...rest, "data-slot": "usage-estimate", mix: mergeMix([landingSurface(), container(CONTAINER_NAME)], mix), children: _jsxs("div", { mix: [
45
+ raw({ display: "grid", gridTemplateColumns: "minmax(0, 1fr)" }),
46
+ at("40rem", CONTAINER_NAME, raw({ gridTemplateColumns: "minmax(0, 0.9fr) minmax(0, 1.1fr)" })),
47
+ ], children: [_jsxs("form", { method: "get", action: action, mix: [
48
+ raw({
49
+ display: "flex",
50
+ flexDirection: "column",
51
+ alignItems: "stretch",
52
+ gap: "1.25rem",
53
+ padding: "1.5rem",
54
+ }),
55
+ ], children: [fields, _jsx(Button, { type: "submit", color: "neutral", variant: "surface", mix: [landingCtaChrome()], children: submitLabel }), live === undefined ? null : (_jsx(UsageEstimateLive, { frame: live.frame, delay: live.delay ?? DEFAULT_DELAY }))] }), _jsx("div", { "data-slot": "usage-estimate-sheet", mix: [
56
+ raw({
57
+ display: "grid",
58
+ padding: "1.5rem",
59
+ backgroundColor: "color-mix(in oklch, CanvasText 3%, transparent)",
60
+ borderStartEndRadius: "inherit",
61
+ borderEndEndRadius: "inherit",
62
+ borderEndStartRadius: "inherit",
63
+ boxShadow: "inset 0 1px 0 var(--ui-landing-hairline)",
64
+ }),
65
+ at("40rem", CONTAINER_NAME, raw({
66
+ borderEndStartRadius: "0",
67
+ boxShadow: "inset 1px 0 0 var(--ui-landing-hairline)",
68
+ })),
69
+ ], children: live === undefined ? bill : _jsx(Frame, { name: live.frame, src: live.src }) })] }) }));
70
+ };
71
+ }
72
+ /**
73
+ * The bill a calculator shows: its lines and total in a column of tabular figures, then the
74
+ * footnote and the CTA at the sheet's foot. A live route returns it alone for the frame, and
75
+ * the total is a polite live region, so a re-priced bill is announced by its sum.
76
+ *
77
+ * @param handle Runtime handle carrying the bill.
78
+ * @returns The render function producing the bill.
79
+ * @example
80
+ * <UsageEstimate.Bill label="Estimated monthly bill" rows={[{ label: "Free hours", detail: "5 h × $0.00", amount: "$0.00" }]} total={{ label: "Per month", amount: "$0.00" }} footnote="Readers are free." />
81
+ */
82
+ UsageEstimate.Bill = function UsageEstimateBill(handle) {
83
+ return () => {
84
+ let { cta, footnote, label, rows, total } = handle.props;
85
+ return (_jsxs("div", { "data-slot": "usage-estimate-bill", mix: [
86
+ raw({
87
+ display: "flex",
88
+ flexDirection: "column",
89
+ gap: "1rem",
90
+ minBlockSize: "100%",
91
+ }),
92
+ ], children: [_jsxs("table", { "aria-label": label, mix: [
93
+ raw({
94
+ inlineSize: "100%",
95
+ borderCollapse: "collapse",
96
+ fontVariantNumeric: "tabular-nums",
97
+ fontSize: "0.9375rem",
98
+ }),
99
+ ], children: [_jsx("tbody", { children: rows.map((row) => (_jsx(BillRow, { row: row }))) }), _jsx("tfoot", { "aria-live": "polite", children: _jsx(BillRow, { row: total, total: true }) })] }), footnote === undefined ? null : (_jsx("p", { mix: [
100
+ raw({
101
+ margin: "0",
102
+ fontSize: "0.875rem",
103
+ color: "var(--ui-neutral-fg-muted)",
104
+ textWrap: "pretty",
105
+ }),
106
+ ], children: footnote })), cta === undefined ? null : (_jsx("div", { mix: [raw({ display: "grid", marginBlockStart: "auto" })], children: cta }))] }));
107
+ };
108
+ };
109
+ /**
110
+ * The island a live calculator places in its form: it reloads the named bill frame for the
111
+ * form's query as the reader types, and on submit, with the address following through
112
+ * `replaceState`. Load `@sdxc/ui/landing/usage-estimate` in the browser entry.
113
+ */
114
+ export const UsageEstimateLive = clientEntry("@sdxc/ui/landing/usage-estimate#UsageEstimateLive", function UsageEstimateLive(handle) {
115
+ /** Reloads the bill frame from `src`; a frame missing from the page rejects. */
116
+ let reload = async (src) => {
117
+ let frame = handle.frames.get(handle.props.frame);
118
+ if (frame === undefined)
119
+ throw new Error(`No frame named ${handle.props.frame}`);
120
+ await frame.reload({ src });
121
+ };
122
+ return () => (_jsx("span", { "data-slot": "usage-estimate-live", mix: [hidden(), usageEstimateLive({ reload, delay: handle.props.delay })] }));
123
+ });
124
+ /**
125
+ * One line of the bill: the label with its arithmetic under it, and the amount pinned to
126
+ * the end. The total's cells carry the rule, so it spans the table's full width.
127
+ */
128
+ function BillRow(handle) {
129
+ return () => {
130
+ let { row, total = false } = handle.props;
131
+ let cell = raw({
132
+ paddingBlock: total ? "0.875rem 0" : "0.5rem",
133
+ verticalAlign: "baseline",
134
+ borderBlockStart: total ? "1px solid var(--ui-neutral-border-strong)" : "0",
135
+ });
136
+ return (_jsxs("tr", { "data-total": total ? "" : undefined, children: [_jsxs("th", { scope: "row", mix: [
137
+ cell,
138
+ raw({
139
+ textAlign: "start",
140
+ fontWeight: total ? "600" : "400",
141
+ color: "var(--ui-neutral-fg-emphasis)",
142
+ }),
143
+ ], children: [row.label, row.detail === undefined ? null : (_jsx("span", { mix: [
144
+ raw({
145
+ display: "block",
146
+ fontFamily: "var(--ui-font-mono)",
147
+ fontSize: "0.75rem",
148
+ fontWeight: "400",
149
+ color: "var(--ui-neutral-fg-muted)",
150
+ }),
151
+ ], children: row.detail }))] }), _jsx("td", { mix: [
152
+ cell,
153
+ raw({
154
+ textAlign: "end",
155
+ whiteSpace: "nowrap",
156
+ paddingInlineStart: "1rem",
157
+ fontSize: total ? "1.75rem" : "inherit",
158
+ fontWeight: total ? "600" : "400",
159
+ letterSpacing: total ? "-0.02em" : "normal",
160
+ color: "var(--ui-neutral-fg-emphasis)",
161
+ }),
162
+ ], children: row.amount })] }));
163
+ };
164
+ }
@@ -0,0 +1,33 @@
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
+ /** Types for {@link countdownParts}. */
10
+ export declare namespace CountdownParts {
11
+ /** A moment as a `Date`, an ISO 8601 string or epoch milliseconds. */
12
+ type DateInput = Date | string | number;
13
+ /** The time left, each unit already carried into the next, and whether it has run out. */
14
+ interface Result {
15
+ /** `true` once `now` has reached `to`, when every unit reads zero. */
16
+ done: boolean;
17
+ days: number;
18
+ hours: number;
19
+ minutes: number;
20
+ seconds: number;
21
+ }
22
+ }
23
+ /**
24
+ * The whole units left from `now` until `to`, rounded down, so a countdown reads "0 days" only
25
+ * in the last day and never jumps ahead of the clock. A moment that does not parse counts as
26
+ * already reached.
27
+ *
28
+ * @param to The moment counted down to.
29
+ * @param now The moment counted from.
30
+ * @returns The days, hours, minutes and seconds left, and whether none are.
31
+ * @example countdownParts("2027-04-15T07:00:00Z", "2027-04-14T05:30:00Z") // { done: false, days: 1, hours: 1, minutes: 30, seconds: 0 }
32
+ */
33
+ export declare function countdownParts(to: CountdownParts.DateInput, now: CountdownParts.DateInput): CountdownParts.Result;
@@ -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
+ }