@sdxc/kit 2026.11.11 → 2026.11.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.jsonl +114 -0
- package/dist/pkg/catalog.js +1 -0
- package/package.json +2 -2
- package/registry/ui/button.json +2 -2
- package/registry/ui/character-count.json +17 -0
- package/registry/ui/label-chip.json +16 -0
- package/registry/ui/property-list.json +3 -3
- package/registry/ui/textarea.json +6 -3
- package/registry/ui/timeline.json +3 -3
package/changelog.jsonl
CHANGED
|
@@ -483,6 +483,7 @@
|
|
|
483
483
|
{"release":"2026.10.2","package":"@sdxc/database-middleware","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
|
|
484
484
|
{"release":"2026.10.2","package":"@sdxc/dates","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
|
|
485
485
|
{"release":"2026.10.2","package":"@sdxc/diagram","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
|
|
486
|
+
{"release":"2026.10.2","package":"@sdxc/diff","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
|
|
486
487
|
{"release":"2026.10.2","package":"@sdxc/digest-fields","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
|
|
487
488
|
{"release":"2026.10.2","package":"@sdxc/distill","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
|
|
488
489
|
{"release":"2026.10.2","package":"@sdxc/doh","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
|
|
@@ -1983,3 +1984,116 @@
|
|
|
1983
1984
|
{"release":"2026.11.11","package":"@sdxc/epub","type":"fix","breaking":false,"title":"Parse stylesheet url() values in linear time","body":"Before, `cssReferences` and `rewriteCss` walked every `url()` with a regular\nexpression whose bare-value alternative backtracked over unfinished openers, so a\nstylesheet of many `url(!` prefixes could stall the Markdown book build. Now both\nfunctions scan forward for each closed `url()` and stop once an opener reaches the\nend of the file, so the same stylesheet finishes in time proportional to its length.\nThe rewritten CSS and the listed references are unchanged for every closed `url()`,\nand consumers need not act."}
|
|
1984
1985
|
{"release":"2026.11.11","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add PhoneFrame, PhoneFan and FeatureBand mediaSide","body":"PhoneFrame is the ink bezel around a capture or live screen; PhoneFan lays\nthree of them on a pausable bobbing stage. FeatureBand.mediaSide flips a\nsplit so media leads without hand-rolled order and lean.\n\n```tsx\n<PhoneFan label={t(\"phones\")} start={a} front={b} end={c} />\n<FeatureBand layout=\"split\" mediaSide=\"start\" title={t(\"title\")} media={shot}>\n {claims}\n</FeatureBand>\n```"}
|
|
1985
1986
|
{"release":"2026.11.11","package":"@sdxc/ui","type":"docs","breaking":false,"title":"Document FeatureBand mediaSide beside layout","body":"Call out split `mediaSide` and `lean` next to the existing layout options so\nthe README matches the PhoneFrame / PhoneFan composition craft already listed."}
|
|
1987
|
+
{"release":"2026.11.14","package":"@sdxc/diff","type":"feat","breaking":false,"title":"Add @sdxc/diff for line and word diffs and unified diff parsing","body":"New package. `diffLines` diffs two texts into hunks with context, aligning\nlines the way `git diff --histogram` does (anchored on lines rare in the\nfile, Myers where none is), then slides each block of changes where git puts\nit, indent heuristic included, so the hunks and their `@@` section headings\nmatch git's output. Paired deleted and added lines carry word ranges as\n`[start, end)` offsets. A cost cap turns pathological input into one replace\nblock marked `approximate: true` instead of a long computation.\n\n`parsePatch` reads every file header of a unified diff (renames, copies, new\nand deleted files, mode changes, binary files, quoted paths) in one pass and\nleaves each file's hunks as offsets; `parseHunks` reads one file's hunks when\nit is shown; `stringifyPatch` writes files and hunks back, byte for byte for\nwhat was read from git. Everything is plain JSON and runs in Workers, Node\nand Bun with no dependencies.\n\n import { diffLines, parseHunks, parsePatch } from \"@sdxc/diff\";\n\n let { hunks, additions, deletions } = diffLines(before, after);"}
|
|
1988
|
+
{"release":"2026.11.14","package":"@sdxc/diff","type":"docs","breaking":false,"title":"Show how fast diffing is next to the diff package","body":"The README gains a Performance section: mean times for line diffs (a few edits, many edits, a moved block, a full rewrite, a minified file) and for parsing a 1.28 MB patch, each beside the diff package 9.0.0 on the same input, plus the entry's gzipped size and the command that reruns the benchmarks. No code changes; consumers need not act."}
|
|
1989
|
+
{"release":"2026.11.14","package":"@sdxc/diff","type":"docs","breaking":false,"title":"Show the faster moved-block benchmark in the README","body":"The README's Performance table now shows a newer run for a 10,000-line file with a 500-line block moved: 1.32 ms against 57.0 ms for the diff package, 43× faster (it said 39×). No code changes; consumers need not act."}
|
|
1990
|
+
{"release":"2026.11.14","package":"@sdxc/highlight","type":"perf","breaking":false,"title":"Try only the rules that can start at each character","body":"`tokenize`, `highlight` and `scan` now try, at each position, only the rules\nwhose pattern can start with the character there, in the grammar's order, and\ntake a run of characters no rule can start as one `plain` token in one step.\nThe tokens are the same as before for ordinary files: a differential test holds\nthe new scanner to the previous one over every grammar test input, a sample of\nreal TypeScript, TSX, CSS, JSON, Markdown, YAML and shell files, and seeded\nsplices of both. Nothing to change to upgrade.\n\nTokenizing time, before and after, against Prism 1.30 on the same input:\n\n- 10,000-line TypeScript file: 27 ms -> 4.5 ms (Prism 120 ms)\n- 2 MB JSON document: 200 ms -> 37 ms (Prism 95 ms)\n- 10,000-line Markdown file: 31 ms -> 5 ms (Prism 23 ms)\n- 500 KB minified JavaScript line: 66 ms -> 15 ms read in full, 0.05 ms with\n the default line cap (Prism 70 ms)\n\nLines longer than 2,000 characters: before, every line was tokenized in full;\nnow the grammar reads the first 2,000 characters of a line and the rest of it,\nup to its newline, is one `plain` token, so a minified file paints at once. To\nkeep highlighting long lines in full, pass the new `maxLineLength` option:\n\n tokenize(code, \"js\", { maxLineLength: Infinity });\n\nLinear time on hostile input. Four grammars took quadratic time on input such\nas a long run of one character; each now scans in linear time:\n\n- CSS: a long run of `-` or `_` in a selector, block or value.\n- JavaScript, TypeScript and JSX: a long run of whitespace after a name.\n- Markdown: a long line inside a fenced code block.\n- Ruby: an unclosed `%w(`, `%i[` (any of the four delimiters). Before, it\n painted as an operator and punctuation; now it paints as a string to the end\n of the source, as an unclosed single-quoted string already did. Closed lists\n paint as before.\n\nLines with their state. `tokenizeLines(code, language, options?)` (and\n`scanLines(code, grammar, options?)` for a grammar value) returns one entry per\nline: its tokens without the newline, and `state`, the mode stack the line ends\nin. Pass a line's `state` back to scan the lines after it on their own, such as\na diff hunk loaded later:\n\n import { tokenizeLines } from \"@sdxc/highlight\";\n\n let lines = tokenizeLines(file, \"ts\");\n let hunk = tokenizeLines(linesFrom42, \"ts\", { state: lines[40]?.state });\n\n`scan`, `tokenize` and `highlight` take the same `options` (`maxLineLength`,\n`state`). The new types `Line` and `ScanOptions` are exported."}
|
|
1991
|
+
{"release":"2026.11.14","package":"@sdxc/highlight","type":"docs","breaking":false,"title":"Show how fast tokenizing is next to Prism","body":"The README gains a Performance section: mean tokenize times for a 10,000-line TypeScript file, a 2 MB JSON document, a 10,000-line Markdown file and a 500 KB minified line, each beside Prism 1.30 on the same input (4× to 10× faster, and 700× on the minified line thanks to the default line cap), plus the command that reruns them. No code changes; consumers need not act."}
|
|
1992
|
+
{"release":"2026.11.14","package":"@sdxc/highlight","type":"docs","breaking":false,"title":"Update the tokenizing benchmarks to a quiet-machine run","body":"The README's Performance table shows each input's best measured run: a 10,000-line TypeScript file tokenizes 30× faster than Prism 1.30, a 2 MB JSON document 4×, a 10,000-line Markdown file 4.5×, and a 500 KB minified line 1,200× with the default line cap (25 ms, still 5× faster, without it). No code changes; consumers need not act.","correctedIn":"2026.11.14"}
|
|
1993
|
+
{"release":"2026.11.14","package":"@sdxc/kit","type":"fix","breaking":false,"title":"Know @sdxc/diff in sdxc pkg","body":"`sdxc pkg` did not list `@sdxc/diff`, the line and word diff package, among the\npublished packages, so it treated `diff` as unknown. It now knows the package and\nthat it ships no command line. Nothing to change for anyone using the kit."}
|
|
1994
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep AppShell rail icons centred when the nav scrolls","body":"On browsers with classic scrollbars (Chrome/Edge on Windows and Linux),\nan overflowing collapsed rail reserved a gutter beside the icons, so the\ncurrent row's fill no longer sat under its glyph. Safari's overlay\nscrollbars never took that space, which is why the shift was easy to\nmiss there.\n\nThe rail nav now hides its scrollbar while it stays a rail (peek and the\nexpanded column still show the thin bar). Wheel, touch and keyboard\nscrolling are unchanged. After upgrading `@sdxc/ui`, a tall collapsed\nsidebar keeps the active fill on the icon the way a short one does; no\nother consumer action is required."}
|
|
1995
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add a chat Composer that streams replies in and stops on Stop","body":"`@sdxc/ui/chat` gains the message box a chat assistant needs, and a way to\nplay a server-rendered reply back as if it were streaming from a model.\n\n- `Composer` is a plain `<form>`: `Composer.Input` grows with its text up to\n twelve lines (`--ui-composer-max-block-size`) and then scrolls,\n `Composer.Toolbar` holds attach and option controls, and `Composer.Hint`\n says how to send (it truncates on a narrow composer and hides on touch\n screens).\n- `ComposerSubmit` is its send button, a client island: Enter sends,\n Shift+Enter writes a new line, the field clears after sending, and while a\n reply streams it turns into Stop (Escape stops too).\n- `revealStream(root)` replays a reply's existing markup a few words at a\n time, showing each paragraph, list item, table row or code block when the\n text reaches it; `streamTarget()` styles the reply so it never flashes\n before the replay, shows at once under reduced motion or without scripts,\n and shows whole after 2.5s if the script never runs.\n- `composerSend(options)` is the mixin behind `ComposerSubmit`, for a send\n control of your own.\n\n <Composer method=\"post\" action=\"/chat\">\n \t<Composer.Input name=\"prompt\" aria-label=\"Message\" required />\n \t<Composer.Toolbar>\n \t\t<Composer.Hint><Keyboard>Enter</Keyboard> to send</Composer.Hint>\n \t\t<ComposerSubmit labels={{ send: \"Send\", stop: \"Stop\" }} stream=\"reply-7\" />\n \t</Composer.Toolbar>\n </Composer>\n <div id=\"reply-7\" data-stream-pending mix={[streamTarget()]}>…</div>\n\nLoad `@sdxc/ui/chat/composer-submit` in your browser entry so the island\nhydrates. Nothing existing changes."}
|
|
1996
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Reset an OptimisticToggle to the server's state when it is reused","body":"Before, an `OptimisticToggle` that a client navigation reused for another\nrecord kept the last press: after starring one conversation and opening the\nnext, the second showed the first one's colour and pressed state, because the\npress was drawn straight onto the DOM and a re-render with the same props\nchanged nothing.\n\nNow every render puts the toggle back to the `pressed` value the server\nrendered, unless a press is still waiting for its answer. The\n`optimisticToggleSync()` mixin takes that value as a new optional `pressed`\noption; `OptimisticToggle` passes it for you, so consumers need not act."}
|
|
1997
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"refactor","breaking":false,"title":"Keep revealStream beside streamTarget in the chat mixins","body":"`revealStream()` and its attribute constants now live in the same folder as\n`streamTarget()`, so the catalogue documents them together. They are still\nexported from `@sdxc/ui/chat` exactly as before; this change has no effect\non consumers."}
|
|
1998
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add Activity, a \"Thinking\" disclosure for what an assistant did","body":"`@sdxc/ui/chat` gains `Activity`, the collapsible record an assistant shows\nabove its reply: its plan, then each step it took, built on native\n`<details>` so it opens without script.\n\n- `Activity.Summary` says what was done (\"Thought for 8s\") and, while the\n reply around it is `aria-busy`, a shimmering busy label (\"Thinking\").\n- `Activity.Note` holds the assistant's own words on its plan.\n- `Activity.Steps` lists `Activity.Step` rows: an icon and a line, a\n `running` state that swaps the icon for moving dots, and a `detail` that\n turns the line into a disclosure opening onto a command's output or a\n `boxed` run of steps.\n\n <Activity open>\n \t<Activity.Summary busy=\"Thinking\">Thought for 14s</Activity.Summary>\n \t<Activity.Note>I'll check the search, then cancel stale requests.</Activity.Note>\n \t<Activity.Steps>\n \t\t<Activity.Step icon={<TerminalIcon />} duration={1200} detail={<pre>1 failed</pre>}>\n \t\t\tRan the tests\n \t\t</Activity.Step>\n \t</Activity.Steps>\n </Activity>\n\n`revealStream()` replays these steps the way an agent works: it marks the\nblock it showed last with `data-stream-current` (a step shows its dots\nthere), dwells on a block that carries `data-stream-pause` (an\n`Activity.Step`'s `duration`), and leaves the folded content of a closed\ndisclosure whole instead of typing it out unseen. Existing replays behave as\nbefore."}
|
|
1999
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Draw ComposerSubmit's Send and Stop buttons as circles","body":"Before, the composer's Send and Stop buttons rendered as a slightly tall\nrounded square: the button's own height and corner radius won over the\ncomposer's shape. Now both are a 36px circle at any size of the surrounding\ntype, so swapping Send for Stop never moves the row. Consumers need not act."}
|
|
2000
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Fold an assistant's thinking once its answer starts","body":"Before, an `Activity` opened for a streamed reply stayed open after the reply\nfinished, so the thinking pushed the answer down. Now a replay folds it the\nmoment the answer's first words appear, and its summary switches from the\nshimmering busy label (\"Thinking\") to the done one (\"Thought for 5s\") while\nthe rest of the answer streams. A reply shown at once under reduced motion\nfolds it straight away; a reply stopped while thinking leaves it open.\n\n`Activity` opts in by default. Any other disclosure can do the same with the\n`data-stream-collapse` attribute, and `collapseStream(root, block?)` folds\nthem by hand:\n\n <details data-stream-collapse open>…</details>\n\nConsumers need not act."}
|
|
2001
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add CharacterCount, a live ring and count for limited fields","body":"`@sdxc/ui` gains `CharacterCount`, a client island that shows how much of a\nfield's limit is used: a ring that fills as the field is typed in, the\ncharacters left once the limit is near, and how far over once past it. It\nrenders the count for the field's server-side text, so a form re-rendered\nafter a refused submit opens on the right state.\n\n <textarea id=\"draft\" name=\"text\" />\n <CharacterCount\n for=\"draft\"\n max={280}\n value={draft}\n holdSubmit\n labels={{ remaining: \"{count} characters left\", over: \"{count} characters over the limit\" }}\n />\n\n- `warn` (default 20) sets how many characters left show the number.\n- `holdSubmit` disables the form's submit buttons while the field is empty\n or over the limit, and the field gets `aria-invalid` past it.\n- A screen reader hears each change of state once, not every keystroke.\n- From ten over, the ring fades and only the number stays.\n- `countCharacters(text)` counts grapheme clusters, so an emoji with a skin\n tone counts once. Use it on the server to check the same limit.\n- `characterCount(options)` is the mixin behind it, for a custom count.\n\nAdd `@sdxc/ui/character-count` to your browser entry's module map so the\nisland hydrates. Nothing existing changes."}
|
|
2002
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add Skeleton.Text, a placeholder shaped by the real text","body":"`Skeleton.Text` lays its children out unseen and paints a bar over each line\nthey wrap to. A placeholder built from the real markup takes the content's\nexact size at every width, so a frame or a lazy part lands without the page\nmoving, and a name that wraps on a phone wraps in its placeholder too.\n\n <strong><Skeleton.Text>{person.name}</Skeleton.Text></strong>\n <p><Skeleton.Text>{person.bio}</Skeleton.Text></p>\n <Skeleton.Text block><Button size=\"sm\">Follow</Button></Skeleton.Text>\n\n`block` paints one pill around an inline-flex box, such as a button or a\nbadge, instead of a bar per line. The placeholder is hidden from assistive\ntechnology. Nothing existing changes."}
|
|
2003
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Let OptimisticToggle take a button variant and size","body":"`OptimisticToggle` takes `variant` and `size`, passed to its button. Its tone\nstill follows the state: neutral while off, brand once on. A solid toggle\nreads as the one action in a row, such as a Follow pill:\n\n <OptimisticToggle\n action={`/people/${person.handle}/follow`}\n name=\"following\"\n pressed={person.following}\n variant=\"solid\"\n labels={{ label: `Follow ${person.name}`, pressed: `Unfollow ${person.name}`, failed: \"Failed\" }}\n pressedContent=\"Following\"\n unpressedContent=\"Follow\"\n />\n\nThe defaults stay `variant=\"ghost\"` and `size=\"sm\"`, so existing toggles\nrender as before and need no change."}
|
|
2004
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add TabBar, a phone's bottom tab bar","body":"`@sdxc/ui/app` gains `TabBar`, the bottom tab bar a phone layout uses in\nplace of a sidebar. It holds four or five destinations, each an icon over its\nname, fixed above the home indicator. It keeps its own height in the page\nflow, so the last row of content never hides behind it.\n\n <TabBar label=\"Primary\">\n <TabBar.Item href=\"/\" icon={<HouseIcon />} label=\"Home\" current />\n <TabBar.Item href=\"/search\" icon={<SearchIcon />} label=\"Search\" />\n <TabBar.Item href=\"/alerts\" icon={<BellIcon />} label=\"Alerts\" count={3} countLabel=\"3 new\" />\n </TabBar>\n\n- `hideFrom` (\"30rem\" | \"40rem\" | \"48rem\" | \"64rem\" | \"never\", default\n \"40rem\") is the width from which the bar is gone, matching where the\n app's sidebar appears. `never` keeps it at every width.\n- `showLabels={false}` draws icons alone and keeps the names for assistive\n tech.\n- The current item gets `aria-current=\"page\"` and the brand colour. A count\n over 99 reads \"99+\", and `countLabel` says what it means.\n- Every item is at least 44px square.\n- `TAB_BAR_BLOCK_SIZE` is the bar's height, for a floating button that\n sits above it.\n\nThe package README also lists `CharacterCount` and `Skeleton.Text`. Nothing\nexisting changes."}
|
|
2005
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add Board and Roadmap, a kanban and a project timeline","body":"`@sdxc/ui/app` gains two components for project tools.\n\n`Board` lays out kanban columns of cards. A mouse or pen drag lifts a card,\nrings the column under the pointer, and on drop moves the card there and\nposts the card's own move form with that column's value. Escape cancels a\ndrag, and a press that never travels stays a click. Touch presses scroll the\nboard as usual. The move form is also what a card's menu submits, so a card\nmoves without script, by keyboard and on a phone too.\n\n <Board id=\"web\" label=\"Web issues by status\">\n <Board.Column value=\"todo\" title=\"Todo\" count={1} empty=\"No issues\">\n <Board.Card value=\"WEB-12\" move={{ action: \"/issues/WEB-12\", name: \"status\" }}>\n <a href=\"/issues/WEB-12\">Fix the cart badge</a>\n </Board.Card>\n </Board.Column>\n </Board>\n\n- `boardMoveFormId(board, card)` names a card's move form, for a menu row\n that submits it with its own name and value.\n- Columns are `--ui-board-column-width` (18rem) wide; below a 40rem board,\n one column and a sliver of the next show, snapping column by column.\n- The drag dispatches a cancelable `ui:board-move` (`BoardMoveEvent`) on\n the card before the form posts.\n- The drag is the `BoardDrag` island at `@sdxc/ui/app/board#BoardDrag`; map\n `@sdxc/ui/app/board` in your browser entry's module loader.\n\n`Roadmap` draws grouped projects as bars on a month and week axis. Each bar\nfills with its progress, today's line runs through every row, and a project\nprojected past its target runs a hatched tail to the projected day. The list\ncolumn and the axis stay put while the roadmap scrolls inside its own box.\n\n <Roadmap label=\"Roadmap\" start=\"2026-09-01\" end=\"2027-03-31\" today=\"2026-11-12\" labels={labels}>\n <Roadmap.Group title=\"Q4 2026\">\n <Roadmap.Item name=\"Checkout v2\" href=\"/projects/checkout\" start=\"2026-10-01\"\n end=\"2026-12-15\" progress={0.6} projectedEnd=\"2027-01-10\" />\n </Roadmap.Group>\n </Roadmap>\n\n- Dates are `YYYY-MM-DD`, read as UTC. `roadmapDay(date)` converts one to\n whole days for your own arithmetic.\n- `--ui-roadmap-day-width` (6px), `--ui-roadmap-list-width` (20rem) and\n `--ui-roadmap-row-height` (2.75rem) size it; below 40rem the list column\n narrows to 10rem and hides each row's `meta`.\n- Every row's name carries its dates, progress and projection as text for\n a screen reader.\n\nNothing existing changes."}
|
|
2006
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"refactor","breaking":false,"title":"Draw Board's and Roadmap's optional parts through iife","body":"`Board` and `Roadmap` now build each optional part (a column's icon, count,\nactions and empty line, a card's move form, a roadmap row's glyph, meta, late\ntail and trailing slot, and today's marker) with an early-returning `iife`,\nand set their `data-board-*` attributes through the `attrs()` mixin. The drag\nmixin's handlers are named function declarations.\n\nThe rendered HTML and every behavior are unchanged. Consumers need not act."}
|
|
2007
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep a Board drop's column in its post, and fit Board and Roadmap on phones","body":"Three fixes to `Board` and `Roadmap` from `@sdxc/ui/app`.\n\nA drop posted no column. Before, the drag filled the card's move form and\ndisabled its field again right after `requestSubmit()`, so a client runtime\nthat reads the form after that task (the Remix runtime does) posted without\nit and the server answered 400. Now a drop appends the column's field to the\nform and leaves it there; the next render of the form drops it. The form names\nthat field in `data-board-move-field`, and the value comes after the form's\nown `fields`. A menu row's submitter also comes last, so read the field's\nlast value (`form.getAll(\"status\").at(-1)`) if a card can be both dragged\nand moved by its menu.\n\nOn a touch screen, a phone-narrow board widened the whole page to the width\nof all its columns. A button's enlarged touch target is an absolutely\npositioned box that escaped the unpositioned scroller. The column row is now\npositioned, so it clips everything inside it and the page stays the\nviewport's width.\n\nOn a phone-narrow roadmap, the list column kept its 20rem width. The 10rem\nnarrow width was set on the roadmap's own box, which its own container query\ncannot style. It now applies, and the axis gets the room back. The axis's week\nlines also run the roadmap's full height, and the scroll box is positioned.\n\nConsumers need not act unless they read a card's move field with `get()`\nwhile also submitting the form from a menu."}
|
|
2008
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep a Button's touch target inside the scroll box it sits in","body":"On a touch screen `Button` grows its pointer target to 44px with an\nabsolutely positioned box. The button was not positioned, so that box took\nthe page as its containing block and escaped any scrolling row it sat in.\nBefore, a row of small buttons wider than a phone, such as a kanban's column\nheaders, widened the whole page. Now the button is the target's containing\nblock, so the row clips it and only the row scrolls.\n\nA position utility in a Button's `mix` (`absolute()`, `sticky()`, ...)\nstill replaces the button's own, so positioned buttons are unchanged.\nConsumers need not act."}
|
|
2009
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Open a Roadmap on today","body":"`Roadmap` now scrolls itself sideways once it is laid out, so today's line\nsits a third of the way across the visible axis. A roadmap wide enough to\nshow today, or one the reader already scrolled, stays where it is. Without\nscript it opens at its first day, as before.\n\nThe scroll is the `RoadmapToday` island at\n`@sdxc/ui/app/roadmap#RoadmapToday`, which a roadmap renders whenever\n`today` falls on its axis. Map `@sdxc/ui/app/roadmap` in your browser entry's\nmodule loader:\n\n \"@sdxc/ui/app/roadmap\": () => import(\"@sdxc/ui/app/roadmap\"),\n\nThe `roadmapToday()` mixin is also exported for a marker of your own.\n\nA roadmap whose `start` or `end` cannot be read now draws a one-day axis\ninstead of throwing while it renders."}
|
|
2010
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Move a Board card from the keyboard","body":"`Board` cards now move with Shift+ArrowLeft and Shift+ArrowRight. The card\nthat holds focus moves one column over and keeps focus. Both columns'\ncounts update, and the card's move form posts the new column's value,\nexactly as a drop does.\n\nAn optional `labels.moved` says where the card went, through the board's\nown polite live region:\n\n <Board id=\"web\" label=\"Issues by status\" labels={{ moved: \"Moved to {column}\" }}>\n\nWithout `labels` a keyboard move is silent. The `boardDrag()` mixin takes\nthe same `{ moved }` option. Nothing existing changes."}
|
|
2011
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Close a FilterBar facet on Apply and turn its chevron while open","body":"A facet popover in `FilterBar` now closes when its Apply button submits, by a\nclick or by Enter in one of its checkboxes. Before, a page that answered the\nsubmit in place (client navigation or a frame) left the popover open over the\nfiltered list. A full page load behaves as before.\n\nThe facet trigger's chevron now turns over while that facet's popover is open,\nand a facet's `icon` is drawn at 16px, the size of the View trigger's icon, so\nicons of different artwork sit at one size in the bar.\n\nApply is now the `FilterBarApply` island, which loads from the same\n`@sdxc/ui/app/filter-bar` module as `FilterBarClear`. An app that already maps\nthat specifier in its browser entry needs no change. Without script, Apply\nsubmits the bar's form as before."}
|
|
2012
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Let a Board fill a height and an AppShell hold its screen to the window","body":"`Board` now fills the height it is given and becomes the one scroller for its\ncolumns, on both axes, with each column's header sticky at the top. Give it a\nheight through its parent or `mix`:\n\n <Board id=\"web\" label=\"Web issues\" mix={[raw({ flex: \"1 1 auto\" })]}>…</Board>\n\nWithout a height it grows with its tallest column, as before.\n\nA column's empty line now sits right under its header. Before, a column\nstretched to the board's height drew it at the column's foot.\n\n`AppShell` takes `fill`, which holds `<main>` to the height under the top bar\nwhile the sidebar is docked and lays its children out as a flex column, so a\nscreen that scrolls inside itself keeps its scrollbars on screen:\n\n <AppShell fill …><div style=\"flex: 1 1 auto; min-block-size: 0\">…</div></AppShell>\n\nShells without `fill` are unchanged."}
|
|
2013
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":true,"title":"Scope AppShell and SplitView cookies to a path","body":"`AppShell` and `SplitView` take `cookiePath`, the path their remembered state\nis written under, so an app mounted under a prefix keeps its sidebar and split\nto itself. Both default to `/`, which keeps every existing shell as it was:\n\n <AppShell cookieName=\"crm-sidebar\" cookiePath=\"/apps/crm\" …>\n <SplitView cookie=\"crm-split\" cookiePath=\"/apps/crm\" …>\n\nBreaking: `writeCookie` takes an options object in place of a bare max age,\nwhich also carries the new `path`.\n\n // before\n writeCookie(\"ui:dismissed\", true, 60 * 60 * 24 * 7);\n // after\n writeCookie(\"ui:dismissed\", true, { maxAgeSeconds: 60 * 60 * 24 * 7 });\n\nA call with only a name and a value is unchanged."}
|
|
2014
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Let a Board card land where it is dropped","body":"`Board.Move` takes `position`, the field a move sends the value of the card\nit lands before in, or an empty value when it lands last:\n\n <Board.Card value=\"WEB-12\" move={{ action, name: \"status\", position: \"before\" }}>\n\nWith it, a drag places the card between the cards under the pointer as it\nmoves, also within its own column. The drop posts the column and the\nneighbour, so the server can keep the order the visitor sees. Escape puts the\ncard back where it started. Shift+ArrowUp and Shift+ArrowDown move the focused\ncard past its neighbour, and Shift+ArrowLeft and Shift+ArrowRight land it at\nthe top of the next column. `BoardMoveEvent` carries the neighbour as `before`.\n\nA card without `position` behaves as before: a drop on another column puts it\nat the top of that column, and only the column's value is posted."}
|
|
2015
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Snap a Board's sideways scroll column by column","body":"A `Board` now snaps column by column at every width. A sideways scroll settles\nwith a column's start at the left edge instead of stopping halfway through\none. Before, only a board narrower than 40rem snapped. The snap is lifted\nwhile a card is dragged, so the board still scrolls smoothly when the pointer\nrests near its edge. Consumers need no change."}
|
|
2016
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Paint a Chart's edge markers and strokes in full","body":"A `Chart` now draws markers and line strokes that sit on its edges in full. A\npoint at the bottom or top of `yDomain`, such as a zero on a burn-up chart,\nnow shows its whole dot. Before, the chart's box clipped half of it. The\nchart's size and layout are unchanged, and consumers need no change."}
|
|
2017
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Preset a dialog's fields from the button that opens it","body":"The new `invokerFields()` mixin lets an invoker button preset the dialog or\npopover it opens. A button carrying `name` and `value` sets the target's\nfield of that name to that value. Once the target closes, each preset field\nreturns to what it held before. Put it on a hidden marker inside the target,\nin a hydrated island:\n\n <button commandfor=\"new-issue\" command=\"show-modal\" name=\"status\" value=\"done\">+</button>\n <dialog id=\"new-issue\">\n <span hidden mix={[invokerFields()]} />\n <form>…<select name=\"status\">…</select></form>\n </dialog>\n\nWithout script the button still opens its target, with every field at its\ndefault."}
|
|
2018
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":true,"title":"Move items within and between any lists with sortable()","body":"The drag and keyboard moves behind `Board` are now the general `sortable()`\nmixin in `@sdxc/ui/mixins`, so any list or set of lists can use them:\nsortable settings rows, a playlist, a board of your own. Mark the parts with\nattributes and put the mixin on a hidden marker inside the root, in a hydrated\nisland:\n\n <section data-sortable>\n <span hidden mix={[sortable({ moved: \"Moved to {list}\" })]} />\n <span data-sortable-status role=\"status\" />\n <div data-sortable-list=\"queue\">\n <h2 data-sortable-title>Queue</h2>\n <ul data-sortable-items>\n <li data-sortable-item=\"a\">…</li>\n </ul>\n </div>\n </section>\n\n- A mouse or pen drag lifts an item under a ghost and places it between the\n items under the pointer, in its own list or another. Escape puts it back.\n- Shift+ArrowUp and Shift+ArrowDown move the focused item past its neighbour.\n Shift+ArrowLeft and Shift+ArrowRight move it to the top of the list on\n either side. Focus stays on the item, and the move is announced.\n- Each move dispatches `ui:sortable-move` (`SortableMoveEvent`: `item`, `from`,\n `to`, `before`). Prevent it to keep the item in place.\n- An item can name its own move form with `data-sortable-form`. The form\n receives the list's value in its `data-sortable-field` field and, when it\n names one, the item it lands before in its `data-sortable-position` field.\n\nBreaking: the board-only names are gone, and `Board` users who read them\nchange as follows.\n\n- `boardDrag(options)` → `sortable(options)`; the `moved` template takes\n `{list}` (Board's own `labels.moved` still takes `{column}`).\n- `BoardMoveEvent` / `ui:board-move` → `SortableMoveEvent` /\n `ui:sortable-move`, with `card` renamed to `item`.\n- `BOARD_*_ATTRIBUTE` constants → their `SORTABLE_*_ATTRIBUTE` counterparts.\n The DOM attributes a Board renders change to match, so `data-board-card`\n becomes `data-sortable-item`, `data-board-column` becomes\n `data-sortable-list`, and `form[data-board-move]` becomes\n `form[data-sortable-form]`.\n\n`Board`'s own props are unchanged."}
|
|
2019
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Reload an AppShell's top bar and screen as one frame","body":"`AppShell.Pane` draws the shell's top bar and `<main>`, the part a\nscreen changes, and `AppShell` takes a `pane` to draw in their place.\nPass a named `<Frame>` whose content is an `AppShell.Pane`. A link or\nform aimed at that frame then reloads the screen together with its top\nbar controls, and the sidebar stays mounted:\n\n <AppShell labels={labels} nav={nav} pane={<Frame name=\"main\" src={url} />} />\n\n // the frame's content\n <AppShell.Pane labels={labels} topbar={<ModelPicker />}>\n <Chat />\n </AppShell.Pane>\n\n`AppShell.Pane` takes the shell's `labels` (`menu` and `collapse`),\n`collapsed`, `topbar`, `id`, `fill`, `cookieName`, `cookiePath` and\n`sheetBelow`. Give it the same values as the shell so the collapse\ntoggle and the skip link keep working. `children` on `AppShell` is now\noptional, since a `pane` replaces it.\n\nAfter each navigation, the sidebar's current row now follows the\naddress. The row whose link names the current path gets\n`aria-current=\"page\"` and `data-current`, and the row that held them\nloses them. Before, a navigation that reloaded only a frame beside the\nsidebar left the old row marked. A sidebar with no row matching the\naddress keeps the marks the server drew. This needs\n`@sdxc/ui/app/app-shell-toggle` loaded in the browser entry, as it\nalready must be."}
|
|
2020
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Aim SettingsLayout and SplitView links at a named frame","body":"`SettingsLayout` and `SplitView` take a `frame` prop: the name of the\n`<Frame>` their own links load into. Pass it when the layout is drawn\ninside that frame, so following one of its links reloads only that\nframe and the rest of the page stays put:\n\n <SettingsLayout frame=\"main\" sections={sections} backHref=\"/settings\" labels={labels}>\n\n <SplitView frame=\"main\" list={list} detail={detail} backHref=\"/inbox\" labels={labels} />\n\n`SettingsLayout` writes it as `data-rmx-target` on every section link\nand its narrow back link, and `SplitView` on its narrow back link.\nWithout `frame`, the links stay as they were."}
|
|
2021
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Retitle the page when an AppShell pane lands in a frame","body":"`AppShell.Pane` takes a `title`: the document title for its screen.\nA navigation that reloads only a frame holding the pane leaves the\npage's `<title>` as it was. Once such a navigation finishes, the\nshell's controls apply the landed pane's `title` to the page:\n\n <AppShell.Pane labels={labels} title=\"Invoices — Acme\" topbar={topbar}>\n <Invoices />\n </AppShell.Pane>\n\nThe pane writes it as `data-title` on its `<main>`. A pane without a\n`title` leaves the page's title alone. Like the current-row resync,\nthis needs `@sdxc/ui/app/app-shell-toggle` loaded in the browser entry."}
|
|
2022
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep a composer's message in a multipart post that a frame reloads","body":"`composerSend` empties the composer's field after a message is sent.\nIt used to empty it one task after `submit`. For a multipart form\n(`enctype=\"multipart/form-data\"`, which a composer with an attach\nbutton needs), the browser fires the Navigation API's `navigate` event\na task after `submit`, and a runtime that intercepts the navigation\n(such as Remix's, for a form aimed at a named frame) reads the form's\ndata from that event. So the message often went out empty: the server\nsaw `prompt=\"\"` and answered as if nothing had been typed.\n\nThe field now empties only after the `navigate` event, so the post\ncarries the message. Where the Navigation API is missing, it empties\none task after `submit`, as before. No change is needed in consumers."}
|
|
2023
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Aim FilterBar, ViewOptions, Board moves and DetailSheet links at a frame","body":"Four app components now take the name of a `<Frame>` to load into. A filter,\na view change, a board move or a step through a sheet then reloads only that\nframe, while the address still moves. Without script, every link and form\nloads its page as before.\n\n <FilterBar target=\"issues\" … /> // form, tabs, sort, chips, clear\n <ViewOptions target=\"issues\" … /> // Apply\n <Board.Card move={{ action, name: \"status\", target: \"board\" }} />\n <DetailSheet target=\"sheet\" closeHref={…} position={…} … />\n\nEach sets `data-rmx-target` on the links and forms it renders. An inert\nPrevious or Next link carries no target.\n\nA `Board.Card` now renders `data-rmx-key` set to its value. When its frame\nreloads, each card is then matched to the same live element, even after a drop\nmoved it to another column. Components without a target behave as before."}
|
|
2024
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Empty a composer whose post a script sends itself","body":"When a page's script takes over a composer's submission (a `submit`\nlistener that calls `preventDefault` and sends the form itself, such\nas through a frame reload), `composerSend` used to keep the typed\nmessage in the field. It waited for a Navigation API `navigate` event,\nand a post sent by script fires none.\n\nThe field now empties one task after `submit` when the submission was\ntaken over, after the script has read it. When the browser itself\nnavigates, the field still empties after the `navigate` event, so a\nmultipart post keeps its message. No change is needed in consumers."}
|
|
2025
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Replay a reply that arrives after the composer mounted","body":"`ComposerSubmit` replays the reply its `stream` names. When that reply\narrived after the composer was already on the page (a frame reload\nanswering a send, which gives the mounted composer a new `stream` and\n`streamKey`), `composerSend` threw a framework invariant (\"handle.signal\nis only available during mixin setup, render, or lifecycle callbacks\").\nThe reply then stayed hidden, its text never revealed and Stop never\nshowed.\n\nThe replay now starts in that case too and ends when the composer\nleaves the page, as one that starts on first render does. No change is\nneeded in consumers."}
|
|
2026
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":true,"title":"Rename Roadmap to Gantt","body":"`@sdxc/ui/app`'s `Roadmap` is now `Gantt`, named after the chart it draws:\ngrouped rows of bars on a month and week axis, with progress, today's line\nand a hatched tail for a late projection. Nothing about how it draws or\nbehaves changes.\n\nBreaking: every name changes, with no aliases. To migrate:\n\n1. Import from `@sdxc/ui/app/gantt`, and rename the component, its parts and\n its types.\n\n // before\n import { Roadmap } from \"@sdxc/ui/app/roadmap\";\n let labels: Roadmap.Labels = { … };\n <Roadmap label=\"Plan\" start={start} end={end} labels={labels}>\n <Roadmap.Group title=\"Q4\">\n <Roadmap.Item name=\"Checkout\" start=\"2026-09-14\" end=\"2026-12-11\" />\n </Roadmap.Group>\n </Roadmap>\n\n // after\n import { Gantt } from \"@sdxc/ui/app/gantt\";\n let labels: Gantt.Labels = { … };\n <Gantt label=\"Plan\" start={start} end={end} labels={labels}>\n <Gantt.Group title=\"Q4\">\n <Gantt.Item name=\"Checkout\" start=\"2026-09-14\" end=\"2026-12-11\" />\n </Gantt.Group>\n </Gantt>\n\n The helper `roadmapDay(date)` is now `ganttDay(date)`.\n\n2. Rename the mixin and its island.\n\n // before\n import { roadmapToday } from \"@sdxc/ui/app\";\n <span hidden mix={[roadmapToday()]} />\n // after\n import { ganttToday } from \"@sdxc/ui/app\";\n <span hidden mix={[ganttToday()]} />\n\n The island `RoadmapToday` (`@sdxc/ui/app/roadmap#RoadmapToday`) is now\n `GanttToday` (`@sdxc/ui/app/gantt#GanttToday`).\n\n3. Point the browser entry's module map at the new subpath.\n\n // before\n \"@sdxc/ui/app/roadmap\": () => import(\"@sdxc/ui/app/roadmap\"),\n // after\n \"@sdxc/ui/app/gantt\": () => import(\"@sdxc/ui/app/gantt\"),\n\n4. Rename the custom properties you set, and any selectors on its parts:\n `--ui-roadmap-day-width`, `--ui-roadmap-list-width` and\n `--ui-roadmap-row-height` are now `--ui-gantt-*`. Every\n `data-slot=\"roadmap…\"` is now `data-slot=\"gantt…\"`, such as\n `gantt-item`, `gantt-late` and `gantt-today`."}
|
|
2027
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Restore AppShell's content scroll on Back and Forward within the page","body":"Before, an app shell whose pages swapped in place (a frame navigation) kept its\ncontent panel wherever the visitor last scrolled it: Back landed the panel at\nthe top or at the previous page's offset, and a link to another page opened\npartway down, because the panel scrolls rather than the window. Now\n`AppShell` keeps the panel's position for each history entry: Back and Forward\nreturn to it, a link to another path starts at the top, and a change to the\nquery alone keeps the position. Whole-page navigations behave as before.\nNothing to change in your app; the shell's toggle island already carries it."}
|
|
2028
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Wait a full interval before AutoRefresh's first reload","body":"Before, `AutoRefresh` counted its first interval from `refreshedAt`, so a page\nwhose time was older than the interval (a copy served from a cache, or a fixed\ndemo time) reloaded the moment it hydrated, which also cancelled anything the\nvisitor did in that instant. Now the first reload comes one full interval\nafter the page loads, and later ones keep counting from the end of the last\nreload. `refreshedAt` still sets the time the status shows until that first\nreload. A page that wants fresh data on load should render it fresh; nothing\nelse changes for consumers."}
|
|
2029
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Show SaveStatus's Saved when the page redraws it in place","body":"Before, a `SaveStatus` the page redrew without remounting it, such as an editor\nwhose save answered through a frame, went blank: the new `state=\"saved\"`\nlanded on the element's `data-state`, but its text stayed empty and never\ndecayed to the edit time. Now a changed `state` or `editedAt` from a redraw\ndrives the status the way a fresh render does: \"Saved\" shows for `savedMs`,\nthen the edit time. Nothing to change in your app."}
|
|
2030
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Ask before an in-page navigation leaves SaveBar's unsaved changes","body":"Before, `SaveBar` guarded only `beforeunload`, so in an app that swaps pages in\nplace (a frame navigation) a visitor could follow a link away from a dirty form\nand lose the changes without a prompt. Now, while the form has unsaved changes,\nany navigation the page handles itself asks first and stays put when the\nvisitor declines; a jump to an anchor on the same page goes ahead. The question\ndefaults to the bar's `message`; pass `labels.leave` to word it as one:\n\n <SaveBar labels={{ message: \"Unsaved changes\", leave: \"Leave without saving your changes?\", discard: \"Discard\", save: \"Save\" }} />\n\nNothing else changes for consumers."}
|
|
2031
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Export codeLines and fileIcon from @sdxc/ui/utils","body":"`@sdxc/ui/utils` now exports the two helpers `CodeBlock` and `FileTree` draw\nwith, so a component of your own that draws code a line at a time, or names\na file, matches them.\n\n`codeLines(runs)` splits highlighted runs into one array of runs per source\nline. A run that spans lines, such as a block comment, becomes one run per\nline with the same type, and a blank line is an empty array:\n\n```ts\nimport { tokenize } from \"@sdxc/highlight\";\nimport { codeLines } from \"@sdxc/ui/utils\";\n\nlet lines = codeLines(tokenize(source, \"ts\")); // CodeToken[][]\n```\n\n`fileIcon(name, { fallback? })` returns the `@sdxc/icons` component for a file\nname or path, by extension (a dotfile's name counts as one):\n\n```tsx\nlet Glyph = fileIcon(\"package.json\"); // FileBracesIcon\n<Glyph size={16} aria-hidden=\"true\" />\n```\n\n`CodeBlock` and `FileTree` now share one icon map. A `CodeBlock` titled with a\n`.sh`, `.css`, image or lockfile name now shows the terminal, type, image or\nlock file icon `FileTree` uses for it (it showed the code file icon before),\nand a `FileTree` entry ending in `.ini` shows the settings file icon. No code\nchange is needed."}
|
|
2032
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add LabelChip, a label pill readable in any colour","body":"`LabelChip` draws the label an issue, pull request or record carries. Pass\nany CSS colour, or a hue in degrees, and the chip derives its tint, border\nand text from it at fixed OKLCH lightness, so the text stays at 4.5:1 or\nbetter on its tint for every colour, in light and dark themes alike:\n\n```tsx\nimport { LabelChip } from \"@sdxc/ui\";\n\n<LabelChip color=\"#d73a4a\">bug</LabelChip>\n<LabelChip hue={150}>{t(\"labels.feature\")}</LabelChip>\n```\n\nFor dense rows, `variant=\"dot\"` draws a neutral outlined chip with the colour\nin a dot before the name:\n\n```tsx\n<LabelChip variant=\"dot\" color={label.color}>{label.name}</LabelChip>\n```\n\nA chip without `color` or `hue` is grey. The colour is also available to your\nown rules as the `--ui-label-chip-color` custom property on the chip."}
|
|
2033
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add comment cards and commit groups to Timeline","body":"`Timeline` gains two parts for a pull request's conversation, where talk gets a\ncard and housekeeping gets a line:\n\n- `Timeline.Comment` draws a comment as a card with the author's avatar on the\n rail, a header reading \"name action time\" with a `⋯` slot at its end, the\n rendered Markdown body, and a reactions row.\n- `Timeline.Commits` lists a push's commits under one rail stop, and\n `Timeline.Commit` gives each its subject, a check-state slot and the short sha.\n\n```tsx\n<Timeline aria-label=\"Conversation\">\n <Timeline.Comment id=\"comment-12\" avatar={<Avatar size=\"xs\" />} author=\"ana\"\n action=\"commented\" time={<RelativeTime date={at} />} menu={<CommentMenu />}\n reactions={<Reactions />}>\n <Markdown source={body} />\n </Timeline.Comment>\n <Timeline.Commits icon={<GitCommitHorizontalIcon />} actor=\"ana\" summary=\"added 2 commits\">\n <Timeline.Commit sha=\"a1b2c3d\" href=\"/commit/a1b2c3d\" check={<ChecksPassed />}>\n Fix the parser\n </Timeline.Commit>\n </Timeline.Commits>\n</Timeline>\n```\n\n`Timeline`, `Timeline.Event` and `Timeline.More` are unchanged; nothing to do\nfor existing consumers."}
|
|
2034
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Fold PageHeader tabs into a More menu on a narrow pane","body":"Before, a header with many tabs scrolled its tab row sideways on a phone, so\ntabs and their counts hid off-screen. Now, under 40rem of header width, the row\nkeeps the first two tabs and a \"More ▾\" button that opens a native popover menu\nwith the rest, counts included. The current tab always stays in the row: when\nit would have folded, it takes the row's last place. Wide headers show every\ntab as before, and a header with three tabs or fewer never folds.\n\n```tsx\n<PageHeader\n title=\"acme / delta\"\n tabsLabel=\"Repository\"\n tabs={[\n { href: \"/code\", label: \"Code\", current: true },\n { href: \"/issues\", label: \"Issues\", count: 26 },\n { href: \"/pulls\", label: \"Pull requests\", count: 71 },\n { href: \"/actions\", label: \"Actions\" },\n ]}\n tabsNarrow={2}\n tabsMore=\"More\"\n/>\n```\n\n`tabsNarrow` (default 2) and `tabsMore` (default \"More\") are optional; existing\nheaders need no change."}
|
|
2035
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add a fuzzy file finder page to CommandPalette","body":"`CommandPalette.Finder` is a \"Go to file\" page for the palette. It ranks a list\nof paths against the query on every keystroke, lists the best 50 as links with\nthe matched characters in bold, and moves with ↑↓ and Enter like any other\npage. Matching is a subsequence score that prefers path-segment and word starts,\nconsecutive runs and the file's own name; 5,000 paths rank within a keystroke.\n\n`CommandPalette.Page` (and so the finder) takes a `shortcut` that opens the\npalette straight on that page, listed in the `?` help under the page's title.\n\n```tsx\n<CommandPalette id=\"palette\" labels={labels}>\n <CommandPalette.Finder id=\"files\" title=\"Go to File\" shortcut=\"t\"\n paths={tree.paths} href=\"/blob/main/{path}\" />\n</CommandPalette>\n```\n\nThe scoring is exported, so a server renders the same results on its own\n`/find?q=` page for a browser without script:\n\n```ts\nimport { fuzzyFilter, fuzzySegments } from \"@sdxc/ui/app/command-palette\";\n\nlet results = fuzzyFilter(query, tree.paths, 100);\nlet bolded = fuzzySegments(results[0].path, results[0].positions); // Highlight-shaped\n```\n\nExisting palettes need no change."}
|
|
2036
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add file rows, a filter and keyboard navigation to Tree","body":"`Tree` from `@sdxc/ui/app/tree` now builds a file browser as well as an outline.\n\n- `Tree.Leaf` is a file row: a link with the file's icon, indented from the folders\n around it and exposed as a `treeitem`. `current` marks the file being read with\n `aria-current=\"page\"`, a tint and an accent bar (render its folders `open`). A diff's\n file list adds `status` (`added`, `modified`, `deleted`, `renamed`), drawn as a toned\n A/M/D/R letter with a spoken `statusLabel`, and `additions`/`deletions` as end-aligned\n `+n −n` counts.\n- `Tree` takes `frame`, the frame every file link swaps (`data-rmx-target`), so picking a\n file redraws only the code.\n- `Tree.Filter` is a \"Go to file\" field: a GET form (`?filter=`) that works without\n script, plus an island that hides files missing the query as the reader types, opens the\n folders holding matches and restores them when cleared. `treeFilterMatches(path, query)`\n is the same rule for the server's narrowed render.\n- `Tree.Navigation` adds the keyboard: one Tab stop, ↑↓ and `j`/`k` between visible rows,\n → opens or enters a folder, ← closes it or goes to its parent, Home/End and type-ahead.\n The keys go through the page's shortcut registry and answer only while focus is in the\n tree, so a list's own `j`/`k` keep working elsewhere. The mixin is `treeNavigation()`.\n\nBoth islands load from `@sdxc/ui/app/tree#TreeFilterField` and\n`@sdxc/ui/app/tree#TreeNavigation`; map them in your browser entry.\n\n <Tree.Filter tree=\"files\" label={t(\"files.filter\")} value={filter} />\n <Tree id=\"files\" aria-label={t(\"files.title\")} frame=\"main\">\n <Tree.Navigation labels={{ group: t(\"keys.files\"), next: t(\"keys.next\") }} />\n <Tree.Item id=\"app\" open>\n <Tree.ItemContent><Tree.ExpandButton />app</Tree.ItemContent>\n <Tree.Leaf href=\"/blob/main/app/routes.ts\" name=\"routes.ts\" path=\"app/routes.ts\" current />\n </Tree.Item>\n </Tree>\n\nExisting trees render as before."}
|
|
2037
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add CheckRuns, a check list summarised by state","body":"`@sdxc/ui/app/check-runs` exports `CheckRuns`, which summarises check runs in one\nsentence (\"1 failing, 1 pending and 22 successful checks\") and discloses the list in a\nnative `<details>` that opens on its own when a run failed. Rows sort failure, pending,\nsuccess, then skipped and cancelled; each state has its own icon shape as well as its\ntone, the pending icon pulses (and holds still under reduced motion), and each row links\nto its log. Every string comes from `labels`, plural-aware, and the counts are joined\nwith `Intl.ListFormat` in `locale`. No script is needed.\n\n import { CheckRuns } from \"@sdxc/ui/app/check-runs\";\n\n <CheckRuns\n runs={[{ name: \"typecheck\", workflow: \"CI\", state: \"failure\", duration: \"48s\", href: \"/runs/1\" }]}\n locale=\"en\"\n labels={{\n counts: { failure: (n) => `${n} failing`, pending: (n) => `${n} pending`, success: (n) => `${n} successful`, skipped: (n) => `${n} skipped`, cancelled: (n) => `${n} cancelled` },\n summary: (list, total) => `${list} ${total === 1 ? \"check\" : \"checks\"}`,\n states: { failure: \"Failed\", pending: \"In progress\", success: \"Passed\", skipped: \"Skipped\", cancelled: \"Cancelled\" },\n details: \"Details\",\n empty: \"No checks\",\n }}\n />\n\n`CheckRunIcon`, `sortCheckRuns` and `checkRunsSummary` are exported for a page composing\nits own rows, such as a commit's status in a list of commits."}
|
|
2038
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add MergeBox, a merge control that says why it is blocked","body":"`@sdxc/ui/app/merge-box` exports `MergeBox`, the box that ends a pull request. It draws\none ruled row per precondition (reviews, checks, conflicts), each with a toned icon whose\nshape repeats its tone, a title, a detail and optional content such as a `CheckRuns`\nlist. Below them sits a split merge button: a submit button joined to a menu of methods\n(merge, squash, rebase) built as a native radio group posting `method`, so picking one\nand merging needs no script. While the state is `blocked` or `conflicts` both halves stay\non screen, disabled, with the reason as their `aria-describedby`; `merged` and `closed`\nshow the outcome and a `followUp` slot such as \"Delete branch\". The form is a plain POST\nto `action`, with extra hidden `fields` such as a CSRF token.\n\n import { MergeBox } from \"@sdxc/ui/app/merge-box\";"}
|
|
2039
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add ContributionGraph, a year of daily counts as a grid","body":"`@sdxc/ui/app/contribution-graph` exports `ContributionGraph`, a year of per-day counts\nas a real `<table role=\"grid\">`: a caption, a month header row, weekday row headers (Mon,\nWed and Fri shown), and one cell per day with `data-level` 0–4 and a name such as \"12\ncontributions on Tuesday, Nov 3\", then a \"Less · More\" legend. Weeks start on the\nlocale's first day (or `weekStart`), `levels` sets each level's lower bound, and `href`\nturns days into links. Levels read `--graph-level-0` to `--graph-level-4`, which default\nto the accent mixed into the neutral tint, so every theme recolours the graph in light and\ndark. On a phone the table scrolls inside its own box and opens on the current week.\n\nWithout script each day has a `title`. Map the `ContributionGraphTooltip` island\n(`@sdxc/ui/app/contribution-graph#ContributionGraphTooltip`) in the browser entry for one\nshared tooltip anchored to the hovered or focused day and arrow-key, Home and End\nnavigation with a roving Tab stop.\n\n import { ContributionGraph } from \"@sdxc/ui/app/contribution-graph\";"}
|
|
2040
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Let a PropertyList row open the app's own popover","body":"`PropertyList.Item`'s `edit` now takes `popover`, a whole popover the app\nrenders, in place of the row's built-in one and its `content`. The row's\nvalue button still opens it by `edit.id` and anchors it under the row, so\na multi-value property (labels, assignees, reviewers) can open a\nfilterable picker instead of a hand-built form.\n\n <PropertyList.Item\n label=\"Labels\"\n empty=\"None yet\"\n edit={{\n id: \"edit-labels\",\n label: \"Edit labels\",\n popover: <FilterMenu.Popover id=\"edit-labels\" mode=\"multiple\" name=\"label\" {...picker} />,\n }}\n >\n {chips}\n </PropertyList.Item>\n\nThe popover's own `id` must equal `edit.id`. `edit.content` is now\noptional; rows that pass it render exactly as before, so no change is\nneeded in existing code."}
|
|
2041
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add FilterMenu, a filterable picker for links, radios or checkboxes","body":"`FilterMenu` from `@sdxc/ui/app/filter-menu` is one popover list for every\n\"pick from many\" trigger: a branch or tag picker whose items are links\n(`mode=\"navigate\"`), and label, assignee or milestone pickers whose items\nare radios (`\"single\"`) or checkboxes (`\"multiple\"`) posted to `action`\nwhen the popover closes having changed, so the property saves as a model.\n\n <FilterMenu\n id=\"ref-picker\"\n mode=\"navigate\"\n tabs\n trigger=\"main\"\n groups={[\n { label: \"Branches\", items: branches },\n { label: \"Tags\", items: tags },\n ]}\n filterAction=\"/branches\"\n footer={<a href=\"/branches\">View all branches</a>}\n labels={{ title: \"Switch branches/tags\", filter: \"Filter branches\",\n empty: \"Nothing to show\", more: \"{count} more, refine your filter\", save: \"Save\" }}\n />\n\n <FilterMenu id=\"labels\" mode=\"multiple\" name=\"label\" action=\"/issues/7/labels\"\n trigger=\"Labels\" groups={[{ label: \"Labels\", items: labels }]} labels={copy} />\n\nItems take `value`, `label`, `href`, `description`, `color` (drawn as a\n`LabelChip` dot), `badge` and `selected`; selected items sort first.\n`FilterMenu.Popover` renders the popover alone for a trigger the page\nalready has, such as a `PropertyList` row's `edit.popover`. At phone widths\nthe same popover is a bottom sheet.\n\nThe list is the `FilterMenuList` island\n(`@sdxc/ui/app/filter-menu#FilterMenuList`): map\n`@sdxc/ui/app/filter-menu` in the app's browser entry. Hydrated, it focuses\nthe filter, hides rows as you type, moves a highlighted row with ↑↓, picks\nwith Enter and closes with Escape. It draws at most `limit` (100) matches\nand counts the rest, so a list of thousands keeps a small page. Without\nscript, links still navigate, `filterAction` filters through a GET form,\nand pickers show a Save button.\n\nAlso adds the `submitOnClose()` mixin, which submits the form holding it\nwhen its popover closes with different values, and `filterMenuKeys()`."}
|
|
2042
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add LogViewer for CI job logs","body":"`LogViewer` (from `@sdxc/ui/app/log-viewer`) draws a CI job's log the way a\nreader hunts for a failure:\n\n- One native `<details>` per step with its state icon and duration; the failed\n step starts open and the others closed.\n- Numbered lines whose numbers are links (`lineHref`) painted from attributes,\n so copying a line copies only its text; the link's fragment is the line's id,\n so `:target` paints a cited line.\n- `##[group]`/`##[endgroup]` become nested folds (a fold holding an error starts\n open), `##[error]`/`##[warning]` tone their line, and ANSI SGR colours become\n toned spans.\n- Timestamps as a GET toggle (`timestamps`, `timestampsHref`).\n- Every line stays in the page, chunked with `content-visibility: auto`, so\n find-in-page and selection cover a 20,000-line log at three nodes per line.\n- A step with `stream` is live (`LogViewer.Stream`): its further lines stream\n from `stream.src` as `text/plain` and append in place, the log follows its\n tail until the reader scrolls up, and a \"Jump to latest\" pill brings them\n back. Without script, the page shows the log so far and a Refresh link.\n- One island adds search: a match counter, Enter / ⇧Enter to step, and matches\n painted with the CSS Custom Highlight API.\n\n```tsx\n<LogViewer\n steps={job.steps}\n lineHref={(step, n) => `#step:${step}:${n}`}\n timestamps={showTimes}\n timestampsHref={showTimes ? \"?\" : \"?ts=1\"}\n labels={labels}\n/>\n```\n\nRegister the island in the browser entry by loading `@sdxc/ui/app/log-viewer`.\nThe ANSI parser (`parseAnsi`, `parseAnsiLine`, `stripAnsi`) and the log helpers\n(`buildLogTree`, `readMarker`, `splitTimestamp`, `formatLogTime`) are exported\nfrom the same module."}
|
|
2043
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Name LogViewer's island options apart from its island","body":"The options type of the `logViewerController` mixin is now\n`LogViewerBehavior.Options`. It was declared as `LogViewerController`, the same\nname as the `LogViewerController` island component, so re-exporting both\nmodules from one barrel made the name ambiguous. `LogViewer.ControllerProps`\nis unchanged; nothing to do unless you imported the mixin's options type by\nits old name, in which case import `LogViewerBehavior` instead."}
|
|
2044
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add CodeView, a whole-file reader with line links and blame","body":"`CodeView` from `@sdxc/ui/app/code-view` shows a source file to read and cite.\n\n- One table row per line. Line `n` is `#Ln`, and its number is painted from\n `data-line-number`, so copying code never copies the numbers.\n- Rows come in `<tbody>` chunks of 200 lines with `content-visibility: auto`. The browser\n skips chunks until they near the screen, but every line stays in the document, so\n find-in-page and anchors keep working. A line costs four elements plus its highlighted\n runs; plain text gets no span.\n- Citing lines works without script: each number links to `?L=n#Ln`, `:target` paints\n one line, and `selected` paints a `?L=3-8` range on the server (read it with\n `parseLineRange`).\n- With script, one island per view handles the rest. Click a number to select a line, or\n shift-click to select a range. The address becomes `#L3-L8` through `replaceState`,\n which keeps `history.state`. A `⋯` menu on the first selected line offers Copy line,\n Copy permalink and Reference in new issue. `y` rewrites the address to `permalink`, and\n Escape clears the selection. The island loads from\n `@sdxc/ui/app/code-view#CodeViewSelection`; map it in your browser entry.\n- `blame` hunks draw a leading cell spanning each hunk's rows, with the subject, author and\n age. An age strip runs from older to newer through `--code-age-1` to `--code-age-5`.\n `CodeView.AgeLegend` draws its key.\n- `CodeView.Header` holds the file's facts (from `codeStats(code)`) and its actions.\n Below a 40rem view width, lines soft-wrap and numbers stay on each line's first row."}
|
|
2045
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add PriceList, a menu or price list for landings","body":"`PriceList` from `@sdxc/ui/landing` lays out named groups of items, each a name joined to\nits price by a dotted leader with a short description under it. Groups flow into as many\ncolumns as the band holds (each at least `columnWidth`, 18rem by default) and stack into one\ncolumn on a phone; a long name wraps before it pushes the price off its line. Group titles\nrender at the ambient heading level.\n\n import { PriceList } from \"@sdxc/ui/landing\";"}
|
|
2046
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Play a TypedTerminal session on the light code card","body":"`TypedTerminal` takes a `variant` prop. The default, `\"terminal\"`, keeps the\ndark panel. `\"code\"` plays the same typed session on the raised code card in\nthe page's own colour scheme, for a session that reads as a document being\nwritten rather than a shell, with pass and failure lines inked in the step that\nreads on the page."}
|
|
2047
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add ContributorWall, a project's contributors as a tile mosaic","body":"`@sdxc/ui/landing` now ships `ContributorWall`, for an open-source landing that\nshows who builds the project. Each contributor is a square, linked tile with\ntheir picture or initials, tinted by a stable shade read from their name, so a\nwall of initials reads as texture and the page's accent stays free; hovering or\nfocusing a tile fills it with the brand. A closing `More` tile counts everyone\nthe wall leaves out and links to the full list.\n\n```tsx\nimport { ContributorWall } from \"@sdxc/ui/landing\";\n\n<ContributorWall aria-label=\"Contributors\">\n {people.map((person) => (\n <ContributorWall.Person href={person.url} name={person.name} />\n ))}\n <ContributorWall.More href={contributorsUrl} count=\"+179\" aria-label=\"All 214 contributors\" />\n</ContributorWall>\n```\n\nThe mosaic steps from 6 to 9 to 12 columns as its container widens; pass\n`columns={[phone, md, lg]}` to change the steps, and pick a tile count every\nstep divides so each row fills."}
|
|
2048
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Export only the landing components that ship","body":"The previous release's `@sdxc/ui/landing` barrel re-exported four modules that\nwere not part of it (`case-study`, `countdown`, `episode-player` and\n`video-stage`), so importing `@sdxc/ui/landing` failed to resolve. The barrel\nnow exports exactly the components the package ships, `ContributorWall`\nincluded. Consumers need do nothing beyond upgrading."}
|
|
2049
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add Countdown, the time left until a launch or an event","body":"`Countdown` from `@sdxc/ui/landing` shows the days, hours, minutes and\nseconds left until a moment as one `<time datetime>`. The server renders the\ntime left from `now`; with `live`, an island rewrites it from the viewer's\nclock and ticks every second, so a cached page still reads true. Once the\nmoment passes, the units give way to the `done` text.\n\n import { Countdown } from \"@sdxc/ui/landing\";\n\n <Countdown\n to=\"2027-04-15T07:00:00Z\"\n now={requestTime}\n done=\"Doors are open\"\n labels={{ days: \"days\" }}\n live\n />\n\n`live` needs the island in the app's browser entry:\n\n \"@sdxc/ui/landing/countdown\": () => import(\"@sdxc/ui/landing/countdown\"),\n\nStyle the figures from an ancestor through the `countdown-unit`,\n`countdown-value`, `countdown-label` and `countdown-done` slots, which reach\nthe server render and the island alike. `countdownParts(to, now)` returns the\nsame arithmetic for a page that draws its own countdown."}
|
|
2050
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Pulse a pending CheckRunIcon through real keyframe stops","body":"Before, the pending check-run icon declared its `@keyframes` inside the\n`[data-state=\"pending\"]` selector, where each stop serialized as a dropped\n`0%: [object Object]` declaration, so the icon named an animation with no\nstops and never pulsed. Now the keyframes sit at the top level of the icon's\nstyles and the pending icon fades between full and 35% opacity while motion\nis allowed. Consumers of `CheckRuns` and `CheckRunIcon` from `@sdxc/ui/app`\nneed no change."}
|
|
2051
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Export CheckRuns, CodeView, FilterMenu, LogViewer and more from @sdxc/ui/app","body":"The `@sdxc/ui/app` barrel now re-exports the newest app components with\ntheir helpers and mixins: `CheckRuns` and `CheckRunIcon` (with\n`sortCheckRuns`, `checkRunsSummary`), `CodeView` and `CodeViewSelection`\n(with `codeStats`, `parseLineRange`, `lineRangeQuery`, `lineRangeHash`,\n`lineLink`, the `LineRange` type and the `codeViewSelection` mixin),\n`ContributionGraph` (with `contributionGraphKeys`), `FilterMenu` and\n`FilterMenuList` (with `filterMenuKeys` and `submitOnClose`), `LogViewer`\nand `LogViewerController` (with `parseAnsi`, `stripAnsi`, `buildLogTree` and\nthe `logViewerController` mixin), `MergeBox`, and the Tree mixins\n`treeFilter`, `applyTreeFilter` and `treeNavigation`. Each still imports on\nits own as `@sdxc/ui/app/<module>`.\n\n import { CheckRuns, CodeView, MergeBox } from \"@sdxc/ui/app\";"}
|
|
2052
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add UsageEstimate, a usage calculator that needs no script","body":"`UsageEstimate` from `@sdxc/ui/landing` sets a GET form of the reader's\nnumbers beside the bill the server printed for them. Submitting reloads the\npage with the query, the page computes the bill and passes its rows, so the\ncalculator works without JavaScript and every answer is a shareable URL.\nAmounts share one right-aligned column of tabular figures with the total; the\nform and bill sit side by side on a wide card and stack on a phone."}
|
|
2053
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Let a page set Countdown's figures in its own type","body":"Before, `Countdown`'s own figure and label styles won over a page's rules\nfor its `countdown-value` and `countdown-label` slots, so a page could not\nchange the figures' size, face or colour. Now the countdown reads them from\ncustom properties a page sets on any ancestor:\n\n <div\n style=\"--ui-countdown-value-font: Impact; --ui-countdown-value-size: 3rem;\n --ui-countdown-value-color: hotpink; --ui-countdown-label-size: 0.75rem\"\n >\n <Countdown to={doorsOpen} done=\"Doors are open\" live />\n </div>\n\nThe properties are `--ui-countdown-value-font`, `-value-size`,\n`-value-weight` and `-value-color`, `--ui-countdown-label-font` and\n`-label-size`, `--ui-countdown-gap` and `--ui-countdown-align`. A page that\nstyled the slots directly moves those values to the properties."}
|
|
2054
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add EpisodePlayer, an audio episode with chapters and a transcript","body":"`EpisodePlayer` from `@sdxc/ui/landing` renders a podcast or read-aloud\nepisode: the browser's own `<audio controls>` with a captions track, a\nchapter list and a timed transcript in a closed `<details>`. Every chapter\nand transcript time is a media-fragment link (`episode.mp3#t=112`), so it\nplays from that moment with no script. Once the page's islands run, a click\nseeks the player and starts it, and the chapter and passage that are playing\ncarry `aria-current=\"true\"`.\n\n import { EpisodePlayer } from \"@sdxc/ui/landing\";\n\n <EpisodePlayer\n src=\"/audio/63.mp3\"\n type=\"audio/mpeg\"\n captions={{ src: \"/audio/63.vtt\", srclang: \"en\", label: \"English\" }}\n title=\"The pressure at the top of the hill\"\n meta=\"Episode 63 · 14:20\"\n chapters={[{ start: 0, title: \"Cold open\" }, { start: 112, title: \"What pressure means\" }]}\n transcript={[{ start: 0, speaker: \"Tove\", text: \"This is Undercurrent.\" }]}\n />\n\nThe seeking runs in the `EpisodeSync` island it renders, which loads from\n`@sdxc/ui/landing/episode-player`. Map that specifier in your browser entry\nnext to your other package islands:\n\n \"@sdxc/ui/landing/episode-player\": () => import(\"@sdxc/ui/landing/episode-player\"),\n\n`formatEpisodeTime(seconds)` writes a time the same way the list does\n(`1:52`, `1:02:05`)."}
|
|
2055
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Space stacked FaqBand columns with --ui-landing-faq-gap","body":"Before, a two-column `FaqBand` from `@sdxc/ui/landing` stacked its columns with no gap\nbetween them, so on a phone a FAQ whose questions are cards showed a seam where the first\ncolumn's last card touched the second column's first card. The band now spaces stacked\ncolumns by the `--ui-landing-faq-gap` custom property, which defaults to 0, so hairline FAQs\nlook exactly as before. A FAQ built from cards sets the property to the gap between its\ncards, ideally reading it in the accordion too, so every gap is the same:\n\n <FaqBand columns={2} title=\"Questions\" mix={[raw({ \"--ui-landing-faq-gap\": \"0.75rem\" })]}>\n \t<Accordion mix={[raw({ display: \"flex\", flexDirection: \"column\", gap: \"var(--ui-landing-faq-gap)\" })]}>…</Accordion>\n \t<Accordion mix={[raw({ display: \"flex\", flexDirection: \"column\", gap: \"var(--ui-landing-faq-gap)\" })]}>…</Accordion>\n </FaqBand>\n\nPages with carded FAQs must set the property to get the fix; nothing else changes."}
|
|
2056
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add CaseStudy, a project as a full-bleed scene with its result","body":"`CaseStudy` from `@sdxc/ui/landing` sets one project the way a printed\nportfolio lays out a spread: a running head (index, client, meta), a plate\nthat crosses the whole band edge to edge past the measured column, and under\nit the title with the problem, what was built and the measured result on a\ntwelve-column grid. Below the `lg` container everything stacks.\n\n import { CaseStudy } from \"@sdxc/ui/landing\";\n\n <CaseStudy\n index=\"01 / 03\"\n client=\"Harbour Line\"\n meta=\"River ferries · 2025\"\n title=\"A ferry that tells you the tram will wait\"\n scene={<DeparturesBoard />}\n sceneLabel=\"The departures board on pier 3 at 08:14\"\n plate=\"#0d1b2e\"\n problem=\"Riders missed one connection in five.\"\n built=\"One timetable service behind every screen.\"\n result={{ value: \"−31%\", label: \"missed connections, first winter\" }}\n />\n\nThe scene fills the plate, so an SVG with\n`preserveAspectRatio=\"xMidYMid slice\"` keeps its centre on a phone. `plate`\nsets the fill (the tinted neutral by default), `labels` translates the three\ncolumn labels, and `--ui-landing-case-figure-size` resizes the result figure.\nThe band takes every `LandingSection` prop, such as `spacing` and `tone`."}
|
|
2057
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add ScrollScene and sceneMotion for scroll-linked landing scenes","body":"`@sdxc/ui/landing` now exports `ScrollScene`, a tall runway whose stage\nsticks under the landing header while the reader scrolls through it, and\n`sceneMotion()`, which runs any part of the stage through keyframes along\nthe scene's named view timeline.\n\n import { ScrollScene, sceneMotion } from \"@sdxc/ui/landing\";\n\n <ScrollScene timeline=\"explode\" length={2.5}>\n \t<div\n \t\tmix={[\n \t\t\traw({ translate: \"0 0 4rem\" }),\n \t\t\tsceneMotion(\"explode\", { from: { translate: \"0 0 0\" } }, \"contain 5% contain 70%\"),\n \t\t]}\n \t/>\n </ScrollScene>\n\n`length` is in viewport heights below the header (default 2.5). A part's\nown styles are the static frame: under `prefers-reduced-motion: reduce`, or\nin a browser without `animation-timeline: view()`, the stage sits in normal\nflow and nothing animates, so make the last keyframe match those styles.\n`sceneMotion()` takes an optional easing, such as `steps(7, end)` for\ntext that types itself.\n\nA scene inside a fixed-height scroll panel sets\n`--ui-scroll-scene-viewport` to the panel's height (and\n`--ui-landing-header-height` to `0px`), so the stage pins inside the panel."}
|
|
2058
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"chore","breaking":false,"title":"Sort the CaseStudy export in the landing barrel","body":"The `CaseStudy` export in `@sdxc/ui/landing` moves into alphabetical order\nbeside the others. Nothing changes for consumers."}
|
|
2059
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add Diff, a server-rendered unified and split diff viewer","body":"`Diff` in `@sdxc/ui/app` draws a change from the hunks `@sdxc/diff` parses or\ncomputes, entirely on the server:\n\n- `Diff.File` is one file's card: a native `<details>` whose summary shows the\n collapse chevron, the A/M/D/R status, the path (old → new for a rename), the\n counts and a five-block bar, with a copy-path button, a `menu` slot and a\n `viewedControl` slot beside it. `viewed` and `collapsed` render it closed.\n- Hunks draw unified (two number columns, sign, code) or split (old and new in\n one four-column table). Below a 48rem container, split lays the same markup\n out as unified, so a phone needs no second render.\n- Changed words from `words` become `<mark>`s, each side of a hunk highlights\n as one source through `@sdxc/highlight`, and hunk headers carry an optional\n `expandHref` link.\n- `threads` places a node as a full-width row after the line keyed `R12` or\n `L12`. `commentHref` gives every line a `+` link to the app's comment form.\n- A file past `largeThreshold` (400 changed lines) with a `load` slot renders\n closed with that slot in place of its rows; `binary` and `tooLarge` say why\n a file has no lines.\n- `Diff.Toolbar` holds the unified/split switch as GET links and \"n / N files\n viewed\" with its bar. `Diff.Hunks` draws hunks without a card.\n\nRows sit in `<tbody>` chunks under `content-visibility: auto`, line numbers are\npainted from attributes, and the whole page hydrates one island,\n`@sdxc/ui/app/diff#DiffInteractions`. With it mapped in the browser entry, a\npress on a `+` or a drag across numbers dispatches a bubbling\n`ui:diff-comment` event (`DIFF_COMMENT_EVENT`) carrying `path`, `side`,\n`start` and `end`, and the copy button copies the path.\n\n import { Diff, DIFF_COMMENT_EVENT } from \"@sdxc/ui/app\";\n import { parseHunks, parsePatch } from \"@sdxc/diff\";\n\n <Diff labels={{ copied: t(\"copied\") }}>\n <Diff.Toolbar view={view} unifiedHref=\"?diff=unified\" splitHref=\"?diff=split\"\n viewed={viewed} total={files.length} labels={toolbarLabels} />\n {parsePatch(patch).map((file) => (\n <Diff.File path={file.newPath} oldPath={file.oldPath} status={file.status}\n additions={file.additions} deletions={file.deletions} binary={file.binary}\n hunks={parseHunks(patch, file)} language=\"ts\" view={view}\n commentHref={(path, side, line) => `?comment=${path}:${side}${line}`}\n labels={fileLabels} />\n ))}\n </Diff>\n\n`CodeView` now reads its token colours from the same rule set; its output is\nunchanged and consumers need not act."}
|
|
2060
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add ReviewThread, a resolvable conversation anchored to lines","body":"`ReviewThread` in `@sdxc/ui/app` renders a review conversation that works\nwithout script:\n\n- Comments draw as `Timeline.Comment` cards; one marked `pending` carries a\n \"Pending\" badge until its review is sent.\n- `replyAction` adds a reply box and `resolveAction` a Resolve / Unresolve\n button, each a plain POST form (the reply posts `body`, the button posts\n `resolved=true|false`). `frame` sets `data-rmx-target` on every form so a\n post reloads only the thread's own named frame; `fields` adds hidden inputs\n such as a CSRF token.\n- `resolved` folds the thread into a closed `<details>` behind\n `resolvedSummary` (\"ana marked this conversation as resolved\"); `outdated`\n folds it behind an \"Outdated\" badge and the excerpt's path.\n- `excerpt` draws the cited lines above the comments, for the timeline and for\n an outdated thread; `suggestion` draws a suggested change as a small diff\n with an \"Apply suggestion\" form when it has an `applyAction`.\n\n import { ReviewThread } from \"@sdxc/ui/app\";\n\n <Frame name={`thread-${id}`} src={`/threads/${id}`}>\n <ReviewThread id={`thread-${id}`} frame={`thread-${id}`} comments={comments}\n replyAction={`/threads/${id}/replies`} resolveAction={`/threads/${id}/resolve`}\n suggestion={{ path, hunks: diffLines(before, after).hunks, applyAction: `/threads/${id}/apply` }}\n labels={labels} />\n </Frame>\n\nInside a diff, pass the thread to `Diff.File`'s `threads` under its line key\n(`R12`); its excerpt and suggestion tables carry no line anchors, so they never\ncollide with the file's own."}
|
|
2061
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add @sdxc/ui/video, a video player with custom controls and settings","body":"`@sdxc/ui/video` is a new namespace holding `VideoPlayer`, a compound player\nbuilt on the native `<video>`. Chapters and a transcript are written once as\ndata; they become the video's WebVTT tracks, the chapter scrubber, the chapter\nlist and the timed transcript, and every time is a `#t=` link into the first\nsource, so seeking works without script.\n\n`VideoPlayer.Controls` adds a YouTube-style bar: `Progress`, `Play`, `Time`,\n`CaptionsToggle`, `Settings`, `Theater` and `Fullscreen`. The server renders\nthe native controls with the bar `hidden`; the `VideoPlayerSync` island swaps\nthem. The settings gear opens a Popover API menu with the built-in\n`CaptionsMenu`, `SpeedMenu` and `QualityMenu`, plus the page's own rows:\n`SettingsToggle` is a real checkbox and `SettingsMenu` a radio group of\n`SettingsOption`s, read by `name` from ordinary `change` events.\n\n import { VideoPlayer } from \"@sdxc/ui/video\";\n\n <VideoPlayer duration={703} chapters={chapters} transcript={lines}>\n <VideoPlayer.Screen label=\"Centering 3 kg\">\n <VideoPlayer.Source src=\"/07-1080.mp4\" type=\"video/mp4\" label=\"1080p\" badge=\"HD\" />\n <VideoPlayer.Source src=\"/07-2160.mp4\" type=\"video/mp4\" label=\"2160p\" badge=\"4K\" />\n <VideoPlayer.Controls>\n <VideoPlayer.Progress />\n <VideoPlayer.Play />\n <VideoPlayer.Time />\n <VideoPlayer.CaptionsToggle />\n <VideoPlayer.Settings>\n <VideoPlayer.SettingsToggle name=\"ambient\" label=\"Ambient mode\" />\n <VideoPlayer.CaptionsMenu />\n <VideoPlayer.SpeedMenu />\n <VideoPlayer.QualityMenu />\n </VideoPlayer.Settings>\n <VideoPlayer.Theater />\n <VideoPlayer.Fullscreen />\n </VideoPlayer.Controls>\n </VideoPlayer.Screen>\n <VideoPlayer.Side>\n <VideoPlayer.Chapters />\n <VideoPlayer.Transcript />\n </VideoPlayer.Side>\n </VideoPlayer>\n\nAn app that hydrates islands must map the specifier\n`@sdxc/ui/video/video-player` in its browser entry.\n\nThe `@sdxc/ui/mixins` entry also exports `installMenuKeys(host, signal,\noptions)`, the logic behind `menuKeys()`, for script that runs the menu\nkeyboard on server-rendered markup. `menuKeys()` behaves as before."}
|
|
2062
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Export Diff and ReviewThread from @sdxc/ui/app","body":"Diff, its DiffInteractions island, DIFF_COMMENT_EVENT, the hunkHeader, splitRows and changeBlocks helpers, and ReviewThread are now importable from the @sdxc/ui/app barrel as well as their own subpaths:"}
|
|
2063
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":true,"title":"Take every VideoPlayer label from the page and fit its bar on a phone","body":"`@sdxc/ui/video` follows the package's rule that it ships no copy: every\nvisible and accessible string a `VideoPlayer` part draws is now a required\nprop, so a page passes its own locale's words. The bar also fits a 375px\nscreen: `VideoPlayer.Theater` shows only from the `lg` container width,\nwhere the side column sits beside the screen, and the settings menu opens\nbelow or across the viewport when it fits beside the gear on neither side.\n\nMigration: pass each label the parts now require.\n\nBefore:\n\n <VideoPlayer.Screen label=\"Lesson 7\">…</VideoPlayer.Screen>\n <VideoPlayer.Controls>\n <VideoPlayer.Progress />\n <VideoPlayer.Play />\n <VideoPlayer.CaptionsToggle />\n <VideoPlayer.Settings>\n <VideoPlayer.CaptionsMenu />\n <VideoPlayer.SettingsMenu name=\"sleep\" label=\"Sleep timer\">…</VideoPlayer.SettingsMenu>\n <VideoPlayer.SpeedMenu />\n <VideoPlayer.QualityMenu />\n </VideoPlayer.Settings>\n <VideoPlayer.Theater />\n <VideoPlayer.Fullscreen />\n </VideoPlayer.Controls>\n <VideoPlayer.Chapters />\n <VideoPlayer.Transcript />\n\nAfter:\n\n <VideoPlayer.Screen label=\"Lesson 7\" captionsLabel=\"English\" chaptersLabel=\"Chapters\">…</VideoPlayer.Screen>\n <VideoPlayer.Controls label=\"Video controls\">\n <VideoPlayer.Progress label=\"Seek\" />\n <VideoPlayer.Play label=\"Play\" pauseLabel=\"Pause\" />\n <VideoPlayer.CaptionsToggle label=\"Subtitles/closed captions\" />\n <VideoPlayer.Settings label=\"Settings\">\n <VideoPlayer.CaptionsMenu label=\"Subtitles/CC\" offLabel=\"Off\" backLabel=\"Back\" />\n <VideoPlayer.SettingsMenu name=\"sleep\" label=\"Sleep timer\" backLabel=\"Back\">…</VideoPlayer.SettingsMenu>\n <VideoPlayer.SpeedMenu label=\"Playback speed\" normalLabel=\"Normal\" backLabel=\"Back\" />\n <VideoPlayer.QualityMenu label=\"Quality\" backLabel=\"Back\" />\n </VideoPlayer.Settings>\n <VideoPlayer.Theater label=\"Theater mode\" />\n <VideoPlayer.Fullscreen label=\"Full screen\" />\n </VideoPlayer.Controls>\n <VideoPlayer.Chapters label=\"Chapters\" />\n <VideoPlayer.Transcript label=\"Transcript\" />\n\nThe bar's inks and the menu's surface also read\n`--ui-video-player-on-video`, `--ui-video-player-on-video-muted`,\n`--ui-video-player-on-video-wash` and `--ui-video-player-menu-bg`, and the\nswitch's motion runs only without `prefers-reduced-motion: reduce`."}
|
|
2064
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":true,"title":"Take EpisodePlayer's labels from the page","body":"`EpisodePlayer` no longer ships English copy. `chaptersLabel`,\n`transcriptLabel` and `fallback` are now required, so a localized page\nalways names its own chapter list, transcript disclosure and no-audio\nfallback. The seeking behaviour moved into its own mixin module; the island\nspecifier `@sdxc/ui/landing/episode-player` and the markup are unchanged,\nso browser entries need no change.\n\nMigration: pass the three labels where you render the player.\n\nBefore:\n\n <EpisodePlayer src=\"/audio/63.mp3\" captions={captions} title=\"No. 63\" chapters={chapters} />\n\nAfter:"}
|
|
2065
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add mediaSync, time links and playing marks for any audio or video player","body":"`@sdxc/ui/mixins` now exports `mediaSync(options)`, the behaviour a media\nplayer's island needs to make its time links seek in place: a plain click\non an `a[data-start]` sets the media's time and plays, a modified click\nstill opens the file, and as it plays the last started item of each\nplaying-order list carries `aria-current=\"true\"`. Lists name their items'\nstarts in `data-start` or `data-cue`.\n\n <span hidden mix={[mediaSync({\n root: '[data-slot=\"episode\"]',\n marks: ['[data-slot=\"chapters\"] a', \"[data-cue]\"],\n })]} />\n\n`installMediaSync(root, media, signal, options)` runs the same on markup a\nscript already holds, with an `onTime(time, changed)` callback after each\nupdate, and `markPlaying(items, time)` marks one list. `VideoPlayer` from\n`@sdxc/ui/video` now runs on it; its behaviour is unchanged."}
|
|
2066
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":true,"title":"Give UsageEstimate a live mode that re-prices while the reader types","body":"`UsageEstimate` from `@sdxc/ui/landing` can now re-price its bill as the\nreader types or drags, without a page load. The bill is its own part,\n`UsageEstimate.Bill`, and the calculator takes either a printed `bill` or a\n`live` frame that loads one.\n\nLive mode renders the bill as a blocking `<Frame>`, so the server still inlines\nit. An island in the form debounces input and change events, reloads only that\nframe with the form's query, and moves the address there with `replaceState`,\nso the estimate stays shareable and history gains no entry. Focus and a slider\ndrag are never interrupted, because the fields sit outside the frame. Without\nscript the form is still a plain GET form.\n\n <UsageEstimate\n action=\"#pricing\"\n fields={<input type=\"number\" name=\"hours\" defaultValue=\"40\" />}\n submitLabel=\"Estimate\"\n live={{ frame: \"pricing-bill\", src: \"/?hours=40\", delay: 250 }}\n />\n\nThe page's route answers a request carrying `X-Remix-Target: pricing-bill` with\nthe bill alone, and sends `Vary: X-Remix-Target`:\n\n <UsageEstimate.Bill label=\"Estimated monthly bill\" rows={rows} total={total} footnote={…} cta={…} />\n\nMap the island in the browser entry's `loadModule`:\n`\"@sdxc/ui/landing/usage-estimate\": () => import(\"@sdxc/ui/landing/usage-estimate\")`.\n\nMigration (breaking): the bill's props moved from `UsageEstimate` onto\n`UsageEstimate.Bill`, and `billLabel` is now `label`."}
|
|
2067
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"refactor","breaking":false,"title":"Run EpisodePlayer's seeking through the shared mediaSync","body":"`EpisodePlayer`'s island now uses `mediaSync` from `@sdxc/ui/mixins`, the\nsame time-link and playing-mark sync the video player uses, in place of a\ncopy of its own. Behaviour, markup and the island specifier\n`@sdxc/ui/landing/episode-player` are unchanged, so consumers need no\nchange."}
|
|
2068
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Let the newest request win in UsageEstimate's live mode","body":"Before: in `UsageEstimate`'s live mode, a slow answer for an older query could\nmove the address back to that query after a newer bill had landed, and a\nsubmit overtaken by a newer one could fall back to a full page load when its\ncancelled reload rejected.\n\nAfter: requests are counted, and only the newest one moves the address or\nfalls back to a native submit. Older answers settle quietly, and the frame\nruntime already discards their content. No consumer action needed."}
|
|
2069
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Name backers under their circles and align a SponsorWall to the start edge","body":"`SponsorWall.Person` takes `showName` to set the backer's name under the circle, in two\ncentred lines at most, so every named person keeps the same 6rem width:\n\n <SponsorWall.Person href={sponsor.url} name={sponsor.name} src={sponsor.avatarUrl} size=\"lg\" showName />\n\nThe circle stays the one link that takes focus and is named for assistive technology; the\ncaption links to the same profile for a pointer.\n\n`SponsorWall` takes `align=\"start\"` to set the backer cloud and the closing actions on the\nstart edge, for a wall under a title set flush with the column:\n\n <SponsorWall align=\"start\" actions={<LinkButton href={profile}>Sponsor</LinkButton>}>…</SponsorWall>\n\nBoth are optional. A wall without them renders exactly as before, so no change is needed."}
|
|
2070
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"docs","breaking":false,"title":"Document the baseline, island and custom properties of today's components","body":"The reference documentation of CheckRuns, MergeBox, ContributionGraph, FilterMenu, CodeView, LogViewer, Diff, ReviewThread, Tree, Timeline, PageHeader, CommandPalette, PropertyList, LabelChip, ContributorWall, Countdown, PriceList, CaseStudy, ScrollScene and TypedTerminal now says what each renders without script, which island to map in the browser entry for the enhanced behaviour, and which custom properties a page sets to restyle it. Props, labels and parts that had no description now have one, and new examples show Tree's file navigation, Timeline's comment cards and commit groups, PageHeader's More menu, CommandPalette's file finder and TypedTerminal's code card.\n\nThis changes comments only; consumers are not affected."}
|
|
2071
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Let a named submit button load the page in UsageEstimate's live mode","body":"Before: in `UsageEstimate`'s live mode every submit was caught and only\nre-priced the bill. A button carrying its own `name` and `value`, such as \"Add\nmonitor\" (`add=1`), never reached the server, so the fields it should have\nadded never appeared, and the address kept `add=1`.\n\nAfter: Enter, `requestSubmit()` and an unnamed submit button still re-price in\nplace. A submit from a named button loads the page natively, so the server can\nrender the new set of fields. No consumer action needed; give such buttons a\n`name` and `value`, as a no-script form already requires."}
|
|
2072
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"docs","breaking":false,"title":"Document EpisodePlayer, UsageEstimate, VideoPlayer and SponsorWall's names","body":"The reference documentation of EpisodePlayer, UsageEstimate and UsageEstimate.Bill, VideoPlayer, mediaSync and SponsorWall now says what each renders without script, which island to map in the browser entry (EpisodeSync, UsageEstimateLive, VideoPlayerSync), and which custom properties a page sets. New examples show a static UsageEstimate with its Bill, an episode with chapters and a transcript, a theater VideoPlayer, and SponsorWall.Person with showName. The README lists ContributorWall, Countdown, PriceList, CaseStudy, ScrollScene, EpisodePlayer, UsageEstimate, LabelChip, CheckRuns, MergeBox, ContributionGraph, FilterMenu, CodeView, Diff, ReviewThread, LogViewer, codeLines and fileIcon, and the new parts of Tree, PageHeader, CommandPalette and TypedTerminal.\n\nThis changes documentation only; consumers are not affected."}
|
|
2073
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Pad the unified and split switch in a diff's toolbar","body":"`Diff.Toolbar`'s Unified / Split segments used to render with no padding, so the\nraised tile of the chosen view hugged its label and the switch read as two bare words.\nEach segment is now a 28px-tall, padded tile like the other segmented controls in the\nkit. No action is needed from consumers."}
|
|
2074
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Open a failed job's log on its first error line","body":"`LogViewer` used to open a failed job with its failed step expanded but the log\nscrolled to the top, so the reader still had to hunt for the error. Once its script\nruns, a finished job's log now scrolls its first `##[error]` line (in an open failed\nstep) to the middle of the log box, and scrolls the page too when that line is off\nscreen. An address with a fragment, such as a line link `#step:3:42`, keeps that line\ninstead, and a running job still follows its tail. No action is needed."}
|
|
2075
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Say when a tree's filter matches no file with Tree.NoMatches","body":"A `Tree` narrowed by `Tree.Filter` used to go blank when the query matched nothing.\nPut a `Tree.NoMatches` inside the tree and it shows (and is announced) while the\nquery leaves no file, then hides again as soon as a file matches or the field clears:\n\n <Tree id=\"files\" aria-label=\"Files\">\n <Tree.Leaf href=\"/blob/app.ts\" name=\"app.ts\" />\n <Tree.NoMatches>No file matches</Tree.NoMatches>\n </Tree>\n\nTrees without it behave as before."}
|
|
2076
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Cover both gutters with a sticky PageHeader's background","body":"A sticky `PageHeader` reaches into `--ui-app-gutter` on both sides, but under a\nborder-box reset (such as `@sdxc/ui/reset.css`) its width stayed at the content box,\nso its background stopped one gutter short of the right edge and content scrolling\nunder it showed through that strip. The header now sizes itself to the content width\nplus both gutters, whatever the page's `box-sizing`. No action is needed."}
|
|
2077
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Leave an unlabelled VideoPlayer source off the quality menu","body":"`VideoPlayer.QualityMenu` listed every `VideoPlayer.Source`, so a format\nfallback such as an MP4 after a WebM showed up as a second quality named\nafter its file. It now lists only sources with a `label`; a source with no\nlabel stays a plain `<source>` the browser falls back to.\n\n <VideoPlayer.Source src=\"/clip.webm\" type=\"video/webm\" label=\"1080p\" badge=\"HD\" />\n <VideoPlayer.Source src=\"/clip.mp4\" type=\"video/mp4\" />\n\nNo action needed unless a page relied on unlabelled sources appearing in\nthe menu; give those a `label` to keep them listed."}
|
|
2078
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep blame's code lines even and draw code without ligatures","body":"`CodeView` with `blame` used to stretch the code rows beside every hunk of one or\ntwo lines, because the hunk's subject and author needed more height than its\nlines had, so a file read with uneven gaps between lines. Hunk text now sits on\nthe code's own line height, and a one-line hunk sets its subject and age on that\none line. Every line keeps the same height whatever the hunks are.\n\n`CodeView`, `Diff` and `LogViewer` also turn ligatures off. A monospace font with\nligatures (JetBrains Mono, Cascadia Code, Fira Code) used to draw `===`, `!==` and\n`=>` as single glyphs; code now reads exactly as typed in any font a theme picks.\n\nNothing to change in consuming code."}
|
|
2079
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep a split LandingHeader's eyebrow on its title","body":"A `LandingHeader` with `layout=\"split\"` put its eyebrow in a grid row of its\nown, so when the lead beside the title ran taller than the title, the title\nsank to the lead's last line and left the eyebrow floating up to 90px above it.\n\nBefore: on a wide header with a four-line lead, the eyebrow sat at the top of\nthe band and the title at the bottom, with an empty gap between them.\n\nAfter: the lead spans both rows and the first row takes the extra height, so\nthe eyebrow always rests 0.5rem above the title, and the lead still ends on the\ntitle's last line. On narrow headers the split still stacks, eyebrow at the start.\n\nNo action needed; split headers pick this up on upgrade."}
|
|
2080
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Show AutoRefresh's last update in the reader's time zone","body":"`AutoRefresh` writes \"Updated <time>\" on the server, which knows no reader's time\nzone, so a page rendered on a Worker said \"Updated 12:44:01 PM\" in UTC to a reader\nat 7:44 in the morning until the first reload rewrote it. The time now switches to\nthe reader's own zone as soon as the page hydrates; without script it keeps the\nserver's text.\n\nA `timeZone` passed to `AutoRefresh` still wins, on the server and in the browser.\nThe `autoRefresh` mixin takes the same `timeZone` option. Nothing to change in\nconsuming code."}
|
|
2081
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Set a PageHeader's More tab in the tabs' own size","body":"On a narrow `PageHeader`, the \"More ▾\" button that folds the extra tabs used to\nrender at the page's body size (16px) beside 14px tabs, so it read as a different\ncontrol. It now takes the tabs' size and line height. Nothing to change in\nconsuming code."}
|
|
2082
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Give the code more room beside blame on a phone","body":"Below its wrap width, `CodeView` with `blame` used to spend about 120px of a\n375px screen on the blame column and the line numbers, so a line of code wrapped\nevery two or three words. The blame column now narrows to the age it shows and\nthe line numbers keep only the padding they need, giving the code about a third\nmore width. Nothing to change in consuming code."}
|
|
2083
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Quote unchanged lines in Diff.Hunks with one number column","body":"`Diff.Hunks` given only unchanged lines, as when an issue or a review quotes a\nrange of a file, drew each line number twice, in an old and a new column holding\nthe same value. When every line is unchanged at the same number on both sides,\nthe unified view now draws a single number column, as a code citation reads on\nGitHub. Hunks with any change, any shifted line or any thread render as before.\nNothing to change in consuming code."}
|
|
2084
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Make CodeView's and Diff's line links one Tab stop","body":"Every line number in a `CodeView`, and every number and `+` comment link in a\n`Diff`, used to be its own Tab stop, so getting past a 500-line file or a pull\nrequest's diffs by keyboard took thousands of presses. Each code table is now one\nTab stop, on the selected line or the first line link. From there:\n\n- ArrowUp and ArrowDown move a line (in `Diff`, along the same column: a side's\n numbers or the comment links); Home and End go to the first and last line.\n- In `CodeView`, PageUp and PageDown move twenty lines.\n- In `Diff`, ArrowLeft and ArrowRight move across the row's links.\n- Enter still follows the focused link, so Enter and Shift+Enter keep citing a line\n or a range.\n\nLine links that aren't the table's stop render `tabindex=\"-1\"`. A test that matches\nthose links' exact markup needs the new attribute. Without script, Tab reaches the\nfirst line link of each table and every line stays linkable by its address."}
|
|
2085
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Reach a Diff file's header actions before its lines","body":"A `Diff.File`'s header buttons (copy path, the file menu, Viewed) came after the\nwhole diff in Tab order, though they sit on the header's row, so a keyboard user\nmet them only after the file's lines. Tab now reaches them right before the\nheader's collapse toggle, ahead of the file's lines, and they still sit on the\nheader's row above the collapsible body. Nothing to change in consuming code.","correctedIn":"2026.11.14"}
|
|
2086
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Ring a Tree folder row on keyboard focus","body":"A `Tree.Item` folder row showed keyboard focus only as its hover tint, while a\n`Tree.Leaf` file row drew the brand focus ring, so Tab and the arrow keys lost\ntheir place on folders. Folder rows now draw the same 2px ring on\n`:focus-visible`. Nothing to change in consuming code."}
|
|
2087
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Draw TextArea's focus ring on keyboard focus","body":"`TextArea` declared a focus-visible ring but also cleared the outline on every\nfocus, and the clearing rule won, so a text area reached by Tab showed only a\nslightly stronger border. Only pointer focus drops the outline now; keyboard focus\ndraws the ring of the field's colour role, as `Input` does. Nothing to change in\nconsuming code."}
|
|
2088
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Place Tree.NoMatches beside its tree with a tree prop","body":"`Tree.NoMatches` inside a `Tree` puts a `role=\"status\"` line among the tree's\nitems, which a tree's ARIA children may not include, so accessibility checkers\nflag it. It can now sit beside the tree, naming the tree it answers for, and the\nfilter shows and hides it the same way:\n\n <Tree id=\"files\" aria-label=\"Files\">…</Tree>\n <Tree.NoMatches tree=\"files\">No file matches</Tree.NoMatches>\n\nA `Tree.NoMatches` inside its tree keeps working; move it out and add `tree` to\npass an ARIA audit."}
|
|
2089
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Turn disclosure chevrons without motion under reduced motion","body":"The chevrons of `Diff.File`, `ReviewThread`, `LogViewer` steps and `CheckRuns`\nrotated over 150ms even when the reader asked for reduced motion. They now turn\nat once under `prefers-reduced-motion: reduce` and keep the short rotation\notherwise. Nothing to change in consuming code."}
|
|
2090
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Reach every Diff comment link by keyboard without script","body":"Making a `Diff` table one Tab stop left a keyboard user without script able to\nreach only its first line number, so the `+` links to the comment form on every\nother line were out of reach. The server now leaves each comment link in the Tab\norder, a real link to `commentHref`. Once the script runs it takes them back out,\nincluding rows that arrive later such as a file loaded behind \"Load diff\", so each\ntable is again one Tab stop the arrow keys walk.\n\nA test that matched comment links' exact markup no longer sees a `tabindex` on\nthem. Nothing else changes for consuming code."}
|
|
2091
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"docs","breaking":false,"title":"Show writeCookie's path option with a plain path","body":"`writeCookie`'s JSDoc example scoped a cookie to a path that read like a folder\nof this repository; it now uses a plain `/crm` path. No consumer effect."}
|
|
2092
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Show a sponsor's initials when their picture fails to load","body":"`SponsorWall.Person` with a `src` drew an empty circle, or the browser's broken-image icon, whenever the picture failed to load: a blocked host, a removed account or a network error left a blank, unnamed spot in the wall.\n\nNow the circle always renders the name's initials under the picture. They show while the picture loads and stay when it fails, painted over the broken-image icon, so every backer reads as someone. A picture that loads covers them exactly as before.\n\nNo action is needed: existing `<SponsorWall.Person href name src />` calls get the fallback as they are."}
|
|
2093
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep a sticky PageHeader's narrow layout in browsers without scroll-state queries","body":"A sticky `PageHeader` declared its container as `inline-size scroll-state`. Browsers that don't know scroll-state containers, such as Safari, dropped that declaration whole, so none of the header's width queries applied: on a phone the breadcrumb trail showed beside the parent link, and the parent link's chevron sat on its own line above its label.\n\nThe header is now always an inline-size container, and only browsers that support scroll-state containers add that type. Every browser picks the trail or the parent link by width again, and the header still compacts once stuck where scroll-state queries exist. Consumers need not change anything."}
|
|
2094
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"style","breaking":false,"title":"Format PageHeader's scroll-state container rule","body":"Formatting only; no change for consumers."}
|
|
2095
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep a PageHeader parent link's chevron on its label's row","body":"A `PageHeader`'s parent link, shown on a narrow pane in place of the breadcrumb trail, laid its chevron and label out in a row only inside the narrow-width query. Wherever that query didn't apply, the chevron fell onto a line of its own above the label. The link is now always a centered row of chevron and label, and the wide-width query only hides it. Consumers need not change anything."}
|
|
2096
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Close a diff file when a redraw marks it viewed","body":"With `diffInteractions` on a page of diffs, a `Diff.File` now closes as soon as a redraw gives it the viewed mark (`data-viewed`), and opens again when the mark is lifted. Before, the file's diff stayed open after Viewed was checked, because a frame redraw keeps every `<details>` as the reader left it, so the server's closed file only showed after a full reload. Consumers need not change anything."}
|
|
2097
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Give a PageHeader's title row more room above its description","body":"A `PageHeader` now leaves 0.75rem between the title row and the description at every width, up from 0.5rem. A status pill beside the title no longer crowds a description holding chips of its own, such as a pull request's branches. Consumers need not change anything; headers with a description grow by 4px."}
|
|
2098
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep @sdxc/u in declaration emit for mixin returns","body":"Before, `streamTarget`, `screenCorners`, `sceneMotion` and\n`pausedWhenChecked` left their return type inferred, so `tsc` wrote\n`import(\"packages/u/src…\").UtilityMixin` into the published `.d.ts` and\nthe daily release failed on `streamTarget` (the others shipped the same\nbroken form under a looser check). Each now annotates `UtilityMixin`\nfrom `@sdxc/u`, so the declarations name the published package.\nConsumers of the typed return value get a resolvable import; no\ncall-site change is required."}
|
|
2099
|
+
{"release":"2026.11.14","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep VideoPlayer time links from leaving the page","body":"Before, `VideoPlayerSync` mounted above the screen's `<video>`, so its\ninsert handler often found no media and left `#t=` chapter links to\nnavigate. The island now sits after the layout (as `EpisodeSync` does\nafter `<audio>`), and the browser tests fire time-link clicks without\nfollowing `href`, which was tearing down Vitest Browser Mode's iframe.\nConsumers need not change call sites; existing `<VideoPlayer>` trees\npick up the seek handler."}
|
package/dist/pkg/catalog.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdxc/kit",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.14",
|
|
4
4
|
"description": "The sdxc command line: start a Remix v3 app, generate its files, copy UI components into it and upgrade it",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"remix": "3.2.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "5d069a9e855202a3a5e79141319e4e2d2ce7c084",
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
package/registry/ui/button.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "button",
|
|
3
|
-
"changedIn": "2026.11.
|
|
3
|
+
"changedIn": "2026.11.14",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"cta-group"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
11
|
"path": "button.tsx",
|
|
12
|
-
"content": "/**\n * An interactive control for a single, immediate action — submitting a form,\n * triggering a command, opening a dialog. Its host renders as a native\n * `<button>` shaped by a semantic color role, a visual weight variant, and a\n * size, and holds its footprint while rendering a busy pending state.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { LoaderCircleIcon } from \"@sdxc/icons\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, visibility } from \"@sdxc/u/effects\";\nimport { cursor, raw, userSelect, mergeMix } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tgap,\n\tinlineFlex,\n\tinset,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n} from \"@sdxc/u/layout\";\nimport { bs, is, minBs, p, pb, pi, pie, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { text } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { hitArea } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { surfaceControl } from \"@sdxc/ui/styles\";\nimport { glyphEdges } from \"@sdxc/ui/utils\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { CtaGroup } from \"@sdxc/ui/cta-group\";\n\nconst DEFAULT_COLOR: Button.Color = \"neutral\";\n\nconst DEFAULT_VARIANT: Button.Variant = \"solid\";\n\nconst DEFAULT_SIZE: Button.Size = \"md\";\n\n/** Edge of a small icon-only button, matching the `sm` row height. */\nconst ICON_ONLY_SIZE_SM = \"var(--ui-button-icon-size-sm, 2rem)\";\n\n/** Edge of a medium icon-only button, matching the `md` row height. */\nconst ICON_ONLY_SIZE_MD = \"var(--ui-button-icon-size-md, 2.5rem)\";\n\n/** Edge of a large icon-only button, matching the `lg` row height. */\nconst ICON_ONLY_SIZE_LG = \"var(--ui-button-icon-size-lg, 3rem)\";\n\n/**\n * Native `type` given to a button carrying `command`/`commandfor` and no\n * `type` of its own: the platform treats a button that could also submit as an\n * ambiguous invoker and skips its command, so an invoker needs this type.\n */\nconst INVOKER_TYPE = \"button\";\n\n/**\n * Prop types for {@link Button}.\n */\nexport namespace Button {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Visual weight the button renders with: a solid fill with an on-solid\n\t * foreground, a transparent fill with a strong colored border, a fully\n\t * transparent fill with just a colored label, or a raised `surface` fill with\n\t * the emphasis ink and a tactile edge — a secondary that reads as a control\n\t * beside a solid primary, and turns translucent inside inverse and brand bands.\n\t */\n\texport type Variant = \"solid\" | \"outline\" | \"ghost\" | \"surface\";\n\n\t/**\n\t * Size variant controlling the button's padding and font size.\n\t * Inside a {@link CtaGroup} an omitted size takes the group's, so a hero row\n\t * sizes every action at once; `\"md\"` is the 40px landing CTA.\n\t */\n\texport type Size = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Per-part styling for the elements a pending button renders besides its\n\t * own host.\n\t */\n\texport interface PartsProps {\n\t\t/** Styling for the decorative rotating glyph shown while pending. */\n\t\tspinner?: TagProps<\"span\">[\"mix\"];\n\t\t/**\n\t\t * Styling for the wrapper holding the button's own children while\n\t\t * pending; kept in the layout to preserve the button's footprint, but\n\t\t * hidden from view and from assistive technology.\n\t\t */\n\t\tcontent?: TagProps<\"span\">[\"mix\"];\n\t}\n\n\t/**\n\t * Props accepted by {@link Button}.\n\t */\n\texport interface Props extends TagProps<\"button\"> {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Size variant. Defaults to {@link DEFAULT_SIZE}. */\n\t\tsize?: Size;\n\t\t/**\n\t\t * Marks the button busy: merges into the native `disabled` attribute and\n\t\t * swaps the visible content for a spinner glyph while holding the rendered\n\t\t * footprint, so a page mid-request keeps its layout.\n\t\t */\n\t\tisPending?: boolean;\n\t\t/** Per-part styling for the pending state's internal elements. */\n\t\tparts?: PartsProps;\n\t}\n}\n\n/**\n * Reports whether `children` is a lone glyph, which is what makes a button a target for\n * that glyph rather than for a label. A selector cannot answer this: `:only-child`\n * counts elements, so a button holding text beside one icon still matches it.\n *\n * @param children The button's own children.\n * @returns Whether the button renders a single element and no text of its own.\n */\nfunction holdsOnlyAGlyph(children: RemixNode): boolean {\n\treturn typeof children === \"object\" && children !== null && !Array.isArray(children);\n}\n\n/**\n * Visual state lives in `data-color`/`data-variant`/`data-size` on the host, so\n * hover, pressed, and focus-visible stay on native pseudo-classes. `type` precedes\n * the spread so the platform sees it while parsing `command`/`commandfor`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the button's markup.\n * @example\n * <Button type=\"submit\">{t(\"actions.save\")}</Button>\n * @example\n * <Button color=\"danger\" variant=\"outline\" size=\"sm\">{t(\"actions.delete\")}</Button>\n * @example\n * <Button type=\"submit\" isPending={isSubmitting}>{t(\"actions.save\")}</Button>\n * @example\n * <Button size=\"lg\" color=\"brand\" mix={[landingCtaChrome()]}>{t(\"hero.cta\")}</Button>\n */\nexport function Button(handle: Handle<Button.Props>) {\n\treturn () => {\n\t\tlet { color, variant, size, isPending, disabled, type, parts, children, mix, ...rest } =\n\t\t\thandle.props;\n\t\tlet isInvoker = rest.command !== undefined || rest.commandfor !== undefined;\n\t\tlet resolvedType = type ?? (isInvoker ? INVOKER_TYPE : undefined);\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet group = handle.context.get(CtaGroup) as CtaGroup.Context | undefined;\n\t\tlet resolvedSize = size ?? group?.size ?? DEFAULT_SIZE;\n\t\tlet resolvedDisabled = disabled || isPending;\n\t\tlet iconOnly = holdsOnlyAGlyph(children);\n\t\tlet edges = glyphEdges(children);\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Button: an icon-only button needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-pending={isPending || undefined}\n\t\t\t\tdata-icon-only={iconOnly || undefined}\n\t\t\t\tdata-glyph-start={edges.start || undefined}\n\t\t\t\tdata-glyph-end={edges.end || undefined}\n\t\t\t\tdisabled={resolvedDisabled}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', outline(\"neutral.ring\")),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', outline(\"success.ring\")),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', outline(\"warning.ring\")),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', outline(\"danger.ring\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A glyph is measured against the label it sits beside rather than against\n\t\t\t\t\t\t * whatever an icon set draws at, so the row keeps the height its text and\n\t\t\t\t\t\t * padding ask for. It never shrinks either: squeeze the row and the default\n\t\t\t\t\t\t * `flex-shrink: 1` compresses the glyph rather than the words, and a squashed\n\t\t\t\t\t\t * icon reads as a rendering fault.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"& > svg\", [shrink(), is(4), bs(4)]),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tborderRadius: \"var(--ui-button-radius, var(--ui-radius-md, 0.375rem))\",\n\t\t\t\t\t\t\tfontWeight: \"var(--ui-button-weight, 500)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\t\t/** A small control reaches `--ui-target-size` however a consumer positions it. */\n\t\t\t\t\t\thitArea({ anchor: \"flex-center\" }),\n\t\t\t\t\t\tuserSelect(),\n\n\t\t\t\t\t\tpi(4),\n\t\t\t\t\t\tpb(2),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Every variant carries the same border width, colored to match its own\n\t\t\t\t\t\t * fill (transparent for ghost), so solid and ghost render the exact\n\t\t\t\t\t\t * footprint outline does.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tborder({ width: 1, noStyleDefault: true }),\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The row measure is stated rather than left to fall out of the padding and\n\t\t\t\t\t\t * the border, so the control lines up with a field of the same size when a\n\t\t\t\t\t\t * Group fuses the two, and still grows when a long label wraps.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tminBs(\"2.5rem\"),\n\n\t\t\t\t\t\twhen('&[data-size=\"sm\"]', [\n\t\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\t\tpb(1.5),\n\t\t\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\t\twhen(\"& > svg\", [is(3), bs(3)]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"lg\"]', [\n\t\t\t\t\t\t\tpi(5),\n\t\t\t\t\t\t\tpb(2.5),\n\t\t\t\t\t\t\ttext(\"base\"),\n\t\t\t\t\t\t\tminBs(\"3rem\"),\n\t\t\t\t\t\t\twhen(\"& > svg\", [is(5), bs(5)]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A glyph beside a label carries its own side bearing, so the padding on that\n\t\t\t\t\t\t * side drops one step and the glyph and the words read as evenly inset.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&[data-glyph-start]:has(> svg:first-child)\", [\n\t\t\t\t\t\t\tpis(3),\n\t\t\t\t\t\t\twhen('&[data-size=\"sm\"]', pis(2)),\n\t\t\t\t\t\t\twhen('&[data-size=\"lg\"]', pis(4)),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\"&[data-glyph-end]:has(> svg:last-child)\", [\n\t\t\t\t\t\t\tpie(3),\n\t\t\t\t\t\t\twhen('&[data-size=\"sm\"]', pie(2)),\n\t\t\t\t\t\t\twhen('&[data-size=\"lg\"]', pie(4)),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A button holding a glyph and nothing else is a target for that glyph alone, so\n\t\t\t\t\t\t * it takes a round footprint as tall as the row it would otherwise fill. The\n\t\t\t\t\t\t * measure is a custom property per size, since a box sized by its own content on\n\t\t\t\t\t\t * both axes has no ratio to resolve against, and an app or a composing part can\n\t\t\t\t\t\t * resize it without touching the rule.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&[data-icon-only]\", [\n\t\t\t\t\t\t\tp(0),\n\t\t\t\t\t\t\tis(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\t\tbs(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\t\traw({ \"--ui-button-radius\": \"9999px\" }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"sm\"][data-icon-only]', [\n\t\t\t\t\t\t\tis(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\t\tbs(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"lg\"][data-icon-only]', [\n\t\t\t\t\t\t\tis(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\t\tbs(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"solid\"]', [\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\t\tborder(\"brand.solid\"),\n\t\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"brand.bg-solid-hover\"), border(\"brand.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [bg(\"brand.bg-solid-pressed\"), border(\"brand.bg-solid-pressed\")]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\t\tbg(\"neutral.solid\"),\n\t\t\t\t\t\t\t\tborder(\"neutral.solid\"),\n\t\t\t\t\t\t\t\tfg(\"neutral.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.bg-solid-hover\"), border(\"neutral.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"neutral.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"neutral.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tbg(\"success.solid\"),\n\t\t\t\t\t\t\t\tborder(\"success.solid\"),\n\t\t\t\t\t\t\t\tfg(\"success.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"success.bg-solid-hover\"), border(\"success.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"success.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"success.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tbg(\"warning.solid\"),\n\t\t\t\t\t\t\t\tborder(\"warning.solid\"),\n\t\t\t\t\t\t\t\tfg(\"warning.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"warning.bg-solid-hover\"), border(\"warning.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"warning.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"warning.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tbg(\"danger.solid\"),\n\t\t\t\t\t\t\t\tborder(\"danger.solid\"),\n\t\t\t\t\t\t\t\tfg(\"danger.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"danger.bg-solid-hover\"), border(\"danger.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"danger.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"danger.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"outline\"]', [\n\t\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tborder(\"brand\"),\n\t\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"brand.tint\"), border(\"brand.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\t\tborder(\"neutral\"),\n\t\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.tint\"), border(\"neutral.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tborder(\"success\"),\n\t\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"success.tint\"), border(\"success.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tborder(\"warning\"),\n\t\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"warning.tint\"), border(\"warning.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tborder(\"danger\"),\n\t\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"danger.tint\"), border(\"danger.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"ghost\"]', [\n\t\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\t\tborder(\"transparent\"),\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"brand.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"success.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"warning.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"danger.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"surface\"]', [surfaceControl()]),\n\n\t\t\t\t\t\twhen(\"&:disabled:not([data-pending])\", [cursor(\"not-allowed\"), opacity(50)]),\n\n\t\t\t\t\t\twhen(\"&[data-pending]\", [relative(), cursor(\"wait\")]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{isPending ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tdata-slot=\"spinner\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\t\t\tinset(0),\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\t\t\twhen(\"& svg\", [\n\t\t\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\twhen('[data-size=\"lg\"] & svg', [\n\t\t\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\tparts?.spinner,\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LoaderCircleIcon />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-slot=\"content\"\n\t\t\t\t\t\t\tmix={[visibility(\"hidden\"), inlineFlex(), items(\"center\"), gap(2), parts?.content]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\tchildren\n\t\t\t\t)}\n\t\t\t</button>\n\t\t);\n\t};\n}\n"
|
|
12
|
+
"content": "/**\n * An interactive control for a single, immediate action — submitting a form,\n * triggering a command, opening a dialog. Its host renders as a native\n * `<button>` shaped by a semantic color role, a visual weight variant, and a\n * size, and holds its footprint while rendering a busy pending state.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { LoaderCircleIcon } from \"@sdxc/icons\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, visibility } from \"@sdxc/u/effects\";\nimport { cursor, raw, userSelect, mergeMix } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tgap,\n\tinlineFlex,\n\tinset,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n} from \"@sdxc/u/layout\";\nimport { bs, is, minBs, p, pb, pi, pie, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { text } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { hitArea } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { surfaceControl } from \"@sdxc/ui/styles\";\nimport { glyphEdges } from \"@sdxc/ui/utils\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { CtaGroup } from \"@sdxc/ui/cta-group\";\n\nconst DEFAULT_COLOR: Button.Color = \"neutral\";\n\nconst DEFAULT_VARIANT: Button.Variant = \"solid\";\n\nconst DEFAULT_SIZE: Button.Size = \"md\";\n\n/** Edge of a small icon-only button, matching the `sm` row height. */\nconst ICON_ONLY_SIZE_SM = \"var(--ui-button-icon-size-sm, 2rem)\";\n\n/** Edge of a medium icon-only button, matching the `md` row height. */\nconst ICON_ONLY_SIZE_MD = \"var(--ui-button-icon-size-md, 2.5rem)\";\n\n/** Edge of a large icon-only button, matching the `lg` row height. */\nconst ICON_ONLY_SIZE_LG = \"var(--ui-button-icon-size-lg, 3rem)\";\n\n/**\n * Native `type` given to a button carrying `command`/`commandfor` and no\n * `type` of its own: the platform treats a button that could also submit as an\n * ambiguous invoker and skips its command, so an invoker needs this type.\n */\nconst INVOKER_TYPE = \"button\";\n\n/**\n * Prop types for {@link Button}.\n */\nexport namespace Button {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Visual weight the button renders with: a solid fill with an on-solid\n\t * foreground, a transparent fill with a strong colored border, a fully\n\t * transparent fill with just a colored label, or a raised `surface` fill with\n\t * the emphasis ink and a tactile edge — a secondary that reads as a control\n\t * beside a solid primary, and turns translucent inside inverse and brand bands.\n\t */\n\texport type Variant = \"solid\" | \"outline\" | \"ghost\" | \"surface\";\n\n\t/**\n\t * Size variant controlling the button's padding and font size.\n\t * Inside a {@link CtaGroup} an omitted size takes the group's, so a hero row\n\t * sizes every action at once; `\"md\"` is the 40px landing CTA.\n\t */\n\texport type Size = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Per-part styling for the elements a pending button renders besides its\n\t * own host.\n\t */\n\texport interface PartsProps {\n\t\t/** Styling for the decorative rotating glyph shown while pending. */\n\t\tspinner?: TagProps<\"span\">[\"mix\"];\n\t\t/**\n\t\t * Styling for the wrapper holding the button's own children while\n\t\t * pending; kept in the layout to preserve the button's footprint, but\n\t\t * hidden from view and from assistive technology.\n\t\t */\n\t\tcontent?: TagProps<\"span\">[\"mix\"];\n\t}\n\n\t/**\n\t * Props accepted by {@link Button}.\n\t */\n\texport interface Props extends TagProps<\"button\"> {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Size variant. Defaults to {@link DEFAULT_SIZE}. */\n\t\tsize?: Size;\n\t\t/**\n\t\t * Marks the button busy: merges into the native `disabled` attribute and\n\t\t * swaps the visible content for a spinner glyph while holding the rendered\n\t\t * footprint, so a page mid-request keeps its layout.\n\t\t */\n\t\tisPending?: boolean;\n\t\t/** Per-part styling for the pending state's internal elements. */\n\t\tparts?: PartsProps;\n\t}\n}\n\n/**\n * Reports whether `children` is a lone glyph, which is what makes a button a target for\n * that glyph rather than for a label. A selector cannot answer this: `:only-child`\n * counts elements, so a button holding text beside one icon still matches it.\n *\n * @param children The button's own children.\n * @returns Whether the button renders a single element and no text of its own.\n */\nfunction holdsOnlyAGlyph(children: RemixNode): boolean {\n\treturn typeof children === \"object\" && children !== null && !Array.isArray(children);\n}\n\n/**\n * Visual state lives in `data-color`/`data-variant`/`data-size` on the host, so\n * hover, pressed, and focus-visible stay on native pseudo-classes. `type` precedes\n * the spread so the platform sees it while parsing `command`/`commandfor`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the button's markup.\n * @example\n * <Button type=\"submit\">{t(\"actions.save\")}</Button>\n * @example\n * <Button color=\"danger\" variant=\"outline\" size=\"sm\">{t(\"actions.delete\")}</Button>\n * @example\n * <Button type=\"submit\" isPending={isSubmitting}>{t(\"actions.save\")}</Button>\n * @example\n * <Button size=\"lg\" color=\"brand\" mix={[landingCtaChrome()]}>{t(\"hero.cta\")}</Button>\n */\nexport function Button(handle: Handle<Button.Props>) {\n\treturn () => {\n\t\tlet { color, variant, size, isPending, disabled, type, parts, children, mix, ...rest } =\n\t\t\thandle.props;\n\t\tlet isInvoker = rest.command !== undefined || rest.commandfor !== undefined;\n\t\tlet resolvedType = type ?? (isInvoker ? INVOKER_TYPE : undefined);\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet group = handle.context.get(CtaGroup) as CtaGroup.Context | undefined;\n\t\tlet resolvedSize = size ?? group?.size ?? DEFAULT_SIZE;\n\t\tlet resolvedDisabled = disabled || isPending;\n\t\tlet iconOnly = holdsOnlyAGlyph(children);\n\t\tlet edges = glyphEdges(children);\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Button: an icon-only button needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-pending={isPending || undefined}\n\t\t\t\tdata-icon-only={iconOnly || undefined}\n\t\t\t\tdata-glyph-start={edges.start || undefined}\n\t\t\t\tdata-glyph-end={edges.end || undefined}\n\t\t\t\tdisabled={resolvedDisabled}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', outline(\"neutral.ring\")),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', outline(\"success.ring\")),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', outline(\"warning.ring\")),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', outline(\"danger.ring\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A glyph is measured against the label it sits beside rather than against\n\t\t\t\t\t\t * whatever an icon set draws at, so the row keeps the height its text and\n\t\t\t\t\t\t * padding ask for. It never shrinks either: squeeze the row and the default\n\t\t\t\t\t\t * `flex-shrink: 1` compresses the glyph rather than the words, and a squashed\n\t\t\t\t\t\t * icon reads as a rendering fault.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"& > svg\", [shrink(), is(4), bs(4)]),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tborderRadius: \"var(--ui-button-radius, var(--ui-radius-md, 0.375rem))\",\n\t\t\t\t\t\t\tfontWeight: \"var(--ui-button-weight, 500)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A small control reaches `--ui-target-size` however a consumer positions it. The\n\t\t\t\t\t\t * control is its target's containing block, so a scrolling row of buttons clips\n\t\t\t\t\t\t * every target and the page never grows to fit one; a consumer's own position\n\t\t\t\t\t\t * utility in `mix` replaces it.\n\t\t\t\t\t\t */\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\thitArea({ anchor: \"flex-center\" }),\n\t\t\t\t\t\tuserSelect(),\n\n\t\t\t\t\t\tpi(4),\n\t\t\t\t\t\tpb(2),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Every variant carries the same border width, colored to match its own\n\t\t\t\t\t\t * fill (transparent for ghost), so solid and ghost render the exact\n\t\t\t\t\t\t * footprint outline does.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tborder({ width: 1, noStyleDefault: true }),\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The row measure is stated rather than left to fall out of the padding and\n\t\t\t\t\t\t * the border, so the control lines up with a field of the same size when a\n\t\t\t\t\t\t * Group fuses the two, and still grows when a long label wraps.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tminBs(\"2.5rem\"),\n\n\t\t\t\t\t\twhen('&[data-size=\"sm\"]', [\n\t\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\t\tpb(1.5),\n\t\t\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\t\twhen(\"& > svg\", [is(3), bs(3)]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"lg\"]', [\n\t\t\t\t\t\t\tpi(5),\n\t\t\t\t\t\t\tpb(2.5),\n\t\t\t\t\t\t\ttext(\"base\"),\n\t\t\t\t\t\t\tminBs(\"3rem\"),\n\t\t\t\t\t\t\twhen(\"& > svg\", [is(5), bs(5)]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A glyph beside a label carries its own side bearing, so the padding on that\n\t\t\t\t\t\t * side drops one step and the glyph and the words read as evenly inset.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&[data-glyph-start]:has(> svg:first-child)\", [\n\t\t\t\t\t\t\tpis(3),\n\t\t\t\t\t\t\twhen('&[data-size=\"sm\"]', pis(2)),\n\t\t\t\t\t\t\twhen('&[data-size=\"lg\"]', pis(4)),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\"&[data-glyph-end]:has(> svg:last-child)\", [\n\t\t\t\t\t\t\tpie(3),\n\t\t\t\t\t\t\twhen('&[data-size=\"sm\"]', pie(2)),\n\t\t\t\t\t\t\twhen('&[data-size=\"lg\"]', pie(4)),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A button holding a glyph and nothing else is a target for that glyph alone, so\n\t\t\t\t\t\t * it takes a round footprint as tall as the row it would otherwise fill. The\n\t\t\t\t\t\t * measure is a custom property per size, since a box sized by its own content on\n\t\t\t\t\t\t * both axes has no ratio to resolve against, and an app or a composing part can\n\t\t\t\t\t\t * resize it without touching the rule.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&[data-icon-only]\", [\n\t\t\t\t\t\t\tp(0),\n\t\t\t\t\t\t\tis(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\t\tbs(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\t\traw({ \"--ui-button-radius\": \"9999px\" }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"sm\"][data-icon-only]', [\n\t\t\t\t\t\t\tis(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\t\tbs(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"lg\"][data-icon-only]', [\n\t\t\t\t\t\t\tis(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\t\tbs(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"solid\"]', [\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\t\tborder(\"brand.solid\"),\n\t\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"brand.bg-solid-hover\"), border(\"brand.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [bg(\"brand.bg-solid-pressed\"), border(\"brand.bg-solid-pressed\")]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\t\tbg(\"neutral.solid\"),\n\t\t\t\t\t\t\t\tborder(\"neutral.solid\"),\n\t\t\t\t\t\t\t\tfg(\"neutral.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.bg-solid-hover\"), border(\"neutral.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"neutral.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"neutral.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tbg(\"success.solid\"),\n\t\t\t\t\t\t\t\tborder(\"success.solid\"),\n\t\t\t\t\t\t\t\tfg(\"success.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"success.bg-solid-hover\"), border(\"success.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"success.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"success.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tbg(\"warning.solid\"),\n\t\t\t\t\t\t\t\tborder(\"warning.solid\"),\n\t\t\t\t\t\t\t\tfg(\"warning.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"warning.bg-solid-hover\"), border(\"warning.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"warning.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"warning.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tbg(\"danger.solid\"),\n\t\t\t\t\t\t\t\tborder(\"danger.solid\"),\n\t\t\t\t\t\t\t\tfg(\"danger.onSolid\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"danger.bg-solid-hover\"), border(\"danger.bg-solid-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\t\tbg(\"danger.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t\tborder(\"danger.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"outline\"]', [\n\t\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tborder(\"brand\"),\n\t\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"brand.tint\"), border(\"brand.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\t\tborder(\"neutral\"),\n\t\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.tint\"), border(\"neutral.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tborder(\"success\"),\n\t\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"success.tint\"), border(\"success.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tborder(\"warning\"),\n\t\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"warning.tint\"), border(\"warning.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tborder(\"danger\"),\n\t\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"danger.tint\"), border(\"danger.border-hover\")]),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"ghost\"]', [\n\t\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\t\tborder(\"transparent\"),\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"brand.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"success.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"warning.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"danger.tint\")),\n\t\t\t\t\t\t\t\twhen(\"&:active\", bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen('&[data-variant=\"surface\"]', [surfaceControl()]),\n\n\t\t\t\t\t\twhen(\"&:disabled:not([data-pending])\", [cursor(\"not-allowed\"), opacity(50)]),\n\n\t\t\t\t\t\twhen(\"&[data-pending]\", [relative(), cursor(\"wait\")]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{isPending ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tdata-slot=\"spinner\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\t\t\tinset(0),\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\t\t\twhen(\"& svg\", [\n\t\t\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\twhen('[data-size=\"lg\"] & svg', [\n\t\t\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\tparts?.spinner,\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LoaderCircleIcon />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-slot=\"content\"\n\t\t\t\t\t\t\tmix={[visibility(\"hidden\"), inlineFlex(), items(\"center\"), gap(2), parts?.content]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\tchildren\n\t\t\t\t)}\n\t\t\t</button>\n\t\t);\n\t};\n}\n"
|
|
13
13
|
},
|
|
14
14
|
"test": {
|
|
15
15
|
"path": "button.test.tsx",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "character-count",
|
|
3
|
+
"changedIn": "2026.11.14",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"CharacterCountProps",
|
|
7
|
+
"CharacterCount"
|
|
8
|
+
],
|
|
9
|
+
"source": {
|
|
10
|
+
"path": "character-count.tsx",
|
|
11
|
+
"content": "/**\n * A ring that fills as a limited field is typed in, the characters left once the limit is\n * near, and how far over once past it, for a post, a bio or a short reply. A client island\n * the server draws for the field's text, so a re-rendered form opens on the right count.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { EntryComponent } from \"remix/component\";\n\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { raw } from \"@sdxc/u/general\";\nimport { motionReduce } from \"@sdxc/u/responsive\";\nimport { when } from \"@sdxc/u/state\";\nimport { clientEntry } from \"remix/component\";\n\nimport {\n\tcharacterCount,\n\tcharacterCountState,\n\tcountCharacters,\n\tisRingHidden,\n} from \"@sdxc/ui/mixins\";\n\nexport { countCharacters } from \"@sdxc/ui/mixins\";\n\n/** How many characters left show the number when `warn` is omitted. */\nconst DEFAULT_WARN = 20;\n\n/**\n * Props {@link CharacterCount} serializes into the page for hydration, which is why they are\n * a `type`: `SerializableProps` rejects an interface.\n */\nexport type CharacterCountProps = {\n\t/** The `id` of the `<textarea>` or `<input>` counted. */\n\tfor: string;\n\t/** The most characters the field takes, counted by `countCharacters`. */\n\tmax: number;\n\t/** The field's text as the server renders it, so the first paint shows its count. */\n\tvalue?: string;\n\t/** How many characters left show the number. @default 20 */\n\twarn?: number;\n\t/** Disables the form's submit buttons while the field is empty or over the limit. @default false */\n\tholdSubmit?: boolean;\n\t/** What a screen reader hears as the state changes; `{count}` is the number left or over. */\n\tlabels: {\n\t\t/** Such as \"{count} characters left\". */\n\t\tremaining: string;\n\t\t/** Such as \"{count} characters over the limit\". */\n\t\tover: string;\n\t};\n};\n\n/**\n * Renders the ring and its number. The ring sits in a fixed box and scales up for the\n * warning, so the controls beside it never move; past ten over, only the number remains.\n * The island loads from `@sdxc/ui/character-count`, which the browser entry maps.\n *\n * @example\n * <Textarea id=\"draft\" name=\"text\" />\n * <CharacterCount for=\"draft\" max={280} holdSubmit\n * \tlabels={{ remaining: \"{count} characters left\", over: \"{count} characters over\" }} />\n */\nexport const CharacterCount: EntryComponent<CharacterCountProps> = clientEntry(\n\t\"@sdxc/ui/character-count#CharacterCount\",\n\tfunction CharacterCount(handle) {\n\t\treturn () => {\n\t\t\tlet {\n\t\t\t\tfor: field,\n\t\t\t\tmax,\n\t\t\t\tvalue = \"\",\n\t\t\t\twarn = DEFAULT_WARN,\n\t\t\t\tholdSubmit = false,\n\t\t\t\tlabels,\n\t\t\t} = handle.props;\n\t\t\tlet length = countCharacters(value);\n\t\t\tlet state = characterCountState(length, max, warn);\n\t\t\tlet left = max - length;\n\t\t\tlet shown = state === \"warn\" || state === \"over\" ? String(left) : \"\";\n\n\t\t\treturn (\n\t\t\t\t<span\n\t\t\t\t\tdata-slot=\"character-count\"\n\t\t\t\t\tdata-state={state}\n\t\t\t\t\tdata-ring-hidden={isRingHidden(left) ? \"\" : undefined}\n\t\t\t\t\tstyle={`--ui-character-count-progress: ${Math.min(1, length / max)}`}\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tcharacterCount({ for: field, max, warn, holdSubmit, labels }),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\"--ui-character-count-tone\": \"var(--ui-brand-fg)\",\n\t\t\t\t\t\t\tposition: \"relative\",\n\t\t\t\t\t\t\tdisplay: \"inline-grid\",\n\t\t\t\t\t\t\tplaceItems: \"center\",\n\t\t\t\t\t\t\tflexShrink: 0,\n\t\t\t\t\t\t\tinlineSize: \"1.875rem\",\n\t\t\t\t\t\t\tblockSize: \"1.875rem\",\n\t\t\t\t\t\t\tfontSize: \"0.75rem\",\n\t\t\t\t\t\t\tfontVariantNumeric: \"tabular-nums\",\n\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg-muted)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\"&[data-state='warn']\",\n\t\t\t\t\t\t\traw({ \"--ui-character-count-tone\": \"var(--ui-warning-fg)\" }),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\"&[data-state='over']\",\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\"--ui-character-count-tone\": \"var(--ui-danger-fg)\",\n\t\t\t\t\t\t\t\tcolor: \"var(--ui-danger-fg)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<svg\n\t\t\t\t\t\tviewBox=\"0 0 20 20\"\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tdata-character-count-ring=\"\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tgridArea: \"1 / 1\",\n\t\t\t\t\t\t\t\tinlineSize: \"1.25rem\",\n\t\t\t\t\t\t\t\tblockSize: \"1.25rem\",\n\t\t\t\t\t\t\t\ttransform: \"rotate(-90deg)\",\n\t\t\t\t\t\t\t\ttransition: \"scale 150ms ease-out, opacity 150ms ease-out\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\twhen(\"[data-state='warn'] > &, [data-state='over'] > &\", raw({ scale: \"1.4\" })),\n\t\t\t\t\t\t\twhen(\"[data-ring-hidden] > &\", raw({ opacity: \"0\" })),\n\t\t\t\t\t\t\tmotionReduce(raw({ transition: \"none\" })),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\tcx=\"10\"\n\t\t\t\t\t\t\tcy=\"10\"\n\t\t\t\t\t\t\tr=\"8\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\t\t\tmix={[raw({ stroke: \"var(--ui-neutral-border)\" })]}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\tcx=\"10\"\n\t\t\t\t\t\t\tcy=\"10\"\n\t\t\t\t\t\t\tr=\"8\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\t\t\tpathLength=\"100\"\n\t\t\t\t\t\t\tstroke-dasharray=\"100\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\tstroke: \"var(--ui-character-count-tone)\",\n\t\t\t\t\t\t\t\t\tstrokeDashoffset: \"calc(100 - var(--ui-character-count-progress, 0) * 100)\",\n\t\t\t\t\t\t\t\t\ttransition: \"stroke-dashoffset 120ms linear, stroke 150ms\",\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\twhen(\"[data-state='empty'] > svg > &\", raw({ opacity: \"0\" })),\n\t\t\t\t\t\t\t\tmotionReduce(raw({ transition: \"none\" })),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</svg>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tdata-character-count-number=\"\"\n\t\t\t\t\t\tmix={[raw({ gridArea: \"1 / 1\", lineHeight: \"1\" })]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{shown}\n\t\t\t\t\t</span>\n\t\t\t\t\t<span role=\"status\" data-character-count-status=\"\" mix={[visuallyHidden()]} />\n\t\t\t\t</span>\n\t\t\t);\n\t\t};\n\t},\n);\n"
|
|
12
|
+
},
|
|
13
|
+
"test": {
|
|
14
|
+
"path": "character-count.browser.test.tsx",
|
|
15
|
+
"content": "/**\n * Types into a field beside its character count in a real browser: the server-drawn state\n * matches the field's text, the ring and number follow every keystroke, the number shows\n * only near the limit, Post waits while the field is empty or over, the ring gives way to\n * the number far past the limit, and a screen reader hears each change of state once.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { RenderResult } from \"remix/component/test\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\n\nimport { countCharacters } from \"@sdxc/ui/mixins\";\n\nimport { CharacterCount } from \"@sdxc/ui/character-count\";\n\nimport \"@sdxc/ui/reset.css\";\nimport \"@sdxc/ui/theme.css\";\n\n/** Announcement templates. */\nconst LABELS = { remaining: \"{count} characters left\", over: \"{count} characters over the limit\" };\n\nlet mounted: RenderResult | undefined;\n\nafterEach(() => {\n\tmounted?.cleanup();\n\tmounted = undefined;\n});\n\n/** Mounts a form with a 20-character field and its count, then waits for the island. */\nasync function mount(value = \"\", holdSubmit = true) {\n\tmounted = render(\n\t\t<form>\n\t\t\t<textarea id=\"draft\" name=\"text\" defaultValue={value} />\n\t\t\t<CharacterCount\n\t\t\t\tfor=\"draft\"\n\t\t\t\tmax={20}\n\t\t\t\twarn={5}\n\t\t\t\tvalue={value}\n\t\t\t\tholdSubmit={holdSubmit}\n\t\t\t\tlabels={LABELS}\n\t\t\t/>\n\t\t\t<button type=\"submit\">Post</button>\n\t\t</form>,\n\t);\n\tawait new Promise((resolve) => requestAnimationFrame(resolve));\n\tawait new Promise((resolve) => setTimeout(resolve, 0));\n\tlet root = mounted.container;\n\treturn {\n\t\tfield: root.querySelector(\"textarea\")!,\n\t\tcount: root.querySelector<HTMLElement>('[data-slot=\"character-count\"]')!,\n\t\tnumber: root.querySelector<HTMLElement>(\"[data-character-count-number]\")!,\n\t\tstatus: root.querySelector<HTMLElement>(\"[data-character-count-status]\")!,\n\t\tsubmit: root.querySelector<HTMLButtonElement>('button[type=\"submit\"]')!,\n\t\tring: root.querySelector<SVGElement>(\"[data-character-count-ring]\")!,\n\t};\n}\n\n/** Replaces the field's text as typing does, firing `input`. */\nfunction type(field: HTMLTextAreaElement, text: string) {\n\tfield.value = text;\n\tfield.dispatchEvent(new Event(\"input\", { bubbles: true }));\n}\n\ndescribe(\"CharacterCount\", () => {\n\ttest(\"opens on the state of the text the server rendered\", async () => {\n\t\tlet { count, number } = await mount(\"Seventeen letters\");\n\n\t\texpect(count.dataset.state).toBe(\"warn\");\n\t\texpect(number.textContent).toBe(\"3\");\n\t});\n\n\ttest(\"shows no number while there is room, then the characters left near the limit\", async () => {\n\t\tlet { count, field, number } = await mount();\n\n\t\ttype(field, \"Short\");\n\t\texpect(count.dataset.state).toBe(\"ok\");\n\t\texpect(number.textContent).toBe(\"\");\n\n\t\ttype(field, \"Getting close now..\");\n\t\texpect(count.dataset.state).toBe(\"warn\");\n\t\texpect(number.textContent).toBe(\"1\");\n\t});\n\n\ttest(\"fills the ring in step with the text\", async () => {\n\t\tlet { count, field } = await mount();\n\n\t\ttype(field, \"1234567890\");\n\t\texpect(count.style.getPropertyValue(\"--ui-character-count-progress\")).toBe(\"0.5\");\n\t});\n\n\ttest(\"holds the submit button while empty or over, and marks the field invalid past the limit\", async () => {\n\t\tlet { field, submit } = await mount();\n\n\t\texpect(submit.disabled).toBe(true);\n\t\ttype(field, \"Fine\");\n\t\texpect(submit.disabled).toBe(false);\n\t\ttype(field, \"This is well over twenty\");\n\t\texpect(submit.disabled).toBe(true);\n\t\texpect(field.getAttribute(\"aria-invalid\")).not.toBeNull();\n\t});\n\n\ttest(\"leaves the submit button alone without holdSubmit\", async () => {\n\t\tlet { submit } = await mount(\"\", false);\n\n\t\texpect(submit.disabled).toBe(false);\n\t});\n\n\ttest(\"drops the ring for the number alone ten past the limit\", async () => {\n\t\tlet { count, field, number, ring } = await mount();\n\n\t\ttype(field, \"a\".repeat(25));\n\t\texpect(count.hasAttribute(\"data-ring-hidden\")).toBe(false);\n\t\ttype(field, \"a\".repeat(30));\n\t\texpect(count.hasAttribute(\"data-ring-hidden\")).toBe(true);\n\t\texpect(number.textContent).toBe(\"-10\");\n\t\tawait expect.poll(() => getComputedStyle(ring).opacity).toBe(\"0\");\n\t});\n\n\ttest(\"announces each change of state once, not every keystroke\", async () => {\n\t\tlet { field, status } = await mount();\n\n\t\ttype(field, \"a\".repeat(16));\n\t\texpect(status.textContent).toBe(\"4 characters left\");\n\t\tstatus.textContent = \"\";\n\t\ttype(field, \"a\".repeat(17));\n\t\texpect(status.textContent).toBe(\"\");\n\t\ttype(field, \"a\".repeat(22));\n\t\texpect(status.textContent).toBe(\"2 characters over the limit\");\n\t});\n\n\ttest(\"counts what a reader sees as one character once\", () => {\n\t\texpect(countCharacters(\"👋🏽\")).toBe(1);\n\t\texpect(countCharacters(\"🇵🇹 Lisboa\")).toBe(8);\n\t\texpect(countCharacters(\"e\\u0301\")).toBe(1);\n\t});\n});\n"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "label-chip",
|
|
3
|
+
"changedIn": "2026.11.14",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"LabelChip"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "label-chip.tsx",
|
|
10
|
+
"content": "/**\n * A label an issue, pull request or record carries, drawn as a small pill in the label's own\n * colour. Any colour goes in and the text stays readable on its tint in light and dark, so\n * labels whose colours people pick themselves never need a hand-tuned text colour.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { mergeMix, raw } from \"@sdxc/u/general\";\nimport { inlineFlex, items, shrink } from \"@sdxc/u/layout\";\nimport { nowrap } from \"@sdxc/u/typography\";\n\nimport { mergeStyle } from \"@sdxc/ui/utils\";\n\n/** Custom property carrying the label's colour to every rule that derives from it. */\nconst COLOR_PROPERTY = \"--ui-label-chip-color\";\n\n/** The label's colour as the rules read it. */\nconst COLOR = `var(${COLOR_PROPERTY})`;\n\n/** Lightness of the colour a `hue` stands for: a mid-tone, which both themes derive from well. */\nconst HUE_LIGHTNESS = 0.62;\n\n/** Chroma of the colour a `hue` stands for. */\nconst HUE_CHROMA = 0.15;\n\n/** The colour a label without `color` or `hue` takes: a quiet grey. */\nconst DEFAULT_COLOR = \"oklch(0.62 0 0)\";\n\n/**\n * Prop types for {@link LabelChip}.\n */\nexport namespace LabelChip {\n\t/**\n\t * How the colour shows: `pill` tints the whole chip and its text, `dot` keeps a neutral\n\t * outlined chip with the colour in a dot before the name, for dense rows.\n\t */\n\texport type Variant = \"pill\" | \"dot\";\n\n\t/** Every native `<span>` attribute plus the label's colour and look. */\n\texport interface Props extends TagProps<\"span\"> {\n\t\t/** Any CSS colour (`#d73a4a`, `oklch(0.63 0.19 25)`), as the label was defined. */\n\t\tcolor?: string;\n\t\t/** A hue in degrees, used when `color` is absent; it stands for a mid-tone colour. */\n\t\thue?: number;\n\t\t/** @default \"pill\" */\n\t\tvariant?: Variant;\n\t\t/** The label's name. */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Renders the chip as plain HTML and CSS. A pill derives tint, border and text from the colour at\n * fixed OKLCH lightness through `light-dark()`, so text clears 4.5:1 for every hue in the page's\n * `color-scheme`; the dot variant reads neutral roles. Rules read the colour from `--ui-label-chip-color`.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the chip's markup.\n * @example <LabelChip color=\"#d73a4a\">bug</LabelChip>\n * @example <LabelChip hue={150}>{t(\"labels.feature\")}</LabelChip>\n * @example <LabelChip variant=\"dot\" color={label.color}>{label.name}</LabelChip>\n */\nexport function LabelChip(handle: Handle<LabelChip.Props>) {\n\treturn () => {\n\t\tlet { children, color, hue, mix, style, variant = \"pill\", ...rest } = handle.props;\n\t\tlet resolved = color ?? (hue === undefined ? DEFAULT_COLOR : hueColor(hue));\n\t\tlet dot = variant === \"dot\";\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"label-chip\"\n\t\t\t\tdata-variant={variant}\n\t\t\t\tstyle={mergeStyle(style, { [COLOR_PROPERTY]: resolved })}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tnowrap(),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tgap: \"0.3125rem\",\n\t\t\t\t\t\t\tblockSize: \"1.25rem\",\n\t\t\t\t\t\t\tpaddingInline: \"0.4375rem\",\n\t\t\t\t\t\t\tboxSizing: \"border-box\",\n\t\t\t\t\t\t\tborderWidth: \"1px\",\n\t\t\t\t\t\t\tborderStyle: \"solid\",\n\t\t\t\t\t\t\tborderRadius: \"999px\",\n\t\t\t\t\t\t\tfontSize: \"0.75rem\",\n\t\t\t\t\t\t\tlineHeight: \"1rem\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tdot ? dotRules() : pillRules(),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{dot ? (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tdata-slot=\"label-chip-dot\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tshrink(0),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tinlineSize: \"0.5rem\",\n\t\t\t\t\t\t\t\tblockSize: \"0.5rem\",\n\t\t\t\t\t\t\t\tborderRadius: \"999px\",\n\t\t\t\t\t\t\t\tbackgroundColor: COLOR,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t);\n\t};\n}\n\n/** The colour a hue stands for. */\nfunction hueColor(hue: number): string {\n\treturn `oklch(${HUE_LIGHTNESS} ${HUE_CHROMA} ${hue})`;\n}\n\n/**\n * Re-derives the label's colour at one lightness and capped chroma. Fixing lightness is\n * what holds contrast for any hue; capping chroma keeps the result inside sRGB, where\n * clipping would shift its lightness.\n */\nfunction derive(lightness: number, chroma: number): string {\n\treturn `oklch(from ${COLOR} ${lightness} min(c, ${chroma}) h)`;\n}\n\n/** A pill's tint, border and text, one pair of lightnesses per theme. */\nfunction pillRules() {\n\treturn raw({\n\t\tfontWeight: 500,\n\t\tbackgroundColor: `light-dark(${derive(0.95, 0.05)}, ${derive(0.3, 0.07)})`,\n\t\tborderColor: `light-dark(${derive(0.85, 0.09)}, ${derive(0.42, 0.1)})`,\n\t\tcolor: `light-dark(${derive(0.42, 0.14)}, ${derive(0.86, 0.1)})`,\n\t});\n}\n\n/** The dot variant's neutral outline and text, which the page's theme already makes readable. */\nfunction dotRules() {\n\treturn raw({\n\t\tborderColor: \"var(--ui-neutral-border)\",\n\t\tcolor: \"var(--ui-neutral-fg)\",\n\t});\n}\n"
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"path": "label-chip.browser.test.tsx",
|
|
14
|
+
"content": "/**\n * Draws label chips in a real browser: a pill's text clears 4.5:1 against its own tint for\n * every hue and for extreme colours in light and dark, a hue stands in for a colour, and the\n * dot variant keeps neutral text with the colour in a hidden dot.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\n\nimport { LabelChip } from \"@sdxc/ui/label-chip\";\n\nimport \"@sdxc/ui/reset.css\";\nimport \"@sdxc/ui/theme.css\";\n\n/** Every 30° of the wheel, as a hue a label could carry. */\nconst HUES = Array.from({ length: 12 }, (_, index) => index * 30);\n\n/** Colours people pick for labels that stress a derived text colour the most. */\nconst COLORS = [\"#ffff00\", \"#ffffff\", \"#000000\", \"#00ff00\", \"#0000ff\", \"#d73a4a\", \"#808080\"];\n\n/** Mounts `node` in a fresh host appended to the page and returns the first chip in it. */\nfunction mount(node: JSX.Element): HTMLElement {\n\tlet host = document.createElement(\"div\");\n\tdocument.body.appendChild(host);\n\trender(node, { container: host });\n\treturn host.querySelector<HTMLElement>('[data-slot=\"label-chip\"]')!;\n}\n\n/** The relative luminance of a CSS colour, read back as painted on a canvas. */\nfunction luminance(color: string): number {\n\tlet canvas = document.createElement(\"canvas\");\n\tcanvas.width = 1;\n\tcanvas.height = 1;\n\tlet context = canvas.getContext(\"2d\")!;\n\tcontext.fillStyle = color;\n\tcontext.fillRect(0, 0, 1, 1);\n\tlet [r, g, b] = [...context.getImageData(0, 0, 1, 1).data].map((channel) => {\n\t\tlet c = channel / 255;\n\t\treturn c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n\t});\n\treturn 0.2126 * r! + 0.7152 * g! + 0.0722 * b!;\n}\n\n/** WCAG contrast between a chip's text and its own background. */\nfunction contrastOf(chip: HTMLElement): number {\n\tlet style = getComputedStyle(chip);\n\tlet [a, z] = [luminance(style.color), luminance(style.backgroundColor)];\n\treturn (Math.max(a, z) + 0.05) / (Math.min(a, z) + 0.05);\n}\n\nafterEach(() => {\n\tdocument.body.replaceChildren();\n\tdocument.documentElement.classList.remove(\"dark\");\n});\n\ndescribe(\"LabelChip\", () => {\n\tfor (let scheme of [\"light\", \"dark\"] as const) {\n\t\ttest(`keeps a pill's text at 4.5:1 or better on its tint for every hue, in ${scheme}`, () => {\n\t\t\tif (scheme === \"dark\") document.documentElement.classList.add(\"dark\");\n\t\t\tfor (let hue of HUES) {\n\t\t\t\tlet chip = mount(<LabelChip hue={hue}>Label</LabelChip>);\n\t\t\t\texpect(contrastOf(chip), `hue ${hue}`).toBeGreaterThanOrEqual(4.5);\n\t\t\t}\n\t\t});\n\n\t\ttest(`keeps a pill's text at 4.5:1 or better for extreme colours, in ${scheme}`, () => {\n\t\t\tif (scheme === \"dark\") document.documentElement.classList.add(\"dark\");\n\t\t\tfor (let color of COLORS) {\n\t\t\t\tlet chip = mount(<LabelChip color={color}>Label</LabelChip>);\n\t\t\t\texpect(contrastOf(chip), color).toBeGreaterThanOrEqual(4.5);\n\t\t\t}\n\t\t});\n\t}\n\n\ttest(\"tints a pill differently in light and dark\", () => {\n\t\tlet light = getComputedStyle(mount(<LabelChip hue={25}>Bug</LabelChip>)).backgroundColor;\n\t\tdocument.documentElement.classList.add(\"dark\");\n\t\tlet dark = getComputedStyle(mount(<LabelChip hue={25}>Bug</LabelChip>)).backgroundColor;\n\n\t\texpect(luminance(light)).toBeGreaterThan(0.7);\n\t\texpect(luminance(dark)).toBeLessThan(0.1);\n\t});\n\n\ttest(\"derives a pill from its colour, so two hues draw two tints\", () => {\n\t\tlet red = getComputedStyle(mount(<LabelChip color=\"#d73a4a\">bug</LabelChip>));\n\t\tlet green = getComputedStyle(mount(<LabelChip color=\"#0e8a16\">ok</LabelChip>));\n\n\t\texpect(red.backgroundColor).not.toBe(green.backgroundColor);\n\t\texpect(red.color).not.toBe(green.color);\n\t});\n\n\ttest(\"draws the dot variant with neutral text and the colour in a hidden dot\", () => {\n\t\tlet chip = mount(\n\t\t\t<LabelChip variant=\"dot\" color=\"rgb(200, 0, 0)\">\n\t\t\t\tBug\n\t\t\t</LabelChip>,\n\t\t);\n\t\tlet dot = chip.querySelector<HTMLElement>('[data-slot=\"label-chip-dot\"]')!;\n\n\t\texpect(chip.dataset.variant).toBe(\"dot\");\n\t\texpect(chip.textContent).toBe(\"Bug\");\n\t\texpect(dot.getAttribute(\"aria-hidden\")).toBe(\"true\");\n\t\texpect(getComputedStyle(dot).backgroundColor).toBe(\"rgb(200, 0, 0)\");\n\t\texpect(getComputedStyle(dot).inlineSize).toBe(\"8px\");\n\t\texpect(getComputedStyle(chip).backgroundColor).toBe(\"rgba(0, 0, 0, 0)\");\n\t});\n\n\ttest(\"draws no dot on a pill, and keeps a style it was given\", () => {\n\t\tlet chip = mount(\n\t\t\t<LabelChip color=\"#d73a4a\" style={{ \"margin-inline-start\": \"3px\" }}>\n\t\t\t\tbug\n\t\t\t</LabelChip>,\n\t\t);\n\n\t\texpect(chip.querySelector('[data-slot=\"label-chip-dot\"]')).toBeNull();\n\t\texpect(chip.dataset.variant).toBe(\"pill\");\n\t\texpect(getComputedStyle(chip).marginInlineStart).toBe(\"3px\");\n\t\texpect(chip.style.getPropertyValue(\"--ui-label-chip-color\")).toBe(\"#d73a4a\");\n\t});\n\n\ttest(\"stands a hue in for a mid-tone colour, and greys a label with neither\", () => {\n\t\tlet hued = mount(<LabelChip hue={150}>Feature</LabelChip>);\n\t\tlet plain = mount(<LabelChip>Other</LabelChip>);\n\n\t\texpect(hued.style.getPropertyValue(\"--ui-label-chip-color\")).toBe(\"oklch(0.62 0.15 150)\");\n\t\texpect(plain.style.getPropertyValue(\"--ui-label-chip-color\")).toBe(\"oklch(0.62 0 0)\");\n\t});\n\n\ttest(\"stays one line tall however long the name\", () => {\n\t\tlet chip = mount(<LabelChip hue={245}>A rather long label name that would wrap</LabelChip>);\n\n\t\texpect(chip.getBoundingClientRect().height).toBe(20);\n\t});\n});\n"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "property-list",
|
|
3
|
-
"changedIn": "2026.11.
|
|
3
|
+
"changedIn": "2026.11.14",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"popover"
|
|
6
6
|
],
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
11
|
"path": "property-list.tsx",
|
|
12
|
-
"content": "/**\n * Label/value rows for one record's properties, as a `<dl>`: a fixed label column beside\n * each value that stacks once its container narrows, empty values named in words, and an\n * editable row whose value opens an anchored native popover holding the app's own form.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { ChevronDownIcon } from \"@sdxc/icons\";\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, transition } from \"@sdxc/u/effects\";\nimport { cursor, raw, mergeMix } from \"@sdxc/u/general\";\nimport { container, flex, gap, grid, items, justify, shrink, vstack } from \"@sdxc/u/layout\";\nimport { is, m, minBs, minIs, p, pb, pi } from \"@sdxc/u/size\";\nimport { focusVisible, hover } from \"@sdxc/u/state\";\nimport { leading, tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Popover } from \"@sdxc/ui/popover\";\n\n/** Container the list names, so its rows stack against the list's own width. */\nconst PROPERTY_LIST_CONTAINER = \"ui-property-list\";\n\n/** Layout a list takes when `variant` is left unset. */\nconst DEFAULT_VARIANT: PropertyList.Variant = \"rows\";\n\n/** Shown for a value the caller leaves empty and names no empty text for. */\nconst DEFAULT_EMPTY = \"—\";\n\n/**\n * Prop types for {@link PropertyList} and its compound parts.\n */\nexport namespace PropertyList {\n\t/**\n\t * `\"rows\"` sets each label beside its value in a ruled-free column; `\"tiles\"` sets each\n\t * property in its own bordered tile, two to a row, for a record's headline figures.\n\t */\n\texport type Variant = \"rows\" | \"tiles\";\n\n\t/** What {@link PropertyList} shares with its items. */\n\texport interface Context {\n\t\tvariant: Variant;\n\t}\n\n\t/** Every native `<dl>` attribute, plus the layout variant. */\n\texport interface Props extends TagProps<\"dl\"> {\n\t\t/** @default {@link DEFAULT_VARIANT} */\n\t\tvariant?: Variant;\n\t}\n\n\t/**\n\t * Makes a row editable in place: its value becomes a button that opens a popover\n\t * anchored under it, holding whatever form the app renders as `content`.\n\t */\n\texport interface Edit {\n\t\t/** Id of the popover, which the value button targets. */\n\t\tid: string;\n\t\t/** What the button does, read before the current value, such as \"Edit assignee\". */\n\t\tlabel: string;\n\t\t/** The popover's content: the app's form, its described options and its submit. */\n\t\tcontent: RemixNode;\n\t}\n\n\t/** Every native `<div>` attribute the row's group accepts, plus its label and value. */\n\texport interface ItemProps extends Omit<TagProps<\"div\">, \"children\"> {\n\t\t/** The property's name, rendered in the `<dt>`. */\n\t\tlabel: RemixNode;\n\t\t/**\n\t\t * What the row says when `children` is empty, such as \"None\" or \"No reviews\".\n\t\t *\n\t\t * @default \"—\"\n\t\t */\n\t\tempty?: RemixNode;\n\t\t/** Turns the value into a button opening an anchored edit popover. */\n\t\tedit?: Edit;\n\t\t/** The value: text, a link, a badge, an avatar with a name. */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Whether `node` renders nothing a reader would see, which is when the row shows its\n * named empty value instead.\n *\n * @param node The value a row was given.\n * @returns `true` for `null`, `undefined`, `false`, `\"\"` and a list of those.\n */\nfunction isEmptyValue(node: RemixNode | undefined): boolean {\n\tif (node === null || node === undefined || node === false || node === \"\") return true;\n\tif (Array.isArray(node)) return node.every((child) => isEmptyValue(child));\n\treturn false;\n}\n\n/**\n * Renders the `<dl>`. Each item is a `<div>` grouping one `<dt>` and one `<dd>`, which\n * keeps the label/value pairing in the accessibility tree; the list measures itself as a\n * container, so rows stack in a narrow side pane at any viewport width.\n *\n * @param handle Runtime handle carrying the `<dl>`'s props and providing the variant.\n * @returns The render function producing the list's markup.\n * @example\n * <PropertyList>\n * \t<PropertyList.Item label=\"Status\"><Badge color=\"success\">Up</Badge></PropertyList.Item>\n * \t<PropertyList.Item label=\"Reviewers\" empty=\"No reviews\" />\n * </PropertyList>\n * @example\n * <PropertyList variant=\"tiles\">\n * \t<PropertyList.Item label=\"Uptime\">99.98%</PropertyList.Item>\n * </PropertyList>\n */\nexport function PropertyList(handle: Handle<PropertyList.Props, PropertyList.Context>) {\n\treturn () => {\n\t\tlet { variant, mix, ...rest } = handle.props;\n\t\tlet resolved = variant ?? DEFAULT_VARIANT;\n\t\thandle.context.set({ variant: resolved });\n\n\t\treturn (\n\t\t\t<dl\n\t\t\t\tdata-slot=\"property-list\"\n\t\t\t\tdata-variant={resolved}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tis(\"100%\"),\n\t\t\t\t\t\tcontainer(PROPERTY_LIST_CONTAINER),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\tresolved === \"tiles\"\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\tgrid(),\n\t\t\t\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t * Each tile claims at least half the row, so two fit side by side once\n\t\t\t\t\t\t\t\t\t * both reach 9rem and a narrower list falls back to one column.\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\tgridTemplateColumns:\n\t\t\t\t\t\t\t\t\t\t\t\"repeat(auto-fit, minmax(max(9rem, calc(50% - 0.25rem)), 1fr))\",\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: vstack({ gap: 0 }),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders one property. In the rows variant the label column holds\n * `--ui-property-list-label-width` (9rem) from a 22rem container up and stacks above the\n * value below it; a value-less row names its emptiness in muted text.\n *\n * @param handle Runtime handle carrying the group `<div>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <PropertyList.Item label=\"Owner\"><a href=\"/people/ana\">Ana Souza</a></PropertyList.Item>\n * @example\n * <PropertyList.Item\n * \tlabel=\"Assignee\"\n * \tempty=\"No one\"\n * \tedit={{ id: \"edit-assignee\", label: \"Edit assignee\", content: <AssigneeForm /> }}\n * >\n * \t{assignee?.name}\n * </PropertyList.Item>\n */\nPropertyList.Item = function PropertyListItem(handle: Handle<PropertyList.ItemProps>) {\n\treturn () => {\n\t\tlet { label, empty, edit, children, mix, ...rest } = handle.props;\n\t\tlet { variant } = handle.context.get(PropertyList);\n\t\tlet tiles = variant === \"tiles\";\n\t\tlet isEmpty = isEmptyValue(children);\n\n\t\tlet value = isEmpty ? (\n\t\t\t<span data-slot=\"property-empty\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t{empty ?? DEFAULT_EMPTY}\n\t\t\t</span>\n\t\t) : (\n\t\t\tchildren\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"property\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\ttiles\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tvstack({ gap: 1 }),\n\t\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tgrid(),\n\t\t\t\t\t\t\t\tpb(1),\n\t\t\t\t\t\t\t\titems(\"baseline\"),\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * The stacked and side-by-side tracks live in one rule, so the label column\n\t\t\t\t\t\t\t\t * holds at its width whatever order the stylesheet layers land in.\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\tgridTemplateColumns: \"minmax(0, 1fr)\",\n\t\t\t\t\t\t\t\t\trowGap: \"0.125rem\",\n\t\t\t\t\t\t\t\t\t[`@container ${PROPERTY_LIST_CONTAINER} (min-width: 22rem)`]: {\n\t\t\t\t\t\t\t\t\t\tgridTemplateColumns: \"var(--ui-property-list-label-width, 9rem) minmax(0, 1fr)\",\n\t\t\t\t\t\t\t\t\t\tcolumnGap: \"1rem\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<dt\n\t\t\t\t\tdata-slot=\"property-label\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\ttiles ? text(\"xs\") : text(\"sm\"),\n\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\tpb(tiles ? 0 : 1.5),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</dt>\n\t\t\t\t<dd\n\t\t\t\t\tdata-slot=\"property-value\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\traw({ flexWrap: \"wrap\" }),\n\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\ttiles ? [text(\"lg\"), weight(\"semibold\")] : null,\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{edit ? (\n\t\t\t\t\t\t<PropertyEdit edit={edit} empty={isEmpty}>\n\t\t\t\t\t\t\t{value}\n\t\t\t\t\t\t</PropertyEdit>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tvalue\n\t\t\t\t\t)}\n\t\t\t\t</dd>\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/** Props {@link PropertyEdit} reads. */\ninterface PropertyEditProps {\n\tedit: PropertyList.Edit;\n\tempty: boolean;\n\tchildren: RemixNode;\n}\n\n/**\n * The editable value: a full-width button naming its action before the current value,\n * and the popover it opens. The button is the popover's invoker, which makes it the\n * popover's implicit anchor, so the form opens directly under its row.\n *\n * @param handle Runtime handle carrying the edit description and the rendered value.\n * @returns The render function producing the button and its popover.\n */\nfunction PropertyEdit(handle: Handle<PropertyEditProps>) {\n\treturn () => {\n\t\tlet { edit, children } = handle.props;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-slot=\"property-edit\"\n\t\t\t\t\tpopovertarget={edit.id}\n\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"between\"),\n\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\tpi(2),\n\t\t\t\t\t\traw({ marginInline: \"-0.5rem\", inlineSize: \"calc(100% + 1rem)\" }),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"transparent\", width: 0 }),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tfg(),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\ttextAlign(\"start\"),\n\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\ttransition(\"background-color\"),\n\t\t\t\t\t\thover(bg(\"neutral.tint\")),\n\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", width: 2, offset: -2 })),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<span mix={[flex(), items(\"center\"), gap(1.5), raw({ flexWrap: \"wrap\" }), minIs(0)]}>\n\t\t\t\t\t\t<span mix={[visuallyHidden()]}>{`${edit.label}: `}</span>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</span>\n\t\t\t\t\t<ChevronDownIcon size={14} aria-hidden=\"true\" mix={[shrink(0), fg(\"neutral.muted\")]} />\n\t\t\t\t</button>\n\t\t\t\t<Popover\n\t\t\t\t\tid={edit.id}\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-label={edit.label}\n\t\t\t\t\tdata-slot=\"property-popover\"\n\t\t\t\t\tmix={[p(3), is(\"min(20rem, calc(100vw - 2rem))\"), text(\"sm\")]}\n\t\t\t\t>\n\t\t\t\t\t{edit.content}\n\t\t\t\t</Popover>\n\t\t\t</>\n\t\t);\n\t};\n}\n"
|
|
12
|
+
"content": "/**\n * Label/value rows for one record's properties, as a `<dl>`: a fixed label column beside\n * each value that stacks once its container narrows, empty values named in words, and an\n * editable row whose value opens an anchored native popover holding the app's own form.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { ChevronDownIcon } from \"@sdxc/icons\";\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, transition } from \"@sdxc/u/effects\";\nimport { cursor, raw, mergeMix } from \"@sdxc/u/general\";\nimport { container, flex, gap, grid, items, justify, shrink, vstack } from \"@sdxc/u/layout\";\nimport { is, m, minBs, minIs, p, pb, pi } from \"@sdxc/u/size\";\nimport { focusVisible, hover } from \"@sdxc/u/state\";\nimport { leading, tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Popover } from \"@sdxc/ui/popover\";\n\n/** Container the list names, so its rows stack against the list's own width. */\nconst PROPERTY_LIST_CONTAINER = \"ui-property-list\";\n\n/** Layout a list takes when `variant` is left unset. */\nconst DEFAULT_VARIANT: PropertyList.Variant = \"rows\";\n\n/** Shown for a value the caller leaves empty and names no empty text for. */\nconst DEFAULT_EMPTY = \"—\";\n\n/**\n * Prop types for {@link PropertyList} and its compound parts.\n */\nexport namespace PropertyList {\n\t/**\n\t * `\"rows\"` sets each label beside its value in a ruled-free column; `\"tiles\"` sets each\n\t * property in its own bordered tile, two to a row, for a record's headline figures.\n\t */\n\texport type Variant = \"rows\" | \"tiles\";\n\n\t/** What {@link PropertyList} shares with its items. */\n\texport interface Context {\n\t\tvariant: Variant;\n\t}\n\n\t/** Every native `<dl>` attribute, plus the layout variant. */\n\texport interface Props extends TagProps<\"dl\"> {\n\t\t/** @default {@link DEFAULT_VARIANT} */\n\t\tvariant?: Variant;\n\t}\n\n\t/**\n\t * Makes a row editable in place: its value becomes a button that opens a popover\n\t * anchored under it, holding whatever form the app renders as `content`, or the app's\n\t * own popover given as `popover`.\n\t */\n\texport interface Edit {\n\t\t/** Id of the popover, which the value button targets. */\n\t\tid: string;\n\t\t/** What the button does, read before the current value, such as \"Edit assignee\". */\n\t\tlabel: string;\n\t\t/** The popover's content: the app's form, its described options and its submit. */\n\t\tcontent?: RemixNode;\n\t\t/**\n\t\t * A whole popover whose `id` is `id`, drawn in place of the row's own and its `content`,\n\t\t * such as a `FilterMenu.Popover` picker for a multi-value property; the value button\n\t\t * still opens it and anchors it under the row.\n\t\t */\n\t\tpopover?: RemixNode;\n\t}\n\n\t/** Every native `<div>` attribute the row's group accepts, plus its label and value. */\n\texport interface ItemProps extends Omit<TagProps<\"div\">, \"children\"> {\n\t\t/** The property's name, rendered in the `<dt>`. */\n\t\tlabel: RemixNode;\n\t\t/**\n\t\t * What the row says when `children` is empty, such as \"None\" or \"No reviews\".\n\t\t *\n\t\t * @default \"—\"\n\t\t */\n\t\tempty?: RemixNode;\n\t\t/** Turns the value into a button opening an anchored edit popover. */\n\t\tedit?: Edit;\n\t\t/** The value: text, a link, a badge, an avatar with a name. */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Whether `node` renders nothing a reader would see, which is when the row shows its\n * named empty value instead.\n *\n * @param node The value a row was given.\n * @returns `true` for `null`, `undefined`, `false`, `\"\"` and a list of those.\n */\nfunction isEmptyValue(node: RemixNode | undefined): boolean {\n\tif (node === null || node === undefined || node === false || node === \"\") return true;\n\tif (Array.isArray(node)) return node.every((child) => isEmptyValue(child));\n\treturn false;\n}\n\n/**\n * Renders the `<dl>`. Each item is a `<div>` grouping one `<dt>` and one `<dd>`, which\n * keeps the label/value pairing in the accessibility tree; the list measures itself as a\n * container, so rows stack in a narrow side pane at any viewport width.\n *\n * @param handle Runtime handle carrying the `<dl>`'s props and providing the variant.\n * @returns The render function producing the list's markup.\n * @example\n * <PropertyList>\n * \t<PropertyList.Item label=\"Status\"><Badge color=\"success\">Up</Badge></PropertyList.Item>\n * \t<PropertyList.Item label=\"Reviewers\" empty=\"No reviews\" />\n * </PropertyList>\n * @example\n * <PropertyList variant=\"tiles\">\n * \t<PropertyList.Item label=\"Uptime\">99.98%</PropertyList.Item>\n * </PropertyList>\n */\nexport function PropertyList(handle: Handle<PropertyList.Props, PropertyList.Context>) {\n\treturn () => {\n\t\tlet { variant, mix, ...rest } = handle.props;\n\t\tlet resolved = variant ?? DEFAULT_VARIANT;\n\t\thandle.context.set({ variant: resolved });\n\n\t\treturn (\n\t\t\t<dl\n\t\t\t\tdata-slot=\"property-list\"\n\t\t\t\tdata-variant={resolved}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tis(\"100%\"),\n\t\t\t\t\t\tcontainer(PROPERTY_LIST_CONTAINER),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\tresolved === \"tiles\"\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\tgrid(),\n\t\t\t\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t * Each tile claims at least half the row, so two fit side by side once\n\t\t\t\t\t\t\t\t\t * both reach 9rem and a narrower list falls back to one column.\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\tgridTemplateColumns:\n\t\t\t\t\t\t\t\t\t\t\t\"repeat(auto-fit, minmax(max(9rem, calc(50% - 0.25rem)), 1fr))\",\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: vstack({ gap: 0 }),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders one property. In the rows variant the label column holds `--ui-property-list-label-width`\n * (9rem) from a 22rem container up and stacks over the value below that; an empty row says so.\n * With `edit`, the value opens a Popover API popover with no script: the row's own or `popover`.\n *\n * @param handle Runtime handle carrying the group `<div>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <PropertyList.Item label=\"Owner\"><a href=\"/people/ana\">Ana Souza</a></PropertyList.Item>\n * @example\n * <PropertyList.Item\n * \tlabel=\"Assignee\"\n * \tempty=\"No one\"\n * \tedit={{ id: \"edit-assignee\", label: \"Edit assignee\", content: <AssigneeForm /> }}\n * >\n * \t{assignee?.name}\n * </PropertyList.Item>\n * @example\n * <PropertyList.Item label=\"Labels\" empty=\"None yet\"\n * \tedit={{ id: \"edit-labels\", label: \"Edit labels\", popover: <FilterMenu.Popover id=\"edit-labels\" {...picker} /> }}>\n * \t{chips}\n * </PropertyList.Item>\n */\nPropertyList.Item = function PropertyListItem(handle: Handle<PropertyList.ItemProps>) {\n\treturn () => {\n\t\tlet { label, empty, edit, children, mix, ...rest } = handle.props;\n\t\tlet { variant } = handle.context.get(PropertyList);\n\t\tlet tiles = variant === \"tiles\";\n\t\tlet isEmpty = isEmptyValue(children);\n\n\t\tlet value = isEmpty ? (\n\t\t\t<span data-slot=\"property-empty\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t{empty ?? DEFAULT_EMPTY}\n\t\t\t</span>\n\t\t) : (\n\t\t\tchildren\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"property\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\ttiles\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tvstack({ gap: 1 }),\n\t\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tgrid(),\n\t\t\t\t\t\t\t\tpb(1),\n\t\t\t\t\t\t\t\titems(\"baseline\"),\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * The stacked and side-by-side tracks live in one rule, so the label column\n\t\t\t\t\t\t\t\t * holds at its width whatever order the stylesheet layers land in.\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\tgridTemplateColumns: \"minmax(0, 1fr)\",\n\t\t\t\t\t\t\t\t\trowGap: \"0.125rem\",\n\t\t\t\t\t\t\t\t\t[`@container ${PROPERTY_LIST_CONTAINER} (min-width: 22rem)`]: {\n\t\t\t\t\t\t\t\t\t\tgridTemplateColumns: \"var(--ui-property-list-label-width, 9rem) minmax(0, 1fr)\",\n\t\t\t\t\t\t\t\t\t\tcolumnGap: \"1rem\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<dt\n\t\t\t\t\tdata-slot=\"property-label\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\ttiles ? text(\"xs\") : text(\"sm\"),\n\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\tpb(tiles ? 0 : 1.5),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</dt>\n\t\t\t\t<dd\n\t\t\t\t\tdata-slot=\"property-value\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\traw({ flexWrap: \"wrap\" }),\n\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\ttiles ? [text(\"lg\"), weight(\"semibold\")] : null,\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{edit ? (\n\t\t\t\t\t\t<PropertyEdit edit={edit} empty={isEmpty}>\n\t\t\t\t\t\t\t{value}\n\t\t\t\t\t\t</PropertyEdit>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tvalue\n\t\t\t\t\t)}\n\t\t\t\t</dd>\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/** Props {@link PropertyEdit} reads. */\ninterface PropertyEditProps {\n\tedit: PropertyList.Edit;\n\tempty: boolean;\n\tchildren: RemixNode;\n}\n\n/**\n * The editable value: a full-width button naming its action before the current value,\n * and the popover it opens, the row's own or the app's. The button is the popover's\n * invoker, which makes it the popover's implicit anchor, so it opens under its row.\n *\n * @param handle Runtime handle carrying the edit description and the rendered value.\n * @returns The render function producing the button and its popover.\n */\nfunction PropertyEdit(handle: Handle<PropertyEditProps>) {\n\treturn () => {\n\t\tlet { edit, children } = handle.props;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-slot=\"property-edit\"\n\t\t\t\t\tpopovertarget={edit.id}\n\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"between\"),\n\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\tpi(2),\n\t\t\t\t\t\traw({ marginInline: \"-0.5rem\", inlineSize: \"calc(100% + 1rem)\" }),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"transparent\", width: 0 }),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tfg(),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\ttextAlign(\"start\"),\n\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\ttransition(\"background-color\"),\n\t\t\t\t\t\thover(bg(\"neutral.tint\")),\n\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", width: 2, offset: -2 })),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<span mix={[flex(), items(\"center\"), gap(1.5), raw({ flexWrap: \"wrap\" }), minIs(0)]}>\n\t\t\t\t\t\t<span mix={[visuallyHidden()]}>{`${edit.label}: `}</span>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</span>\n\t\t\t\t\t<ChevronDownIcon size={14} aria-hidden=\"true\" mix={[shrink(0), fg(\"neutral.muted\")]} />\n\t\t\t\t</button>\n\t\t\t\t{edit.popover ?? (\n\t\t\t\t\t<Popover\n\t\t\t\t\t\tid={edit.id}\n\t\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\t\taria-label={edit.label}\n\t\t\t\t\t\tdata-slot=\"property-popover\"\n\t\t\t\t\t\tmix={[p(3), is(\"min(20rem, calc(100vw - 2rem))\"), text(\"sm\")]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{edit.content}\n\t\t\t\t\t</Popover>\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t};\n}\n"
|
|
13
13
|
},
|
|
14
14
|
"test": {
|
|
15
15
|
"path": "property-list.browser.test.tsx",
|
|
16
|
-
"content": "/**\n * Lays PropertyList out in a real browser: the label column holds one width down every\n * row and stacks in a narrow container, an empty value reads its name, the edit popover\n * opens under its own row, and
|
|
16
|
+
"content": "/**\n * Lays PropertyList out in a real browser: the label column holds one width down every\n * row and stacks in a narrow container, an empty value reads its name, the edit popover\n * opens under its own row or gives way to the app's, and tiles go two-up only where they fit.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, beforeEach, describe, expect, test } from \"vitest\";\nimport { page, userEvent } from \"vitest/browser\";\n\nimport { PropertyList } from \"@sdxc/ui/property-list\";\n\n/** Mounts `node` in a host `width` pixels wide and returns the host. */\nfunction mount(node: JSX.Element, width = 480): HTMLElement {\n\tlet host = document.createElement(\"div\");\n\thost.style.width = `${width}px`;\n\tdocument.body.appendChild(host);\n\trender(node, { container: host });\n\treturn host;\n}\n\n/** A monitor's properties, one of them editable and one of them empty. */\nfunction Monitor() {\n\treturn () => (\n\t\t<PropertyList>\n\t\t\t<PropertyList.Item label=\"Status\">Up</PropertyList.Item>\n\t\t\t<PropertyList.Item label=\"Region\">Frankfurt, São Paulo and Singapore</PropertyList.Item>\n\t\t\t<PropertyList.Item label=\"Reviewers\" empty=\"No reviews\" />\n\t\t\t<PropertyList.Item\n\t\t\t\tlabel=\"Owner\"\n\t\t\t\tedit={{\n\t\t\t\t\tid: \"edit-owner\",\n\t\t\t\t\tlabel: \"Edit owner\",\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<form>\n\t\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t\t<input type=\"radio\" name=\"owner\" value=\"ana\" /> Ana\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t),\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\tAna Souza\n\t\t\t</PropertyList.Item>\n\t\t</PropertyList>\n\t);\n}\n\n/** The value cells, in source order. */\nfunction values(host: HTMLElement): HTMLElement[] {\n\treturn [...host.querySelectorAll<HTMLElement>(\"dd\")];\n}\n\nbeforeEach(async () => {\n\tawait page.viewport(1280, 800);\n});\n\nafterEach(() => {\n\tdocument.body.replaceChildren();\n});\n\ndescribe(\"PropertyList\", () => {\n\ttest(\"fills a flex row it sits in, though it measures its own width\", () => {\n\t\tlet host = mount(<Monitor />);\n\t\thost.style.display = \"flex\";\n\n\t\texpect(host.querySelector(\"dl\")!.getBoundingClientRect().width).toBeCloseTo(480, 0);\n\t});\n\n\ttest(\"pairs each label and value in a description list\", () => {\n\t\tlet host = mount(<Monitor />);\n\t\tlet list = host.querySelector(\"dl\")!;\n\n\t\texpect(list.querySelectorAll(\":scope > div > dt\")).toHaveLength(4);\n\t\texpect(list.querySelectorAll(\":scope > div > dd\")).toHaveLength(4);\n\t});\n\n\ttest(\"starts every value at the same inline offset beside a fixed label column\", () => {\n\t\tlet host = mount(<Monitor />);\n\t\tlet lefts = values(host).map((dd) => Math.round(dd.getBoundingClientRect().left));\n\t\tlet label = host.querySelector(\"dt\")!.getBoundingClientRect();\n\t\tlet row = host.querySelector(\"dt\")!.parentElement!.getBoundingClientRect();\n\n\t\texpect(new Set(lefts).size).toBe(1);\n\t\texpect(label.width).toBeCloseTo(144, 0);\n\t\texpect(lefts[0]! - row.left).toBeCloseTo(144 + 16, 0);\n\t});\n\n\ttest(\"stacks each label above its value in a narrow container\", () => {\n\t\tlet host = mount(<Monitor />, 300);\n\t\tlet label = host.querySelector(\"dt\")!.getBoundingClientRect();\n\t\tlet value = host.querySelector(\"dd\")!.getBoundingClientRect();\n\n\t\texpect(value.top).toBeGreaterThanOrEqual(label.bottom - 1);\n\t\texpect(value.left).toBeCloseTo(label.left, 0);\n\t\texpect(document.documentElement.scrollWidth).toBeLessThanOrEqual(window.innerWidth);\n\t});\n\n\ttest(\"names an empty value in muted words\", () => {\n\t\tlet host = mount(<Monitor />);\n\t\tlet empty = host.querySelector('[data-slot=\"property-empty\"]')!;\n\n\t\texpect(empty.textContent).toBe(\"No reviews\");\n\t\texpect(empty.closest(\"dd\")?.previousElementSibling?.textContent).toBe(\"Reviewers\");\n\t});\n\n\ttest(\"falls back to an em dash for an empty value with no name\", () => {\n\t\tlet host = mount(\n\t\t\t<PropertyList>\n\t\t\t\t<PropertyList.Item label=\"Last check\">{null}</PropertyList.Item>\n\t\t\t</PropertyList>,\n\t\t);\n\n\t\texpect(host.querySelector(\"dd\")?.textContent).toBe(\"—\");\n\t});\n\n\ttest(\"opens the edit popover anchored under its own row\", async () => {\n\t\tlet host = mount(<Monitor />);\n\t\tlet button = host.querySelector<HTMLButtonElement>('[data-slot=\"property-edit\"]')!;\n\t\tlet popover = host.querySelector<HTMLElement>(\"#edit-owner\")!;\n\n\t\texpect(button.getAttribute(\"popovertarget\")).toBe(\"edit-owner\");\n\t\texpect(button.textContent).toContain(\"Edit owner: Ana Souza\");\n\n\t\tawait userEvent.click(button);\n\t\texpect(popover.matches(\":popover-open\")).toBe(true);\n\n\t\tlet anchor = button.getBoundingClientRect();\n\t\tlet box = popover.getBoundingClientRect();\n\t\texpect(box.top).toBeGreaterThanOrEqual(anchor.bottom);\n\t\texpect(box.top - anchor.bottom).toBeLessThan(12);\n\t\texpect(box.left).toBeCloseTo(anchor.left, 0);\n\t\texpect(popover.getAttribute(\"aria-label\")).toBe(\"Edit owner\");\n\t});\n\n\ttest(\"opens the app's own popover in place of the row's\", async () => {\n\t\tlet host = mount(\n\t\t\t<PropertyList>\n\t\t\t\t<PropertyList.Item\n\t\t\t\t\tlabel=\"Labels\"\n\t\t\t\t\tedit={{\n\t\t\t\t\t\tid: \"edit-labels\",\n\t\t\t\t\t\tlabel: \"Edit labels\",\n\t\t\t\t\t\tpopover: (\n\t\t\t\t\t\t\t<div id=\"edit-labels\" popover=\"auto\" data-slot=\"app-picker\">\n\t\t\t\t\t\t\t\tPicker\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t),\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\tbug\n\t\t\t\t</PropertyList.Item>\n\t\t\t</PropertyList>,\n\t\t);\n\t\tlet button = host.querySelector<HTMLButtonElement>('[data-slot=\"property-edit\"]')!;\n\t\tlet picker = host.querySelector<HTMLElement>('[data-slot=\"app-picker\"]')!;\n\n\t\texpect(host.querySelector('[data-slot=\"property-popover\"]')).toBeNull();\n\t\tawait userEvent.click(button);\n\t\texpect(picker.matches(\":popover-open\")).toBe(true);\n\t});\n\n\ttest(\"sets tiles two to a row only where two fit\", () => {\n\t\tlet tiles = (\n\t\t\t<PropertyList variant=\"tiles\">\n\t\t\t\t<PropertyList.Item label=\"Uptime\">99.98%</PropertyList.Item>\n\t\t\t\t<PropertyList.Item label=\"Response\">212 ms</PropertyList.Item>\n\t\t\t</PropertyList>\n\t\t);\n\t\tlet wide = mount(tiles, 480);\n\t\tlet [first, second] = [...wide.querySelectorAll(\"dl > div\")].map((tile) =>\n\t\t\ttile.getBoundingClientRect(),\n\t\t);\n\t\texpect(second!.top).toBeCloseTo(first!.top, 0);\n\t\texpect(second!.left).toBeGreaterThan(first!.right);\n\n\t\tdocument.body.replaceChildren();\n\t\tlet narrow = mount(tiles, 280);\n\t\tlet [top, bottom] = [...narrow.querySelectorAll(\"dl > div\")].map((tile) =>\n\t\t\ttile.getBoundingClientRect(),\n\t\t);\n\t\texpect(bottom!.top).toBeGreaterThan(top!.bottom - 1);\n\t});\n});\n"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textarea",
|
|
3
|
-
"changedIn": "2026.11.
|
|
3
|
+
"changedIn": "2026.11.14",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"TextArea"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "textarea.tsx",
|
|
10
|
-
"content": "/**\n * A multi-line native form field for free text entry, rendered as a bordered,\n * rounded `<textarea>` that shares {@link Input}'s border, background, and\n * focus-ring contract. It starts at a comfortable minimum block size and\n * grows with its content through `field-sizing: content`, so a reply box or\n * a comment field never clips what's already been typed.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { border, bg, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, opacity } from \"@sdxc/u/effects\";\nimport { cursor, raw, mergeMix } from \"@sdxc/u/general\";\nimport { block } from \"@sdxc/u/layout\";\nimport { is, bs, minBs, pi, pb } from \"@sdxc/u/size\";\nimport { when, hover, invalid } from \"@sdxc/u/state\";\nimport { text } from \"@sdxc/u/typography\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\n\n/** Semantic color role {@link TextArea} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: TextArea.Color = \"neutral\";\n\n/**\n * Prop types for {@link TextArea}.\n */\nexport namespace TextArea {\n\t/**\n\t * Semantic color role for the focus-visible ring, each mapped to its\n\t * matching `--ui-*` variables. A field marked invalid always reads the\n\t * danger tone for its ring instead, regardless of `color`.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Every native `<textarea>` attribute, unchanged, plus the `mix`\n\t * passthrough. `aria-invalid` together with the platform's own\n\t * post-interaction validity state drives the invalid styling.\n\t */\n\texport type Props = TagProps<\"textarea\"> & {\n\t\t/** Semantic color role for the focus-visible ring. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t};\n}\n\n/**\n * Renders a native `<textarea>` host styled as a bordered, rounded field,\n * colored through the `data-color` attribute contract — the same visual\n * language as {@link Input}, rendering only the field itself.\n *\n * @param handle Runtime handle carrying the host `<textarea>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"bio\">{t(\"form.bio.label\")}</Label>\n * <TextArea id=\"bio\" name=\"bio\" />\n * @example\n * <TextArea\n * \taria-label={t(\"form.comment.label\")}\n * \tcolor=\"brand\"\n * \tplaceholder={t(\"form.comment.placeholder\")}\n * />\n * @example\n * <TextArea id=\"notes\" aria-describedby=\"notes-error\" aria-invalid=\"true\" />\n * <FieldError id=\"notes-error\">{t(\"form.notes.tooLong\")}</FieldError>\n */\nexport function TextArea(handle: Handle<TextArea.Props>) {\n\treturn () => {\n\t\tlet { color, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<textarea\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\tblock(),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tbs(\"auto\"),\n\t\t\t\t\t\tminBs(\"6rem\"),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\t\tbg(\"neutral.bg-tint\"),\n\t\t\t\t\t\tfg(\"neutral.fg-emphasis\"),\n\t\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\t\tpb(\"0.5rem\"),\n\t\t\t\t\t\twhen(\"&::placeholder\", fg(\"neutral.fg-muted\")),\n\t\t\t\t\t\thover(border(\"neutral.border-strong\")),\n\t\t\t\t\t\twhen(\"&:focus\", border(\"neutral.border-strong\")),\n\t\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\t\toutline({ color: \"neutral.ring\", offset: 0 }),\n\t\t\t\t\t\t\tborder(\"neutral.border-strong\"),\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tborder(\"brand.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tborder(\"success.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"success.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tborder(\"warning.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"warning.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tborder(\"danger.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"danger.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tinvalid([outline({ color: \"danger.ring\", offset: 0 }), border(\"danger.border-strong\")]),\n\t\t\t\t\t\twhen(\"&:disabled\", [opacity(50), bg(\"neutral.bg-tint-hover\"), cursor(\"not-allowed\")]),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tresize: \"block\",\n\t\t\t\t\t\t\tfieldSizing: \"content\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:focus\", outline(\"none\")),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
10
|
+
"content": "/**\n * A multi-line native form field for free text entry, rendered as a bordered,\n * rounded `<textarea>` that shares {@link Input}'s border, background, and\n * focus-ring contract. It starts at a comfortable minimum block size and\n * grows with its content through `field-sizing: content`, so a reply box or\n * a comment field never clips what's already been typed.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { border, bg, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, opacity } from \"@sdxc/u/effects\";\nimport { cursor, raw, mergeMix } from \"@sdxc/u/general\";\nimport { block } from \"@sdxc/u/layout\";\nimport { is, bs, minBs, pi, pb } from \"@sdxc/u/size\";\nimport { when, hover, invalid } from \"@sdxc/u/state\";\nimport { text } from \"@sdxc/u/typography\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\n\n/** Semantic color role {@link TextArea} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: TextArea.Color = \"neutral\";\n\n/**\n * Prop types for {@link TextArea}.\n */\nexport namespace TextArea {\n\t/**\n\t * Semantic color role for the focus-visible ring, each mapped to its\n\t * matching `--ui-*` variables. A field marked invalid always reads the\n\t * danger tone for its ring instead, regardless of `color`.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Every native `<textarea>` attribute, unchanged, plus the `mix`\n\t * passthrough. `aria-invalid` together with the platform's own\n\t * post-interaction validity state drives the invalid styling.\n\t */\n\texport type Props = TagProps<\"textarea\"> & {\n\t\t/** Semantic color role for the focus-visible ring. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t};\n}\n\n/**\n * Renders a native `<textarea>` host styled as a bordered, rounded field,\n * colored through the `data-color` attribute contract — the same visual\n * language as {@link Input}, rendering only the field itself.\n *\n * @param handle Runtime handle carrying the host `<textarea>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"bio\">{t(\"form.bio.label\")}</Label>\n * <TextArea id=\"bio\" name=\"bio\" />\n * @example\n * <TextArea\n * \taria-label={t(\"form.comment.label\")}\n * \tcolor=\"brand\"\n * \tplaceholder={t(\"form.comment.placeholder\")}\n * />\n * @example\n * <TextArea id=\"notes\" aria-describedby=\"notes-error\" aria-invalid=\"true\" />\n * <FieldError id=\"notes-error\">{t(\"form.notes.tooLong\")}</FieldError>\n */\nexport function TextArea(handle: Handle<TextArea.Props>) {\n\treturn () => {\n\t\tlet { color, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<textarea\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\tblock(),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tbs(\"auto\"),\n\t\t\t\t\t\tminBs(\"6rem\"),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\t\tbg(\"neutral.bg-tint\"),\n\t\t\t\t\t\tfg(\"neutral.fg-emphasis\"),\n\t\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\t\tpb(\"0.5rem\"),\n\t\t\t\t\t\twhen(\"&::placeholder\", fg(\"neutral.fg-muted\")),\n\t\t\t\t\t\thover(border(\"neutral.border-strong\")),\n\t\t\t\t\t\twhen(\"&:focus\", border(\"neutral.border-strong\")),\n\t\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\t\toutline({ color: \"neutral.ring\", offset: 0 }),\n\t\t\t\t\t\t\tborder(\"neutral.border-strong\"),\n\t\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\t\tborder(\"brand.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\t\tborder(\"success.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"success.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\t\tborder(\"warning.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"warning.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\t\tborder(\"danger.border-strong\"),\n\t\t\t\t\t\t\t\toutline({ color: \"danger.ring\", offset: 0 }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tinvalid([outline({ color: \"danger.ring\", offset: 0 }), border(\"danger.border-strong\")]),\n\t\t\t\t\t\twhen(\"&:disabled\", [opacity(50), bg(\"neutral.bg-tint-hover\"), cursor(\"not-allowed\")]),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tresize: \"block\",\n\t\t\t\t\t\t\tfieldSizing: \"content\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Pointer focus drops the platform outline and keyboard focus keeps the ring above:\n\t\t\t\t\t\t * `outline: none` is a shorthand, and from a later cascade layer it would reset the\n\t\t\t\t\t\t * ring's color, width and style at once.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&:focus:not(:focus-visible)\", outline(\"none\")),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
|
-
"test":
|
|
12
|
+
"test": {
|
|
13
|
+
"path": "textarea.browser.test.tsx",
|
|
14
|
+
"content": "/**\n * Holds a text area to the focus contract in a real browser: keyboard focus draws the ring of\n * its colour role, so a reader always sees where typing will land.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\nimport type { RenderResult } from \"remix/component/test\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { userEvent } from \"vitest/browser\";\n\nimport { TextArea } from \"@sdxc/ui/textarea\";\n\nimport \"@sdxc/ui/reset.css\";\nimport \"@sdxc/ui/theme.css\";\n\nlet mounted: RenderResult | undefined;\n\nafterEach(() => {\n\tmounted?.cleanup();\n\tmounted = undefined;\n\tdocument.body.replaceChildren();\n});\n\ndescribe(\"TextArea\", () => {\n\ttest(\"draws a ring on keyboard focus\", async () => {\n\t\tmounted = render(\n\t\t\t<div>\n\t\t\t\t<button type=\"button\">Before</button>\n\t\t\t\t<TextArea aria-label=\"Reply\" />\n\t\t\t</div>,\n\t\t);\n\t\tmounted.container.querySelector(\"button\")!.focus();\n\t\tawait userEvent.keyboard(\"{Tab}\");\n\t\tlet field = document.activeElement as HTMLTextAreaElement;\n\n\t\texpect(field.tagName).toBe(\"TEXTAREA\");\n\t\texpect(getComputedStyle(field).outlineStyle).toBe(\"solid\");\n\t\texpect(Number.parseFloat(getComputedStyle(field).outlineWidth)).toBeGreaterThanOrEqual(2);\n\t});\n});\n"
|
|
15
|
+
}
|
|
13
16
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timeline",
|
|
3
|
-
"changedIn": "2026.11.
|
|
3
|
+
"changedIn": "2026.11.14",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Timeline"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "timeline.tsx",
|
|
10
|
-
"content": "/**\n * A record's activity as an ordered list: a 2px rail threading 16px event icons toned by\n * what happened, one line per event (avatar, bold actor, muted verb, time), an optional\n * comment card, and a native `<details>` folding a run of quiet events into \"N more\".\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { EllipsisIcon } from \"@sdxc/icons\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, pseudoContent, raw, mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, grid, inlineFlex, items, justify, relative, vstack } from \"@sdxc/u/layout\";\nimport { bs, is, m, minIs, p } from \"@sdxc/u/size\";\nimport { before, data, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { leading, text, weight } from \"@sdxc/u/typography\";\n\n/** The side of the square each event's icon sits centred in; the rail runs through its middle. */\nconst ICON_BOX = \"var(--ui-timeline-icon-box, 1.5rem)\";\n\n/** Tone an event's icon takes when `tone` is left unset. */\nconst DEFAULT_TONE: Timeline.Tone = \"neutral\";\n\n/**\n * Prop types for {@link Timeline} and its compound parts.\n */\nexport namespace Timeline {\n\t/** The semantic role an event's icon is drawn in. */\n\texport type Tone = \"neutral\" | \"brand\" | \"success\" | \"warning\" | \"danger\";\n\n\t/** Every native `<ol>` attribute. */\n\texport interface Props extends TagProps<\"ol\"> {}\n\n\t/** Every native `<li>` attribute, plus the event's parts. */\n\texport interface EventProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** A 16px glyph naming the kind of event, decorative beside the line's words. */\n\t\ticon: RemixNode;\n\t\t/** @default {@link DEFAULT_TONE} */\n\t\ttone?: Tone;\n\t\t/** A small avatar of the actor, shown before the name. */\n\t\tavatar?: RemixNode;\n\t\t/** Who did it, set in bold. */\n\t\tactor?: RemixNode;\n\t\t/** When it happened: a `RelativeTime` or plain text. */\n\t\ttime?: RemixNode;\n\t\t/** A comment or other body, set as a card under the line. */\n\t\tbody?: RemixNode;\n\t\t/** What happened, in muted text after the actor: \"resolved the incident\". */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the folded events. */\n\texport interface MoreProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** The disclosure's label, such as \"4 more events\". */\n\t\tsummary: RemixNode;\n\t\t/** Starts unfolded. */\n\t\topen?: boolean;\n\t\t/** The folded {@link Timeline.Event} items. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * The two-column track every row shares: the icon box, then the line. Folded events use\n * it too, so their icons stay on the one rail the list draws.\n */\nfunction rowTrack() {\n\treturn [\n\t\tgrid(),\n\t\traw({ gridTemplateColumns: `${ICON_BOX} minmax(0, 1fr)` }),\n\t\tgap(3),\n\t\traw({ rowGap: \"0.5rem\" }),\n\t\titems(\"start\"),\n\t];\n}\n\n/**\n * Renders the `<ol>` and its rail. The rail is drawn once, behind every icon from the\n * first to the last, so a folded run keeps the line continuous when it opens; icons sit on\n * the page's background, `--ui-timeline-surface`, which masks the rail where they meet it.\n *\n * @param handle Runtime handle carrying the `<ol>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Timeline>\n * \t<Timeline.Event icon={<CircleDotIcon />} tone=\"danger\" actor=\"Uptime\" time={<RelativeTime date={opened} />}>\n * \t\topened the incident\n * \t</Timeline.Event>\n * \t<Timeline.Event icon={<MessageSquareIcon />} avatar={<Avatar size=\"xs\" />} actor=\"Ana\" body={<p>Rolling back.</p>}>\n * \t\tcommented\n * \t</Timeline.Event>\n * </Timeline>\n */\nexport function Timeline(handle: Handle<Timeline.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ol\n\t\t\t\tdata-slot=\"timeline\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tp(0),\n\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\tvstack({ gap: 3 }),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\tbefore([\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\t\tinsetBlock: `calc(${ICON_BOX} / 2)`,\n\t\t\t\t\t\t\t\tinsetInlineStart: `calc(${ICON_BOX} / 2 - 1px)`,\n\t\t\t\t\t\t\t\tinlineSize: \"2px\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders one event: its toned icon on the rail, then a single wrapping line of avatar,\n * actor, description and time, then the body card when one is given.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the event's markup.\n * @example\n * <Timeline.Event icon={<RocketIcon />} tone=\"brand\" actor=\"deploy-bot\" time=\"2m ago\">\n * \tdeployed v4.2.1\n * </Timeline.Event>\n */\nTimeline.Event = function TimelineEvent(handle: Handle<Timeline.EventProps>) {\n\treturn () => {\n\t\tlet { icon, tone, avatar, actor, time, body, children, mix, ...rest } = handle.props;\n\t\tlet resolvedTone = tone ?? DEFAULT_TONE;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-event\"\n\t\t\t\tdata-tone={resolvedTone}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(rowTrack(), mix)}\n\t\t\t>\n\t\t\t\t<TimelineIcon tone={resolvedTone}>{icon}</TimelineIcon>\n\t\t\t\t<div mix={[vstack({ gap: 2 }), minIs(0)]}>\n\t\t\t\t\t<p\n\t\t\t\t\t\tdata-slot=\"timeline-line\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", minBlockSize: ICON_BOX }),\n\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{avatar ? <span mix={[inlineFlex()]}>{avatar}</span> : null}\n\t\t\t\t\t\t{actor ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-actor\" mix={[weight(\"semibold\")]}>\n\t\t\t\t\t\t\t\t{actor}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{children ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-description\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{time ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-time\" mix={[fg(\"neutral.muted\"), text(\"xs\")]}>\n\t\t\t\t\t\t\t\t{time}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</p>\n\t\t\t\t\t{body ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tdata-slot=\"timeline-body\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\"& > :first-child\": { marginBlockStart: 0 },\n\t\t\t\t\t\t\t\t\t\"& > :last-child\": { marginBlockEnd: 0 },\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{body}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders a run of events folded behind a `<details>`: its summary sits on the rail with\n * an ellipsis glyph, and its events open in place, in the same list and on the same rail.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the folded run's markup.\n * @example\n * <Timeline.More summary=\"4 more events\">\n * \t{checks.map((check) => <Timeline.Event icon={<CheckIcon />} actor=\"Uptime\">{check.text}</Timeline.Event>)}\n * </Timeline.More>\n */\nTimeline.More = function TimelineMore(handle: Handle<Timeline.MoreProps>) {\n\treturn () => {\n\t\tlet { summary, open, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li data-slot=\"timeline-more\" {...rest} mix={mergeMix([], mix)}>\n\t\t\t\t<details open={open} mix={[raw({ \"&[open] > summary\": { display: \"none\" } })]}>\n\t\t\t\t\t<summary\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t...rowTrack(),\n\t\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\t\traw({ \"&::-webkit-details-marker\": { display: \"none\" } }),\n\t\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", width: 2, offset: 2 })),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TimelineIcon tone=\"neutral\">\n\t\t\t\t\t\t\t<EllipsisIcon size={16} aria-hidden=\"true\" />\n\t\t\t\t\t\t</TimelineIcon>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\t\t\t\thover(fg(\"neutral.emphasis\")),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{summary}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</summary>\n\t\t\t\t\t<ol mix={[m(0), p(0), listStyle(\"none\"), vstack({ gap: 3 })]}>{children}</ol>\n\t\t\t\t</details>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/** Props {@link TimelineIcon} reads. */\ninterface TimelineIconProps {\n\ttone: Timeline.Tone;\n\tchildren: RemixNode;\n}\n\n/**\n * The icon box on the rail: the glyph in its tone, on the surface colour so the rail\n * reads as passing behind it.\n *\n * @param handle Runtime handle carrying the tone and glyph.\n * @returns The render function producing the icon box.\n */\nfunction TimelineIcon(handle: Handle<TimelineIconProps>) {\n\treturn () => {\n\t\tlet { tone, children } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-icon\"\n\t\t\t\tdata-tone={tone}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tis(ICON_BOX),\n\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tbg(\"var(--ui-timeline-surface, var(--ui-bg, Canvas))\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\tdata(\"tone\", \"brand\", fg(\"brand\")),\n\t\t\t\t\tdata(\"tone\", \"success\", fg(\"success\")),\n\t\t\t\t\tdata(\"tone\", \"warning\", fg(\"warning\")),\n\t\t\t\t\tdata(\"tone\", \"danger\", fg(\"danger\")),\n\t\t\t\t\twhen(\"& > svg\", raw({ inlineSize: \"1rem\", blockSize: \"1rem\" })),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t);\n\t};\n}\n"
|
|
10
|
+
"content": "/**\n * A record's activity as an ordered list: a 2px rail threading 16px event icons toned by\n * what happened, one line per event, comment cards with an author header and reactions,\n * grouped commits, and a native `<details>` folding a run of quiet events into \"N more\".\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { EllipsisIcon } from \"@sdxc/icons\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, pseudoContent, raw, mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, grid, inlineFlex, items, justify, relative, vstack } from \"@sdxc/u/layout\";\nimport { bs, is, m, minIs, p, pi } from \"@sdxc/u/size\";\nimport { before, data, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { font, leading, text, truncate, weight } from \"@sdxc/u/typography\";\n\n/** The side of the square each event's icon sits centred in; the rail runs through its middle. */\nconst ICON_BOX = \"var(--ui-timeline-icon-box, 1.5rem)\";\n\n/** Tone an event's icon takes when `tone` is left unset. */\nconst DEFAULT_TONE: Timeline.Tone = \"neutral\";\n\n/**\n * Prop types for {@link Timeline} and its compound parts.\n */\nexport namespace Timeline {\n\t/** The semantic role an event's icon is drawn in. */\n\texport type Tone = \"neutral\" | \"brand\" | \"success\" | \"warning\" | \"danger\";\n\n\t/** Every native `<ol>` attribute. */\n\texport interface Props extends TagProps<\"ol\"> {}\n\n\t/** Every native `<li>` attribute, plus the event's parts. */\n\texport interface EventProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** A 16px glyph naming the kind of event, decorative beside the line's words. */\n\t\ticon: RemixNode;\n\t\t/** @default {@link DEFAULT_TONE} */\n\t\ttone?: Tone;\n\t\t/** A small avatar of the actor, shown before the name. */\n\t\tavatar?: RemixNode;\n\t\t/** Who did it, set in bold. */\n\t\tactor?: RemixNode;\n\t\t/** When it happened: a `RelativeTime` or plain text. */\n\t\ttime?: RemixNode;\n\t\t/** A comment or other body, set as a card under the line. */\n\t\tbody?: RemixNode;\n\t\t/** What happened, in muted text after the actor: \"resolved the incident\". */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the comment's parts. */\n\texport interface CommentProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** The author's avatar, set on the rail in place of an icon. */\n\t\tavatar: RemixNode;\n\t\t/** The author's name, set in bold at the start of the card's header. */\n\t\tauthor: RemixNode;\n\t\t/** The muted verb after the name: \"commented\", \"reviewed\". */\n\t\taction?: RemixNode;\n\t\t/** When it was written: a `RelativeTime` or plain text. */\n\t\ttime?: RemixNode;\n\t\t/** A `⋯` menu trigger, drawn at the end of the header. */\n\t\tmenu?: RemixNode;\n\t\t/** Reactions or other controls, drawn in a row under the body. */\n\t\treactions?: RemixNode;\n\t\t/** The rendered Markdown body. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the summary line and its commits. */\n\texport interface CommitsProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** A 16px glyph for the group, such as a commit icon. */\n\t\ticon: RemixNode;\n\t\t/** A small avatar of the pusher, shown before the name. */\n\t\tavatar?: RemixNode;\n\t\t/** Who pushed, set in bold. */\n\t\tactor?: RemixNode;\n\t\t/** What happened, muted: \"added 3 commits\". */\n\t\tsummary?: RemixNode;\n\t\t/** When the push happened. */\n\t\ttime?: RemixNode;\n\t\t/** The {@link Timeline.Commit} rows. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the commit's parts. */\n\texport interface CommitProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** The commit's short sha, set in monospace at the end of the row. */\n\t\tsha: string;\n\t\t/** The commit's page; links the subject and the sha. */\n\t\thref?: string;\n\t\t/** A small avatar of the author. */\n\t\tavatar?: RemixNode;\n\t\t/** The commit's checks, such as a toned status icon with its accessible name. */\n\t\tcheck?: RemixNode;\n\t\t/** The commit's subject line. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the folded events. */\n\texport interface MoreProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** The disclosure's label, such as \"4 more events\". */\n\t\tsummary: RemixNode;\n\t\t/** Starts unfolded. */\n\t\topen?: boolean;\n\t\t/** The folded {@link Timeline.Event} items. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * The two-column track every row shares: the icon box, then the line. Folded events use\n * it too, so their icons stay on the one rail the list draws.\n */\nfunction rowTrack() {\n\treturn [\n\t\tgrid(),\n\t\traw({ gridTemplateColumns: `${ICON_BOX} minmax(0, 1fr)` }),\n\t\tgap(3),\n\t\traw({ rowGap: \"0.5rem\" }),\n\t\titems(\"start\"),\n\t];\n}\n\n/**\n * Renders the `<ol>` and its rail, drawn once behind every icon so an opened fold keeps the line\n * whole; icons and {@link Timeline.Comment} cards sit on `--ui-timeline-surface`, masking the rail,\n * in a `--ui-timeline-icon-box` square. {@link Timeline.Commits} groups a push; all of it is HTML.\n *\n * @param handle Runtime handle carrying the `<ol>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Timeline>\n * \t<Timeline.Event icon={<CircleDotIcon />} tone=\"danger\" actor=\"Uptime\" time={<RelativeTime date={opened} />}>\n * \t\topened the incident\n * \t</Timeline.Event>\n * \t<Timeline.Event icon={<MessageSquareIcon />} avatar={<Avatar size=\"xs\" />} actor=\"Ana\" body={<p>Rolling back.</p>}>\n * \t\tcommented\n * \t</Timeline.Event>\n * </Timeline>\n * @example\n * <Timeline aria-label={t(\"pull.conversation\")}>\n * \t<Timeline.Comment id=\"comment-12\" avatar={<Avatar size=\"xs\" />} author=\"ana\" action={t(\"pull.commented\")} time={<RelativeTime date={at} />}>\n * \t\t<Markdown source={body} />\n * \t</Timeline.Comment>\n * \t<Timeline.Commits icon={<GitCommitHorizontalIcon />} actor=\"ana\" summary={t(\"pull.addedCommits\", { count: 1 })}>\n * \t\t<Timeline.Commit sha=\"a1b2c3d\" href=\"/commit/a1b2c3d\">Fix the parser</Timeline.Commit>\n * \t</Timeline.Commits>\n * </Timeline>\n */\nexport function Timeline(handle: Handle<Timeline.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ol\n\t\t\t\tdata-slot=\"timeline\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tp(0),\n\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\tvstack({ gap: 3 }),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\tbefore([\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\t\tinsetBlock: `calc(${ICON_BOX} / 2)`,\n\t\t\t\t\t\t\t\tinsetInlineStart: `calc(${ICON_BOX} / 2 - 1px)`,\n\t\t\t\t\t\t\t\tinlineSize: \"2px\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders one event: its toned icon on the rail, then a single wrapping line of avatar,\n * actor, description and time, then the body card when one is given.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the event's markup.\n * @example\n * <Timeline.Event icon={<RocketIcon />} tone=\"brand\" actor=\"deploy-bot\" time=\"2m ago\">\n * \tdeployed v4.2.1\n * </Timeline.Event>\n */\nTimeline.Event = function TimelineEvent(handle: Handle<Timeline.EventProps>) {\n\treturn () => {\n\t\tlet { icon, tone, avatar, actor, time, body, children, mix, ...rest } = handle.props;\n\t\tlet resolvedTone = tone ?? DEFAULT_TONE;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-event\"\n\t\t\t\tdata-tone={resolvedTone}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(rowTrack(), mix)}\n\t\t\t>\n\t\t\t\t<TimelineIcon tone={resolvedTone}>{icon}</TimelineIcon>\n\t\t\t\t<div mix={[vstack({ gap: 2 }), minIs(0)]}>\n\t\t\t\t\t<p\n\t\t\t\t\t\tdata-slot=\"timeline-line\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", minBlockSize: ICON_BOX }),\n\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{avatar ? <span mix={[inlineFlex()]}>{avatar}</span> : null}\n\t\t\t\t\t\t{actor ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-actor\" mix={[weight(\"semibold\")]}>\n\t\t\t\t\t\t\t\t{actor}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{children ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-description\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{time ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-time\" mix={[fg(\"neutral.muted\"), text(\"xs\")]}>\n\t\t\t\t\t\t\t\t{time}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</p>\n\t\t\t\t\t{body ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tdata-slot=\"timeline-body\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\"& > :first-child\": { marginBlockStart: 0 },\n\t\t\t\t\t\t\t\t\t\"& > :last-child\": { marginBlockEnd: 0 },\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{body}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders a run of events folded behind a `<details>`: its summary sits on the rail with\n * an ellipsis glyph, and its events open in place, in the same list and on the same rail.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the folded run's markup.\n * @example\n * <Timeline.More summary=\"4 more events\">\n * \t{checks.map((check) => <Timeline.Event icon={<CheckIcon />} actor=\"Uptime\">{check.text}</Timeline.Event>)}\n * </Timeline.More>\n */\nTimeline.More = function TimelineMore(handle: Handle<Timeline.MoreProps>) {\n\treturn () => {\n\t\tlet { summary, open, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li data-slot=\"timeline-more\" {...rest} mix={mergeMix([], mix)}>\n\t\t\t\t<details open={open} mix={[raw({ \"&[open] > summary\": { display: \"none\" } })]}>\n\t\t\t\t\t<summary\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t...rowTrack(),\n\t\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\t\traw({ \"&::-webkit-details-marker\": { display: \"none\" } }),\n\t\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", width: 2, offset: 2 })),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TimelineIcon tone=\"neutral\">\n\t\t\t\t\t\t\t<EllipsisIcon size={16} aria-hidden=\"true\" />\n\t\t\t\t\t\t</TimelineIcon>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\t\t\t\thover(fg(\"neutral.emphasis\")),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{summary}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</summary>\n\t\t\t\t\t<ol mix={[m(0), p(0), listStyle(\"none\"), vstack({ gap: 3 })]}>{children}</ol>\n\t\t\t\t</details>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders a comment as a card on the rail: the author's avatar sits where an event's icon\n * would, the header reads \"name action time\" with a `⋯` slot at its end, and the body and\n * reactions follow. A conversation reads as cards and housekeeping as single lines.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the comment's markup.\n * @example\n * <Timeline.Comment id=\"comment-12\" avatar={<Avatar size=\"xs\" />} author=\"ana\" action=\"commented\" time={<RelativeTime date={at} />} menu={<CommentMenu />} reactions={<Reactions />}>\n * \t<Markdown source={body} />\n * </Timeline.Comment>\n */\nTimeline.Comment = function TimelineComment(handle: Handle<Timeline.CommentProps>) {\n\treturn () => {\n\t\tlet { avatar, author, action, time, menu, reactions, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li data-slot=\"timeline-comment\" {...rest} mix={mergeMix(rowTrack(), mix)}>\n\t\t\t\t<span\n\t\t\t\t\tdata-slot=\"timeline-avatar\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tis(ICON_BOX),\n\t\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tbg(\"var(--ui-timeline-surface, var(--ui-bg, Canvas))\"),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{avatar}\n\t\t\t\t</span>\n\t\t\t\t<div\n\t\t\t\t\tdata-slot=\"timeline-card\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\tbg(\"var(--ui-timeline-surface, var(--ui-bg, Canvas))\"),\n\t\t\t\t\t\traw({ overflow: \"clip\" }),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<header\n\t\t\t\t\t\tdata-slot=\"timeline-comment-header\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\t\traw({ minBlockSize: \"2.5rem\", paddingBlock: \"0.375rem\" }),\n\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\traw({ borderBlockEnd: \"1px solid var(--ui-neutral-border)\" }),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"baseline\"),\n\t\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", columnGap: \"0.375rem\", flex: \"1 1 auto\" }),\n\t\t\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span data-slot=\"timeline-actor\" mix={[weight(\"semibold\")]}>\n\t\t\t\t\t\t\t\t{author}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{action ? (\n\t\t\t\t\t\t\t\t<span data-slot=\"timeline-description\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t\t{action}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t{time ? (\n\t\t\t\t\t\t\t\t<span data-slot=\"timeline-time\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t\t{time}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{menu ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-comment-menu\" mix={[inlineFlex(), raw({ flexShrink: 0 })]}>\n\t\t\t\t\t\t\t\t{menu}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</header>\n\t\t\t\t\t<div\n\t\t\t\t\t\tdata-slot=\"timeline-comment-body\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\toverflowWrap: \"anywhere\",\n\t\t\t\t\t\t\t\t\"& > :first-child\": { marginBlockStart: 0 },\n\t\t\t\t\t\t\t\t\"& > :last-child\": { marginBlockEnd: 0 },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</div>\n\t\t\t\t\t{reactions ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tdata-slot=\"timeline-reactions\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\traw({ flexWrap: \"wrap\" }),\n\t\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\t\t\traw({ paddingBlockEnd: \"0.75rem\" }),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{reactions}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders a push as one event on the rail with its commits listed under the line: each row\n * gives the subject, its checks and the short sha, so a run of commits costs one rail stop.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <Timeline.Commits icon={<GitCommitHorizontalIcon />} actor=\"ana\" summary=\"added 2 commits\" time=\"3h ago\">\n * \t<Timeline.Commit sha=\"a1b2c3d\" href=\"/commit/a1b2c3d\" check={<CheckIcon aria-label=\"Checks passed\" />}>Fix the parser</Timeline.Commit>\n * </Timeline.Commits>\n */\nTimeline.Commits = function TimelineCommits(handle: Handle<Timeline.CommitsProps>) {\n\treturn () => {\n\t\tlet { icon, avatar, actor, summary, time, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-commits\"\n\t\t\t\tdata-tone=\"neutral\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(rowTrack(), mix)}\n\t\t\t>\n\t\t\t\t<TimelineIcon tone=\"neutral\">{icon}</TimelineIcon>\n\t\t\t\t<div mix={[vstack({ gap: 1.5 }), minIs(0)]}>\n\t\t\t\t\t<p\n\t\t\t\t\t\tdata-slot=\"timeline-line\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", minBlockSize: ICON_BOX }),\n\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{avatar ? <span mix={[inlineFlex()]}>{avatar}</span> : null}\n\t\t\t\t\t\t{actor ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-actor\" mix={[weight(\"semibold\")]}>\n\t\t\t\t\t\t\t\t{actor}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{summary ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-description\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t{summary}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{time ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-time\" mix={[fg(\"neutral.muted\"), text(\"xs\")]}>\n\t\t\t\t\t\t\t\t{time}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</p>\n\t\t\t\t\t<ol\n\t\t\t\t\t\tdata-slot=\"timeline-commit-list\"\n\t\t\t\t\t\tmix={[m(0), p(0), listStyle(\"none\"), vstack({ gap: 0.5 })]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</ol>\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders one commit of a {@link Timeline.Commits} group: avatar, the subject (truncated to\n * one line), the check-state slot, then the short sha in monospace at the row's end.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the commit's row.\n * @example <Timeline.Commit sha=\"a1b2c3d\" href=\"/commit/a1b2c3d\">Fix the parser</Timeline.Commit>\n */\nTimeline.Commit = function TimelineCommit(handle: Handle<Timeline.CommitProps>) {\n\treturn () => {\n\t\tlet { sha, href, avatar, check, children, mix, ...rest } = handle.props;\n\t\tlet linkMix = [\n\t\t\tfg(\"inherit\"),\n\t\t\traw({ textDecoration: \"none\" }),\n\t\t\thover(raw({ textDecoration: \"underline\" })),\n\t\t];\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-commit\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[flex(), items(\"center\"), gap(2), minIs(0), raw({ minBlockSize: \"1.75rem\" })],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{avatar ? <span mix={[inlineFlex(), raw({ flexShrink: 0 })]}>{avatar}</span> : null}\n\t\t\t\t<span data-slot=\"timeline-commit-subject\" mix={[truncate(), raw({ flex: \"0 1 auto\" })]}>\n\t\t\t\t\t{href ? (\n\t\t\t\t\t\t<a href={href} mix={linkMix}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tchildren\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t\t{check ? (\n\t\t\t\t\t<span data-slot=\"timeline-commit-check\" mix={[inlineFlex(), raw({ flexShrink: 0 })]}>\n\t\t\t\t\t\t{check}\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t\t<code\n\t\t\t\t\tdata-slot=\"timeline-commit-sha\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({ marginInlineStart: \"auto\", flexShrink: 0 }),\n\t\t\t\t\t\tfont(\"mono\"),\n\t\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{href ? (\n\t\t\t\t\t\t<a href={href} mix={linkMix}>\n\t\t\t\t\t\t\t{sha}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tsha\n\t\t\t\t\t)}\n\t\t\t\t</code>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/** Props {@link TimelineIcon} reads. */\ninterface TimelineIconProps {\n\ttone: Timeline.Tone;\n\tchildren: RemixNode;\n}\n\n/**\n * The icon box on the rail: the glyph in its tone, on the surface colour so the rail\n * reads as passing behind it.\n *\n * @param handle Runtime handle carrying the tone and glyph.\n * @returns The render function producing the icon box.\n */\nfunction TimelineIcon(handle: Handle<TimelineIconProps>) {\n\treturn () => {\n\t\tlet { tone, children } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-icon\"\n\t\t\t\tdata-tone={tone}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tis(ICON_BOX),\n\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tbg(\"var(--ui-timeline-surface, var(--ui-bg, Canvas))\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\tdata(\"tone\", \"brand\", fg(\"brand\")),\n\t\t\t\t\tdata(\"tone\", \"success\", fg(\"success\")),\n\t\t\t\t\tdata(\"tone\", \"warning\", fg(\"warning\")),\n\t\t\t\t\tdata(\"tone\", \"danger\", fg(\"danger\")),\n\t\t\t\t\twhen(\"& > svg\", raw({ inlineSize: \"1rem\", blockSize: \"1rem\" })),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
12
|
"test": {
|
|
13
13
|
"path": "timeline.browser.test.tsx",
|
|
14
|
-
"content": "/**\n * Lays Timeline out in a real browser: an ordered list whose rail runs through the centre\n * of every icon, a line per event, a comment card in the text column, and a \"N more\"\n * disclosure whose folded events open on the same rail.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { userEvent } from \"vitest/browser\";\n\nimport { Timeline } from \"@sdxc/ui/timeline\";\n\nimport \"@sdxc/ui/theme.css\";\n\n/** A 16px stand-in glyph. */\nfunction Glyph() {\n\treturn () => (\n\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"6\" fill=\"currentColor\" />\n\t\t</svg>\n\t);\n}\n\n/** An incident's activity: opened, a folded run of checks, a comment, resolved. */\nfunction Incident() {\n\treturn () => (\n\t\t<Timeline aria-label=\"Activity\">\n\t\t\t<Timeline.Event icon={<Glyph />} tone=\"danger\" actor=\"Uptime\" time=\"12m ago\">\n\t\t\t\topened the incident\n\t\t\t</Timeline.Event>\n\t\t\t<Timeline.More summary=\"2 more events\">\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"Uptime\" time=\"11m ago\">\n\t\t\t\t\tchecked from Frankfurt\n\t\t\t\t</Timeline.Event>\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"Uptime\" time=\"10m ago\">\n\t\t\t\t\tchecked from Singapore\n\t\t\t\t</Timeline.Event>\n\t\t\t</Timeline.More>\n\t\t\t<Timeline.Event\n\t\t\t\ticon={<Glyph />}\n\t\t\t\tactor=\"Ana Souza\"\n\t\t\t\ttime=\"8m ago\"\n\t\t\t\tbody={<p>Rolling back the 14:02 deploy.</p>}\n\t\t\t>\n\t\t\t\tcommented\n\t\t\t</Timeline.Event>\n\t\t\t<Timeline.Event icon={<Glyph />} tone=\"success\" actor=\"Ana Souza\" time=\"2m ago\">\n\t\t\t\tresolved the incident\n\t\t\t</Timeline.Event>\n\t\t</Timeline>\n\t);\n}\n\n/** Mounts the incident timeline in a 480px host. */\nfunction mount(): HTMLElement {\n\tlet host = document.createElement(\"div\");\n\thost.style.width = \"480px\";\n\tdocument.body.appendChild(host);\n\trender(<Incident />, { container: host });\n\treturn host;\n}\n\n/** Horizontal centre of a box. */\nfunction centerX(element: Element): number {\n\tlet box = element.getBoundingClientRect();\n\treturn box.left + box.width / 2;\n}\n\nafterEach(() => {\n\tdocument.body.replaceChildren();\n});\n\ndescribe(\"Timeline\", () => {\n\ttest(\"is an ordered list of events\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\n\t\texpect(list.getAttribute(\"aria-label\")).toBe(\"Activity\");\n\t\texpect(list.querySelectorAll(\":scope > li\")).toHaveLength(4);\n\t});\n\n\ttest(\"runs a 2px rail through the centre of every 16px icon\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\t\tlet rail = getComputedStyle(list, \"::before\");\n\t\tlet railCenter = list.getBoundingClientRect().left + parseFloat(rail.left) + 1;\n\n\t\texpect(rail.width).toBe(\"2px\");\n\t\tfor (let icon of host.querySelectorAll('[data-slot=\"timeline-icon\"]')) {\n\t\t\tif (icon.getClientRects().length === 0) continue;\n\t\t\texpect(centerX(icon)).toBeCloseTo(railCenter, 0);\n\t\t\texpect(icon.querySelector(\"svg\")!.getBoundingClientRect().width).toBe(16);\n\t\t}\n\t});\n\n\ttest(\"tones each icon by what happened\", () => {\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-danger-600\", \"rgb(220, 38, 38)\");\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-success-600\", \"rgb(22, 163, 74)\");\n\t\tlet host = mount();\n\t\tlet [opened] = host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]');\n\t\tlet resolved = [...host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]')].at(-1)!;\n\n\t\texpect(getComputedStyle(opened!).color).toBe(\"rgb(220, 38, 38)\");\n\t\texpect(getComputedStyle(resolved).color).toBe(\"rgb(22, 163, 74)\");\n\t});\n\n\ttest(\"keeps each event on one line with the actor in bold\", () => {\n\t\tlet host = mount();\n\t\tlet line = host.querySelector<HTMLElement>('[data-slot=\"timeline-line\"]')!;\n\t\tlet actor = line.querySelector('[data-slot=\"timeline-actor\"]')!;\n\n\t\texpect(line.getBoundingClientRect().height).toBeLessThanOrEqual(24);\n\t\texpect(Number(getComputedStyle(actor).fontWeight)).toBeGreaterThanOrEqual(600);\n\t});\n\n\ttest(\"sets a comment as a card in the text column\", () => {\n\t\tlet host = mount();\n\t\tlet body = host.querySelector<HTMLElement>('[data-slot=\"timeline-body\"]')!;\n\t\tlet line = body.parentElement!.querySelector('[data-slot=\"timeline-line\"]')!;\n\n\t\texpect(body.getBoundingClientRect().left).toBeCloseTo(line.getBoundingClientRect().left, 0);\n\t\texpect(getComputedStyle(body).borderTopWidth).toBe(\"1px\");\n\t});\n\n\ttest(\"folds quiet events behind a disclosure that opens them on the same rail\", async () => {\n\t\tlet host = mount();\n\t\tlet details = host.querySelector(\"details\")!;\n\t\tlet summary = details.querySelector(\"summary\")!;\n\t\tlet folded = details.querySelectorAll<HTMLElement>('[data-slot=\"timeline-event\"]');\n\t\tlet first = host.querySelector('[data-slot=\"timeline-icon\"]')!;\n\n\t\texpect(summary.textContent).toBe(\"2 more events\");\n\t\texpect(folded[0]!.checkVisibility()).toBe(false);\n\n\t\tawait userEvent.click(summary);\n\n\t\texpect(details.open).toBe(true);\n\t\texpect(folded[0]!.checkVisibility()).toBe(true);\n\t\tlet icon = folded[0]!.querySelector('[data-slot=\"timeline-icon\"]')!;\n\t\texpect(centerX(icon)).toBeCloseTo(centerX(first), 0);\n\t});\n});\n"
|
|
14
|
+
"content": "/**\n * Lays Timeline out in a real browser: an ordered list whose rail runs through the centre\n * of every icon, a line per event, a comment card in the text column, and a \"N more\"\n * disclosure whose folded events open on the same rail, comment cards with an author header and\n * reactions, and a push's commits listed under one rail stop.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { userEvent } from \"vitest/browser\";\n\nimport { Timeline } from \"@sdxc/ui/timeline\";\n\nimport \"@sdxc/ui/theme.css\";\n\n/** A 16px stand-in glyph. */\nfunction Glyph() {\n\treturn () => (\n\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"6\" fill=\"currentColor\" />\n\t\t</svg>\n\t);\n}\n\n/** An incident's activity: opened, a folded run of checks, a comment, resolved. */\nfunction Incident() {\n\treturn () => (\n\t\t<Timeline aria-label=\"Activity\">\n\t\t\t<Timeline.Event icon={<Glyph />} tone=\"danger\" actor=\"Uptime\" time=\"12m ago\">\n\t\t\t\topened the incident\n\t\t\t</Timeline.Event>\n\t\t\t<Timeline.More summary=\"2 more events\">\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"Uptime\" time=\"11m ago\">\n\t\t\t\t\tchecked from Frankfurt\n\t\t\t\t</Timeline.Event>\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"Uptime\" time=\"10m ago\">\n\t\t\t\t\tchecked from Singapore\n\t\t\t\t</Timeline.Event>\n\t\t\t</Timeline.More>\n\t\t\t<Timeline.Event\n\t\t\t\ticon={<Glyph />}\n\t\t\t\tactor=\"Ana Souza\"\n\t\t\t\ttime=\"8m ago\"\n\t\t\t\tbody={<p>Rolling back the 14:02 deploy.</p>}\n\t\t\t>\n\t\t\t\tcommented\n\t\t\t</Timeline.Event>\n\t\t\t<Timeline.Event icon={<Glyph />} tone=\"success\" actor=\"Ana Souza\" time=\"2m ago\">\n\t\t\t\tresolved the incident\n\t\t\t</Timeline.Event>\n\t\t</Timeline>\n\t);\n}\n\n/** Mounts the incident timeline in a 480px host. */\nfunction mount(): HTMLElement {\n\tlet host = document.createElement(\"div\");\n\thost.style.width = \"480px\";\n\tdocument.body.appendChild(host);\n\trender(<Incident />, { container: host });\n\treturn host;\n}\n\n/** Horizontal centre of a box. */\nfunction centerX(element: Element): number {\n\tlet box = element.getBoundingClientRect();\n\treturn box.left + box.width / 2;\n}\n\nafterEach(() => {\n\tdocument.body.replaceChildren();\n});\n\ndescribe(\"Timeline\", () => {\n\ttest(\"is an ordered list of events\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\n\t\texpect(list.getAttribute(\"aria-label\")).toBe(\"Activity\");\n\t\texpect(list.querySelectorAll(\":scope > li\")).toHaveLength(4);\n\t});\n\n\ttest(\"runs a 2px rail through the centre of every 16px icon\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\t\tlet rail = getComputedStyle(list, \"::before\");\n\t\tlet railCenter = list.getBoundingClientRect().left + parseFloat(rail.left) + 1;\n\n\t\texpect(rail.width).toBe(\"2px\");\n\t\tfor (let icon of host.querySelectorAll('[data-slot=\"timeline-icon\"]')) {\n\t\t\tif (icon.getClientRects().length === 0) continue;\n\t\t\texpect(centerX(icon)).toBeCloseTo(railCenter, 0);\n\t\t\texpect(icon.querySelector(\"svg\")!.getBoundingClientRect().width).toBe(16);\n\t\t}\n\t});\n\n\ttest(\"tones each icon by what happened\", () => {\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-danger-600\", \"rgb(220, 38, 38)\");\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-success-600\", \"rgb(22, 163, 74)\");\n\t\tlet host = mount();\n\t\tlet [opened] = host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]');\n\t\tlet resolved = [...host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]')].at(-1)!;\n\n\t\texpect(getComputedStyle(opened!).color).toBe(\"rgb(220, 38, 38)\");\n\t\texpect(getComputedStyle(resolved).color).toBe(\"rgb(22, 163, 74)\");\n\t});\n\n\ttest(\"keeps each event on one line with the actor in bold\", () => {\n\t\tlet host = mount();\n\t\tlet line = host.querySelector<HTMLElement>('[data-slot=\"timeline-line\"]')!;\n\t\tlet actor = line.querySelector('[data-slot=\"timeline-actor\"]')!;\n\n\t\texpect(line.getBoundingClientRect().height).toBeLessThanOrEqual(24);\n\t\texpect(Number(getComputedStyle(actor).fontWeight)).toBeGreaterThanOrEqual(600);\n\t});\n\n\ttest(\"sets a comment as a card in the text column\", () => {\n\t\tlet host = mount();\n\t\tlet body = host.querySelector<HTMLElement>('[data-slot=\"timeline-body\"]')!;\n\t\tlet line = body.parentElement!.querySelector('[data-slot=\"timeline-line\"]')!;\n\n\t\texpect(body.getBoundingClientRect().left).toBeCloseTo(line.getBoundingClientRect().left, 0);\n\t\texpect(getComputedStyle(body).borderTopWidth).toBe(\"1px\");\n\t});\n\n\ttest(\"folds quiet events behind a disclosure that opens them on the same rail\", async () => {\n\t\tlet host = mount();\n\t\tlet details = host.querySelector(\"details\")!;\n\t\tlet summary = details.querySelector(\"summary\")!;\n\t\tlet folded = details.querySelectorAll<HTMLElement>('[data-slot=\"timeline-event\"]');\n\t\tlet first = host.querySelector('[data-slot=\"timeline-icon\"]')!;\n\n\t\texpect(summary.textContent).toBe(\"2 more events\");\n\t\texpect(folded[0]!.checkVisibility()).toBe(false);\n\n\t\tawait userEvent.click(summary);\n\n\t\texpect(details.open).toBe(true);\n\t\texpect(folded[0]!.checkVisibility()).toBe(true);\n\t\tlet icon = folded[0]!.querySelector('[data-slot=\"timeline-icon\"]')!;\n\t\texpect(centerX(icon)).toBeCloseTo(centerX(first), 0);\n\t});\n\n\ttest(\"sets a comment as a card with the author's avatar on the rail\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\thost.style.width = \"480px\";\n\t\tdocument.body.appendChild(host);\n\t\trender(\n\t\t\t<Timeline aria-label=\"Conversation\">\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"ana\" time=\"3h ago\">\n\t\t\t\t\topened this pull request\n\t\t\t\t</Timeline.Event>\n\t\t\t\t<Timeline.Comment\n\t\t\t\t\tid=\"comment-1\"\n\t\t\t\t\tavatar={\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-avatar\n\t\t\t\t\t\t\tstyle=\"display:block;width:20px;height:20px;border-radius:50%;background:gray\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tauthor=\"ana\"\n\t\t\t\t\taction=\"commented\"\n\t\t\t\t\ttime=\"2h ago\"\n\t\t\t\t\tmenu={\n\t\t\t\t\t\t<button type=\"button\" aria-label=\"Comment actions\">\n\t\t\t\t\t\t\t⋯\n\t\t\t\t\t\t</button>\n\t\t\t\t\t}\n\t\t\t\t\treactions={<button type=\"button\">👍 2</button>}\n\t\t\t\t>\n\t\t\t\t\t<p>Looks good to me.</p>\n\t\t\t\t</Timeline.Comment>\n\t\t\t</Timeline>,\n\t\t\t{ container: host },\n\t\t);\n\t\tlet list = host.querySelector(\"ol\")!;\n\t\tlet comment = host.querySelector<HTMLElement>('[data-slot=\"timeline-comment\"]')!;\n\t\tlet header = comment.querySelector<HTMLElement>('[data-slot=\"timeline-comment-header\"]')!;\n\t\tlet card = comment.querySelector<HTMLElement>('[data-slot=\"timeline-card\"]')!;\n\t\tlet avatar = comment.querySelector<HTMLElement>('[data-slot=\"timeline-avatar\"]')!;\n\t\tlet icon = host.querySelector('[data-slot=\"timeline-icon\"]')!;\n\t\tlet menu = header.querySelector(\"button\")!;\n\t\tlet rail = getComputedStyle(list, \"::before\");\n\t\tlet railCenter = list.getBoundingClientRect().left + parseFloat(rail.left) + 1;\n\n\t\texpect(comment.id).toBe(\"comment-1\");\n\t\texpect(centerX(avatar)).toBeCloseTo(railCenter, 0);\n\t\texpect(centerX(avatar)).toBeCloseTo(centerX(icon), 0);\n\t\texpect(getComputedStyle(card).borderTopWidth).toBe(\"1px\");\n\t\texpect(header.textContent).toContain(\"ana\");\n\t\texpect(header.textContent).toContain(\"commented\");\n\t\texpect(header.textContent).toContain(\"2h ago\");\n\t\texpect(menu.getBoundingClientRect().right).toBeCloseTo(\n\t\t\theader.getBoundingClientRect().right - 12,\n\t\t\t0,\n\t\t);\n\t\texpect(card.querySelector('[data-slot=\"timeline-comment-body\"] p')!.textContent).toBe(\n\t\t\t\"Looks good to me.\",\n\t\t);\n\t\tlet reactions = card.querySelector<HTMLElement>('[data-slot=\"timeline-reactions\"]')!;\n\t\texpect(reactions.getBoundingClientRect().top).toBeGreaterThan(\n\t\t\tcard.querySelector('[data-slot=\"timeline-comment-body\"]')!.getBoundingClientRect().top,\n\t\t);\n\t});\n\n\ttest(\"lists a push's commits under one rail stop, each with its check and short sha\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\thost.style.width = \"480px\";\n\t\tdocument.body.appendChild(host);\n\t\trender(\n\t\t\t<Timeline aria-label=\"Conversation\">\n\t\t\t\t<Timeline.Commits icon={<Glyph />} actor=\"ana\" summary=\"added 2 commits\" time=\"1h ago\">\n\t\t\t\t\t<Timeline.Commit\n\t\t\t\t\t\tsha=\"a1b2c3d\"\n\t\t\t\t\t\thref=\"#a1b2c3d\"\n\t\t\t\t\t\tcheck={\n\t\t\t\t\t\t\t<span role=\"img\" aria-label=\"Checks passed\">\n\t\t\t\t\t\t\t\t✓\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\tParse ANSI colours in job logs and keep long subjects to a single truncated line\n\t\t\t\t\t</Timeline.Commit>\n\t\t\t\t\t<Timeline.Commit sha=\"e4f5a6b\">Fix the timestamp toggle</Timeline.Commit>\n\t\t\t\t</Timeline.Commits>\n\t\t\t</Timeline>,\n\t\t\t{ container: host },\n\t\t);\n\t\tlet group = host.querySelector<HTMLElement>('[data-slot=\"timeline-commits\"]')!;\n\t\tlet commits = group.querySelectorAll<HTMLElement>('[data-slot=\"timeline-commit\"]');\n\t\tlet first = commits[0]!;\n\t\tlet sha = first.querySelector<HTMLElement>('[data-slot=\"timeline-commit-sha\"]')!;\n\n\t\texpect(group.querySelectorAll('[data-slot=\"timeline-icon\"]')).toHaveLength(1);\n\t\texpect(commits).toHaveLength(2);\n\t\texpect(first.getBoundingClientRect().height).toBeLessThanOrEqual(32);\n\t\texpect(getComputedStyle(sha).fontFamily).toMatch(/mono/i);\n\t\texpect(sha.textContent).toBe(\"a1b2c3d\");\n\t\texpect(sha.getBoundingClientRect().right).toBeCloseTo(first.getBoundingClientRect().right, 0);\n\t\texpect(first.querySelector('[role=\"img\"]')!.getAttribute(\"aria-label\")).toBe(\"Checks passed\");\n\t\texpect(\n\t\t\tfirst\n\t\t\t\t.querySelector<HTMLAnchorElement>('[data-slot=\"timeline-commit-subject\"] a')!\n\t\t\t\t.getAttribute(\"href\"),\n\t\t).toBe(\"#a1b2c3d\");\n\t\texpect(commits[1]!.querySelector(\"a\")).toBeNull();\n\t});\n});\n"
|
|
15
15
|
}
|
|
16
16
|
}
|