@sdxc/kit 2026.11.27 → 2026.11.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/changelog.jsonl +189 -0
  2. package/dist/pkg/catalog.js +1 -0
  3. package/dist/scaffold/render.js +2 -2
  4. package/package.json +2 -2
  5. package/registry/ui/anchor-heading.json +19 -0
  6. package/registry/ui/autocomplete.json +3 -3
  7. package/registry/ui/banner.json +3 -3
  8. package/registry/ui/button.json +3 -3
  9. package/registry/ui/callout.json +16 -0
  10. package/registry/ui/checkbox.json +2 -2
  11. package/registry/ui/code-block.json +18 -0
  12. package/registry/ui/confirm.json +3 -3
  13. package/registry/ui/copy-button.json +14 -0
  14. package/registry/ui/date-field.json +4 -7
  15. package/registry/ui/date-picker.json +3 -5
  16. package/registry/ui/date-range-picker.json +2 -3
  17. package/registry/ui/dialog-dismiss.json +2 -2
  18. package/registry/ui/field-parts.json +30 -0
  19. package/registry/ui/filter-links.json +16 -0
  20. package/registry/ui/form.json +3 -3
  21. package/registry/ui/listbox.json +2 -2
  22. package/registry/ui/media-grid.json +3 -3
  23. package/registry/ui/pager.json +16 -0
  24. package/registry/ui/property-list.json +3 -3
  25. package/registry/ui/radio-group.json +2 -2
  26. package/registry/ui/range-calendar.json +2 -2
  27. package/registry/ui/range-months.json +3 -3
  28. package/registry/ui/rating-input.json +3 -3
  29. package/registry/ui/rating.json +3 -3
  30. package/registry/ui/review-card.json +3 -3
  31. package/registry/ui/search-field.json +6 -3
  32. package/registry/ui/section-bar.json +3 -3
  33. package/registry/ui/sidebar.json +2 -2
  34. package/registry/ui/table-of-contents.json +17 -0
  35. package/registry/ui/text-field.json +5 -9
  36. package/registry/ui/time-field.json +4 -7
  37. package/registry/ui/timeline.json +3 -3
  38. package/registry/ui/typeset.json +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "review-card",
3
- "changedIn": "2026.11.22",
3
+ "changedIn": "2026.11.29",
4
4
  "dependencies": [
5
5
  "rating"
6
6
  ],
@@ -9,10 +9,10 @@
9
9
  ],
10
10
  "source": {
11
11
  "path": "review-card.tsx",
12
- "content": "/**\n * One customer review: the stars, a title and the words, then who wrote it and when, a\n * verified mark, what they bought, any photos, and room for a \"Was this helpful?\" form. Reviews\n * stack in a list separated by hairlines.\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 { CircleCheckIcon } from \"@sdxc/icons\";\nimport { mergeMix, raw } from \"@sdxc/u/general\";\n\nimport { Rating } from \"@sdxc/ui/rating\";\n\n/** Prop types for {@link ReviewCard}. */\nexport namespace ReviewCard {\n\t/** Props accepted by {@link ReviewCard}; the host is an `<article>`. */\n\texport interface Props extends Omit<TagProps<\"article\">, \"children\" | \"title\"> {\n\t\tauthor: RemixNode;\n\t\t/** The stars the reviewer gave, out of five. */\n\t\trating: number;\n\t\ttitle?: RemixNode;\n\t\tbody: RemixNode;\n\t\t/** When it was written, such as a `<time>` or a relative date. */\n\t\tdate: RemixNode;\n\t\t/** The mark of a confirmed purchase, such as \"Verified buyer\"; shown with a check. */\n\t\tverified?: RemixNode;\n\t\t/** What the reviewer bought, such as \"Size: 50×70 · Oak frame\". */\n\t\tmeta?: RemixNode;\n\t\t/** Photos the reviewer added, laid out by the caller. */\n\t\tmedia?: RemixNode;\n\t\t/** A slot at the end of the footer, such as a POST form voting the review helpful. */\n\t\thelpful?: RemixNode;\n\t}\n}\n\n/**\n * Renders the review as an `<article>`: small stars and the title on top, the body in reading\n * size, photos beneath, and a wrapping footer row of author, date, verified mark and purchase\n * with the helpful slot pushed to the end.\n *\n * @example\n * <ReviewCard author=\"Maya R.\" rating={5} title=\"Better in person\" body=\"The paper is heavy and the colours are rich.\" date=\"2 weeks ago\" verified=\"Verified buyer\" meta=\"50×70 · Oak frame\" />\n */\nexport function ReviewCard(handle: Handle<ReviewCard.Props>) {\n\treturn () => {\n\t\tlet { author, body, date, helpful, media, meta, mix, rating, title, verified, ...rest } =\n\t\t\thandle.props;\n\t\treturn (\n\t\t\t<article\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"review-card\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"grid\",\n\t\t\t\t\t\t\tgap: \"0.625rem\",\n\t\t\t\t\t\t\tpaddingBlock: \"1.25rem\",\n\t\t\t\t\t\t\tborderBlockEnd: \"1px solid var(--ui-neutral-border)\",\n\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg)\",\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\t\t<div mix={[raw({ display: \"grid\", gap: \"0.375rem\" })]}>\n\t\t\t\t\t<Rating value={rating} size=\"sm\" />\n\t\t\t\t\t{title === undefined ? null : (\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tdata-slot=\"review-card-title\"\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\tmargin: \"0\",\n\t\t\t\t\t\t\t\t\tfontSize: \"1rem\",\n\t\t\t\t\t\t\t\t\tfontWeight: \"650\",\n\t\t\t\t\t\t\t\t\tlineHeight: \"1.35\",\n\t\t\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg-emphasis)\",\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{title}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t<div\n\t\t\t\t\tdata-slot=\"review-card-body\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tfontSize: \"0.9375rem\",\n\t\t\t\t\t\t\tlineHeight: \"1.6\",\n\t\t\t\t\t\t\t\"& > p\": { margin: \"0\" },\n\t\t\t\t\t\t\t\"& > p + p\": { marginBlockStart: \"0.75em\" },\n\t\t\t\t\t\t}),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{body}\n\t\t\t\t</div>\n\t\t\t\t{media === undefined ? null : <div data-slot=\"review-card-media\">{media}</div>}\n\t\t\t\t<footer\n\t\t\t\t\tdata-slot=\"review-card-footer\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tflexWrap: \"wrap\",\n\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\tcolumnGap: \"0.75rem\",\n\t\t\t\t\t\t\trowGap: \"0.375rem\",\n\t\t\t\t\t\t\tfontSize: \"0.8125rem\",\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]}\n\t\t\t\t>\n\t\t\t\t\t<span mix={[raw({ fontWeight: \"600\", color: \"var(--ui-neutral-fg-emphasis)\" })]}>\n\t\t\t\t\t\t{author}\n\t\t\t\t\t</span>\n\t\t\t\t\t<span>{date}</span>\n\t\t\t\t\t{verified === undefined ? null : (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-slot=\"review-card-verified\"\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\tdisplay: \"inline-flex\",\n\t\t\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\t\t\tgap: \"0.25rem\",\n\t\t\t\t\t\t\t\t\tcolor: \"var(--ui-success-fg)\",\n\t\t\t\t\t\t\t\t\t\"& > svg\": { inlineSize: \"0.875rem\", blockSize: \"0.875rem\" },\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<CircleCheckIcon aria-hidden=\"true\" />\n\t\t\t\t\t\t\t{verified}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t\t{meta === undefined ? null : <span data-slot=\"review-card-meta\">{meta}</span>}\n\t\t\t\t\t{helpful === undefined ? null : (\n\t\t\t\t\t\t<span data-slot=\"review-card-helpful\" mix={[raw({ marginInlineStart: \"auto\" })]}>\n\t\t\t\t\t\t\t{helpful}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</footer>\n\t\t\t</article>\n\t\t);\n\t};\n}\n"
12
+ "content": "/**\n * One customer review, built from parts: the stars and a title, the words, any photos, then\n * a footer of who wrote it and when, a verified mark, what they bought, and room for a \"Was\n * this helpful?\" form. Reviews stack in a list separated by hairlines.\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 { CircleCheckIcon } from \"@sdxc/icons\";\nimport { mergeMix, raw } from \"@sdxc/u/general\";\n\nimport { Rating } from \"@sdxc/ui/rating\";\n\n/** Prop types for {@link ReviewCard} and its parts. */\nexport namespace ReviewCard {\n\t/** Every native `<article>` attribute. */\n\texport interface Props extends TagProps<\"article\"> {}\n\n\t/** Every native `<div>` attribute. */\n\texport interface DivProps extends TagProps<\"div\"> {}\n\n\t/** Every {@link Rating} prop but its size. */\n\texport interface RatingProps extends Omit<Rating.Props, \"size\"> {}\n\n\t/** Every native `<p>` attribute. */\n\texport interface TitleProps extends TagProps<\"p\"> {}\n\n\t/** Every native `<footer>` attribute. */\n\texport interface FooterProps extends TagProps<\"footer\"> {}\n\n\t/** Every native `<span>` attribute. */\n\texport interface SpanProps extends TagProps<\"span\"> {}\n}\n\n/**\n * Renders the review as an `<article>` stacking whichever parts it holds, closed by a hairline.\n *\n * @param handle Runtime handle carrying the host `<article>`'s props.\n * @returns The render function producing the card.\n * @example\n * <ReviewCard>\n * \t<ReviewCard.Header>\n * \t\t<ReviewCard.Rating value={5} />\n * \t\t<ReviewCard.Title>Better in person</ReviewCard.Title>\n * \t</ReviewCard.Header>\n * \t<ReviewCard.Body><p>The paper is heavy and the colours are rich.</p></ReviewCard.Body>\n * \t<ReviewCard.Footer>\n * \t\t<ReviewCard.Author>Maya R.</ReviewCard.Author>\n * \t\t<ReviewCard.Date>2 weeks ago</ReviewCard.Date>\n * \t\t<ReviewCard.Verified>Verified buyer</ReviewCard.Verified>\n * \t</ReviewCard.Footer>\n * </ReviewCard>\n */\nexport function ReviewCard(handle: Handle<ReviewCard.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<article\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"review-card\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"grid\",\n\t\t\t\t\t\t\tgap: \"0.625rem\",\n\t\t\t\t\t\t\tpaddingBlock: \"1.25rem\",\n\t\t\t\t\t\t\tborderBlockEnd: \"1px solid var(--ui-neutral-border)\",\n\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg)\",\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 * The stars and the title, set close together above the words.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the header.\n */\nReviewCard.Header = function ReviewCardHeader(handle: Handle<ReviewCard.DivProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"review-card-header\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([raw({ display: \"grid\", gap: \"0.375rem\" })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The stars the reviewer gave, drawn small.\n *\n * @param handle Runtime handle carrying the rating's props.\n * @returns The render function producing the stars.\n * @example <ReviewCard.Rating value={4} />\n */\nReviewCard.Rating = function ReviewCardRating(handle: Handle<ReviewCard.RatingProps>) {\n\treturn () => <Rating {...handle.props} size=\"sm\" />;\n};\n\n/**\n * The review's own headline.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the title.\n */\nReviewCard.Title = function ReviewCardTitle(handle: Handle<ReviewCard.TitleProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<p\n\t\t\t\tdata-slot=\"review-card-title\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tmargin: \"0\",\n\t\t\t\t\t\t\tfontSize: \"1rem\",\n\t\t\t\t\t\t\tfontWeight: \"650\",\n\t\t\t\t\t\t\tlineHeight: \"1.35\",\n\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg-emphasis)\",\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 * The words, in reading size; paragraphs inside are spaced apart.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the body.\n */\nReviewCard.Body = function ReviewCardBody(handle: Handle<ReviewCard.DivProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"review-card-body\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tfontSize: \"0.9375rem\",\n\t\t\t\t\t\t\tlineHeight: \"1.6\",\n\t\t\t\t\t\t\t\"& > p\": { margin: \"0\" },\n\t\t\t\t\t\t\t\"& > p + p\": { marginBlockStart: \"0.75em\" },\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 * Photos the reviewer added, laid out by the caller.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the media box.\n */\nReviewCard.Media = function ReviewCardMedia(handle: Handle<ReviewCard.DivProps>) {\n\treturn () => <div data-slot=\"review-card-media\" {...handle.props} />;\n};\n\n/**\n * The small muted row closing the card, wrapping its parts; a {@link ReviewCard.Helpful} is\n * pushed to its end.\n *\n * @param handle Runtime handle carrying the host `<footer>`'s props.\n * @returns The render function producing the footer.\n */\nReviewCard.Footer = function ReviewCardFooter(handle: Handle<ReviewCard.FooterProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<footer\n\t\t\t\tdata-slot=\"review-card-footer\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tflexWrap: \"wrap\",\n\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\tcolumnGap: \"0.75rem\",\n\t\t\t\t\t\t\trowGap: \"0.375rem\",\n\t\t\t\t\t\t\tfontSize: \"0.8125rem\",\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],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Who wrote it, set in the emphasis colour.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the name.\n */\nReviewCard.Author = function ReviewCardAuthor(handle: Handle<ReviewCard.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"review-card-author\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([raw({ fontWeight: \"600\", color: \"var(--ui-neutral-fg-emphasis)\" })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * When it was written, such as a `<time>` or a relative date.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the date.\n */\nReviewCard.Date = function ReviewCardDate(handle: Handle<ReviewCard.SpanProps>) {\n\treturn () => <span data-slot=\"review-card-date\" {...handle.props} />;\n};\n\n/**\n * The mark of a confirmed purchase, such as \"Verified buyer\", after a check in the success colour.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the mark.\n */\nReviewCard.Verified = function ReviewCardVerified(handle: Handle<ReviewCard.SpanProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"review-card-verified\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"inline-flex\",\n\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\tgap: \"0.25rem\",\n\t\t\t\t\t\t\tcolor: \"var(--ui-success-fg)\",\n\t\t\t\t\t\t\t\"& > svg\": { inlineSize: \"0.875rem\", blockSize: \"0.875rem\" },\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\t\t<CircleCheckIcon aria-hidden=\"true\" />\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t);\n\t};\n};\n\n/**\n * What the reviewer bought, such as \"Size: 50×70 · Oak frame\".\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the line.\n */\nReviewCard.Meta = function ReviewCardMeta(handle: Handle<ReviewCard.SpanProps>) {\n\treturn () => <span data-slot=\"review-card-meta\" {...handle.props} />;\n};\n\n/**\n * Room at the footer's end, such as a POST form voting the review helpful.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the box.\n */\nReviewCard.Helpful = function ReviewCardHelpful(handle: Handle<ReviewCard.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"review-card-helpful\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([raw({ marginInlineStart: \"auto\" })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
13
13
  },
14
14
  "test": {
15
15
  "path": "review-card.browser.test.tsx",
16
- "content": "/**\n * Holds the review card to its contract in a real browser: a review lays out its stars, title,\n * words and a footer with the helpful slot pushed to the end, and leaves out what it lacks.\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\";\n\nimport { ReviewCard } from \"@sdxc/ui/review-card\";\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});\n\ndescribe(\"ReviewCard\", () => {\n\ttest(\"lays out the stars, title, words and a footer with the helpful slot at the end\", () => {\n\t\tmounted = render(\n\t\t\t<div style={{ inlineSize: \"40rem\" }}>\n\t\t\t\t<ReviewCard\n\t\t\t\t\tauthor=\"Maya R.\"\n\t\t\t\t\trating={5}\n\t\t\t\t\ttitle=\"Better in person\"\n\t\t\t\t\tbody={<p>The paper is heavy and the colours are rich.</p>}\n\t\t\t\t\tdate=\"2 weeks ago\"\n\t\t\t\t\tverified=\"Verified buyer\"\n\t\t\t\t\tmeta=\"50×70 · Oak frame\"\n\t\t\t\t\thelpful={<button type=\"button\">Helpful (3)</button>}\n\t\t\t\t/>\n\t\t\t</div>,\n\t\t);\n\t\tlet card = mounted.container.querySelector<HTMLElement>('[data-slot=\"review-card\"]')!;\n\t\texpect(card.tagName).toBe(\"ARTICLE\");\n\t\texpect(card.querySelector('[role=\"img\"]')!.getAttribute(\"aria-label\")).toBe(\"5 out of 5 stars\");\n\t\texpect(card.querySelector('[data-slot=\"review-card-title\"]')!.textContent).toBe(\n\t\t\t\"Better in person\",\n\t\t);\n\t\tlet footer = card.querySelector<HTMLElement>('[data-slot=\"review-card-footer\"]')!;\n\t\texpect(footer.textContent).toBe(\"Maya R.2 weeks agoVerified buyer50×70 · Oak frameHelpful (3)\");\n\t\tlet helpful = footer.querySelector<HTMLElement>('[data-slot=\"review-card-helpful\"]')!;\n\t\texpect(Math.round(helpful.getBoundingClientRect().right)).toBe(\n\t\t\tMath.round(footer.getBoundingClientRect().right),\n\t\t);\n\t});\n\n\ttest(\"leaves out the parts it was not given\", () => {\n\t\tmounted = render(<ReviewCard author=\"Sam\" rating={3} body=\"Fine.\" date=\"Today\" />);\n\t\tlet card = mounted.container.querySelector<HTMLElement>('[data-slot=\"review-card\"]')!;\n\t\texpect(card.querySelector('[data-slot=\"review-card-title\"]')).toBeNull();\n\t\texpect(card.querySelector('[data-slot=\"review-card-verified\"]')).toBeNull();\n\t\texpect(card.querySelector('[data-slot=\"review-card-helpful\"]')).toBeNull();\n\t});\n});\n"
16
+ "content": "/**\n * Holds the review card to its contract in a real browser: a review lays out its stars, title,\n * words and a footer with the helpful slot pushed to the end, and leaves out what it lacks.\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\";\n\nimport { ReviewCard } from \"@sdxc/ui/review-card\";\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});\n\ndescribe(\"ReviewCard\", () => {\n\ttest(\"lays out the stars, title, words and a footer with the helpful slot at the end\", () => {\n\t\tmounted = render(\n\t\t\t<div style={{ inlineSize: \"40rem\" }}>\n\t\t\t\t<ReviewCard>\n\t\t\t\t\t<ReviewCard.Header>\n\t\t\t\t\t\t<ReviewCard.Rating value={5} />\n\t\t\t\t\t\t<ReviewCard.Title>Better in person</ReviewCard.Title>\n\t\t\t\t\t</ReviewCard.Header>\n\t\t\t\t\t<ReviewCard.Body>\n\t\t\t\t\t\t<p>The paper is heavy and the colours are rich.</p>\n\t\t\t\t\t</ReviewCard.Body>\n\t\t\t\t\t<ReviewCard.Footer>\n\t\t\t\t\t\t<ReviewCard.Author>Maya R.</ReviewCard.Author>\n\t\t\t\t\t\t<ReviewCard.Date>2 weeks ago</ReviewCard.Date>\n\t\t\t\t\t\t<ReviewCard.Verified>Verified buyer</ReviewCard.Verified>\n\t\t\t\t\t\t<ReviewCard.Meta>50×70 · Oak frame</ReviewCard.Meta>\n\t\t\t\t\t\t<ReviewCard.Helpful>\n\t\t\t\t\t\t\t<button type=\"button\">Helpful (3)</button>\n\t\t\t\t\t\t</ReviewCard.Helpful>\n\t\t\t\t\t</ReviewCard.Footer>\n\t\t\t\t</ReviewCard>\n\t\t\t</div>,\n\t\t);\n\t\tlet card = mounted.container.querySelector<HTMLElement>('[data-slot=\"review-card\"]')!;\n\t\texpect(card.tagName).toBe(\"ARTICLE\");\n\t\texpect(card.querySelector('[role=\"img\"]')!.getAttribute(\"aria-label\")).toBe(\"5 out of 5 stars\");\n\t\texpect(card.querySelector('[data-slot=\"review-card-title\"]')!.textContent).toBe(\n\t\t\t\"Better in person\",\n\t\t);\n\t\tlet footer = card.querySelector<HTMLElement>('[data-slot=\"review-card-footer\"]')!;\n\t\texpect(footer.textContent).toBe(\"Maya R.2 weeks agoVerified buyer50×70 · Oak frameHelpful (3)\");\n\t\tlet helpful = footer.querySelector<HTMLElement>('[data-slot=\"review-card-helpful\"]')!;\n\t\texpect(Math.round(helpful.getBoundingClientRect().right)).toBe(\n\t\t\tMath.round(footer.getBoundingClientRect().right),\n\t\t);\n\t});\n\n\ttest(\"draws only the parts it is given, with no empty wrapper\", () => {\n\t\tmounted = render(\n\t\t\t<ReviewCard>\n\t\t\t\t<ReviewCard.Rating value={3} />\n\t\t\t\t<ReviewCard.Body>Fine.</ReviewCard.Body>\n\t\t\t\t<ReviewCard.Footer>\n\t\t\t\t\t<ReviewCard.Author>Sam</ReviewCard.Author>\n\t\t\t\t</ReviewCard.Footer>\n\t\t\t</ReviewCard>,\n\t\t);\n\t\tlet card = mounted.container.querySelector<HTMLElement>('[data-slot=\"review-card\"]')!;\n\t\texpect(card.querySelector('[data-slot=\"review-card-title\"]')).toBeNull();\n\t\texpect(card.querySelector('[data-slot=\"review-card-verified\"]')).toBeNull();\n\t\texpect(card.querySelector('[data-slot=\"review-card-helpful\"]')).toBeNull();\n\t\texpect(card.querySelector('[data-slot=\"review-card-header\"]')).toBeNull();\n\t\texpect(card.children).toHaveLength(3);\n\t});\n});\n"
17
17
  }
18
18
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "search-field",
3
- "changedIn": "2026.11.1",
3
+ "changedIn": "2026.11.29",
4
4
  "dependencies": [
5
5
  "button",
6
6
  "input"
@@ -10,7 +10,10 @@
10
10
  ],
11
11
  "source": {
12
12
  "path": "search-field.tsx",
13
- "content": "/**\n * A single-line search field: a `<search>` landmark stacking a caption, a\n * decorated control, and optional supporting or validation copy, composed\n * from whatever compound parts a given field needs. Its own\n * {@link SearchField.Input} part pairs a leading glyph with the native\n * `<input type=\"search\">` control it decorates, building on {@link Input} for\n * that control's box, color, and state styling, and\n * {@link SearchField.Control} rows that input with the\n * {@link SearchField.Clear} button that empties it.\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 { SearchIcon, XIcon } from \"@sdxc/icons\";\nimport { fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { pointerEvents, mergeMix } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tappearance,\n\tflex,\n\tgrow,\n\thidden,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\titems,\n\trelative,\n} from \"@sdxc/u/layout\";\nimport { bs, is, p, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { translateY } from \"@sdxc/u/transform\";\n\nimport { clearField, SEARCH_FIELD_CLEAR_COMMAND } from \"@sdxc/ui/mixins\";\nimport { fieldStackLayout } from \"@sdxc/ui/styles\";\n\nimport { Button } from \"@sdxc/ui/button\";\nimport { Input } from \"@sdxc/ui/input\";\n\n/**\n * Prop types for {@link SearchField} and its compound parts.\n */\nexport namespace SearchField {\n\t/**\n\t * Every native `<search>` attribute, unchanged, plus the `mix` passthrough.\n\t * `children` composes this field's parts — typically a caption, the\n\t * {@link SearchField.Input} control, and validation copy — in a single column.\n\t */\n\texport interface Props extends TagProps<\"search\"> {\n\t\t/** The field's compound parts: a caption, the control, and any supporting or validation copy. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every prop {@link Input} accepts except `type`, `list`, and `role`,\n\t * which this control fixes to `\"search\"` and the platform's own implicit\n\t * `searchbox` role on the consumer's behalf, plus the `mix` passthrough.\n\t */\n\texport interface InputProps extends Omit<Input.Props, \"type\" | \"list\" | \"role\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * `children` holds one control row: the {@link SearchField.Input} and the\n\t * {@link SearchField.Clear} button that empties it.\n\t */\n\texport interface ControlProps extends TagProps<\"div\"> {\n\t\t/** The row's contents: the search input, and the clear button reading it. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every prop {@link Button} accepts except `type`, `variant`, `size`, and\n\t * `command`, which this control fixes on the consumer's behalf, plus the\n\t * `mix` passthrough.\n\t */\n\texport interface ClearProps extends Omit<\n\t\tButton.Props,\n\t\t\"type\" | \"variant\" | \"size\" | \"command\" | \"children\"\n\t> {\n\t\t/** The `id` of the input this button empties, naming the control it belongs to. */\n\t\tcommandfor: string;\n\t\t/** Glyph or label the button shows. Defaults to a decorative {@link XIcon}. */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Renders a `<search>` landmark — the platform's own role for a search\n * region, needing no explicit `role` attribute — stacking a caption,\n * {@link SearchField.Input}, and validation copy in a single column.\n *\n * @param handle Runtime handle carrying the host `<search>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <SearchField>\n * \t<Label htmlFor=\"site-search\">{t(\"search.label\")}</Label>\n * \t<SearchField.Input id=\"site-search\" name=\"q\" placeholder={t(\"search.placeholder\")} />\n * </SearchField>\n * @example\n * <SearchField aria-label={t(\"search.label\")}>\n * \t<SearchField.Input name=\"q\" />\n * </SearchField>\n */\nexport function SearchField(handle: Handle<SearchField.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <search {...rest} data-slot=\"search-field\" mix={mergeMix(fieldStackLayout(), mix)} />;\n\t};\n}\n\n/**\n * Renders {@link SearchField}'s control: a positioning wrapper pairing a\n * muted, decorative {@link SearchIcon} with a native `<input type=\"search\">`\n * built on {@link Input}, inheriting its box, color, and state styling.\n *\n * The user agent's own cancel affordance is suppressed, so clearing the field is\n * {@link SearchField.Clear}'s job — one glyph the field styles and places, sitting\n * alone in the trailing corner.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <SearchField.Input aria-label={t(\"search.label\")} placeholder={t(\"search.placeholder\")} />\n * @example\n * <SearchField.Input name=\"q\" color=\"brand\" defaultValue=\"remix\" />\n */\nSearchField.Input = function SearchFieldInput(handle: Handle<SearchField.InputProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div data-slot=\"input-wrapper\" mix={[relative(), flex(), items(\"center\")]}>\n\t\t\t\t<SearchIcon\n\t\t\t\t\tsize={16}\n\t\t\t\t\tdata-slot=\"icon\"\n\t\t\t\t\tmix={[absolute(), insIs(\"0.75rem\"), pointerEvents(), fg(\"neutral.muted\")]}\n\t\t\t\t/>\n\t\t\t\t<Input\n\t\t\t\t\ttype=\"search\"\n\t\t\t\t\t{...rest}\n\t\t\t\t\tmix={mergeMix(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tpis(\"2.25rem\"),\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * {@link SearchField.Clear} draws the clear affordance, so the one the user agent draws\n\t\t\t\t\t\t\t * inside a search input holding a value is hidden to keep the two from stacking.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\twhen(\"&::-webkit-search-cancel-button\", [appearance(\"none\"), hidden()]),\n\t\t\t\t\t\t\twhen(\"&::-webkit-search-decoration\", [appearance(\"none\"), hidden()]),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tmix,\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders the row holding {@link SearchField.Input} and the\n * {@link SearchField.Clear} button beside it, and the positioning context that\n * anchors the clear button to the input's trailing edge.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the control row's markup.\n * @example\n * <SearchField.Control>\n * \t<SearchField.Input id=\"site-search\" name=\"q\" />\n * \t<SearchField.Clear commandfor=\"site-search\" aria-label={t(\"search.clear\")} />\n * </SearchField.Control>\n */\nSearchField.Control = function SearchFieldControl(handle: Handle<SearchField.ControlProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"control\"\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\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The input spans the row, so the field keeps the width its container offers.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen('& > [data-slot=\"input-wrapper\"]', grow()),\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 {@link SearchField}'s clear button: a round, icon-sized ghost\n * {@link Button} centred on the input's trailing edge, carrying `clearField()`\n * so it empties the `commandfor` input it names and shows while that input holds text.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the clear button's markup.\n * @example\n * <SearchField.Clear commandfor=\"site-search\" aria-label={t(\"search.clear\")} />\n * @example\n * <SearchField.Clear commandfor=\"site-search\">{t(\"search.clear\")}</SearchField.Clear>\n */\nSearchField.Clear = function SearchFieldClear(handle: Handle<SearchField.ClearProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\thidden\n\t\t\t\tvariant=\"ghost\"\n\t\t\t\tsize=\"sm\"\n\t\t\t\tcommand={SEARCH_FIELD_CLEAR_COMMAND}\n\t\t\t\tdata-slot=\"clear\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tclearField(),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A round, icon-sized target centred on the field, so its hover tint reads as a\n\t\t\t\t\t\t * disc beside the text, and its glyph sits as far from the trailing edge as the\n\t\t\t\t\t\t * search glyph sits from the leading one.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tis(7),\n\t\t\t\t\t\tbs(7),\n\t\t\t\t\t\tp(0),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\tinsIe(\"0.375rem\"),\n\t\t\t\t\t\tinsBs(\"50%\"),\n\t\t\t\t\t\ttranslateY(\"-50%\"),\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{children ?? <XIcon size={16} />}\n\t\t\t</Button>\n\t\t);\n\t};\n};\n"
13
+ "content": "/**\n * A single-line search field: a `<search>` landmark stacking a caption, a\n * decorated control, and optional supporting or validation copy, composed\n * from whatever compound parts a given field needs. Its own\n * {@link SearchField.Input} part pairs a leading glyph with the native\n * `<input type=\"search\">` control it decorates, building on {@link Input} for\n * that control's box, color, and state styling, and\n * {@link SearchField.Control} rows that input with the\n * {@link SearchField.Clear} button that empties it.\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 { SearchIcon, XIcon } from \"@sdxc/icons\";\nimport { fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { pointerEvents, mergeMix } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tappearance,\n\tflex,\n\tgrow,\n\thidden,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\titems,\n\trelative,\n} from \"@sdxc/u/layout\";\nimport { bs, is, p, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { translateY } from \"@sdxc/u/transform\";\n\nimport { clearField, SEARCH_FIELD_CLEAR_COMMAND } from \"@sdxc/ui/mixins\";\nimport { fieldStackLayout } from \"@sdxc/ui/styles\";\n\nimport { Button } from \"@sdxc/ui/button\";\nimport { Input } from \"@sdxc/ui/input\";\n\n/**\n * Matches an input inside a {@link SearchField.Control} whose clear button is still `hidden`:\n * before script reveals it, or whenever the field is empty.\n */\nconst AWAITING_CLEAR_SCRIPT = ':where([data-slot=\"control\"]:has(> [data-slot=\"clear\"][hidden]) *)';\n\n/**\n * Prop types for {@link SearchField} and its compound parts.\n */\nexport namespace SearchField {\n\t/**\n\t * Every native `<search>` attribute, unchanged, plus the `mix` passthrough.\n\t * `children` composes this field's parts — typically a caption, the\n\t * {@link SearchField.Input} control, and validation copy — in a single column.\n\t */\n\texport interface Props extends TagProps<\"search\"> {\n\t\t/** The field's compound parts: a caption, the control, and any supporting or validation copy. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every prop {@link Input} accepts except `type`, `list`, and `role`,\n\t * which this control fixes to `\"search\"` and the platform's own implicit\n\t * `searchbox` role on the consumer's behalf, plus the `mix` passthrough.\n\t */\n\texport interface InputProps extends Omit<Input.Props, \"type\" | \"list\" | \"role\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * `children` holds one control row: the {@link SearchField.Input} and the\n\t * {@link SearchField.Clear} button that empties it.\n\t */\n\texport interface ControlProps extends TagProps<\"div\"> {\n\t\t/** The row's contents: the search input, and the clear button reading it. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every prop {@link Button} accepts except `type`, `variant`, `size`, and\n\t * `command`, which this control fixes on the consumer's behalf, plus the\n\t * `mix` passthrough.\n\t */\n\texport interface ClearProps extends Omit<\n\t\tButton.Props,\n\t\t\"type\" | \"variant\" | \"size\" | \"command\" | \"children\"\n\t> {\n\t\t/** The `id` of the input this button empties, naming the control it belongs to. */\n\t\tcommandfor: string;\n\t\t/** Glyph or label the button shows. Defaults to a decorative {@link XIcon}. */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Renders a `<search>` landmark — the platform's own role for a search\n * region, needing no explicit `role` attribute — stacking a caption,\n * {@link SearchField.Input}, and validation copy in a single column.\n *\n * @param handle Runtime handle carrying the host `<search>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <SearchField>\n * \t<Label htmlFor=\"site-search\">{t(\"search.label\")}</Label>\n * \t<SearchField.Input id=\"site-search\" name=\"q\" placeholder={t(\"search.placeholder\")} />\n * </SearchField>\n * @example\n * <SearchField aria-label={t(\"search.label\")}>\n * \t<SearchField.Input name=\"q\" />\n * </SearchField>\n */\nexport function SearchField(handle: Handle<SearchField.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <search {...rest} data-slot=\"search-field\" mix={mergeMix(fieldStackLayout(), mix)} />;\n\t};\n}\n\n/**\n * Renders {@link SearchField}'s control: a positioning wrapper pairing a\n * muted, decorative {@link SearchIcon} with a native `<input type=\"search\">`\n * built on {@link Input}, inheriting its box, color, and state styling.\n *\n * Clearing the field is {@link SearchField.Clear}'s job — one glyph sitting alone in the\n * trailing corner. While that button stays `hidden`, as it does until script runs, the user\n * agent's own cancel button clears the field instead.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <SearchField.Input aria-label={t(\"search.label\")} placeholder={t(\"search.placeholder\")} />\n * @example\n * <SearchField.Input name=\"q\" color=\"brand\" defaultValue=\"remix\" />\n */\nSearchField.Input = function SearchFieldInput(handle: Handle<SearchField.InputProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div data-slot=\"input-wrapper\" mix={[relative(), flex(), items(\"center\")]}>\n\t\t\t\t<SearchIcon\n\t\t\t\t\tsize={16}\n\t\t\t\t\tdata-slot=\"icon\"\n\t\t\t\t\tmix={[absolute(), insIs(\"0.75rem\"), pointerEvents(), fg(\"neutral.muted\")]}\n\t\t\t\t/>\n\t\t\t\t<Input\n\t\t\t\t\ttype=\"search\"\n\t\t\t\t\t{...rest}\n\t\t\t\t\tmix={mergeMix(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tpis(\"2.25rem\"),\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * {@link SearchField.Clear} draws the clear affordance, so the one the user agent draws\n\t\t\t\t\t\t\t * inside a search input holding a value is hidden to keep the two from stacking. In a\n\t\t\t\t\t\t\t * control whose clear button is still `hidden`, the native one stays as the way to\n\t\t\t\t\t\t\t * clear the field with script off.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\twhen(`&:not(${AWAITING_CLEAR_SCRIPT})::-webkit-search-cancel-button`, [\n\t\t\t\t\t\t\t\tappearance(\"none\"),\n\t\t\t\t\t\t\t\thidden(),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen(\"&::-webkit-search-decoration\", [appearance(\"none\"), hidden()]),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tmix,\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders the row holding {@link SearchField.Input} and the\n * {@link SearchField.Clear} button beside it, and the positioning context that\n * anchors the clear button to the input's trailing edge.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the control row's markup.\n * @example\n * <SearchField.Control>\n * \t<SearchField.Input id=\"site-search\" name=\"q\" />\n * \t<SearchField.Clear commandfor=\"site-search\" aria-label={t(\"search.clear\")} />\n * </SearchField.Control>\n */\nSearchField.Control = function SearchFieldControl(handle: Handle<SearchField.ControlProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"control\"\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\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The input spans the row, so the field keeps the width its container offers.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen('& > [data-slot=\"input-wrapper\"]', grow()),\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 {@link SearchField}'s clear button: a round ghost {@link Button} on the input's\n * trailing edge whose `clearField()` empties the `commandfor` input and shows it while that\n * input holds text. With script off it stays hidden and the input's own cancel button clears.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the clear button's markup.\n * @example\n * <SearchField.Clear commandfor=\"site-search\" aria-label={t(\"search.clear\")} />\n * @example\n * <SearchField.Clear commandfor=\"site-search\">{t(\"search.clear\")}</SearchField.Clear>\n */\nSearchField.Clear = function SearchFieldClear(handle: Handle<SearchField.ClearProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\thidden\n\t\t\t\tvariant=\"ghost\"\n\t\t\t\tsize=\"sm\"\n\t\t\t\tcommand={SEARCH_FIELD_CLEAR_COMMAND}\n\t\t\t\tdata-slot=\"clear\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tclearField(),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A round, icon-sized target centred on the field, so its hover tint reads as a\n\t\t\t\t\t\t * disc beside the text, and its glyph sits as far from the trailing edge as the\n\t\t\t\t\t\t * search glyph sits from the leading one.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tis(7),\n\t\t\t\t\t\tbs(7),\n\t\t\t\t\t\tp(0),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\tinsIe(\"0.375rem\"),\n\t\t\t\t\t\tinsBs(\"50%\"),\n\t\t\t\t\t\ttranslateY(\"-50%\"),\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{children ?? <XIcon size={16} />}\n\t\t\t</Button>\n\t\t);\n\t};\n};\n"
14
14
  },
15
- "test": null
15
+ "test": {
16
+ "path": "search-field.browser.test.tsx",
17
+ "content": "/**\n * Renders `SearchField` in a real browser and checks how the field gets cleared: the native\n * cancel button stays available while the clear button is still hidden, as it is with script\n * off, and gives way to the clear button once script reveals it.\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 { SearchField } from \"@sdxc/ui/search-field\";\n\nimport \"@sdxc/ui/reset.css\";\nimport \"@sdxc/u/theme.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\n/** Mounts a field with a clear button and returns its input and button. */\nfunction mount() {\n\tlet host = document.createElement(\"div\");\n\tdocument.body.appendChild(host);\n\tmounted = render(\n\t\t<SearchField aria-label=\"Search\">\n\t\t\t<SearchField.Control>\n\t\t\t\t<SearchField.Input id=\"probe-search\" name=\"q\" />\n\t\t\t\t<SearchField.Clear commandfor=\"probe-search\" aria-label=\"Clear search\" />\n\t\t\t</SearchField.Control>\n\t\t</SearchField>,\n\t\t{ container: host },\n\t);\n\treturn {\n\t\tinput: host.querySelector<HTMLInputElement>(\"input\")!,\n\t\tclear: host.querySelector<HTMLButtonElement>('[data-slot=\"clear\"]')!,\n\t};\n}\n\n/** The pseudo-element the user agent draws its own cancel button as. */\nconst NATIVE_CANCEL = \"::-webkit-search-cancel-button\";\n\n/** A nested rule's selector with each `&` resolved against the rules that enclose it. */\nfunction resolvedSelector(rule: CSSStyleRule): string {\n\tlet parent = rule.parentRule;\n\twhile (parent !== null && !(parent instanceof CSSStyleRule)) parent = parent.parentRule;\n\tif (parent === null) return rule.selectorText;\n\treturn rule.selectorText.replaceAll(\"&\", `:is(${resolvedSelector(parent)})`);\n}\n\n/** Every style rule in the document's sheets, adopted ones included, nested ones flattened. */\nfunction styleRules(): CSSStyleRule[] {\n\tlet found: CSSStyleRule[] = [];\n\tlet walk = (rules: CSSRuleList) => {\n\t\tfor (let rule of rules) {\n\t\t\tif (rule instanceof CSSStyleRule) found.push(rule);\n\t\t\tif (\"cssRules\" in rule) walk((rule as CSSGroupingRule).cssRules);\n\t\t}\n\t};\n\tfor (let sheet of [...document.styleSheets, ...document.adoptedStyleSheets]) walk(sheet.cssRules);\n\treturn found;\n}\n\n/**\n * Whether a rule hides `input`'s native cancel button. Chromium computes no style for that\n * pseudo-element through `getComputedStyle`, so the check matches each hiding rule's selector,\n * minus the pseudo-element, against the live input.\n */\nfunction hidesNativeCancel(input: HTMLInputElement): boolean {\n\treturn styleRules().some((rule) => {\n\t\tif (!rule.selectorText.endsWith(NATIVE_CANCEL) || rule.style.display !== \"none\") return false;\n\t\treturn input.matches(resolvedSelector(rule).slice(0, -NATIVE_CANCEL.length));\n\t});\n}\n\ndescribe(\"SearchField clearing\", () => {\n\ttest(\"keeps the native cancel button while the clear button is still hidden\", () => {\n\t\tlet { input, clear } = mount();\n\t\t/** A value the clear button's script never saw, which is the page with script off. */\n\t\tinput.value = \"remix\";\n\n\t\texpect(clear.hidden).toBe(true);\n\t\texpect(hidesNativeCancel(input)).toBe(false);\n\t});\n\n\ttest(\"hides the native cancel button once the clear button shows\", () => {\n\t\tlet { input, clear } = mount();\n\t\tinput.value = \"remix\";\n\t\tinput.dispatchEvent(new Event(\"input\", { bubbles: true }));\n\n\t\texpect(clear.hidden).toBe(false);\n\t\texpect(hidesNativeCancel(input)).toBe(true);\n\t});\n\n\ttest(\"hides the native cancel button on an input with no clear button\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\tdocument.body.appendChild(host);\n\t\tmounted = render(\n\t\t\t<SearchField aria-label=\"Search\">\n\t\t\t\t<SearchField.Input name=\"q\" defaultValue=\"remix\" />\n\t\t\t</SearchField>,\n\t\t\t{ container: host },\n\t\t);\n\n\t\texpect(hidesNativeCancel(host.querySelector(\"input\")!)).toBe(true);\n\t});\n\n\ttest(\"empties the input when the clear button is pressed\", () => {\n\t\tlet { input, clear } = mount();\n\t\tinput.value = \"remix\";\n\t\tinput.dispatchEvent(new Event(\"input\", { bubbles: true }));\n\t\tclear.click();\n\n\t\texpect(input.value).toBe(\"\");\n\t\texpect(clear.hidden).toBe(true);\n\t});\n});\n"
18
+ }
16
19
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "section-bar",
3
- "changedIn": "2026.11.22",
3
+ "changedIn": "2026.11.29",
4
4
  "dependencies": [],
5
5
  "exports": [
6
6
  "SectionBar",
@@ -9,10 +9,10 @@
9
9
  ],
10
10
  "source": {
11
11
  "path": "section-bar.tsx",
12
- "content": "/**\n * A sticky row of chips linking to the sections of one long page, such as a menu's\n * categories or a product's specs. The links work as plain anchors; once its island loads,\n * the chip of the section being read is marked and slides into view inside the row.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { EntryComponent, Handle, Props as TagProps } from \"remix/component\";\n\nimport { mergeMix, raw } from \"@sdxc/u/general\";\nimport { motionReduce } from \"@sdxc/u/responsive\";\nimport { when } from \"@sdxc/u/state\";\nimport { clientEntry } from \"remix/component\";\n\n/** Prop types for {@link SectionBar}. */\nexport namespace SectionBar {\n\t/** One section the bar links to. */\n\texport interface Item {\n\t\t/** The section element's `id`, which the chip links to as `#id`. */\n\t\tid: string;\n\t\tlabel: string;\n\t\t/** A count after the label, such as how many dishes the category holds. */\n\t\tcount?: number;\n\t}\n\n\t/** Props accepted by {@link SectionBar}; the host is a `<nav>`. */\n\texport interface Props extends Omit<TagProps<\"nav\">, \"children\"> {\n\t\t/** The bar's `id`, unique on the page; its island finds the bar by it. */\n\t\tid: string;\n\t\t/** The landmark's name, such as \"Menu categories\". */\n\t\tlabel: string;\n\t\titems: Item[];\n\t\t/**\n\t\t * Where the bar sticks, as a CSS length from the top of the viewport, such as the\n\t\t * height of a sticky top bar above it. Each section gives itself a `scroll-margin-top`\n\t\t * of at least this plus the bar's own height, so a jump lands below the bar.\n\t\t *\n\t\t * @default \"0px\"\n\t\t */\n\t\ttop?: string;\n\t}\n\n\t/** Props {@link SectionBarSpy} serializes for hydration. */\n\texport type SpyProps = {\n\t\t/** The bar's `id`. */\n\t\tbar: string;\n\t};\n}\n\n/** The bar's own height, which a section's `scroll-margin-top` adds to the sticky offset. */\nexport const SECTION_BAR_BLOCK_SIZE = \"3.25rem\";\n\n/**\n * Renders the bar: a `<nav>` holding a sideways-scrolling row of chip links, the first one\n * marked current until the island reads the scroll.\n *\n * @example\n * <SectionBar id=\"menu-bar\" label=\"Menu categories\" top=\"4rem\" items={[{ id: \"tacos\", label: \"Tacos\", count: 3 }]} />\n */\nexport function SectionBar(handle: Handle<SectionBar.Props>) {\n\treturn () => {\n\t\tlet { id, label, items, top = \"0px\", mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<nav\n\t\t\t\t{...rest}\n\t\t\t\tid={id}\n\t\t\t\taria-label={label}\n\t\t\t\tdata-slot=\"section-bar\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tposition: \"sticky\",\n\t\t\t\t\t\t\tinsetBlockStart: top,\n\t\t\t\t\t\t\tzIndex: \"10\",\n\t\t\t\t\t\t\tblockSize: SECTION_BAR_BLOCK_SIZE,\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\tbackgroundColor: \"color-mix(in oklch, var(--ui-bg, Canvas) 92%, transparent)\",\n\t\t\t\t\t\t\tbackdropFilter: \"blur(12px) saturate(1.3)\",\n\t\t\t\t\t\t\tWebkitBackdropFilter: \"blur(12px) saturate(1.3)\",\n\t\t\t\t\t\t\tborderBlockEnd: \"1px solid var(--ui-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\t\t<ul\n\t\t\t\t\tdata-slot=\"section-bar-row\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tgap: \"0.375rem\",\n\t\t\t\t\t\t\tinlineSize: \"100%\",\n\t\t\t\t\t\t\tmargin: \"0\",\n\t\t\t\t\t\t\tpaddingBlock: \"0.5rem\",\n\t\t\t\t\t\t\tpaddingInline: \"var(--ui-section-bar-inset, 1rem)\",\n\t\t\t\t\t\t\tlistStyle: \"none\",\n\t\t\t\t\t\t\toverflowX: \"auto\",\n\t\t\t\t\t\t\toverscrollBehaviorInline: \"contain\",\n\t\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t\tscrollPaddingInline: \"var(--ui-section-bar-inset, 1rem)\",\n\t\t\t\t\t\t\t\"&::-webkit-scrollbar\": { display: \"none\" },\n\t\t\t\t\t\t}),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{items.map((item, index) => (\n\t\t\t\t\t\t<li mix={[raw({ flexShrink: \"0\" })]}>\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\thref={`#${item.id}`}\n\t\t\t\t\t\t\t\tdata-section={item.id}\n\t\t\t\t\t\t\t\taria-current={index === 0 ? \"true\" : undefined}\n\t\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\tdisplay: \"inline-flex\",\n\t\t\t\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\t\t\t\tgap: \"0.375rem\",\n\t\t\t\t\t\t\t\t\t\tblockSize: \"2.25rem\",\n\t\t\t\t\t\t\t\t\t\tpaddingInline: \"0.875rem\",\n\t\t\t\t\t\t\t\t\t\tborderRadius: \"999px\",\n\t\t\t\t\t\t\t\t\t\tfontSize: \"0.875rem\",\n\t\t\t\t\t\t\t\t\t\tfontWeight: \"550\",\n\t\t\t\t\t\t\t\t\t\twhiteSpace: \"nowrap\",\n\t\t\t\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg)\",\n\t\t\t\t\t\t\t\t\t\ttextDecoration: \"none\",\n\t\t\t\t\t\t\t\t\t\ttransition: \"background-color 160ms ease, color 160ms ease\",\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\t\t\t\"&:hover\",\n\t\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg-emphasis)\",\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-bg-tint)\",\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\twhen(\n\t\t\t\t\t\t\t\t\t\t\"&[aria-current='true']\",\n\t\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg-on-solid)\",\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-bg-solid)\",\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\twhen(\n\t\t\t\t\t\t\t\t\t\t\"&:focus-visible\",\n\t\t\t\t\t\t\t\t\t\traw({ outline: \"2px solid var(--ui-brand-ring)\", outlineOffset: \"2px\" }),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tmotionReduce(raw({ transition: \"none\" })),\n\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t\t\t{item.count === undefined ? null : (\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tdata-slot=\"section-bar-count\"\n\t\t\t\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\t\t\tfontVariantNumeric: \"tabular-nums\",\n\t\t\t\t\t\t\t\t\t\t\t\tfontWeight: \"500\",\n\t\t\t\t\t\t\t\t\t\t\t\topacity: \"0.65\",\n\t\t\t\t\t\t\t\t\t\t\t}),\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\t\t{item.count}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t))}\n\t\t\t\t</ul>\n\t\t\t\t<SectionBarSpy bar={id} />\n\t\t\t</nav>\n\t\t);\n\t};\n}\n\n/**\n * The island that follows the scroll: on each frame the page scrolls, the current section is\n * the last one whose top has passed under the bar, and its chip is marked and scrolled into\n * the row's view. A page scrolled to its end marks the last section, however short it is.\n */\nexport const SectionBarSpy: EntryComponent<SectionBar.SpyProps> = clientEntry(\n\t\"@sdxc/ui/section-bar#SectionBarSpy\",\n\tfunction SectionBarSpy(handle: Handle<SectionBar.SpyProps>) {\n\t\tlet pending = false;\n\t\tlet current = \"\";\n\n\t\t/** Marks one chip current and brings it into the row's view. */\n\t\tfunction mark(bar: HTMLElement, links: HTMLAnchorElement[], id: string) {\n\t\t\tif (id === current) return;\n\t\t\tcurrent = id;\n\t\t\tlet row = bar.querySelector<HTMLElement>('[data-slot=\"section-bar-row\"]');\n\t\t\tfor (let link of links) {\n\t\t\t\tlet on = link.dataset.section === id;\n\t\t\t\tif (on) link.setAttribute(\"aria-current\", \"true\");\n\t\t\t\telse link.removeAttribute(\"aria-current\");\n\t\t\t\tif (on && row !== null) {\n\t\t\t\t\tlet left = link.offsetLeft - (row.clientWidth - link.offsetWidth) / 2;\n\t\t\t\t\tlet smooth = !matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\t\t\t\t\trow.scrollTo({ left: Math.max(left, 0), behavior: smooth ? \"smooth\" : \"instant\" });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/** Reads which section is under the bar now. */\n\t\tfunction update(bar: HTMLElement) {\n\t\t\tpending = false;\n\t\t\tlet links = [...bar.querySelectorAll<HTMLAnchorElement>(\"a[data-section]\")];\n\t\t\tlet line = bar.getBoundingClientRect().bottom + 8;\n\t\t\tlet found = links[0]?.dataset.section ?? \"\";\n\t\t\tfor (let link of links) {\n\t\t\t\tlet section = document.getElementById(link.dataset.section ?? \"\");\n\t\t\t\tif (section !== null && section.getBoundingClientRect().top <= line) {\n\t\t\t\t\tfound = link.dataset.section ?? found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet atEnd =\n\t\t\t\tMath.ceil(window.scrollY + window.innerHeight) >= document.documentElement.scrollHeight - 2;\n\t\t\tif (atEnd) found = links.at(-1)?.dataset.section ?? found;\n\t\t\tmark(bar, links, found);\n\t\t}\n\n\t\thandle.queueTask(() => {\n\t\t\tlet bar = document.getElementById(handle.props.bar);\n\t\t\tif (bar === null || handle.signal.aborted) return;\n\t\t\tlet target = bar;\n\t\t\tlet schedule = () => {\n\t\t\t\tif (pending) return;\n\t\t\t\tpending = true;\n\t\t\t\trequestAnimationFrame(() => update(target));\n\t\t\t};\n\t\t\twindow.addEventListener(\"scroll\", schedule, { passive: true, signal: handle.signal });\n\t\t\twindow.addEventListener(\"resize\", schedule, { passive: true, signal: handle.signal });\n\t\t\tupdate(target);\n\t\t});\n\n\t\treturn () => <span hidden data-slot=\"section-bar-spy\" />;\n\t},\n);\n"
12
+ "content": "/**\n * A sticky row of chips linking to the sections of one long page, such as a menu's\n * categories or a product's specs. The links work as plain anchors; once its island loads,\n * the chip of the section being read is marked and slides into view inside the row.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { EntryComponent, Handle, Props as TagProps } from \"remix/component\";\n\nimport { mergeMix, raw } from \"@sdxc/u/general\";\nimport { motionReduce } from \"@sdxc/u/responsive\";\nimport { when } from \"@sdxc/u/state\";\nimport { clientEntry } from \"remix/component\";\n\n/** Prop types for {@link SectionBar} and its parts. */\nexport namespace SectionBar {\n\t/** Every native `<a>` attribute but `href` and `role`, plus the section it links to, which sets `href`. */\n\texport type LinkProps = Omit<TagProps<\"a\">, \"href\" | \"role\"> & {\n\t\t/** The section element's `id`, which the chip links to as `#id`. */\n\t\tsection: string;\n\t\t/** Marks the chip current before the island reads the scroll; set it on the first chip. */\n\t\tcurrent?: boolean;\n\t};\n\n\t/** Every native `<span>` attribute. */\n\texport interface CountProps extends TagProps<\"span\"> {}\n\n\t/**\n\t * Every native `<nav>` attribute; name the landmark with `aria-label`, such as \"Menu\n\t * categories\". The {@link SectionBar.Link}s go inside.\n\t */\n\texport interface Props extends TagProps<\"nav\"> {\n\t\t/** The bar's `id`, unique on the page; its island finds the bar by it. */\n\t\tid: string;\n\t\t/**\n\t\t * Where the bar sticks, as a CSS length from the top of the viewport, such as the\n\t\t * height of a sticky top bar above it. Each section gives itself a `scroll-margin-top`\n\t\t * of at least this plus the bar's own height, so a jump lands below the bar.\n\t\t *\n\t\t * @default \"0px\"\n\t\t */\n\t\ttop?: string;\n\t}\n\n\t/** Props {@link SectionBarSpy} serializes for hydration. */\n\texport type SpyProps = {\n\t\t/** The bar's `id`. */\n\t\tbar: string;\n\t};\n}\n\n/** The bar's own height, which a section's `scroll-margin-top` adds to the sticky offset. */\nexport const SECTION_BAR_BLOCK_SIZE = \"3.25rem\";\n\n/**\n * Renders the bar: a `<nav>` holding a sideways-scrolling row of {@link SectionBar.Link} chips,\n * the one written `current` marked until the island reads the scroll.\n *\n * @example\n * <SectionBar id=\"menu-bar\" aria-label=\"Menu categories\" top=\"4rem\">\n * \t<SectionBar.Link section=\"tacos\" current>Tacos <SectionBar.Count>3</SectionBar.Count></SectionBar.Link>\n * </SectionBar>\n */\nexport function SectionBar(handle: Handle<SectionBar.Props>) {\n\treturn () => {\n\t\tlet { id, children, top = \"0px\", mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<nav\n\t\t\t\t{...rest}\n\t\t\t\tid={id}\n\t\t\t\tdata-slot=\"section-bar\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tposition: \"sticky\",\n\t\t\t\t\t\t\tinsetBlockStart: top,\n\t\t\t\t\t\t\tzIndex: \"10\",\n\t\t\t\t\t\t\tblockSize: SECTION_BAR_BLOCK_SIZE,\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\tbackgroundColor: \"color-mix(in oklch, var(--ui-bg, Canvas) 92%, transparent)\",\n\t\t\t\t\t\t\tbackdropFilter: \"blur(12px) saturate(1.3)\",\n\t\t\t\t\t\t\tWebkitBackdropFilter: \"blur(12px) saturate(1.3)\",\n\t\t\t\t\t\t\tborderBlockEnd: \"1px solid var(--ui-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\t\t<ul\n\t\t\t\t\tdata-slot=\"section-bar-row\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tgap: \"0.375rem\",\n\t\t\t\t\t\t\tinlineSize: \"100%\",\n\t\t\t\t\t\t\tmargin: \"0\",\n\t\t\t\t\t\t\tpaddingBlock: \"0.5rem\",\n\t\t\t\t\t\t\tpaddingInline: \"var(--ui-section-bar-inset, 1rem)\",\n\t\t\t\t\t\t\tlistStyle: \"none\",\n\t\t\t\t\t\t\toverflowX: \"auto\",\n\t\t\t\t\t\t\toverscrollBehaviorInline: \"contain\",\n\t\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t\tscrollPaddingInline: \"var(--ui-section-bar-inset, 1rem)\",\n\t\t\t\t\t\t\t\"&::-webkit-scrollbar\": { display: \"none\" },\n\t\t\t\t\t\t}),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</ul>\n\t\t\t\t<SectionBarSpy bar={id} />\n\t\t\t</nav>\n\t\t);\n\t};\n}\n\n/**\n * One chip linking to a section as a plain anchor; the island marks it current while its\n * section is being read.\n *\n * @param handle Runtime handle carrying the link's props.\n * @returns The render function producing the list item and its chip.\n * @example <SectionBar.Link section=\"tacos\">Tacos</SectionBar.Link>\n */\nSectionBar.Link = function SectionBarLink(handle: Handle<SectionBar.LinkProps>) {\n\treturn () => {\n\t\tlet { section, current, mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<li mix={[raw({ flexShrink: \"0\" })]}>\n\t\t\t\t<a\n\t\t\t\t\tdata-slot=\"section-bar-link\"\n\t\t\t\t\t{...rest}\n\t\t\t\t\taria-current={current ? \"true\" : undefined}\n\t\t\t\t\thref={`#${section}`}\n\t\t\t\t\tdata-section={section}\n\t\t\t\t\tmix={mergeMix(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tdisplay: \"inline-flex\",\n\t\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\t\tgap: \"0.375rem\",\n\t\t\t\t\t\t\t\tblockSize: \"2.25rem\",\n\t\t\t\t\t\t\t\tpaddingInline: \"0.875rem\",\n\t\t\t\t\t\t\t\tborderRadius: \"999px\",\n\t\t\t\t\t\t\t\tfontSize: \"0.875rem\",\n\t\t\t\t\t\t\t\tfontWeight: \"550\",\n\t\t\t\t\t\t\t\twhiteSpace: \"nowrap\",\n\t\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg)\",\n\t\t\t\t\t\t\t\ttextDecoration: \"none\",\n\t\t\t\t\t\t\t\ttransition: \"background-color 160ms ease, color 160ms ease\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\t\"&:hover\",\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg-emphasis)\",\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-bg-tint)\",\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(\n\t\t\t\t\t\t\t\t\"&[aria-current='true']\",\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\tcolor: \"var(--ui-neutral-fg-on-solid)\",\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-bg-solid)\",\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(\n\t\t\t\t\t\t\t\t\"&:focus-visible\",\n\t\t\t\t\t\t\t\traw({ outline: \"2px solid var(--ui-brand-ring)\", outlineOffset: \"2px\" }),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tmotionReduce(raw({ transition: \"none\" })),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tmix,\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * A count after a chip's label, such as how many dishes the category holds.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the count.\n */\nSectionBar.Count = function SectionBarCount(handle: Handle<SectionBar.CountProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"section-bar-count\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[raw({ fontVariantNumeric: \"tabular-nums\", fontWeight: \"500\", opacity: \"0.65\" })],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The island that follows the scroll: on each frame the page scrolls, the current section is\n * the last one whose top has passed under the bar, and its chip is marked and scrolled into\n * the row's view. A page scrolled to its end marks the last section, however short it is.\n */\nexport const SectionBarSpy: EntryComponent<SectionBar.SpyProps> = clientEntry(\n\t\"@sdxc/ui/section-bar#SectionBarSpy\",\n\tfunction SectionBarSpy(handle: Handle<SectionBar.SpyProps>) {\n\t\tlet pending = false;\n\t\tlet current = \"\";\n\n\t\t/** Marks one chip current and brings it into the row's view. */\n\t\tfunction mark(bar: HTMLElement, links: HTMLAnchorElement[], id: string) {\n\t\t\tif (id === current) return;\n\t\t\tcurrent = id;\n\t\t\tlet row = bar.querySelector<HTMLElement>('[data-slot=\"section-bar-row\"]');\n\t\t\tfor (let link of links) {\n\t\t\t\tlet on = link.dataset.section === id;\n\t\t\t\tif (on) link.setAttribute(\"aria-current\", \"true\");\n\t\t\t\telse link.removeAttribute(\"aria-current\");\n\t\t\t\tif (on && row !== null) {\n\t\t\t\t\tlet left = link.offsetLeft - (row.clientWidth - link.offsetWidth) / 2;\n\t\t\t\t\tlet smooth = !matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\t\t\t\t\trow.scrollTo({ left: Math.max(left, 0), behavior: smooth ? \"smooth\" : \"instant\" });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/** Reads which section is under the bar now. */\n\t\tfunction update(bar: HTMLElement) {\n\t\t\tpending = false;\n\t\t\tlet links = [...bar.querySelectorAll<HTMLAnchorElement>(\"a[data-section]\")];\n\t\t\tlet line = bar.getBoundingClientRect().bottom + 8;\n\t\t\tlet found = links[0]?.dataset.section ?? \"\";\n\t\t\tfor (let link of links) {\n\t\t\t\tlet section = document.getElementById(link.dataset.section ?? \"\");\n\t\t\t\tif (section !== null && section.getBoundingClientRect().top <= line) {\n\t\t\t\t\tfound = link.dataset.section ?? found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet atEnd =\n\t\t\t\tMath.ceil(window.scrollY + window.innerHeight) >= document.documentElement.scrollHeight - 2;\n\t\t\tif (atEnd) found = links.at(-1)?.dataset.section ?? found;\n\t\t\tmark(bar, links, found);\n\t\t}\n\n\t\thandle.queueTask(() => {\n\t\t\tlet bar = document.getElementById(handle.props.bar);\n\t\t\tif (bar === null || handle.signal.aborted) return;\n\t\t\tlet target = bar;\n\t\t\tlet schedule = () => {\n\t\t\t\tif (pending) return;\n\t\t\t\tpending = true;\n\t\t\t\trequestAnimationFrame(() => update(target));\n\t\t\t};\n\t\t\twindow.addEventListener(\"scroll\", schedule, { passive: true, signal: handle.signal });\n\t\t\twindow.addEventListener(\"resize\", schedule, { passive: true, signal: handle.signal });\n\t\t\tupdate(target);\n\t\t});\n\n\t\treturn () => <span hidden data-slot=\"section-bar-spy\" />;\n\t},\n);\n"
13
13
  },
14
14
  "test": {
15
15
  "path": "section-bar.browser.test.tsx",
16
- "content": "/**\n * Holds the section bar to its contract in a real browser: it links each chip to its section,\n * sticks at its `top`, marks the first chip before any scroll, and once its island runs marks\n * the section under the bar as the page scrolls, down to the last one at the page's end.\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\";\n\nimport { SectionBar } from \"@sdxc/ui/section-bar\";\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\twindow.scrollTo(0, 0);\n});\n\n/** The sections the bar links to. */\nconst ITEMS: SectionBar.Item[] = [\n\t{ id: \"starters\", label: \"Starters\", count: 3 },\n\t{ id: \"mains\", label: \"Mains\", count: 5 },\n\t{ id: \"sides\", label: \"Sides\" },\n\t{ id: \"drinks\", label: \"Drinks\", count: 2 },\n];\n\n/** Mounts the bar over four tall sections and returns its chips. */\nfunction mount(): HTMLAnchorElement[] {\n\tmounted = render(\n\t\t<div>\n\t\t\t<SectionBar id=\"menu-bar\" label=\"Menu categories\" items={ITEMS} top=\"0px\" />\n\t\t\t{ITEMS.map((item, index) => (\n\t\t\t\t<section id={item.id} style={`block-size:${index === 3 ? 120 : 700}px`}>\n\t\t\t\t\t<h2>{item.label}</h2>\n\t\t\t\t</section>\n\t\t\t))}\n\t\t</div>,\n\t);\n\treturn [...mounted.container.querySelectorAll<HTMLAnchorElement>(\"a[data-section]\")];\n}\n\n/** Waits until a check passes, for an island that answers a scroll on the next frame. */\nasync function until(check: () => boolean, timeout = 2000): Promise<void> {\n\tlet start = performance.now();\n\twhile (!check()) {\n\t\tif (performance.now() - start > timeout) throw new Error(\"timed out\");\n\t\tawait new Promise((resolve) => requestAnimationFrame(resolve));\n\t}\n}\n\n/** Which chip is marked current. */\nfunction currentChip(links: HTMLAnchorElement[]): string | undefined {\n\treturn links.find((link) => link.getAttribute(\"aria-current\") === \"true\")?.dataset.section;\n}\n\ndescribe(\"SectionBar\", () => {\n\ttest(\"links every chip to its section and names its landmark\", () => {\n\t\tlet links = mount();\n\t\texpect(links.map((link) => link.getAttribute(\"href\"))).toEqual([\n\t\t\t\"#starters\",\n\t\t\t\"#mains\",\n\t\t\t\"#sides\",\n\t\t\t\"#drinks\",\n\t\t]);\n\t\tlet nav = mounted!.container.querySelector(\"nav\")!;\n\t\texpect(nav.getAttribute(\"aria-label\")).toBe(\"Menu categories\");\n\t\texpect(links[1]!.textContent).toBe(\"Mains5\");\n\t});\n\n\ttest(\"marks the first chip before the page scrolls\", () => {\n\t\tlet links = mount();\n\t\texpect(currentChip(links)).toBe(\"starters\");\n\t});\n\n\ttest(\"sticks to the top while its sections scroll under it\", async () => {\n\t\tmount();\n\t\tlet nav = mounted!.container.querySelector(\"nav\")!;\n\t\twindow.scrollTo(0, 900);\n\t\tawait until(() => Math.abs(nav.getBoundingClientRect().top) < 1);\n\t\texpect(getComputedStyle(nav).position).toBe(\"sticky\");\n\t});\n\n\ttest(\"follows the section under the bar, and the last one at the page's end\", async () => {\n\t\tlet links = mount();\n\t\tlet mains = document.getElementById(\"mains\")!;\n\t\twindow.scrollTo(0, mains.offsetTop - 20);\n\t\tawait until(() => currentChip(links) === \"mains\");\n\t\twindow.scrollTo(0, document.documentElement.scrollHeight);\n\t\tawait until(() => currentChip(links) === \"drinks\");\n\t\texpect(links.filter((link) => link.hasAttribute(\"aria-current\"))).toHaveLength(1);\n\t});\n});\n"
16
+ "content": "/**\n * Holds the section bar to its contract in a real browser: it links each chip to its section,\n * sticks at its `top`, marks the first chip before any scroll, and once its island runs marks\n * the section under the bar as the page scrolls, down to the last one at the page's end.\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\";\n\nimport { SectionBar } from \"@sdxc/ui/section-bar\";\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\twindow.scrollTo(0, 0);\n});\n\n/** One section the tests draw. */\ninterface Item {\n\tid: string;\n\tlabel: string;\n\tcount?: number;\n}\n\n/** The sections the bar links to. */\nconst ITEMS: Item[] = [\n\t{ id: \"starters\", label: \"Starters\", count: 3 },\n\t{ id: \"mains\", label: \"Mains\", count: 5 },\n\t{ id: \"sides\", label: \"Sides\" },\n\t{ id: \"drinks\", label: \"Drinks\", count: 2 },\n];\n\n/** Mounts the bar over four tall sections and returns its chips. */\nfunction mount(): HTMLAnchorElement[] {\n\tmounted = render(\n\t\t<div>\n\t\t\t<SectionBar id=\"menu-bar\" aria-label=\"Menu categories\" top=\"0px\">\n\t\t\t\t{ITEMS.map((item, index) => (\n\t\t\t\t\t<SectionBar.Link section={item.id} current={index === 0}>\n\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t{item.count === undefined ? null : <SectionBar.Count>{item.count}</SectionBar.Count>}\n\t\t\t\t\t</SectionBar.Link>\n\t\t\t\t))}\n\t\t\t</SectionBar>\n\t\t\t{ITEMS.map((item, index) => (\n\t\t\t\t<section id={item.id} style={`block-size:${index === 3 ? 120 : 700}px`}>\n\t\t\t\t\t<h2>{item.label}</h2>\n\t\t\t\t</section>\n\t\t\t))}\n\t\t</div>,\n\t);\n\treturn [...mounted.container.querySelectorAll<HTMLAnchorElement>(\"a[data-section]\")];\n}\n\n/** Waits until a check passes, for an island that answers a scroll on the next frame. */\nasync function until(check: () => boolean, timeout = 2000): Promise<void> {\n\tlet start = performance.now();\n\twhile (!check()) {\n\t\tif (performance.now() - start > timeout) throw new Error(\"timed out\");\n\t\tawait new Promise((resolve) => requestAnimationFrame(resolve));\n\t}\n}\n\n/** Which chip is marked current. */\nfunction currentChip(links: HTMLAnchorElement[]): string | undefined {\n\treturn links.find((link) => link.getAttribute(\"aria-current\") === \"true\")?.dataset.section;\n}\n\ndescribe(\"SectionBar\", () => {\n\ttest(\"links every chip to its section and names its landmark\", () => {\n\t\tlet links = mount();\n\t\texpect(links.map((link) => link.getAttribute(\"href\"))).toEqual([\n\t\t\t\"#starters\",\n\t\t\t\"#mains\",\n\t\t\t\"#sides\",\n\t\t\t\"#drinks\",\n\t\t]);\n\t\tlet nav = mounted!.container.querySelector(\"nav\")!;\n\t\texpect(nav.getAttribute(\"aria-label\")).toBe(\"Menu categories\");\n\t\texpect(links[1]!.textContent).toBe(\"Mains5\");\n\t});\n\n\ttest(\"marks the chip written current before the page scrolls\", () => {\n\t\tlet links = mount();\n\t\texpect(currentChip(links)).toBe(\"starters\");\n\t});\n\n\ttest(\"sticks to the top while its sections scroll under it\", async () => {\n\t\tmount();\n\t\tlet nav = mounted!.container.querySelector(\"nav\")!;\n\t\twindow.scrollTo(0, 900);\n\t\tawait until(() => Math.abs(nav.getBoundingClientRect().top) < 1);\n\t\texpect(getComputedStyle(nav).position).toBe(\"sticky\");\n\t});\n\n\ttest(\"follows the section under the bar, and the last one at the page's end\", async () => {\n\t\tlet links = mount();\n\t\tlet mains = document.getElementById(\"mains\")!;\n\t\twindow.scrollTo(0, mains.offsetTop - 20);\n\t\tawait until(() => currentChip(links) === \"mains\");\n\t\twindow.scrollTo(0, document.documentElement.scrollHeight);\n\t\tawait until(() => currentChip(links) === \"drinks\");\n\t\texpect(links.filter((link) => link.hasAttribute(\"aria-current\"))).toHaveLength(1);\n\t});\n});\n"
17
17
  }
18
18
  }