@sdxc/kit 2026.10.30 → 2026.11.3
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/README.md +59 -0
- package/changelog.jsonl +346 -0
- package/config.schema.json +14 -0
- package/dist/ci/install.d.ts +15 -0
- package/dist/ci/install.js +27 -0
- package/dist/ci/locate.d.ts +23 -0
- package/dist/ci/locate.js +43 -0
- package/dist/cli.js +5 -0
- package/dist/commands/ci/list.d.ts +16 -0
- package/dist/commands/ci/list.js +24 -0
- package/dist/commands/ci/run.d.ts +65 -0
- package/dist/commands/ci/run.js +36 -0
- package/dist/commands/ci/signoff.d.ts +15 -0
- package/dist/commands/ci/signoff.js +15 -0
- package/dist/commands/ci/verify.d.ts +17 -0
- package/dist/commands/ci/verify.js +15 -0
- package/dist/commands/create.js +3 -0
- package/dist/commands/pkg.d.ts +16 -0
- package/dist/commands/pkg.js +71 -0
- package/dist/commands/routes.d.ts +1 -1
- package/dist/config.d.ts +10 -4
- package/dist/config.js +8 -0
- package/dist/contract.d.ts +60 -1
- package/dist/contract.js +46 -0
- package/dist/create/workspace.d.ts +15 -0
- package/dist/create/workspace.js +42 -0
- package/dist/doctor/checks.js +4 -0
- package/dist/doctor/ci.d.ts +15 -0
- package/dist/doctor/ci.js +63 -0
- package/dist/doctor/translations.d.ts +19 -0
- package/dist/doctor/translations.js +144 -0
- package/dist/make/declare.js +32 -11
- package/dist/package-manager.d.ts +2 -0
- package/dist/package-manager.js +16 -2
- package/dist/pkg/catalog.d.ts +12 -0
- package/dist/pkg/catalog.js +153 -0
- package/dist/pkg/resolve.d.ts +67 -0
- package/dist/pkg/resolve.js +147 -0
- package/dist/upgrade/changelog.d.ts +2 -2
- package/dist/upgrade/project.d.ts +2 -2
- package/package.json +10 -8
- package/registry/ui/accordion.json +2 -2
- package/registry/ui/alert-dialog.json +2 -2
- package/registry/ui/alert.json +2 -2
- package/registry/ui/aspect-ratio.json +2 -2
- package/registry/ui/avatar.json +6 -3
- package/registry/ui/badge.json +2 -2
- package/registry/ui/banner.json +16 -0
- package/registry/ui/breadcrumbs.json +2 -2
- package/registry/ui/button.json +5 -3
- package/registry/ui/calendar.json +2 -2
- package/registry/ui/card.json +2 -2
- package/registry/ui/carousel.json +2 -2
- package/registry/ui/checkbox-group.json +2 -2
- package/registry/ui/checkbox.json +2 -2
- package/registry/ui/combobox.json +2 -2
- package/registry/ui/command.json +2 -2
- package/registry/ui/confirm.json +8 -4
- package/registry/ui/cta-group.json +2 -2
- package/registry/ui/date-field.json +2 -2
- package/registry/ui/date-picker.json +2 -2
- package/registry/ui/date-range-picker.json +2 -2
- package/registry/ui/description.json +2 -2
- package/registry/ui/dialog-dismiss.json +13 -0
- package/registry/ui/dialog.json +2 -2
- package/registry/ui/disclosure.json +2 -2
- package/registry/ui/drawer.json +2 -2
- package/registry/ui/field-error.json +2 -2
- package/registry/ui/form.json +2 -2
- package/registry/ui/group.json +2 -2
- package/registry/ui/header.json +2 -2
- package/registry/ui/heading-scope.json +2 -2
- package/registry/ui/heading.json +3 -3
- package/registry/ui/highlight.json +3 -3
- package/registry/ui/hover-card.json +2 -2
- package/registry/ui/image-placeholder.json +2 -2
- package/registry/ui/input.json +2 -2
- package/registry/ui/item.json +2 -2
- package/registry/ui/keyboard.json +2 -2
- package/registry/ui/label.json +2 -2
- package/registry/ui/link-button.json +5 -3
- package/registry/ui/link.json +2 -2
- package/registry/ui/listbox.json +2 -2
- package/registry/ui/menu.json +2 -2
- package/registry/ui/meter.json +2 -2
- package/registry/ui/modal.json +2 -2
- package/registry/ui/nav-link.json +2 -2
- package/registry/ui/navigation-menu.json +2 -2
- package/registry/ui/number-field.json +2 -2
- package/registry/ui/otp-field.json +2 -2
- package/registry/ui/overlay-arrow.json +2 -2
- package/registry/ui/pagination.json +2 -2
- package/registry/ui/popover.json +2 -2
- package/registry/ui/progress-bar.json +2 -2
- package/registry/ui/property-list.json +18 -0
- package/registry/ui/radio-group.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/relative-time.json +17 -0
- package/registry/ui/scroll-area.json +2 -2
- package/registry/ui/search-field.json +2 -2
- package/registry/ui/section.json +2 -2
- package/registry/ui/select.json +2 -2
- package/registry/ui/selection-indicator.json +2 -2
- package/registry/ui/sentinel-row.json +2 -2
- package/registry/ui/separator.json +2 -2
- package/registry/ui/shared-element.json +2 -2
- package/registry/ui/sheet.json +2 -2
- package/registry/ui/sidebar.json +2 -2
- package/registry/ui/slider.json +2 -2
- package/registry/ui/spinner.json +2 -2
- package/registry/ui/status-dot.json +16 -0
- package/registry/ui/switch.json +2 -2
- package/registry/ui/tabs.json +2 -2
- package/registry/ui/tag-group.json +2 -2
- package/registry/ui/text-field.json +7 -3
- package/registry/ui/text.json +2 -2
- package/registry/ui/textarea.json +2 -2
- package/registry/ui/time-field.json +2 -2
- package/registry/ui/timeline.json +16 -0
- package/registry/ui/toggle-button.json +2 -2
- package/registry/ui/tooltip.json +2 -2
- package/registry/ui/typeset.json +2 -2
- package/registry/ui/youtube-embed.json +2 -2
- package/stubs/scaffold.controller.index.stub +1 -1
- package/templates/app/.config/sdxc/ci.ts +26 -0
- package/templates/app/.github/workflows/ci.yml +46 -0
- package/templates/app/README.md +4 -0
- package/templates/app/package.json +1 -0
- package/templates/app/public/_headers +4 -0
- package/registry/ui/attachment.json +0 -15
- package/registry/ui/bubble.json +0 -13
- package/registry/ui/chart.json +0 -13
- package/registry/ui/color-area.json +0 -13
- package/registry/ui/color-field.json +0 -20
- package/registry/ui/color-picker.json +0 -17
- package/registry/ui/color-slider.json +0 -13
- package/registry/ui/color-swatch-picker.json +0 -15
- package/registry/ui/color-swatch.json +0 -13
- package/registry/ui/color-wheel.json +0 -13
- package/registry/ui/context-menu.json +0 -16
- package/registry/ui/drop-indicator.json +0 -13
- package/registry/ui/drop-zone.json +0 -13
- package/registry/ui/empty.json +0 -15
- package/registry/ui/feature.json +0 -18
- package/registry/ui/file-trigger.json +0 -13
- package/registry/ui/grid-list.json +0 -18
- package/registry/ui/logo-cloud.json +0 -16
- package/registry/ui/marker.json +0 -13
- package/registry/ui/marketing-header.json +0 -18
- package/registry/ui/marketing-section.json +0 -16
- package/registry/ui/menubar.json +0 -13
- package/registry/ui/message-scroller.json +0 -16
- package/registry/ui/message.json +0 -13
- package/registry/ui/resizable.json +0 -13
- package/registry/ui/shortcut-list.json +0 -18
- package/registry/ui/skeleton.json +0 -13
- package/registry/ui/split.json +0 -16
- package/registry/ui/stat-strip.json +0 -16
- package/registry/ui/table.json +0 -16
- package/registry/ui/toast.json +0 -16
- package/registry/ui/toolbar.json +0 -13
- package/registry/ui/tree.json +0 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "otp-field",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"input"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
11
|
"path": "otp-field.tsx",
|
|
12
|
-
"content": "/**\n * A one-time-code field: a native `<input>` defaulting to a numeric virtual\n * keyboard and the platform's SMS/email autofill hint for one-time codes,\n * built on {@link Input} for its box, color, and interaction-state styling.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Maximum code length {@link OtpField} falls back to when `length` is omitted. */\nconst DEFAULT_LENGTH = 6;\n\n/** Virtual-keyboard hint {@link OtpField} falls back to when `inputMode` is omitted. */\nconst DEFAULT_INPUT_MODE = \"numeric\";\n\n/** Platform autofill hint {@link OtpField} falls back to when `autoComplete` is omitted. */\nconst DEFAULT_AUTO_COMPLETE = \"one-time-code\";\n\n/**\n * Prop types for {@link OtpField}.\n */\nexport namespace OtpField {\n\t/**\n\t * Every {@link Input} prop except `type`, `list`, `role`, `inputMode`,\n\t * `autoComplete`, and `maxLength`, fixed to a plain text control with\n\t * `inputMode`/`autoComplete`/`length` read from the fields below instead.\n\t */\n\texport interface Props extends Omit<\n\t\tInput.Props,\n\t\t\"type\" | \"list\" | \"role\" | \"inputMode\" | \"autoComplete\" | \"maxLength\"\n\t> {\n\t\t/**\n\t\t * The one-time code's character count, applied as the control's native\n\t\t * `maxLength`. Defaults to {@link DEFAULT_LENGTH}.\n\t\t */\n\t\tlength?: number;\n\t\t/**\n\t\t * Virtual-keyboard hint passed straight through to the native `inputMode`\n\t\t * attribute. Defaults to {@link DEFAULT_INPUT_MODE}, requesting the\n\t\t * numeric keypad; set it to `\"text\"` for a code that mixes in letters.\n\t\t */\n\t\tinputMode?: Input.Props[\"inputMode\"];\n\t\t/**\n\t\t * Platform autofill hint passed straight through to the native\n\t\t * `autoComplete` attribute. Defaults to {@link DEFAULT_AUTO_COMPLETE}, which\n\t\t * a browser or OS keyboard looks for to offer an SMS or email code inline.\n\t\t */\n\t\tautoComplete?: Input.Props[\"autoComplete\"];\n\t}\n}\n\n/**\n * Renders a single native `<input>` for entering a one-time verification\n * code, built on {@link Input}, sized as one full-width control since a\n * single `<input>` is what carries `autoComplete=\"one-time-code\"` reliably.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"otp\">{t(\"auth.otp.label\")}</Label>\n * <OtpField id=\"otp\" name=\"code\" autoFocus />\n * @example\n * <OtpField\n * \tid=\"otp\"\n * \tname=\"code\"\n * \taria-describedby=\"otp-error\"\n * \taria-invalid=\"true\"\n * />\n * <FieldError id=\"otp-error\">{t(\"auth.otp.invalid\")}</FieldError>\n * @example\n * <OtpField\n * \tid=\"invite-code\"\n * \tname=\"inviteCode\"\n * \tlength={8}\n * \tinputMode=\"text\"\n * \tautoComplete=\"off\"\n * \tpattern=\"[A-Za-z0-9]*\"\n * />\n */\nexport function OtpField(handle: Handle<OtpField.Props>) {\n\treturn () => {\n\t\tlet { length, inputMode, autoComplete, mix, ...rest } = handle.props;\n\t\tlet resolvedLength = length ?? DEFAULT_LENGTH;\n\t\tlet resolvedInputMode = inputMode ?? DEFAULT_INPUT_MODE;\n\t\tlet resolvedAutoComplete = autoComplete ?? DEFAULT_AUTO_COMPLETE;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputMode={resolvedInputMode}\n\t\t\t\tautoComplete={resolvedAutoComplete}\n\t\t\t\tmaxLength={resolvedLength}\n\t\t\t\tdata-slot=\"otp-field\"\n\t\t\t\tmix={[textAlign(\"center\"), weight(500), tabularNums(), text(\"base\"), mix
|
|
12
|
+
"content": "/**\n * A one-time-code field: a native `<input>` defaulting to a numeric virtual\n * keyboard and the platform's SMS/email autofill hint for one-time codes,\n * built on {@link Input} for its box, color, and interaction-state styling.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { mergeMix } from \"@sdxc/u/general\";\nimport { tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Maximum code length {@link OtpField} falls back to when `length` is omitted. */\nconst DEFAULT_LENGTH = 6;\n\n/** Virtual-keyboard hint {@link OtpField} falls back to when `inputMode` is omitted. */\nconst DEFAULT_INPUT_MODE = \"numeric\";\n\n/** Platform autofill hint {@link OtpField} falls back to when `autoComplete` is omitted. */\nconst DEFAULT_AUTO_COMPLETE = \"one-time-code\";\n\n/**\n * Prop types for {@link OtpField}.\n */\nexport namespace OtpField {\n\t/**\n\t * Every {@link Input} prop except `type`, `list`, `role`, `inputMode`,\n\t * `autoComplete`, and `maxLength`, fixed to a plain text control with\n\t * `inputMode`/`autoComplete`/`length` read from the fields below instead.\n\t */\n\texport interface Props extends Omit<\n\t\tInput.Props,\n\t\t\"type\" | \"list\" | \"role\" | \"inputMode\" | \"autoComplete\" | \"maxLength\"\n\t> {\n\t\t/**\n\t\t * The one-time code's character count, applied as the control's native\n\t\t * `maxLength`. Defaults to {@link DEFAULT_LENGTH}.\n\t\t */\n\t\tlength?: number;\n\t\t/**\n\t\t * Virtual-keyboard hint passed straight through to the native `inputMode`\n\t\t * attribute. Defaults to {@link DEFAULT_INPUT_MODE}, requesting the\n\t\t * numeric keypad; set it to `\"text\"` for a code that mixes in letters.\n\t\t */\n\t\tinputMode?: Input.Props[\"inputMode\"];\n\t\t/**\n\t\t * Platform autofill hint passed straight through to the native\n\t\t * `autoComplete` attribute. Defaults to {@link DEFAULT_AUTO_COMPLETE}, which\n\t\t * a browser or OS keyboard looks for to offer an SMS or email code inline.\n\t\t */\n\t\tautoComplete?: Input.Props[\"autoComplete\"];\n\t}\n}\n\n/**\n * Renders a single native `<input>` for entering a one-time verification\n * code, built on {@link Input}, sized as one full-width control since a\n * single `<input>` is what carries `autoComplete=\"one-time-code\"` reliably.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"otp\">{t(\"auth.otp.label\")}</Label>\n * <OtpField id=\"otp\" name=\"code\" autoFocus />\n * @example\n * <OtpField\n * \tid=\"otp\"\n * \tname=\"code\"\n * \taria-describedby=\"otp-error\"\n * \taria-invalid=\"true\"\n * />\n * <FieldError id=\"otp-error\">{t(\"auth.otp.invalid\")}</FieldError>\n * @example\n * <OtpField\n * \tid=\"invite-code\"\n * \tname=\"inviteCode\"\n * \tlength={8}\n * \tinputMode=\"text\"\n * \tautoComplete=\"off\"\n * \tpattern=\"[A-Za-z0-9]*\"\n * />\n */\nexport function OtpField(handle: Handle<OtpField.Props>) {\n\treturn () => {\n\t\tlet { length, inputMode, autoComplete, mix, ...rest } = handle.props;\n\t\tlet resolvedLength = length ?? DEFAULT_LENGTH;\n\t\tlet resolvedInputMode = inputMode ?? DEFAULT_INPUT_MODE;\n\t\tlet resolvedAutoComplete = autoComplete ?? DEFAULT_AUTO_COMPLETE;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputMode={resolvedInputMode}\n\t\t\t\tautoComplete={resolvedAutoComplete}\n\t\t\t\tmaxLength={resolvedLength}\n\t\t\t\tdata-slot=\"otp-field\"\n\t\t\t\tmix={mergeMix([textAlign(\"center\"), weight(500), tabularNums(), text(\"base\")], mix)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
13
13
|
},
|
|
14
14
|
"test": null
|
|
15
15
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "overlay-arrow",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"OverlayArrow"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "overlay-arrow.tsx",
|
|
10
|
-
"content": "/**\n * A small pointer glyph anchoring an overlay surface — a popover, a menu, a\n * tooltip — visually back to the trigger it floats beside. It renders as an\n * absolutely positioned host holding whatever arrow shape a consumer draws\n * as its child (typically an inline `<svg>`), oriented and offset by the\n * `data-placement` attribute contract.\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 { fill } from \"@sdxc/u/color\";\nimport { calc, pointerEvents, var as varUtility } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinsLeft,\n\tinsRight,\n\titems,\n\tjustify,\n} from \"@sdxc/u/layout\";\nimport { is, mb, mi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { attrs } from \"remix/component\";\n\n/**\n * Side of the overlay {@link OverlayArrow} attaches to when `placement` is\n * left unset. Matches the side an overlay renders on when its own placement\n * request goes unanswered by the positioning engine.\n */\nconst DEFAULT_PLACEMENT: OverlayArrow.Placement = \"bottom\";\n\n/**\n * `aria-hidden=\"true\"` applied through {@link attrs} unless a consumer\n * overrides it, keeping the purely decorative pointer glyph out of the\n * accessibility tree.\n */\nconst DEFAULT_ARIA_HIDDEN = \"true\";\n\n/**\n * Prop types for {@link OverlayArrow}.\n */\nexport namespace OverlayArrow {\n\t/**\n\t * Side (and, for the four corner variants, alignment) of the trigger an\n\t * overlay renders relative to. {@link OverlayArrow} reads only the leading\n\t * segment; the `-start`/`-end` suffix carries no visual effect on the arrow.\n\t */\n\texport type Placement =\n\t\t| \"top\"\n\t\t| \"top-start\"\n\t\t| \"top-end\"\n\t\t| \"bottom\"\n\t\t| \"bottom-start\"\n\t\t| \"bottom-end\"\n\t\t| \"left\"\n\t\t| \"left-start\"\n\t\t| \"left-end\"\n\t\t| \"right\"\n\t\t| \"right-start\"\n\t\t| \"right-end\";\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, plus the\n\t * `placement` that drives which edge of the overlay the arrow attaches to.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Side of the trigger the overlay renders on. Defaults to\n\t\t * {@link DEFAULT_PLACEMENT}.\n\t\t */\n\t\tplacement?: Placement;\n\t}\n}\n\n/**\n * Renders a decorative pointer glyph, rotating to point back at the trigger\n * from whichever edge the overlay attaches to. `\"left\"`/`\"right\"` name a\n * physical viewport side, so the arrow keeps attaching there under any `dir`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the arrow's markup.\n * @example\n * <Popover>\n * \t<OverlayArrow placement=\"bottom\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function OverlayArrow(handle: Handle<OverlayArrow.Props>) {\n\treturn () => {\n\t\tlet { placement, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ARIA_HIDDEN }),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\t/**\n\t\t\t\t\t * The host spans the whole edge it attaches to, so centring the glyph inside it\n\t\t\t\t\t * is what puts the point under the trigger the surface is anchored to.\n\t\t\t\t\t */\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tfill(\"neutral.tint\"),\n\t\t\t\t\tpointerEvents(),\n\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', [\n\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\trotate(180),\n\t\t\t\t\t\tinsBs(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"top\"]', [\n\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\tinsBe(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * A side placement sits past the surface's own inline edge, where the space\n\t\t\t\t\t * left to grow into is none, so the glyph is sized from its own content the\n\t\t\t\t\t * way the block placements are sized from theirs.\n\t\t\t\t\t */\n\t\t\t\t\twhen('&[data-placement^=\"left\"]', [\n\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\trotate(-90),\n\t\t\t\t\t\tinsLeft(\"100%\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"right\"]', [\n\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\trotate(90),\n\t\t\t\t\t\tinsRight(\"100%\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t
|
|
10
|
+
"content": "/**\n * A small pointer glyph anchoring an overlay surface — a popover, a menu, a\n * tooltip — visually back to the trigger it floats beside. It renders as an\n * absolutely positioned host holding whatever arrow shape a consumer draws\n * as its child (typically an inline `<svg>`), oriented and offset by the\n * `data-placement` attribute contract.\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 { fill } from \"@sdxc/u/color\";\nimport { calc, pointerEvents, var as varUtility, mergeMix } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinsLeft,\n\tinsRight,\n\titems,\n\tjustify,\n} from \"@sdxc/u/layout\";\nimport { is, mb, mi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { attrs } from \"remix/component\";\n\n/**\n * Side of the overlay {@link OverlayArrow} attaches to when `placement` is\n * left unset. Matches the side an overlay renders on when its own placement\n * request goes unanswered by the positioning engine.\n */\nconst DEFAULT_PLACEMENT: OverlayArrow.Placement = \"bottom\";\n\n/**\n * `aria-hidden=\"true\"` applied through {@link attrs} unless a consumer\n * overrides it, keeping the purely decorative pointer glyph out of the\n * accessibility tree.\n */\nconst DEFAULT_ARIA_HIDDEN = \"true\";\n\n/**\n * Prop types for {@link OverlayArrow}.\n */\nexport namespace OverlayArrow {\n\t/**\n\t * Side (and, for the four corner variants, alignment) of the trigger an\n\t * overlay renders relative to. {@link OverlayArrow} reads only the leading\n\t * segment; the `-start`/`-end` suffix carries no visual effect on the arrow.\n\t */\n\texport type Placement =\n\t\t| \"top\"\n\t\t| \"top-start\"\n\t\t| \"top-end\"\n\t\t| \"bottom\"\n\t\t| \"bottom-start\"\n\t\t| \"bottom-end\"\n\t\t| \"left\"\n\t\t| \"left-start\"\n\t\t| \"left-end\"\n\t\t| \"right\"\n\t\t| \"right-start\"\n\t\t| \"right-end\";\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, plus the\n\t * `placement` that drives which edge of the overlay the arrow attaches to.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Side of the trigger the overlay renders on. Defaults to\n\t\t * {@link DEFAULT_PLACEMENT}.\n\t\t */\n\t\tplacement?: Placement;\n\t}\n}\n\n/**\n * Renders a decorative pointer glyph, rotating to point back at the trigger\n * from whichever edge the overlay attaches to. `\"left\"`/`\"right\"` name a\n * physical viewport side, so the arrow keeps attaching there under any `dir`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the arrow's markup.\n * @example\n * <Popover>\n * \t<OverlayArrow placement=\"bottom\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function OverlayArrow(handle: Handle<OverlayArrow.Props>) {\n\treturn () => {\n\t\tlet { placement, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ARIA_HIDDEN }),\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The host spans the whole edge it attaches to, so centring the glyph inside it\n\t\t\t\t\t\t * is what puts the point under the trigger the surface is anchored to.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tfill(\"neutral.tint\"),\n\t\t\t\t\t\tpointerEvents(),\n\t\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', [\n\t\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\t\trotate(180),\n\t\t\t\t\t\t\tinsBs(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-placement^=\"top\"]', [\n\t\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\t\tinsBe(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A side placement sits past the surface's own inline edge, where the space\n\t\t\t\t\t\t * left to grow into is none, so the glyph is sized from its own content the\n\t\t\t\t\t\t * way the block placements are sized from theirs.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen('&[data-placement^=\"left\"]', [\n\t\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\t\trotate(-90),\n\t\t\t\t\t\t\tinsLeft(\"100%\"),\n\t\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-placement^=\"right\"]', [\n\t\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\t\trotate(90),\n\t\t\t\t\t\t\tinsRight(\"100%\"),\n\t\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\t\tis(\"max-content\"),\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"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pagination",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Pagination"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "pagination.tsx",
|
|
10
|
-
"content": "/**\n * A navigation landmark for moving between pages of results, composing a\n * `<nav>` root, an `<ul>` list, and `<li>` items around two interactive\n * parts: {@link Pagination.Link} for page-number destinations and\n * {@link Pagination.Button} for previous/next controls. The active page reads\n * straight from the native `aria-current` attribute a consumer sets while\n * rendering the current page's link server-side, with no client-tracked\n * route state anywhere in this module.\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 { bg, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, pointerEvents } from \"@sdxc/u/general\";\nimport { flex, gap, inlineFlex, items, justify } from \"@sdxc/u/layout\";\nimport { bs, m, minIs, p, pi } from \"@sdxc/u/size\";\nimport { active, hover, when } from \"@sdxc/u/state\";\nimport { tabularNums, text, textDecoration, weight } from \"@sdxc/u/typography\";\n\nimport type { LinkPrefetch } from \"@sdxc/ui/utils\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { prefetchAttribute, rendersPrefetchHint } from \"@sdxc/ui/utils\";\nimport {\n\twarnIfNoAccessibleLabel,\n\twarnIfNoAccessibleName,\n} from \"@sdxc/ui/utils\";\n\n/**\n * `type` given to a {@link Pagination.Button} carrying an Invoker Command, for\n * which the platform accepts no other value.\n */\nconst INVOKER_TYPE = \"button\";\n\n/** Prefetch mode {@link Pagination.Link} falls back to when `prefetch` is omitted. */\nconst DEFAULT_PREFETCH: Pagination.Prefetch = \"none\";\n\n/**\n * Prop types for {@link Pagination} and its compound parts.\n */\nexport namespace Pagination {\n\t/**\n\t * Every native `<nav>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"nav\"> {}\n\n\t/**\n\t * Every native `<ul>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ListProps extends TagProps<\"ul\"> {}\n\n\t/**\n\t * Every native `<li>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ItemProps extends TagProps<\"li\"> {}\n\n\t/**\n\t * When a {@link Pagination.Link}'s destination starts loading, the same\n\t * modes every link component in this library accepts.\n\t */\n\texport type Prefetch = LinkPrefetch;\n\n\t/**\n\t * Every native `<a>` attribute, plus `prefetch` and the `mix` passthrough. A\n\t * type alias rather than an interface, since native anchor props resolve\n\t * through a conditional type an `interface extends` clause can't extend.\n\t */\n\texport type LinkProps = TagProps<\"a\"> & {\n\t\t/**\n\t\t * `\"intent\"`/`\"viewport\"` write `data-rmx-prefetch`; `\"render\"` adds a `<link rel=\"prefetch\">`\n\t\t * that also serves full-document navigations. The next-page link suits `\"render\"` or\n\t\t * `\"intent\"`. Defaults to {@link DEFAULT_PREFETCH}.\n\t\t */\n\t\tprefetch?: Prefetch;\n\t};\n\n\t/**\n\t * Every native `<button>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ButtonProps extends TagProps<\"button\"> {}\n}\n\n/**\n * Renders the pagination's `<nav>` root, laying its single {@link\n * Pagination.List} child out as a centered row. In dev mode, a root missing\n * `aria-label`/`aria-labelledby` logs a `console.warn` for assistive tech.\n *\n * @param handle Runtime handle carrying the host `<nav>`'s props.\n * @returns The render function producing the navigation landmark's markup.\n * @example\n * <Pagination aria-label={t(\"pagination.label\")}>\n * \t<Pagination.List>\n * \t\t<Pagination.Item>\n * \t\t\t<Pagination.Link href=\"?page=1\" aria-current=\"page\">1</Pagination.Link>\n * \t\t</Pagination.Item>\n * \t</Pagination.List>\n * </Pagination>\n */\nexport function Pagination(handle: Handle<Pagination.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Pagination: needs an \"aria-label\" or \"aria-labelledby\" identifying which set of results it paginates for assistive technology.',\n\t\t);\n\n\t\treturn <nav {...rest} data-slot=\"pagination\" mix={[flex(), items(\"center\"), mix]} />;\n\t};\n}\n\n/**\n * Renders the pagination's `<ul>` list, resetting native list markers and\n * spacing and laying {@link Pagination.Item} children out as a centered row\n * with a small gap between them.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Pagination.List>\n * \t<Pagination.Item>\n * \t\t<Pagination.Link href=\"?page=1\" aria-current=\"page\">1</Pagination.Link>\n * \t</Pagination.Item>\n * \t<Pagination.Item>\n * \t\t<Pagination.Link href=\"?page=2\">2</Pagination.Link>\n * \t</Pagination.Item>\n * </Pagination.List>\n */\nPagination.List = function PaginationList(handle: Handle<Pagination.ListProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"list\"\n\t\t\t\tmix={[flex(), items(\"center\"), gap(\"0.25rem\"), m(\"0\"), p(\"0\"), listStyle(), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a single `<li>` wrapping one {@link Pagination.Link} or\n * {@link Pagination.Button}, centering its content — this element carries no\n * visual styling of its own beyond the layout needed to hold its child.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props.\n * @returns The render function producing the item's markup.\n * @example\n * <Pagination.Item>\n * \t<Pagination.Link href=\"?page=3\">3</Pagination.Link>\n * </Pagination.Item>\n */\nPagination.Item = function PaginationItem(handle: Handle<Pagination.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <li {...rest} data-slot=\"item\" mix={[flex(), items(\"center\"), mix]} />;\n\t};\n};\n\n/**\n * Renders a page-number destination as a native `<a>`, followed by its\n * `<link rel=\"prefetch\">` when `prefetch=\"render\"`. `aria-current=\"page\"` fills\n * it with the active-page treatment; `aria-disabled=\"true\"` mutes it.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the link's markup.\n * @example\n * <Pagination.Link href=\"?page=6\" prefetch=\"render\">6</Pagination.Link>\n * @example\n * <Pagination.Link href=\"?page=5\" aria-current=\"page\">5</Pagination.Link>\n * @example\n * <Pagination.Link aria-disabled=\"true\">…</Pagination.Link>\n */\nPagination.Link = function PaginationLink(handle: Handle<Pagination.LinkProps>) {\n\treturn () => {\n\t\tlet { prefetch, mix, ...rest } = handle.props;\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"link\"\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tbs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\tminIs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\tweight(500),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', opacity(50)),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), pointerEvents()]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\n\t\tif (!rendersPrefetchHint(resolvedPrefetch, rest.href)) return anchor;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{anchor}\n\t\t\t\t<link rel=\"prefetch\" href={rest.href} />\n\t\t\t</>\n\t\t);\n\t};\n};\n\n/**\n * Renders a previous/next control as a native `<button>`. A control with\n * `command`/`commandfor` renders `type=\"button\"` first, since the platform's\n * ambiguity check can't see a `type` written after those attributes.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <Pagination.Button aria-label={t(\"pagination.previous\")} disabled={!hasPreviousPage}>\n * \t<ChevronLeftIcon aria-hidden />\n * </Pagination.Button>\n * @example\n * <Pagination.Button aria-label={t(\"pagination.next\")} disabled={!hasNextPage}>\n * \t<ChevronRightIcon aria-hidden />\n * </Pagination.Button>\n */\nPagination.Button = function PaginationButton(handle: Handle<Pagination.ButtonProps>) {\n\treturn () => {\n\t\tlet { type, children, mix, ...rest } = handle.props;\n\t\tlet isInvoker = rest.command !== undefined || rest.commandfor !== undefined;\n\t\tlet resolvedType = type ?? (isInvoker ? INVOKER_TYPE : undefined);\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t'Pagination.Button: an icon-only control needs an \"aria-label\" describing what it does — assistive technology has no accessible text to announce otherwise.',\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"button\"\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tbs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\tminIs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\tweight(500),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\twhen(\"&:disabled\", opacity(50)),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\twhen(\"&:disabled\", cursor(\"not-allowed\")),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n"
|
|
10
|
+
"content": "/**\n * A navigation landmark for moving between pages of results, composing a\n * `<nav>` root, an `<ul>` list, and `<li>` items around two interactive\n * parts: {@link Pagination.Link} for page-number destinations and\n * {@link Pagination.Button} for previous/next controls. The active page reads\n * straight from the native `aria-current` attribute a consumer sets while\n * rendering the current page's link server-side, with no client-tracked\n * route state anywhere in this module.\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 { bg, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, pointerEvents, mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, inlineFlex, items, justify } from \"@sdxc/u/layout\";\nimport { bs, m, minIs, p, pi } from \"@sdxc/u/size\";\nimport { active, hover, when } from \"@sdxc/u/state\";\nimport { tabularNums, text, textDecoration, weight } from \"@sdxc/u/typography\";\n\nimport type { LinkPrefetch } from \"@sdxc/ui/utils\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { prefetchAttribute, rendersPrefetchHint } from \"@sdxc/ui/utils\";\nimport {\n\twarnIfNoAccessibleLabel,\n\twarnIfNoAccessibleName,\n} from \"@sdxc/ui/utils\";\n\n/**\n * `type` given to a {@link Pagination.Button} carrying an Invoker Command, for\n * which the platform accepts no other value.\n */\nconst INVOKER_TYPE = \"button\";\n\n/** Prefetch mode {@link Pagination.Link} falls back to when `prefetch` is omitted. */\nconst DEFAULT_PREFETCH: Pagination.Prefetch = \"none\";\n\n/**\n * Prop types for {@link Pagination} and its compound parts.\n */\nexport namespace Pagination {\n\t/**\n\t * Every native `<nav>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"nav\"> {}\n\n\t/**\n\t * Every native `<ul>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ListProps extends TagProps<\"ul\"> {}\n\n\t/**\n\t * Every native `<li>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ItemProps extends TagProps<\"li\"> {}\n\n\t/**\n\t * When a {@link Pagination.Link}'s destination starts loading, the same\n\t * modes every link component in this library accepts.\n\t */\n\texport type Prefetch = LinkPrefetch;\n\n\t/**\n\t * Every native `<a>` attribute, plus `prefetch` and the `mix` passthrough. A\n\t * type alias rather than an interface, since native anchor props resolve\n\t * through a conditional type an `interface extends` clause can't extend.\n\t */\n\texport type LinkProps = TagProps<\"a\"> & {\n\t\t/**\n\t\t * `\"intent\"`/`\"viewport\"` write `data-rmx-prefetch`; `\"render\"` adds a `<link rel=\"prefetch\">`\n\t\t * that also serves full-document navigations. The next-page link suits `\"render\"` or\n\t\t * `\"intent\"`. Defaults to {@link DEFAULT_PREFETCH}.\n\t\t */\n\t\tprefetch?: Prefetch;\n\t};\n\n\t/**\n\t * Every native `<button>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ButtonProps extends TagProps<\"button\"> {}\n}\n\n/**\n * Renders the pagination's `<nav>` root, laying its single {@link\n * Pagination.List} child out as a centered row. In dev mode, a root missing\n * `aria-label`/`aria-labelledby` logs a `console.warn` for assistive tech.\n *\n * @param handle Runtime handle carrying the host `<nav>`'s props.\n * @returns The render function producing the navigation landmark's markup.\n * @example\n * <Pagination aria-label={t(\"pagination.label\")}>\n * \t<Pagination.List>\n * \t\t<Pagination.Item>\n * \t\t\t<Pagination.Link href=\"?page=1\" aria-current=\"page\">1</Pagination.Link>\n * \t\t</Pagination.Item>\n * \t</Pagination.List>\n * </Pagination>\n */\nexport function Pagination(handle: Handle<Pagination.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Pagination: needs an \"aria-label\" or \"aria-labelledby\" identifying which set of results it paginates for assistive technology.',\n\t\t);\n\n\t\treturn <nav {...rest} data-slot=\"pagination\" mix={mergeMix([flex(), items(\"center\")], mix)} />;\n\t};\n}\n\n/**\n * Renders the pagination's `<ul>` list, resetting native list markers and\n * spacing and laying {@link Pagination.Item} children out as a centered row\n * with a small gap between them.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Pagination.List>\n * \t<Pagination.Item>\n * \t\t<Pagination.Link href=\"?page=1\" aria-current=\"page\">1</Pagination.Link>\n * \t</Pagination.Item>\n * \t<Pagination.Item>\n * \t\t<Pagination.Link href=\"?page=2\">2</Pagination.Link>\n * \t</Pagination.Item>\n * </Pagination.List>\n */\nPagination.List = function PaginationList(handle: Handle<Pagination.ListProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"list\"\n\t\t\t\tmix={mergeMix([flex(), items(\"center\"), gap(\"0.25rem\"), m(\"0\"), p(\"0\"), listStyle()], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a single `<li>` wrapping one {@link Pagination.Link} or\n * {@link Pagination.Button}, centering its content — this element carries no\n * visual styling of its own beyond the layout needed to hold its child.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props.\n * @returns The render function producing the item's markup.\n * @example\n * <Pagination.Item>\n * \t<Pagination.Link href=\"?page=3\">3</Pagination.Link>\n * </Pagination.Item>\n */\nPagination.Item = function PaginationItem(handle: Handle<Pagination.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <li {...rest} data-slot=\"item\" mix={mergeMix([flex(), items(\"center\")], mix)} />;\n\t};\n};\n\n/**\n * Renders a page-number destination as a native `<a>`, followed by its\n * `<link rel=\"prefetch\">` when `prefetch=\"render\"`. `aria-current=\"page\"` fills\n * it with the active-page treatment; `aria-disabled=\"true\"` mutes it.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the link's markup.\n * @example\n * <Pagination.Link href=\"?page=6\" prefetch=\"render\">6</Pagination.Link>\n * @example\n * <Pagination.Link href=\"?page=5\" aria-current=\"page\">5</Pagination.Link>\n * @example\n * <Pagination.Link aria-disabled=\"true\">…</Pagination.Link>\n */\nPagination.Link = function PaginationLink(handle: Handle<Pagination.LinkProps>) {\n\treturn () => {\n\t\tlet { prefetch, mix, ...rest } = handle.props;\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"link\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tbs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\t\tminIs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\twhen('&[aria-disabled=\"true\"]', opacity(50)),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), pointerEvents()]),\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\n\t\tif (!rendersPrefetchHint(resolvedPrefetch, rest.href)) return anchor;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{anchor}\n\t\t\t\t<link rel=\"prefetch\" href={rest.href} />\n\t\t\t</>\n\t\t);\n\t};\n};\n\n/**\n * Renders a previous/next control as a native `<button>`. A control with\n * `command`/`commandfor` renders `type=\"button\"` first, since the platform's\n * ambiguity check can't see a `type` written after those attributes.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <Pagination.Button aria-label={t(\"pagination.previous\")} disabled={!hasPreviousPage}>\n * \t<ChevronLeftIcon aria-hidden />\n * </Pagination.Button>\n * @example\n * <Pagination.Button aria-label={t(\"pagination.next\")} disabled={!hasNextPage}>\n * \t<ChevronRightIcon aria-hidden />\n * </Pagination.Button>\n */\nPagination.Button = function PaginationButton(handle: Handle<Pagination.ButtonProps>) {\n\treturn () => {\n\t\tlet { type, children, mix, ...rest } = handle.props;\n\t\tlet isInvoker = rest.command !== undefined || rest.commandfor !== undefined;\n\t\tlet resolvedType = type ?? (isInvoker ? INVOKER_TYPE : undefined);\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t'Pagination.Button: an icon-only control needs an \"aria-label\" describing what it does — assistive technology has no accessible text to announce otherwise.',\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"button\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tbs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\t\tminIs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\twhen(\"&:disabled\", opacity(50)),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\twhen(\"&:disabled\", cursor(\"not-allowed\")),\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}\n\t\t\t</button>\n\t\t);\n\t};\n};\n"
|
|
11
11
|
},
|
|
12
12
|
"test": {
|
|
13
13
|
"path": "pagination.test.tsx",
|
package/registry/ui/popover.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "popover",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Popover"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "popover.tsx",
|
|
10
|
-
"content": "/**\n * A floating surface anchored to whatever element opened it, built entirely\n * on the native Popover API: the host carries the `popover` attribute and\n * opens through `popovertarget` or a Command Invoker (`commandfor`/\n * `command=\"toggle-popover\"`) elsewhere on the page, with no positioning\n * logic running in script. Placement rides CSS anchor positioning, using\n * the invoker relationship as an implicit anchor and the `data-placement`\n * attribute to pick which `position-area` it resolves against.\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 { raw } from \"@sdxc/u/general\";\nimport { inset, positionArea, positionTryFallbacks } from \"@sdxc/u/layout\";\nimport { m, marginLeft, marginRight, mbe, mbs } from \"@sdxc/u/size\";\nimport { data, when } from \"@sdxc/u/state\";\n\nimport type { AnchorPlacement } from \"@sdxc/ui/utils\";\n\nimport { floatingSurface } from \"@sdxc/ui/styles\";\n\n/**\n * Side of the anchor {@link Popover} renders against when `placement` is\n * left unset.\n */\nconst DEFAULT_PLACEMENT: Popover.Placement = \"bottom\";\n\n/**\n * `popover` attribute mode applied when a consumer leaves it unset, giving\n * the host light-dismiss behavior: it closes on outside click or Escape, and\n * showing it closes any other `\"auto\"` popover already open.\n */\nconst DEFAULT_MODE: NonNullable<Popover.Props[\"popover\"]> = \"auto\";\n\n/**\n * Prop types for {@link Popover}.\n */\nexport namespace Popover {\n\t/**\n\t * Side of the anchor the host renders against, and, for the four corner\n\t * variants, which anchor edge it aligns to along the perpendicular axis.\n\t * Each name is a physical viewport side, fixed under any `dir` value.\n\t */\n\texport type Placement = AnchorPlacement;\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, with `id`\n\t * narrowed to required, since `popovertarget`, `commandfor`, and the host's\n\t * own implicit CSS anchor reference all target it by that id.\n\t */\n\texport interface Props extends Omit<TagProps<\"div\">, \"id\" | \"popover\"> {\n\t\t/** Stable id an invoker elsewhere on the page targets to open this host. */\n\t\tid: string;\n\t\t/**\n\t\t * `popover` attribute mode: `\"auto\"` dismisses on outside click or Escape\n\t\t * and closes sibling `\"auto\"` popovers when shown; `\"hint\"` layers over an\n\t\t * open one without closing it; `\"manual\"` closes only when hidden explicitly.\n\t\t *\n\t\t * @default {@link DEFAULT_MODE}\n\t\t */\n\t\tpopover?: \"auto\" | \"hint\" | \"manual\";\n\t\t/** Side of the anchor to render against. Defaults to {@link DEFAULT_PLACEMENT}. */\n\t\tplacement?: Placement;\n\t\t/** The popover's content. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the floating surface itself: a `popover`-attributed `<div>`\n * positioned via CSS anchor positioning. The invoker that opens it becomes\n * the implicit anchor its `position-area` resolves against.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the surface's markup.\n * @example\n * <button commandfor=\"account-menu\" command=\"toggle-popover\">{t(\"nav.account\")}</button>\n * <Popover id=\"account-menu\" placement=\"bottom-start\">\n * \t<p>{t(\"nav.accountMenu.body\")}</p>\n * </Popover>\n * @example\n * <Popover id=\"filters\" placement=\"top\" mix={[fade({ duration: durations.normal })]}>\n * \t<OverlayArrow placement=\"top\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function Popover(handle: Handle<Popover.Props>) {\n\treturn () => {\n\t\tlet { id, popover, placement, children, mix, ...rest } = handle.props;\n\t\tlet resolvedMode = popover ?? DEFAULT_MODE;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={id}\n\t\t\t\tpopover={resolvedMode}\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tfloatingSurface(),\n\t\t\t\t\tm(\"0\"),\n\t\t\t\t\tinset(\"auto\"),\n\t\t\t\t\twhen('&[data-placement^=\"top\"]', mbe(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', mbs(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\twhen('&[data-placement^=\"left\"]', marginRight(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\twhen('&[data-placement^=\"right\"]', marginLeft(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\tpositionTryFallbacks(\"flip-block\", \"flip-inline\", \"flip-block flip-inline\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * A corner placement aligns one pair of edges and grows away from it, so the surface\n\t\t\t\t\t * occupies the anchor's own track and spans the one beyond it, flush with the anchor's edge.\n\t\t\t\t\t */\n\t\t\t\t\tdata(\"placement\", \"top\", positionArea(\"top\")),\n\t\t\t\t\tdata(\"placement\", \"top-start\", positionArea(\"top span-right\")),\n\t\t\t\t\tdata(\"placement\", \"top-end\", positionArea(\"top span-left\")),\n\t\t\t\t\tdata(\"placement\", \"bottom\", positionArea(\"bottom\")),\n\t\t\t\t\tdata(\"placement\", \"bottom-start\", positionArea(\"bottom span-right\")),\n\t\t\t\t\tdata(\"placement\", \"bottom-end\", positionArea(\"bottom span-left\")),\n\t\t\t\t\tdata(\"placement\", \"left\", positionArea(\"left\")),\n\t\t\t\t\tdata(\"placement\", \"left-start\", positionArea(\"left span-bottom\")),\n\t\t\t\t\tdata(\"placement\", \"left-end\", positionArea(\"left span-top\")),\n\t\t\t\t\tdata(\"placement\", \"right\", positionArea(\"right\")),\n\t\t\t\t\tdata(\"placement\", \"right-start\", positionArea(\"right span-bottom\")),\n\t\t\t\t\tdata(\"placement\", \"right-end\", positionArea(\"right span-top\")),\n\t\t\t\t\t/**\n\t\t\t\t\t * Layout parts on this surface set `display` and beat the UA's closed `display: none`, so\n\t\t\t\t\t * the closed state is important to outrank a consumer's later sublayer. A `\"hint\"` surface\n\t\t\t\t\t * reveals itself from CSS state on its trigger, so it keeps its own hidden state.\n\t\t\t\t\t */\n\t\t\t\t\twhen('&:not(:popover-open):not([popover=\"hint\"])', raw({ display: \"none !important\" })),\n\t\t\t\t\tmix,\n\t\t\t\t
|
|
10
|
+
"content": "/**\n * A floating surface anchored to whatever element opened it, built entirely\n * on the native Popover API: the host carries the `popover` attribute and\n * opens through `popovertarget` or a Command Invoker (`commandfor`/\n * `command=\"toggle-popover\"`) elsewhere on the page, with no positioning\n * logic running in script. Placement rides CSS anchor positioning, using\n * the invoker relationship as an implicit anchor and the `data-placement`\n * attribute to pick which `position-area` it resolves against.\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 { raw, mergeMix } from \"@sdxc/u/general\";\nimport { inset, positionArea, positionTryFallbacks } from \"@sdxc/u/layout\";\nimport { m, marginLeft, marginRight, mbe, mbs } from \"@sdxc/u/size\";\nimport { data, when } from \"@sdxc/u/state\";\n\nimport type { AnchorPlacement } from \"@sdxc/ui/utils\";\n\nimport { floatingSurface } from \"@sdxc/ui/styles\";\n\n/**\n * Side of the anchor {@link Popover} renders against when `placement` is\n * left unset.\n */\nconst DEFAULT_PLACEMENT: Popover.Placement = \"bottom\";\n\n/**\n * `popover` attribute mode applied when a consumer leaves it unset, giving\n * the host light-dismiss behavior: it closes on outside click or Escape, and\n * showing it closes any other `\"auto\"` popover already open.\n */\nconst DEFAULT_MODE: NonNullable<Popover.Props[\"popover\"]> = \"auto\";\n\n/**\n * Prop types for {@link Popover}.\n */\nexport namespace Popover {\n\t/**\n\t * Side of the anchor the host renders against, and, for the four corner\n\t * variants, which anchor edge it aligns to along the perpendicular axis.\n\t * Each name is a physical viewport side, fixed under any `dir` value.\n\t */\n\texport type Placement = AnchorPlacement;\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, with `id`\n\t * narrowed to required, since `popovertarget`, `commandfor`, and the host's\n\t * own implicit CSS anchor reference all target it by that id.\n\t */\n\texport interface Props extends Omit<TagProps<\"div\">, \"id\" | \"popover\"> {\n\t\t/** Stable id an invoker elsewhere on the page targets to open this host. */\n\t\tid: string;\n\t\t/**\n\t\t * `popover` attribute mode: `\"auto\"` dismisses on outside click or Escape\n\t\t * and closes sibling `\"auto\"` popovers when shown; `\"hint\"` layers over an\n\t\t * open one without closing it; `\"manual\"` closes only when hidden explicitly.\n\t\t *\n\t\t * @default {@link DEFAULT_MODE}\n\t\t */\n\t\tpopover?: \"auto\" | \"hint\" | \"manual\";\n\t\t/** Side of the anchor to render against. Defaults to {@link DEFAULT_PLACEMENT}. */\n\t\tplacement?: Placement;\n\t\t/** The popover's content. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the floating surface itself: a `popover`-attributed `<div>`\n * positioned via CSS anchor positioning. The invoker that opens it becomes\n * the implicit anchor its `position-area` resolves against.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the surface's markup.\n * @example\n * <button commandfor=\"account-menu\" command=\"toggle-popover\">{t(\"nav.account\")}</button>\n * <Popover id=\"account-menu\" placement=\"bottom-start\">\n * \t<p>{t(\"nav.accountMenu.body\")}</p>\n * </Popover>\n * @example\n * <Popover id=\"filters\" placement=\"top\" mix={[fade({ duration: durations.normal })]}>\n * \t<OverlayArrow placement=\"top\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function Popover(handle: Handle<Popover.Props>) {\n\treturn () => {\n\t\tlet { id, popover, placement, children, mix, ...rest } = handle.props;\n\t\tlet resolvedMode = popover ?? DEFAULT_MODE;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={id}\n\t\t\t\tpopover={resolvedMode}\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tfloatingSurface(),\n\t\t\t\t\t\tm(\"0\"),\n\t\t\t\t\t\tinset(\"auto\"),\n\t\t\t\t\t\twhen('&[data-placement^=\"top\"]', mbe(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', mbs(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\t\twhen('&[data-placement^=\"left\"]', marginRight(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\t\twhen('&[data-placement^=\"right\"]', marginLeft(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\t\tpositionTryFallbacks(\"flip-block\", \"flip-inline\", \"flip-block flip-inline\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A corner placement aligns one pair of edges and grows away from it, so the surface\n\t\t\t\t\t\t * occupies the anchor's own track and spans the one beyond it, flush with the anchor's edge.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tdata(\"placement\", \"top\", positionArea(\"top\")),\n\t\t\t\t\t\tdata(\"placement\", \"top-start\", positionArea(\"top span-right\")),\n\t\t\t\t\t\tdata(\"placement\", \"top-end\", positionArea(\"top span-left\")),\n\t\t\t\t\t\tdata(\"placement\", \"bottom\", positionArea(\"bottom\")),\n\t\t\t\t\t\tdata(\"placement\", \"bottom-start\", positionArea(\"bottom span-right\")),\n\t\t\t\t\t\tdata(\"placement\", \"bottom-end\", positionArea(\"bottom span-left\")),\n\t\t\t\t\t\tdata(\"placement\", \"left\", positionArea(\"left\")),\n\t\t\t\t\t\tdata(\"placement\", \"left-start\", positionArea(\"left span-bottom\")),\n\t\t\t\t\t\tdata(\"placement\", \"left-end\", positionArea(\"left span-top\")),\n\t\t\t\t\t\tdata(\"placement\", \"right\", positionArea(\"right\")),\n\t\t\t\t\t\tdata(\"placement\", \"right-start\", positionArea(\"right span-bottom\")),\n\t\t\t\t\t\tdata(\"placement\", \"right-end\", positionArea(\"right span-top\")),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Layout parts on this surface set `display` and beat the UA's closed `display: none`, so\n\t\t\t\t\t\t * the closed state is important to outrank a consumer's later sublayer. A `\"hint\"` surface\n\t\t\t\t\t\t * reveals itself from CSS state on its trigger, so it keeps its own hidden state.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen('&:not(:popover-open):not([popover=\"hint\"])', raw({ display: \"none !important\" })),\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}\n\t\t\t</div>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "progress-bar",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"ProgressBar"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "progress-bar.tsx",
|
|
10
|
-
"content": "/**\n * A styled native `<progress>` control paired with an optional value label,\n * stacked in a single column so a caption can sit alongside the bar it\n * describes. The indicator's track and fill read entirely from the control's\n * own `value`/`max` attributes and its native `:indeterminate` state, so a\n * value-less indicator already renders as busy with zero library JavaScript.\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 { bg, border, fg } from \"@sdxc/u/color\";\nimport { rounded, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { appearance, block, flex, flexCol, gap } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, m, p } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { tabularNums, text } from \"@sdxc/u/typography\";\n\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\n/** Native `max` value {@link ProgressBar.Indicator} falls back to when `max` is omitted, so a bare `value` reads as a percentage without passing `max={100}` every time. */\nconst DEFAULT_MAX = 100;\n\n/**\n * Prop types for {@link ProgressBar} and its compound parts.\n */\nexport namespace ProgressBar {\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * The root only supplies the column layout stacking {@link\n\t * ProgressBar.Indicator} and {@link ProgressBar.ValueLabel}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<progress>` attribute, unchanged, plus the `mix`\n\t * passthrough. Leaving `value` unset renders the indeterminate state;\n\t * `max` defaults to {@link DEFAULT_MAX}.\n\t */\n\texport interface IndicatorProps extends TagProps<\"progress\"> {}\n\n\t/**\n\t * Every native `<span>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ValueLabelProps extends TagProps<\"span\"> {}\n}\n\n/**\n * Renders the root column: a `<div>` stacking {@link ProgressBar.Indicator}\n * and an optional {@link ProgressBar.ValueLabel}, carrying no ARIA of its\n * own since the `<progress>` inside already exposes progressbar semantics.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the root column's markup.\n * @example\n * <ProgressBar>\n * \t<ProgressBar.Indicator value={70} max={100} aria-label={t(\"upload.progress\")} />\n * \t<ProgressBar.ValueLabel>{t(\"upload.percent\", { value: 70 })}</ProgressBar.ValueLabel>\n * </ProgressBar>\n */\nexport function ProgressBar(handle: Handle<ProgressBar.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} mix={[flex(), flexCol(), gap(\"0.25rem\"), mix
|
|
10
|
+
"content": "/**\n * A styled native `<progress>` control paired with an optional value label,\n * stacked in a single column so a caption can sit alongside the bar it\n * describes. The indicator's track and fill read entirely from the control's\n * own `value`/`max` attributes and its native `:indeterminate` state, so a\n * value-less indicator already renders as busy with zero library JavaScript.\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 { bg, border, fg } from \"@sdxc/u/color\";\nimport { rounded, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { mergeMix } from \"@sdxc/u/general\";\nimport { appearance, block, flex, flexCol, gap } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, m, p } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { tabularNums, text } from \"@sdxc/u/typography\";\n\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\n/** Native `max` value {@link ProgressBar.Indicator} falls back to when `max` is omitted, so a bare `value` reads as a percentage without passing `max={100}` every time. */\nconst DEFAULT_MAX = 100;\n\n/**\n * Prop types for {@link ProgressBar} and its compound parts.\n */\nexport namespace ProgressBar {\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * The root only supplies the column layout stacking {@link\n\t * ProgressBar.Indicator} and {@link ProgressBar.ValueLabel}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<progress>` attribute, unchanged, plus the `mix`\n\t * passthrough. Leaving `value` unset renders the indeterminate state;\n\t * `max` defaults to {@link DEFAULT_MAX}.\n\t */\n\texport interface IndicatorProps extends TagProps<\"progress\"> {}\n\n\t/**\n\t * Every native `<span>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ValueLabelProps extends TagProps<\"span\"> {}\n}\n\n/**\n * Renders the root column: a `<div>` stacking {@link ProgressBar.Indicator}\n * and an optional {@link ProgressBar.ValueLabel}, carrying no ARIA of its\n * own since the `<progress>` inside already exposes progressbar semantics.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the root column's markup.\n * @example\n * <ProgressBar>\n * \t<ProgressBar.Indicator value={70} max={100} aria-label={t(\"upload.progress\")} />\n * \t<ProgressBar.ValueLabel>{t(\"upload.percent\", { value: 70 })}</ProgressBar.ValueLabel>\n * </ProgressBar>\n */\nexport function ProgressBar(handle: Handle<ProgressBar.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} mix={mergeMix([flex(), flexCol(), gap(\"0.25rem\")], mix)} />;\n\t};\n}\n\n/**\n * Renders the busy/progress indicator: a native `<progress>` restyled as a\n * pill track. Firefox paints from the host itself, so track and fill colors\n * mirror onto the `::-webkit-*`/`::-moz-*` pseudo-elements each engine paints.\n *\n * @param handle Runtime handle carrying the host `<progress>`'s props.\n * @returns The render function producing the indicator's markup.\n * @example\n * <ProgressBar.Indicator value={70} max={100} aria-label={t(\"upload.progress\")} />\n * @example\n * <ProgressBar.Indicator aria-label={t(\"upload.progress\")} mix={[shimmer()]} />\n */\nProgressBar.Indicator = function ProgressBarIndicator(handle: Handle<ProgressBar.IndicatorProps>) {\n\treturn () => {\n\t\tlet { mix, max, ...rest } = handle.props;\n\t\tlet resolvedMax = max ?? DEFAULT_MAX;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t\"ProgressBar.Indicator: a progress indicator with no `aria-label` or `aria-labelledby` needs one describing what it tracks — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<progress\n\t\t\t\tmax={resolvedMax}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tappearance(),\n\t\t\t\t\t\tblock(),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tbs(\"var(--ui-progress-bar-block-size, 0.5rem)\"),\n\t\t\t\t\t\tm(\"0\"),\n\t\t\t\t\t\tp(\"0\"),\n\t\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\twhen(\"&::-webkit-progress-bar\", [bg(\"neutral.border\"), rounded(\"full\")]),\n\t\t\t\t\t\twhen(\"&::-webkit-progress-value\", [\n\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\t\ttransition(\"all\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\"&::-moz-progress-bar\", [bg(\"brand.solid\"), rounded(\"full\"), transition(\"all\")]),\n\t\t\t\t\t\tborder(\"none\"),\n\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\t\twhen(\"&::-webkit-progress-value\", transitionDuration(\"0s\")),\n\t\t\t\t\t\t\twhen(\"&::-moz-progress-bar\", transitionDuration(\"0s\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the indicator's caption: a `<span>` sized as a small run of body\n * copy in the neutral muted foreground color, for a percentage or status\n * string placed alongside {@link ProgressBar.Indicator}.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the value label's markup.\n * @example\n * <ProgressBar.ValueLabel>{t(\"upload.percent\", { value: 70 })}</ProgressBar.ValueLabel>\n */\nProgressBar.ValueLabel = function ProgressBarValueLabel(\n\thandle: Handle<ProgressBar.ValueLabelProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <span {...rest} mix={mergeMix([fg(\"neutral\"), text(\"sm\"), tabularNums()], mix)} />;\n\t};\n};\n"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "property-list",
|
|
3
|
+
"changedIn": "2026.11.3",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"popover"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"PropertyList"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "property-list.tsx",
|
|
12
|
+
"content": "/**\n * Label/value rows for one record's properties, as a `<dl>`: a fixed label column beside\n * each value that stacks once its container narrows, empty values named in words, and an\n * editable row whose value opens an anchored native popover holding the app's own form.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { ChevronDownIcon } from \"@sdxc/icons\";\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, transition } from \"@sdxc/u/effects\";\nimport { cursor, raw, mergeMix } from \"@sdxc/u/general\";\nimport { container, flex, gap, grid, items, justify, shrink, vstack } from \"@sdxc/u/layout\";\nimport { is, m, minBs, minIs, p, pb, pi } from \"@sdxc/u/size\";\nimport { focusVisible, hover } from \"@sdxc/u/state\";\nimport { leading, tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Popover } from \"@sdxc/ui/popover\";\n\n/** Container the list names, so its rows stack against the list's own width. */\nconst PROPERTY_LIST_CONTAINER = \"ui-property-list\";\n\n/** Layout a list takes when `variant` is left unset. */\nconst DEFAULT_VARIANT: PropertyList.Variant = \"rows\";\n\n/** Shown for a value the caller leaves empty and names no empty text for. */\nconst DEFAULT_EMPTY = \"—\";\n\n/**\n * Prop types for {@link PropertyList} and its compound parts.\n */\nexport namespace PropertyList {\n\t/**\n\t * `\"rows\"` sets each label beside its value in a ruled-free column; `\"tiles\"` sets each\n\t * property in its own bordered tile, two to a row, for a record's headline figures.\n\t */\n\texport type Variant = \"rows\" | \"tiles\";\n\n\t/** What {@link PropertyList} shares with its items. */\n\texport interface Context {\n\t\tvariant: Variant;\n\t}\n\n\t/** Every native `<dl>` attribute, plus the layout variant. */\n\texport interface Props extends TagProps<\"dl\"> {\n\t\t/** @default {@link DEFAULT_VARIANT} */\n\t\tvariant?: Variant;\n\t}\n\n\t/**\n\t * Makes a row editable in place: its value becomes a button that opens a popover\n\t * anchored under it, holding whatever form the app renders as `content`.\n\t */\n\texport interface Edit {\n\t\t/** Id of the popover, which the value button targets. */\n\t\tid: string;\n\t\t/** What the button does, read before the current value, such as \"Edit assignee\". */\n\t\tlabel: string;\n\t\t/** The popover's content: the app's form, its described options and its submit. */\n\t\tcontent: RemixNode;\n\t}\n\n\t/** Every native `<div>` attribute the row's group accepts, plus its label and value. */\n\texport interface ItemProps extends Omit<TagProps<\"div\">, \"children\"> {\n\t\t/** The property's name, rendered in the `<dt>`. */\n\t\tlabel: RemixNode;\n\t\t/**\n\t\t * What the row says when `children` is empty, such as \"None\" or \"No reviews\".\n\t\t *\n\t\t * @default \"—\"\n\t\t */\n\t\tempty?: RemixNode;\n\t\t/** Turns the value into a button opening an anchored edit popover. */\n\t\tedit?: Edit;\n\t\t/** The value: text, a link, a badge, an avatar with a name. */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Whether `node` renders nothing a reader would see, which is when the row shows its\n * named empty value instead.\n *\n * @param node The value a row was given.\n * @returns `true` for `null`, `undefined`, `false`, `\"\"` and a list of those.\n */\nfunction isEmptyValue(node: RemixNode | undefined): boolean {\n\tif (node === null || node === undefined || node === false || node === \"\") return true;\n\tif (Array.isArray(node)) return node.every((child) => isEmptyValue(child));\n\treturn false;\n}\n\n/**\n * Renders the `<dl>`. Each item is a `<div>` grouping one `<dt>` and one `<dd>`, which\n * keeps the label/value pairing in the accessibility tree; the list measures itself as a\n * container, so rows stack in a narrow side pane at any viewport width.\n *\n * @param handle Runtime handle carrying the `<dl>`'s props and providing the variant.\n * @returns The render function producing the list's markup.\n * @example\n * <PropertyList>\n * \t<PropertyList.Item label=\"Status\"><Badge color=\"success\">Up</Badge></PropertyList.Item>\n * \t<PropertyList.Item label=\"Reviewers\" empty=\"No reviews\" />\n * </PropertyList>\n * @example\n * <PropertyList variant=\"tiles\">\n * \t<PropertyList.Item label=\"Uptime\">99.98%</PropertyList.Item>\n * </PropertyList>\n */\nexport function PropertyList(handle: Handle<PropertyList.Props, PropertyList.Context>) {\n\treturn () => {\n\t\tlet { variant, mix, ...rest } = handle.props;\n\t\tlet resolved = variant ?? DEFAULT_VARIANT;\n\t\thandle.context.set({ variant: resolved });\n\n\t\treturn (\n\t\t\t<dl\n\t\t\t\tdata-slot=\"property-list\"\n\t\t\t\tdata-variant={resolved}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tis(\"100%\"),\n\t\t\t\t\t\tcontainer(PROPERTY_LIST_CONTAINER),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\tresolved === \"tiles\"\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\tgrid(),\n\t\t\t\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t * Each tile claims at least half the row, so two fit side by side once\n\t\t\t\t\t\t\t\t\t * both reach 9rem and a narrower list falls back to one column.\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\tgridTemplateColumns:\n\t\t\t\t\t\t\t\t\t\t\t\"repeat(auto-fit, minmax(max(9rem, calc(50% - 0.25rem)), 1fr))\",\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: vstack({ gap: 0 }),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders one property. In the rows variant the label column holds\n * `--ui-property-list-label-width` (9rem) from a 22rem container up and stacks above the\n * value below it; a value-less row names its emptiness in muted text.\n *\n * @param handle Runtime handle carrying the group `<div>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <PropertyList.Item label=\"Owner\"><a href=\"/people/ana\">Ana Souza</a></PropertyList.Item>\n * @example\n * <PropertyList.Item\n * \tlabel=\"Assignee\"\n * \tempty=\"No one\"\n * \tedit={{ id: \"edit-assignee\", label: \"Edit assignee\", content: <AssigneeForm /> }}\n * >\n * \t{assignee?.name}\n * </PropertyList.Item>\n */\nPropertyList.Item = function PropertyListItem(handle: Handle<PropertyList.ItemProps>) {\n\treturn () => {\n\t\tlet { label, empty, edit, children, mix, ...rest } = handle.props;\n\t\tlet { variant } = handle.context.get(PropertyList);\n\t\tlet tiles = variant === \"tiles\";\n\t\tlet isEmpty = isEmptyValue(children);\n\n\t\tlet value = isEmpty ? (\n\t\t\t<span data-slot=\"property-empty\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t{empty ?? DEFAULT_EMPTY}\n\t\t\t</span>\n\t\t) : (\n\t\t\tchildren\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"property\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\ttiles\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tvstack({ gap: 1 }),\n\t\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tgrid(),\n\t\t\t\t\t\t\t\tpb(1),\n\t\t\t\t\t\t\t\titems(\"baseline\"),\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * The stacked and side-by-side tracks live in one rule, so the label column\n\t\t\t\t\t\t\t\t * holds at its width whatever order the stylesheet layers land in.\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\tgridTemplateColumns: \"minmax(0, 1fr)\",\n\t\t\t\t\t\t\t\t\trowGap: \"0.125rem\",\n\t\t\t\t\t\t\t\t\t[`@container ${PROPERTY_LIST_CONTAINER} (min-width: 22rem)`]: {\n\t\t\t\t\t\t\t\t\t\tgridTemplateColumns: \"var(--ui-property-list-label-width, 9rem) minmax(0, 1fr)\",\n\t\t\t\t\t\t\t\t\t\tcolumnGap: \"1rem\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<dt\n\t\t\t\t\tdata-slot=\"property-label\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\ttiles ? text(\"xs\") : text(\"sm\"),\n\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\tpb(tiles ? 0 : 1.5),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</dt>\n\t\t\t\t<dd\n\t\t\t\t\tdata-slot=\"property-value\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\traw({ flexWrap: \"wrap\" }),\n\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\ttiles ? [text(\"lg\"), weight(\"semibold\")] : null,\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{edit ? (\n\t\t\t\t\t\t<PropertyEdit edit={edit} empty={isEmpty}>\n\t\t\t\t\t\t\t{value}\n\t\t\t\t\t\t</PropertyEdit>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tvalue\n\t\t\t\t\t)}\n\t\t\t\t</dd>\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/** Props {@link PropertyEdit} reads. */\ninterface PropertyEditProps {\n\tedit: PropertyList.Edit;\n\tempty: boolean;\n\tchildren: RemixNode;\n}\n\n/**\n * The editable value: a full-width button naming its action before the current value,\n * and the popover it opens. The button is the popover's invoker, which makes it the\n * popover's implicit anchor, so the form opens directly under its row.\n *\n * @param handle Runtime handle carrying the edit description and the rendered value.\n * @returns The render function producing the button and its popover.\n */\nfunction PropertyEdit(handle: Handle<PropertyEditProps>) {\n\treturn () => {\n\t\tlet { edit, children } = handle.props;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-slot=\"property-edit\"\n\t\t\t\t\tpopovertarget={edit.id}\n\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"between\"),\n\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\tpi(2),\n\t\t\t\t\t\traw({ marginInline: \"-0.5rem\", inlineSize: \"calc(100% + 1rem)\" }),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"transparent\", width: 0 }),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tfg(),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\ttextAlign(\"start\"),\n\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\ttransition(\"background-color\"),\n\t\t\t\t\t\thover(bg(\"neutral.tint\")),\n\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", width: 2, offset: -2 })),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<span mix={[flex(), items(\"center\"), gap(1.5), raw({ flexWrap: \"wrap\" }), minIs(0)]}>\n\t\t\t\t\t\t<span mix={[visuallyHidden()]}>{`${edit.label}: `}</span>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</span>\n\t\t\t\t\t<ChevronDownIcon size={14} aria-hidden=\"true\" mix={[shrink(0), fg(\"neutral.muted\")]} />\n\t\t\t\t</button>\n\t\t\t\t<Popover\n\t\t\t\t\tid={edit.id}\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-label={edit.label}\n\t\t\t\t\tdata-slot=\"property-popover\"\n\t\t\t\t\tmix={[p(3), is(\"min(20rem, calc(100vw - 2rem))\"), text(\"sm\")]}\n\t\t\t\t>\n\t\t\t\t\t{edit.content}\n\t\t\t\t</Popover>\n\t\t\t</>\n\t\t);\n\t};\n}\n"
|
|
13
|
+
},
|
|
14
|
+
"test": {
|
|
15
|
+
"path": "property-list.browser.test.tsx",
|
|
16
|
+
"content": "/**\n * Lays PropertyList out in a real browser: the label column holds one width down every\n * row and stacks in a narrow container, an empty value reads its name, the edit popover\n * opens under its own row, and the tiles variant goes two-up only where it fits.\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(\"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
|
+
}
|
|
18
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "radio-group",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"RadioGroup"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "radio-group.tsx",
|
|
10
|
-
"content": "/**\n * A set of mutually exclusive options built from native `<input\n * type=\"radio\">` controls sharing one grouping name, rendered as a\n * `role=\"radiogroup\"` host wrapping a run of {@link RadioGroup.Radio}\n * instances. Each option pairs a visually hidden native input — carrying\n * every focus, keyboard, and form-submission semantic the platform already\n * provides — with a styled visual indicator that reads the input's own\n * `:checked` and `:focus-visible` states through sibling selectors.\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 { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded, transition } from \"@sdxc/u/effects\";\nimport { cursor, pseudoContent } from \"@sdxc/u/general\";\nimport { flex, flexCol, flexRow, gap, items, justify, relative, shrink } from \"@sdxc/u/layout\";\nimport { bs, is } from \"@sdxc/u/size\";\nimport { after, precededBy, when } from \"@sdxc/u/state\";\nimport { scale } from \"@sdxc/u/transform\";\nimport { text } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\n/**\n * `role=\"radiogroup\"` applied through {@link attrs} unless a consumer\n * supplies its own `role`, announcing the host as a radio group landmark to\n * assistive technology.\n */\nconst DEFAULT_ROLE = \"radiogroup\";\n\n/**\n * Default {@link RadioGroup.Props} orientation, applied when `orientation`\n * is omitted, laying options out in a single column.\n */\nconst DEFAULT_ORIENTATION: RadioGroup.Orientation = \"vertical\";\n\n/**\n * Prop types for {@link RadioGroup} and its {@link RadioGroup.Radio}\n * compound part.\n */\nexport namespace RadioGroup {\n\t/**\n\t * Axis a group's options lay out along: a single column, or a single row.\n\t */\n\texport type Orientation = \"horizontal\" | \"vertical\";\n\n\t/**\n\t * Value {@link RadioGroup} stores in component context so every\n\t * {@link RadioGroup.Radio} nested inside shares the same native grouping\n\t * name without a consumer repeating it on each option.\n\t */\n\texport interface Context {\n\t\t/** Shared `name` every {@link RadioGroup.Radio} reads unless it sets its own. */\n\t\tname: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link RadioGroup}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Native grouping name shared by every {@link RadioGroup.Radio} nested\n\t\t * inside. Defaults to the group's own {@link Handle.id | stable\n\t\t * instance id} so options group correctly without a consumer setting one.\n\t\t */\n\t\tname?: string;\n\t\t/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t}\n\n\t/**\n\t * Props accepted by {@link RadioGroup.Radio}.\n\t */\n\texport interface RadioProps extends Omit<TagProps<\"label\">, \"children\"> {\n\t\t/** Value submitted with the enclosing form when this option is selected. */\n\t\tvalue: string;\n\t\t/**\n\t\t * Native grouping name for this option's underlying input. Defaults to\n\t\t * the name provided by the nearest ancestor {@link RadioGroup} — set\n\t\t * this only to opt a single option out of its group's shared name.\n\t\t */\n\t\tname?: string;\n\t\t/** Whether this option starts selected, for a form that leaves selection tracking to the browser. */\n\t\tdefaultChecked?: boolean;\n\t\t/** Whether this option is selected, for a form that tracks selection itself. */\n\t\tchecked?: boolean;\n\t\t/** Whether this option is inert and excluded from the group's tab order. */\n\t\tdisabled?: boolean;\n\t\t/** Marks the enclosing native radio group as requiring one option selected. */\n\t\trequired?: boolean;\n\t\t/** The option's visible label text, associated with the input by native nesting. */\n\t\tchildren?: RemixNode;\n\t\t/**\n\t\t * Per-part styling for the option's hidden `input` and visible\n\t\t * `indicator` elements, layered after each part's own built-in styling.\n\t\t * Use the `mix` prop instead to style the option's outer `<label>` host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to the hidden native `<input type=\"radio\">`. */\n\t\t\tinput?: TagProps<\"input\">[\"mix\"];\n\t\t\t/** Additional mixin(s) applied to the visible indicator `<span>`. */\n\t\t\tindicator?: TagProps<\"span\">[\"mix\"];\n\t\t};\n\t}\n}\n\n/**\n * Renders the group host: a `role=\"radiogroup\"` `<div>` laying its\n * {@link RadioGroup.Radio} options in a column, or a row when\n * `orientation` is `\"horizontal\"`, giving every option a shared, stable `name`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props and providing {@link RadioGroup.Context}.\n * @returns The render function producing the group's markup.\n * @example\n * <RadioGroup aria-label={t(\"shipping.method\")}>\n * \t<RadioGroup.Radio value=\"standard\">{t(\"shipping.standard\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"express\">{t(\"shipping.express\")}</RadioGroup.Radio>\n * </RadioGroup>\n * @example\n * <RadioGroup aria-label={t(\"size.label\")} orientation=\"horizontal\">\n * \t<RadioGroup.Radio value=\"sm\">{t(\"size.small\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"md\">{t(\"size.medium\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"lg\">{t(\"size.large\")}</RadioGroup.Radio>\n * </RadioGroup>\n */\nexport function RadioGroup(handle: Handle<RadioGroup.Props, RadioGroup.Context>) {\n\treturn () => {\n\t\tlet { name, orientation, mix, ...rest } = handle.props;\n\t\tlet resolvedName = name ?? handle.id;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\n\t\thandle.context.set({ name: resolvedName });\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-orientation={resolvedOrientation}\n\t\t\t\taria-orientation={resolvedOrientation}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_ROLE }),\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', flexRow()),\n\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', gap(\"1rem\")),\n\t\t\t\t\tmix,\n\t\t\t\t
|
|
10
|
+
"content": "/**\n * A set of mutually exclusive options built from native `<input\n * type=\"radio\">` controls sharing one grouping name, rendered as a\n * `role=\"radiogroup\"` host wrapping a run of {@link RadioGroup.Radio}\n * instances. Each option pairs a visually hidden native input — carrying\n * every focus, keyboard, and form-submission semantic the platform already\n * provides — with a styled visual indicator that reads the input's own\n * `:checked` and `:focus-visible` states through sibling selectors.\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 { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded, transition } from \"@sdxc/u/effects\";\nimport { cursor, pseudoContent, mergeMix } from \"@sdxc/u/general\";\nimport { flex, flexCol, flexRow, gap, items, justify, relative, shrink } from \"@sdxc/u/layout\";\nimport { bs, is } from \"@sdxc/u/size\";\nimport { after, precededBy, when } from \"@sdxc/u/state\";\nimport { scale } from \"@sdxc/u/transform\";\nimport { text } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\n/**\n * `role=\"radiogroup\"` applied through {@link attrs} unless a consumer\n * supplies its own `role`, announcing the host as a radio group landmark to\n * assistive technology.\n */\nconst DEFAULT_ROLE = \"radiogroup\";\n\n/**\n * Default {@link RadioGroup.Props} orientation, applied when `orientation`\n * is omitted, laying options out in a single column.\n */\nconst DEFAULT_ORIENTATION: RadioGroup.Orientation = \"vertical\";\n\n/**\n * Prop types for {@link RadioGroup} and its {@link RadioGroup.Radio}\n * compound part.\n */\nexport namespace RadioGroup {\n\t/**\n\t * Axis a group's options lay out along: a single column, or a single row.\n\t */\n\texport type Orientation = \"horizontal\" | \"vertical\";\n\n\t/**\n\t * Value {@link RadioGroup} stores in component context so every\n\t * {@link RadioGroup.Radio} nested inside shares the same native grouping\n\t * name without a consumer repeating it on each option.\n\t */\n\texport interface Context {\n\t\t/** Shared `name` every {@link RadioGroup.Radio} reads unless it sets its own. */\n\t\tname: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link RadioGroup}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Native grouping name shared by every {@link RadioGroup.Radio} nested\n\t\t * inside. Defaults to the group's own {@link Handle.id | stable\n\t\t * instance id} so options group correctly without a consumer setting one.\n\t\t */\n\t\tname?: string;\n\t\t/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t}\n\n\t/**\n\t * Props accepted by {@link RadioGroup.Radio}.\n\t */\n\texport interface RadioProps extends Omit<TagProps<\"label\">, \"children\"> {\n\t\t/** Value submitted with the enclosing form when this option is selected. */\n\t\tvalue: string;\n\t\t/**\n\t\t * Native grouping name for this option's underlying input. Defaults to\n\t\t * the name provided by the nearest ancestor {@link RadioGroup} — set\n\t\t * this only to opt a single option out of its group's shared name.\n\t\t */\n\t\tname?: string;\n\t\t/** Whether this option starts selected, for a form that leaves selection tracking to the browser. */\n\t\tdefaultChecked?: boolean;\n\t\t/** Whether this option is selected, for a form that tracks selection itself. */\n\t\tchecked?: boolean;\n\t\t/** Whether this option is inert and excluded from the group's tab order. */\n\t\tdisabled?: boolean;\n\t\t/** Marks the enclosing native radio group as requiring one option selected. */\n\t\trequired?: boolean;\n\t\t/** The option's visible label text, associated with the input by native nesting. */\n\t\tchildren?: RemixNode;\n\t\t/**\n\t\t * Per-part styling for the option's hidden `input` and visible\n\t\t * `indicator` elements, layered after each part's own built-in styling.\n\t\t * Use the `mix` prop instead to style the option's outer `<label>` host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to the hidden native `<input type=\"radio\">`. */\n\t\t\tinput?: TagProps<\"input\">[\"mix\"];\n\t\t\t/** Additional mixin(s) applied to the visible indicator `<span>`. */\n\t\t\tindicator?: TagProps<\"span\">[\"mix\"];\n\t\t};\n\t}\n}\n\n/**\n * Renders the group host: a `role=\"radiogroup\"` `<div>` laying its\n * {@link RadioGroup.Radio} options in a column, or a row when\n * `orientation` is `\"horizontal\"`, giving every option a shared, stable `name`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props and providing {@link RadioGroup.Context}.\n * @returns The render function producing the group's markup.\n * @example\n * <RadioGroup aria-label={t(\"shipping.method\")}>\n * \t<RadioGroup.Radio value=\"standard\">{t(\"shipping.standard\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"express\">{t(\"shipping.express\")}</RadioGroup.Radio>\n * </RadioGroup>\n * @example\n * <RadioGroup aria-label={t(\"size.label\")} orientation=\"horizontal\">\n * \t<RadioGroup.Radio value=\"sm\">{t(\"size.small\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"md\">{t(\"size.medium\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"lg\">{t(\"size.large\")}</RadioGroup.Radio>\n * </RadioGroup>\n */\nexport function RadioGroup(handle: Handle<RadioGroup.Props, RadioGroup.Context>) {\n\treturn () => {\n\t\tlet { name, orientation, mix, ...rest } = handle.props;\n\t\tlet resolvedName = name ?? handle.id;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\n\t\thandle.context.set({ name: resolvedName });\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-orientation={resolvedOrientation}\n\t\t\t\taria-orientation={resolvedOrientation}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ role: DEFAULT_ROLE }),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tflexCol(),\n\t\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', flexRow()),\n\t\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', gap(\"1rem\")),\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 a single option: a `<label>` pairing a hidden native `<input\n * type=\"radio\">` with a styled indicator driven by its checked, focus, and\n * disabled state; add `ariaChecked()` via `parts.input` for `aria-checked`.\n *\n * @param handle Runtime handle carrying the host `<label>`'s props.\n * @returns The render function producing the option's markup.\n * @example\n * <RadioGroup.Radio value=\"dog\">{t(\"pet.dog\")}</RadioGroup.Radio>\n * @example\n * <RadioGroup.Radio value=\"cat\" defaultChecked>{t(\"pet.cat\")}</RadioGroup.Radio>\n * @example\n * <RadioGroup.Radio value=\"hamster\" disabled>{t(\"pet.hamster\")}</RadioGroup.Radio>\n */\nRadioGroup.Radio = function RadioGroupRadio(handle: Handle<RadioGroup.RadioProps>) {\n\treturn () => {\n\t\tlet {\n\t\t\tvalue,\n\t\t\tname,\n\t\t\tchecked,\n\t\t\tdefaultChecked,\n\t\t\tdisabled,\n\t\t\trequired,\n\t\t\tchildren,\n\t\t\tparts,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet context = handle.context.get(RadioGroup);\n\t\tlet resolvedName = name ?? context.name;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\twhen(\"&:has(input:disabled)\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\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<input\n\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\tid={handle.id}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tname={resolvedName}\n\t\t\t\t\tchecked={checked}\n\t\t\t\t\tdefaultChecked={defaultChecked}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\trequired={required}\n\t\t\t\t\tmix={[visuallyHidden(), parts?.input]}\n\t\t\t\t/>\n\t\t\t\t<span\n\t\t\t\t\tdata-slot=\"indicator\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tis(\"var(--ui-radio-size, 1.25rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-radio-size, 1.25rem)\"),\n\t\t\t\t\t\tafter([\n\t\t\t\t\t\t\tis(\"var(--ui-radio-mark-size, 0.625rem)\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-radio-mark-size, 0.625rem)\"),\n\t\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\t\tbg(\"brand.onSolid\"),\n\t\t\t\t\t\t\ttransition(\"transform\"),\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\tscale(0),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tborder({ color: \"neutral.strong\", width: 2 }),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\ttransition(\"background-color, border-color\"),\n\t\t\t\t\t\tprecededBy(\"input:checked\", after(scale(1))),\n\t\t\t\t\t\tprecededBy(\"input:checked\", [border(\"brand.solid\"), bg(\"brand.solid\")]),\n\t\t\t\t\t\tprecededBy(\"input:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\tparts?.indicator,\n\t\t\t\t\t]}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</label>\n\t\t);\n\t};\n};\n"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "range-calendar",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"calendar",
|
|
6
6
|
"input"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"source": {
|
|
12
12
|
"path": "range-calendar.tsx",
|
|
13
|
-
"content": "/**\n * A calendar surface for choosing a start and end date as one connected\n * range, sharing every header, grid, and row part with {@link Calendar} and\n * layering range position on top of its day cell. Used bare, with no\n * composed children, it renders a pair of native `<input type=\"date\">`\n * fields instead — start and end, each independently keyboard-operable —\n * ready for the `calendarKeys()`/`rangePreview()` mixins a consumer attaches\n * to turn the composed grid into a live, drag- or arrow-key-extended range.\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 { bg, fg } from \"@sdxc/u/color\";\nimport { roundedCorner } from \"@sdxc/u/effects\";\nimport { flex, gap, items } from \"@sdxc/u/layout\";\nimport { when } from \"@sdxc/u/state\";\nimport { attrs } from \"remix/component\";\n\nimport { Calendar } from \"@sdxc/ui/calendar\";\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Semantic color role {@link RangeCalendar}'s bare fallback pair falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: RangeCalendar.Color = \"neutral\";\n\n/**\n * Prop types for {@link RangeCalendar} and its compound parts. Every part\n * but {@link RangeCalendar.Cell} aliases {@link Calendar}'s matching part,\n * sharing its header, grid, and row markup.\n */\nexport namespace RangeCalendar {\n\t/**\n\t * Semantic color role for the bare fallback pair's keyboard focus rings,\n\t * mapped to `--ui-*` variables like {@link Calendar.Color}. The composed\n\t * grid's day cells always use fixed semantic roles, regardless of this value.\n\t */\n\texport type Color = Calendar.Color;\n\n\t/**\n\t * Per-part styling for the bare fallback pair's two internally composed\n\t * inputs, layered after each input's own built-in styling. Style the\n\t * composed grid's parts through {@link Calendar}'s own compound parts.\n\t */\n\texport interface PartsProps {\n\t\t/** Styling for the bare fallback's start-date input, rendered through {@link Input}. */\n\t\tstart?: TagProps<\"input\">[\"mix\"];\n\t\t/** Styling for the bare fallback's end-date input, rendered through {@link Input}. */\n\t\tend?: TagProps<\"input\">[\"mix\"];\n\t}\n\n\t/**\n\t * Props accepted by {@link RangeCalendar}. Composing\n\t * {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`\n\t * renders the visual month surface; omitting `children` renders a bare native `<input type=\"date\">` pair from the fields below.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Semantic color role for the bare fallback pair's focus rings. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Native `name` submitted with an enclosing form, read only by the bare fallback's start-date input. */\n\t\tstartName?: string;\n\t\t/** Native `name` submitted with an enclosing form, read only by the bare fallback's end-date input. */\n\t\tendName?: string;\n\t\t/** Current start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */\n\t\tstartValue?: string;\n\t\t/** Current end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */\n\t\tendValue?: string;\n\t\t/** Initial start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */\n\t\tstartDefaultValue?: string;\n\t\t/** Initial end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */\n\t\tendDefaultValue?: string;\n\t\t/** Earliest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */\n\t\tmin?: string;\n\t\t/** Latest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */\n\t\tmax?: string;\n\t\t/** Granularity, in days, both of the bare fallback pair's values must fall on. */\n\t\tstep?: number;\n\t\t/** Marks both of the bare fallback pair's inputs required for their enclosing form. */\n\t\trequired?: boolean;\n\t\t/** Marks both of the bare fallback pair's inputs inert and excluded from the tab order. */\n\t\tdisabled?: boolean;\n\t\t/** Marks both of the bare fallback pair's inputs' values fixed, while keeping them focusable and included in form submission. */\n\t\treadOnly?: boolean;\n\t\t/** Native autofill hint for both of the bare fallback pair's inputs, e.g. `\"bday\"`. */\n\t\tautoComplete?: string;\n\t\t/** Accessible label for the bare fallback pair's start-date input. Read only when `children` is unset. */\n\t\tstartLabel?: string;\n\t\t/** Accessible label for the bare fallback pair's end-date input. Read only when `children` is unset. */\n\t\tendLabel?: string;\n\t\t/** Per-part styling for the bare fallback pair's internally composed inputs. */\n\t\tparts?: PartsProps;\n\t}\n\n\t/** Every prop {@link Calendar.HeaderProps} accepts, unchanged. */\n\texport interface HeaderProps extends Calendar.HeaderProps {}\n\n\t/** Every prop {@link Calendar.PreviousButtonProps} accepts, unchanged. */\n\texport interface PreviousButtonProps extends Calendar.PreviousButtonProps {}\n\n\t/** Every prop {@link Calendar.NextButtonProps} accepts, unchanged. */\n\texport interface NextButtonProps extends Calendar.NextButtonProps {}\n\n\t/** Every prop {@link Calendar.HeadingProps} accepts, unchanged. */\n\texport interface HeadingProps extends Calendar.HeadingProps {}\n\n\t/** Every prop {@link Calendar.GridProps} accepts, unchanged. */\n\texport interface GridProps extends Calendar.GridProps {}\n\n\t/** Every prop {@link Calendar.GridHeaderProps} accepts, unchanged. */\n\texport interface GridHeaderProps extends Calendar.GridHeaderProps {}\n\n\t/** Every prop {@link Calendar.RowProps} accepts, unchanged. */\n\texport interface RowProps extends Calendar.RowProps {}\n\n\t/** Every prop {@link Calendar.HeaderCellProps} accepts, unchanged. */\n\texport interface HeaderCellProps extends Calendar.HeaderCellProps {}\n\n\t/** Every prop {@link Calendar.GridBodyProps} accepts, unchanged. */\n\texport interface GridBodyProps extends Calendar.GridBodyProps {}\n\n\t/**\n\t * Every prop {@link Calendar.CellProps} accepts, unchanged. Set\n\t * `data-selection-start` on the range's first day, `data-selection-end`\n\t * on its last, and `aria-selected=\"true\"` alone on the days between — each read straight off what the consumer sets on this instance.\n\t */\n\texport interface CellProps extends Calendar.CellProps {}\n}\n\n/**\n * Renders {@link RangeCalendar}'s root through {@link Calendar}. Composing\n * {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`\n * renders the visual month surface; omitting `children` renders a bare, script-free native `<input type=\"date\">` pair from this instance's own fields.\n *\n * @param handle Runtime handle carrying the root element's props.\n * @returns The render function producing the range calendar's markup.\n * @example\n * <RangeCalendar startLabel={t(\"form.stay.checkIn\")} endLabel={t(\"form.stay.checkOut\")} startName=\"checkIn\" endName=\"checkOut\" />\n * @example\n * <RangeCalendar aria-label={t(\"calendar.label\")}>\n * \t<RangeCalendar.Header>\n * \t\t<RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t\t<RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n * \t\t<RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n * \t</RangeCalendar.Header>\n * \t<RangeCalendar.Grid aria-label={monthLabel}>\n * \t\t<RangeCalendar.GridHeader>\n * \t\t\t<RangeCalendar.Row>\n * \t\t\t\t{weekdayLabels.map((day) => (\n * \t\t\t\t\t<RangeCalendar.HeaderCell key={day}>{day}</RangeCalendar.HeaderCell>\n * \t\t\t\t))}\n * \t\t\t</RangeCalendar.Row>\n * \t\t</RangeCalendar.GridHeader>\n * \t\t<RangeCalendar.GridBody>\n * \t\t\t{weeks.map((week) => (\n * \t\t\t\t<RangeCalendar.Row key={week[0].iso}>\n * \t\t\t\t\t{week.map((day) => (\n * \t\t\t\t\t\t<RangeCalendar.Cell\n * \t\t\t\t\t\t\tkey={day.iso}\n * \t\t\t\t\t\t\taria-selected={day.inRange ? \"true\" : undefined}\n * \t\t\t\t\t\t\tdata-selection-start={day.iso === range.start ? \"\" : undefined}\n * \t\t\t\t\t\t\tdata-selection-end={day.iso === range.end ? \"\" : undefined}\n * \t\t\t\t\t\t>\n * \t\t\t\t\t\t\t{day.label}\n * \t\t\t\t\t\t</RangeCalendar.Cell>\n * \t\t\t\t\t))}\n * \t\t\t\t</RangeCalendar.Row>\n * \t\t\t))}\n * \t\t</RangeCalendar.GridBody>\n * \t</RangeCalendar.Grid>\n * </RangeCalendar>\n */\nexport function RangeCalendar(handle: Handle<RangeCalendar.Props>) {\n\treturn () => {\n\t\tlet {\n\t\t\tcolor,\n\t\t\tstartName,\n\t\t\tendName,\n\t\t\tstartValue,\n\t\t\tendValue,\n\t\t\tstartDefaultValue,\n\t\t\tendDefaultValue,\n\t\t\tmin,\n\t\t\tmax,\n\t\t\tstep,\n\t\t\trequired,\n\t\t\tdisabled,\n\t\t\treadOnly,\n\t\t\tautoComplete,\n\t\t\tstartLabel,\n\t\t\tendLabel,\n\t\t\tparts,\n\t\t\tchildren,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\tif (import.meta.env?.DEV && !children) {\n\t\t\tif (!startLabel) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'RangeCalendar: falling back to a plain \"input type=date\" pair needs a \"startLabel\" describing the range\\'s start for assistive technology.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!endLabel) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'RangeCalendar: falling back to a plain \"input type=date\" pair needs an \"endLabel\" describing the range\\'s end for assistive technology.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<Calendar {...rest} mix={mix}>\n\t\t\t\t{children ?? (\n\t\t\t\t\t<div\n\t\t\t\t\t\tdata-slot=\"fields\"\n\t\t\t\t\t\tmix={[attrs({ role: \"group\" }), flex(), items(\"center\"), gap(\"0.5rem\")]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tdata-slot=\"start-input\"\n\t\t\t\t\t\t\tcolor={resolvedColor}\n\t\t\t\t\t\t\tname={startName}\n\t\t\t\t\t\t\tvalue={startValue}\n\t\t\t\t\t\t\tdefaultValue={startDefaultValue}\n\t\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\t\taria-label={startLabel}\n\t\t\t\t\t\t\tmix={parts?.start}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tdata-slot=\"end-input\"\n\t\t\t\t\t\t\tcolor={resolvedColor}\n\t\t\t\t\t\t\tname={endName}\n\t\t\t\t\t\t\tvalue={endValue}\n\t\t\t\t\t\t\tdefaultValue={endDefaultValue}\n\t\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\t\taria-label={endLabel}\n\t\t\t\t\t\t\tmix={parts?.end}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</Calendar>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link RangeCalendar.HeaderProps.children} as the nav row: identical\n * to {@link Calendar.Header}, since {@link RangeCalendar} reuses\n * {@link Calendar}'s grid markup for its own header.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the nav row's markup.\n * @example\n * <RangeCalendar.Header>\n * \t<RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t<RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n * \t<RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n * </RangeCalendar.Header>\n */\nRangeCalendar.Header = Calendar.Header;\n\n/**\n * Renders a control standing for \"show the previous month\": identical to\n * {@link Calendar.PreviousButton}.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n */\nRangeCalendar.PreviousButton = Calendar.PreviousButton;\n\n/**\n * Renders a control standing for \"show the following month\": identical to\n * {@link Calendar.NextButton}.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n */\nRangeCalendar.NextButton = Calendar.NextButton;\n\n/**\n * Renders the calendar's visible month/year caption: identical to\n * {@link Calendar.Heading}.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the caption's markup.\n * @example\n * <RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n */\nRangeCalendar.Heading = Calendar.Heading;\n\n/**\n * Renders the day grid's native `<table>` host: identical to\n * {@link Calendar.Grid}.\n *\n * @param handle Runtime handle carrying the host `<table>`'s props.\n * @returns The render function producing the grid's markup.\n * @example\n * <RangeCalendar.Grid aria-label={monthLabel}>\n * \t<RangeCalendar.GridHeader>...</RangeCalendar.GridHeader>\n * \t<RangeCalendar.GridBody>...</RangeCalendar.GridBody>\n * </RangeCalendar.Grid>\n */\nRangeCalendar.Grid = Calendar.Grid;\n\n/**\n * Renders the grid's `<thead>` host: identical to {@link Calendar.GridHeader}.\n *\n * @param handle Runtime handle carrying the host `<thead>`'s props.\n * @returns The render function producing the header section's markup.\n * @example\n * <RangeCalendar.GridHeader>\n * \t<RangeCalendar.Row>\n * \t\t<RangeCalendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</RangeCalendar.HeaderCell>\n * \t</RangeCalendar.Row>\n * </RangeCalendar.GridHeader>\n */\nRangeCalendar.GridHeader = Calendar.GridHeader;\n\n/**\n * Renders a native `<tr>` host: identical to {@link Calendar.Row}. Composes\n * a row of {@link RangeCalendar.HeaderCell} inside\n * {@link RangeCalendar.GridHeader}, or a week's row of {@link RangeCalendar.Cell} inside {@link RangeCalendar.GridBody}.\n *\n * @param handle Runtime handle carrying the host `<tr>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <RangeCalendar.Row>\n * \t<RangeCalendar.Cell>{day.label}</RangeCalendar.Cell>\n * </RangeCalendar.Row>\n */\nRangeCalendar.Row = Calendar.Row;\n\n/**\n * Renders a weekday abbreviation: identical to {@link Calendar.HeaderCell}.\n *\n * @param handle Runtime handle carrying the host `<th>`'s props.\n * @returns The render function producing the weekday header's markup.\n * @example\n * <RangeCalendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</RangeCalendar.HeaderCell>\n */\nRangeCalendar.HeaderCell = Calendar.HeaderCell;\n\n/**\n * Renders the grid's `<tbody>` host: identical to {@link Calendar.GridBody}.\n *\n * @param handle Runtime handle carrying the host `<tbody>`'s props.\n * @returns The render function producing the body section's markup.\n * @example\n * <RangeCalendar.GridBody>\n * \t{weeks.map((week) => (\n * \t\t<RangeCalendar.Row key={week[0].iso}>...</RangeCalendar.Row>\n * \t))}\n * </RangeCalendar.GridBody>\n */\nRangeCalendar.GridBody = Calendar.GridBody;\n\n/**\n * Renders one calendar day for {@link RangeCalendar}, building on\n * {@link Calendar.Cell}. `data-selection-start`/`data-selection-end`\n * square off each end's outer corners so the range reads as one unbroken bar, driven by whatever state the consumer sets for the `calendarKeys()`/`rangePreview()` mixins.\n *\n * @param handle Runtime handle carrying the host `<td>`'s props.\n * @returns The render function producing the day's markup.\n * @example\n * <RangeCalendar.Cell data-selection-start=\"\">{day.label}</RangeCalendar.Cell>\n * @example\n * <RangeCalendar.Cell aria-selected=\"true\">{day.label}</RangeCalendar.Cell>\n * @example\n * <RangeCalendar.Cell data-selection-end=\"\">{day.label}</RangeCalendar.Cell>\n */\nRangeCalendar.Cell = function RangeCalendarCell(handle: Handle<RangeCalendar.CellProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Calendar.Cell\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\t/**\n\t\t\t\t\t * A day is the range's opening, its closing, both at once, or one of the days\n\t\t\t\t\t * between. The four are written under selectors that match one apiece, so each\n\t\t\t\t\t * day keeps its own shape however the cascade orders the set.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&[data-selection-start]:not([data-selection-end])\", [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\troundedCorner(\"start-end\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-end\", \"none\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&[data-selection-end]:not([data-selection-start])\", [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\troundedCorner(\"start-start\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-start\", \"none\"),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * A range of one day opens and closes on itself, so it reads as a single day.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&[data-selection-start][data-selection-end]\", [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[aria-selected=\"true\"]:not([data-selection-start]):not([data-selection-end])', [\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The days between carry the range across the row, so the band reads as one\n\t\t\t\t\t\t * run at a glance while the two ends stay the strongest thing in the month.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tbg(\"brand.bg-tint-hover\"),\n\t\t\t\t\t\tfg(\"brand.emphasis\"),\n\t\t\t\t\t\troundedCorner(\"start-start\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"start-end\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-start\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-end\", \"none\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
13
|
+
"content": "/**\n * A calendar surface for choosing a start and end date as one connected\n * range, sharing every header, grid, and row part with {@link Calendar} and\n * layering range position on top of its day cell. Used bare, with no\n * composed children, it renders a pair of native `<input type=\"date\">`\n * fields instead — start and end, each independently keyboard-operable —\n * ready for the `calendarKeys()`/`rangePreview()` mixins a consumer attaches\n * to turn the composed grid into a live, drag- or arrow-key-extended range.\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 { bg, fg } from \"@sdxc/u/color\";\nimport { roundedCorner } from \"@sdxc/u/effects\";\nimport { mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, items } from \"@sdxc/u/layout\";\nimport { when } from \"@sdxc/u/state\";\nimport { attrs } from \"remix/component\";\n\nimport { Calendar } from \"@sdxc/ui/calendar\";\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Semantic color role {@link RangeCalendar}'s bare fallback pair falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: RangeCalendar.Color = \"neutral\";\n\n/**\n * Prop types for {@link RangeCalendar} and its compound parts. Every part\n * but {@link RangeCalendar.Cell} aliases {@link Calendar}'s matching part,\n * sharing its header, grid, and row markup.\n */\nexport namespace RangeCalendar {\n\t/**\n\t * Semantic color role for the bare fallback pair's keyboard focus rings,\n\t * mapped to `--ui-*` variables like {@link Calendar.Color}. The composed\n\t * grid's day cells always use fixed semantic roles, regardless of this value.\n\t */\n\texport type Color = Calendar.Color;\n\n\t/**\n\t * Per-part styling for the bare fallback pair's two internally composed\n\t * inputs, layered after each input's own built-in styling. Style the\n\t * composed grid's parts through {@link Calendar}'s own compound parts.\n\t */\n\texport interface PartsProps {\n\t\t/** Styling for the bare fallback's start-date input, rendered through {@link Input}. */\n\t\tstart?: TagProps<\"input\">[\"mix\"];\n\t\t/** Styling for the bare fallback's end-date input, rendered through {@link Input}. */\n\t\tend?: TagProps<\"input\">[\"mix\"];\n\t}\n\n\t/**\n\t * Props accepted by {@link RangeCalendar}. Composing\n\t * {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`\n\t * renders the visual month surface; omitting `children` renders a bare native `<input type=\"date\">` pair from the fields below.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Semantic color role for the bare fallback pair's focus rings. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Native `name` submitted with an enclosing form, read only by the bare fallback's start-date input. */\n\t\tstartName?: string;\n\t\t/** Native `name` submitted with an enclosing form, read only by the bare fallback's end-date input. */\n\t\tendName?: string;\n\t\t/** Current start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */\n\t\tstartValue?: string;\n\t\t/** Current end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */\n\t\tendValue?: string;\n\t\t/** Initial start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */\n\t\tstartDefaultValue?: string;\n\t\t/** Initial end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */\n\t\tendDefaultValue?: string;\n\t\t/** Earliest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */\n\t\tmin?: string;\n\t\t/** Latest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */\n\t\tmax?: string;\n\t\t/** Granularity, in days, both of the bare fallback pair's values must fall on. */\n\t\tstep?: number;\n\t\t/** Marks both of the bare fallback pair's inputs required for their enclosing form. */\n\t\trequired?: boolean;\n\t\t/** Marks both of the bare fallback pair's inputs inert and excluded from the tab order. */\n\t\tdisabled?: boolean;\n\t\t/** Marks both of the bare fallback pair's inputs' values fixed, while keeping them focusable and included in form submission. */\n\t\treadOnly?: boolean;\n\t\t/** Native autofill hint for both of the bare fallback pair's inputs, e.g. `\"bday\"`. */\n\t\tautoComplete?: string;\n\t\t/** Accessible label for the bare fallback pair's start-date input. Read only when `children` is unset. */\n\t\tstartLabel?: string;\n\t\t/** Accessible label for the bare fallback pair's end-date input. Read only when `children` is unset. */\n\t\tendLabel?: string;\n\t\t/** Per-part styling for the bare fallback pair's internally composed inputs. */\n\t\tparts?: PartsProps;\n\t}\n\n\t/** Every prop {@link Calendar.HeaderProps} accepts, unchanged. */\n\texport interface HeaderProps extends Calendar.HeaderProps {}\n\n\t/** Every prop {@link Calendar.PreviousButtonProps} accepts, unchanged. */\n\texport interface PreviousButtonProps extends Calendar.PreviousButtonProps {}\n\n\t/** Every prop {@link Calendar.NextButtonProps} accepts, unchanged. */\n\texport interface NextButtonProps extends Calendar.NextButtonProps {}\n\n\t/** Every prop {@link Calendar.HeadingProps} accepts, unchanged. */\n\texport interface HeadingProps extends Calendar.HeadingProps {}\n\n\t/** Every prop {@link Calendar.GridProps} accepts, unchanged. */\n\texport interface GridProps extends Calendar.GridProps {}\n\n\t/** Every prop {@link Calendar.GridHeaderProps} accepts, unchanged. */\n\texport interface GridHeaderProps extends Calendar.GridHeaderProps {}\n\n\t/** Every prop {@link Calendar.RowProps} accepts, unchanged. */\n\texport interface RowProps extends Calendar.RowProps {}\n\n\t/** Every prop {@link Calendar.HeaderCellProps} accepts, unchanged. */\n\texport interface HeaderCellProps extends Calendar.HeaderCellProps {}\n\n\t/** Every prop {@link Calendar.GridBodyProps} accepts, unchanged. */\n\texport interface GridBodyProps extends Calendar.GridBodyProps {}\n\n\t/**\n\t * Every prop {@link Calendar.CellProps} accepts, unchanged. Set\n\t * `data-selection-start` on the range's first day, `data-selection-end`\n\t * on its last, and `aria-selected=\"true\"` alone on the days between — each read straight off what the consumer sets on this instance.\n\t */\n\texport interface CellProps extends Calendar.CellProps {}\n}\n\n/**\n * Renders {@link RangeCalendar}'s root through {@link Calendar}. Composing\n * {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`\n * renders the visual month surface; omitting `children` renders a bare, script-free native `<input type=\"date\">` pair from this instance's own fields.\n *\n * @param handle Runtime handle carrying the root element's props.\n * @returns The render function producing the range calendar's markup.\n * @example\n * <RangeCalendar startLabel={t(\"form.stay.checkIn\")} endLabel={t(\"form.stay.checkOut\")} startName=\"checkIn\" endName=\"checkOut\" />\n * @example\n * <RangeCalendar aria-label={t(\"calendar.label\")}>\n * \t<RangeCalendar.Header>\n * \t\t<RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t\t<RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n * \t\t<RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n * \t</RangeCalendar.Header>\n * \t<RangeCalendar.Grid aria-label={monthLabel}>\n * \t\t<RangeCalendar.GridHeader>\n * \t\t\t<RangeCalendar.Row>\n * \t\t\t\t{weekdayLabels.map((day) => (\n * \t\t\t\t\t<RangeCalendar.HeaderCell key={day}>{day}</RangeCalendar.HeaderCell>\n * \t\t\t\t))}\n * \t\t\t</RangeCalendar.Row>\n * \t\t</RangeCalendar.GridHeader>\n * \t\t<RangeCalendar.GridBody>\n * \t\t\t{weeks.map((week) => (\n * \t\t\t\t<RangeCalendar.Row key={week[0].iso}>\n * \t\t\t\t\t{week.map((day) => (\n * \t\t\t\t\t\t<RangeCalendar.Cell\n * \t\t\t\t\t\t\tkey={day.iso}\n * \t\t\t\t\t\t\taria-selected={day.inRange ? \"true\" : undefined}\n * \t\t\t\t\t\t\tdata-selection-start={day.iso === range.start ? \"\" : undefined}\n * \t\t\t\t\t\t\tdata-selection-end={day.iso === range.end ? \"\" : undefined}\n * \t\t\t\t\t\t>\n * \t\t\t\t\t\t\t{day.label}\n * \t\t\t\t\t\t</RangeCalendar.Cell>\n * \t\t\t\t\t))}\n * \t\t\t\t</RangeCalendar.Row>\n * \t\t\t))}\n * \t\t</RangeCalendar.GridBody>\n * \t</RangeCalendar.Grid>\n * </RangeCalendar>\n */\nexport function RangeCalendar(handle: Handle<RangeCalendar.Props>) {\n\treturn () => {\n\t\tlet {\n\t\t\tcolor,\n\t\t\tstartName,\n\t\t\tendName,\n\t\t\tstartValue,\n\t\t\tendValue,\n\t\t\tstartDefaultValue,\n\t\t\tendDefaultValue,\n\t\t\tmin,\n\t\t\tmax,\n\t\t\tstep,\n\t\t\trequired,\n\t\t\tdisabled,\n\t\t\treadOnly,\n\t\t\tautoComplete,\n\t\t\tstartLabel,\n\t\t\tendLabel,\n\t\t\tparts,\n\t\t\tchildren,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\tif (import.meta.env?.DEV && !children) {\n\t\t\tif (!startLabel) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'RangeCalendar: falling back to a plain \"input type=date\" pair needs a \"startLabel\" describing the range\\'s start for assistive technology.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!endLabel) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'RangeCalendar: falling back to a plain \"input type=date\" pair needs an \"endLabel\" describing the range\\'s end for assistive technology.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<Calendar {...rest} mix={mix}>\n\t\t\t\t{children ?? (\n\t\t\t\t\t<div\n\t\t\t\t\t\tdata-slot=\"fields\"\n\t\t\t\t\t\tmix={[attrs({ role: \"group\" }), flex(), items(\"center\"), gap(\"0.5rem\")]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tdata-slot=\"start-input\"\n\t\t\t\t\t\t\tcolor={resolvedColor}\n\t\t\t\t\t\t\tname={startName}\n\t\t\t\t\t\t\tvalue={startValue}\n\t\t\t\t\t\t\tdefaultValue={startDefaultValue}\n\t\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\t\taria-label={startLabel}\n\t\t\t\t\t\t\tmix={parts?.start}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tdata-slot=\"end-input\"\n\t\t\t\t\t\t\tcolor={resolvedColor}\n\t\t\t\t\t\t\tname={endName}\n\t\t\t\t\t\t\tvalue={endValue}\n\t\t\t\t\t\t\tdefaultValue={endDefaultValue}\n\t\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\t\taria-label={endLabel}\n\t\t\t\t\t\t\tmix={parts?.end}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</Calendar>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link RangeCalendar.HeaderProps.children} as the nav row: identical\n * to {@link Calendar.Header}, since {@link RangeCalendar} reuses\n * {@link Calendar}'s grid markup for its own header.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the nav row's markup.\n * @example\n * <RangeCalendar.Header>\n * \t<RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t<RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n * \t<RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n * </RangeCalendar.Header>\n */\nRangeCalendar.Header = Calendar.Header;\n\n/**\n * Renders a control standing for \"show the previous month\": identical to\n * {@link Calendar.PreviousButton}.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n */\nRangeCalendar.PreviousButton = Calendar.PreviousButton;\n\n/**\n * Renders a control standing for \"show the following month\": identical to\n * {@link Calendar.NextButton}.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n */\nRangeCalendar.NextButton = Calendar.NextButton;\n\n/**\n * Renders the calendar's visible month/year caption: identical to\n * {@link Calendar.Heading}.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the caption's markup.\n * @example\n * <RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n */\nRangeCalendar.Heading = Calendar.Heading;\n\n/**\n * Renders the day grid's native `<table>` host: identical to\n * {@link Calendar.Grid}.\n *\n * @param handle Runtime handle carrying the host `<table>`'s props.\n * @returns The render function producing the grid's markup.\n * @example\n * <RangeCalendar.Grid aria-label={monthLabel}>\n * \t<RangeCalendar.GridHeader>...</RangeCalendar.GridHeader>\n * \t<RangeCalendar.GridBody>...</RangeCalendar.GridBody>\n * </RangeCalendar.Grid>\n */\nRangeCalendar.Grid = Calendar.Grid;\n\n/**\n * Renders the grid's `<thead>` host: identical to {@link Calendar.GridHeader}.\n *\n * @param handle Runtime handle carrying the host `<thead>`'s props.\n * @returns The render function producing the header section's markup.\n * @example\n * <RangeCalendar.GridHeader>\n * \t<RangeCalendar.Row>\n * \t\t<RangeCalendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</RangeCalendar.HeaderCell>\n * \t</RangeCalendar.Row>\n * </RangeCalendar.GridHeader>\n */\nRangeCalendar.GridHeader = Calendar.GridHeader;\n\n/**\n * Renders a native `<tr>` host: identical to {@link Calendar.Row}. Composes\n * a row of {@link RangeCalendar.HeaderCell} inside\n * {@link RangeCalendar.GridHeader}, or a week's row of {@link RangeCalendar.Cell} inside {@link RangeCalendar.GridBody}.\n *\n * @param handle Runtime handle carrying the host `<tr>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <RangeCalendar.Row>\n * \t<RangeCalendar.Cell>{day.label}</RangeCalendar.Cell>\n * </RangeCalendar.Row>\n */\nRangeCalendar.Row = Calendar.Row;\n\n/**\n * Renders a weekday abbreviation: identical to {@link Calendar.HeaderCell}.\n *\n * @param handle Runtime handle carrying the host `<th>`'s props.\n * @returns The render function producing the weekday header's markup.\n * @example\n * <RangeCalendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</RangeCalendar.HeaderCell>\n */\nRangeCalendar.HeaderCell = Calendar.HeaderCell;\n\n/**\n * Renders the grid's `<tbody>` host: identical to {@link Calendar.GridBody}.\n *\n * @param handle Runtime handle carrying the host `<tbody>`'s props.\n * @returns The render function producing the body section's markup.\n * @example\n * <RangeCalendar.GridBody>\n * \t{weeks.map((week) => (\n * \t\t<RangeCalendar.Row key={week[0].iso}>...</RangeCalendar.Row>\n * \t))}\n * </RangeCalendar.GridBody>\n */\nRangeCalendar.GridBody = Calendar.GridBody;\n\n/**\n * Renders one calendar day for {@link RangeCalendar}, building on\n * {@link Calendar.Cell}. `data-selection-start`/`data-selection-end`\n * square off each end's outer corners so the range reads as one unbroken bar, driven by whatever state the consumer sets for the `calendarKeys()`/`rangePreview()` mixins.\n *\n * @param handle Runtime handle carrying the host `<td>`'s props.\n * @returns The render function producing the day's markup.\n * @example\n * <RangeCalendar.Cell data-selection-start=\"\">{day.label}</RangeCalendar.Cell>\n * @example\n * <RangeCalendar.Cell aria-selected=\"true\">{day.label}</RangeCalendar.Cell>\n * @example\n * <RangeCalendar.Cell data-selection-end=\"\">{day.label}</RangeCalendar.Cell>\n */\nRangeCalendar.Cell = function RangeCalendarCell(handle: Handle<RangeCalendar.CellProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Calendar.Cell\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A day is the range's opening, its closing, both at once, or one of the days\n\t\t\t\t\t\t * between. The four are written under selectors that match one apiece, so each\n\t\t\t\t\t\t * day keeps its own shape however the cascade orders the set.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&[data-selection-start]:not([data-selection-end])\", [\n\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t\troundedCorner(\"start-end\", \"none\"),\n\t\t\t\t\t\t\troundedCorner(\"end-end\", \"none\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\"&[data-selection-end]:not([data-selection-start])\", [\n\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t\troundedCorner(\"start-start\", \"none\"),\n\t\t\t\t\t\t\troundedCorner(\"end-start\", \"none\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A range of one day opens and closes on itself, so it reads as a single day.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&[data-selection-start][data-selection-end]\", [\n\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[aria-selected=\"true\"]:not([data-selection-start]):not([data-selection-end])', [\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The days between carry the range across the row, so the band reads as one\n\t\t\t\t\t\t\t * run at a glance while the two ends stay the strongest thing in the month.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tbg(\"brand.bg-tint-hover\"),\n\t\t\t\t\t\t\tfg(\"brand.emphasis\"),\n\t\t\t\t\t\t\troundedCorner(\"start-start\", \"none\"),\n\t\t\t\t\t\t\troundedCorner(\"start-end\", \"none\"),\n\t\t\t\t\t\t\troundedCorner(\"end-start\", \"none\"),\n\t\t\t\t\t\t\troundedCorner(\"end-end\", \"none\"),\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"
|
|
14
14
|
},
|
|
15
15
|
"test": null
|
|
16
16
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "relative-time",
|
|
3
|
+
"changedIn": "2026.11.3",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"RelativeTime",
|
|
7
|
+
"RelativeTimeLocal"
|
|
8
|
+
],
|
|
9
|
+
"source": {
|
|
10
|
+
"path": "relative-time.tsx",
|
|
11
|
+
"content": "/**\n * A `<time>` that reads \"2m ago\" for the last week and a date after it, with the absolute local\n * time and UTC in its title. The server renders it from an explicit `now` and zone, and an\n * optional island rewrites it in the viewer's own zone, the one thing a server cannot know.\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 } from \"@sdxc/u/general\";\nimport { tabularNums } from \"@sdxc/u/typography\";\nimport { clientEntry } from \"remix/component\";\n\nimport type { RelativeTimeFormat } from \"@sdxc/ui/utils\";\n\nimport { viewerTime } from \"@sdxc/ui/mixins\";\nimport { formatRelativeTime } from \"@sdxc/ui/utils\";\n\nexport { formatRelativeTime } from \"@sdxc/ui/utils\";\n\n/**\n * Prop types for {@link RelativeTime} and its island.\n */\nexport namespace RelativeTime {\n\t/** A moment as a `Date`, an ISO 8601 string or epoch milliseconds. */\n\texport type DateInput = RelativeTimeFormat.DateInput;\n\n\t/**\n\t * Every native `<time>` attribute but `dateTime`, which the component writes, plus the\n\t * moment and how to format it.\n\t */\n\texport interface Props extends Omit<TagProps<\"time\">, \"dateTime\" | \"children\"> {\n\t\t/** The moment to show. */\n\t\tdate: DateInput;\n\t\t/** The reference moment; pass the request's time so server and tests render the same text. */\n\t\tnow?: DateInput;\n\t\t/** BCP 47 locale for the text and the title. */\n\t\tlocale?: string;\n\t\t/** IANA zone the server formats in. Defaults to UTC. */\n\t\ttimeZone?: string;\n\t\t/**\n\t\t * Hydrates the {@link RelativeTimeLocal} island, which rewrites the date and title in the\n\t\t * viewer's zone and locale, counting from `now` when given and their clock otherwise.\n\t\t * Needs `@sdxc/ui/relative-time#RelativeTimeLocal` in the app's browser entry.\n\t\t */\n\t\tlocal?: boolean;\n\t}\n\n\t/** Props {@link RelativeTimeLocal} serializes for hydration, so they stay plain JSON. */\n\texport type LocalProps = {\n\t\t/** The moment, as an ISO 8601 string or epoch milliseconds. */\n\t\tdate: string | number;\n\t\t/** The reference moment the text counts from; unset counts from the viewer's clock. */\n\t\tnow?: string | number;\n\t\t/** BCP 47 locale for the text and the title. */\n\t\tlocale?: string;\n\t\t/** IANA zone the server rendered in. */\n\t\ttimeZone?: string;\n\t\t/** Accessible description, passed through to the `<time>`. */\n\t\t\"aria-label\"?: string;\n\t\t/** Element id, passed through to the `<time>`. */\n\t\tid?: string;\n\t};\n}\n\n/**\n * Renders the moment as `<time datetime>` with its text and absolute title. With `local` it\n * hands the same props to {@link RelativeTimeLocal}, so the server HTML is identical and the\n * viewer's zone replaces the server's once the island hydrates.\n *\n * @param handle Runtime handle carrying the `<time>`'s props.\n * @returns The render function producing the element.\n * @example <RelativeTime date={check.at} now={ctx.requestTime} locale={locale} />\n * @example <RelativeTime date={deploy.createdAt} now={now} locale={locale} local />\n */\nexport function RelativeTime(handle: Handle<RelativeTime.Props>) {\n\treturn () => {\n\t\tlet { date, now, locale, timeZone, local, mix, ...rest } = handle.props;\n\n\t\tif (local) {\n\t\t\treturn (\n\t\t\t\t<RelativeTimeLocal\n\t\t\t\t\tdate={serializable(date)}\n\t\t\t\t\tnow={now === undefined ? undefined : serializable(now)}\n\t\t\t\t\tlocale={locale}\n\t\t\t\t\ttimeZone={timeZone}\n\t\t\t\t\taria-label={rest[\"aria-label\"]}\n\t\t\t\t\tid={rest.id}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\tlet formatted = formatRelativeTime(date, { now, locale, timeZone });\n\n\t\treturn (\n\t\t\t<time\n\t\t\t\ttitle={formatted.title || undefined}\n\t\t\t\t{...rest}\n\t\t\t\tdateTime={formatted.dateTime || undefined}\n\t\t\t\tdata-slot=\"relative-time\"\n\t\t\t\tmix={mergeMix(tabularNums(), mix)}\n\t\t\t>\n\t\t\t\t{formatted.text}\n\t\t\t</time>\n\t\t);\n\t};\n}\n\n/** Turns a `Date` into its ISO string so an island prop survives serialization. */\nfunction serializable(value: RelativeTime.DateInput): string | number {\n\treturn value instanceof Date ? value.toISOString() : value;\n}\n\n/**\n * Client island behind {@link RelativeTime}'s `local` prop: the same `<time>` the server renders,\n * rewritten in the viewer's zone on hydration, still counting from `now` when one is given.\n * Until the island loads the server's text stands, so the moment is always readable.\n *\n * @example <RelativeTimeLocal date=\"2026-10-30T14:00:00Z\" locale=\"en\" />\n */\nexport const RelativeTimeLocal: EntryComponent<RelativeTime.LocalProps> = clientEntry(\n\t\"@sdxc/ui/relative-time#RelativeTimeLocal\",\n\tfunction RelativeTimeLocal(handle: Handle<RelativeTime.LocalProps>) {\n\t\treturn () => {\n\t\t\tlet { date, now, locale, timeZone, ...rest } = handle.props;\n\t\t\tlet formatted = formatRelativeTime(date, { now, locale, timeZone });\n\n\t\t\treturn (\n\t\t\t\t<time\n\t\t\t\t\t{...rest}\n\t\t\t\t\ttitle={formatted.title || undefined}\n\t\t\t\t\tdateTime={formatted.dateTime || undefined}\n\t\t\t\t\tdata-slot=\"relative-time\"\n\t\t\t\t\tmix={[tabularNums(), viewerTime(locale, now)]}\n\t\t\t\t>\n\t\t\t\t\t{formatted.text}\n\t\t\t\t</time>\n\t\t\t);\n\t\t};\n\t},\n);\n"
|
|
12
|
+
},
|
|
13
|
+
"test": {
|
|
14
|
+
"path": "relative-time.browser.test.tsx",
|
|
15
|
+
"content": "/**\n * Renders relative times in a real browser: the text steps through seconds, minutes, hours and\n * days and turns into a date at seven days, `datetime` carries the instant, the title names local\n * and UTC time, and the island rewrites both in the viewer's zone.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { cdp } from \"vitest/browser\";\n\nimport { formatRelativeTime, RelativeTime, RelativeTimeLocal } from \"@sdxc/ui/relative-time\";\n\nconst NOW = \"2026-11-01T12:00:00.000Z\";\n\n/** Mounts `node` in a fresh host and returns its `<time>`. */\nfunction mount(node: JSX.Element): HTMLTimeElement {\n\tlet host = document.createElement(\"div\");\n\tdocument.body.appendChild(host);\n\trender(node, { container: host });\n\treturn host.querySelector(\"time\")!;\n}\n\n/** The instant `ms` milliseconds before {@link NOW}. */\nfunction before(ms: number): string {\n\treturn new Date(Date.parse(NOW) - ms).toISOString();\n}\n\nafterEach(async () => {\n\tdocument.body.replaceChildren();\n\tawait cdp().send(\"Emulation.setTimezoneOverride\", { timezoneId: \"\" });\n});\n\ndescribe(\"RelativeTime\", () => {\n\tfor (let [ago, text] of [\n\t\t[0, \"now\"],\n\t\t[30 * 1000, \"30s ago\"],\n\t\t[2 * 60 * 1000, \"2m ago\"],\n\t\t[59 * 60 * 1000 + 59 * 1000, \"59m ago\"],\n\t\t[3 * 60 * 60 * 1000, \"3h ago\"],\n\t\t[2 * 24 * 60 * 60 * 1000, \"2d ago\"],\n\t\t[7 * 24 * 60 * 60 * 1000 - 1000, \"6d ago\"],\n\t\t[7 * 24 * 60 * 60 * 1000, \"Oct 25, 2026\"],\n\t] as const) {\n\t\ttest(`reads ${text} for a moment ${ago}ms before now`, () => {\n\t\t\tlet time = mount(<RelativeTime date={before(ago)} now={NOW} locale=\"en\" />);\n\t\t\texpect(time.textContent).toBe(text);\n\t\t});\n\t}\n\n\ttest(\"reads future moments forward\", () => {\n\t\tlet time = mount(<RelativeTime date=\"2026-11-01T12:05:00Z\" now={NOW} locale=\"en\" />);\n\t\texpect(time.textContent).toBe(\"in 5m\");\n\t});\n\n\ttest(\"carries the instant in datetime and the absolute time in the title\", () => {\n\t\tlet time = mount(<RelativeTime date=\"2026-11-01T11:58:00Z\" now={NOW} locale=\"en\" />);\n\n\t\texpect(time.dateTime).toBe(\"2026-11-01T11:58:00.000Z\");\n\t\texpect(time.title).toBe(\"Nov 1, 2026, 11:58:00 AM UTC\");\n\t});\n\n\ttest(\"names the server's zone and UTC on two lines when they differ\", () => {\n\t\tlet time = mount(\n\t\t\t<RelativeTime date=\"2026-10-01T02:00:00Z\" now={NOW} locale=\"en\" timeZone=\"America/Lima\" />,\n\t\t);\n\n\t\texpect(time.textContent).toBe(\"Sep 30, 2026\");\n\t\texpect(time.title.split(\"\\n\")).toEqual([\n\t\t\t\"Sep 30, 2026, 9:00:00 PM GMT-5\",\n\t\t\t\"Oct 1, 2026, 2:00:00 AM UTC\",\n\t\t]);\n\t});\n\n\ttest(\"renders a dash for a date that does not parse\", () => {\n\t\tlet time = mount(<RelativeTime date=\"not a date\" now={NOW} />);\n\n\t\texpect(time.textContent).toBe(\"—\");\n\t\texpect(time.hasAttribute(\"datetime\")).toBe(false);\n\t});\n\n\ttest(\"formats in the locale it is given\", () => {\n\t\texpect(formatRelativeTime(before(2 * 60 * 60 * 1000), { now: NOW, locale: \"es\" }).text).toBe(\n\t\t\t\"hace 2 h\",\n\t\t);\n\t});\n});\n\ndescribe(\"RelativeTimeLocal\", () => {\n\ttest(\"rewrites the date and title in the viewer's zone\", async () => {\n\t\tawait cdp().send(\"Emulation.setTimezoneOverride\", { timezoneId: \"America/Lima\" });\n\t\tlet time = mount(<RelativeTimeLocal date=\"2020-03-01T02:00:00Z\" locale=\"en\" />);\n\n\t\tawait expect.poll(() => time.textContent).toBe(\"Feb 29, 2020\");\n\t\texpect(time.title.split(\"\\n\")).toEqual([\n\t\t\t\"Feb 29, 2020, 9:00:00 PM GMT-5\",\n\t\t\t\"Mar 1, 2020, 2:00:00 AM UTC\",\n\t\t]);\n\t\texpect(time.dateTime).toBe(\"2020-03-01T02:00:00.000Z\");\n\t});\n\n\ttest(\"counts from the given now while formatting in the viewer's zone\", async () => {\n\t\tawait cdp().send(\"Emulation.setTimezoneOverride\", { timezoneId: \"America/Lima\" });\n\t\tlet past = mount(\n\t\t\t<RelativeTimeLocal date=\"2020-03-01T02:00:00Z\" now=\"2020-03-01T04:00:00Z\" locale=\"en\" />,\n\t\t);\n\n\t\tawait expect.poll(() => past.title.split(\"\\n\")[0]).toBe(\"Feb 29, 2020, 9:00:00 PM GMT-5\");\n\t\texpect(past.textContent).toBe(\"2h ago\");\n\n\t\tlet future = mount(\n\t\t\t<RelativeTime date=\"2020-03-01T06:00:00Z\" now=\"2020-03-01T04:00:00Z\" locale=\"en\" local />,\n\t\t);\n\t\tawait expect.poll(() => future.title.split(\"\\n\")[0]).toBe(\"Mar 1, 2020, 1:00:00 AM GMT-5\");\n\t\texpect(future.textContent).toBe(\"in 2h\");\n\t});\n\n\ttest(\"is what RelativeTime renders with local\", async () => {\n\t\tawait cdp().send(\"Emulation.setTimezoneOverride\", { timezoneId: \"Asia/Tokyo\" });\n\t\tlet time = mount(<RelativeTime date=\"2020-03-01T20:00:00Z\" locale=\"en\" local />);\n\n\t\tawait expect.poll(() => time.textContent).toBe(\"Mar 2, 2020\");\n\t});\n});\n"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scroll-area",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"ScrollArea"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "scroll-area.tsx",
|
|
10
|
-
"content": "/**\n * A scrollable region wrapping long or overflowing content — a chat log, a\n * table, a tall list — so it scrolls its own axis inside a bordered panel\n * instead of pushing the surrounding page. {@link ScrollArea.Viewport} is the\n * element that actually scrolls; the root only supplies the panel's border\n * and rounding.\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 { bg, border, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { raw } from \"@sdxc/u/general\";\nimport { relative } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is } from \"@sdxc/u/size\";\nimport { data, hover, when } from \"@sdxc/u/state\";\nimport { attrs } from \"remix/component\";\n\nimport { panelChrome } from \"@sdxc/ui/styles\";\n\n/**\n * Native tab-stop order applied to {@link ScrollArea.Viewport} through\n * {@link attrs} unless a consumer supplies its own `tabIndex`, keeping it\n * reachable via keyboard even when none of its content is focusable.\n */\nconst DEFAULT_TAB_INDEX = 0;\n\n/**\n * Default {@link ScrollArea.Viewport} axis, applied whenever a consumer\n * omits `orientation`.\n */\nconst DEFAULT_ORIENTATION: ScrollArea.Orientation = \"vertical\";\n\n/**\n * Prop types for {@link ScrollArea} and its compound parts.\n */\nexport namespace ScrollArea {\n\t/**\n\t * Axis {@link ScrollArea.Viewport} scrolls along: only the block axis\n\t * (`\"vertical\"`), only the inline axis (`\"horizontal\"`), or both at once\n\t * (`\"both\"`).\n\t */\n\texport type Orientation = \"vertical\" | \"horizontal\" | \"both\";\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * `orientation` defaults to {@link DEFAULT_ORIENTATION}; `tabIndex` defaults\n\t * to {@link DEFAULT_TAB_INDEX}, overridable to `-1` when content is reachable.\n\t */\n\texport interface ViewportProps extends TagProps<\"div\"> {\n\t\t/** Axis the viewport scrolls along. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t}\n}\n\n/**\n * Renders the scroll area's outer panel: a relatively positioned, rounded,\n * bordered `<div>` that frames whatever {@link ScrollArea.Viewport} scrolls\n * inside it, staying a fixed border around the scrolling content.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the panel's markup.\n * @example\n * <ScrollArea>\n * \t<ScrollArea.Viewport>\n * \t\t<p>{t(\"changelog.body\")}</p>\n * \t</ScrollArea.Viewport>\n * </ScrollArea>\n */\nexport function ScrollArea(handle: Handle<ScrollArea.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"scroll-area\" mix={[panelChrome(), relative(), mix
|
|
10
|
+
"content": "/**\n * A scrollable region wrapping long or overflowing content — a chat log, a\n * table, a tall list — so it scrolls its own axis inside a bordered panel\n * instead of pushing the surrounding page. {@link ScrollArea.Viewport} is the\n * element that actually scrolls; the root only supplies the panel's border\n * and rounding.\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 { bg, border, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { raw, mergeMix } from \"@sdxc/u/general\";\nimport { relative } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is } from \"@sdxc/u/size\";\nimport { data, hover, when } from \"@sdxc/u/state\";\nimport { attrs } from \"remix/component\";\n\nimport { panelChrome } from \"@sdxc/ui/styles\";\n\n/**\n * Native tab-stop order applied to {@link ScrollArea.Viewport} through\n * {@link attrs} unless a consumer supplies its own `tabIndex`, keeping it\n * reachable via keyboard even when none of its content is focusable.\n */\nconst DEFAULT_TAB_INDEX = 0;\n\n/**\n * Default {@link ScrollArea.Viewport} axis, applied whenever a consumer\n * omits `orientation`.\n */\nconst DEFAULT_ORIENTATION: ScrollArea.Orientation = \"vertical\";\n\n/**\n * Prop types for {@link ScrollArea} and its compound parts.\n */\nexport namespace ScrollArea {\n\t/**\n\t * Axis {@link ScrollArea.Viewport} scrolls along: only the block axis\n\t * (`\"vertical\"`), only the inline axis (`\"horizontal\"`), or both at once\n\t * (`\"both\"`).\n\t */\n\texport type Orientation = \"vertical\" | \"horizontal\" | \"both\";\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * `orientation` defaults to {@link DEFAULT_ORIENTATION}; `tabIndex` defaults\n\t * to {@link DEFAULT_TAB_INDEX}, overridable to `-1` when content is reachable.\n\t */\n\texport interface ViewportProps extends TagProps<\"div\"> {\n\t\t/** Axis the viewport scrolls along. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t}\n}\n\n/**\n * Renders the scroll area's outer panel: a relatively positioned, rounded,\n * bordered `<div>` that frames whatever {@link ScrollArea.Viewport} scrolls\n * inside it, staying a fixed border around the scrolling content.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the panel's markup.\n * @example\n * <ScrollArea>\n * \t<ScrollArea.Viewport>\n * \t\t<p>{t(\"changelog.body\")}</p>\n * \t</ScrollArea.Viewport>\n * </ScrollArea>\n */\nexport function ScrollArea(handle: Handle<ScrollArea.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div {...rest} data-slot=\"scroll-area\" mix={mergeMix([panelChrome(), relative()], mix)} />\n\t\t);\n\t};\n}\n\n/**\n * Renders the scroll area's scrolling surface: a `<div>` filling its parent\n * panel, clipping and scrolling along the axis named by `data-orientation`\n * with a thin native scrollbar that gains a focus ring when focus-visible.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the viewport's markup.\n * @example\n * <ScrollArea.Viewport>\n * \t<Table>...</Table>\n * </ScrollArea.Viewport>\n * @example\n * <ScrollArea.Viewport orientation=\"horizontal\">\n * \t<Toolbar aria-label={t(\"gallery.filmstrip\")}>...</Toolbar>\n * </ScrollArea.Viewport>\n */\nScrollArea.Viewport = function ScrollAreaViewport(handle: Handle<ScrollArea.ViewportProps>) {\n\treturn () => {\n\t\tlet { orientation, mix, ...rest } = handle.props;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-orientation={resolvedOrientation}\n\t\t\t\tdata-slot=\"viewport\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ tabIndex: DEFAULT_TAB_INDEX }),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tbs(\"full\"),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tscrollBehavior: \"smooth\",\n\t\t\t\t\t\t\tscrollbarWidth: \"thin\",\n\t\t\t\t\t\t\tscrollbarGutter: \"stable\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tdata(\n\t\t\t\t\t\t\t\"orientation\",\n\t\t\t\t\t\t\t\"vertical\",\n\t\t\t\t\t\t\traw({ overflowBlock: \"auto\", overflowInline: \"hidden\" }),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdata(\n\t\t\t\t\t\t\t\"orientation\",\n\t\t\t\t\t\t\t\"horizontal\",\n\t\t\t\t\t\t\traw({ overflowInline: \"auto\", overflowBlock: \"hidden\" }),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdata(\"orientation\", \"both\", overflow(\"auto\")),\n\t\t\t\t\t\twhen(\"&::-webkit-scrollbar\", raw({ width: \"0.75rem\", height: \"0.75rem\" })),\n\t\t\t\t\t\twhen(\"&::-webkit-scrollbar-track\", bg(\"transparent\")),\n\t\t\t\t\t\twhen(\"&::-webkit-scrollbar-thumb\", [\n\t\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\t\tborder({ color: \"transparent\", width: \"3px\" }),\n\t\t\t\t\t\t\traw({ backgroundClip: \"content-box\" }),\n\t\t\t\t\t\t\thover(bg(\"neutral.strong\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", raw({ scrollBehavior: \"auto\" })),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|