@sdxc/kit 0.0.0-stage → 2026.10.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +93 -2
- package/changelog.jsonl +1097 -0
- package/config.schema.json +89 -0
- package/dist/author.d.ts +36 -0
- package/dist/author.js +107 -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 +169 -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 +53 -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 +69 -0
- package/dist/create/templates.js +251 -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 +40 -0
- package/dist/init.js +100 -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 +598 -0
- package/dist/make/generate.d.ts +62 -0
- package/dist/make/generate.js +160 -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 +140 -0
- package/dist/make/kinds.d.ts +40 -0
- package/dist/make/kinds.js +96 -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 +60 -0
- package/dist/testing.js +148 -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 +16 -0
- package/stubs/command.test.stub +21 -0
- package/stubs/controller.api.stub +21 -0
- package/stubs/controller.api.test.stub +18 -0
- package/stubs/controller.form.stub +63 -0
- package/stubs/controller.form.test.stub +61 -0
- package/stubs/controller.stub +24 -0
- package/stubs/controller.test.stub +18 -0
- package/stubs/email.stub +26 -0
- package/stubs/email.test.stub +21 -0
- package/stubs/factory.stub +13 -0
- package/stubs/initializer.stub +9 -0
- package/stubs/initializer.test.stub +16 -0
- package/stubs/job.cron.stub +16 -0
- package/stubs/job.stub +15 -0
- package/stubs/job.test.stub +18 -0
- package/stubs/mcp.resource.stub +15 -0
- package/stubs/mcp.stub +13 -0
- package/stubs/mcp.test.stub +18 -0
- package/stubs/middleware.stub +16 -0
- package/stubs/middleware.test.stub +16 -0
- package/stubs/migration.stub +1 -0
- package/stubs/model.stub +33 -0
- package/stubs/model.test.stub +18 -0
- package/stubs/policy.stub +16 -0
- package/stubs/policy.test.stub +20 -0
- package/stubs/service.stub +17 -0
- package/stubs/service.test.stub +17 -0
- package/stubs/validator.stub +17 -0
- package/stubs/validator.test.stub +25 -0
- package/templates/app/.env.example +16 -0
- package/templates/app/README.md +84 -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/db/console.ts +6 -0
- package/templates/app/app/commands/db/migrate.test.ts +30 -0
- package/templates/app/app/commands/db/migrate.ts +55 -0
- package/templates/app/app/commands/index.ts +31 -0
- package/templates/app/app/commands/typegen.test.ts +17 -0
- package/templates/app/app/commands/typegen.ts +16 -0
- package/templates/app/app/http/controllers/api/health.tsx +15 -0
- package/templates/app/app/http/controllers/api/not-found.tsx +16 -0
- package/templates/app/app/http/controllers/api/openapi.tsx +17 -0
- package/templates/app/app/http/controllers/home.tsx +30 -0
- package/templates/app/app/http/controllers/mcp.tsx +16 -0
- package/templates/app/app/http/controllers/not-found.tsx +30 -0
- package/templates/app/app/http/controllers/robots.test.ts +18 -0
- package/templates/app/app/http/controllers/robots.ts +24 -0
- package/templates/app/app/http/controllers/sitemap.test.ts +28 -0
- package/templates/app/app/http/controllers/sitemap.ts +25 -0
- package/templates/app/app/http/middleware/api.ts +10 -0
- package/templates/app/app/http/middleware/page.test.ts +40 -0
- package/templates/app/app/http/middleware/page.ts +49 -0
- package/templates/app/app/http/middleware/server-timing.test.ts +15 -0
- package/templates/app/app/http/middleware/server-timing.ts +42 -0
- package/templates/app/app/initializers/assets.ts +11 -0
- package/templates/app/app/initializers/captcha.ts +11 -0
- package/templates/app/app/initializers/cli.ts +75 -0
- package/templates/app/app/initializers/database.test.ts +18 -0
- package/templates/app/app/initializers/database.ts +18 -0
- package/templates/app/app/initializers/dispatcher.ts +36 -0
- package/templates/app/app/initializers/honeypot.ts +11 -0
- package/templates/app/app/initializers/i18n.test.ts +16 -0
- package/templates/app/app/initializers/i18n.ts +28 -0
- package/templates/app/app/initializers/local-database.test.ts +33 -0
- package/templates/app/app/initializers/local-database.ts +53 -0
- package/templates/app/app/initializers/logger.ts +10 -0
- package/templates/app/app/initializers/mail.test.ts +27 -0
- package/templates/app/app/initializers/mail.ts +11 -0
- package/templates/app/app/initializers/mcp.ts +16 -0
- package/templates/app/app/initializers/openapi.ts +21 -0
- package/templates/app/app/initializers/router.test.ts +61 -0
- package/templates/app/app/initializers/router.tsx +111 -0
- package/templates/app/app/initializers/seo.ts +15 -0
- package/templates/app/app/initializers/session.test.ts +34 -0
- package/templates/app/app/initializers/session.ts +29 -0
- package/templates/app/app/initializers/spam.ts +10 -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/app/models/index.ts +10 -0
- package/templates/app/app/services/migrations.test.ts +45 -0
- package/templates/app/app/services/migrations.ts +60 -0
- package/templates/app/app/test/cloudflare-workers.ts +25 -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 +56 -0
- package/templates/app/config/constants.ts +19 -0
- package/templates/app/config/problems.ts +24 -0
- package/templates/app/config/security-policy.ts +34 -0
- package/templates/app/config/security-txt.ts +28 -0
- package/templates/app/database/migrations/.gitkeep +0 -0
- package/templates/app/gitignore +9 -0
- package/templates/app/package.json +68 -0
- package/templates/app/resources/layouts/document.tsx +79 -0
- package/templates/app/resources/locales/en.json +10 -0
- package/templates/app/routes/api.ts +29 -0
- package/templates/app/routes/web.ts +14 -0
- package/templates/app/tsconfig.json +40 -0
- package/templates/app/vite.config.ts +44 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "message-scroller",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"button",
|
|
6
|
+
"scroll-area"
|
|
7
|
+
],
|
|
8
|
+
"exports": [
|
|
9
|
+
"MessageScroller"
|
|
10
|
+
],
|
|
11
|
+
"source": {
|
|
12
|
+
"path": "message-scroller.tsx",
|
|
13
|
+
"content": "/**\n * A scrollable frame for a conversational message log. Its viewport reuses\n * the same scrollbar treatment every scrolling surface in this catalog\n * shares and fades its own edges to hint at history above and replies still\n * below; its content region announces newly appended rows through the ARIA\n * log role; each row carries the message id and anchor data a scroll-follow\n * behavior reads; and a static jump-to-latest control sits ready for that\n * same behavior to reveal.\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 { border } from \"@sdxc/u/color\";\nimport { rounded, shadow } from \"@sdxc/u/effects\";\nimport { raw } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tcontainer,\n\tflex,\n\tflexCol,\n\tgap,\n\tinsIe,\n\tinsIs,\n\tinset,\n\tjustify,\n\trelative,\n} from \"@sdxc/u/layout\";\nimport { pb, pi } from \"@sdxc/u/size\";\nimport { z } from \"@sdxc/u/stacking\";\nimport { when } from \"@sdxc/u/state\";\nimport { translateProperty } from \"@sdxc/u/transform\";\nimport { attrs } from \"remix/component\";\n\nimport { Button } from \"@sdxc/ui/button\";\nimport { ScrollArea } from \"@sdxc/ui/scroll-area\";\n\n/**\n * Named container {@link MessageScroller} declares on its own host, so\n * {@link MessageScroller.Button} can size its own placement to the\n * frame's own width.\n */\nconst CONTAINER_NAME = \"ui-message-scroller\";\n\n/**\n * Container width under which {@link MessageScroller.Button} switches from a\n * centered floating pill to a bar stretched across the frame's own inline\n * size. It is measured against the frame's own width, which a conversation\n * column keeps well under a viewport's, so only a phone-width column reaches it.\n */\nconst BUTTON_NARROW_QUERY = `@container ${CONTAINER_NAME} (max-width: 20rem)`;\n\n/**\n * `role=\"log\"` applied to {@link MessageScroller.Content} through\n * {@link attrs} unless a consumer supplies its own `role`, whose implicit\n * `aria-live=\"polite\"` behavior announces each newly appended row.\n */\nconst DEFAULT_CONTENT_ROLE = \"log\";\n\n/**\n * `aria-relevant=\"additions\"` applied to {@link MessageScroller.Content}\n * through {@link attrs} unless overridden, scoping assistive-technology\n * announcements to newly appended rows.\n */\nconst DEFAULT_CONTENT_ARIA_RELEVANT = \"additions\";\n\n/** Semantic color role {@link MessageScroller.Button} falls back to when `color` is omitted. */\nconst DEFAULT_BUTTON_COLOR: Button.Color = \"neutral\";\n\n/**\n * Visual weight {@link MessageScroller.Button} falls back to when `variant` is omitted.\n * The control floats over a conversation it points at rather than competing with it, so\n * it reads as a surface of its own carrying an arrow.\n */\nconst DEFAULT_BUTTON_VARIANT: Button.Variant = \"outline\";\n\n/** Size variant {@link MessageScroller.Button} falls back to when `size` is omitted. */\nconst DEFAULT_BUTTON_SIZE: Button.Size = \"sm\";\n\n/**\n * `hidden` applied to {@link MessageScroller.Button} when a consumer omits\n * it: the control starts absent from rendering and the accessibility tree\n * until a paired scroll-follow behavior reveals it.\n */\nconst DEFAULT_BUTTON_HIDDEN = true;\n\n/**\n * Prop types for {@link MessageScroller} and its compound parts.\n */\nexport namespace MessageScroller {\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * Size the frame through `mix` since {@link MessageScroller.Viewport}\n\t * fills whatever block size this host resolves to.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** The frame's compound parts: {@link MessageScroller.Viewport} and, optionally, {@link MessageScroller.Button}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ViewportProps extends TagProps<\"div\"> {\n\t\t/** {@link MessageScroller.Content}, scrolling inside the viewport. */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ContentProps extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Marks the log as busy while a row inside it is still being written\n\t\t * to — a reply still streaming in, for instance — forwarded to the host's\n\t\t * native `aria-busy` attribute. Clear it once the row settles.\n\t\t */\n\t\t\"aria-busy\"?: TagProps<\"div\">[\"aria-busy\"];\n\t\t/** The {@link MessageScroller.Item} rows to render in document order. */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ItemProps extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Stable id of the message this row renders, mirrored onto the host's\n\t\t * `data-message-id` attribute so a scroll-follow behavior can find,\n\t\t * measure, and scroll to this exact row directly.\n\t\t */\n\t\tmessageId: string;\n\t\t/**\n\t\t * Marks this row as a candidate anchor point — typically the first row\n\t\t * of a new turn — mirrored onto `data-scroll-anchor` so a scroll-follow\n\t\t * behavior can tell which rows are worth anchoring the viewport to.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\tscrollAnchor?: boolean;\n\t\t/** The row's own content, typically a conversational row composed inside it. */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every {@link Button.Props} field, unchanged, except `hidden`, which\n\t * defaults to `true`.\n\t */\n\texport interface ButtonProps extends Button.Props {\n\t\t/**\n\t\t * Whether the control is absent from rendering and the accessibility tree.\n\t\t * A paired scroll-follow behavior clears this attribute as the reader\n\t\t * scrolls away from the live edge and sets it again on return or press.\n\t\t *\n\t\t * @default true\n\t\t */\n\t\thidden?: boolean;\n\t}\n}\n\n/**\n * Renders the frame's root host: a bordered, rounded `<div>` that\n * declares the `ui-message-scroller` container queried by\n * {@link MessageScroller.Button} for its own placement.\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 * <MessageScroller mix={css({ blockSize: \"32rem\" })}>\n * \t<MessageScroller.Viewport>\n * \t\t<MessageScroller.Content aria-busy={isStreaming}>\n * \t\t\t<MessageScroller.Item messageId={turn.id} scrollAnchor>\n * \t\t\t\t{turn.content}\n * \t\t\t</MessageScroller.Item>\n * \t\t</MessageScroller.Content>\n * \t</MessageScroller.Viewport>\n * \t<MessageScroller.Button aria-label={t(\"chat.jumpToLatest\")} />\n * </MessageScroller>\n */\nexport function MessageScroller(handle: Handle<MessageScroller.Props>) {\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=\"message-scroller\"\n\t\t\t\tmix={[\n\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\trelative(),\n\t\t\t\t\tcontainer(CONTAINER_NAME),\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 the frame's scrolling surface as {@link ScrollArea.Viewport},\n * fixed to the block axis. Compose `scrollFade()` through `mix` to fade\n * this viewport's edges when more content is off-screen.\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 * <MessageScroller.Viewport mix={scrollFade({ axis: \"block\" })}>\n * \t<MessageScroller.Content>...</MessageScroller.Content>\n * </MessageScroller.Viewport>\n */\nMessageScroller.Viewport = function MessageScrollerViewport(\n\thandle: Handle<MessageScroller.ViewportProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <ScrollArea.Viewport {...rest} orientation=\"vertical\" mix={mix} />;\n\t};\n};\n\n/**\n * Renders the frame's live region: a `<div>` carrying the ARIA log role,\n * stacking its {@link MessageScroller.Item} rows in a column and\n * announcing each added row via `aria-relevant=\"additions\"`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the log region's markup.\n * @example\n * <MessageScroller.Content aria-busy={isStreaming}>\n * \t<MessageScroller.Item messageId={turn.id}>{turn.content}</MessageScroller.Item>\n * </MessageScroller.Content>\n */\nMessageScroller.Content = function MessageScrollerContent(\n\thandle: Handle<MessageScroller.ContentProps>,\n) {\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\tattrs({ role: DEFAULT_CONTENT_ROLE, \"aria-relevant\": DEFAULT_CONTENT_ARIA_RELEVANT }),\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\tgap(4),\n\t\t\t\t\tpb(4),\n\t\t\t\t\tpi(4),\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 a single message row: a `<div>` mirroring `messageId` onto\n * `data-message-id` and, when `scrollAnchor` is set, an empty\n * `data-scroll-anchor` attribute for a scroll-follow behavior to read.\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 * <MessageScroller.Item messageId={turn.id} scrollAnchor={turn.startsNewTurn}>\n * \t{turn.content}\n * </MessageScroller.Item>\n */\nMessageScroller.Item = function MessageScrollerItem(handle: Handle<MessageScroller.ItemProps>) {\n\treturn () => {\n\t\tlet { messageId, scrollAnchor, children, mix, ...rest } = handle.props;\n\n\t\tif (import.meta.env.DEV && !messageId) {\n\t\t\tconsole.warn(\n\t\t\t\t'MessageScroller.Item: needs a \"messageId\" — a scroll-follow behavior matches rows against this instead of parsing rendered children.',\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=\"item\"\n\t\t\t\tdata-message-id={messageId}\n\t\t\t\tdata-scroll-anchor={scrollAnchor || undefined}\n\t\t\t\tmix={[\n\t\t\t\t\traw({\n\t\t\t\t\t\tscrollMarginBlockStart: \"var(--ui-message-scroller-anchor-offset, 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\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders a static jump-to-latest control as {@link Button}, floating\n * over the frame's block-end edge and starting `hidden` until a paired\n * scroll-follow behavior clears the attribute.\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 * <MessageScroller.Button aria-label={t(\"chat.jumpToLatest\")}>\n * \t{t(\"chat.jumpToLatest\")}\n * </MessageScroller.Button>\n */\nMessageScroller.Button = function MessageScrollerButton(\n\thandle: Handle<MessageScroller.ButtonProps>,\n) {\n\treturn () => {\n\t\tlet { hidden, color, variant, size, mix, ...rest } = handle.props;\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\tcolor={color ?? DEFAULT_BUTTON_COLOR}\n\t\t\t\tvariant={variant ?? DEFAULT_BUTTON_VARIANT}\n\t\t\t\tsize={size ?? DEFAULT_BUTTON_SIZE}\n\t\t\t\thidden={hidden ?? DEFAULT_BUTTON_HIDDEN}\n\t\t\t\tdata-slot=\"jump-button\"\n\t\t\t\tmix={[\n\t\t\t\t\tz(1),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tinset(\"auto\", \"auto\", \"1rem\", \"50%\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * The control floats over the log, so it carries an opaque surface of its own to stay\n\t\t\t\t\t * legible. `!important` settles it: each mix entry gets its own cascade sublayer, and\n\t\t\t\t\t * the variant's own fill may land in a later one.\n\t\t\t\t\t */\n\t\t\t\t\traw({ backgroundColor: \"var(--ui-bg, Canvas) !important\" }),\n\t\t\t\t\tshadow(\"md\"),\n\t\t\t\t\ttranslateProperty(\"-50% 0\"),\n\t\t\t\t\twhen(BUTTON_NARROW_QUERY, [\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tinsIs(\"1rem\"),\n\t\t\t\t\t\tinsIe(\"1rem\"),\n\t\t\t\t\t\ttranslateProperty(\"0 0\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
14
|
+
},
|
|
15
|
+
"test": null
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "message",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Message"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "message.tsx",
|
|
10
|
+
"content": "/**\n * A single conversational turn in a message log: a row composing a\n * bottom-anchored avatar, a header for the sender's identity and timing, a\n * content slot for the message's own surface, and an optional footer for its\n * actions. Compound parts lay out entirely through CSS grid areas keyed off\n * each part's `data-slot`, so the avatar's vertical anchor and the footer's\n * presence never need to be tracked as 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 { fg } from \"@sdxc/u/color\";\nimport {\n\tcontainer,\n\tflex,\n\tflexWrap,\n\tgap,\n\tgrid,\n\tgridArea,\n\tgridTemplate,\n\thstack,\n\titems,\n\tjustify,\n\trelative,\n\tself,\n\tvstack,\n} from \"@sdxc/u/layout\";\nimport { at } from \"@sdxc/u/responsive\";\nimport { maxIs, minIs } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { fontSize, tabularNums, weight } from \"@sdxc/u/typography\";\n\n/**\n * Named container {@link Message} declares on its own host, so\n * {@link Message.Header} can query the row's own width instead of the\n * page's, matching whether it renders full-page or in a narrower panel.\n */\nconst CONTAINER_NAME = \"ui-message\";\n\n/**\n * Prop types for {@link Message} and its compound parts.\n */\nexport namespace Message {\n\t/**\n\t * Props accepted by {@link Message}.\n\t */\n\texport interface Props extends TagProps<\"article\"> {\n\t\t/** The row's compound parts: {@link Message.Avatar}, {@link Message.Header}, {@link Message.Content}, and an optional {@link Message.Footer}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Message.Avatar}.\n\t */\n\texport interface AvatarProps extends TagProps<\"div\"> {\n\t\t/** An Avatar instance identifying the message's sender. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Message.Header}.\n\t */\n\texport interface HeaderProps extends TagProps<\"header\"> {\n\t\t/** The sender's name, typically followed by a timestamp. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Message.Content}.\n\t */\n\texport interface ContentProps extends TagProps<\"div\"> {\n\t\t/** The message's own surface — a Bubble, an attachment card, or any other rendered turn content. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Message.Footer}.\n\t */\n\texport interface FooterProps extends TagProps<\"footer\"> {\n\t\t/** The row's actions, typically a copy Button and a like Button. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Message.Group}.\n\t */\n\texport interface GroupProps extends TagProps<\"div\"> {\n\t\t/** A run of consecutive {@link Message} rows sharing the same sender. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the message row as a two-column grid whose `\"avatar\"` area spans only the\n * header and content rows, anchoring {@link Message.Avatar} to the bottom edge\n * of {@link Message.Content}, regardless of whether {@link Message.Footer} renders.\n *\n * @param handle Runtime handle carrying the host `<article>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Message>\n * \t<Message.Avatar>\n * \t\t<Avatar>\n * \t\t\t<Avatar.Image src={sender.avatarUrl} alt={sender.name} />\n * \t\t\t<Avatar.Fallback>{sender.initials}</Avatar.Fallback>\n * \t\t</Avatar>\n * \t</Message.Avatar>\n * \t<Message.Header>\n * \t\t<strong>{sender.name}</strong>\n * \t\t<time dateTime={message.sentAt}>{formattedTime}</time>\n * \t</Message.Header>\n * \t<Message.Content>\n * \t\t<Bubble>{message.text}</Bubble>\n * \t</Message.Content>\n * \t<Message.Footer>\n * \t\t<Button\n * \t\t\taria-label={t(\"message.copy\")}\n * \t\t\tcommandfor={`${message.id}-text`}\n * \t\t\tcommand={COPY_COMMAND}\n * \t\t\tmix={copyToClipboard()}\n * \t\t>\n * \t\t\t<CopyIcon />\n * \t\t</Button>\n * \t\t<Button aria-label={t(\"message.like\")} onClick={likeMessage}>\n * \t\t\t<ThumbsUpIcon />\n * \t\t</Button>\n * \t</Message.Footer>\n * </Message>\n */\nexport function Message(handle: Handle<Message.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<article\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"message\"\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tgrid(),\n\t\t\t\t\tgap(\"var(--ui-message-row-gap, 0.25rem)\", \"var(--ui-message-gap, 0.75rem)\"),\n\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\tgridTemplate({\n\t\t\t\t\t\tcolumns: \"auto 1fr\",\n\t\t\t\t\t\tareas: `\"avatar header\" \"avatar content\" \". footer\"`,\n\t\t\t\t\t}),\n\t\t\t\t\twhen('& > [data-slot=\"avatar\"]', [gridArea(\"avatar\"), self(\"end\")]),\n\t\t\t\t\twhen('& > [data-slot=\"header\"]', gridArea(\"header\")),\n\t\t\t\t\twhen('& > [data-slot=\"content\"]', gridArea(\"content\")),\n\t\t\t\t\twhen('& > [data-slot=\"footer\"]', gridArea(\"footer\")),\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</article>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link Message.AvatarProps.children} as the row's avatar slot,\n * aligned to the `\"avatar\"` area's block-end edge so it tracks the bottom\n * edge of {@link Message.Content}. Nest an Avatar instance inside it.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the avatar slot's markup.\n * @example\n * <Message.Avatar>\n * \t<Avatar>\n * \t\t<Avatar.Image src={sender.avatarUrl} alt={sender.name} />\n * \t\t<Avatar.Fallback>{sender.initials}</Avatar.Fallback>\n * \t</Avatar>\n * </Message.Avatar>\n */\nMessage.Avatar = function MessageAvatar(handle: Handle<Message.AvatarProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div {...rest} data-slot=\"avatar\" mix={[flex(), mix]}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Message.HeaderProps.children} as the row's identity line,\n * wrapping until the `ui-message` container passes `26rem`, then settling\n * onto one row with the sender's name first and later children as secondary metadata.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the identity line's markup.\n * @example\n * <Message.Header>\n * \t<strong>{sender.name}</strong>\n * \t<time dateTime={message.sentAt}>{formattedTime}</time>\n * </Message.Header>\n */\nMessage.Header = function MessageHeader(handle: Handle<Message.HeaderProps>) {\n\treturn () => {\n\t\tlet { children, 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={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexWrap(\"wrap\"),\n\t\t\t\t\titems(\"baseline\"),\n\t\t\t\t\tgap(\"0.125rem\", \"0.5rem\"),\n\t\t\t\t\twhen(\"& > :first-child\", [fontSize(\"sm\"), weight(\"semibold\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\twhen(\"& > :not(:first-child)\", [fontSize(\"xs\"), fg(\"neutral.muted\"), tabularNums()]),\n\t\t\t\t\tat(\"26rem\", CONTAINER_NAME, [flexWrap(\"nowrap\"), justify(\"between\")]),\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</header>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Message.ContentProps.children} as the row's content slot,\n * capped to a comfortable reading measure and never narrower than its grid\n * area. Nest a Bubble, attachment card, or other turn content inside it.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the content slot's markup.\n * @example\n * <Message.Content>\n * \t<Bubble>{message.text}</Bubble>\n * </Message.Content>\n */\nMessage.Content = function MessageContent(handle: Handle<Message.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.375rem\" }),\n\t\t\t\t\tminIs(\"0\"),\n\t\t\t\t\tmaxIs(\"var(--ui-message-content-max-size, 36rem)\"),\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 Message.FooterProps.children} as the row's action slot,\n * occupying the grid's `\"footer\"` area beneath {@link Message.Content} and\n * never reached by {@link Message.Avatar}'s bottom anchor.\n *\n * @param handle Runtime handle carrying the host `<footer>`'s props.\n * @returns The render function producing the action slot's markup.\n * @example\n * <Message.Footer>\n * \t<Button\n * \t\taria-label={t(\"message.copy\")}\n * \t\tcommandfor={`${message.id}-text`}\n * \t\tcommand={COPY_COMMAND}\n * \t\tmix={copyToClipboard()}\n * \t>\n * \t\t<CopyIcon />\n * \t</Button>\n * \t<Button aria-label={t(\"message.like\")} onClick={likeMessage}>\n * \t\t<ThumbsUpIcon />\n * \t</Button>\n * </Message.Footer>\n */\nMessage.Footer = function MessageFooter(handle: Handle<Message.FooterProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<footer {...rest} data-slot=\"footer\" mix={[hstack({ align: \"center\", gap: \"0.25rem\" }), mix]}>\n\t\t\t\t{children}\n\t\t\t</footer>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Message.GroupProps.children} as a run of consecutive\n * {@link Message} rows sharing the same sender, stacked with a hairline gap\n * that reads as one continuous turn.\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 * <Message.Group>\n * \t<Message>\n * \t\t<Message.Header>{sender.name}</Message.Header>\n * \t\t<Message.Content><Bubble>{firstReply.text}</Bubble></Message.Content>\n * \t</Message>\n * \t<Message>\n * \t\t<Message.Avatar>\n * \t\t\t<Avatar>\n * \t\t\t\t<Avatar.Image src={sender.avatarUrl} alt={sender.name} />\n * \t\t\t\t<Avatar.Fallback>{sender.initials}</Avatar.Fallback>\n * \t\t\t</Avatar>\n * \t\t</Message.Avatar>\n * \t\t<Message.Content><Bubble>{secondReply.text}</Bubble></Message.Content>\n * \t</Message>\n * </Message.Group>\n */\nMessage.Group = function MessageGroup(handle: Handle<Message.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={[vstack({ gap: \"var(--ui-message-group-gap, 0.125rem)\" }), mix]}\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,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "meter",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Meter"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "meter.tsx",
|
|
10
|
+
"content": "/**\n * A styled native `<meter>` gauge paired with an optional value label,\n * stacked in a single column so a caption can sit alongside the bar it\n * measures. The gauge's track and fill read entirely from the control's own\n * `value`/`min`/`max` attributes, tinted by a semantic color role chosen\n * independently of the platform's own optimum/suboptimum quality coloring.\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 { raw } from \"@sdxc/u/general\";\nimport { appearance, block, vstack } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, m, p } from \"@sdxc/u/size\";\nimport { data, when } from \"@sdxc/u/state\";\nimport { tabularNums, text } from \"@sdxc/u/typography\";\n\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\n/** Semantic color role {@link Meter.Indicator} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Meter.Color = \"neutral\";\n\n/**\n * Native `max` value {@link Meter.Indicator} falls back to when `max` is\n * omitted, matching the common percentage-based convention for a bare `value`.\n */\nconst DEFAULT_MAX = 100;\n\n/**\n * Selector list matching every engine's pseudo-element for a meter's fill:\n * WebKit/Blink split it in three depending on `value` vs. `low`/`high`/\n * `optimum`; Gecko exposes one. All four resolve their color from `data-color`.\n */\n/**\n * Chrome and Safari name the fill by how the value scores against the optimum range, and\n * Firefox names it once. Each engine gets a rule of its own, because a vendor\n * pseudo-element an engine does not know invalidates every selector in the list beside it —\n * one combined list leaves both engines with no fill at all.\n */\nconst FILL_SELECTORS = [\n\t\"&::-webkit-meter-optimum-value, &::-webkit-meter-suboptimum-value, &::-webkit-meter-even-less-good-value\",\n\t\"&::-moz-meter-bar\",\n] as const;\n\n/**\n * Prop types for {@link Meter} and its compound parts.\n */\nexport namespace Meter {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*-bg-solid`\n\t * variable for the gauge's filled portion.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * The root only supplies the column layout stacking {@link Indicator} and\n\t * {@link ValueLabel}; it carries no semantics of its own.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<meter>` attribute, unchanged, plus `color` and the `mix`\n\t * passthrough. `max` defaults to {@link DEFAULT_MAX}, so a bare `value`\n\t * reads directly as a percentage.\n\t */\n\texport interface IndicatorProps extends TagProps<\"meter\"> {\n\t\t/** Semantic color role for the gauge's fill. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t}\n\n\t/**\n\t * Every native `<span>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ValueLabelProps extends TagProps<\"span\"> {}\n}\n\n/**\n * Renders the root column: a `<div>` stacking {@link Meter.Indicator} and an\n * optional {@link Meter.ValueLabel} with a small gap. The native `<meter>`\n * inside already exposes the platform's meter semantics.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the root column's markup.\n * @example\n * <Meter>\n * \t<Meter.Indicator value={45} max={100} aria-label={t(\"storage.used\")} />\n * \t<Meter.ValueLabel>{t(\"storage.percent\", { value: 45 })}</Meter.ValueLabel>\n * </Meter>\n */\nexport function Meter(handle: Handle<Meter.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} mix={[vstack({ gap: \"0.25rem\" }), mix]} />;\n\t};\n}\n\n/**\n * Renders the gauge as a pill-shaped track filled in a semantic `color`,\n * mirrored across each engine's fill pseudo-elements so `low`/`high`/`optimum`\n * keep shaping accessible semantics independently of the rendered color; dev mode warns when no accessible name is set.\n *\n * @param handle Runtime handle carrying the host `<meter>`'s props.\n * @returns The render function producing the gauge's markup.\n * @example\n * <Meter.Indicator value={45} max={100} aria-label={t(\"storage.used\")} />\n * @example\n * <Meter.Indicator color=\"danger\" value={92} aria-label={t(\"cpu.usage\")} />\n * @example\n * <Meter.Indicator\n * \tcolor=\"success\"\n * \tvalue={8}\n * \tlow={3}\n * \thigh={9}\n * \toptimum={10}\n * \tmax={10}\n * \taria-label={t(\"rating.score\")}\n * />\n */\nMeter.Indicator = function MeterIndicator(handle: Handle<Meter.IndicatorProps>) {\n\treturn () => {\n\t\tlet { color, max, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedMax = max ?? DEFAULT_MAX;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t\"Meter.Indicator: a meter with no `aria-label` or `aria-labelledby` needs one describing what it measures — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<meter\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tmax={resolvedMax}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tappearance(),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\tbs(\"var(--ui-meter-track-block-size, 0.5rem)\"),\n\t\t\t\t\tm(\"0\"),\n\t\t\t\t\tp(\"0\"),\n\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\tblock(),\n\t\t\t\t\tborder(\"none\"),\n\t\t\t\t\twhen(\"&::-webkit-meter-bar\", [bg(\"neutral.border\"), rounded(\"full\")]),\n\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, [rounded(\"full\"), transition(\"all\")])),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"brand\",\n\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"brand.solid\"))),\n\t\t\t\t\t),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"neutral\",\n\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"neutral.solid\"))),\n\t\t\t\t\t),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"success\",\n\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"success.solid\"))),\n\t\t\t\t\t),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"warning.solid\"))),\n\t\t\t\t\t),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"danger\",\n\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"danger.solid\"))),\n\t\t\t\t\t),\n\t\t\t\t\tmedia(\n\t\t\t\t\t\t\"(prefers-reduced-motion: reduce)\",\n\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, raw({ transitionDuration: \"0s\" }))),\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 gauge's caption: a `<span>` sized as a small run of body copy\n * in the neutral muted foreground color, for a percentage or status string\n * placed alongside {@link Meter.Indicator}.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the value label's markup.\n * @example\n * <Meter.ValueLabel>{t(\"storage.percent\", { value: 45 })}</Meter.ValueLabel>\n */\nMeter.ValueLabel = function MeterValueLabel(handle: Handle<Meter.ValueLabelProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <span {...rest} mix={[text(\"sm\"), tabularNums(), fg(\"neutral\"), mix]} />;\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "modal",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"dialog"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"Modal"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "modal.tsx",
|
|
12
|
+
"content": "/**\n * A pre-animated preset of {@link Dialog}: the same native `<dialog>` panel,\n * its `::backdrop` treatment, and every compound part, with the panel's own\n * pop-in and pop-out motion — a fade paired with a scale, entering from\n * slightly smaller than rest and leaving faster, shrinking only halfway back\n * and blurring softly as it fades — already wired onto the host.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { durations, easings } from \"@sdxc/ui/animations\";\nimport { enterExit } from \"@sdxc/ui/animations\";\n\nimport { Dialog } from \"@sdxc/ui/dialog\";\n\n/** `scale` factor {@link Modal}'s panel grows from on entry. */\nconst PANEL_ENTRY_SCALE = 0.95;\n\n/** `scale` factor the panel shrinks to on exit, halfway back toward its entry scale. */\nconst PANEL_EXIT_SCALE = 0.975;\n\n/** Blur radius in pixels the panel softens to as it fades out. */\nconst PANEL_EXIT_BLUR_PX = 2;\n\n/**\n * Prop types for {@link Modal} and its compound parts. Every part aliases\n * {@link Dialog}'s matching part, since {@link Modal} renders straight\n * through to {@link Dialog}'s own markup.\n */\nexport namespace Modal {\n\t/** Every prop {@link Dialog.Props} accepts, unchanged. */\n\texport interface Props extends Dialog.Props {}\n\n\t/** Every prop {@link Dialog.HeaderProps} accepts, unchanged. */\n\texport interface HeaderProps extends Dialog.HeaderProps {}\n\n\t/** Every prop {@link Dialog.TitleProps} accepts, unchanged. */\n\texport interface TitleProps extends Dialog.TitleProps {}\n\n\t/** Every prop {@link Dialog.DescriptionProps} accepts, unchanged. */\n\texport interface DescriptionProps extends Dialog.DescriptionProps {}\n\n\t/** Every prop {@link Dialog.FooterProps} accepts, unchanged. */\n\texport interface FooterProps extends Dialog.FooterProps {}\n\n\t/** Every prop {@link Dialog.CloseProps} accepts, unchanged. */\n\texport interface CloseProps extends Dialog.CloseProps {}\n}\n\n/**\n * Renders {@link Dialog} with its panel's pop-in/pop-out motion pre-wired\n * through `mix`, collapsing to an opacity-only fade under reduced motion.\n * A `mix` passed to {@link Modal} layers alongside the built-in motion.\n *\n * @param handle Runtime handle carrying the host `<dialog>`'s props.\n * @returns The render function producing the animated panel's markup.\n * @example\n * <Button commandfor=\"welcome\" command=\"show-modal\">{t(\"welcome.cta\")}</Button>\n * <Modal id=\"welcome\" aria-labelledby=\"welcome-title\">\n * \t<Modal.Header>\n * \t\t<Modal.Title id=\"welcome-title\">{t(\"welcome.title\")}</Modal.Title>\n * \t</Modal.Header>\n * </Modal>\n * @example\n * <Modal id=\"confirm-delete\" aria-labelledby=\"confirm-delete-title\">\n * \t<Modal.Close commandfor=\"confirm-delete\" aria-label={t(\"actions.close\")} />\n * \t<Modal.Header>\n * \t\t<Modal.Title id=\"confirm-delete-title\">{t(\"project.deleteTitle\")}</Modal.Title>\n * \t\t<Modal.Description>{t(\"project.deleteDescription\")}</Modal.Description>\n * \t</Modal.Header>\n * \t<Modal.Footer>\n * \t\t<Button commandfor=\"confirm-delete\" command=\"close\" color=\"danger\">{t(\"actions.delete\")}</Button>\n * \t</Modal.Footer>\n * </Modal>\n */\nexport function Modal(handle: Handle<Modal.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Dialog\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tenterExit({\n\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\tscale: PANEL_ENTRY_SCALE,\n\t\t\t\t\t\tduration: durations.normal,\n\t\t\t\t\t\teasing: easings.standard,\n\t\t\t\t\t\texit: { scale: PANEL_EXIT_SCALE, blur: PANEL_EXIT_BLUR_PX },\n\t\t\t\t\t\texitDuration: durations.fast,\n\t\t\t\t\t}),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link Modal.HeaderProps.children} as the panel's header slot:\n * identical to {@link Dialog.Header}, since {@link Modal} shares its panel\n * markup with {@link Dialog}.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the header slot's markup.\n * @example\n * <Modal.Header>\n * \t<Modal.Title>{t(\"welcome.title\")}</Modal.Title>\n * </Modal.Header>\n */\nModal.Header = Dialog.Header;\n\n/**\n * Renders {@link Modal.TitleProps.children} as the panel's heading:\n * identical to {@link Dialog.Title}.\n *\n * @param handle Runtime handle carrying the host `<h2>`'s props.\n * @returns The render function producing the heading's markup.\n * @example\n * <Modal.Title>{t(\"welcome.title\")}</Modal.Title>\n */\nModal.Title = Dialog.Title;\n\n/**\n * Renders {@link Modal.DescriptionProps.children} as the panel's supporting\n * copy: identical to {@link Dialog.Description}.\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 * <Modal.Description>{t(\"welcome.description\")}</Modal.Description>\n */\nModal.Description = Dialog.Description;\n\n/**\n * Renders {@link Modal.FooterProps.children} as the panel's action row:\n * identical to {@link Dialog.Footer}.\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 * <Modal.Footer>\n * \t<Button commandfor=\"welcome\" command=\"close\" variant=\"outline\">{t(\"actions.cancel\")}</Button>\n * \t<Button commandfor=\"welcome\" command=\"close\">{t(\"actions.continue\")}</Button>\n * </Modal.Footer>\n */\nModal.Footer = Dialog.Footer;\n\n/**\n * Renders a dismiss control for the ancestor {@link Modal} named by\n * `commandfor`: identical to {@link Dialog.Close}.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the dismiss control's markup.\n * @example\n * <Modal.Close commandfor=\"welcome\" aria-label={t(\"actions.close\")} />\n */\nModal.Close = Dialog.Close;\n"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nav-link",
|
|
3
|
+
"changedIn": "2026.10.2",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"NavLink"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "nav-link.tsx",
|
|
10
|
+
"content": "/**\n * An inline text link for site navigation, colored through a semantic color\n * role and underlined to read as a link among surrounding prose. Its\n * current-page state comes straight from `aria-current` set on the host\n * server-side, rendering the emphasized, non-underlined treatment directly\n * from that attribute.\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 { colorMix, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { cursor, raw } from \"@sdxc/u/general\";\nimport { data, hover, when } from \"@sdxc/u/state\";\nimport { textDecoration, weight } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\n\n/** Semantic color role {@link NavLink} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: NavLink.Color = \"neutral\";\n\n/**\n * Prop types for {@link NavLink}.\n */\nexport namespace NavLink {\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 * Props accepted by {@link NavLink}, built as an intersection: the\n\t * underlying anchor prop type is a union keyed on `href`, since the\n\t * accessible-anchor contract restricts `role` once `href` is present.\n\t */\n\texport type Props = TagProps<\"a\"> & {\n\t\t/** Destination the link navigates to. */\n\t\thref: string;\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/**\n\t\t * Marks the link as sitting over its own colored background: drops the\n\t\t * underline entirely, since the background fill already sets it apart\n\t\t * from surrounding text.\n\t\t */\n\t\thasBackground?: boolean;\n\t};\n}\n\n/**\n * Renders a native `<a>`, colored via `data-color` and underlined with a\n * translucent decoration that solidifies on hover. Setting `aria-current`\n * server-side renders the current-page treatment; the focus-visible ring always reads in the primary color.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the link's markup.\n * @example\n * <NavLink href=\"/dashboard\" color=\"brand\">{t(\"nav.dashboard\")}</NavLink>\n * @example\n * <NavLink href=\"/settings\" aria-current={pathname === \"/settings\" ? \"page\" : undefined}>{t(\"nav.settings\")}</NavLink>\n * @example\n * <NavLink href=\"/settings\" hasBackground mix={css({ paddingInline: \"0.75rem\", paddingBlock: \"0.5rem\" })}>{t(\"nav.settings\")}</NavLink>\n */\nexport function NavLink(handle: Handle<NavLink.Props>) {\n\treturn () => {\n\t\tlet { color, hasBackground, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tdata-has-background={hasBackground || undefined}\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\ttextDecoration(\"underline\"),\n\t\t\t\t\traw({\n\t\t\t\t\t\ttextDecorationColor: colorMix(\n\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t{ color: \"currentcolor\", weight: 60 },\n\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttextUnderlineOffset: \"4px\",\n\t\t\t\t\t}),\n\t\t\t\t\thover(raw({ textDecorationColor: \"currentcolor\" })),\n\t\t\t\t\tdata(\"color\", \"brand\", [\n\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\tfg(\"brand.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\tfg(\"success.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\tfg(\"warning.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"danger\", [\n\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\tfg(\"danger.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\traw({ textDecorationThickness: \"2px\", textDecorationColor: \"currentcolor\" }),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"has-background\", textDecoration(\"none\")),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t'&[data-has-background]:hover, &[data-has-background][aria-current]:not([aria-current=\"false\"])',\n\t\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\t),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "navigation-menu",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"popover"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"NavigationMenu"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "navigation-menu.tsx",
|
|
12
|
+
"content": "/**\n * A row of top-level navigation triggers, each either a plain link or a\n * button that opens a floating panel of related links. `NavigationMenu.Item`\n * hands its own stable id to whichever `NavigationMenu.Trigger` and\n * `NavigationMenu.Content` nest inside it through component context, so the\n * two pair up automatically — a consumer never wires a `commandfor`/`id`\n * pair by hand for the common case.\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, fg, outline, outlineStyle } from \"@sdxc/u/color\";\nimport {\n\topacity,\n\trounded,\n\ttransition,\n\ttransitionBehavior,\n\ttransitionProperty,\n} from \"@sdxc/u/effects\";\nimport { cursor, raw, userSelect } from \"@sdxc/u/general\";\nimport {\n\tcontainer,\n\tflex,\n\tflexCol,\n\tgap,\n\tgrid,\n\tgridTemplate,\n\tinlineFlex,\n\titems,\n\tjustify,\n\trelative,\n} from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { at, media, startingStyle } from \"@sdxc/u/responsive\";\nimport { bs, is, maxIs, mbs, minIs, pb, pi } from \"@sdxc/u/size\";\nimport { z } from \"@sdxc/u/stacking\";\nimport { data, disabled, hover, when } from \"@sdxc/u/state\";\nimport { scaleProperty } from \"@sdxc/u/transform\";\nimport { fontSize, leading, text, textDecoration, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { durations, easings } from \"@sdxc/ui/animations\";\nimport {\n\tconcentricRadius,\n\tfloatingSurface,\n\tsurfaceInset,\n\tsurfacePadding,\n} from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\n\nimport { Popover } from \"@sdxc/ui/popover\";\n\n/**\n * Named container {@link NavigationMenu.Content} declares on its own host, so\n * {@link NavigationMenu.ContentGrid} can adapt to the panel's own width\n * instead of the page's.\n */\nconst CONTAINER_NAME = \"ui-navigation-menu-content\";\n\n/**\n * `role=\"list\"` applied to {@link NavigationMenu.List} through {@link attrs}\n * unless a consumer supplies its own `role`, restoring list semantics that a\n * stylesheet clearing `list-style` otherwise drops for assistive technology.\n */\nconst DEFAULT_LIST_ROLE = \"list\";\n\n/**\n * Default {@link NavigationMenu.ListProps} orientation, applied when\n * `orientation` is omitted, laying triggers out in a single row.\n */\nconst DEFAULT_ORIENTATION: NavigationMenu.Orientation = \"horizontal\";\n\n/**\n * `type` {@link NavigationMenu.TriggerProps.type} falls back to when a\n * consumer doesn't supply one, keeping a click on the trigger from\n * submitting a surrounding `<form>`.\n */\nconst DEFAULT_TRIGGER_TYPE: NonNullable<NavigationMenu.TriggerProps[\"type\"]> = \"button\";\n\n/**\n * Invoker Commands verb {@link NavigationMenu.TriggerProps.command} falls\n * back to when omitted, showing the paired {@link NavigationMenu.Content} if\n * it's hidden and hiding it again if it's already showing.\n */\nconst DEFAULT_TRIGGER_COMMAND = \"toggle-popover\";\n\n/**\n * Side of the trigger {@link NavigationMenu.Content} renders against when\n * `placement` is left unset, matching a dropdown reading down and start-ward\n * from its trigger.\n */\nconst DEFAULT_CONTENT_PLACEMENT: NavigationMenu.ContentProps[\"placement\"] = \"bottom-start\";\n\n/**\n * {@link NavigationMenu.ContentProps.size} falls back to when omitted,\n * sizing the panel to its own content instead of a fixed wide measure.\n */\nconst DEFAULT_CONTENT_SIZE: NavigationMenu.ContentSize = \"default\";\n\n/**\n * Prop types for {@link NavigationMenu} and its compound parts.\n */\nexport namespace NavigationMenu {\n\t/**\n\t * Axis {@link NavigationMenu.List} lays its triggers out along: a single\n\t * row, or a single column.\n\t */\n\texport type Orientation = \"horizontal\" | \"vertical\";\n\n\t/**\n\t * Panel width {@link NavigationMenu.Content} renders at: sized to its own\n\t * content (`\"default\"`), or a fixed, generously wide measure that still\n\t * clamps to the viewport on narrow screens (`\"wide\"`).\n\t */\n\texport type ContentSize = \"default\" | \"wide\";\n\n\t/**\n\t * Value {@link NavigationMenu.Item} stores in component context so the\n\t * {@link NavigationMenu.Trigger} and {@link NavigationMenu.Content} nested\n\t * inside it pair up automatically.\n\t */\n\texport interface Context {\n\t\t/** Stable id the enclosing {@link NavigationMenu.Item} generated for its {@link NavigationMenu.Content}. */\n\t\tcontentId: string;\n\t}\n\n\t/**\n\t * Every native `<nav>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"nav\"> {\n\t\t/** The menu's own {@link NavigationMenu.List}, and anything else rendered alongside it (a {@link NavigationMenu.Viewport}, for instance). */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<ul>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface ListProps extends TagProps<\"ul\"> {\n\t\t/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t\t/** One or more {@link NavigationMenu.Item}s. */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<li>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface ItemProps extends TagProps<\"li\"> {\n\t\t/**\n\t\t * Either a standalone {@link NavigationMenu.Link}, or a\n\t\t * {@link NavigationMenu.Trigger} followed by the\n\t\t * {@link NavigationMenu.Content} it opens.\n\t\t */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<button>` attribute, plus the `mix` passthrough.\n\t * `commandfor` and `command` both default from the enclosing\n\t * {@link NavigationMenu.Item}'s context.\n\t */\n\texport interface TriggerProps extends TagProps<\"button\"> {}\n\n\t/**\n\t * Every prop {@link Popover.Props} accepts except `id`, which becomes\n\t * optional here since it defaults from the enclosing\n\t * {@link NavigationMenu.Item}'s context, plus `size`.\n\t */\n\texport interface ContentProps extends Omit<Popover.Props, \"id\" | \"placement\"> {\n\t\t/** Stable id matched against a {@link NavigationMenu.Trigger}'s `commandfor`. Defaults to the enclosing {@link NavigationMenu.Item}'s generated id. */\n\t\tid?: string;\n\t\t/** Side of the trigger to render against. Defaults to {@link DEFAULT_CONTENT_PLACEMENT}. */\n\t\tplacement?: Popover.Placement;\n\t\t/** Panel width. Defaults to {@link DEFAULT_CONTENT_SIZE}. */\n\t\tsize?: ContentSize;\n\t}\n\n\t/**\n\t * Every native `<a>` attribute, plus the `mix` passthrough. Uses an\n\t * intersection because the underlying anchor prop type is a union keyed on\n\t * `href`, narrowed here to required since a link needs a destination.\n\t */\n\texport type LinkProps = TagProps<\"a\"> & {\n\t\t/** Destination the link navigates to. */\n\t\thref: string;\n\t};\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface ViewportProps extends TagProps<\"div\"> {\n\t\t/** The currently active item's content, mirrored in from wherever it actually renders. */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface ContentListProps extends TagProps<\"div\"> {\n\t\t/** One or more {@link NavigationMenu.Link}s. */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface ContentGridProps extends TagProps<\"div\"> {\n\t\t/** Two or more {@link NavigationMenu.ContentColumn}s. */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface ContentColumnProps extends TagProps<\"div\"> {\n\t\t/** One or more {@link NavigationMenu.Link}s. */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Renders the menu's root host: a native `<nav>` landmark establishing a\n * positioning context for whatever floating panels its\n * {@link NavigationMenu.Content} instances anchor against.\n *\n * @param handle Runtime handle carrying the host `<nav>`'s props.\n * @returns The render function producing the menu's markup.\n * @example\n * <NavigationMenu aria-label={t(\"nav.primary\")}>\n * \t<NavigationMenu.List>\n * \t\t<NavigationMenu.Item>\n * \t\t\t<NavigationMenu.Link href=\"/\">{t(\"nav.home\")}</NavigationMenu.Link>\n * \t\t</NavigationMenu.Item>\n * \t</NavigationMenu.List>\n * </NavigationMenu>\n */\nexport function NavigationMenu(handle: Handle<NavigationMenu.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <nav {...rest} mix={[relative(), mix]} />;\n\t};\n}\n\n/**\n * Renders the row of top-level triggers: a native `<ul>` laying its\n * {@link NavigationMenu.Item}s out horizontally by default, switching to a\n * single start-aligned column when `orientation` is `\"vertical\"`.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <NavigationMenu.List>\n * \t<NavigationMenu.Item>\n * \t\t<NavigationMenu.Link href=\"/pricing\">{t(\"nav.pricing\")}</NavigationMenu.Link>\n * \t</NavigationMenu.Item>\n * </NavigationMenu.List>\n * @example\n * <NavigationMenu.List orientation=\"vertical\">\n * \t<NavigationMenu.Item>\n * \t\t<NavigationMenu.Link href=\"/settings/profile\">{t(\"nav.profile\")}</NavigationMenu.Link>\n * \t</NavigationMenu.Item>\n * </NavigationMenu.List>\n */\nNavigationMenu.List = function NavigationMenuList(handle: Handle<NavigationMenu.ListProps>) {\n\treturn () => {\n\t\tlet { orientation, mix, ...rest } = handle.props;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\n\t\treturn (\n\t\t\t<ul\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_LIST_ROLE }),\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(1),\n\t\t\t\t\twhen('&[data-orientation=\"vertical\"]', [flexCol(), items(\"start\")]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a single top-level entry: a native `<li>` holding either a\n * standalone {@link NavigationMenu.Link} or a {@link NavigationMenu.Trigger}\n * paired with the {@link NavigationMenu.Content} it opens.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props and providing {@link NavigationMenu.Context}.\n * @returns The render function producing the item's markup.\n * @example\n * <NavigationMenu.Item>\n * \t<NavigationMenu.Trigger>{t(\"nav.products\")}</NavigationMenu.Trigger>\n * \t<NavigationMenu.Content>\n * \t\t<NavigationMenu.ContentList>\n * \t\t\t<NavigationMenu.Link href=\"/products/one\">{t(\"products.one\")}</NavigationMenu.Link>\n * \t\t\t<NavigationMenu.Link href=\"/products/two\">{t(\"products.two\")}</NavigationMenu.Link>\n * \t\t</NavigationMenu.ContentList>\n * \t</NavigationMenu.Content>\n * </NavigationMenu.Item>\n */\nNavigationMenu.Item = function NavigationMenuItem(\n\thandle: Handle<NavigationMenu.ItemProps, NavigationMenu.Context>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\thandle.context.set({ contentId: handle.id });\n\n\t\treturn <li {...rest} mix={[relative(), flex(), items(\"center\"), mix]} />;\n\t};\n};\n\n/**\n * Renders a native `<button>` that opens the enclosing\n * {@link NavigationMenu.Item}'s {@link NavigationMenu.Content} through the\n * Invoker Commands API, so `aria-expanded` reflects the panel automatically.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the trigger's markup.\n * @example\n * <NavigationMenu.Trigger>{t(\"nav.products\")}</NavigationMenu.Trigger>\n * @example\n * <NavigationMenu.Trigger aria-disabled=\"true\">{t(\"nav.archived\")}</NavigationMenu.Trigger>\n */\nNavigationMenu.Trigger = function NavigationMenuTrigger(\n\thandle: Handle<NavigationMenu.TriggerProps>,\n) {\n\treturn () => {\n\t\tlet { type, commandfor, command, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(NavigationMenu.Item);\n\t\tlet resolvedType = type ?? DEFAULT_TRIGGER_TYPE;\n\t\tlet resolvedCommandfor = commandfor ?? context.contentId;\n\t\tlet resolvedCommand = command ?? DEFAULT_TRIGGER_COMMAND;\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\tcommandfor={resolvedCommandfor}\n\t\t\t\tcommand={resolvedCommand}\n\t\t\t\t{...rest}\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\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(2),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(3),\n\t\t\t\t\tpb(2),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\tdisabled(opacity(50)),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\twhen('&[aria-expanded=\"true\"]', [bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\tdisabled(cursor(\"not-allowed\")),\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 {@link NavigationMenu.Content}, the floating panel a\n * {@link NavigationMenu.Trigger} opens: a {@link Popover} that fades and\n * scales itself using the platform's own `:popover-open` state.\n *\n * @param handle Runtime handle carrying the host's {@link Popover} props.\n * @returns The render function producing the panel's markup.\n * @example\n * <NavigationMenu.Content>\n * \t<NavigationMenu.ContentList>\n * \t\t<NavigationMenu.Link href=\"/products/one\">{t(\"products.one\")}</NavigationMenu.Link>\n * \t</NavigationMenu.ContentList>\n * </NavigationMenu.Content>\n * @example\n * <NavigationMenu.Content size=\"wide\">\n * \t<NavigationMenu.ContentGrid>\n * \t\t<NavigationMenu.ContentColumn>\n * \t\t\t<NavigationMenu.Link href=\"/products/one\">{t(\"products.one\")}</NavigationMenu.Link>\n * \t\t</NavigationMenu.ContentColumn>\n * \t\t<NavigationMenu.ContentColumn>\n * \t\t\t<NavigationMenu.Link href=\"/products/two\">{t(\"products.two\")}</NavigationMenu.Link>\n * \t\t</NavigationMenu.ContentColumn>\n * \t</NavigationMenu.ContentGrid>\n * </NavigationMenu.Content>\n */\nNavigationMenu.Content = function NavigationMenuContent(\n\thandle: Handle<NavigationMenu.ContentProps>,\n) {\n\treturn () => {\n\t\tlet { id, placement, size, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(NavigationMenu.Item);\n\t\tlet resolvedId = id ?? context.contentId;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_CONTENT_PLACEMENT;\n\t\tlet resolvedSize = size ?? DEFAULT_CONTENT_SIZE;\n\n\t\treturn (\n\t\t\t<Popover\n\t\t\t\tid={resolvedId}\n\t\t\t\tplacement={resolvedPlacement}\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\tminIs(\"11rem\"),\n\t\t\t\t\tsurfaceInset({ scale: 2 }),\n\t\t\t\t\tz(50),\n\t\t\t\t\topacity(0),\n\t\t\t\t\twhen('& [data-slot=\"link\"]', [is(\"full\"), justify(\"start\")]),\n\t\t\t\t\twhen('&[data-size=\"wide\"]', [is(\"28rem\"), maxIs(\"calc(100vw - 2rem)\")]),\n\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\ttransition(\"opacity, scale, display, overlay\", {\n\t\t\t\t\t\tduration: durations.fast,\n\t\t\t\t\t\teasing: easings.standard,\n\t\t\t\t\t}),\n\t\t\t\t\toutlineStyle(\"none\"),\n\t\t\t\t\tscaleProperty(\"0.95\"),\n\t\t\t\t\ttransitionBehavior(\"allow-discrete\"),\n\t\t\t\t\twhen(\"&:popover-open\", [opacity(100), scaleProperty(\"none\")]),\n\t\t\t\t\tstartingStyle(when(\"&:popover-open\", [opacity(0), scaleProperty(\"0.95\")])),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\tscaleProperty(\"none\"),\n\t\t\t\t\t\ttransitionProperty(\"opacity, display, overlay\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link NavigationMenu.LinkProps.children} as a native `<a>`.\n * `aria-current` marks the active page; `aria-disabled=\"true\"` only mutes it\n * visually, since a plain `<a>` has no native disabled state to block clicks.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the link's markup.\n * @example\n * <NavigationMenu.Link href=\"/pricing\">{t(\"nav.pricing\")}</NavigationMenu.Link>\n * @example\n * <NavigationMenu.Link href=\"/dashboard\" aria-current={pathname === \"/dashboard\" ? \"page\" : undefined}>\n * \t{t(\"nav.dashboard\")}\n * </NavigationMenu.Link>\n */\nNavigationMenu.Link = function NavigationMenuLink(handle: Handle<NavigationMenu.LinkProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\tdata-slot=\"link\"\n\t\t\t\t{...rest}\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\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(2),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(3),\n\t\t\t\t\tpb(2),\n\t\t\t\t\tleading(1),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [opacity(50), cursor(\"not-allowed\")]),\n\t\t\t\t\tuserSelect(),\n\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\tfontSize(\"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 a shared, animated surface that swaps in the active\n * {@link NavigationMenu.Item}'s content, sized by the custom properties a\n * pairing mixin writes as it measures the active panel and toggles visibility.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the shared frame's markup.\n * @example\n * <NavigationMenu.Viewport data-visible={isMenuOpen || undefined} />\n */\nNavigationMenu.Viewport = function NavigationMenuViewport(\n\thandle: Handle<NavigationMenu.ViewportProps>,\n) {\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\tfloatingSurface(),\n\t\t\t\t\traw({ borderRadius: concentricRadius(surfacePadding(2)) }),\n\t\t\t\t\trelative(),\n\t\t\t\t\tmbs(2),\n\t\t\t\t\toverflow(),\n\t\t\t\t\tis(\"var(--ui-navigation-menu-viewport-inline-size, auto)\"),\n\t\t\t\t\tbs(\"var(--ui-navigation-menu-viewport-block-size, auto)\"),\n\t\t\t\t\topacity(0),\n\t\t\t\t\ttransition(\"inline-size, block-size, opacity, scale\", {\n\t\t\t\t\t\tduration: durations.normal,\n\t\t\t\t\t\teasing: easings.decelerate,\n\t\t\t\t\t}),\n\t\t\t\t\tscaleProperty(\"0.95\"),\n\t\t\t\t\tdata(\"visible\", [opacity(100), scaleProperty(\"none\")]),\n\t\t\t\t\tstartingStyle(data(\"visible\", [opacity(0), scaleProperty(\"0.95\")])),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\tscaleProperty(\"none\"),\n\t\t\t\t\t\ttransitionProperty(\"inline-size, block-size, opacity\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link NavigationMenu.ContentListProps.children} as a plain\n * vertical run of {@link NavigationMenu.Link}s inside\n * {@link NavigationMenu.Content}, for a dropdown that's just a short list.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <NavigationMenu.ContentList>\n * \t<NavigationMenu.Link href=\"/products/one\">{t(\"products.one\")}</NavigationMenu.Link>\n * \t<NavigationMenu.Link href=\"/products/two\">{t(\"products.two\")}</NavigationMenu.Link>\n * </NavigationMenu.ContentList>\n */\nNavigationMenu.ContentList = function NavigationMenuContentList(\n\thandle: Handle<NavigationMenu.ContentListProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} mix={[grid(), gap(1), mix]} />;\n\t};\n};\n\n/**\n * Renders {@link NavigationMenu.ContentGridProps.children} as a\n * multi-column layout inside {@link NavigationMenu.Content}: a single column\n * while the panel's own container is narrower than `40rem`, else two columns.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the grid's markup.\n * @example\n * <NavigationMenu.Content size=\"wide\">\n * \t<NavigationMenu.ContentGrid>\n * \t\t<NavigationMenu.ContentColumn>\n * \t\t\t<NavigationMenu.Link href=\"/products/one\">{t(\"products.one\")}</NavigationMenu.Link>\n * \t\t</NavigationMenu.ContentColumn>\n * \t\t<NavigationMenu.ContentColumn>\n * \t\t\t<NavigationMenu.Link href=\"/products/two\">{t(\"products.two\")}</NavigationMenu.Link>\n * \t\t</NavigationMenu.ContentColumn>\n * \t</NavigationMenu.ContentGrid>\n * </NavigationMenu.Content>\n */\nNavigationMenu.ContentGrid = function NavigationMenuContentGrid(\n\thandle: Handle<NavigationMenu.ContentGridProps>,\n) {\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\tgrid(),\n\t\t\t\t\tgap(4),\n\t\t\t\t\tat(\"40rem\", CONTAINER_NAME, gridTemplate({ columns: \"repeat(2, minmax(0, 1fr))\" })),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link NavigationMenu.ContentColumnProps.children} as one column of\n * stacked {@link NavigationMenu.Link}s inside a\n * {@link NavigationMenu.ContentGrid}.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the column's markup.\n * @example\n * <NavigationMenu.ContentColumn>\n * \t<NavigationMenu.Link href=\"/products/one\">{t(\"products.one\")}</NavigationMenu.Link>\n * </NavigationMenu.ContentColumn>\n */\nNavigationMenu.ContentColumn = function NavigationMenuContentColumn(\n\thandle: Handle<NavigationMenu.ContentColumnProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} mix={[grid(), gap(1), mix]} />;\n\t};\n};\n"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "number-field",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"input"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"NumberField"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "number-field.tsx",
|
|
12
|
+
"content": "/**\n * A numeric field pairing a native `<input type=\"number\">` control with a\n * decrement and an increment button, all three sharing one bordered,\n * rounded frame. The frame draws its own box styling and keyboard focus\n * ring, so the input inside sits flush against its neighboring buttons\n * instead of carrying a competing border of 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 { MinusIcon, PlusIcon } from \"@sdxc/icons\";\nimport { bg, border, borderEdge, fg, outline, outlineWidth } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, raw } from \"@sdxc/u/general\";\nimport { basis, flex, grow, inlineFlex, items, justify, shrink } from \"@sdxc/u/layout\";\nimport { bs, is } from \"@sdxc/u/size\";\nimport { active, focusVisible, hover, invalid, when } from \"@sdxc/u/state\";\nimport { tabularNums, textAlign } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { fieldStackLayout } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\n\nimport { Input } from \"@sdxc/ui/input\";\n\n/**\n * ARIA role applied to {@link NumberField.Group} through {@link attrs}\n * unless a consumer supplies its own `role`, announcing the frame as one\n * related unit to assistive technology.\n */\nconst DEFAULT_ROLE = \"group\";\n\n/**\n * Native `<button>` `type` {@link NumberField.DecrementButton} and\n * {@link NumberField.IncrementButton} fall back to when a consumer doesn't\n * supply one, keeping a click on either from submitting a surrounding `<form>`.\n */\nconst DEFAULT_BUTTON_TYPE: NonNullable<NumberField.DecrementButtonProps[\"type\"]> = \"button\";\n\n/**\n * Shared box, color, and interaction-state styling for\n * {@link NumberField.DecrementButton} and {@link NumberField.IncrementButton},\n * differing only in which inline edge carries the divider border.\n *\n * @param dividerEdge Which inline edge carries the divider border: `\"end\"` for the control preceding the input, `\"start\"` for the one following it.\n * @returns The mixins shared by both stepper buttons.\n */\nfunction stepperButtonMix(dividerEdge: \"start\" | \"end\") {\n\treturn [\n\t\tinteractiveTransition(),\n\t\tflex(),\n\t\titems(\"center\"),\n\t\tjustify(\"center\"),\n\t\tis(\"2.5rem\"),\n\t\tfg(\"neutral\"),\n\t\tborder(\"neutral\"),\n\t\tborderEdge(dividerEdge === \"start\" ? \"inline-start\" : \"inline-end\", { width: 1 }),\n\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\trounded(\"none\"),\n\t\tbg(\"transparent\"),\n\t\twhen(\"& svg\", [is(\"1rem\"), bs(\"1rem\")]),\n\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t];\n}\n\n/**\n * Prop types for {@link NumberField} and its compound parts.\n */\nexport namespace NumberField {\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * `children` composes this field's parts — typically a caption, the\n\t * {@link NumberField.Group} row, and any supporting or validation copy.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * `children` composes {@link NumberField.DecrementButton},\n\t * {@link NumberField.Input}, and {@link NumberField.IncrementButton}.\n\t */\n\texport interface GroupProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every prop {@link Input.Props} accepts except `type` and `role`, fixed to\n\t * `\"number\"` and the platform's own `spinbutton` role, and `color`, unexposed\n\t * since the keyboard focus ring is deferred to {@link NumberField.Group}.\n\t */\n\texport interface InputProps extends Omit<Input.Props, \"type\" | \"role\" | \"color\"> {}\n\n\t/**\n\t * Every native `<button>` attribute except `children`, which stays fixed\n\t * to this button's own decrement glyph, plus the `mix` passthrough.\n\t * `type` defaults to {@link DEFAULT_BUTTON_TYPE}.\n\t */\n\texport interface DecrementButtonProps extends Omit<TagProps<\"button\">, \"children\"> {}\n\n\t/**\n\t * Every native `<button>` attribute except `children`, which stays fixed\n\t * to this button's own increment glyph, plus the `mix` passthrough.\n\t * `type` defaults to {@link DEFAULT_BUTTON_TYPE}.\n\t */\n\texport interface IncrementButtonProps extends Omit<TagProps<\"button\">, \"children\"> {}\n}\n\n/**\n * Renders a plain host stacking this field's compound parts in a single\n * column with a small gap between them: typically a caption, the\n * {@link NumberField.Group} row, and any supporting or validation copy.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <NumberField>\n * \t<Label htmlFor=\"quantity\">{t(\"form.quantity.label\")}</Label>\n * \t<NumberField.Group>\n * \t\t<NumberField.DecrementButton aria-label={t(\"stepper.decrement\")} />\n * \t\t<NumberField.Input id=\"quantity\" name=\"quantity\" min={0} max={10} defaultValue={1} />\n * \t\t<NumberField.IncrementButton aria-label={t(\"stepper.increment\")} />\n * \t</NumberField.Group>\n * </NumberField>\n */\nexport function NumberField(handle: Handle<NumberField.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"number-field\" mix={[fieldStackLayout(), mix]} />;\n\t};\n}\n\n/**\n * Renders {@link NumberField}'s frame: a `role=\"group\"` `<div>` drawing a\n * bordered, rounded, tinted-background box that reads as one seamless\n * control, ringing the whole frame via `:focus-within` when a child gains focus.\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 * <NumberField.Group>\n * \t<NumberField.DecrementButton aria-label={t(\"stepper.decrement\")} />\n * \t<NumberField.Input aria-label={t(\"form.quantity.label\")} />\n * \t<NumberField.IncrementButton aria-label={t(\"stepper.increment\")} />\n * </NumberField.Group>\n */\nNumberField.Group = function NumberFieldGroup(handle: Handle<NumberField.GroupProps>) {\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=\"group\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_ROLE }),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"stretch\"),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\thover(border(\"neutral.border-hover\")),\n\t\t\t\t\t/**\n\t\t\t\t\t * The wrapper wears the focus of whichever part holds it as a ring standing off the\n\t\t\t\t\t * field, as every button here does; the border steps only to its hover weight, since a\n\t\t\t\t\t * darkened border flush with the ring reads as one thick slab.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&:focus-within\", [\n\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\tborder(\"neutral.border-hover\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link NumberField}'s control: a native `<input type=\"number\">`\n * built on {@link Input}. The stepper buttons need a separately wired\n * `stepUp()`/`stepDown()` for press-and-hold repeat; typed entry works without it.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <NumberField.Input aria-label={t(\"form.quantity.label\")} min={0} max={10} defaultValue={1} />\n * @example\n * <NumberField.Input id=\"price\" name=\"price\" step={0.01} aria-invalid=\"true\" />\n */\nNumberField.Input = function NumberFieldInput(handle: Handle<NumberField.InputProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\ttype=\"number\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\ttextAlign(\"center\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\trounded(\"none\"),\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\tborder({ width: \"0\", noStyleDefault: true }),\n\t\t\t\t\traw({\n\t\t\t\t\t\t\"-moz-appearance\": \"textfield\",\n\n\t\t\t\t\t\t\"&::-webkit-inner-spin-button, &::-webkit-outer-spin-button\": {\n\t\t\t\t\t\t\t\"-webkit-appearance\": \"none\",\n\t\t\t\t\t\t\tmargin: \"0\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\tfg(\"inherit\"),\n\t\t\t\t\twhen(\"&:disabled\", bg(\"transparent\")),\n\t\t\t\t\tfocusVisible(outlineWidth(\"0\")),\n\t\t\t\t\tinvalid([outlineWidth(\"0\"), fg(\"danger\")]),\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 native `<button>` decrementing {@link NumberField.Input}'s\n * value; its glyph is `aria-hidden`, so callers must supply an `aria-label`.\n * In dev mode, a missing `aria-label`/`aria-labelledby` logs a `console.warn`.\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 * <NumberField.DecrementButton aria-label={t(\"stepper.decrement\")} />\n * @example\n * <NumberField.DecrementButton aria-label={t(\"stepper.decrement\")} disabled={quantity <= 0} />\n */\nNumberField.DecrementButton = function NumberFieldDecrementButton(\n\thandle: Handle<NumberField.DecrementButtonProps>,\n) {\n\treturn () => {\n\t\tlet { type, mix, ...rest } = handle.props;\n\n\t\tif (import.meta.env.DEV && !handle.props[\"aria-label\"] && !handle.props[\"aria-labelledby\"]) {\n\t\t\tconsole.warn(\n\t\t\t\t\"NumberField.DecrementButton: needs an `aria-label` describing what it does — its content is a decorative glyph with no accessible name of its own.\",\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={type ?? DEFAULT_BUTTON_TYPE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"decrement\"\n\t\t\t\tmix={[stepperButtonMix(\"end\"), mix]}\n\t\t\t>\n\t\t\t\t<MinusIcon />\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders a native `<button>` incrementing {@link NumberField.Input}'s\n * value; its glyph is `aria-hidden`, so callers must supply an `aria-label`.\n * In dev mode, a missing `aria-label`/`aria-labelledby` logs a `console.warn`.\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 * <NumberField.IncrementButton aria-label={t(\"stepper.increment\")} />\n * @example\n * <NumberField.IncrementButton aria-label={t(\"stepper.increment\")} disabled={quantity >= 10} />\n */\nNumberField.IncrementButton = function NumberFieldIncrementButton(\n\thandle: Handle<NumberField.IncrementButtonProps>,\n) {\n\treturn () => {\n\t\tlet { type, mix, ...rest } = handle.props;\n\n\t\tif (import.meta.env.DEV && !handle.props[\"aria-label\"] && !handle.props[\"aria-labelledby\"]) {\n\t\t\tconsole.warn(\n\t\t\t\t\"NumberField.IncrementButton: needs an `aria-label` describing what it does — its content is a decorative glyph with no accessible name of its own.\",\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={type ?? DEFAULT_BUTTON_TYPE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"increment\"\n\t\t\t\tmix={[stepperButtonMix(\"start\"), mix]}\n\t\t\t>\n\t\t\t\t<PlusIcon />\n\t\t\t</button>\n\t\t);\n\t};\n};\n"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "otp-field",
|
|
3
|
+
"changedIn": "2026.10.2",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"input"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"OtpField"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "otp-field.tsx",
|
|
12
|
+
"content": "/**\n * A one-time-code field: a native `<input>` defaulting to a numeric virtual\n * keyboard and the platform's SMS/email autofill hint for one-time codes,\n * built on {@link Input} for its box, color, and interaction-state styling.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Maximum code length {@link OtpField} falls back to when `length` is omitted. */\nconst DEFAULT_LENGTH = 6;\n\n/** Virtual-keyboard hint {@link OtpField} falls back to when `inputMode` is omitted. */\nconst DEFAULT_INPUT_MODE = \"numeric\";\n\n/** Platform autofill hint {@link OtpField} falls back to when `autoComplete` is omitted. */\nconst DEFAULT_AUTO_COMPLETE = \"one-time-code\";\n\n/**\n * Prop types for {@link OtpField}.\n */\nexport namespace OtpField {\n\t/**\n\t * Every {@link Input} prop except `type`, `list`, `role`, `inputMode`,\n\t * `autoComplete`, and `maxLength`, fixed to a plain text control with\n\t * `inputMode`/`autoComplete`/`length` read from the fields below instead.\n\t */\n\texport interface Props extends Omit<\n\t\tInput.Props,\n\t\t\"type\" | \"list\" | \"role\" | \"inputMode\" | \"autoComplete\" | \"maxLength\"\n\t> {\n\t\t/**\n\t\t * The one-time code's character count, applied as the control's native\n\t\t * `maxLength`. Defaults to {@link DEFAULT_LENGTH}.\n\t\t */\n\t\tlength?: number;\n\t\t/**\n\t\t * Virtual-keyboard hint passed straight through to the native `inputMode`\n\t\t * attribute. Defaults to {@link DEFAULT_INPUT_MODE}, requesting the\n\t\t * numeric keypad; set it to `\"text\"` for a code that mixes in letters.\n\t\t */\n\t\tinputMode?: Input.Props[\"inputMode\"];\n\t\t/**\n\t\t * Platform autofill hint passed straight through to the native\n\t\t * `autoComplete` attribute. Defaults to {@link DEFAULT_AUTO_COMPLETE}, which\n\t\t * a browser or OS keyboard looks for to offer an SMS or email code inline.\n\t\t */\n\t\tautoComplete?: Input.Props[\"autoComplete\"];\n\t}\n}\n\n/**\n * Renders a single native `<input>` for entering a one-time verification\n * code, built on {@link Input}, sized as one full-width control since a\n * single `<input>` is what carries `autoComplete=\"one-time-code\"` reliably.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"otp\">{t(\"auth.otp.label\")}</Label>\n * <OtpField id=\"otp\" name=\"code\" autoFocus />\n * @example\n * <OtpField\n * \tid=\"otp\"\n * \tname=\"code\"\n * \taria-describedby=\"otp-error\"\n * \taria-invalid=\"true\"\n * />\n * <FieldError id=\"otp-error\">{t(\"auth.otp.invalid\")}</FieldError>\n * @example\n * <OtpField\n * \tid=\"invite-code\"\n * \tname=\"inviteCode\"\n * \tlength={8}\n * \tinputMode=\"text\"\n * \tautoComplete=\"off\"\n * \tpattern=\"[A-Za-z0-9]*\"\n * />\n */\nexport function OtpField(handle: Handle<OtpField.Props>) {\n\treturn () => {\n\t\tlet { length, inputMode, autoComplete, mix, ...rest } = handle.props;\n\t\tlet resolvedLength = length ?? DEFAULT_LENGTH;\n\t\tlet resolvedInputMode = inputMode ?? DEFAULT_INPUT_MODE;\n\t\tlet resolvedAutoComplete = autoComplete ?? DEFAULT_AUTO_COMPLETE;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputMode={resolvedInputMode}\n\t\t\t\tautoComplete={resolvedAutoComplete}\n\t\t\t\tmaxLength={resolvedLength}\n\t\t\t\tdata-slot=\"otp-field\"\n\t\t\t\tmix={[textAlign(\"center\"), weight(500), tabularNums(), text(\"base\"), mix]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
13
|
+
},
|
|
14
|
+
"test": null
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "overlay-arrow",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"OverlayArrow"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "overlay-arrow.tsx",
|
|
10
|
+
"content": "/**\n * A small pointer glyph anchoring an overlay surface — a popover, a menu, a\n * tooltip — visually back to the trigger it floats beside. It renders as an\n * absolutely positioned host holding whatever arrow shape a consumer draws\n * as its child (typically an inline `<svg>`), oriented and offset by the\n * `data-placement` attribute contract.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { fill } from \"@sdxc/u/color\";\nimport { calc, pointerEvents, var as varUtility } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinsLeft,\n\tinsRight,\n\titems,\n\tjustify,\n} from \"@sdxc/u/layout\";\nimport { is, mb, mi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { attrs } from \"remix/component\";\n\n/**\n * Side of the overlay {@link OverlayArrow} attaches to when `placement` is\n * left unset. Matches the side an overlay renders on when its own placement\n * request goes unanswered by the positioning engine.\n */\nconst DEFAULT_PLACEMENT: OverlayArrow.Placement = \"bottom\";\n\n/**\n * `aria-hidden=\"true\"` applied through {@link attrs} unless a consumer\n * overrides it, keeping the purely decorative pointer glyph out of the\n * accessibility tree.\n */\nconst DEFAULT_ARIA_HIDDEN = \"true\";\n\n/**\n * Prop types for {@link OverlayArrow}.\n */\nexport namespace OverlayArrow {\n\t/**\n\t * Side (and, for the four corner variants, alignment) of the trigger an\n\t * overlay renders relative to. {@link OverlayArrow} reads only the leading\n\t * segment; the `-start`/`-end` suffix carries no visual effect on the arrow.\n\t */\n\texport type Placement =\n\t\t| \"top\"\n\t\t| \"top-start\"\n\t\t| \"top-end\"\n\t\t| \"bottom\"\n\t\t| \"bottom-start\"\n\t\t| \"bottom-end\"\n\t\t| \"left\"\n\t\t| \"left-start\"\n\t\t| \"left-end\"\n\t\t| \"right\"\n\t\t| \"right-start\"\n\t\t| \"right-end\";\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, plus the\n\t * `placement` that drives which edge of the overlay the arrow attaches to.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Side of the trigger the overlay renders on. Defaults to\n\t\t * {@link DEFAULT_PLACEMENT}.\n\t\t */\n\t\tplacement?: Placement;\n\t}\n}\n\n/**\n * Renders a decorative pointer glyph, rotating to point back at the trigger\n * from whichever edge the overlay attaches to. `\"left\"`/`\"right\"` name a\n * physical viewport side, so the arrow keeps attaching there under any `dir`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the arrow's markup.\n * @example\n * <Popover>\n * \t<OverlayArrow placement=\"bottom\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function OverlayArrow(handle: Handle<OverlayArrow.Props>) {\n\treturn () => {\n\t\tlet { placement, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ARIA_HIDDEN }),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\t/**\n\t\t\t\t\t * The host spans the whole edge it attaches to, so centring the glyph inside it\n\t\t\t\t\t * is what puts the point under the trigger the surface is anchored to.\n\t\t\t\t\t */\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tfill(\"neutral.tint\"),\n\t\t\t\t\tpointerEvents(),\n\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', [\n\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\trotate(180),\n\t\t\t\t\t\tinsBs(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"top\"]', [\n\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\tinsBe(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * A side placement sits past the surface's own inline edge, where the space\n\t\t\t\t\t * left to grow into is none, so the glyph is sized from its own content the\n\t\t\t\t\t * way the block placements are sized from theirs.\n\t\t\t\t\t */\n\t\t\t\t\twhen('&[data-placement^=\"left\"]', [\n\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\trotate(-90),\n\t\t\t\t\t\tinsLeft(\"100%\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"right\"]', [\n\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\trotate(90),\n\t\t\t\t\t\tinsRight(\"100%\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pagination",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Pagination"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "pagination.tsx",
|
|
10
|
+
"content": "/**\n * A navigation landmark for moving between pages of results, composing a\n * `<nav>` root, an `<ul>` list, and `<li>` items around two interactive\n * parts: {@link Pagination.Link} for page-number destinations and\n * {@link Pagination.Button} for previous/next controls. The active page reads\n * straight from the native `aria-current` attribute a consumer sets while\n * rendering the current page's link server-side, with no client-tracked\n * route state anywhere in this module.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { bg, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, pointerEvents } from \"@sdxc/u/general\";\nimport { flex, gap, inlineFlex, items, justify } from \"@sdxc/u/layout\";\nimport { bs, m, minIs, p, pi } from \"@sdxc/u/size\";\nimport { active, hover, when } from \"@sdxc/u/state\";\nimport { tabularNums, text, textDecoration, weight } from \"@sdxc/u/typography\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport {\n\twarnIfNoAccessibleLabel,\n\twarnIfNoAccessibleName,\n} from \"@sdxc/ui/utils\";\n\n/**\n * `type` given to a {@link Pagination.Button} carrying an Invoker Command, for\n * which the platform accepts no other value.\n */\nconst INVOKER_TYPE = \"button\";\n\n/**\n * Prop types for {@link Pagination} and its compound parts.\n */\nexport namespace Pagination {\n\t/**\n\t * Every native `<nav>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"nav\"> {}\n\n\t/**\n\t * Every native `<ul>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ListProps extends TagProps<\"ul\"> {}\n\n\t/**\n\t * Every native `<li>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ItemProps extends TagProps<\"li\"> {}\n\n\t/**\n\t * Every native `<a>` attribute, plus the `mix` passthrough. A type alias\n\t * rather than an interface, since native anchor props resolve through a\n\t * conditional type an `interface extends` clause can't statically extend.\n\t */\n\texport type LinkProps = TagProps<\"a\">;\n\n\t/**\n\t * Every native `<button>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ButtonProps extends TagProps<\"button\"> {}\n}\n\n/**\n * Renders the pagination's `<nav>` root, laying its single {@link\n * Pagination.List} child out as a centered row. In dev mode, a root missing\n * `aria-label`/`aria-labelledby` logs a `console.warn` for assistive tech.\n *\n * @param handle Runtime handle carrying the host `<nav>`'s props.\n * @returns The render function producing the navigation landmark's markup.\n * @example\n * <Pagination aria-label={t(\"pagination.label\")}>\n * \t<Pagination.List>\n * \t\t<Pagination.Item>\n * \t\t\t<Pagination.Link href=\"?page=1\" aria-current=\"page\">1</Pagination.Link>\n * \t\t</Pagination.Item>\n * \t</Pagination.List>\n * </Pagination>\n */\nexport function Pagination(handle: Handle<Pagination.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Pagination: needs an \"aria-label\" or \"aria-labelledby\" identifying which set of results it paginates for assistive technology.',\n\t\t);\n\n\t\treturn <nav {...rest} data-slot=\"pagination\" mix={[flex(), items(\"center\"), mix]} />;\n\t};\n}\n\n/**\n * Renders the pagination's `<ul>` list, resetting native list markers and\n * spacing and laying {@link Pagination.Item} children out as a centered row\n * with a small gap between them.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Pagination.List>\n * \t<Pagination.Item>\n * \t\t<Pagination.Link href=\"?page=1\" aria-current=\"page\">1</Pagination.Link>\n * \t</Pagination.Item>\n * \t<Pagination.Item>\n * \t\t<Pagination.Link href=\"?page=2\">2</Pagination.Link>\n * \t</Pagination.Item>\n * </Pagination.List>\n */\nPagination.List = function PaginationList(handle: Handle<Pagination.ListProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"list\"\n\t\t\t\tmix={[flex(), items(\"center\"), gap(\"0.25rem\"), m(\"0\"), p(\"0\"), listStyle(), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a single `<li>` wrapping one {@link Pagination.Link} or\n * {@link Pagination.Button}, centering its content — this element carries no\n * visual styling of its own beyond the layout needed to hold its child.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props.\n * @returns The render function producing the item's markup.\n * @example\n * <Pagination.Item>\n * \t<Pagination.Link href=\"?page=3\">3</Pagination.Link>\n * </Pagination.Item>\n */\nPagination.Item = function PaginationItem(handle: Handle<Pagination.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <li {...rest} data-slot=\"item\" mix={[flex(), items(\"center\"), mix]} />;\n\t};\n};\n\n/**\n * Renders a page-number destination as a native `<a>`. Setting\n * `aria-current=\"page\"` fills it with the active-page treatment, and\n * `aria-disabled=\"true\"` mutes it and blocks pointer interaction.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the link's markup.\n * @example\n * <Pagination.Link href=\"?page=4\">4</Pagination.Link>\n * @example\n * <Pagination.Link href=\"?page=5\" aria-current=\"page\">5</Pagination.Link>\n * @example\n * <Pagination.Link aria-disabled=\"true\">…</Pagination.Link>\n */\nPagination.Link = function PaginationLink(handle: Handle<Pagination.LinkProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"link\"\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tbs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\tminIs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\tweight(500),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', opacity(50)),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), pointerEvents()]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a previous/next control as a native `<button>`. A control with\n * `command`/`commandfor` renders `type=\"button\"` first, since the platform's\n * ambiguity check can't see a `type` written after those attributes.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <Pagination.Button aria-label={t(\"pagination.previous\")} disabled={!hasPreviousPage}>\n * \t<ChevronLeftIcon aria-hidden />\n * </Pagination.Button>\n * @example\n * <Pagination.Button aria-label={t(\"pagination.next\")} disabled={!hasNextPage}>\n * \t<ChevronRightIcon aria-hidden />\n * </Pagination.Button>\n */\nPagination.Button = function PaginationButton(handle: Handle<Pagination.ButtonProps>) {\n\treturn () => {\n\t\tlet { type, children, mix, ...rest } = handle.props;\n\t\tlet isInvoker = rest.command !== undefined || rest.commandfor !== undefined;\n\t\tlet resolvedType = type ?? (isInvoker ? INVOKER_TYPE : undefined);\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t'Pagination.Button: an icon-only control needs an \"aria-label\" describing what it does — assistive technology has no accessible text to announce otherwise.',\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"button\"\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tbs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\tminIs(\"var(--ui-pagination-control-size, 2.25rem)\"),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(\"0.75rem\"),\n\t\t\t\t\tweight(500),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\twhen(\"&:disabled\", opacity(50)),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\twhen(\"&:disabled\", cursor(\"not-allowed\")),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"path": "pagination.test.tsx",
|
|
14
|
+
"content": "/**\n * Tests for the `type` {@link Pagination.Button} resolves: a control carrying an\n * Invoker Command renders `type=\"button\"` on its own, before the command\n * attributes, because inside a `<form>` an untyped button is a submit button and\n * the platform then refuses to run its command at all — judging that while it\n * parses `command`/`commandfor`, so a `type` written after them is refused the\n * same way. A control carrying no command is left untyped, so a previous/next\n * control a consumer wired to a real form still submits it.\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 { Pagination } from \"@sdxc/ui/pagination\";\n\ndescribe(\"Pagination.Button\", () => {\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<Pagination.Button aria-label=\"Next\" commandfor=\"results\" command=\"next\">\n\t\t\t\tNext\n\t\t\t</Pagination.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(\n\t\t\t<Pagination.Button aria-label=\"Next\" commandfor=\"results\">\n\t\t\t\tNext\n\t\t\t</Pagination.Button>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"button\"');\n\t});\n\n\ttest(\"renders no type of its own for a control carrying no command\", async () => {\n\t\tlet html = await renderToString(<Pagination.Button aria-label=\"Next\">Next</Pagination.Button>);\n\n\t\texpect(html).not.toContain(\"type=\");\n\t});\n\n\ttest(\"leaves an explicitly typed submit control alone\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Pagination.Button aria-label=\"Next\" type=\"submit\">\n\t\t\t\tNext\n\t\t\t</Pagination.Button>,\n\t\t);\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<Pagination.Button aria-label=\"Next\" commandfor=\"results\" command=\"next\">\n\t\t\t\tNext\n\t\t\t</Pagination.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"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "popover",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Popover"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "popover.tsx",
|
|
10
|
+
"content": "/**\n * A floating surface anchored to whatever element opened it, built entirely\n * on the native Popover API: the host carries the `popover` attribute and\n * opens through `popovertarget` or a Command Invoker (`commandfor`/\n * `command=\"toggle-popover\"`) elsewhere on the page, with no positioning\n * logic running in script. Placement rides CSS anchor positioning, using\n * the invoker relationship as an implicit anchor and the `data-placement`\n * attribute to pick which `position-area` it resolves against.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { raw } from \"@sdxc/u/general\";\nimport { inset, positionArea, positionTryFallbacks } from \"@sdxc/u/layout\";\nimport { m, marginLeft, marginRight, mbe, mbs } from \"@sdxc/u/size\";\nimport { data, when } from \"@sdxc/u/state\";\n\nimport type { AnchorPlacement } from \"@sdxc/ui/utils\";\n\nimport { floatingSurface } from \"@sdxc/ui/styles\";\n\n/**\n * Side of the anchor {@link Popover} renders against when `placement` is\n * left unset.\n */\nconst DEFAULT_PLACEMENT: Popover.Placement = \"bottom\";\n\n/**\n * `popover` attribute mode applied when a consumer leaves it unset, giving\n * the host light-dismiss behavior: it closes on outside click or Escape, and\n * showing it closes any other `\"auto\"` popover already open.\n */\nconst DEFAULT_MODE: NonNullable<Popover.Props[\"popover\"]> = \"auto\";\n\n/**\n * Prop types for {@link Popover}.\n */\nexport namespace Popover {\n\t/**\n\t * Side of the anchor the host renders against, and, for the four corner\n\t * variants, which anchor edge it aligns to along the perpendicular axis.\n\t * Each name is a physical viewport side, fixed under any `dir` value.\n\t */\n\texport type Placement = AnchorPlacement;\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, with `id`\n\t * narrowed to required, since `popovertarget`, `commandfor`, and the host's\n\t * own implicit CSS anchor reference all target it by that id.\n\t */\n\texport interface Props extends Omit<TagProps<\"div\">, \"id\" | \"popover\"> {\n\t\t/** Stable id an invoker elsewhere on the page targets to open this host. */\n\t\tid: string;\n\t\t/**\n\t\t * `popover` attribute mode: `\"auto\"` dismisses on outside click or Escape\n\t\t * and closes sibling `\"auto\"` popovers when shown; `\"hint\"` layers over an\n\t\t * open one without closing it; `\"manual\"` closes only when hidden explicitly.\n\t\t *\n\t\t * @default {@link DEFAULT_MODE}\n\t\t */\n\t\tpopover?: \"auto\" | \"hint\" | \"manual\";\n\t\t/** Side of the anchor to render against. Defaults to {@link DEFAULT_PLACEMENT}. */\n\t\tplacement?: Placement;\n\t\t/** The popover's content. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the floating surface itself: a `popover`-attributed `<div>`\n * positioned via CSS anchor positioning. The invoker that opens it becomes\n * the implicit anchor its `position-area` resolves against.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the surface's markup.\n * @example\n * <button commandfor=\"account-menu\" command=\"toggle-popover\">{t(\"nav.account\")}</button>\n * <Popover id=\"account-menu\" placement=\"bottom-start\">\n * \t<p>{t(\"nav.accountMenu.body\")}</p>\n * </Popover>\n * @example\n * <Popover id=\"filters\" placement=\"top\" mix={[fade({ duration: durations.normal })]}>\n * \t<OverlayArrow placement=\"top\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function Popover(handle: Handle<Popover.Props>) {\n\treturn () => {\n\t\tlet { id, popover, placement, children, mix, ...rest } = handle.props;\n\t\tlet resolvedMode = popover ?? DEFAULT_MODE;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={id}\n\t\t\t\tpopover={resolvedMode}\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tfloatingSurface(),\n\t\t\t\t\tm(\"0\"),\n\t\t\t\t\tinset(\"auto\"),\n\t\t\t\t\twhen('&[data-placement^=\"top\"]', mbe(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', mbs(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\twhen('&[data-placement^=\"left\"]', marginRight(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\twhen('&[data-placement^=\"right\"]', marginLeft(\"var(--ui-popover-offset, 0.5rem)\")),\n\t\t\t\t\tpositionTryFallbacks(\"flip-block\", \"flip-inline\", \"flip-block flip-inline\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * A corner placement aligns one pair of edges and grows away from it, so the surface\n\t\t\t\t\t * occupies the anchor's own track and spans the one beyond it, flush with the anchor's edge.\n\t\t\t\t\t */\n\t\t\t\t\tdata(\"placement\", \"top\", positionArea(\"top\")),\n\t\t\t\t\tdata(\"placement\", \"top-start\", positionArea(\"top span-right\")),\n\t\t\t\t\tdata(\"placement\", \"top-end\", positionArea(\"top span-left\")),\n\t\t\t\t\tdata(\"placement\", \"bottom\", positionArea(\"bottom\")),\n\t\t\t\t\tdata(\"placement\", \"bottom-start\", positionArea(\"bottom span-right\")),\n\t\t\t\t\tdata(\"placement\", \"bottom-end\", positionArea(\"bottom span-left\")),\n\t\t\t\t\tdata(\"placement\", \"left\", positionArea(\"left\")),\n\t\t\t\t\tdata(\"placement\", \"left-start\", positionArea(\"left span-bottom\")),\n\t\t\t\t\tdata(\"placement\", \"left-end\", positionArea(\"left span-top\")),\n\t\t\t\t\tdata(\"placement\", \"right\", positionArea(\"right\")),\n\t\t\t\t\tdata(\"placement\", \"right-start\", positionArea(\"right span-bottom\")),\n\t\t\t\t\tdata(\"placement\", \"right-end\", positionArea(\"right span-top\")),\n\t\t\t\t\t/**\n\t\t\t\t\t * Layout parts on this surface set `display` and beat the UA's closed `display: none`, so\n\t\t\t\t\t * the closed state is important to outrank a consumer's later sublayer. A `\"hint\"` surface\n\t\t\t\t\t * reveals itself from CSS state on its trigger, so it keeps its own hidden state.\n\t\t\t\t\t */\n\t\t\t\t\twhen('&:not(:popover-open):not([popover=\"hint\"])', raw({ display: \"none !important\" })),\n\t\t\t\t\tmix,\n\t\t\t\t]}\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,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "progress-bar",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"ProgressBar"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "progress-bar.tsx",
|
|
10
|
+
"content": "/**\n * A styled native `<progress>` control paired with an optional value label,\n * stacked in a single column so a caption can sit alongside the bar it\n * describes. The indicator's track and fill read entirely from the control's\n * own `value`/`max` attributes and its native `:indeterminate` state, so a\n * value-less indicator already renders as busy with zero library JavaScript.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { bg, border, fg } from \"@sdxc/u/color\";\nimport { rounded, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { appearance, block, flex, flexCol, gap } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, m, p } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { tabularNums, text } from \"@sdxc/u/typography\";\n\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\n/** Native `max` value {@link ProgressBar.Indicator} falls back to when `max` is omitted, so a bare `value` reads as a percentage without passing `max={100}` every time. */\nconst DEFAULT_MAX = 100;\n\n/**\n * Prop types for {@link ProgressBar} and its compound parts.\n */\nexport namespace ProgressBar {\n\t/**\n\t * Every native `<div>` attribute, unchanged, plus the `mix` passthrough.\n\t * The root only supplies the column layout stacking {@link\n\t * ProgressBar.Indicator} and {@link ProgressBar.ValueLabel}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<progress>` attribute, unchanged, plus the `mix`\n\t * passthrough. Leaving `value` unset renders the indeterminate state;\n\t * `max` defaults to {@link DEFAULT_MAX}.\n\t */\n\texport interface IndicatorProps extends TagProps<\"progress\"> {}\n\n\t/**\n\t * Every native `<span>` attribute, unchanged, plus the `mix` passthrough.\n\t */\n\texport interface ValueLabelProps extends TagProps<\"span\"> {}\n}\n\n/**\n * Renders the root column: a `<div>` stacking {@link ProgressBar.Indicator}\n * and an optional {@link ProgressBar.ValueLabel}, carrying no ARIA of its\n * own since the `<progress>` inside already exposes progressbar semantics.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the root column's markup.\n * @example\n * <ProgressBar>\n * \t<ProgressBar.Indicator value={70} max={100} aria-label={t(\"upload.progress\")} />\n * \t<ProgressBar.ValueLabel>{t(\"upload.percent\", { value: 70 })}</ProgressBar.ValueLabel>\n * </ProgressBar>\n */\nexport function ProgressBar(handle: Handle<ProgressBar.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} mix={[flex(), flexCol(), gap(\"0.25rem\"), mix]} />;\n\t};\n}\n\n/**\n * Renders the busy/progress indicator: a native `<progress>` restyled as a\n * pill track. Firefox paints from the host itself, so track and fill colors\n * mirror onto the `::-webkit-*`/`::-moz-*` pseudo-elements each engine paints.\n *\n * @param handle Runtime handle carrying the host `<progress>`'s props.\n * @returns The render function producing the indicator's markup.\n * @example\n * <ProgressBar.Indicator value={70} max={100} aria-label={t(\"upload.progress\")} />\n * @example\n * <ProgressBar.Indicator aria-label={t(\"upload.progress\")} mix={[shimmer()]} />\n */\nProgressBar.Indicator = function ProgressBarIndicator(handle: Handle<ProgressBar.IndicatorProps>) {\n\treturn () => {\n\t\tlet { mix, max, ...rest } = handle.props;\n\t\tlet resolvedMax = max ?? DEFAULT_MAX;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t\"ProgressBar.Indicator: a progress indicator with no `aria-label` or `aria-labelledby` needs one describing what it tracks — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<progress\n\t\t\t\tmax={resolvedMax}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tappearance(),\n\t\t\t\t\tblock(),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\tbs(\"var(--ui-progress-bar-block-size, 0.5rem)\"),\n\t\t\t\t\tm(\"0\"),\n\t\t\t\t\tp(\"0\"),\n\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\twhen(\"&::-webkit-progress-bar\", [bg(\"neutral.border\"), rounded(\"full\")]),\n\t\t\t\t\twhen(\"&::-webkit-progress-value\", [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\ttransition(\"all\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&::-moz-progress-bar\", [bg(\"brand.solid\"), rounded(\"full\"), transition(\"all\")]),\n\t\t\t\t\tborder(\"none\"),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\twhen(\"&::-webkit-progress-value\", transitionDuration(\"0s\")),\n\t\t\t\t\t\twhen(\"&::-moz-progress-bar\", transitionDuration(\"0s\")),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the indicator's caption: a `<span>` sized as a small run of body\n * copy in the neutral muted foreground color, for a percentage or status\n * string placed alongside {@link ProgressBar.Indicator}.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the value label's markup.\n * @example\n * <ProgressBar.ValueLabel>{t(\"upload.percent\", { value: 70 })}</ProgressBar.ValueLabel>\n */\nProgressBar.ValueLabel = function ProgressBarValueLabel(\n\thandle: Handle<ProgressBar.ValueLabelProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <span {...rest} mix={[fg(\"neutral\"), text(\"sm\"), tabularNums(), mix]} />;\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "radio-group",
|
|
3
|
+
"changedIn": "2026.10.2",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"RadioGroup"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "radio-group.tsx",
|
|
10
|
+
"content": "/**\n * A set of mutually exclusive options built from native `<input\n * type=\"radio\">` controls sharing one grouping name, rendered as a\n * `role=\"radiogroup\"` host wrapping a run of {@link RadioGroup.Radio}\n * instances. Each option pairs a visually hidden native input — carrying\n * every focus, keyboard, and form-submission semantic the platform already\n * provides — with a styled visual indicator that reads the input's own\n * `:checked` and `:focus-visible` states through sibling selectors.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded, transition } from \"@sdxc/u/effects\";\nimport { cursor, pseudoContent } from \"@sdxc/u/general\";\nimport { flex, flexCol, flexRow, gap, items, justify, relative, shrink } from \"@sdxc/u/layout\";\nimport { bs, is } from \"@sdxc/u/size\";\nimport { after, precededBy, when } from \"@sdxc/u/state\";\nimport { scale } from \"@sdxc/u/transform\";\nimport { text } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\n/**\n * `role=\"radiogroup\"` applied through {@link attrs} unless a consumer\n * supplies its own `role`, announcing the host as a radio group landmark to\n * assistive technology.\n */\nconst DEFAULT_ROLE = \"radiogroup\";\n\n/**\n * Default {@link RadioGroup.Props} orientation, applied when `orientation`\n * is omitted, laying options out in a single column.\n */\nconst DEFAULT_ORIENTATION: RadioGroup.Orientation = \"vertical\";\n\n/**\n * Prop types for {@link RadioGroup} and its {@link RadioGroup.Radio}\n * compound part.\n */\nexport namespace RadioGroup {\n\t/**\n\t * Axis a group's options lay out along: a single column, or a single row.\n\t */\n\texport type Orientation = \"horizontal\" | \"vertical\";\n\n\t/**\n\t * Value {@link RadioGroup} stores in component context so every\n\t * {@link RadioGroup.Radio} nested inside shares the same native grouping\n\t * name without a consumer repeating it on each option.\n\t */\n\texport interface Context {\n\t\t/** Shared `name` every {@link RadioGroup.Radio} reads unless it sets its own. */\n\t\tname: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link RadioGroup}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Native grouping name shared by every {@link RadioGroup.Radio} nested\n\t\t * inside. Defaults to the group's own {@link Handle.id | stable\n\t\t * instance id} so options group correctly without a consumer setting one.\n\t\t */\n\t\tname?: string;\n\t\t/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t}\n\n\t/**\n\t * Props accepted by {@link RadioGroup.Radio}.\n\t */\n\texport interface RadioProps extends Omit<TagProps<\"label\">, \"children\"> {\n\t\t/** Value submitted with the enclosing form when this option is selected. */\n\t\tvalue: string;\n\t\t/**\n\t\t * Native grouping name for this option's underlying input. Defaults to\n\t\t * the name provided by the nearest ancestor {@link RadioGroup} — set\n\t\t * this only to opt a single option out of its group's shared name.\n\t\t */\n\t\tname?: string;\n\t\t/** Whether this option starts selected, for a form that leaves selection tracking to the browser. */\n\t\tdefaultChecked?: boolean;\n\t\t/** Whether this option is selected, for a form that tracks selection itself. */\n\t\tchecked?: boolean;\n\t\t/** Whether this option is inert and excluded from the group's tab order. */\n\t\tdisabled?: boolean;\n\t\t/** Marks the enclosing native radio group as requiring one option selected. */\n\t\trequired?: boolean;\n\t\t/** The option's visible label text, associated with the input by native nesting. */\n\t\tchildren?: RemixNode;\n\t\t/**\n\t\t * Per-part styling for the option's hidden `input` and visible\n\t\t * `indicator` elements, layered after each part's own built-in styling.\n\t\t * Use the `mix` prop instead to style the option's outer `<label>` host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to the hidden native `<input type=\"radio\">`. */\n\t\t\tinput?: TagProps<\"input\">[\"mix\"];\n\t\t\t/** Additional mixin(s) applied to the visible indicator `<span>`. */\n\t\t\tindicator?: TagProps<\"span\">[\"mix\"];\n\t\t};\n\t}\n}\n\n/**\n * Renders the group host: a `role=\"radiogroup\"` `<div>` laying its\n * {@link RadioGroup.Radio} options in a column, or a row when\n * `orientation` is `\"horizontal\"`, giving every option a shared, stable `name`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props and providing {@link RadioGroup.Context}.\n * @returns The render function producing the group's markup.\n * @example\n * <RadioGroup aria-label={t(\"shipping.method\")}>\n * \t<RadioGroup.Radio value=\"standard\">{t(\"shipping.standard\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"express\">{t(\"shipping.express\")}</RadioGroup.Radio>\n * </RadioGroup>\n * @example\n * <RadioGroup aria-label={t(\"size.label\")} orientation=\"horizontal\">\n * \t<RadioGroup.Radio value=\"sm\">{t(\"size.small\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"md\">{t(\"size.medium\")}</RadioGroup.Radio>\n * \t<RadioGroup.Radio value=\"lg\">{t(\"size.large\")}</RadioGroup.Radio>\n * </RadioGroup>\n */\nexport function RadioGroup(handle: Handle<RadioGroup.Props, RadioGroup.Context>) {\n\treturn () => {\n\t\tlet { name, orientation, mix, ...rest } = handle.props;\n\t\tlet resolvedName = name ?? handle.id;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\n\t\thandle.context.set({ name: resolvedName });\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-orientation={resolvedOrientation}\n\t\t\t\taria-orientation={resolvedOrientation}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_ROLE }),\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', flexRow()),\n\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', gap(\"1rem\")),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders a single option: a `<label>` pairing a hidden native `<input\n * type=\"radio\">` with a styled indicator driven by its checked, focus, and\n * disabled state; add `ariaChecked()` via `parts.input` for `aria-checked`.\n *\n * @param handle Runtime handle carrying the host `<label>`'s props.\n * @returns The render function producing the option's markup.\n * @example\n * <RadioGroup.Radio value=\"dog\">{t(\"pet.dog\")}</RadioGroup.Radio>\n * @example\n * <RadioGroup.Radio value=\"cat\" defaultChecked>{t(\"pet.cat\")}</RadioGroup.Radio>\n * @example\n * <RadioGroup.Radio value=\"hamster\" disabled>{t(\"pet.hamster\")}</RadioGroup.Radio>\n */\nRadioGroup.Radio = function RadioGroupRadio(handle: Handle<RadioGroup.RadioProps>) {\n\treturn () => {\n\t\tlet {\n\t\t\tvalue,\n\t\t\tname,\n\t\t\tchecked,\n\t\t\tdefaultChecked,\n\t\t\tdisabled,\n\t\t\trequired,\n\t\t\tchildren,\n\t\t\tparts,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet context = handle.context.get(RadioGroup);\n\t\tlet resolvedName = name ?? context.name;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\twhen(\"&:has(input:disabled)\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\tid={handle.id}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tname={resolvedName}\n\t\t\t\t\tchecked={checked}\n\t\t\t\t\tdefaultChecked={defaultChecked}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\trequired={required}\n\t\t\t\t\tmix={[visuallyHidden(), parts?.input]}\n\t\t\t\t/>\n\t\t\t\t<span\n\t\t\t\t\tdata-slot=\"indicator\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tis(\"var(--ui-radio-size, 1.25rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-radio-size, 1.25rem)\"),\n\t\t\t\t\t\tafter([\n\t\t\t\t\t\t\tis(\"var(--ui-radio-mark-size, 0.625rem)\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-radio-mark-size, 0.625rem)\"),\n\t\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\t\tbg(\"brand.onSolid\"),\n\t\t\t\t\t\t\ttransition(\"transform\"),\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\tscale(0),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tborder({ color: \"neutral.strong\", width: 2 }),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\ttransition(\"background-color, border-color\"),\n\t\t\t\t\t\tprecededBy(\"input:checked\", after(scale(1))),\n\t\t\t\t\t\tprecededBy(\"input:checked\", [border(\"brand.solid\"), bg(\"brand.solid\")]),\n\t\t\t\t\t\tprecededBy(\"input:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\tparts?.indicator,\n\t\t\t\t\t]}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</label>\n\t\t);\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": null
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "range-calendar",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"calendar",
|
|
6
|
+
"input"
|
|
7
|
+
],
|
|
8
|
+
"exports": [
|
|
9
|
+
"RangeCalendar"
|
|
10
|
+
],
|
|
11
|
+
"source": {
|
|
12
|
+
"path": "range-calendar.tsx",
|
|
13
|
+
"content": "/**\n * A calendar surface for choosing a start and end date as one connected\n * range, sharing every header, grid, and row part with {@link Calendar} and\n * layering range position on top of its day cell. Used bare, with no\n * composed children, it renders a pair of native `<input type=\"date\">`\n * fields instead — start and end, each independently keyboard-operable —\n * ready for the `calendarKeys()`/`rangePreview()` mixins a consumer attaches\n * to turn the composed grid into a live, drag- or arrow-key-extended range.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { bg, fg } from \"@sdxc/u/color\";\nimport { roundedCorner } from \"@sdxc/u/effects\";\nimport { flex, gap, items } from \"@sdxc/u/layout\";\nimport { when } from \"@sdxc/u/state\";\nimport { attrs } from \"remix/component\";\n\nimport { Calendar } from \"@sdxc/ui/calendar\";\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Semantic color role {@link RangeCalendar}'s bare fallback pair falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: RangeCalendar.Color = \"neutral\";\n\n/**\n * Prop types for {@link RangeCalendar} and its compound parts. Every part\n * but {@link RangeCalendar.Cell} aliases {@link Calendar}'s matching part,\n * sharing its header, grid, and row markup.\n */\nexport namespace RangeCalendar {\n\t/**\n\t * Semantic color role for the bare fallback pair's keyboard focus rings,\n\t * mapped to `--ui-*` variables like {@link Calendar.Color}. The composed\n\t * grid's day cells always use fixed semantic roles, regardless of this value.\n\t */\n\texport type Color = Calendar.Color;\n\n\t/**\n\t * Per-part styling for the bare fallback pair's two internally composed\n\t * inputs, layered after each input's own built-in styling. Style the\n\t * composed grid's parts through {@link Calendar}'s own compound parts.\n\t */\n\texport interface PartsProps {\n\t\t/** Styling for the bare fallback's start-date input, rendered through {@link Input}. */\n\t\tstart?: TagProps<\"input\">[\"mix\"];\n\t\t/** Styling for the bare fallback's end-date input, rendered through {@link Input}. */\n\t\tend?: TagProps<\"input\">[\"mix\"];\n\t}\n\n\t/**\n\t * Props accepted by {@link RangeCalendar}. Composing\n\t * {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`\n\t * renders the visual month surface; omitting `children` renders a bare native `<input type=\"date\">` pair from the fields below.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Semantic color role for the bare fallback pair's focus rings. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Native `name` submitted with an enclosing form, read only by the bare fallback's start-date input. */\n\t\tstartName?: string;\n\t\t/** Native `name` submitted with an enclosing form, read only by the bare fallback's end-date input. */\n\t\tendName?: string;\n\t\t/** Current start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */\n\t\tstartValue?: string;\n\t\t/** Current end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */\n\t\tendValue?: string;\n\t\t/** Initial start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */\n\t\tstartDefaultValue?: string;\n\t\t/** Initial end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */\n\t\tendDefaultValue?: string;\n\t\t/** Earliest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */\n\t\tmin?: string;\n\t\t/** Latest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */\n\t\tmax?: string;\n\t\t/** Granularity, in days, both of the bare fallback pair's values must fall on. */\n\t\tstep?: number;\n\t\t/** Marks both of the bare fallback pair's inputs required for their enclosing form. */\n\t\trequired?: boolean;\n\t\t/** Marks both of the bare fallback pair's inputs inert and excluded from the tab order. */\n\t\tdisabled?: boolean;\n\t\t/** Marks both of the bare fallback pair's inputs' values fixed, while keeping them focusable and included in form submission. */\n\t\treadOnly?: boolean;\n\t\t/** Native autofill hint for both of the bare fallback pair's inputs, e.g. `\"bday\"`. */\n\t\tautoComplete?: string;\n\t\t/** Accessible label for the bare fallback pair's start-date input. Read only when `children` is unset. */\n\t\tstartLabel?: string;\n\t\t/** Accessible label for the bare fallback pair's end-date input. Read only when `children` is unset. */\n\t\tendLabel?: string;\n\t\t/** Per-part styling for the bare fallback pair's internally composed inputs. */\n\t\tparts?: PartsProps;\n\t}\n\n\t/** Every prop {@link Calendar.HeaderProps} accepts, unchanged. */\n\texport interface HeaderProps extends Calendar.HeaderProps {}\n\n\t/** Every prop {@link Calendar.PreviousButtonProps} accepts, unchanged. */\n\texport interface PreviousButtonProps extends Calendar.PreviousButtonProps {}\n\n\t/** Every prop {@link Calendar.NextButtonProps} accepts, unchanged. */\n\texport interface NextButtonProps extends Calendar.NextButtonProps {}\n\n\t/** Every prop {@link Calendar.HeadingProps} accepts, unchanged. */\n\texport interface HeadingProps extends Calendar.HeadingProps {}\n\n\t/** Every prop {@link Calendar.GridProps} accepts, unchanged. */\n\texport interface GridProps extends Calendar.GridProps {}\n\n\t/** Every prop {@link Calendar.GridHeaderProps} accepts, unchanged. */\n\texport interface GridHeaderProps extends Calendar.GridHeaderProps {}\n\n\t/** Every prop {@link Calendar.RowProps} accepts, unchanged. */\n\texport interface RowProps extends Calendar.RowProps {}\n\n\t/** Every prop {@link Calendar.HeaderCellProps} accepts, unchanged. */\n\texport interface HeaderCellProps extends Calendar.HeaderCellProps {}\n\n\t/** Every prop {@link Calendar.GridBodyProps} accepts, unchanged. */\n\texport interface GridBodyProps extends Calendar.GridBodyProps {}\n\n\t/**\n\t * Every prop {@link Calendar.CellProps} accepts, unchanged. Set\n\t * `data-selection-start` on the range's first day, `data-selection-end`\n\t * on its last, and `aria-selected=\"true\"` alone on the days between — each read straight off what the consumer sets on this instance.\n\t */\n\texport interface CellProps extends Calendar.CellProps {}\n}\n\n/**\n * Renders {@link RangeCalendar}'s root through {@link Calendar}. Composing\n * {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`\n * renders the visual month surface; omitting `children` renders a bare, script-free native `<input type=\"date\">` pair from this instance's own fields.\n *\n * @param handle Runtime handle carrying the root element's props.\n * @returns The render function producing the range calendar's markup.\n * @example\n * <RangeCalendar startLabel={t(\"form.stay.checkIn\")} endLabel={t(\"form.stay.checkOut\")} startName=\"checkIn\" endName=\"checkOut\" />\n * @example\n * <RangeCalendar aria-label={t(\"calendar.label\")}>\n * \t<RangeCalendar.Header>\n * \t\t<RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t\t<RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n * \t\t<RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n * \t</RangeCalendar.Header>\n * \t<RangeCalendar.Grid aria-label={monthLabel}>\n * \t\t<RangeCalendar.GridHeader>\n * \t\t\t<RangeCalendar.Row>\n * \t\t\t\t{weekdayLabels.map((day) => (\n * \t\t\t\t\t<RangeCalendar.HeaderCell key={day}>{day}</RangeCalendar.HeaderCell>\n * \t\t\t\t))}\n * \t\t\t</RangeCalendar.Row>\n * \t\t</RangeCalendar.GridHeader>\n * \t\t<RangeCalendar.GridBody>\n * \t\t\t{weeks.map((week) => (\n * \t\t\t\t<RangeCalendar.Row key={week[0].iso}>\n * \t\t\t\t\t{week.map((day) => (\n * \t\t\t\t\t\t<RangeCalendar.Cell\n * \t\t\t\t\t\t\tkey={day.iso}\n * \t\t\t\t\t\t\taria-selected={day.inRange ? \"true\" : undefined}\n * \t\t\t\t\t\t\tdata-selection-start={day.iso === range.start ? \"\" : undefined}\n * \t\t\t\t\t\t\tdata-selection-end={day.iso === range.end ? \"\" : undefined}\n * \t\t\t\t\t\t>\n * \t\t\t\t\t\t\t{day.label}\n * \t\t\t\t\t\t</RangeCalendar.Cell>\n * \t\t\t\t\t))}\n * \t\t\t\t</RangeCalendar.Row>\n * \t\t\t))}\n * \t\t</RangeCalendar.GridBody>\n * \t</RangeCalendar.Grid>\n * </RangeCalendar>\n */\nexport function RangeCalendar(handle: Handle<RangeCalendar.Props>) {\n\treturn () => {\n\t\tlet {\n\t\t\tcolor,\n\t\t\tstartName,\n\t\t\tendName,\n\t\t\tstartValue,\n\t\t\tendValue,\n\t\t\tstartDefaultValue,\n\t\t\tendDefaultValue,\n\t\t\tmin,\n\t\t\tmax,\n\t\t\tstep,\n\t\t\trequired,\n\t\t\tdisabled,\n\t\t\treadOnly,\n\t\t\tautoComplete,\n\t\t\tstartLabel,\n\t\t\tendLabel,\n\t\t\tparts,\n\t\t\tchildren,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\tif (import.meta.env.DEV && !children) {\n\t\t\tif (!startLabel) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'RangeCalendar: falling back to a plain \"input type=date\" pair needs a \"startLabel\" describing the range\\'s start for assistive technology.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!endLabel) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'RangeCalendar: falling back to a plain \"input type=date\" pair needs an \"endLabel\" describing the range\\'s end for assistive technology.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<Calendar {...rest} mix={mix}>\n\t\t\t\t{children ?? (\n\t\t\t\t\t<div\n\t\t\t\t\t\tdata-slot=\"fields\"\n\t\t\t\t\t\tmix={[attrs({ role: \"group\" }), flex(), items(\"center\"), gap(\"0.5rem\")]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tdata-slot=\"start-input\"\n\t\t\t\t\t\t\tcolor={resolvedColor}\n\t\t\t\t\t\t\tname={startName}\n\t\t\t\t\t\t\tvalue={startValue}\n\t\t\t\t\t\t\tdefaultValue={startDefaultValue}\n\t\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\t\taria-label={startLabel}\n\t\t\t\t\t\t\tmix={parts?.start}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tdata-slot=\"end-input\"\n\t\t\t\t\t\t\tcolor={resolvedColor}\n\t\t\t\t\t\t\tname={endName}\n\t\t\t\t\t\t\tvalue={endValue}\n\t\t\t\t\t\t\tdefaultValue={endDefaultValue}\n\t\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\t\taria-label={endLabel}\n\t\t\t\t\t\t\tmix={parts?.end}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</Calendar>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link RangeCalendar.HeaderProps.children} as the nav row: identical\n * to {@link Calendar.Header}, since {@link RangeCalendar} reuses\n * {@link Calendar}'s grid markup for its own header.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the nav row's markup.\n * @example\n * <RangeCalendar.Header>\n * \t<RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n * \t<RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n * \t<RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n * </RangeCalendar.Header>\n */\nRangeCalendar.Header = Calendar.Header;\n\n/**\n * Renders a control standing for \"show the previous month\": identical to\n * {@link Calendar.PreviousButton}.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <RangeCalendar.PreviousButton aria-label={t(\"calendar.previous\")} />\n */\nRangeCalendar.PreviousButton = Calendar.PreviousButton;\n\n/**\n * Renders a control standing for \"show the following month\": identical to\n * {@link Calendar.NextButton}.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the control's markup.\n * @example\n * <RangeCalendar.NextButton aria-label={t(\"calendar.next\")} />\n */\nRangeCalendar.NextButton = Calendar.NextButton;\n\n/**\n * Renders the calendar's visible month/year caption: identical to\n * {@link Calendar.Heading}.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the caption's markup.\n * @example\n * <RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>\n */\nRangeCalendar.Heading = Calendar.Heading;\n\n/**\n * Renders the day grid's native `<table>` host: identical to\n * {@link Calendar.Grid}.\n *\n * @param handle Runtime handle carrying the host `<table>`'s props.\n * @returns The render function producing the grid's markup.\n * @example\n * <RangeCalendar.Grid aria-label={monthLabel}>\n * \t<RangeCalendar.GridHeader>...</RangeCalendar.GridHeader>\n * \t<RangeCalendar.GridBody>...</RangeCalendar.GridBody>\n * </RangeCalendar.Grid>\n */\nRangeCalendar.Grid = Calendar.Grid;\n\n/**\n * Renders the grid's `<thead>` host: identical to {@link Calendar.GridHeader}.\n *\n * @param handle Runtime handle carrying the host `<thead>`'s props.\n * @returns The render function producing the header section's markup.\n * @example\n * <RangeCalendar.GridHeader>\n * \t<RangeCalendar.Row>\n * \t\t<RangeCalendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</RangeCalendar.HeaderCell>\n * \t</RangeCalendar.Row>\n * </RangeCalendar.GridHeader>\n */\nRangeCalendar.GridHeader = Calendar.GridHeader;\n\n/**\n * Renders a native `<tr>` host: identical to {@link Calendar.Row}. Composes\n * a row of {@link RangeCalendar.HeaderCell} inside\n * {@link RangeCalendar.GridHeader}, or a week's row of {@link RangeCalendar.Cell} inside {@link RangeCalendar.GridBody}.\n *\n * @param handle Runtime handle carrying the host `<tr>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <RangeCalendar.Row>\n * \t<RangeCalendar.Cell>{day.label}</RangeCalendar.Cell>\n * </RangeCalendar.Row>\n */\nRangeCalendar.Row = Calendar.Row;\n\n/**\n * Renders a weekday abbreviation: identical to {@link Calendar.HeaderCell}.\n *\n * @param handle Runtime handle carrying the host `<th>`'s props.\n * @returns The render function producing the weekday header's markup.\n * @example\n * <RangeCalendar.HeaderCell>{t(\"calendar.weekdays.sun\")}</RangeCalendar.HeaderCell>\n */\nRangeCalendar.HeaderCell = Calendar.HeaderCell;\n\n/**\n * Renders the grid's `<tbody>` host: identical to {@link Calendar.GridBody}.\n *\n * @param handle Runtime handle carrying the host `<tbody>`'s props.\n * @returns The render function producing the body section's markup.\n * @example\n * <RangeCalendar.GridBody>\n * \t{weeks.map((week) => (\n * \t\t<RangeCalendar.Row key={week[0].iso}>...</RangeCalendar.Row>\n * \t))}\n * </RangeCalendar.GridBody>\n */\nRangeCalendar.GridBody = Calendar.GridBody;\n\n/**\n * Renders one calendar day for {@link RangeCalendar}, building on\n * {@link Calendar.Cell}. `data-selection-start`/`data-selection-end`\n * square off each end's outer corners so the range reads as one unbroken bar, driven by whatever state the consumer sets for the `calendarKeys()`/`rangePreview()` mixins.\n *\n * @param handle Runtime handle carrying the host `<td>`'s props.\n * @returns The render function producing the day's markup.\n * @example\n * <RangeCalendar.Cell data-selection-start=\"\">{day.label}</RangeCalendar.Cell>\n * @example\n * <RangeCalendar.Cell aria-selected=\"true\">{day.label}</RangeCalendar.Cell>\n * @example\n * <RangeCalendar.Cell data-selection-end=\"\">{day.label}</RangeCalendar.Cell>\n */\nRangeCalendar.Cell = function RangeCalendarCell(handle: Handle<RangeCalendar.CellProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Calendar.Cell\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\t/**\n\t\t\t\t\t * A day is the range's opening, its closing, both at once, or one of the days\n\t\t\t\t\t * between. The four are written under selectors that match one apiece, so each\n\t\t\t\t\t * day keeps its own shape however the cascade orders the set.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&[data-selection-start]:not([data-selection-end])\", [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\troundedCorner(\"start-end\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-end\", \"none\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&[data-selection-end]:not([data-selection-start])\", [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\troundedCorner(\"start-start\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-start\", \"none\"),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * A range of one day opens and closes on itself, so it reads as a single day.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&[data-selection-start][data-selection-end]\", [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[aria-selected=\"true\"]:not([data-selection-start]):not([data-selection-end])', [\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The days between carry the range across the row, so the band reads as one\n\t\t\t\t\t\t * run at a glance while the two ends stay the strongest thing in the month.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tbg(\"brand.bg-tint-hover\"),\n\t\t\t\t\t\tfg(\"brand.emphasis\"),\n\t\t\t\t\t\troundedCorner(\"start-start\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"start-end\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-start\", \"none\"),\n\t\t\t\t\t\troundedCorner(\"end-end\", \"none\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
14
|
+
},
|
|
15
|
+
"test": null
|
|
16
|
+
}
|