@sdxc/kit 0.0.0-stage → 2026.10.16
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/LICENSE.md +21 -0
- package/README.md +92 -2
- package/changelog.jsonl +1040 -0
- package/config.schema.json +89 -0
- package/dist/bin.d.ts +9 -0
- package/dist/bin.js +10 -0
- package/dist/cli.d.ts +33 -0
- package/dist/cli.js +58 -0
- package/dist/commands/create.d.ts +20 -0
- package/dist/commands/create.js +164 -0
- package/dist/commands/init.d.ts +16 -0
- package/dist/commands/init.js +27 -0
- package/dist/commands/make.d.ts +335 -0
- package/dist/commands/make.js +152 -0
- package/dist/commands/run.d.ts +23 -0
- package/dist/commands/run.js +51 -0
- package/dist/commands/ui/add.d.ts +23 -0
- package/dist/commands/ui/add.js +50 -0
- package/dist/commands/ui/diff.d.ts +20 -0
- package/dist/commands/ui/diff.js +28 -0
- package/dist/commands/ui/list.d.ts +24 -0
- package/dist/commands/ui/list.js +45 -0
- package/dist/commands/ui/remove.d.ts +22 -0
- package/dist/commands/ui/remove.js +48 -0
- package/dist/commands/ui/update.d.ts +23 -0
- package/dist/commands/ui/update.js +37 -0
- package/dist/commands/upgrade.d.ts +30 -0
- package/dist/commands/upgrade.js +184 -0
- package/dist/config.d.ts +81 -0
- package/dist/config.js +157 -0
- package/dist/contract.d.ts +161 -0
- package/dist/contract.js +308 -0
- package/dist/create/github.d.ts +63 -0
- package/dist/create/github.js +172 -0
- package/dist/create/target.d.ts +31 -0
- package/dist/create/target.js +56 -0
- package/dist/create/templates.d.ts +62 -0
- package/dist/create/templates.js +228 -0
- package/dist/dependencies.d.ts +34 -0
- package/dist/dependencies.js +76 -0
- package/dist/diff.d.ts +14 -0
- package/dist/diff.js +103 -0
- package/dist/format.d.ts +21 -0
- package/dist/format.js +40 -0
- package/dist/init.d.ts +38 -0
- package/dist/init.js +92 -0
- package/dist/lock.d.ts +74 -0
- package/dist/lock.js +214 -0
- package/dist/make/declare.d.ts +54 -0
- package/dist/make/declare.js +495 -0
- package/dist/make/generate.d.ts +62 -0
- package/dist/make/generate.js +154 -0
- package/dist/make/imports.d.ts +43 -0
- package/dist/make/imports.js +105 -0
- package/dist/make/index.d.ts +43 -0
- package/dist/make/index.js +136 -0
- package/dist/make/kinds.d.ts +39 -0
- package/dist/make/kinds.js +95 -0
- package/dist/make/migrations.d.ts +41 -0
- package/dist/make/migrations.js +116 -0
- package/dist/make/names.d.ts +31 -0
- package/dist/make/names.js +47 -0
- package/dist/make/stubs.d.ts +44 -0
- package/dist/make/stubs.js +89 -0
- package/dist/middleware.d.ts +44 -0
- package/dist/middleware.js +49 -0
- package/dist/package-manager.d.ts +41 -0
- package/dist/package-manager.js +80 -0
- package/dist/project.d.ts +19 -0
- package/dist/project.js +42 -0
- package/dist/releases.d.ts +40 -0
- package/dist/releases.js +110 -0
- package/dist/testing.d.ts +50 -0
- package/dist/testing.js +129 -0
- package/dist/ui/commands.d.ts +114 -0
- package/dist/ui/commands.js +432 -0
- package/dist/ui/imports.d.ts +46 -0
- package/dist/ui/imports.js +160 -0
- package/dist/ui/layout.d.ts +48 -0
- package/dist/ui/layout.js +138 -0
- package/dist/ui/registry.d.ts +58 -0
- package/dist/ui/registry.js +82 -0
- package/dist/upgrade/changelog.d.ts +50 -0
- package/dist/upgrade/changelog.js +69 -0
- package/dist/upgrade/project.d.ts +62 -0
- package/dist/upgrade/project.js +132 -0
- package/dist/upgrade/prompt.d.ts +51 -0
- package/dist/upgrade/prompt.js +227 -0
- package/dist/upgrade/registry.d.ts +33 -0
- package/dist/upgrade/registry.js +50 -0
- package/lock.schema.json +60 -0
- package/package.json +44 -5
- package/registry/ui/accordion.json +15 -0
- package/registry/ui/alert-dialog.json +20 -0
- package/registry/ui/alert.json +15 -0
- package/registry/ui/aspect-ratio.json +13 -0
- package/registry/ui/attachment.json +15 -0
- package/registry/ui/avatar.json +15 -0
- package/registry/ui/badge.json +13 -0
- package/registry/ui/breadcrumbs.json +15 -0
- package/registry/ui/bubble.json +13 -0
- package/registry/ui/button.json +16 -0
- package/registry/ui/calendar.json +16 -0
- package/registry/ui/card.json +18 -0
- package/registry/ui/carousel.json +15 -0
- package/registry/ui/chart.json +13 -0
- package/registry/ui/checkbox-group.json +13 -0
- package/registry/ui/checkbox.json +16 -0
- package/registry/ui/color-area.json +13 -0
- package/registry/ui/color-field.json +20 -0
- package/registry/ui/color-picker.json +17 -0
- package/registry/ui/color-slider.json +13 -0
- package/registry/ui/color-swatch-picker.json +15 -0
- package/registry/ui/color-swatch.json +13 -0
- package/registry/ui/color-wheel.json +13 -0
- package/registry/ui/combobox.json +15 -0
- package/registry/ui/command.json +13 -0
- package/registry/ui/confirm.json +19 -0
- package/registry/ui/context-menu.json +16 -0
- package/registry/ui/date-field.json +19 -0
- package/registry/ui/date-picker.json +15 -0
- package/registry/ui/date-range-picker.json +16 -0
- package/registry/ui/description.json +13 -0
- package/registry/ui/dialog.json +19 -0
- package/registry/ui/disclosure.json +18 -0
- package/registry/ui/drawer.json +18 -0
- package/registry/ui/drop-indicator.json +13 -0
- package/registry/ui/drop-zone.json +13 -0
- package/registry/ui/empty.json +15 -0
- package/registry/ui/field-error.json +13 -0
- package/registry/ui/file-trigger.json +13 -0
- package/registry/ui/form.json +21 -0
- package/registry/ui/grid-list.json +18 -0
- package/registry/ui/group.json +13 -0
- package/registry/ui/header.json +13 -0
- package/registry/ui/heading-scope.json +20 -0
- package/registry/ui/heading.json +15 -0
- package/registry/ui/highlight.json +16 -0
- package/registry/ui/hover-card.json +13 -0
- package/registry/ui/image-placeholder.json +16 -0
- package/registry/ui/input.json +13 -0
- package/registry/ui/item.json +13 -0
- package/registry/ui/keyboard.json +13 -0
- package/registry/ui/label.json +13 -0
- package/registry/ui/link-button.json +16 -0
- package/registry/ui/link.json +13 -0
- package/registry/ui/listbox.json +15 -0
- package/registry/ui/logo.json +15 -0
- package/registry/ui/marker.json +13 -0
- package/registry/ui/menu.json +19 -0
- package/registry/ui/menubar.json +13 -0
- package/registry/ui/message-scroller.json +16 -0
- package/registry/ui/message.json +13 -0
- package/registry/ui/meter.json +13 -0
- package/registry/ui/modal.json +15 -0
- package/registry/ui/nav-link.json +13 -0
- package/registry/ui/navigation-menu.json +15 -0
- package/registry/ui/number-field.json +15 -0
- package/registry/ui/otp-field.json +15 -0
- package/registry/ui/overlay-arrow.json +13 -0
- package/registry/ui/pagination.json +16 -0
- package/registry/ui/popover.json +13 -0
- package/registry/ui/progress-bar.json +13 -0
- package/registry/ui/radio-group.json +13 -0
- package/registry/ui/range-calendar.json +16 -0
- package/registry/ui/resizable.json +13 -0
- package/registry/ui/scroll-area.json +13 -0
- package/registry/ui/search-field.json +16 -0
- package/registry/ui/section.json +13 -0
- package/registry/ui/select.json +13 -0
- package/registry/ui/selection-indicator.json +13 -0
- package/registry/ui/sentinel-row.json +16 -0
- package/registry/ui/separator.json +13 -0
- package/registry/ui/shared-element.json +13 -0
- package/registry/ui/sheet.json +15 -0
- package/registry/ui/shortcut-list.json +18 -0
- package/registry/ui/sidebar.json +20 -0
- package/registry/ui/skeleton.json +13 -0
- package/registry/ui/slider.json +16 -0
- package/registry/ui/spinner.json +13 -0
- package/registry/ui/switch.json +16 -0
- package/registry/ui/table.json +16 -0
- package/registry/ui/tabs.json +17 -0
- package/registry/ui/tag-group.json +18 -0
- package/registry/ui/text-field.json +19 -0
- package/registry/ui/text.json +13 -0
- package/registry/ui/textarea.json +13 -0
- package/registry/ui/time-field.json +19 -0
- package/registry/ui/toast.json +16 -0
- package/registry/ui/toggle-button.json +17 -0
- package/registry/ui/toolbar.json +13 -0
- package/registry/ui/tooltip.json +16 -0
- package/registry/ui/tree.json +18 -0
- package/registry/ui/typeset.json +16 -0
- package/registry/ui/youtube-embed.json +16 -0
- package/stubs/command.stub +12 -0
- package/stubs/command.test.stub +18 -0
- package/stubs/controller.form.stub +33 -0
- package/stubs/controller.stub +17 -0
- package/stubs/controller.test.stub +15 -0
- package/stubs/email.stub +44 -0
- package/stubs/email.test.stub +16 -0
- package/stubs/factory.stub +10 -0
- package/stubs/initializer.stub +7 -0
- package/stubs/initializer.test.stub +13 -0
- package/stubs/job.cron.stub +12 -0
- package/stubs/job.stub +11 -0
- package/stubs/job.test.stub +15 -0
- package/stubs/mcp.resource.stub +12 -0
- package/stubs/mcp.stub +10 -0
- package/stubs/mcp.test.stub +15 -0
- package/stubs/middleware.stub +11 -0
- package/stubs/middleware.test.stub +13 -0
- package/stubs/migration.stub +1 -0
- package/stubs/model.stub +24 -0
- package/stubs/model.test.stub +15 -0
- package/stubs/policy.stub +13 -0
- package/stubs/policy.test.stub +17 -0
- package/stubs/service.stub +13 -0
- package/stubs/service.test.stub +14 -0
- package/stubs/validator.stub +14 -0
- package/stubs/validator.test.stub +22 -0
- package/templates/app/README.md +57 -0
- package/templates/app/app/commands/about.test.ts +29 -0
- package/templates/app/app/commands/about.ts +34 -0
- package/templates/app/app/commands/index.ts +15 -0
- package/templates/app/app/http/controllers/home.tsx +22 -0
- package/templates/app/app/http/controllers/not-found.tsx +25 -0
- package/templates/app/app/initializers/assets.ts +11 -0
- package/templates/app/app/initializers/cli.ts +35 -0
- package/templates/app/app/initializers/dispatcher.ts +18 -0
- package/templates/app/app/initializers/logger.ts +10 -0
- package/templates/app/app/initializers/mcp.ts +16 -0
- package/templates/app/app/initializers/router.tsx +65 -0
- package/templates/app/app/jobs/index.ts +10 -0
- package/templates/app/app/mcp/resources/index.ts +9 -0
- package/templates/app/app/mcp/tools/index.ts +10 -0
- package/templates/app/bootstrap/browser.ts +27 -0
- package/templates/app/bootstrap/cli.ts +9 -0
- package/templates/app/bootstrap/worker.ts +31 -0
- package/templates/app/cloudflare.config.ts +28 -0
- package/templates/app/config/router-context.d.ts +20 -0
- package/templates/app/gitignore +9 -0
- package/templates/app/package.json +38 -0
- package/templates/app/resources/layouts/document.tsx +58 -0
- package/templates/app/routes/web.ts +12 -0
- package/templates/app/tsconfig.json +40 -0
- package/templates/app/vite.config.ts +40 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "attachment",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"button"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"Attachment"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "attachment.tsx",
|
|
12
|
+
"content": "/**\n * A compound card presenting one attached file or image — media preview, name,\n * supporting details, actions — plus a horizontally scrolling row for several\n * cards side by side. Every part styles itself off the card's own `state`, and\n * whole-card click-through stays an opt-in wrapper a consumer mixes in.\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 { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, transition } from \"@sdxc/u/effects\";\nimport { raw } from \"@sdxc/u/general\";\nimport {\n\tbasis,\n\tblock,\n\tcontainer,\n\tflex,\n\tflexCol,\n\tgap,\n\tgrow,\n\thstack,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n\tvstack,\n} from \"@sdxc/u/layout\";\nimport { overflow, overflowX } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { aspect, bs, fit, is, minIs, p } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { text, textAlign, truncate, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { shimmer } from \"@sdxc/ui/animations\";\nimport { scrollFade } from \"@sdxc/ui/animations\";\n\nimport { Button } from \"@sdxc/ui/button\";\n\nconst DEFAULT_STATE: Attachment.State = \"idle\";\n\n/**\n * Named container {@link Attachment} declares on its own host, so\n * {@link Attachment.Media}, {@link Attachment.Content}, and the inner layout\n * wrapper resolve their width queries against the card itself.\n */\nconst CONTAINER_NAME = \"ui-attachment\";\n\n/**\n * `@container` query every width-adapting part below the root shares: at or\n * under this width the card reflows into a taller tile, the shape\n * {@link Attachment.Group}'s narrow, fixed-width cards need.\n */\nconst NARROW_CONTAINER_QUERY = `@container ${CONTAINER_NAME} (max-width: 12rem)`;\n\n/**\n * Selector fragment gating {@link Attachment.Title}'s shimmer: it matches the\n * title's own `data-state` attribute while that reads `\"uploading\"` or\n * `\"processing\"`, so a title in any other state renders as plain text.\n */\nconst TITLE_SHIMMER_WHEN = ':is([data-state=\"uploading\"], [data-state=\"processing\"])';\n\nconst DEFAULT_ACTION_VARIANT: Button.Variant = \"ghost\";\n\nconst DEFAULT_ACTION_SIZE: Button.Size = \"sm\";\n\nconst DEFAULT_ACTION_COLOR: Button.Color = \"neutral\";\n\n/**\n * Tab-stop order {@link attrs} applies to {@link Attachment.Group} when a\n * consumer supplies no `tabIndex`, so the row itself stays keyboard-reachable\n * and scrollable whatever its cards contain.\n */\nconst DEFAULT_GROUP_TAB_INDEX = 0;\n\nconst GROUP_SCROLL_FADE_SIZE = \"2rem\";\n\n/**\n * Prop types for {@link Attachment} and its compound parts.\n */\nexport namespace Attachment {\n\t/**\n\t * Lifecycle state of a card's file or image. `\"idle\"` and `\"done\"` both\n\t * render as a settled card — `\"idle\"` for a file already on the server,\n\t * `\"done\"` for one whose transfer finished. A consumer owns every transition.\n\t */\n\texport type State = \"idle\" | \"uploading\" | \"processing\" | \"error\" | \"done\";\n\n\t/**\n\t * Props accepted by {@link Attachment}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Lifecycle state of the file or image the card represents. Defaults to `\"idle\"`. */\n\t\tstate?: State;\n\t\t/** The card's compound parts: {@link Attachment.Media}, {@link Attachment.Content}, and {@link Attachment.Actions}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Attachment.Media}.\n\t */\n\texport interface MediaProps extends TagProps<\"div\"> {\n\t\t/** The preview itself: an `<img>`, or a decorative icon standing in for the file's type. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Attachment.Content}.\n\t */\n\texport interface ContentProps extends TagProps<\"div\"> {\n\t\t/** {@link Attachment.Title} and, optionally, {@link Attachment.Description}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Attachment.Title}.\n\t */\n\texport interface TitleProps extends TagProps<\"p\"> {\n\t\t/**\n\t\t * The ancestor {@link Attachment}'s own `state`, repeated here because a\n\t\t * component reads only its own props; passing the same value to both is\n\t\t * what keeps them in sync. Left unset, the title renders plain.\n\t\t */\n\t\tstate?: Attachment.State;\n\t\t/** The file or image name. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Attachment.Description}.\n\t */\n\texport interface DescriptionProps extends TagProps<\"p\"> {\n\t\t/** Supporting detail — a file size, a page count, an error message. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Attachment.Actions}.\n\t */\n\texport interface ActionsProps extends TagProps<\"div\"> {\n\t\t/** A run of {@link Attachment.Action} controls. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Attachment.Action}: every {@link Button.Props}\n\t * field, unchanged, so an action keeps the same color, weight, and size\n\t * contract as every other button in the catalog.\n\t */\n\texport interface ActionProps extends Button.Props {}\n\n\t/**\n\t * Props accepted by {@link Attachment.Trigger}.\n\t */\n\texport interface TriggerProps extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Destination the whole card follows once `attachmentTrigger()` is mixed\n\t\t * in, opened in place unless the activation asks for a new tab. It rides on\n\t\t * a `<div>` so a nested {@link Attachment.Action} stays valid markup.\n\t\t */\n\t\thref?: string;\n\t\t/**\n\t\t * `id` of a `<dialog>` element the whole card opens once\n\t\t * `attachmentTrigger()` is mixed in, instead of following `href`.\n\t\t */\n\t\tcommandfor?: string;\n\t\t/** Invoker Commands verb dispatched to `commandfor`'s dialog. Defaults to `\"show-modal\"`. */\n\t\tcommand?: \"show-modal\";\n\t\t/** Where `href` opens: a window/frame name, or `\"_blank\"` for a new tab. Meaningful only alongside `href`. */\n\t\ttarget?: string;\n\t\t/** The card's own markup — typically an {@link Attachment}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Attachment.Group}.\n\t */\n\texport interface GroupProps extends TagProps<\"div\"> {\n\t\t/** A run of {@link Attachment} or {@link Attachment.Trigger} cards. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * The card's outer host, recolored to the danger tint at `state=\"error\"` and\n * declaring the `ui-attachment` named container so nested parts reflow at the\n * card's width. A busy state sets `aria-busy` to the token ARIA recognizes.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the card's markup.\n * @example\n * <Attachment state=\"uploading\">\n * \t<Attachment.Media><FileIcon aria-hidden /></Attachment.Media>\n * \t<Attachment.Content>\n * \t\t<Attachment.Title state=\"uploading\">quarterly-report.pdf</Attachment.Title>\n * \t\t<Attachment.Description>{t(\"attachment.uploading\")}</Attachment.Description>\n * \t</Attachment.Content>\n * </Attachment>\n * @example\n * <Attachment state=\"error\">\n * \t<Attachment.Media><FileIcon aria-hidden /></Attachment.Media>\n * \t<Attachment.Content>\n * \t\t<Attachment.Title>quarterly-report.pdf</Attachment.Title>\n * \t\t<Attachment.Description>{t(\"attachment.uploadFailed\")}</Attachment.Description>\n * \t</Attachment.Content>\n * \t<Attachment.Actions>\n * \t\t<Attachment.Action aria-label={t(\"attachment.retry\")}><RotateCwIcon /></Attachment.Action>\n * \t</Attachment.Actions>\n * </Attachment>\n */\nexport function Attachment(handle: Handle<Attachment.Props>) {\n\treturn () => {\n\t\tlet { state, children, mix, ...rest } = handle.props;\n\t\tlet resolvedState = state ?? DEFAULT_STATE;\n\t\tlet isBusy = resolvedState === \"uploading\" || resolvedState === \"processing\";\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"attachment\"\n\t\t\t\tdata-state={resolvedState}\n\t\t\t\taria-busy={isBusy ? \"true\" : undefined}\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\tborder({ width: 1 }),\n\t\t\t\t\tborder(\"neutral\"),\n\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tp(3),\n\t\t\t\t\ttransition(\"border-color, background-color\"),\n\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\twhen('&[data-state=\"error\"]', [\n\t\t\t\t\t\tborder(\"danger\"),\n\t\t\t\t\t\tbg(\"danger.tint\"),\n\t\t\t\t\t\tfg(\"danger.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<div\n\t\t\t\t\tdata-slot=\"body\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\thstack({ gap: 3, align: \"center\" }),\n\t\t\t\t\t\twhen(NARROW_CONTAINER_QUERY, [flexCol(), items(\"stretch\")]),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t};\n}\n\n/**\n * The card's media well: a fixed-size, rounded box clipping the preview a\n * consumer nests inside. Inside a narrow container it grows to the card's own\n * inline size at a wider aspect ratio, reading as a thumbnail tile.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the media well's markup.\n * @example\n * <Attachment.Media><img src={file.thumbnailUrl} alt=\"\" /></Attachment.Media>\n * @example\n * <Attachment.Media><FileTextIcon aria-hidden /></Attachment.Media>\n */\nAttachment.Media = function AttachmentMedia(handle: Handle<Attachment.MediaProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"media\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tshrink(0),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\toverflow(),\n\t\t\t\t\tis(10),\n\t\t\t\t\tbs(10),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\twhen(\"& > svg\", [is(5), bs(5)]),\n\t\t\t\t\twhen(\"& > img\", [is(\"full\"), bs(\"full\"), fit(\"cover\")]),\n\t\t\t\t\twhen(NARROW_CONTAINER_QUERY, [is(\"full\"), bs(\"auto\"), aspect(4, 3), rounded(\"lg\")]),\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\n/**\n * The card's text column, growing into whatever inline space\n * {@link Attachment.Media} and {@link Attachment.Actions} leave it. Its minimum\n * inline size collapses to `0`, which is what lets its children truncate.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the text column's markup.\n * @example\n * <Attachment.Content>\n * \t<Attachment.Title>quarterly-report.pdf</Attachment.Title>\n * \t<Attachment.Description>2.4 MB</Attachment.Description>\n * </Attachment.Content>\n */\nAttachment.Content = function AttachmentContent(handle: Handle<Attachment.ContentProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"content\"\n\t\t\t\tmix={[\n\t\t\t\t\tvstack({ gap: 0.5 }),\n\t\t\t\t\tminIs(0),\n\t\t\t\t\tgrow(),\n\t\t\t\t\tshrink(1),\n\t\t\t\t\tbasis(\"0%\"),\n\t\t\t\t\twhen(NARROW_CONTAINER_QUERY, textAlign(\"center\")),\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\n/**\n * The file or image name in a native `<p>`, truncated to a single line with an\n * ellipsis. Given the same `state` as the ancestor {@link Attachment}, it\n * shimmers while that reads `\"uploading\"` or `\"processing\"`, then settles.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the title's markup.\n * @example\n * <Attachment.Title>quarterly-report.pdf</Attachment.Title>\n * @example\n * <Attachment.Title state={attachment.state}>{attachment.name}</Attachment.Title>\n */\nAttachment.Title = function AttachmentTitle(handle: Handle<Attachment.TitleProps>) {\n\treturn () => {\n\t\tlet { state, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<p\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"title\"\n\t\t\t\tdata-state={state}\n\t\t\t\tmix={[\n\t\t\t\t\tweight(\"semibold\"),\n\t\t\t\t\ttruncate(),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * The loop settles visible, because this host carries the file's name: a gated\n\t\t\t\t\t * loop rests hidden outside its gate, which suits an element that exists only\n\t\t\t\t\t * as a loading cue and would leave every finished upload unnamed.\n\t\t\t\t\t */\n\t\t\t\t\tshimmer({ when: TITLE_SHIMMER_WHEN, outsideGate: \"visible\" }),\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</p>\n\t\t);\n\t};\n};\n\n/**\n * The card's supporting detail line: a muted, single-line `<p>` carrying a file\n * size, a page count, or the explanation of what went wrong once the ancestor\n * {@link Attachment}'s `state` reads `\"error\"`.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the description's markup.\n * @example\n * <Attachment.Description>2.4 MB</Attachment.Description>\n * @example\n * <Attachment.Description>{t(\"attachment.uploadFailed\")}</Attachment.Description>\n */\nAttachment.Description = function AttachmentDescription(\n\thandle: Handle<Attachment.DescriptionProps>,\n) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<p {...rest} data-slot=\"description\" mix={[truncate(), fg(\"neutral.muted\"), text(\"xs\"), mix]}>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t);\n\t};\n};\n\n/**\n * The card's action row, shrink-proof so a narrow card's width is absorbed by\n * {@link Attachment.Content}'s own truncation while the actions keep their\n * size.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the action row's markup.\n * @example\n * <Attachment.Actions>\n * \t<Attachment.Action aria-label={t(\"attachment.download\")}><DownloadIcon /></Attachment.Action>\n * \t<Attachment.Action aria-label={t(\"attachment.remove\")}><XIcon /></Attachment.Action>\n * </Attachment.Actions>\n */\nAttachment.Actions = function AttachmentActions(handle: Handle<Attachment.ActionsProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div {...rest} data-slot=\"actions\" mix={[flex(), shrink(0), items(\"center\"), gap(1), mix]}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * A single card action as a {@link Button}, defaulting to a compact, `\"ghost\"`,\n * neutral control so a row of actions reads as secondary to the card's title.\n * Every {@link Button} prop stays available, `type` included.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the action's markup.\n * @example\n * <Attachment.Action aria-label={t(\"attachment.download\")}>\n * \t<DownloadIcon />\n * </Attachment.Action>\n * @example\n * <Attachment.Action type=\"submit\" name=\"intent\" value=\"retry\" aria-label={t(\"attachment.retry\")}>\n * \t<RotateCwIcon />\n * </Attachment.Action>\n */\nAttachment.Action = function AttachmentAction(handle: Handle<Attachment.ActionProps>) {\n\treturn () => {\n\t\tlet { color, variant, size, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tcolor={color ?? DEFAULT_ACTION_COLOR}\n\t\t\t\tvariant={variant ?? DEFAULT_ACTION_VARIANT}\n\t\t\t\tsize={size ?? DEFAULT_ACTION_SIZE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"action\"\n\t\t\t\tmix={[shrink(0), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A wrapper `<div>` whose `href` or `commandfor` stays an inert attribute until\n * a consumer mixes in `attachmentTrigger()`. Either one also derives a `role`\n * and `tabIndex`, so whole-card activation is announced and keyboard-reachable.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the wrapper's markup.\n * @example\n * <Attachment.Trigger href=\"/files/quarterly-report.pdf\" mix={attachmentTrigger()}>\n * \t<Attachment state=\"done\">\n * \t\t<Attachment.Media><FileTextIcon aria-hidden /></Attachment.Media>\n * \t\t<Attachment.Content>\n * \t\t\t<Attachment.Title>quarterly-report.pdf</Attachment.Title>\n * \t\t</Attachment.Content>\n * \t\t<Attachment.Actions>\n * \t\t\t<Attachment.Action aria-label={t(\"attachment.download\")}><DownloadIcon /></Attachment.Action>\n * \t\t</Attachment.Actions>\n * \t</Attachment>\n * </Attachment.Trigger>\n * @example\n * <Attachment.Trigger commandfor=\"quarterly-report-preview\" mix={attachmentTrigger()}>\n * \t<Attachment state=\"done\">…</Attachment>\n * </Attachment.Trigger>\n * <Dialog id=\"quarterly-report-preview\">…</Dialog>\n */\nAttachment.Trigger = function AttachmentTrigger(handle: Handle<Attachment.TriggerProps>) {\n\treturn () => {\n\t\tlet { href, commandfor, command, target, role, tabIndex, children, mix, ...rest } =\n\t\t\thandle.props;\n\t\tlet isConfigured = href !== undefined || commandfor !== undefined;\n\t\tlet resolvedRole = role ?? (href !== undefined ? \"link\" : isConfigured ? \"button\" : undefined);\n\t\tlet resolvedTabIndex = tabIndex ?? (isConfigured ? 0 : undefined);\n\n\t\tif (import.meta.env.DEV && !isConfigured) {\n\t\t\tconsole.warn(\n\t\t\t\t'Attachment.Trigger: rendered with neither \"href\" nor \"commandfor\" — nothing will happen once `attachmentTrigger()` handles an activation.',\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\trole={resolvedRole}\n\t\t\t\ttabIndex={resolvedTabIndex}\n\t\t\t\tdata-slot=\"trigger\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ href, commandfor, command, target }),\n\t\t\t\t\trelative(),\n\t\t\t\t\tblock(),\n\t\t\t\t\trounded(\"inherit\"),\n\t\t\t\t\twhen(\"&[role]:hover\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\twhen(\"&[role]:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\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\n/**\n * A horizontally scroll-snapping row of cards, faded at both inline edges to\n * hint at cards beyond the current view. The row itself carries the tab stop,\n * since the row is what scrolls.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Attachment.Group aria-label={t(\"thread.attachments\")}>\n * \t{attachments.map((attachment) => (\n * \t\t<Attachment key={attachment.id} state={attachment.state}>…</Attachment>\n * \t))}\n * </Attachment.Group>\n */\nAttachment.Group = function AttachmentGroup(handle: Handle<Attachment.GroupProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"group\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ tabIndex: DEFAULT_GROUP_TAB_INDEX }),\n\t\t\t\t\tflex(),\n\t\t\t\t\tgap(3),\n\t\t\t\t\toverflowX(\"auto\"),\n\t\t\t\t\traw({\n\t\t\t\t\t\toverscrollBehaviorInline: \"contain\",\n\t\t\t\t\t\tscrollSnapType: \"inline mandatory\",\n\t\t\t\t\t\tscrollPaddingInline: \"0.75rem\",\n\t\t\t\t\t\tscrollBehavior: \"auto\",\n\t\t\t\t\t}),\n\t\t\t\t\twhen(\"& > *\", [shrink(0), raw({ scrollSnapAlign: \"start\" })]),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: no-preference)\", raw({ scrollBehavior: \"smooth\" })),\n\t\t\t\t\tscrollFade({ axis: \"inline\", size: GROUP_SCROLL_FADE_SIZE }),\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"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "avatar",
|
|
3
|
+
"changedIn": "2026.10.2",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"image-placeholder"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"Avatar"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "avatar.tsx",
|
|
12
|
+
"content": "/**\n * A person's or entity's picture rendered as a fixed-size, fully circular\n * host stacking an image layer, an initials fallback, and an optional corner\n * status badge, plus a way to overlap several instances into one group with\n * a trailing overflow count. The circular shape stays fixed, since a profile\n * picture always renders fully rounded.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { ImagePlaceholder } from \"@sdxc/ui/image-placeholder\";\n\n/**\n * Prop types for {@link Avatar} and its compound parts. Each part aliases\n * {@link ImagePlaceholder}'s matching part, since {@link Avatar} renders\n * straight through to it with the shape fixed to a full circle.\n */\nexport namespace Avatar {\n\t/**\n\t * Size variant controlling the host's rendered dimensions and, through\n\t * ordinary inheritance, the fallback initials' font size. Re-exports\n\t * {@link ImagePlaceholder.Size}.\n\t */\n\texport type Size = ImagePlaceholder.Size;\n\n\t/**\n\t * Props accepted by {@link Avatar}: every prop {@link ImagePlaceholder.Props}\n\t * accepts except `shape`, which stays fixed to a full circle.\n\t */\n\texport interface Props extends Omit<ImagePlaceholder.Props, \"shape\"> {}\n\n\t/**\n\t * Props accepted by {@link Avatar.Image}, unchanged from\n\t * {@link ImagePlaceholder.ImageProps}.\n\t */\n\texport interface ImageProps extends ImagePlaceholder.ImageProps {}\n\n\t/**\n\t * Props accepted by {@link Avatar.Fallback}, unchanged from\n\t * {@link ImagePlaceholder.FallbackProps}.\n\t */\n\texport interface FallbackProps extends ImagePlaceholder.FallbackProps {}\n\n\t/**\n\t * Props accepted by {@link Avatar.Badge}, unchanged from\n\t * {@link ImagePlaceholder.BadgeProps}.\n\t */\n\texport interface BadgeProps extends ImagePlaceholder.BadgeProps {}\n\n\t/**\n\t * Props accepted by {@link Avatar.Group}, unchanged from\n\t * {@link ImagePlaceholder.GroupProps}.\n\t */\n\texport interface GroupProps extends ImagePlaceholder.GroupProps {}\n\n\t/**\n\t * Props accepted by {@link Avatar.Group.Count}: every prop\n\t * {@link ImagePlaceholder.GroupCountProps} accepts except `shape`, which\n\t * stays fixed to the same full circle the avatars it trails render with.\n\t */\n\texport interface GroupCountProps extends Omit<ImagePlaceholder.GroupCountProps, \"shape\"> {}\n}\n\n/**\n * Renders a fixed-size, fully circular picture host sized through the\n * `data-size` attribute contract (`\"sm\"`, `\"md\"`, or `\"lg\"`), stacking\n * whichever image, fallback, and badge parts a consumer composes as children.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the picture host's markup.\n * @example\n * <Avatar>\n * \t<Avatar.Image src={user.avatarUrl} alt={user.name} />\n * \t<Avatar.Fallback>{initials}</Avatar.Fallback>\n * </Avatar>\n * @example\n * <Avatar size=\"lg\">\n * \t<Avatar.Image src={user.avatarUrl} alt={user.name} />\n * \t<Avatar.Fallback>{initials}</Avatar.Fallback>\n * \t<Avatar.Badge aria-label={t(\"status.online\")} />\n * </Avatar>\n */\nexport function Avatar(handle: Handle<Avatar.Props>) {\n\treturn () => <ImagePlaceholder {...handle.props} shape=\"circle\" />;\n}\n\n/**\n * Renders the avatar's image layer: an absolutely positioned `<img>` filling\n * the host edge to edge, cropped with `object-fit: cover` and clipped to\n * {@link Avatar}'s circular shape. Stacking order decides which layer shows.\n *\n * @param handle Runtime handle carrying the host `<img>`'s props.\n * @returns The render function producing the image layer's markup.\n * @example\n * <Avatar.Image src={user.avatarUrl} alt={user.name} />\n */\nAvatar.Image = ImagePlaceholder.Image;\n\n/**\n * Renders the avatar's fallback layer: an absolutely positioned `<span>`\n * centering its content (typically initials) in uppercase, medium-weight\n * text whose size inherits from the host, staying in proportion at any size.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the fallback layer's markup.\n * @example\n * <Avatar.Fallback>{initials}</Avatar.Fallback>\n */\nAvatar.Fallback = ImagePlaceholder.Fallback;\n\n/**\n * Renders a small status dot pinned to the host's block-end/inline-end\n * corner: always fully rounded and ringed with a border matching the\n * surrounding background, so it reads as cut out from what sits beneath it.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the badge's markup.\n * @example\n * <Avatar.Badge aria-label={t(\"status.online\")} />\n */\nAvatar.Badge = ImagePlaceholder.Badge;\n\n/**\n * Renders {@link Avatar.GroupProps.children} as a row of overlapping\n * avatars, pulling every child but the first back over its predecessor and\n * ringing it, so the overlap reads as stacked cutouts.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <Avatar.Group>\n * \t<Avatar>…</Avatar>\n * \t<Avatar>…</Avatar>\n * \t<Avatar.Group.Count>+3</Avatar.Group.Count>\n * </Avatar.Group>\n */\nfunction AvatarGroup(handle: Handle<Avatar.GroupProps>) {\n\treturn () => <ImagePlaceholder.Group {...handle.props} />;\n}\n\n/**\n * Renders the \"+N\" overflow indicator that trails {@link Avatar.Group}: a\n * fixed medium-size box matching {@link Avatar}'s default dimensions, ringed\n * the same way a grouped avatar is and fixed to the same full circle.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the overflow indicator's markup.\n * @example\n * <Avatar.Group.Count>+3</Avatar.Group.Count>\n */\nfunction AvatarGroupCount(handle: Handle<Avatar.GroupCountProps>) {\n\treturn () => <ImagePlaceholder.GroupCount {...handle.props} shape=\"circle\" />;\n}\n\nAvatarGroup.Count = AvatarGroupCount;\nAvatar.Group = AvatarGroup;\n"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "badge",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Badge"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "badge.tsx",
|
|
10
|
+
"content": "/**\n * A compact pill communicating a short status, label, or count inline with\n * surrounding content. Its host renders solid, tinted, or outlined depending\n * on a variant attribute, colored through a semantic color role, and\n * composes with `Icon` and `Text` parts for glyph-plus-label badges.\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 } from \"@sdxc/u/effects\";\nimport { userSelect } from \"@sdxc/u/general\";\nimport { gap, inlineFlex, items, shrink } from \"@sdxc/u/layout\";\nimport { bs, is, pb, pi } from \"@sdxc/u/size\";\nimport { data, when } from \"@sdxc/u/state\";\nimport { fontSize, leading, nowrap, tabularNums, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { DEFAULT_ICON_ARIA_HIDDEN } from \"@sdxc/ui/utils\";\n\n/** Semantic color role {@link Badge} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Badge.Color = \"neutral\";\n\n/** Visual weight {@link Badge} falls back to when `variant` is omitted. */\nconst DEFAULT_VARIANT: Badge.Variant = \"default\";\n\n/**\n * Prop types for {@link Badge} and its compound parts.\n */\nexport namespace Badge {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Visual weight the badge renders with: a solid fill, a tinted fill, or\n\t * a transparent chip with just an outline.\n\t */\n\texport type Variant = \"default\" | \"secondary\" | \"outline\";\n\n\t/**\n\t * Props accepted by {@link Badge}.\n\t */\n\texport interface Props extends TagProps<\"span\"> {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t}\n\n\t/**\n\t * Props accepted by {@link Badge.Icon}.\n\t */\n\texport interface IconProps extends TagProps<\"span\"> {}\n\n\t/**\n\t * Props accepted by {@link Badge.Text}.\n\t */\n\texport interface TextProps extends TagProps<\"span\"> {}\n}\n\n/**\n * Renders a single-line pill host, colored and shaped through the\n * `data-color` and `data-variant` attribute contract: `\"default\"` fills the\n * pill solid, `\"secondary\"` tints the fill, `\"outline\"` keeps just a border.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the badge's markup.\n * @example\n * <Badge>{t(\"badge.new\")}</Badge>\n * @example\n * <Badge color=\"success\" variant=\"secondary\">\n * \t<Badge.Icon><CheckIcon /></Badge.Icon>\n * \t<Badge.Text>{t(\"badge.active\")}</Badge.Text>\n * </Badge>\n * @example\n * <Badge color=\"danger\" variant=\"outline\">{t(\"badge.failed\")}</Badge>\n */\nexport function Badge(handle: Handle<Badge.Props>) {\n\treturn () => {\n\t\tlet { color, variant, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(1),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tborder({ width: 1 }),\n\t\t\t\t\tpi(2.5),\n\t\t\t\t\tpb(0.5),\n\t\t\t\t\tleading(1),\n\t\t\t\t\tweight(\"semibold\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\tnowrap(),\n\t\t\t\t\ttransition(\n\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t),\n\t\t\t\t\tfontSize(\"xs\"),\n\t\t\t\t\tuserSelect(),\n\t\t\t\t\tdata(\"variant\", \"default\", [\n\t\t\t\t\t\tdata(\"color\", \"brand\", [bg(\"brand.solid\"), fg(\"brand.onSolid\"), border(\"brand.solid\")]),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\t\tbg(\"neutral.solid\"),\n\t\t\t\t\t\t\tfg(\"neutral.onSolid\"),\n\t\t\t\t\t\t\tborder(\"neutral.solid\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\t\tbg(\"success.solid\"),\n\t\t\t\t\t\t\tfg(\"success.onSolid\"),\n\t\t\t\t\t\t\tborder(\"success.solid\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\t\tbg(\"warning.solid\"),\n\t\t\t\t\t\t\tfg(\"warning.onSolid\"),\n\t\t\t\t\t\t\tborder(\"warning.solid\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"danger\", [\n\t\t\t\t\t\t\tbg(\"danger.solid\"),\n\t\t\t\t\t\t\tfg(\"danger.onSolid\"),\n\t\t\t\t\t\t\tborder(\"danger.solid\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"secondary\", [\n\t\t\t\t\t\tdata(\"color\", \"brand\", [bg(\"brand.tint\"), fg(\"brand\"), border(\"brand\")]),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", [bg(\"neutral.tint\"), fg(\"neutral\"), border(\"neutral\")]),\n\t\t\t\t\t\tdata(\"color\", \"success\", [bg(\"success.tint\"), fg(\"success\"), border(\"success\")]),\n\t\t\t\t\t\tdata(\"color\", \"warning\", [bg(\"warning.tint\"), fg(\"warning\"), border(\"warning\")]),\n\t\t\t\t\t\tdata(\"color\", \"danger\", [bg(\"danger.tint\"), fg(\"danger\"), border(\"danger\")]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"outline\", [\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tdata(\"color\", \"brand\", [border(\"brand.strong\"), fg(\"brand\")]),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", [border(\"neutral\"), fg(\"neutral\")]),\n\t\t\t\t\t\tdata(\"color\", \"success\", [border(\"success.strong\"), fg(\"success\")]),\n\t\t\t\t\t\tdata(\"color\", \"warning\", [border(\"warning.strong\"), fg(\"warning\")]),\n\t\t\t\t\t\tdata(\"color\", \"danger\", [border(\"danger.strong\"), fg(\"danger\")]),\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 badge's leading or trailing glyph slot: an inert, shrink-proof\n * `<span>` sized to hold a single small icon and hidden from assistive\n * technology, since {@link Badge.Text} carries the badge's meaning.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the icon slot's markup.\n * @example\n * <Badge.Icon><CheckIcon /></Badge.Icon>\n */\nBadge.Icon = function BadgeIcon(handle: Handle<Badge.IconProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ICON_ARIA_HIDDEN }),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\tshrink(0),\n\t\t\t\t\twhen(\"& > svg\", [is(3), bs(3), shrink(0), fg(\"currentColor\")]),\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 badge's label slot: a `<span>` with its line height collapsed\n * to one, keeping short label text vertically centered inside the pill.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the label slot's markup.\n * @example\n * <Badge.Text>{t(\"badge.active\")}</Badge.Text>\n */\nBadge.Text = function BadgeText(handle: Handle<Badge.TextProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <span {...rest} mix={[leading(1), mix]} />;\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "breadcrumbs",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"link"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"Breadcrumbs"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "breadcrumbs.tsx",
|
|
12
|
+
"content": "/**\n * A trail of links marking the page's position within a hierarchy of parent\n * sections, composing a `<nav>` root, an `<ol>` list, and `<li>` items around\n * {@link Breadcrumbs.Link}, a restyled {@link Link}. Every item but the last\n * draws its separator through a CSS `::after` pseudo-element, keeping it\n * purely presentational, and the trail's current segment reads straight from\n * the native `aria-current` attribute a consumer sets while rendering the\n * page it currently occupies.\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 { fg } from \"@sdxc/u/color\";\nimport { listStyle, pseudoContent } from \"@sdxc/u/general\";\nimport { flex, items } from \"@sdxc/u/layout\";\nimport { m, mb, mis, p, pb, pi } from \"@sdxc/u/size\";\nimport { data, hover, when } from \"@sdxc/u/state\";\nimport { fontSize, textDecoration, weight } from \"@sdxc/u/typography\";\n\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\nimport { Link } from \"@sdxc/ui/link\";\n\n/** Semantic color role {@link Breadcrumbs.Link} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Link.Color = \"neutral\";\n\n/**\n * Prop types for {@link Breadcrumbs} and its compound parts.\n */\nexport namespace Breadcrumbs {\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 `<ol>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ListProps extends TagProps<\"ol\"> {}\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 * Every prop {@link Link.Props} accepts, unchanged. A type alias rather than\n\t * an interface, since {@link Link.Props} resolves through a conditional type\n\t * that an `interface extends` clause can't statically extend.\n\t */\n\texport type LinkProps = Link.Props;\n}\n\n/**\n * Renders the trail's `<nav>` root, laying {@link Breadcrumbs.List} as a row.\n * A root missing `aria-label` or `aria-labelledby` logs a dev-mode\n * `console.warn`, since assistive technology needs one to identify this landmark.\n *\n * @param handle Runtime handle carrying the host `<nav>`'s props.\n * @returns The render function producing the trail's markup.\n * @example\n * <Breadcrumbs aria-label={t(\"breadcrumbs.label\")}>\n * \t<Breadcrumbs.List>\n * \t\t<Breadcrumbs.Item>\n * \t\t\t<Breadcrumbs.Link href=\"/\">{t(\"nav.home\")}</Breadcrumbs.Link>\n * \t\t</Breadcrumbs.Item>\n * \t\t<Breadcrumbs.Item>\n * \t\t\t<Breadcrumbs.Link href=\"/projects\" aria-current=\"page\">\n * \t\t\t\t{t(\"nav.projects\")}\n * \t\t\t</Breadcrumbs.Link>\n * \t\t</Breadcrumbs.Item>\n * \t</Breadcrumbs.List>\n * </Breadcrumbs>\n */\nexport function Breadcrumbs(handle: Handle<Breadcrumbs.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Breadcrumbs: needs an \"aria-label\" or \"aria-labelledby\" identifying this navigation landmark for assistive technology.',\n\t\t);\n\n\t\treturn <nav {...rest} data-slot=\"breadcrumbs\" mix={[flex(), items(\"center\"), mix]} />;\n\t};\n}\n\n/**\n * Renders the trail's `<ol>` list, resetting native list markers and spacing\n * and laying {@link Breadcrumbs.Item} children out in a row whose spacing\n * comes from each {@link Breadcrumbs.Link}'s padding, so the gaps stay clickable.\n *\n * @param handle Runtime handle carrying the host `<ol>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Breadcrumbs.List>\n * \t<Breadcrumbs.Item>\n * \t\t<Breadcrumbs.Link href=\"/\">{t(\"nav.home\")}</Breadcrumbs.Link>\n * \t</Breadcrumbs.Item>\n * </Breadcrumbs.List>\n */\nBreadcrumbs.List = function BreadcrumbsList(handle: Handle<Breadcrumbs.ListProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ol\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"list\"\n\t\t\t\tmix={[flex(), items(\"center\"), 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 Breadcrumbs.Link}. Every item\n * but the last draws a `›` separator glyph via a CSS `::after`\n * pseudo-element, keeping the divider purely presentational.\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 * <Breadcrumbs.Item>\n * \t<Breadcrumbs.Link href=\"/projects\">{t(\"nav.projects\")}</Breadcrumbs.Link>\n * </Breadcrumbs.Item>\n */\nBreadcrumbs.Item = function BreadcrumbsItem(handle: Handle<Breadcrumbs.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"item\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\twhen(\"&:not(:last-child)::after\", [\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\t\tpseudoContent('\"›\"'),\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 trail segment as a restyled {@link Link}: sized to `0.875rem`\n * with its underline dropped, defaulting to a quiet neutral color role that\n * brightens on hover and bolds when `aria-current=\"page\"` is set.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the segment's markup.\n * @example\n * <Breadcrumbs.Link href=\"/settings\">{t(\"nav.settings\")}</Breadcrumbs.Link>\n * @example\n * <Breadcrumbs.Link href=\"/settings/profile\" aria-current=\"page\">\n * \t{t(\"nav.profile\")}\n * </Breadcrumbs.Link>\n * @example\n * <Breadcrumbs.Link aria-disabled=\"true\">{t(\"nav.archived\")}</Breadcrumbs.Link>\n */\nBreadcrumbs.Link = function BreadcrumbsLink(handle: Handle<Breadcrumbs.LinkProps>) {\n\treturn () => {\n\t\tlet { color, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<Link\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"link\"\n\t\t\t\tmix={[\n\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * The space around each separator lives in the link's own padding, so the\n\t\t\t\t\t * whole gap is clickable; the block padding reaches a 24px target and its\n\t\t\t\t\t * negative margin keeps the row at the text's height. The trail's first link\n\t\t\t\t\t * pulls back by its padding so the trail stays flush with its container.\n\t\t\t\t\t */\n\t\t\t\t\tpi(2),\n\t\t\t\t\tpb(0.5),\n\t\t\t\t\tmb(-0.5),\n\t\t\t\t\twhen('[data-slot=\"item\"]:first-child > &', mis(-2)),\n\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\thover(textDecoration(\"none\")),\n\t\t\t\t\tdata(\"color\", \"neutral\", [fg(\"neutral.muted\"), hover(fg(\"neutral\"))]),\n\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\tweight(\"medium\"),\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);\n\t};\n};\n"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bubble",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Bubble"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "bubble.tsx",
|
|
10
|
+
"content": "/**\n * The framed message surface inside a conversational row's content slot,\n * sized to its own content up to a share of the row's width. Variants cover\n * tones from a solid fill to fully unframed, and `align` hugs either row\n * edge. `Bubble.Content`, `Bubble.Reactions`, and `Bubble.Group` compose the\n * turn's text, its reaction toggles, and multi-bubble runs.\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 { bg, border, fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { raw, vars } from \"@sdxc/u/general\";\nimport { block, flex, flexWrap, gap, items, vstack } from \"@sdxc/u/layout\";\nimport { maxIs, mie, mis, pb, pbe, pi, width } from \"@sdxc/u/size\";\nimport { data, when } from \"@sdxc/u/state\";\nimport { pretty, wordBreak } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\n/** Selector matching every framed variant, the ones that hug their own text. */\nconst FRAMED = '&:not([data-variant=\"ghost\"])';\n\n/** Visual weight {@link Bubble} falls back to when `variant` is omitted. */\nconst DEFAULT_VARIANT: Bubble.Variant = \"default\";\n\n/** Edge of the row {@link Bubble} falls back to when `align` is omitted. */\nconst DEFAULT_ALIGN: Bubble.Align = \"start\";\n\n/**\n * ARIA role applied to {@link Bubble.Reactions} through {@link attrs},\n * announcing the row as one related set of pressed toggles.\n */\nconst DEFAULT_REACTIONS_ROLE = \"group\";\n\n/**\n * Prop types for {@link Bubble} and its compound parts.\n */\nexport namespace Bubble {\n\t/**\n\t * Visual weight the frame renders with: solid `\"default\"`/`\"secondary\"` fills,\n\t * soft `\"muted\"`/`\"tinted\"` tints, a bordered `\"outline\"`, an unframed\n\t * `\"ghost\"`, and a solid danger fill for `\"destructive\"`.\n\t */\n\texport type Variant =\n\t\t| \"default\"\n\t\t| \"secondary\"\n\t\t| \"muted\"\n\t\t| \"tinted\"\n\t\t| \"outline\"\n\t\t| \"ghost\"\n\t\t| \"destructive\";\n\n\t/**\n\t * Edge of the row the frame hugs: `\"start\"` stays flush with the row's\n\t * leading edge (flipping under `dir=\"rtl\"`), `\"end\"` stays flush with the\n\t * trailing edge, typically paired with the reader's own turns vs everyone else's.\n\t */\n\texport type Align = \"start\" | \"end\";\n\n\t/**\n\t * Props accepted by {@link Bubble}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Edge of the row the frame hugs. Defaults to {@link DEFAULT_ALIGN}. */\n\t\talign?: Align;\n\t\t/** The frame's compound parts: {@link Bubble.Content}, an optional {@link Bubble.Reactions}, or any other content. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Bubble.Content}.\n\t */\n\texport interface ContentProps extends TagProps<\"div\"> {\n\t\t/** The turn's text — plain, or wrapped in a typography layer for rendered markdown. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Bubble.Reactions}. `aria-label` is required so\n\t * assistive technology has an accessible name to announce for this row.\n\t */\n\texport interface ReactionsProps extends Omit<TagProps<\"div\">, \"aria-label\"> {\n\t\t/** Accessible label describing the row as a set of reactions. */\n\t\t\"aria-label\": string;\n\t\t/** One or more already-pressed toggle controls, each scoped to a single reaction. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Bubble.Group}.\n\t */\n\texport interface GroupProps extends TagProps<\"div\"> {\n\t\t/** Two or more {@link Bubble} frames from the same turn, stacked into one run. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the frame, pushed to the edge `align` names via auto margins so it\n * aligns correctly regardless of its row's layout. Its nearest corner falls\n * back to a literal `0.125rem`, since `roundedCorner()` has no `\"xs\"` step.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the frame's markup.\n * @example\n * <Bubble align=\"end\">\n * \t<Bubble.Content>{turn.text}</Bubble.Content>\n * </Bubble>\n * @example\n * <Bubble variant=\"muted\" align=\"start\">\n * \t<Bubble.Content>{turn.text}</Bubble.Content>\n * </Bubble>\n * @example\n * <Bubble variant=\"ghost\" align=\"start\">\n * \t<Bubble.Content>\n * \t\t<Typeset preset=\"chat\">{renderedMarkdownHtml}</Typeset>\n * \t</Bubble.Content>\n * </Bubble>\n */\nexport function Bubble(handle: Handle<Bubble.Props>) {\n\treturn () => {\n\t\tlet { variant, align, children, mix, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet resolvedAlign = align ?? DEFAULT_ALIGN;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"bubble\"\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-align={resolvedAlign}\n\t\t\t\tmix={[\n\t\t\t\t\tblock(),\n\t\t\t\t\trounded(\"xl\"),\n\t\t\t\t\tborder({ width: 1 }),\n\t\t\t\t\tborder(\"transparent\"),\n\n\t\t\t\t\twhen(FRAMED, [width(\"fit-content\"), maxIs(\"80%\")]),\n\t\t\t\t\twhen(`${FRAMED}[data-align=\"start\"]`, mie(\"auto\")),\n\t\t\t\t\twhen(`${FRAMED}[data-align=\"end\"]`, mis(\"auto\")),\n\n\t\t\t\t\tdata(\"align\", \"start\", [\n\t\t\t\t\t\traw({ borderEndStartRadius: \"var(--ui-radius-xs, 0.125rem)\" }),\n\t\t\t\t\t\tvars({ \"ui-bubble-reactions-justify\": \"flex-start\" }),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"align\", \"end\", [\n\t\t\t\t\t\traw({ borderEndEndRadius: \"var(--ui-radius-xs, 0.125rem)\" }),\n\t\t\t\t\t\tvars({ \"ui-bubble-reactions-justify\": \"flex-end\" }),\n\t\t\t\t\t]),\n\n\t\t\t\t\tdata(\"variant\", \"default\", [bg(\"brand.solid\"), fg(\"brand.onSolid\")]),\n\t\t\t\t\tdata(\"variant\", \"secondary\", [bg(\"neutral.solid\"), fg(\"neutral.onSolid\")]),\n\t\t\t\t\tdata(\"variant\", \"muted\", [bg(\"neutral.tint\"), fg(\"neutral.emphasis\"), border(\"neutral\")]),\n\t\t\t\t\tdata(\"variant\", \"tinted\", [bg(\"brand.tint\"), fg(\"brand.emphasis\"), border(\"brand\")]),\n\t\t\t\t\tdata(\"variant\", \"outline\", [\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\tborder(\"neutral.strong\"),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"ghost\", [\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tborder(\"transparent\"),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"destructive\", [bg(\"danger.solid\"), fg(\"danger.onSolid\")]),\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\n/**\n * Renders {@link Bubble.ContentProps.children} as the frame's padded text\n * slot, breaking long unbroken runs at the inline box edge and taking its\n * text color from the ancestor {@link Bubble}'s `variant` via CSS inheritance.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the text slot's markup.\n * @example\n * <Bubble.Content>{turn.text}</Bubble.Content>\n * @example\n * <Bubble.Content>\n * \t<p>{turn.summary}</p>\n * \t<Disclosure>\n * \t\t<Disclosure.Trigger>{t(\"message.showMore\")}</Disclosure.Trigger>\n * \t\t<Disclosure.Panel>{turn.rest}</Disclosure.Panel>\n * \t</Disclosure>\n * </Bubble.Content>\n * @example\n * <Bubble.Content>\n * \t{turn.text}\n * \t<button popovertarget={`${turn.id}-meta`} aria-label={t(\"message.details\")}>\n * \t\t<InfoIcon aria-hidden />\n * \t</button>\n * \t<Popover id={`${turn.id}-meta`} popover=\"hint\" placement=\"top-end\">\n * \t\t{t(\"message.model\", { model: turn.model })}\n * \t</Popover>\n * </Bubble.Content>\n */\nBubble.Content = function BubbleContent(handle: Handle<Bubble.ContentProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"content\"\n\t\t\t\tmix={[\n\t\t\t\t\tpb(2.5),\n\t\t\t\t\tpi(3.5),\n\t\t\t\t\traw({\n\t\t\t\t\t\tfontSize: \"0.9375rem\",\n\t\t\t\t\t\tlineHeight: \"1.5\",\n\t\t\t\t\t\toverflowWrap: \"break-word\",\n\t\t\t\t\t}),\n\t\t\t\t\twordBreak(\"break-word\"),\n\t\t\t\t\tpretty(),\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\n/**\n * Renders {@link Bubble.ReactionsProps.children} as a `role=\"group\"` row: a\n * negative block-start margin pins it into the frame's lower padding, aligned\n * via the `--ui-bubble-reactions-justify` property the frame sets from `align`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the reaction row's markup.\n * @example\n * <Bubble.Reactions aria-label={t(\"message.reactions\")}>\n * \t<ToggleButton\n * \t\taria-pressed={reactions.thumbsUp}\n * \t\taria-label={t(\"message.reactThumbsUp\")}\n * \t\tsize=\"sm\"\n * \t\tname=\"reaction\"\n * \t\tvalue=\"thumbs-up\"\n * \t>\n * \t\t👍\n * \t</ToggleButton>\n * \t<ToggleButton\n * \t\taria-pressed={reactions.heart}\n * \t\taria-label={t(\"message.reactHeart\")}\n * \t\tsize=\"sm\"\n * \t\tname=\"reaction\"\n * \t\tvalue=\"heart\"\n * \t>\n * \t\t❤️\n * \t</ToggleButton>\n * </Bubble.Reactions>\n */\nBubble.Reactions = function BubbleReactions(handle: Handle<Bubble.ReactionsProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"reactions\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_REACTIONS_ROLE }),\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexWrap(\"wrap\"),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(1),\n\t\t\t\t\t/**\n\t\t\t\t\t * The row sits on the line the turn's own text sits on and clears the frame's lower\n\t\t\t\t\t * edge, inset to match the content beside it, so the reactions stay clear of the\n\t\t\t\t\t * message's last line.\n\t\t\t\t\t */\n\t\t\t\t\tpi(3.5),\n\t\t\t\t\tpbe(2.5),\n\t\t\t\t\traw({ justifyContent: \"var(--ui-bubble-reactions-justify, flex-start)\" }),\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\n/**\n * Renders {@link Bubble.GroupProps.children} as a tightly spaced column of\n * consecutive {@link Bubble} frames, softening only the corners touching a\n * neighbor to a smaller radius, so the run reads as one continuous shape.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the run's markup.\n * @example\n * <Bubble.Group>\n * \t<Bubble align=\"end\"><Bubble.Content>{turnOne.text}</Bubble.Content></Bubble>\n * \t<Bubble align=\"end\"><Bubble.Content>{turnTwo.text}</Bubble.Content></Bubble>\n * </Bubble.Group>\n */\nBubble.Group = function BubbleGroup(handle: Handle<Bubble.GroupProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"group\"\n\t\t\t\tmix={[\n\t\t\t\t\tvstack({ gap: 0.5 }),\n\t\t\t\t\twhen('& > [data-slot=\"bubble\"]:not(:first-child)', [\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tborderStartStartRadius: \"var(--ui-radius-xs, 0.125rem)\",\n\t\t\t\t\t\t\tborderStartEndRadius: \"var(--ui-radius-xs, 0.125rem)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('& > [data-slot=\"bubble\"]:not(:last-child)', [\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tborderEndStartRadius: \"var(--ui-radius-xs, 0.125rem)\",\n\t\t\t\t\t\t\tborderEndEndRadius: \"var(--ui-radius-xs, 0.125rem)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "button",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Button"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "button.tsx",
|
|
10
|
+
"content": "/**\n * An interactive control for a single, immediate action — submitting a form,\n * triggering a command, opening a dialog. Its host renders as a native\n * `<button>` shaped by a semantic color role, a visual weight variant, and a\n * size, and holds its footprint while rendering a busy pending state.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { LoaderCircleIcon } from \"@sdxc/icons\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded, visibility } from \"@sdxc/u/effects\";\nimport { cursor, userSelect } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tgap,\n\tinlineFlex,\n\tinset,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n} from \"@sdxc/u/layout\";\nimport { bs, is, minBs, p, pb, pi, pie, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { text, weight } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { hitArea } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { glyphEdges } from \"@sdxc/ui/utils\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nconst DEFAULT_COLOR: Button.Color = \"neutral\";\n\nconst DEFAULT_VARIANT: Button.Variant = \"solid\";\n\nconst DEFAULT_SIZE: Button.Size = \"md\";\n\n/** Edge of a small icon-only button, matching the `sm` row height. */\nconst ICON_ONLY_SIZE_SM = \"var(--ui-button-icon-size-sm, 2rem)\";\n\n/** Edge of a medium icon-only button, matching the `md` row height. */\nconst ICON_ONLY_SIZE_MD = \"var(--ui-button-icon-size-md, 2.5rem)\";\n\n/** Edge of a large icon-only button, matching the `lg` row height. */\nconst ICON_ONLY_SIZE_LG = \"var(--ui-button-icon-size-lg, 3rem)\";\n\n/**\n * Native `type` given to a button carrying `command`/`commandfor` and no\n * `type` of its own: the platform treats a button that could also submit as an\n * ambiguous invoker and skips its command, so an invoker needs this type.\n */\nconst INVOKER_TYPE = \"button\";\n\n/**\n * Prop types for {@link Button}.\n */\nexport namespace Button {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Visual weight the button renders with: a solid fill with an on-solid\n\t * foreground, a transparent fill with a strong colored border, or a fully\n\t * transparent fill with just a colored label.\n\t */\n\texport type Variant = \"solid\" | \"outline\" | \"ghost\";\n\n\t/**\n\t * Size variant controlling the button's padding and font size.\n\t */\n\texport type Size = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Per-part styling for the elements a pending button renders besides its\n\t * own host.\n\t */\n\texport interface PartsProps {\n\t\t/** Styling for the decorative rotating glyph shown while pending. */\n\t\tspinner?: TagProps<\"span\">[\"mix\"];\n\t\t/**\n\t\t * Styling for the wrapper holding the button's own children while\n\t\t * pending; kept in the layout to preserve the button's footprint, but\n\t\t * hidden from view and from assistive technology.\n\t\t */\n\t\tcontent?: TagProps<\"span\">[\"mix\"];\n\t}\n\n\t/**\n\t * Props accepted by {@link Button}.\n\t */\n\texport interface Props extends TagProps<\"button\"> {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Size variant. Defaults to {@link DEFAULT_SIZE}. */\n\t\tsize?: Size;\n\t\t/**\n\t\t * Marks the button busy: merges into the native `disabled` attribute and\n\t\t * swaps the visible content for a spinner glyph while holding the rendered\n\t\t * footprint, so a page mid-request keeps its layout.\n\t\t */\n\t\tisPending?: boolean;\n\t\t/** Per-part styling for the pending state's internal elements. */\n\t\tparts?: PartsProps;\n\t}\n}\n\n/**\n * Reports whether `children` is a lone glyph, which is what makes a button a target for\n * that glyph rather than for a label. A selector cannot answer this: `:only-child`\n * counts elements, so a button holding text beside one icon still matches it.\n *\n * @param children The button's own children.\n * @returns Whether the button renders a single element and no text of its own.\n */\nfunction holdsOnlyAGlyph(children: RemixNode): boolean {\n\treturn typeof children === \"object\" && children !== null && !Array.isArray(children);\n}\n\n/**\n * Visual state lives in `data-color`/`data-variant`/`data-size` on the host, so\n * hover, pressed, and focus-visible stay on native pseudo-classes. `type` precedes\n * the spread so the platform sees it while parsing `command`/`commandfor`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the button's markup.\n * @example\n * <Button type=\"submit\">{t(\"actions.save\")}</Button>\n * @example\n * <Button color=\"danger\" variant=\"outline\" size=\"sm\">{t(\"actions.delete\")}</Button>\n * @example\n * <Button type=\"submit\" isPending={isSubmitting}>{t(\"actions.save\")}</Button>\n */\nexport function Button(handle: Handle<Button.Props>) {\n\treturn () => {\n\t\tlet { color, variant, size, isPending, disabled, type, parts, children, mix, ...rest } =\n\t\t\thandle.props;\n\t\tlet isInvoker = rest.command !== undefined || rest.commandfor !== undefined;\n\t\tlet resolvedType = type ?? (isInvoker ? INVOKER_TYPE : undefined);\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet resolvedSize = size ?? DEFAULT_SIZE;\n\t\tlet resolvedDisabled = disabled || isPending;\n\t\tlet iconOnly = holdsOnlyAGlyph(children);\n\t\tlet edges = glyphEdges(children);\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Button: an icon-only button needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-pending={isPending || undefined}\n\t\t\t\tdata-icon-only={iconOnly || undefined}\n\t\t\t\tdata-glyph-start={edges.start || undefined}\n\t\t\t\tdata-glyph-end={edges.end || undefined}\n\t\t\t\tdisabled={resolvedDisabled}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', outline(\"neutral.ring\")),\n\t\t\t\t\t\twhen('&[data-color=\"success\"]', outline(\"success.ring\")),\n\t\t\t\t\t\twhen('&[data-color=\"warning\"]', outline(\"warning.ring\")),\n\t\t\t\t\t\twhen('&[data-color=\"danger\"]', outline(\"danger.ring\")),\n\t\t\t\t\t]),\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\tgap(2),\n\t\t\t\t\t/**\n\t\t\t\t\t * A glyph is measured against the label it sits beside rather than against\n\t\t\t\t\t * whatever an icon set draws at, so the row keeps the height its text and\n\t\t\t\t\t * padding ask for. It never shrinks either: squeeze the row and the default\n\t\t\t\t\t * `flex-shrink: 1` compresses the glyph rather than the words, and a squashed\n\t\t\t\t\t * icon reads as a rendering fault.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"& > svg\", [shrink(), is(4), bs(4)]),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\t/** A small control reaches `--ui-target-size` however a consumer positions it. */\n\t\t\t\t\thitArea({ anchor: \"flex-center\" }),\n\t\t\t\t\tuserSelect(),\n\n\t\t\t\t\tpi(4),\n\t\t\t\t\tpb(2),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * Every variant carries the same border width, colored to match its own\n\t\t\t\t\t * fill (transparent for ghost), so solid and ghost render the exact\n\t\t\t\t\t * footprint outline does.\n\t\t\t\t\t */\n\t\t\t\t\tborder({ width: 1, noStyleDefault: true }),\n\n\t\t\t\t\t/**\n\t\t\t\t\t * The row measure is stated rather than left to fall out of the padding and\n\t\t\t\t\t * the border, so the control lines up with a field of the same size when a\n\t\t\t\t\t * Group fuses the two, and still grows when a long label wraps.\n\t\t\t\t\t */\n\t\t\t\t\tminBs(\"2.5rem\"),\n\n\t\t\t\t\twhen('&[data-size=\"sm\"]', [\n\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\tpb(1.5),\n\t\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\t\tminBs(\"2rem\"),\n\t\t\t\t\t\twhen(\"& > svg\", [is(3), bs(3)]),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-size=\"lg\"]', [\n\t\t\t\t\t\tpi(5),\n\t\t\t\t\t\tpb(2.5),\n\t\t\t\t\t\ttext(\"base\"),\n\t\t\t\t\t\tminBs(\"3rem\"),\n\t\t\t\t\t\twhen(\"& > svg\", [is(5), bs(5)]),\n\t\t\t\t\t]),\n\n\t\t\t\t\t/**\n\t\t\t\t\t * A glyph beside a label carries its own side bearing, so the padding on that\n\t\t\t\t\t * side drops one step and the glyph and the words read as evenly inset.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&[data-glyph-start]:has(> svg:first-child)\", [\n\t\t\t\t\t\tpis(3),\n\t\t\t\t\t\twhen('&[data-size=\"sm\"]', pis(2)),\n\t\t\t\t\t\twhen('&[data-size=\"lg\"]', pis(4)),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&[data-glyph-end]:has(> svg:last-child)\", [\n\t\t\t\t\t\tpie(3),\n\t\t\t\t\t\twhen('&[data-size=\"sm\"]', pie(2)),\n\t\t\t\t\t\twhen('&[data-size=\"lg\"]', pie(4)),\n\t\t\t\t\t]),\n\n\t\t\t\t\t/**\n\t\t\t\t\t * A button holding a glyph and nothing else is a target for that glyph alone, so\n\t\t\t\t\t * it takes a round footprint as tall as the row it would otherwise fill. The\n\t\t\t\t\t * measure is a custom property per size, since a box sized by its own content on\n\t\t\t\t\t * both axes has no ratio to resolve against, and an app or a composing part can\n\t\t\t\t\t * resize it without touching the rule.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&[data-icon-only]\", [\n\t\t\t\t\t\tp(0),\n\t\t\t\t\t\tis(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\tbs(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_MD),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-size=\"sm\"][data-icon-only]', [\n\t\t\t\t\t\tis(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\tbs(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_SM),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-size=\"lg\"][data-icon-only]', [\n\t\t\t\t\t\tis(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\tbs(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t\tminBs(ICON_ONLY_SIZE_LG),\n\t\t\t\t\t]),\n\n\t\t\t\t\twhen('&[data-variant=\"solid\"]', [\n\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\tborder(\"brand.solid\"),\n\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"brand.bg-solid-hover\"), border(\"brand.bg-solid-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", [bg(\"brand.bg-solid-pressed\"), border(\"brand.bg-solid-pressed\")]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\tbg(\"neutral.solid\"),\n\t\t\t\t\t\t\tborder(\"neutral.solid\"),\n\t\t\t\t\t\t\tfg(\"neutral.onSolid\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.bg-solid-hover\"), border(\"neutral.bg-solid-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\tbg(\"neutral.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\tborder(\"neutral.bg-solid-pressed\"),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\tbg(\"success.solid\"),\n\t\t\t\t\t\t\tborder(\"success.solid\"),\n\t\t\t\t\t\t\tfg(\"success.onSolid\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"success.bg-solid-hover\"), border(\"success.bg-solid-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\tbg(\"success.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\tborder(\"success.bg-solid-pressed\"),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\tbg(\"warning.solid\"),\n\t\t\t\t\t\t\tborder(\"warning.solid\"),\n\t\t\t\t\t\t\tfg(\"warning.onSolid\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"warning.bg-solid-hover\"), border(\"warning.bg-solid-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", [\n\t\t\t\t\t\t\t\tbg(\"warning.bg-solid-pressed\"),\n\t\t\t\t\t\t\t\tborder(\"warning.bg-solid-pressed\"),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\tbg(\"danger.solid\"),\n\t\t\t\t\t\t\tborder(\"danger.solid\"),\n\t\t\t\t\t\t\tfg(\"danger.onSolid\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"danger.bg-solid-hover\"), border(\"danger.bg-solid-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", [bg(\"danger.bg-solid-pressed\"), border(\"danger.bg-solid-pressed\")]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\n\t\t\t\t\twhen('&[data-variant=\"outline\"]', [\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\tborder(\"brand\"),\n\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"brand.tint\"), border(\"brand.border-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\tborder(\"neutral\"),\n\t\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.tint\"), border(\"neutral.border-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\tborder(\"success\"),\n\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"success.tint\"), border(\"success.border-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\tborder(\"warning\"),\n\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"warning.tint\"), border(\"warning.border-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\tborder(\"danger\"),\n\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", [bg(\"danger.tint\"), border(\"danger.border-hover\")]),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\n\t\t\t\t\twhen('&[data-variant=\"ghost\"]', [\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tborder(\"transparent\"),\n\t\t\t\t\t\twhen('&[data-color=\"brand\"]', [\n\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"brand.tint\")),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', [\n\t\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"success\"]', [\n\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"success.tint\")),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"warning\"]', [\n\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"warning.tint\")),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-color=\"danger\"]', [\n\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\twhen(\"&:hover\", bg(\"danger.tint\")),\n\t\t\t\t\t\t\twhen(\"&:active\", bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\n\t\t\t\t\twhen(\"&:disabled:not([data-pending])\", [cursor(\"not-allowed\"), opacity(50)]),\n\n\t\t\t\t\twhen(\"&[data-pending]\", [relative(), cursor(\"wait\")]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{isPending ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tdata-slot=\"spinner\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\t\t\tinset(0),\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\t\t\twhen(\"& svg\", [\n\t\t\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\twhen('[data-size=\"lg\"] & svg', [\n\t\t\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\tparts?.spinner,\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LoaderCircleIcon />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-slot=\"content\"\n\t\t\t\t\t\t\tmix={[visibility(\"hidden\"), inlineFlex(), items(\"center\"), gap(2), parts?.content]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\tchildren\n\t\t\t\t)}\n\t\t\t</button>\n\t\t);\n\t};\n}\n"
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"path": "button.test.tsx",
|
|
14
|
+
"content": "/**\n * Tests for {@link Button}: the `type` an Invoker Command needs (and where it is written),\n * the per-size icon-only measure, the glyph-edge markers that trim padding beside a\n * leading or trailing glyph, and the pointer target box drawn however it is positioned.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport { renderToString } from \"remix/component/server\";\nimport { describe, expect, test } from \"vitest\";\n\nimport { Button } from \"@sdxc/ui/button\";\n\ndescribe(Button.name, () => {\n\ttest('types itself \"button\" when it carries a command, so its command survives inside a form', async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button commandfor=\"confirm-delete\" command=\"show-modal\">\n\t\t\t\tDelete\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"button\"');\n\t});\n\n\ttest('types itself \"button\" when it carries only a commandfor', async () => {\n\t\tlet html = await renderToString(<Button commandfor=\"confirm-delete\">Delete</Button>);\n\n\t\texpect(html).toContain('type=\"button\"');\n\t});\n\n\ttest(\"renders no type of its own for a button carrying no command\", async () => {\n\t\tlet html = await renderToString(<Button>Save</Button>);\n\n\t\texpect(html).not.toContain(\"type=\");\n\t});\n\n\ttest(\"leaves an explicitly typed submit button alone\", async () => {\n\t\tlet html = await renderToString(<Button type=\"submit\">Save</Button>);\n\n\t\texpect(html).toContain('type=\"submit\"');\n\t});\n\n\ttest(\"writes type before the command attributes, which is where the platform reads it\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button commandfor=\"confirm-delete\" command=\"show-modal\">\n\t\t\t\tDelete\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html.indexOf('type=\"button\"')).toBeLessThan(html.indexOf(\"commandfor=\"));\n\t\texpect(html.indexOf('type=\"button\"')).toBeLessThan(html.indexOf(\"command=\"));\n\t});\n\n\ttest(\"writes an explicit type before the command attributes too\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button type=\"button\" commandfor=\"confirm-delete\" command=\"close\">\n\t\t\t\tCancel\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html.indexOf('type=\"button\"')).toBeLessThan(html.indexOf(\"commandfor=\"));\n\t});\n\n\ttest(\"respects an explicit type even on a command invoker\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button type=\"reset\" commandfor=\"confirm-delete\" command=\"close\">\n\t\t\t\tReset\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"reset\"');\n\t\texpect(html).not.toContain('type=\"button\"');\n\t});\n\n\ttest(\"sizes an icon-only button from a per-size custom property\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button size=\"sm\" aria-label=\"Close\">\n\t\t\t\t<svg />\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html).toContain(\"data-icon-only\");\n\t\texpect(html).toContain(\"inline-size: var(--ui-button-icon-size-sm, 2rem);\");\n\t\texpect(html).toContain(\"inline-size: var(--ui-button-icon-size-md, 2.5rem);\");\n\t\texpect(html).toContain(\"inline-size: var(--ui-button-icon-size-lg, 3rem);\");\n\t});\n\n\ttest(\"marks a leading glyph beside a label so its side's padding drops a step\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button>\n\t\t\t\t<svg />\n\t\t\t\tSave\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html).toMatch(/<button[^>]*data-glyph-start/);\n\t\texpect(html).not.toMatch(/<button[^>]*data-glyph-end/);\n\t});\n\n\ttest(\"marks a trailing glyph after a label, even though :first-child would also match it\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button>\n\t\t\t\tNext\n\t\t\t\t<svg />\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html).toMatch(/<button[^>]*data-glyph-end/);\n\t\texpect(html).not.toMatch(/<button[^>]*data-glyph-start/);\n\t});\n\n\ttest(\"marks neither edge on an icon-only or text-only button\", async () => {\n\t\tlet iconOnly = await renderToString(\n\t\t\t<Button aria-label=\"Close\">\n\t\t\t\t<svg />\n\t\t\t</Button>,\n\t\t);\n\t\tlet textOnly = await renderToString(<Button>Save</Button>);\n\n\t\texpect(iconOnly).not.toMatch(/<button[^>]*data-glyph-/);\n\t\texpect(textOnly).not.toMatch(/<button[^>]*data-glyph-/);\n\t});\n\n\ttest(\"draws an unanchored target box, so it reaches --ui-target-size however it is positioned\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Button size=\"sm\" aria-label=\"Close\">\n\t\t\t\t<svg />\n\t\t\t</Button>,\n\t\t);\n\n\t\texpect(html).toMatch(\n\t\t\t/&::after \\{[^}]*position: absolute;[^}]*inline-size: var\\(--ui-target-size, 1\\.5rem\\);[^}]*block-size: var\\(--ui-target-size, 1\\.5rem\\);/,\n\t\t);\n\t\texpect(html).not.toMatch(/&::after \\{[^}]*inset/);\n\t});\n});\n"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "calendar",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"heading",
|
|
6
|
+
"input"
|
|
7
|
+
],
|
|
8
|
+
"exports": [
|
|
9
|
+
"Calendar"
|
|
10
|
+
],
|
|
11
|
+
"source": {
|
|
12
|
+
"path": "calendar.tsx",
|
|
13
|
+
"content": "/**\n * A month-grid calendar surface composed from a navigable header and a native\n * `<table>` of day cells, styled through the platform's own semantics. Used\n * bare, it renders a native `<input type=\"date\">` — a complete,\n * keyboard-operable date control on its own.\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 { ChevronLeftIcon, ChevronRightIcon } from \"@sdxc/icons\";\nimport { bg, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, raw } from \"@sdxc/u/general\";\nimport {\n\tbasis,\n\tborderCollapse,\n\tborderSpacing,\n\tflex,\n\tgrow,\n\tinlineBlock,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n} from \"@sdxc/u/layout\";\nimport { bs, is, mbe, p, pbe } from \"@sdxc/u/size\";\nimport { hover, when } from \"@sdxc/u/state\";\nimport { scaleX } from \"@sdxc/u/transform\";\nimport {\n\ttabularNums,\n\ttext,\n\ttextAlign,\n\ttextDecoration,\n\tverticalAlign,\n\tweight,\n} from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { hitArea } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport {\n\twarnIfNoAccessibleLabel,\n\twarnIfNoAccessibleName,\n} from \"@sdxc/ui/utils\";\n\nimport { Heading } from \"@sdxc/ui/heading\";\nimport { Input } from \"@sdxc/ui/input\";\n\nconst DEFAULT_COLOR: Calendar.Color = \"neutral\";\n\n/**\n * `type` for {@link Calendar.PreviousButton} and {@link Calendar.NextButton}\n * when a consumer supplies none, keeping a click on either control a plain\n * month change inside a surrounding `<form>`.\n */\nconst DEFAULT_NAV_BUTTON_TYPE: NonNullable<Calendar.PreviousButtonProps[\"type\"]> = \"button\";\n\n/**\n * Prop types for {@link Calendar} and its compound parts.\n */\nexport namespace Calendar {\n\t/**\n\t * Semantic color role for the bare `<input type=\"date\">` fallback's keyboard\n\t * focus ring, each mapped to its matching `--ui-*` variables. The composed\n\t * grid reads fixed semantic roles, identical across every rendered month.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Props accepted by {@link Calendar}. Composing {@link Calendar.Header} and\n\t * {@link Calendar.Grid} as `children` renders the visual month surface;\n\t * `children` left unset renders the native `<input type=\"date\">` fallback.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Semantic color role for the bare fallback control's focus ring. 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 control. */\n\t\tname?: string;\n\t\t/** Current value, in `YYYY-MM-DD` form, for a bare fallback control a consumer tracks itself. */\n\t\tvalue?: string;\n\t\t/** Initial value, in `YYYY-MM-DD` form, for a bare fallback control left to the platform's own uncontrolled state. */\n\t\tdefaultValue?: string;\n\t\t/** Earliest accepted date, in `YYYY-MM-DD` form, read only by the bare fallback control. */\n\t\tmin?: string;\n\t\t/** Latest accepted date, in `YYYY-MM-DD` form, read only by the bare fallback control. */\n\t\tmax?: string;\n\t\t/** Granularity, in days, the bare fallback control's value must fall on. */\n\t\tstep?: number;\n\t\t/** Marks the bare fallback control required for its enclosing form. */\n\t\trequired?: boolean;\n\t\t/** Marks the bare fallback control inert and excluded from the tab order. */\n\t\tdisabled?: boolean;\n\t\t/** Marks the bare fallback control's value fixed, while keeping it focusable and included in form submission. */\n\t\treadOnly?: boolean;\n\t\t/** Native autofill hint for the bare fallback control, e.g. `\"bday\"`. */\n\t\tautoComplete?: string;\n\t}\n\n\t/**\n\t * Every native `<header>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface HeaderProps extends TagProps<\"header\"> {}\n\n\t/**\n\t * Every native `<button>` attribute, unchanged, plus the `mix` passthrough.\n\t * `type` defaults to {@link DEFAULT_NAV_BUTTON_TYPE}. Needs an `aria-label`\n\t * (e.g. `\"Previous month\"`) as the control's only accessible name.\n\t */\n\texport interface PreviousButtonProps extends TagProps<\"button\"> {}\n\n\t/**\n\t * Every native `<button>` attribute, unchanged, plus the `mix`\n\t * passthrough, mirroring {@link Calendar.PreviousButton} for the following\n\t * month instead.\n\t */\n\texport interface NextButtonProps extends TagProps<\"button\"> {}\n\n\t/**\n\t * Every prop {@link Heading} accepts, unchanged. `level` still chooses\n\t * which native heading element renders, defaulting the same way\n\t * {@link Heading} does.\n\t */\n\texport interface HeadingProps extends Heading.Props {}\n\n\t/**\n\t * Every native `<table>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface GridProps extends TagProps<\"table\"> {}\n\n\t/**\n\t * Every native `<thead>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface GridHeaderProps extends TagProps<\"thead\"> {}\n\n\t/**\n\t * Every native `<tr>` attribute, unchanged, plus the `mix` passthrough. Holds\n\t * one row of {@link Calendar.HeaderCell} in {@link Calendar.GridHeader}, or\n\t * one week of {@link Calendar.Cell} in {@link Calendar.GridBody}.\n\t */\n\texport interface RowProps extends TagProps<\"tr\"> {}\n\n\t/**\n\t * Every native `<th>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface HeaderCellProps extends TagProps<\"th\"> {}\n\n\t/**\n\t * Every native `<tbody>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface GridBodyProps extends TagProps<\"tbody\"> {}\n\n\t/**\n\t * Every native `<td>` attribute, unchanged, plus the `mix` passthrough. Day\n\t * state is read straight off the rendered element: the consumer sets\n\t * `aria-selected`, `aria-disabled`, `data-unavailable`, `data-outside-month`.\n\t */\n\texport interface CellProps extends TagProps<\"td\"> {}\n}\n\n/**\n * Renders a rounded, padded surface around whichever children a consumer\n * composes; `children` left unset renders a native `<input type=\"date\">`\n * through {@link Input}, the one part the platform itself operates.\n *\n * @param handle Runtime handle carrying the root element's props.\n * @returns The render function producing the calendar's markup.\n * @example\n * <Calendar aria-label={t(\"form.startDate.label\")} name=\"startDate\" />\n * @example\n * <Calendar aria-label={t(\"calendar.label\")}>\n * \t<Calendar.Header>\n * \t\t<Calendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t\t<Calendar.Heading>{monthLabel}</Calendar.Heading>\n * \t\t<Calendar.NextButton aria-label={t(\"calendar.next\")} />\n * \t</Calendar.Header>\n * \t<Calendar.Grid aria-label={monthLabel}>\n * \t\t<Calendar.GridHeader>\n * \t\t\t<Calendar.Row>\n * \t\t\t\t{weekdayLabels.map((day) => (\n * \t\t\t\t\t<Calendar.HeaderCell key={day}>{day}</Calendar.HeaderCell>\n * \t\t\t\t))}\n * \t\t\t</Calendar.Row>\n * \t\t</Calendar.GridHeader>\n * \t\t<Calendar.GridBody>\n * \t\t\t{weeks.map((week) => (\n * \t\t\t\t<Calendar.Row key={week[0].iso}>\n * \t\t\t\t\t{week.map((day) => (\n * \t\t\t\t\t\t<Calendar.Cell\n * \t\t\t\t\t\t\tkey={day.iso}\n * \t\t\t\t\t\t\taria-selected={day.iso === selected ? \"true\" : undefined}\n * \t\t\t\t\t\t\tdata-outside-month={day.outsideMonth ? \"\" : 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</Calendar.Cell>\n * \t\t\t\t\t))}\n * \t\t\t\t</Calendar.Row>\n * \t\t\t))}\n * \t\t</Calendar.GridBody>\n * \t</Calendar.Grid>\n * </Calendar>\n */\nexport function Calendar(handle: Handle<Calendar.Props>) {\n\treturn () => {\n\t\tlet {\n\t\t\tcolor,\n\t\t\tname,\n\t\t\tvalue,\n\t\t\tdefaultValue,\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\t\"aria-label\": ariaLabel,\n\t\t\t\"aria-labelledby\": ariaLabelledBy,\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 && !ariaLabel && !ariaLabelledBy) {\n\t\t\tconsole.warn(\n\t\t\t\t'Calendar: falling back to a plain \"input type=date\" needs an \"aria-label\" or \"aria-labelledby\" describing what it collects for assistive technology.',\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"calendar\"\n\t\t\t\tmix={[inlineBlock(), rounded(\"lg\"), p(3), bg(\"neutral.tint\"), mix]}\n\t\t\t>\n\t\t\t\t{children ?? (\n\t\t\t\t\t<Input\n\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\tcolor={resolvedColor}\n\t\t\t\t\t\tname={name}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\tdefaultValue={defaultValue}\n\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link Calendar}'s nav row: a flex row spacing\n * {@link Calendar.PreviousButton}, {@link Calendar.Heading}, and\n * {@link Calendar.NextButton} apart, the heading centered between the controls.\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 * <Calendar.Header>\n * \t<Calendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t<Calendar.Heading>{monthLabel}</Calendar.Heading>\n * \t<Calendar.NextButton aria-label={t(\"calendar.next\")} />\n * </Calendar.Header>\n */\nCalendar.Header = function CalendarHeader(handle: Handle<Calendar.HeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<header\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"header\"\n\t\t\t\tmix={[flex(), items(\"center\"), justify(\"between\"), mbe(4), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a round icon control standing for \"show the previous month\", sized\n * to match {@link Calendar.NextButton}. Its default chevron flips under\n * `dir=\"rtl\"` through CSS. A `calendarKeys()` mixin drives the behavior.\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 * <Calendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n */\nCalendar.PreviousButton = function CalendarPreviousButton(\n\thandle: Handle<Calendar.PreviousButtonProps>,\n) {\n\treturn () => {\n\t\tlet { type, children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t'Calendar.PreviousButton: 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={type ?? DEFAULT_NAV_BUTTON_TYPE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"previous-button\"\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\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\trelative(),\n\t\t\t\t\tis(8),\n\t\t\t\t\tbs(8),\n\t\t\t\t\thitArea(),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\twhen(\"& svg\", [is(4), bs(4)]),\n\t\t\t\t\twhen(\"&:dir(rtl) svg\", scaleX(-1)),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children ?? <ChevronLeftIcon />}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders a round icon control standing for \"show the following month\", with\n * the rendering, focus, and disabled-state contract of\n * {@link Calendar.PreviousButton} and a trailing chevron by default.\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 * <Calendar.NextButton aria-label={t(\"calendar.next\")} />\n */\nCalendar.NextButton = function CalendarNextButton(handle: Handle<Calendar.NextButtonProps>) {\n\treturn () => {\n\t\tlet { type, children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t'Calendar.NextButton: 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={type ?? DEFAULT_NAV_BUTTON_TYPE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"next-button\"\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\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\trelative(),\n\t\t\t\t\tis(8),\n\t\t\t\t\tbs(8),\n\t\t\t\t\thitArea(),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\twhen(\"& svg\", [is(4), bs(4)]),\n\t\t\t\t\twhen(\"&:dir(rtl) svg\", scaleX(-1)),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children ?? <ChevronRightIcon />}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders the consumer-formatted month/year caption through {@link Heading},\n * centered between the nav controls at a small semibold size layered after\n * {@link Heading}'s own defaults, so this size and alignment win over them.\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 * <Calendar.Heading>{new Intl.DateTimeFormat(locale, { month: \"long\", year: \"numeric\" }).format(visibleMonth)}</Calendar.Heading>\n */\nCalendar.Heading = function CalendarHeading(handle: Handle<Calendar.HeadingProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Heading\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"heading\"\n\t\t\t\tmix={[\n\t\t\t\t\tgrow(),\n\t\t\t\t\tshrink(1),\n\t\t\t\t\tbasis(\"0%\"),\n\t\t\t\t\ttextAlign(\"center\"),\n\t\t\t\t\tweight(\"semibold\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\ttext(\"sm\"),\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 day grid's native `<table>` host, rows and cells set apart by a\n * small gap on every side. Its `aria-label`/`aria-labelledby` — typically the\n * visible month label — names the whole grid; dev mode warns when it is absent.\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 * <Calendar.Grid aria-label={monthLabel}>\n * \t<Calendar.GridHeader>...</Calendar.GridHeader>\n * \t<Calendar.GridBody>...</Calendar.GridBody>\n * </Calendar.Grid>\n */\nCalendar.Grid = function CalendarGrid(handle: Handle<Calendar.GridProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Calendar.Grid: needs an \"aria-label\" or \"aria-labelledby\" identifying which month it shows for assistive technology.',\n\t\t);\n\n\t\treturn (\n\t\t\t<table\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"grid\"\n\t\t\t\tmix={[borderCollapse(\"separate\"), borderSpacing(\"0.25rem\"), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the grid's `<thead>` host: a plain wrapper for the weekday\n * {@link Calendar.Row}.\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 * <Calendar.GridHeader>\n * \t<Calendar.Row>\n * \t\t<Calendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</Calendar.HeaderCell>\n * \t</Calendar.Row>\n * </Calendar.GridHeader>\n */\nCalendar.GridHeader = function CalendarGridHeader(handle: Handle<Calendar.GridHeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <thead {...rest} data-slot=\"grid-header\" mix={[mix]} />;\n\t};\n};\n\n/**\n * Renders a native `<tr>` host: one row of {@link Calendar.HeaderCell} inside\n * {@link Calendar.GridHeader}, or one week of {@link Calendar.Cell} inside\n * {@link Calendar.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 * <Calendar.Row>\n * \t<Calendar.Cell>{day.label}</Calendar.Cell>\n * </Calendar.Row>\n */\nCalendar.Row = function CalendarRow(handle: Handle<Calendar.RowProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <tr {...rest} data-slot=\"row\" mix={[mix]} />;\n\t};\n};\n\n/**\n * Renders a weekday abbreviation inside a native `<th scope=\"col\">`, sized\n * small and muted beneath {@link Calendar.Cell}'s own larger day numbers.\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 * <Calendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</Calendar.HeaderCell>\n */\nCalendar.HeaderCell = function CalendarHeaderCell(handle: Handle<Calendar.HeaderCellProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<th\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"header-cell\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ scope: \"col\" }),\n\t\t\t\t\tpbe(2),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\ttext(\"xs\"),\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 grid's `<tbody>` host: a plain wrapper for one\n * {@link Calendar.Row} per week.\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 * <Calendar.GridBody>\n * \t{weeks.map((week) => (\n * \t\t<Calendar.Row key={week[0].iso}>...</Calendar.Row>\n * \t))}\n * </Calendar.GridBody>\n */\nCalendar.GridBody = function CalendarGridBody(handle: Handle<Calendar.GridBodyProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <tbody {...rest} data-slot=\"grid-body\" mix={[mix]} />;\n\t};\n};\n\n/**\n * Renders one calendar day inside a native `<td>`, a fixed round pill around\n * its number. `aria-selected`, `aria-disabled`, `data-unavailable`,\n * `data-outside-month`, and `aria-invalid` each drive their own visual state.\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 * <Calendar.Cell aria-selected={day.iso === selected ? \"true\" : undefined}>\n * \t{day.label}\n * </Calendar.Cell>\n * @example\n * <Calendar.Cell data-outside-month=\"\">{day.label}</Calendar.Cell>\n */\nCalendar.Cell = function CalendarCell(handle: Handle<Calendar.CellProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<td\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"cell\"\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t/**\n\t\t\t\t\t * Table alignment centres the day while the cell stays a table cell in its row; a row\n\t\t\t\t\t * laid out as a flex box turns its cells into blocks, where `align-content` centres the\n\t\t\t\t\t * day. Each declaration answers one of the two cases.\n\t\t\t\t\t */\n\t\t\t\t\ttextAlign(\"center\"),\n\t\t\t\t\tverticalAlign(\"middle\"),\n\t\t\t\t\traw({ alignContent: \"center\" }),\n\t\t\t\t\tis(9),\n\t\t\t\t\tbs(9),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\twhen('&[aria-selected=\"true\"]', [bg(\"brand.solid\"), fg(\"brand.onSolid\")]),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), opacity(30)]),\n\t\t\t\t\twhen(\"&[data-unavailable]\", [fg(\"neutral.muted\"), textDecoration(\"line-through\")]),\n\t\t\t\t\twhen(\"&[data-outside-month]\", fg(\"neutral.muted\")),\n\t\t\t\t\twhen('&[aria-invalid=\"true\"]', [bg(\"danger.solid\"), fg(\"danger.onSolid\")]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
14
|
+
},
|
|
15
|
+
"test": null
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "card",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"heading-scope"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"Card"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "card.tsx",
|
|
12
|
+
"content": "/**\n * A bounded container grouping a header, body content, and footer actions\n * into one ring-edged, softly lifted panel tinted by a semantic color role.\n * The role colors border, background, and text together, so {@link Card.Title}\n * and {@link Card.Description} inherit their text color from the root through\n * ordinary CSS inheritance.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { border } from \"@sdxc/u/color\";\nimport { opacity, rounded, shadow } from \"@sdxc/u/effects\";\nimport { vars } from \"@sdxc/u/general\";\nimport { flex, flexCol, gap, items } from \"@sdxc/u/layout\";\nimport { p, pbe, pbs, pi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { balance, fontSize, leading, pretty, tracking, weight } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { SHADOW_RING } from \"@sdxc/ui/styles\";\nimport { semanticColorPanel } from \"@sdxc/ui/styles\";\n\nimport { resolveHeadingLevel, TAG_BY_LEVEL } from \"@sdxc/ui/heading-scope\";\n\n/** Semantic color role {@link Card} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Card.Color = \"neutral\";\n\n/**\n * Prop types for {@link Card} and its compound parts.\n */\nexport namespace Card {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` border,\n\t * background, and foreground variables.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Every native `<section>` attribute, unchanged, plus the `color` role that\n\t * tints the panel.\n\t */\n\texport interface Props extends TagProps<\"section\"> {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t}\n\n\t/** Every native `<header>` attribute, unchanged, plus the `mix` passthrough. */\n\texport interface HeaderProps extends TagProps<\"header\"> {}\n\n\t/**\n\t * Every native heading-element attribute, unchanged: the rendered tag\n\t * follows the nearest ambient heading level, falling back to `<h1>` where\n\t * nothing supplies one.\n\t */\n\texport interface TitleProps extends TagProps<\"h1\"> {}\n\n\t/** Every native `<p>` attribute, unchanged, plus the `mix` passthrough. */\n\texport interface DescriptionProps extends TagProps<\"p\"> {}\n\n\t/** Every native `<div>` attribute, unchanged, plus the `mix` passthrough. */\n\texport interface ContentProps extends TagProps<\"div\"> {}\n\n\t/** Every native `<footer>` attribute, unchanged, plus the `mix` passthrough. */\n\texport interface FooterProps extends TagProps<\"footer\"> {}\n}\n\n/**\n * The card panel: a rounded, softly lifted `<section>` tinted through the\n * `data-color` attribute contract. A neutral card draws its edge as a ring\n * shadow that takes on the tone behind it; a colored one keeps its tinted\n * border inside that ring. Compose {@link Card.Header},\n * {@link Card.Content}, and {@link Card.Footer} inside it.\n *\n * @param handle Runtime handle carrying the host `<section>`'s props.\n * @returns The render function producing the panel's markup.\n * @example\n * <Card>\n * \t<Card.Header>\n * \t\t<Card.Title>{t(\"plan.title\")}</Card.Title>\n * \t\t<Card.Description>{t(\"plan.description\")}</Card.Description>\n * \t</Card.Header>\n * \t<Card.Content>{t(\"plan.body\")}</Card.Content>\n * \t<Card.Footer>\n * \t\t<Button>{t(\"plan.upgrade\")}</Button>\n * \t</Card.Footer>\n * </Card>\n * @example\n * <Card color=\"danger\">\n * \t<Card.Header>\n * \t\t<Card.Title>{t(\"errors.billing.title\")}</Card.Title>\n * \t</Card.Header>\n * </Card>\n */\nexport function Card(handle: Handle<Card.Props>) {\n\treturn () => {\n\t\tlet { color, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<section\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tsemanticColorPanel(),\n\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\tborder({ width: 1 }),\n\t\t\t\t\twhen('&[data-color=\"neutral\"]', border(\"transparent\")),\n\t\t\t\t\tshadow(\"sm\"),\n\t\t\t\t\tvars({ \"ui-box-shadow-ring\": SHADOW_RING }),\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 card's header slot: a `<header>` stacking its children in a\n * column with a small gap, padded on every side. Nest {@link Card.Title} and\n * {@link Card.Description} inside it.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the header slot's markup.\n * @example\n * <Card.Header>\n * \t<Card.Title>{t(\"plan.title\")}</Card.Title>\n * </Card.Header>\n */\nCard.Header = function CardHeader(handle: Handle<Card.HeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <header {...rest} mix={[flex(), flexCol(), p(6, 6), gap(\"0.375rem\"), mix]} />;\n\t};\n};\n\n/**\n * The card's heading, in the native heading element matching the nearest\n * ambient heading level — `<h1>` where nothing supplies one. Its text color\n * inherits from the card root's `color` value.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the heading's markup.\n * @example\n * <Card.Title>{t(\"plan.title\")}</Card.Title>\n */\nCard.Title = function CardTitle(handle: Handle<Card.TitleProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet resolved = resolveHeadingLevel(handle);\n\t\tlet Tag = TAG_BY_LEVEL[resolved];\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\t{...rest}\n\t\t\t\tdata-heading-level={resolved}\n\t\t\t\tmix={[fontSize(\"2xl\"), leading(1), weight(\"semibold\"), tracking(\"tight\"), balance(), mix]}\n\t\t\t>\n\t\t\t\t{rest.children}\n\t\t\t</Tag>\n\t\t);\n\t};\n};\n\n/**\n * Renders the card's supporting copy inside a native `<p>`, muted to\n * seventy percent opacity so it reads as secondary to {@link Card.Title}.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the description's markup.\n * @example\n * <Card.Description>{t(\"plan.description\")}</Card.Description>\n */\nCard.Description = function CardDescription(handle: Handle<Card.DescriptionProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <p {...rest} mix={[fontSize(\"sm\"), opacity(70), pretty(), mix]} />;\n\t};\n};\n\n/**\n * The card's main body slot: a `<div>` padded on its inline and block-end\n * edges, leaving its block-start edge flush against {@link Card.Header}. Its\n * prose wraps with `text-wrap: pretty`, which every paragraph inside inherits.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the body slot's markup.\n * @example\n * <Card.Content>{t(\"plan.body\")}</Card.Content>\n */\nCard.Content = function CardContent(handle: Handle<Card.ContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\t/**\n\t\t\t\t\t * The body leaves the gap above it to a header, and takes it back when it opens the card,\n\t\t\t\t\t * so a card of content alone still clears its own top edge.\n\t\t\t\t\t */\n\t\t\t\t\tpbs(0),\n\t\t\t\t\twhen(\"&:first-child\", pbs(6)),\n\t\t\t\t\tpbe(6),\n\t\t\t\t\tpi(6),\n\t\t\t\t\tpretty(),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The card's footer slot: a `<footer>` laying its children out in a\n * vertically centered row, padded on its inline and block-end edges so it\n * sits flush against the content above.\n *\n * @param handle Runtime handle carrying the host `<footer>`'s props.\n * @returns The render function producing the footer slot's markup.\n * @example\n * <Card.Footer>\n * \t<Button>{t(\"plan.upgrade\")}</Button>\n * </Card.Footer>\n */\nCard.Footer = function CardFooter(handle: Handle<Card.FooterProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <footer {...rest} mix={[flex(), items(\"center\"), pbs(0), pbe(6), pi(6), mix]} />;\n\t};\n};\n"
|
|
13
|
+
},
|
|
14
|
+
"test": {
|
|
15
|
+
"path": "card.test.tsx",
|
|
16
|
+
"content": "/**\n * Covers the card panel's ring-shadow edge and its text wrapping, read from\n * the stylesheet the component emits: a neutral card hands its edge to the\n * ring shadow, and the title balances while body copy wraps prettily.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport { renderToString } from \"remix/component/server\";\nimport { describe, expect, test } from \"vitest\";\n\nimport { Card } from \"@sdxc/ui/card\";\n\ndescribe(\"Card\", () => {\n\ttest(\"draws its edge with the theme's ring shadow and clears a neutral card's border\", async () => {\n\t\tlet html = await renderToString(<Card>Plan</Card>);\n\n\t\texpect(html).toContain(\"--ui-box-shadow-ring: var(--ui-shadow-ring,\");\n\t\texpect(html.replace(/\\s+/g, \" \")).toMatch(\n\t\t\t/&\\[data-color=\"neutral\"\\] \\{ border-color: transparent; \\}/,\n\t\t);\n\t});\n\n\ttest(\"balances the title and wraps description and content prettily\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Card>\n\t\t\t\t<Card.Header>\n\t\t\t\t\t<Card.Title>Pro plan</Card.Title>\n\t\t\t\t\t<Card.Description>For growing teams.</Card.Description>\n\t\t\t\t</Card.Header>\n\t\t\t\t<Card.Content>Everything in Free, and more.</Card.Content>\n\t\t\t</Card>,\n\t\t);\n\n\t\texpect(html).toContain(\"text-wrap: balance\");\n\t\texpect(html).toContain(\"text-wrap: pretty\");\n\t});\n});\n"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "carousel",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"button"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"Carousel"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "carousel.tsx",
|
|
12
|
+
"content": "/**\n * A horizontally scrolling collection of slides riding native CSS scroll snap,\n * so swiping or scrolling advances between slides with no script in the\n * baseline. {@link Carousel.Viewport} is the scrolling surface,\n * {@link Carousel.Track} rows up its {@link Carousel.Slide} children, and\n * {@link Carousel.Previous}/{@link Carousel.Next} are invoker buttons a paired\n * mixin wires into working controls.\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 { ChevronLeftIcon, ChevronRightIcon } from \"@sdxc/icons\";\nimport { outline } from \"@sdxc/u/color\";\nimport { raw, vars } from \"@sdxc/u/general\";\nimport { flex, flexCol, gap, grow, items, justify, shrink } from \"@sdxc/u/layout\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, minIs, pi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { attrs } from \"remix/component\";\n\nimport { Button } from \"@sdxc/ui/button\";\n\n/** Native ARIA role applied to {@link Carousel.Viewport} unless a consumer overrides it. */\nconst DEFAULT_VIEWPORT_ROLE = \"group\";\n\n/**\n * Native tab-stop index applied to {@link Carousel.Viewport} unless a consumer\n * overrides it, so the scrollable region is reachable by keyboard even before\n * any control is wired up.\n */\nconst DEFAULT_VIEWPORT_TAB_INDEX = 0;\n\n/** Native ARIA role applied to {@link Carousel.Slide} unless a consumer overrides it. */\nconst DEFAULT_SLIDE_ROLE = \"group\";\n\n/**\n * Visual weight {@link Carousel.Previous} and {@link Carousel.Next} fall back\n * to when `variant` is omitted.\n */\nconst DEFAULT_CONTROL_VARIANT: Button.Variant = \"ghost\";\n\n/**\n * Semantic color role {@link Carousel.Previous} and {@link Carousel.Next} fall\n * back to when `color` is omitted.\n */\nconst DEFAULT_CONTROL_COLOR: Button.Color = \"neutral\";\n\n/**\n * Size variant {@link Carousel.Previous} and {@link Carousel.Next} fall back to\n * when `size` is omitted.\n */\nconst DEFAULT_CONTROL_SIZE: Button.Size = \"sm\";\n\n/** Invoker Commands verb {@link Carousel.Previous} falls back to when `command` is omitted. */\nconst DEFAULT_PREVIOUS_COMMAND = \"--ui-prev\";\n\n/** Invoker Commands verb {@link Carousel.Next} falls back to when `command` is omitted. */\nconst DEFAULT_NEXT_COMMAND = \"--ui-next\";\n\n/**\n * Prop types for {@link Carousel} and its compound parts.\n */\nexport namespace Carousel {\n\t/**\n\t * Every native `<section>` attribute, unchanged, plus the `mix`\n\t * passthrough. Override `--ui-carousel-gap`, `--ui-carousel-slide-size`, or\n\t * `--ui-carousel-padding` per instance through the inherited `style` prop.\n\t */\n\texport interface Props extends TagProps<\"section\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * Give it an `id` for the controls' `commandfor` prop to target, and pair a\n\t * `carouselControls()` mixin on it to make those controls scroll it.\n\t */\n\texport interface ViewportProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface TrackProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface SlideProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ControlsProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every {@link Button.Props} field, with `commandfor` required and `command`\n\t * narrowed to the verb the paired mixin listens for.\n\t */\n\texport interface PreviousProps extends Omit<Button.Props, \"commandfor\" | \"command\"> {\n\t\t/** `id` of the {@link Carousel.Viewport} this control scrolls back through. */\n\t\tcommandfor: string;\n\t\t/** Invoker Commands verb a `carouselControls()` mixin listens for. Defaults to `\"--ui-prev\"`. */\n\t\tcommand?: \"--ui-prev\";\n\t}\n\n\t/**\n\t * Every {@link Button.Props} field, with `commandfor` required and `command`\n\t * narrowed to the verb the paired mixin listens for.\n\t */\n\texport interface NextProps extends Omit<Button.Props, \"commandfor\" | \"command\"> {\n\t\t/** `id` of the {@link Carousel.Viewport} this control scrolls forward through. */\n\t\tcommandfor: string;\n\t\t/** Invoker Commands verb a `carouselControls()` mixin listens for. Defaults to `\"--ui-next\"`. */\n\t\tcommand?: \"--ui-next\";\n\t}\n}\n\n/**\n * The carousel root: a `<section>` stacking {@link Carousel.Viewport} and\n * {@link Carousel.Controls} in a column, declaring the `--ui-carousel-*`\n * custom properties its descendants read with per-instance defaults.\n *\n * @param handle Runtime handle carrying the host `<section>`'s props.\n * @returns The render function producing the carousel's markup.\n * @example\n * <Carousel aria-label={t(\"gallery.label\")}>\n * \t<Carousel.Viewport id=\"gallery-viewport\">\n * \t\t<Carousel.Track>\n * \t\t\t<Carousel.Slide><img src={photo.src} alt={photo.alt} /></Carousel.Slide>\n * \t\t</Carousel.Track>\n * \t</Carousel.Viewport>\n * \t<Carousel.Controls>\n * \t\t<Carousel.Previous commandfor=\"gallery-viewport\" aria-label={t(\"gallery.previous\")} />\n * \t\t<Carousel.Next commandfor=\"gallery-viewport\" aria-label={t(\"gallery.next\")} />\n * \t</Carousel.Controls>\n * </Carousel>\n */\nexport function Carousel(handle: Handle<Carousel.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<section\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"carousel\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\tgap(3),\n\t\t\t\t\tvars({\n\t\t\t\t\t\t\"ui-carousel-gap\": \"1rem\",\n\t\t\t\t\t\t\"ui-carousel-slide-size\": \"18rem\",\n\t\t\t\t\t\t\"ui-carousel-padding\": \"0px\",\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 * A `<div>` scrolling {@link Carousel.Track} along the inline axis via logical\n * properties for correct writing direction, with mandatory scroll-snap stops;\n * scroll padding reads `--ui-carousel-padding` to clear the track's own padding.\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 * <Carousel.Viewport id=\"gallery-viewport\">\n * \t<Carousel.Track>{slides}</Carousel.Track>\n * </Carousel.Viewport>\n */\nCarousel.Viewport = function CarouselViewport(handle: Handle<Carousel.ViewportProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"viewport\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_VIEWPORT_ROLE, tabIndex: DEFAULT_VIEWPORT_TAB_INDEX }),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\traw({\n\t\t\t\t\t\toverflowInline: \"auto\",\n\t\t\t\t\t\toverflowBlock: \"hidden\",\n\t\t\t\t\t\tscrollBehavior: \"smooth\",\n\t\t\t\t\t\tscrollSnapType: \"inline mandatory\",\n\t\t\t\t\t\tscrollPaddingInline: \"var(--ui-carousel-padding, 0px)\",\n\t\t\t\t\t\t\"-webkit-overflow-scrolling\": \"touch\",\n\t\t\t\t\t}),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", raw({ scrollBehavior: \"auto\" })),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The carousel's slide row: a `<div>` laying its {@link Carousel.Slide}\n * children out in one inline row, gapped by `--ui-carousel-gap` and padded by\n * `--ui-carousel-padding` so the first and last slide can still center.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the track's markup.\n * @example\n * <Carousel.Track>\n * \t<Carousel.Slide>{firstSlide}</Carousel.Slide>\n * \t<Carousel.Slide>{secondSlide}</Carousel.Slide>\n * </Carousel.Track>\n */\nCarousel.Track = function CarouselTrack(handle: Handle<Carousel.TrackProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"track\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tgap(\"var(--ui-carousel-gap, 1rem)\"),\n\t\t\t\t\tpi(\"var(--ui-carousel-padding, 0px)\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A single slide: a `<div>` held at `--ui-carousel-slide-size` along the\n * inline axis, snapping to its inline-start edge so the viewport settles on a\n * slide boundary.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the slide's markup.\n * @example\n * <Carousel.Slide><img src={photo.src} alt={photo.alt} /></Carousel.Slide>\n */\nCarousel.Slide = function CarouselSlide(handle: Handle<Carousel.SlideProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"slide\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_SLIDE_ROLE }),\n\t\t\t\t\tgrow(0),\n\t\t\t\t\tshrink(0),\n\t\t\t\t\t/**\n\t\t\t\t\t * The slide snaps to the viewport's start edge and leaves the scroll free to pass it:\n\t\t\t\t\t * `scroll-snap-stop: always` clamps programmatic scrolls too, so every dot would move\n\t\t\t\t\t * one slide and none would reach the slide it names.\n\t\t\t\t\t */\n\t\t\t\t\traw({\n\t\t\t\t\t\tflexBasis: \"var(--ui-carousel-slide-size, 18rem)\",\n\t\t\t\t\t\tscrollSnapAlign: \"start\",\n\t\t\t\t\t}),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The carousel's control row: a `<div>` laying {@link Carousel.Previous} and\n * {@link Carousel.Next} out as an end-aligned, vertically centered row.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the control row's markup.\n * @example\n * <Carousel.Controls>\n * \t<Carousel.Previous commandfor=\"gallery-viewport\" aria-label={t(\"gallery.previous\")} />\n * \t<Carousel.Next commandfor=\"gallery-viewport\" aria-label={t(\"gallery.next\")} />\n * </Carousel.Controls>\n */\nCarousel.Controls = function CarouselControls(handle: Handle<Carousel.ControlsProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"controls\"\n\t\t\t\tmix={[flex(), items(\"center\"), gap(2), justify(\"end\"), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A static control scrolling {@link Carousel.Viewport} named by `commandfor` back\n * one slide when a hydrated `carouselControls()` mixin handles `\"--ui-prev\"`; custom\n * `children` replacing the chevron still need their own `aria-label`.\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 * <Carousel.Previous commandfor=\"gallery-viewport\" aria-label={t(\"gallery.previous\")} />\n */\nCarousel.Previous = function CarouselPrevious(handle: Handle<Carousel.PreviousProps>) {\n\treturn () => {\n\t\tlet { variant, color, size, command, children, mix, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_CONTROL_VARIANT;\n\t\tlet resolvedColor = color ?? DEFAULT_CONTROL_COLOR;\n\t\tlet resolvedSize = size ?? DEFAULT_CONTROL_SIZE;\n\t\tlet resolvedCommand = command ?? DEFAULT_PREVIOUS_COMMAND;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"button\"\n\t\t\t\tvariant={resolvedVariant}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tsize={resolvedSize}\n\t\t\t\tcommand={resolvedCommand}\n\t\t\t\tdata-slot=\"previous\"\n\t\t\t\tmix={[minIs(0), when(\"& > svg\", [is(4), bs(4)]), mix]}\n\t\t\t>\n\t\t\t\t{children ?? <ChevronLeftIcon />}\n\t\t\t</Button>\n\t\t);\n\t};\n};\n\n/**\n * A static control scrolling {@link Carousel.Viewport} named by `commandfor` forward\n * one slide when a hydrated `carouselControls()` mixin handles `\"--ui-next\"`; custom\n * `children` replacing the chevron still need their own `aria-label`.\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 * <Carousel.Next commandfor=\"gallery-viewport\" aria-label={t(\"gallery.next\")} />\n */\nCarousel.Next = function CarouselNext(handle: Handle<Carousel.NextProps>) {\n\treturn () => {\n\t\tlet { variant, color, size, command, children, mix, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_CONTROL_VARIANT;\n\t\tlet resolvedColor = color ?? DEFAULT_CONTROL_COLOR;\n\t\tlet resolvedSize = size ?? DEFAULT_CONTROL_SIZE;\n\t\tlet resolvedCommand = command ?? DEFAULT_NEXT_COMMAND;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"button\"\n\t\t\t\tvariant={resolvedVariant}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tsize={resolvedSize}\n\t\t\t\tcommand={resolvedCommand}\n\t\t\t\tdata-slot=\"next\"\n\t\t\t\tmix={[minIs(0), when(\"& > svg\", [is(4), bs(4)]), mix]}\n\t\t\t>\n\t\t\t\t{children ?? <ChevronRightIcon />}\n\t\t\t</Button>\n\t\t);\n\t};\n};\n"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chart",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Chart"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "chart.tsx",
|
|
10
|
+
"content": "/**\n * The `Chart` namespace's compound parts, covering Cartesian series\n * ({@link Chart}, {@link Chart.Line}, {@link Chart.Area}, {@link Chart.Bar})\n * and the independent {@link Chart.Pie} root, each pairing with\n * {@link Chart.Legend} for a script-free series switcher and\n * {@link Chart.Tooltip} for a richer hover surface.\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 {\n\tbg,\n\tfg,\n\tfill,\n\tfillOpacity,\n\toutline,\n\tstroke,\n\tstrokeLinecap,\n\tstrokeLinejoin,\n\tstrokeWidth,\n\tvectorEffect,\n} from \"@sdxc/u/color\";\nimport { opacity, rounded, shadow, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { cursor, pointerEvents, raw, userSelect } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tblock,\n\tflex,\n\tflexWrap,\n\tgap,\n\tinlineBlock,\n\tinlineFlex,\n\titems,\n\trelative,\n\tshrink,\n} from \"@sdxc/u/layout\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, pb, pi } from \"@sdxc/u/size\";\nimport { z } from \"@sdxc/u/stacking\";\nimport { focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { scaleProperty, translateProperty } from \"@sdxc/u/transform\";\nimport { fontSize, leading, nowrap, tabularNums, textDecoration, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport type { Point } from \"@sdxc/ui/utils\";\nimport type { PieAngles } from \"@sdxc/ui/utils\";\n\nimport { durations, easings } from \"@sdxc/ui/animations\";\nimport { CHART_COLOR_SLOT_COUNT, chartPalette } from \"@sdxc/ui/styles\";\nimport { legendToggle } from \"@sdxc/ui/styles\";\nimport { computeMarkerIndices } from \"@sdxc/ui/utils\";\nimport { arcPath, areaPath, linePath } from \"@sdxc/ui/utils\";\nimport { bandScale, linearScale, pieAngles, ticks } from \"@sdxc/ui/utils\";\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\n/** Categorical color {@link Chart.Line} falls back to when `color` is omitted. */\nconst DEFAULT_LINE_COLOR: Chart.Color = 1;\n\n/** Categorical color {@link Chart.Area} falls back to when `color` is omitted. */\nconst DEFAULT_AREA_COLOR: Chart.Color = 1;\n\n/**\n * `yDomain` value {@link Chart.Area} falls back to closing a series' filled\n * region down (or up) to when `baseline` is omitted.\n */\nconst DEFAULT_AREA_BASELINE = 0;\n\n/**\n * Approximate marker count {@link Chart.Line} and {@link Chart.Area} fall\n * back to for `markerCount`, giving keyboard and screen-reader users a\n * representative spread of stops instead of one per raw sample.\n */\nconst DEFAULT_MARKER_COUNT = 6;\n\n/**\n * `aria-hidden=\"true\"` applied to {@link Chart.Line}'s and {@link Chart.Area}'s\n * plotted `<path>` through {@link attrs} — a series' accessible name and\n * hover tooltip live on its point markers instead.\n */\nconst DEFAULT_PATH_ARIA_HIDDEN = \"true\";\n\n/**\n * Pixel distance from center to every wedge's inner edge {@link Chart.Pie}\n * falls back to when `innerRadius` is omitted — a solid pie reaching the\n * center, with no donut hole.\n */\nconst DEFAULT_PIE_INNER_RADIUS = 0;\n\n/**\n * {@link Chart.Color} {@link Chart.Tooltip.Swatch} falls back to when\n * `color` is omitted, matching {@link DEFAULT_LINE_COLOR}'s own default.\n */\nconst DEFAULT_SWATCH_COLOR: Chart.Color = 1;\n\n/**\n * `aria-hidden` value applied to {@link Chart.Tooltip} through\n * {@link attrs} unless overridden — the surface only restates the label,\n * value, and color a hovered point's native `<title>` already carries.\n */\nconst DEFAULT_TOOLTIP_ARIA_HIDDEN = \"true\";\n\n/** Approximate gridline count {@link Chart.Bar} falls back to when `tickCount` is omitted. */\nconst DEFAULT_BAR_TICK_COUNT = 5;\n\n/** Fraction of each category band reserved as a gap from its neighbors, {@link Chart.Bar} falls back to when `categoryGap` is omitted. */\nconst DEFAULT_CATEGORY_GAP = 0.2;\n\n/**\n * Fraction of a category's own band reserved as a gap between its series'\n * bars, {@link Chart.Bar} falls back to when `seriesGap` is omitted —\n * packing bars edge to edge, since most rows plot a single series.\n */\nconst DEFAULT_SERIES_GAP = 0;\n\n/**\n * `role=\"group\"` applied to {@link Chart.Legend}'s host through\n * {@link attrs} unless a consumer supplies its own `role`, announcing the\n * series switcher as a related set of controls to assistive technology.\n */\nconst DEFAULT_LEGEND_ROLE = \"group\";\n\n/**\n * `defaultChecked` {@link Chart.LegendItemProps} falls back to when\n * omitted, so a series renders visible until a reader explicitly hides it.\n */\nconst DEFAULT_LEGEND_ITEM_CHECKED = true;\n\n/**\n * Renders the series switcher's host: a `role=\"group\"` `<div>` laying its\n * {@link Chart.Legend.Item} children in a wrapping row. Must render as a\n * later sibling of the chart root, with items in that chart's series order.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the legend's markup.\n * @example\n * <Chart width={480} height={240} xDomain={[0, 11]} yDomain={[0, 1000]} aria-label={t(\"chart.revenue.label\")}>\n * \t<Chart.Line points={points} color={1} />\n * </Chart>\n * <Chart.Legend aria-label={t(\"chart.legend\")}>\n * \t<Chart.Legend.Item color={1}>{t(\"chart.series.revenue\")}</Chart.Legend.Item>\n * </Chart.Legend>\n */\nfunction ChartLegend(handle: Handle<Chart.LegendProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Chart.Legend: needs an \"aria-label\" or \"aria-labelledby\" identifying this legend for assistive technology.',\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"legend\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_LEGEND_ROLE }),\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexWrap(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(4),\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 series' entry: a native `<label>` wrapping a visually hidden,\n * `defaultChecked` checkbox, a `data-color` swatch matching its series, and\n * its name — unchecking hides the series via the paired chart root's `css()`.\n *\n * @param handle Runtime handle carrying the host `<label>`'s props, plus\n * the underlying `<input>`'s own attributes and per-part `swatch` styling.\n * @returns The render function producing the item's markup.\n * @example\n * <Chart.Legend.Item color={1}>{t(\"chart.series.revenue\")}</Chart.Legend.Item>\n * @example\n * <Chart.Legend.Item color={3} defaultChecked={false}>\n * \t{t(\"chart.series.archived\")}\n * </Chart.Legend.Item>\n */\nfunction ChartLegendItem(handle: Handle<Chart.LegendItemProps>) {\n\treturn () => {\n\t\tlet { color, defaultChecked, children, parts, mix, ...rest } = handle.props;\n\t\tlet resolvedChecked = defaultChecked ?? DEFAULT_LEGEND_ITEM_CHECKED;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\tdata-slot=\"legend-item\"\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\twhen(\"&:has(input:focus-visible)\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\tgap(2),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\ttransition(\"opacity, color\"),\n\t\t\t\t\tuserSelect(),\n\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\tleading(1.25),\n\t\t\t\t\twhen(\"&:has(input:not(:checked))\", [opacity(50), textDecoration(\"line-through\")]),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tdata-slot=\"swatch\"\n\t\t\t\t\tdata-color={String(color)}\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tchartPalette(\"color\"),\n\t\t\t\t\t\tinlineBlock(),\n\t\t\t\t\t\tis(2.5),\n\t\t\t\t\t\tbs(2.5),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\tbg(\"currentColor\"),\n\t\t\t\t\t\tparts?.swatch,\n\t\t\t\t\t]}\n\t\t\t\t/>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tdefaultChecked={resolvedChecked}\n\t\t\t\t\t{...rest}\n\t\t\t\t\tmix={[visuallyHidden(), mix]}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</label>\n\t\t);\n\t};\n}\n\nChartLegend.Item = ChartLegendItem;\n\n/**\n * Prop and context types for {@link Chart} and its {@link Chart.Line},\n * {@link Chart.Area}, {@link Chart.Pie}, and {@link Chart.Legend} compound\n * parts.\n */\nexport namespace Chart {\n\t/**\n\t * Props accepted by {@link Chart.Legend}. Every native `<div>` attribute is\n\t * available unchanged, so `aria-label`, `aria-labelledby`, and `mix` style\n\t * the host exactly as they would on a bare grouping `<div>`.\n\t */\n\texport interface LegendProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Per-part styling for the color swatch {@link Chart.Legend.Item}\n\t * composes internally alongside its own host `<input>`.\n\t */\n\texport interface LegendItemPartsProps {\n\t\t/** Styling for the small swatch identifying this series' color. */\n\t\tswatch?: TagProps<\"span\">[\"mix\"];\n\t}\n\n\t/**\n\t * Props accepted by {@link Chart.Legend.Item}. Every native `<input>`\n\t * attribute is available unchanged — aside from `type`, always\n\t * `\"checkbox\"` — and `mix` styles that same `<input>` host.\n\t */\n\texport interface LegendItemProps extends Omit<TagProps<\"input\">, \"type\" | \"role\"> {\n\t\t/** ARIA role override, restricted to what a checkbox input may carry. */\n\t\trole?: \"checkbox\" | \"button\" | \"menuitemcheckbox\" | \"option\" | \"switch\";\n\t\t/**\n\t\t * This series' categorical color — the identical {@link Color} its\n\t\t * matching plotted series was given as its own `color`, so this\n\t\t * swatch always matches the series it labels.\n\t\t */\n\t\tcolor: Color;\n\t\t/**\n\t\t * The series' visible name, read aloud as this checkbox's\n\t\t * accessible name through native `<label>` association. Required —\n\t\t * this module ships no built-in copy of its own.\n\t\t */\n\t\tchildren: RemixNode;\n\t\t/** Per-part styling for this item's internally composed swatch. */\n\t\tparts?: LegendItemPartsProps;\n\t}\n\n\t/**\n\t * Value {@link Chart} stores in component context: the pixel dimensions of\n\t * its coordinate space and the data domains mapped across them, shared with\n\t * every nested series compound part.\n\t */\n\texport interface Context {\n\t\t/** Pixel width of the coordinate space, matching {@link Props.width}. */\n\t\twidth: number;\n\t\t/** Pixel height of the coordinate space, matching {@link Props.height}. */\n\t\theight: number;\n\t\t/** `[start, end]` domain bounds mapped across `width`, matching {@link Props.xDomain}. */\n\t\txDomain: readonly [number, number];\n\t\t/** `[start, end]` domain bounds mapped across `height`, matching {@link Props.yDomain}. */\n\t\tyDomain: readonly [number, number];\n\t}\n\n\t/**\n\t * Props accepted by {@link Chart}. Every native `<svg>` attribute still\n\t * applies except `viewBox`, `width`, and `height`, computed from the props\n\t * of the same name below so every nested series' pixel math matches.\n\t */\n\texport interface Props extends Omit<TagProps<\"svg\">, \"viewBox\" | \"width\" | \"height\"> {\n\t\t/**\n\t\t * Pixel width of the chart's internal coordinate space — the value every\n\t\t * nested series' `x` positions are mapped onto. The `<svg>` renders at its\n\t\t * container's full size, scaling this space while preserving aspect ratio.\n\t\t */\n\t\twidth: number;\n\t\t/**\n\t\t * Pixel height of the chart's internal coordinate space — the value\n\t\t * every nested series' `y` positions are mapped onto.\n\t\t */\n\t\theight: number;\n\t\t/**\n\t\t * `[start, end]` bounds of every nested series' horizontal data\n\t\t * values, mapped across `width` and shared through context so every\n\t\t * series lines up on the same horizontal scale.\n\t\t */\n\t\txDomain: readonly [number, number];\n\t\t/**\n\t\t * `[start, end]` bounds of every nested series' vertical data values, mapped\n\t\t * across `height`. `start` maps to the coordinate space's bottom edge and\n\t\t * `end` to its top, matching a value axis growing upward against SVG's `y`.\n\t\t */\n\t\tyDomain: readonly [number, number];\n\t}\n\n\t/**\n\t * One categorical color a {@link Chart.Line}, {@link Chart.Area}, or any\n\t * further series picks up through the `--ui-chart-1` through `--ui-chart-8`\n\t * semantic variables, rotating a fixed palette across several series.\n\t */\n\texport type Color = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;\n\n\t/**\n\t * One data point plotted by {@link Chart.Line}, in data space — the\n\t * values a consumer's own domain uses, not yet mapped to pixels.\n\t */\n\texport interface LinePoint {\n\t\t/** Horizontal data value, mapped across the ancestor {@link Chart}'s `xDomain`. */\n\t\tx: number;\n\t\t/** Vertical data value, mapped across the ancestor {@link Chart}'s `yDomain`. */\n\t\ty: number;\n\t\t/**\n\t\t * Accessible name and hover tooltip text for this point, read by the\n\t\t * native `<title>` nested in its marker when the point falls among the\n\t\t * representative spread {@link Chart.Line} renders a marker for.\n\t\t */\n\t\tlabel: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link Chart.Line}. Extends every native `<g>`\n\t * attribute except `children` and `points`, redefined below with this\n\t * series' own data-space shape in place of the native `<polyline>` attribute.\n\t */\n\texport interface LineProps extends Omit<TagProps<\"g\">, \"children\" | \"points\"> {\n\t\t/**\n\t\t * The series' data points, in draw order along `x`. The plotted path\n\t\t * connects every point given here; the accessible markers render on\n\t\t * only a representative spread of them, chosen through `markerCount`.\n\t\t */\n\t\tpoints: readonly LinePoint[];\n\t\t/** Categorical color. Defaults to {@link DEFAULT_LINE_COLOR}. */\n\t\tcolor?: Color;\n\t\t/**\n\t\t * Approximate number of accessible, hoverable markers placed along\n\t\t * `points`. Each marker snaps to the point closest to one of this many\n\t\t * evenly spread \"nice\" values across the ancestor {@link Chart}'s `xDomain`.\n\t\t *\n\t\t * @default {@link DEFAULT_MARKER_COUNT}\n\t\t */\n\t\tmarkerCount?: number;\n\t\t/**\n\t\t * Per-part styling for the plotted `path` and each point `marker`,\n\t\t * layered after each part's own built-in styling. Use the `mix` prop\n\t\t * instead to style the series' outer host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to the stroked `<path>`. */\n\t\t\tpath?: TagProps<\"path\">[\"mix\"];\n\t\t\t/** Additional mixin(s) applied to each point's `<circle>` marker. */\n\t\t\tmarker?: TagProps<\"circle\">[\"mix\"];\n\t\t};\n\t}\n\n\t/**\n\t * One data point plotted by {@link Chart.Area}, in data space — the\n\t * values a consumer's own domain uses, not yet mapped to pixels.\n\t */\n\texport interface AreaPoint {\n\t\t/** Horizontal data value, mapped across the ancestor {@link Chart}'s `xDomain`. */\n\t\tx: number;\n\t\t/** Vertical data value, mapped across the ancestor {@link Chart}'s `yDomain`. */\n\t\ty: number;\n\t\t/**\n\t\t * Accessible name and hover tooltip text for this point, read by the\n\t\t * native `<title>` nested in its marker when the point falls among the\n\t\t * representative spread {@link Chart.Area} renders a marker for.\n\t\t */\n\t\tlabel: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link Chart.Area}. Extends every native `<g>`\n\t * attribute except `children` and `points`, redefined below with this\n\t * series' own data-space shape in place of the native `<polyline>` attribute.\n\t */\n\texport interface AreaProps extends Omit<TagProps<\"g\">, \"children\" | \"points\"> {\n\t\t/**\n\t\t * The series' data points, in draw order along `x`. The filled region\n\t\t * traces every point given here before closing down to `baseline`; markers\n\t\t * render on a representative spread of them, chosen through `markerCount`.\n\t\t */\n\t\tpoints: readonly AreaPoint[];\n\t\t/** Categorical color. Defaults to {@link DEFAULT_AREA_COLOR}. */\n\t\tcolor?: Color;\n\t\t/**\n\t\t * The `yDomain` value the filled region closes down (or up) to —\n\t\t * typically the value axis' zero line. Defaults to\n\t\t * {@link DEFAULT_AREA_BASELINE}.\n\t\t */\n\t\tbaseline?: number;\n\t\t/**\n\t\t * Approximate number of accessible, hoverable markers placed along\n\t\t * `points`. Each marker snaps to the point closest to one of this many\n\t\t * evenly spread \"nice\" values across the ancestor {@link Chart}'s `xDomain`.\n\t\t *\n\t\t * @default {@link DEFAULT_MARKER_COUNT}\n\t\t */\n\t\tmarkerCount?: number;\n\t\t/**\n\t\t * Per-part styling for the filled `path` and each point `marker`,\n\t\t * layered after each part's own built-in styling. Use the `mix` prop\n\t\t * instead to style the series' outer host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to the filled `<path>`. */\n\t\t\tpath?: TagProps<\"path\">[\"mix\"];\n\t\t\t/** Additional mixin(s) applied to each point's `<circle>` marker. */\n\t\t\tmarker?: TagProps<\"circle\">[\"mix\"];\n\t\t};\n\t}\n\n\t/**\n\t * One wedge's input for {@link Chart.Pie}: a magnitude and its required\n\t * accessible label. {@link pieAngles} turns `value` into a proportional\n\t * angle span, treating a negative value as zero and an all-zero total as even.\n\t */\n\texport interface PieDatum {\n\t\t/** The magnitude this wedge represents. */\n\t\tvalue: number;\n\t\t/**\n\t\t * Accessible name and hover tooltip text for this wedge, read by the\n\t\t * native `<title>` nested inside it — required, since a wedge with no\n\t\t * label has nothing for assistive technology to announce.\n\t\t */\n\t\tlabel: string;\n\t\t/**\n\t\t * Categorical color for this wedge, defaulting to its position in `data`\n\t\t * modulo the palette's slot count. Set explicitly to pin a category's\n\t\t * color across several charts or a paired legend.\n\t\t */\n\t\tcolor?: Color;\n\t}\n\n\t/**\n\t * Props accepted by {@link Chart.Pie}. Every native `<svg>` attribute still\n\t * applies except `children`, `viewBox`, `width`, and `height` — the latter\n\t * two take plain numbers for this component's own math, computing `viewBox`.\n\t */\n\texport interface PieProps\n\t\textends PieAngles.Options, Omit<TagProps<\"svg\">, \"children\" | \"viewBox\" | \"width\" | \"height\"> {\n\t\t/**\n\t\t * The wedges to draw, in draw order. Each entry's position in this\n\t\t * list picks its default color when its own `color` is omitted.\n\t\t */\n\t\tdata: readonly PieDatum[];\n\t\t/**\n\t\t * Pixel width of the chart's internal coordinate space that `viewBox` maps\n\t\t * onto. The rendered `<svg>` fills `100%` of the host's own inline size,\n\t\t * scaled to fit while preserving this aspect ratio against `height`.\n\t\t */\n\t\twidth: number;\n\t\t/**\n\t\t * Pixel height of the chart's internal coordinate space, on the same\n\t\t * terms as `width`.\n\t\t */\n\t\theight: number;\n\t\t/**\n\t\t * Pixel distance from center to every wedge's inner edge, in the same\n\t\t * coordinate space as `width`/`height`. A positive value smaller than the\n\t\t * chart's outer radius produces a donut with a hole that size.\n\t\t *\n\t\t * @default {@link DEFAULT_PIE_INNER_RADIUS}\n\t\t */\n\t\tinnerRadius?: number;\n\t\t/**\n\t\t * Per-part styling for every wedge `segment`, layered after its own\n\t\t * built-in styling. Use the `mix` prop instead to style the chart's\n\t\t * outer host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to every wedge's `<path>`. */\n\t\t\tsegment?: TagProps<\"path\">[\"mix\"];\n\t\t};\n\t}\n\n\t/**\n\t * Prop types for {@link Chart.Tooltip} and its own compound parts.\n\t */\n\texport namespace Tooltip {\n\t\t/**\n\t\t * Every native `<div>` attribute, plus the `mix` passthrough. A\n\t\t * `chartTooltip()` mixin writes this host's position and open state\n\t\t * directly at runtime, as CSS custom properties and a `data-open` attribute.\n\t\t */\n\t\texport interface Props extends TagProps<\"div\"> {}\n\n\t\t/**\n\t\t * Props accepted by {@link Chart.Tooltip.Swatch}.\n\t\t */\n\t\texport interface SwatchProps extends TagProps<\"span\"> {\n\t\t\t/**\n\t\t\t * Categorical color matching the hovered point or wedge's own\n\t\t\t * series — the same {@link Chart.Color} any series or {@link Chart.Pie}\n\t\t\t * wedge renders with. Defaults to {@link DEFAULT_SWATCH_COLOR}.\n\t\t\t */\n\t\t\tcolor?: Color;\n\t\t}\n\n\t\t/**\n\t\t * Every native `<span>` attribute, plus the `mix` passthrough.\n\t\t */\n\t\texport interface LabelProps extends TagProps<\"span\"> {}\n\n\t\t/**\n\t\t * Every native `<span>` attribute, plus the `mix` passthrough.\n\t\t */\n\t\texport interface ValueProps extends TagProps<\"span\"> {}\n\t}\n\n\t/**\n\t * A single series' plotted value at one {@link Chart.BarRow}'s category.\n\t */\n\texport interface BarValue {\n\t\t/** Numeric magnitude this bar represents, mapped across {@link Chart.BarProps.domain}. */\n\t\tvalue: number;\n\t\t/**\n\t\t * Accessible name and hover tooltip text for this bar, read by the\n\t\t * native `<title>` nested inside it — typically a formatted description of\n\t\t * the category, series, and value together (e.g. `\"March revenue: $1,240\"`).\n\t\t */\n\t\tlabel: string;\n\t}\n\n\t/**\n\t * One category's row of plotted values, one {@link Chart.BarValue} per key\n\t * listed in {@link Chart.BarProps.series}.\n\t */\n\texport interface BarRow {\n\t\t/**\n\t\t * Category key positioning this row's bars along the shared band axis.\n\t\t * Keep every row's category unique — a repeated category shares its first\n\t\t * occurrence's band position, overlapping its bars there.\n\t\t */\n\t\tcategory: string;\n\t\t/**\n\t\t * This row's value for every key listed in {@link Chart.BarProps.series},\n\t\t * keyed the same way. A row missing one of those keys renders no bar\n\t\t * for that series at this category.\n\t\t */\n\t\tvalues: Readonly<Record<string, BarValue>>;\n\t}\n\n\t/**\n\t * Props accepted by {@link Chart.Bar}. Every native `<svg>` attribute still\n\t * applies except `children`, `viewBox`, `width`, and `height` — the latter\n\t * two take plain numbers for this component's own math, computing `viewBox`.\n\t */\n\texport interface BarProps extends Omit<\n\t\tTagProps<\"svg\">,\n\t\t\"children\" | \"viewBox\" | \"width\" | \"height\"\n\t> {\n\t\t/** Rows to plot, one band per row along the category axis, in draw order. */\n\t\tdata: readonly BarRow[];\n\t\t/**\n\t\t * Ordered series keys plotted within every row's band. A key's position in\n\t\t * this list is both the stable index stamped onto `data-series-index` and\n\t\t * its slot in the `--ui-chart-1`–`--ui-chart-8` palette, wrapping past it.\n\t\t */\n\t\tseries: readonly string[];\n\t\t/**\n\t\t * Pixel width of the chart's internal coordinate space that `viewBox` maps\n\t\t * onto. The rendered `<svg>` fills `100%` of the host's own inline size,\n\t\t * scaled to fit while preserving this aspect ratio against `height`.\n\t\t */\n\t\twidth: number;\n\t\t/**\n\t\t * Pixel height of the chart's internal coordinate space, on the same\n\t\t * terms as `width`.\n\t\t */\n\t\theight: number;\n\t\t/**\n\t\t * `[start, end]` bounds of every bar's value, mapped across `height`.\n\t\t * `start` maps to the bottom edge and `end` to the top, matching the same\n\t\t * upward-value convention {@link Chart.Props.yDomain} uses against SVG's `y`.\n\t\t */\n\t\tdomain: readonly [number, number];\n\t\t/** Approximate number of horizontal gridlines spanning `domain`. Defaults to {@link DEFAULT_BAR_TICK_COUNT}. */\n\t\ttickCount?: number;\n\t\t/** Fraction of each category band reserved as a gap from its neighbors. Defaults to {@link DEFAULT_CATEGORY_GAP}. */\n\t\tcategoryGap?: number;\n\t\t/**\n\t\t * Fraction of each category's own band reserved as a gap between its\n\t\t * series' bars — most bar charts plot a single series per category, with\n\t\t * no neighboring bar to gap against.\n\t\t *\n\t\t * @default {@link DEFAULT_SERIES_GAP}\n\t\t */\n\t\tseriesGap?: number;\n\t\t/**\n\t\t * Per-part styling for the gridlines and bars, layered after each\n\t\t * part's own built-in styling. Use the `mix` prop instead to style\n\t\t * the chart's outer host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to each horizontal gridline. */\n\t\t\tgridline?: TagProps<\"line\">[\"mix\"];\n\t\t\t/** Additional mixin(s) applied to each plotted bar. */\n\t\t\tbar?: TagProps<\"rect\">[\"mix\"];\n\t\t};\n\t}\n}\n\n/**\n * Renders a chart's coordinate space: a responsive `<svg>` whose `viewBox`\n * comes from `width`/`height`, shared via context so nested series share one\n * scale. A paired {@link Chart.Legend} must render as this root's later sibling.\n *\n * @param handle Runtime handle carrying the host `<svg>`'s props and providing {@link Chart.Context}.\n * @returns The render function producing the chart's coordinate space.\n * @example\n * <Chart width={480} height={240} xDomain={[0, 11]} yDomain={[0, 1000]} aria-label={t(\"chart.revenue.label\")}>\n * \t<Chart.Line\n * \t\tpoints={months.map((month) => ({\n * \t\t\tx: month.index,\n * \t\t\ty: month.revenue,\n * \t\t\tlabel: t(\"chart.revenue.point\", { month: month.name, amount: month.revenue }),\n * \t\t}))}\n * \t/>\n * </Chart>\n * <Chart.Legend aria-label={t(\"chart.legend\")}>\n * \t<Chart.Legend.Item color={1}>{t(\"chart.series.revenue\")}</Chart.Legend.Item>\n * </Chart.Legend>\n */\nexport function Chart(handle: Handle<Chart.Props, Chart.Context>) {\n\treturn () => {\n\t\tlet { width, height, xDomain, yDomain, mix, ...rest } = handle.props;\n\n\t\thandle.context.set({ width, height, xDomain, yDomain });\n\n\t\treturn (\n\t\t\t<svg\n\t\t\t\tviewBox={`0 0 ${width} ${height}`}\n\t\t\t\tpreserveAspectRatio=\"xMidYMid meet\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={[legendToggle(), block(), is(\"full\"), bs(\"auto\"), mix]}\n\t\t\t/>\n\t\t);\n\t};\n}\n\nChart.Legend = ChartLegend;\n\n/**\n * Renders one series' representative point markers: a small focusable\n * `<circle>` at each of `markerIndices`' scaled positions, nested with a\n * `<title>` carrying that point's own `label`.\n *\n * @param points The series' original data points, read for each marker's label.\n * @param scaledPoints Each point's already-scaled pixel position, in the same order as `points`.\n * @param markerIndices Which of `points`' indices to render a marker for.\n * @param markerMix Additional mixin(s) layered after each marker's own built-in styling.\n * @returns The rendered `<circle>` markers.\n */\nfunction renderChartMarkers(\n\tpoints: readonly { label: string }[],\n\tscaledPoints: readonly Point[],\n\tmarkerIndices: readonly number[],\n\tmarkerMix: TagProps<\"circle\">[\"mix\"],\n): RemixNode {\n\treturn markerIndices.map((index) => {\n\t\tlet point = points[index];\n\t\tlet position = scaledPoints[index];\n\n\t\tif (point === undefined || position === undefined) return null;\n\n\t\treturn (\n\t\t\t<circle\n\t\t\t\tkey={index}\n\t\t\t\tcx={position.x}\n\t\t\t\tcy={position.y}\n\t\t\t\ttabIndex={0}\n\t\t\t\trole=\"img\"\n\t\t\t\tmix={[\n\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\tfill(\"currentColor\"),\n\t\t\t\t\traw({ r: \"var(--ui-chart-point-radius, 0.1875rem)\" }),\n\t\t\t\t\tmarkerMix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t<title>{point.label}</title>\n\t\t\t</circle>\n\t\t);\n\t});\n}\n\n/**\n * Renders a line series: a stroked, `aria-hidden` `<path>` connecting\n * `points` via {@link linearScale} and {@link linePath}, plus a focusable\n * marker with a `<title>`, sampled via {@link ticks} for manageable density.\n *\n * @param handle Runtime handle carrying the host `<g>`'s props.\n * @returns The render function producing the series' markup.\n * @example\n * <Chart.Line\n * \tcolor={2}\n * \tpoints={[\n * \t\t{ x: 0, y: 12, label: t(\"chart.point\", { x: 0, y: 12 }) },\n * \t\t{ x: 1, y: 18, label: t(\"chart.point\", { x: 1, y: 18 }) },\n * \t\t{ x: 2, y: 9, label: t(\"chart.point\", { x: 2, y: 9 }) },\n * \t]}\n * />\n * @example\n * <Chart.Line points={points} markerCount={3} parts={{ path: css({ strokeDasharray: \"4 4\" }) }} />\n */\nChart.Line = function ChartLine(handle: Handle<Chart.LineProps>) {\n\treturn () => {\n\t\tlet { points, color, markerCount, parts, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Chart);\n\t\tlet resolvedColor = color ?? DEFAULT_LINE_COLOR;\n\t\tlet resolvedMarkerCount = markerCount ?? DEFAULT_MARKER_COUNT;\n\n\t\tlet x = linearScale(context.xDomain, [0, context.width]);\n\t\tlet y = linearScale(context.yDomain, [context.height, 0]);\n\t\tlet scaledPoints: Point[] = points.map((point) => ({ x: x(point.x), y: y(point.y) }));\n\t\tlet d = linePath(scaledPoints);\n\n\t\tlet markerIndices = computeMarkerIndices(points, context.xDomain, resolvedMarkerCount);\n\n\t\treturn (\n\t\t\t<g data-color={String(resolvedColor)} {...rest} mix={[chartPalette(\"color\"), mix]}>\n\t\t\t\t<path\n\t\t\t\t\td={d}\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_PATH_ARIA_HIDDEN }),\n\t\t\t\t\t\tfill(\"none\"),\n\t\t\t\t\t\tstroke(\"currentColor\"),\n\t\t\t\t\t\tstrokeWidth(\"var(--ui-chart-line-width, 2px)\"),\n\t\t\t\t\t\tstrokeLinejoin(\"round\"),\n\t\t\t\t\t\tstrokeLinecap(\"round\"),\n\t\t\t\t\t\tparts?.path,\n\t\t\t\t\t]}\n\t\t\t\t/>\n\t\t\t\t{renderChartMarkers(points, scaledPoints, markerIndices, parts?.marker)}\n\t\t\t</g>\n\t\t);\n\t};\n};\n\n/**\n * Renders the tooltip's floating host: an absolutely positioned `<div>`\n * reading position and `data-open` state a `chartTooltip()` mixin writes\n * onto it. Visibility requires pairing that mixin with the chart root.\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 * <div style={{ position: \"relative\" }} mix={chartTooltip()}>\n * \t<Chart width={480} height={240} xDomain={[0, 11]} yDomain={[0, 1000]} aria-label={t(\"chart.revenue.label\")}>\n * \t\t<Chart.Line points={points} />\n * \t</Chart>\n * \t<Chart.Tooltip>\n * \t\t<Chart.Tooltip.Swatch color={2} />\n * \t\t<Chart.Tooltip.Label>{t(\"chart.months.march\")}</Chart.Tooltip.Label>\n * \t\t<Chart.Tooltip.Value>42</Chart.Tooltip.Value>\n * \t</Chart.Tooltip>\n * </div>\n */\nfunction ChartTooltip(handle: Handle<Chart.Tooltip.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"tooltip\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_TOOLTIP_ARIA_HIDDEN }),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(2),\n\t\t\t\t\tfg(\"neutral.onSolid\"),\n\t\t\t\t\tbg(\"neutral.solid\"),\n\t\t\t\t\tshadow(\"md\"),\n\t\t\t\t\tz(10),\n\t\t\t\t\tgap(1.5),\n\t\t\t\t\tpb(1.5),\n\t\t\t\t\tnowrap(),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\topacity(0),\n\t\t\t\t\ttransition(\"opacity, scale\", { duration: durations.fast, easing: easings.standard }),\n\t\t\t\t\twhen(\"&[data-open]\", [opacity(100), scaleProperty(1)]),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\tscaleProperty(\"none\"),\n\t\t\t\t\t\traw({ transitionProperty: \"opacity\" }),\n\t\t\t\t\t]),\n\t\t\t\t\traw({\n\t\t\t\t\t\tleft: \"var(--ui-chart-tooltip-x, 0px)\",\n\t\t\t\t\t\ttop: \"var(--ui-chart-tooltip-y, 0px)\",\n\t\t\t\t\t\tfontSize: \"0.8125rem\",\n\t\t\t\t\t}),\n\t\t\t\t\ttranslateProperty(\"-50% calc(-100% - var(--ui-chart-tooltip-gap, 0.5rem))\"),\n\t\t\t\t\tleading(1.2),\n\t\t\t\t\tpointerEvents(),\n\t\t\t\t\tscaleProperty(0.95),\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 small circular color chip identifying the tooltip's current\n * point or wedge: a native `<span>` colored through the `data-color`\n * attribute, on the same eight-slot palette every series already renders with.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the swatch's markup.\n * @example\n * <Chart.Tooltip.Swatch color={2} />\n */\nChartTooltip.Swatch = function ChartTooltipSwatch(handle: Handle<Chart.Tooltip.SwatchProps>) {\n\treturn () => {\n\t\tlet { color, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_SWATCH_COLOR;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"swatch\"\n\t\t\t\tdata-color={String(resolvedColor)}\n\t\t\t\tmix={[\n\t\t\t\t\tchartPalette(\"backgroundColor\"),\n\t\t\t\t\tinlineBlock(),\n\t\t\t\t\tis(2),\n\t\t\t\t\tbs(2),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tshrink(),\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 tooltip's label slot: a native `<span>` showing the hovered\n * point or wedge's own label — the same string rendered into its native\n * `<title>` — muted to read as secondary against {@link Chart.Tooltip.Value}.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the label's markup.\n * @example\n * <Chart.Tooltip.Label>{t(\"chart.months.march\")}</Chart.Tooltip.Label>\n */\nChartTooltip.Label = function ChartTooltipLabel(handle: Handle<Chart.Tooltip.LabelProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <span {...rest} data-slot=\"label\" mix={[opacity(75), mix]} />;\n\t};\n};\n\n/**\n * Renders the tooltip's value slot: a native `<span>` showing the hovered\n * point or wedge's own value, weighted as the surface's most prominent figure\n * and set in tabular digits, so the surface holds its width as the value changes.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the value's markup.\n * @example\n * <Chart.Tooltip.Value>42</Chart.Tooltip.Value>\n */\nChartTooltip.Value = function ChartTooltipValue(handle: Handle<Chart.Tooltip.ValueProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <span {...rest} data-slot=\"value\" mix={[weight(\"semibold\"), tabularNums(), mix]} />;\n\t};\n};\n\n// @ts-ignore\nChart.Tooltip = ChartTooltip;\n\n/**\n * Renders an area series: a filled, `aria-hidden` `<path>` tracing `points`\n * and closing down to `baseline`, mapped through {@link linearScale} and\n * {@link areaPath}, plus a focusable marker sampled via {@link ticks}.\n *\n * @param handle Runtime handle carrying the host `<g>`'s props.\n * @returns The render function producing the series' markup.\n * @example\n * <Chart.Area\n * \tcolor={3}\n * \tpoints={[\n * \t\t{ x: 0, y: 12, label: t(\"chart.point\", { x: 0, y: 12 }) },\n * \t\t{ x: 1, y: 18, label: t(\"chart.point\", { x: 1, y: 18 }) },\n * \t\t{ x: 2, y: 9, label: t(\"chart.point\", { x: 2, y: 9 }) },\n * \t]}\n * />\n * @example\n * <Chart.Area\n * \tpoints={points}\n * \tbaseline={20}\n * \tmarkerCount={3}\n * \tparts={{ path: css({ fillOpacity: 0.4 }) }}\n * />\n */\nChart.Area = function ChartArea(handle: Handle<Chart.AreaProps>) {\n\treturn () => {\n\t\tlet { points, color, baseline, markerCount, parts, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Chart);\n\t\tlet resolvedColor = color ?? DEFAULT_AREA_COLOR;\n\t\tlet resolvedBaseline = baseline ?? DEFAULT_AREA_BASELINE;\n\t\tlet resolvedMarkerCount = markerCount ?? DEFAULT_MARKER_COUNT;\n\n\t\tlet x = linearScale(context.xDomain, [0, context.width]);\n\t\tlet y = linearScale(context.yDomain, [context.height, 0]);\n\t\tlet scaledPoints: Point[] = points.map((point) => ({ x: x(point.x), y: y(point.y) }));\n\t\tlet d = areaPath(scaledPoints, y(resolvedBaseline));\n\n\t\tlet markerIndices = computeMarkerIndices(points, context.xDomain, resolvedMarkerCount);\n\n\t\treturn (\n\t\t\t<g data-color={String(resolvedColor)} {...rest} mix={[chartPalette(\"color\"), mix]}>\n\t\t\t\t<path\n\t\t\t\t\td={d}\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_PATH_ARIA_HIDDEN }),\n\t\t\t\t\t\tfill(\"currentColor\"),\n\t\t\t\t\t\tfillOpacity(\"var(--ui-chart-area-fill-opacity, 0.25)\"),\n\t\t\t\t\t\tstroke(\"currentColor\"),\n\t\t\t\t\t\tstrokeWidth(\"var(--ui-chart-area-width, 2px)\"),\n\t\t\t\t\t\tstrokeLinejoin(\"round\"),\n\t\t\t\t\t\tstrokeLinecap(\"round\"),\n\t\t\t\t\t\tparts?.path,\n\t\t\t\t\t]}\n\t\t\t\t/>\n\t\t\t\t{renderChartMarkers(points, scaledPoints, markerIndices, parts?.marker)}\n\t\t\t</g>\n\t\t);\n\t};\n};\n\n/**\n * Renders a pie or donut chart: an independent `<svg>` root, since a\n * circular layout shares no domain with a Cartesian {@link Chart}. A paired\n * {@link Chart.Legend} must render as this root's later sibling.\n *\n * @param handle Runtime handle carrying the host `<svg>`'s props.\n * @returns The render function producing the chart's markup.\n * @example\n * <Chart.Pie\n * \twidth={200}\n * \theight={200}\n * \taria-label={t(\"chart.revenueByRegion\")}\n * \tdata={[\n * \t\t{ value: 45, label: t(\"region.americas\", { percent: 45 }) },\n * \t\t{ value: 30, label: t(\"region.emea\", { percent: 30 }) },\n * \t\t{ value: 25, label: t(\"region.apac\", { percent: 25 }) },\n * \t]}\n * />\n * @example\n * <Chart.Pie\n * \twidth={200}\n * \theight={200}\n * \tinnerRadius={60}\n * \taria-label={t(\"chart.storageByType\")}\n * \tdata={rows.map((row) => ({ value: row.bytes, label: row.name }))}\n * />\n */\nChart.Pie = function ChartPie(handle: Handle<Chart.PieProps>) {\n\treturn () => {\n\t\tlet { data, width, height, innerRadius, startAngle, endAngle, padAngle, parts, mix, ...rest } =\n\t\t\thandle.props;\n\t\tlet resolvedInnerRadius = innerRadius ?? DEFAULT_PIE_INNER_RADIUS;\n\n\t\tlet cx = width / 2;\n\t\tlet cy = height / 2;\n\t\tlet outerRadius = Math.min(width, height) / 2;\n\n\t\tlet slices = pieAngles(\n\t\t\tdata.map((datum) => datum.value),\n\t\t\t{ startAngle, endAngle, padAngle },\n\t\t);\n\n\t\treturn (\n\t\t\t<svg\n\t\t\t\tviewBox={`0 0 ${width} ${height}`}\n\t\t\t\tpreserveAspectRatio=\"xMidYMid meet\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={[chartPalette(\"fill\", \" \"), legendToggle(), block(), is(\"full\"), bs(\"auto\"), mix]}\n\t\t\t>\n\t\t\t\t{slices.map((slice, index) => {\n\t\t\t\t\tlet datum = data[index];\n\t\t\t\t\tif (datum === undefined) return null;\n\n\t\t\t\t\tlet d = arcPath({\n\t\t\t\t\t\tcx,\n\t\t\t\t\t\tcy,\n\t\t\t\t\t\tinnerRadius: resolvedInnerRadius,\n\t\t\t\t\t\touterRadius,\n\t\t\t\t\t\tstartAngle: slice.startAngle,\n\t\t\t\t\t\tendAngle: slice.endAngle,\n\t\t\t\t\t});\n\t\t\t\t\tif (d === \"\") return null;\n\n\t\t\t\t\tlet resolvedColor: Chart.Color =\n\t\t\t\t\t\tdatum.color ?? (((index % CHART_COLOR_SLOT_COUNT) + 1) as Chart.Color);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<path\n\t\t\t\t\t\t\tkey={index}\n\t\t\t\t\t\t\td={d}\n\t\t\t\t\t\t\tdata-color={String(resolvedColor)}\n\t\t\t\t\t\t\ttabIndex={0}\n\t\t\t\t\t\t\trole=\"img\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\t\t\t\tparts?.segment,\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<title>{datum.label}</title>\n\t\t\t\t\t\t</path>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</svg>\n\t\t);\n\t};\n};\n\n/**\n * Renders a categorical bar chart: an independent `<svg>` root, since a\n * band axis shares no continuous domain with a Cartesian {@link Chart}. A\n * paired {@link Chart.Legend} must render as this root's later sibling.\n *\n * @param handle Runtime handle carrying the host `<svg>`'s props.\n * @returns The render function producing the chart's markup.\n * @example\n * <Chart.Bar\n * \twidth={480}\n * \theight={240}\n * \tdomain={[0, 5000]}\n * \taria-label={t(\"chart.revenue.label\")}\n * \tdata={[\n * \t\t{\n * \t\t\tcategory: \"Jan\",\n * \t\t\tvalues: { revenue: { value: 4000, label: t(\"chart.revenuePoint\", { month: \"Jan\", value: 4000 }) } },\n * \t\t},\n * \t\t{\n * \t\t\tcategory: \"Feb\",\n * \t\t\tvalues: { revenue: { value: 3000, label: t(\"chart.revenuePoint\", { month: \"Feb\", value: 3000 }) } },\n * \t\t},\n * \t]}\n * \tseries={[\"revenue\"]}\n * />\n * @example\n * <Chart.Bar\n * \twidth={480}\n * \theight={240}\n * \tdomain={[0, 5000]}\n * \taria-label={t(\"chart.revenue.label\")}\n * \tdata={quarters.map((quarter) => ({\n * \t\tcategory: quarter.name,\n * \t\tvalues: {\n * \t\t\trevenue: {\n * \t\t\t\tvalue: quarter.revenue,\n * \t\t\t\tlabel: t(\"chart.revenuePoint\", { quarter: quarter.name, value: quarter.revenue }),\n * \t\t\t},\n * \t\t\trefunds: {\n * \t\t\t\tvalue: quarter.refunds,\n * \t\t\t\tlabel: t(\"chart.refundsPoint\", { quarter: quarter.name, value: quarter.refunds }),\n * \t\t\t},\n * \t\t},\n * \t}))}\n * \tseries={[\"revenue\", \"refunds\"]}\n * \tseriesGap={0.15}\n * />\n */\nChart.Bar = function ChartBar(handle: Handle<Chart.BarProps>) {\n\treturn () => {\n\t\tlet {\n\t\t\tdata,\n\t\t\tseries,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tdomain,\n\t\t\ttickCount,\n\t\t\tcategoryGap,\n\t\t\tseriesGap,\n\t\t\tparts,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet resolvedTickCount = tickCount ?? DEFAULT_BAR_TICK_COUNT;\n\t\tlet resolvedCategoryGap = categoryGap ?? DEFAULT_CATEGORY_GAP;\n\t\tlet resolvedSeriesGap = seriesGap ?? DEFAULT_SERIES_GAP;\n\n\t\tlet categories = data.map((row) => row.category);\n\t\tlet outer = bandScale(categories, [0, width], {\n\t\t\tpaddingInner: resolvedCategoryGap,\n\t\t\tpaddingOuter: resolvedCategoryGap / 2,\n\t\t});\n\t\tlet inner = bandScale(series, [0, outer.bandwidth], { paddingInner: resolvedSeriesGap });\n\t\tlet y = linearScale(domain, [height, 0]);\n\t\tlet baselineY = y(0);\n\t\tlet gridlineValues = ticks(domain, resolvedTickCount);\n\n\t\treturn (\n\t\t\t<svg\n\t\t\t\tviewBox={`0 0 ${width} ${height}`}\n\t\t\t\tpreserveAspectRatio=\"xMidYMid meet\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={[chartPalette(\"fill\", \" \"), legendToggle(), block(), is(\"full\"), bs(\"auto\"), mix]}\n\t\t\t>\n\t\t\t\t<g mix={[attrs({ \"aria-hidden\": DEFAULT_PATH_ARIA_HIDDEN })]}>\n\t\t\t\t\t{gridlineValues.map((value) => (\n\t\t\t\t\t\t<line\n\t\t\t\t\t\t\tkey={value}\n\t\t\t\t\t\t\tx1={0}\n\t\t\t\t\t\t\tx2={width}\n\t\t\t\t\t\t\ty1={y(value)}\n\t\t\t\t\t\t\ty2={y(value)}\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tstroke(\"var(--ui-neutral-border)\"),\n\t\t\t\t\t\t\t\tstrokeWidth(\"1\"),\n\t\t\t\t\t\t\t\tvectorEffect(\"non-scaling-stroke\"),\n\t\t\t\t\t\t\t\tparts?.gridline,\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</g>\n\t\t\t\t{data.map((row) => {\n\t\t\t\t\tlet categoryX = outer.position(row.category);\n\t\t\t\t\tif (categoryX === undefined) return null;\n\n\t\t\t\t\treturn series.map((key, index) => {\n\t\t\t\t\t\tlet entry = row.values[key];\n\t\t\t\t\t\tif (entry === undefined) return null;\n\n\t\t\t\t\t\tlet barX = categoryX + (inner.position(key) ?? 0);\n\t\t\t\t\t\tlet barValueY = y(entry.value);\n\t\t\t\t\t\tlet rectY = Math.min(baselineY, barValueY);\n\t\t\t\t\t\tlet rectHeight = Math.abs(barValueY - baselineY);\n\t\t\t\t\t\tlet resolvedColor: Chart.Color = ((index % CHART_COLOR_SLOT_COUNT) + 1) as Chart.Color;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\tkey={`${row.category}:${key}`}\n\t\t\t\t\t\t\t\tx={barX}\n\t\t\t\t\t\t\t\ty={rectY}\n\t\t\t\t\t\t\t\twidth={inner.bandwidth}\n\t\t\t\t\t\t\t\theight={rectHeight}\n\t\t\t\t\t\t\t\tdata-color={String(resolvedColor)}\n\t\t\t\t\t\t\t\tdata-series-index={String(index)}\n\t\t\t\t\t\t\t\ttabIndex={0}\n\t\t\t\t\t\t\t\trole=\"img\"\n\t\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\t\thover(opacity(85)),\n\t\t\t\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\t\t\t\t\ttransition(\"opacity\"),\n\t\t\t\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", transitionDuration(\"0s\")),\n\t\t\t\t\t\t\t\t\tparts?.bar,\n\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<title>{entry.label}</title>\n\t\t\t\t\t\t\t</rect>\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t})}\n\t\t\t</svg>\n\t\t);\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "checkbox-group",
|
|
3
|
+
"changedIn": "2026.10.2",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"CheckboxGroup"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "checkbox-group.tsx",
|
|
10
|
+
"content": "/**\n * A landmark grouping independently toggled checkbox controls into one\n * related set: a `role=\"group\"` host laying children out in a column, or a\n * row when `orientation` is `\"horizontal\"`. Each nested checkbox keeps its\n * own checked state, `name`, and `value`; the host contributes the shared\n * grouping, the layout, and an invalid-state color for composed text.\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 { fg } from \"@sdxc/u/color\";\nimport { flexRow, gap, vstack } from \"@sdxc/u/layout\";\nimport { when } from \"@sdxc/u/state\";\nimport { attrs } from \"remix/component\";\n\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\n/**\n * Announces the host as a related set of controls to assistive technology;\n * {@link attrs} lets a consumer's own `role` win.\n */\nconst DEFAULT_ROLE = \"group\";\n\nconst DEFAULT_ORIENTATION: CheckboxGroup.Orientation = \"vertical\";\n\n/**\n * Prop types for {@link CheckboxGroup}.\n */\nexport namespace CheckboxGroup {\n\t/**\n\t * Axis a group's checkboxes lay out along: a single column, or a single\n\t * row.\n\t */\n\texport type Orientation = \"horizontal\" | \"vertical\";\n\n\t/**\n\t * Props accepted by {@link CheckboxGroup}. Native `<div>` attributes and\n\t * `mix` pass through to the grouping host, so `aria-label`,\n\t * `aria-labelledby`, `aria-describedby`, and `aria-invalid` behave natively.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t}\n}\n\n/**\n * Lays checkbox children out in a column, or a row when `orientation` is\n * `\"horizontal\"`; each nested checkbox keeps its own checked state, `name`,\n * and `value`. `aria-invalid=\"true\"` recolors plain text composed alongside.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <CheckboxGroup aria-labelledby=\"fruits-label\">\n * \t<Label id=\"fruits-label\">{t(\"fruits.label\")}</Label>\n * \t<Checkbox name=\"fruits\" value=\"apple\">{t(\"fruits.apple\")}</Checkbox>\n * \t<Checkbox name=\"fruits\" value=\"banana\">{t(\"fruits.banana\")}</Checkbox>\n * \t<Checkbox name=\"fruits\" value=\"orange\">{t(\"fruits.orange\")}</Checkbox>\n * </CheckboxGroup>\n * @example\n * <CheckboxGroup aria-label={t(\"notifications.label\")} orientation=\"horizontal\">\n * \t<Checkbox name=\"notify\" value=\"email\">{t(\"notifications.email\")}</Checkbox>\n * \t<Checkbox name=\"notify\" value=\"sms\">{t(\"notifications.sms\")}</Checkbox>\n * \t<Checkbox name=\"notify\" value=\"push\">{t(\"notifications.push\")}</Checkbox>\n * </CheckboxGroup>\n * @example\n * <CheckboxGroup aria-labelledby=\"terms-label\" aria-invalid=\"true\" aria-describedby=\"terms-error\">\n * \t<Label id=\"terms-label\">{t(\"terms.label\")}</Label>\n * \t<Checkbox name=\"terms\" value=\"accepted\" required>{t(\"terms.accept\")}</Checkbox>\n * \t<FieldError id=\"terms-error\">{t(\"terms.required\")}</FieldError>\n * </CheckboxGroup>\n */\nexport function CheckboxGroup(handle: Handle<CheckboxGroup.Props>) {\n\treturn () => {\n\t\tlet { orientation, mix, ...rest } = handle.props;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t\"CheckboxGroup: a group with no `aria-label` or `aria-labelledby` needs one describing the set — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-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\tvstack({ gap: 2 }),\n\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', [flexRow(), gap(4)]),\n\t\t\t\t\twhen('&[aria-invalid=\"true\"]', fg(\"danger\")),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|