@sdxc/kit 2026.11.14 → 2026.11.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.jsonl CHANGED
@@ -2097,3 +2097,9 @@
2097
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
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
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."}
2100
+ {"release":"2026.11.17","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Set a SaveStatus on the baseline of the text beside it","body":"A `SaveStatus` in a row that aligns its items by baseline, such as a panel\nheading with the status on its right, used to sit about 5px below the heading,\nbecause the status took its baseline from its empty live region. Its pieces now\nalign by baseline, so \"Edited 4s ago\" reads on the same line as the heading.\nConsumers need no change."}
2101
+ {"release":"2026.11.17","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep an editable PropertyList value's chevron on its first row","body":"An editable `PropertyList.Item` whose value runs to several rows, such as a list\nof reviewers, used to center its chevron across the whole list, so it floated\nbeside a middle row. The chevron now sits on the value's first row, and a\nsingle-row value keeps it centered as before. Consumers need no change."}
2102
+ {"release":"2026.11.17","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Set an editable PropertyList value's chevron on its label's line","body":"In a narrow `PropertyList`, where each label stacks above its value, an editable\nvalue's chevron used to sit beside the value, so a list of reviewers carried it\non their first name and a one-line value on that line. It now sits at the end of\nthe label's line (\"Reviewers ⌄\"), the same place for every row. A wide list,\nwith labels beside their values, keeps the chevron on the value's first row.\nConsumers need no change."}
2103
+ {"release":"2026.11.17","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Link a streamed LogViewer line only to an http(s) address","body":"Before, a line streamed into a running step of `LogViewer` from `@sdxc/ui/app` copied the\n`lineHref` template straight into its number link, so a `javascript:` or `data:` template\nbecame a link that ran script when clicked (code scanning alert js/xss-through-dom).\n\nNow the streamed line resolves the link against the page and sets it only when it is an\nhttp(s) URL; any other scheme leaves the line number unlinked. Lines the server draws are\nunchanged. Consumers whose `lineHref` returns a path, a fragment or an http(s) URL need no\naction."}
2104
+ {"release":"2026.11.17","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add VideoCard, VideoShelf and EpisodeList to @sdxc/ui/video","body":"`@sdxc/ui/video` now holds the pieces a video library browses with, beside\nthe player.\n\n`VideoCard` is a title as one link: 16:9 or 2:3 art, an optional badge, a\nwatched bar and its name and meta line.\n\n <VideoCard\n href=\"/watch/tidewater/2-3\"\n title=\"Tidewater\"\n art={<img src={still} alt=\"\" />}\n meta=\"S2:E3 · Lee Shore\"\n progress={0.42}\n progressLabel=\"42% watched\"\n />\n\n`VideoShelf` is a titled row of `VideoShelf.Item`s that scrolls sideways\nwith scroll snap and works without script. Its `VideoShelfSync` island\nreveals paging buttons at the edges, steps a screenful at a time and\ndisables each button at its end. Map the island in your browser entry the\nway you map the player:\n\n \"@sdxc/ui/video/video-shelf\": () => import(\"@sdxc/ui/video/video-shelf\"),\n\n <VideoShelf id=\"trending\" title=\"Trending now\"\n labels={{ previous: \"Previous titles\", next: \"More titles\" }}>\n {titles.map((t) => <VideoShelf.Item><VideoCard {...t} /></VideoShelf.Item>)}\n </VideoShelf>\n\nSet `--ui-video-shelf-inset` to your page gutter so the first card lines up\nwith the page while the row runs edge to edge.\n\n`EpisodeList` is a season as an `<ol>` of `EpisodeList.Item` links, each with\na still, number, running time, synopsis and watched bar, with `current`\nmarking the episode the viewer is on. In a narrow list the synopsis wraps\nunder the still.\n\nEvery watched bar is decorative. Pass `progressLabel` with the words a\nscreen reader should hear."}
2105
+ {"release":"2026.11.17","package":"@sdxc/ui","type":"feat","breaking":false,"title":"Add TitleHero to @sdxc/ui/video and ProfilePicker to @sdxc/ui/app","body":"`TitleHero` is a video title's hero: its art edge to edge behind the page,\nfaded into the page at its foot and toward the text, with `.Eyebrow`,\n`.Title` (level 1 or 2), `.Facts`, `.Rating`, `.Summary` and `.Actions`.\nSet `--ui-title-hero-offset` to a sticky top bar's height, so the art\nstarts at the window's edge while the text clears the bar. Set\n`--ui-title-hero-inset` to your page gutter. The art drifts in slightly and\nholds still under reduced motion.\n\n <TitleHero size=\"title\" art={<img src={art} alt=\"\" />} aria-labelledby=\"t\">\n <TitleHero.Eyebrow>Original</TitleHero.Eyebrow>\n <TitleHero.Title id=\"t\" level={1}>Tidewater</TitleHero.Title>\n <TitleHero.Facts><TitleHero.Rating>16+</TitleHero.Rating><span>2026</span></TitleHero.Facts>\n <TitleHero.Summary>A harbour town keeps one secret a season.</TitleHero.Summary>\n <TitleHero.Actions><LinkButton href=\"/watch/tidewater\">Play</LinkButton></TitleHero.Actions>\n </TitleHero>\n\n`ProfilePicker` is the \"who is using this?\" screen of an account several\npeople share. Each `.Profile` is a submit button with its own `formAction`,\nso one form around the picker posts the pick without script. `current`\nrings the profile in use."}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/kit",
3
- "version": "2026.11.14",
3
+ "version": "2026.11.17",
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": "5d069a9e855202a3a5e79141319e4e2d2ce7c084",
36
+ "gitHead": "d0a98d9f22d429ae5da7d5e75b4c0f55d311e758",
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "property-list",
3
- "changedIn": "2026.11.14",
3
+ "changedIn": "2026.11.17",
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`, 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"
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\traw({ position: \"relative\" }),\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} labelRow={!tiles}>\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\t/**\n\t * Sets the chevron at the end of the label's row while the label stacks above the value,\n\t * offset by the row's and the label's block padding so it centres on the label's line.\n\t */\n\tlabelRow: boolean;\n\tchildren: RemixNode;\n}\n\n/**\n * The editable value: a full-width button naming its action before the current value, its\n * chevron on the label's row, and the popover it opens, the row's own or the app's. As the\n * popover's invoker the button is its 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, labelRow } = 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({\n\t\t\t\t\t\t\tmarginInline: \"-0.5rem\",\n\t\t\t\t\t\t\tinlineSize: \"calc(100% + 1rem)\",\n\t\t\t\t\t\t\tpaddingBlock: \"0.25rem\",\n\t\t\t\t\t\t}),\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<span\n\t\t\t\t\t\taria-hidden=\"true\"\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\tshrink(0),\n\t\t\t\t\t\t\traw({ alignSelf: \"flex-start\", blockSize: \"1.5rem\" }),\n\t\t\t\t\t\t\tlabelRow\n\t\t\t\t\t\t\t\t? raw({\n\t\t\t\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\t\t\t\tinsetBlockStart: \"0.625rem\",\n\t\t\t\t\t\t\t\t\t\tinsetInlineEnd: 0,\n\t\t\t\t\t\t\t\t\t\tblockSize: \"1.25rem\",\n\t\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\t\tposition: \"static\",\n\t\t\t\t\t\t\t\t\t\t\tblockSize: \"1.5rem\",\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ChevronDownIcon size={14} mix={[fg(\"neutral.muted\")]} />\n\t\t\t\t\t</span>\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 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"
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(\"keeps an editable value's chevron on its first row when the value runs to several\", () => {\n\t\tlet host = mount(\n\t\t\t<PropertyList>\n\t\t\t\t<PropertyList.Item\n\t\t\t\t\tlabel=\"Reviewers\"\n\t\t\t\t\tedit={{ id: \"edit-reviewers\", label: \"Edit reviewers\", content: <p>Picker</p> }}\n\t\t\t\t>\n\t\t\t\t\t<span style={{ display: \"grid\", gap: \"0.5rem\" }}>\n\t\t\t\t\t\t{[\"Kenji\", \"Mara\", \"Tobias\", \"Inés\"].map((name) => (\n\t\t\t\t\t\t\t<span key={name} data-slot=\"reviewer\" style={{ blockSize: \"1.5rem\" }}>\n\t\t\t\t\t\t\t\t{name}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</span>\n\t\t\t\t</PropertyList.Item>\n\t\t\t</PropertyList>,\n\t\t);\n\t\tlet chevron = host.querySelector('[data-slot=\"property-edit\"] svg')!.getBoundingClientRect();\n\t\tlet first = host.querySelector('[data-slot=\"reviewer\"]')!.getBoundingClientRect();\n\n\t\texpect(chevron.top + chevron.height / 2).toBeCloseTo(first.top + first.height / 2, 0);\n\t});\n\n\ttest(\"sets an editable value's chevron at the end of its label's row once the label stacks\", () => {\n\t\tlet host = mount(\n\t\t\t<PropertyList>\n\t\t\t\t<PropertyList.Item\n\t\t\t\t\tlabel=\"Reviewers\"\n\t\t\t\t\tedit={{ id: \"edit-reviewers\", label: \"Edit reviewers\", content: <p>Picker</p> }}\n\t\t\t\t>\n\t\t\t\t\t<span style={{ display: \"grid\", gap: \"0.5rem\" }}>\n\t\t\t\t\t\t<span style={{ blockSize: \"1.5rem\" }}>Kenji</span>\n\t\t\t\t\t\t<span style={{ blockSize: \"1.5rem\" }}>Mara</span>\n\t\t\t\t\t</span>\n\t\t\t\t</PropertyList.Item>\n\t\t\t</PropertyList>,\n\t\t\t300,\n\t\t);\n\t\tlet chevron = host.querySelector('[data-slot=\"property-edit\"] svg')!.getBoundingClientRect();\n\t\tlet label = host.querySelector(\"dt\")!.getBoundingClientRect();\n\t\tlet row = host.querySelector(\"dt\")!.parentElement!.getBoundingClientRect();\n\t\tlet line =\n\t\t\tlabel.top +\n\t\t\tNumber.parseFloat(getComputedStyle(host.querySelector(\"dt\")!).paddingBlockStart) +\n\t\t\t10;\n\n\t\texpect(chevron.top + chevron.height / 2).toBeCloseTo(line, 0);\n\t\texpect(row.right - chevron.right).toBeLessThan(6);\n\t});\n\n\ttest(\"centres the chevron on a single-row value\", () => {\n\t\tlet host = mount(<Monitor />);\n\t\tlet button = host.querySelector('[data-slot=\"property-edit\"]')!.getBoundingClientRect();\n\t\tlet chevron = host.querySelector('[data-slot=\"property-edit\"] svg')!.getBoundingClientRect();\n\n\t\texpect(chevron.top + chevron.height / 2).toBeCloseTo(button.top + button.height / 2, 0);\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
  }