@sdxc/kit 2026.10.30 → 2026.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.jsonl +89 -0
- package/dist/make/declare.js +32 -11
- package/package.json +2 -2
- package/registry/ui/accordion.json +2 -2
- package/registry/ui/alert-dialog.json +2 -2
- package/registry/ui/alert.json +2 -2
- package/registry/ui/aspect-ratio.json +2 -2
- package/registry/ui/avatar.json +6 -3
- package/registry/ui/badge.json +2 -2
- package/registry/ui/breadcrumbs.json +2 -2
- package/registry/ui/button.json +5 -3
- package/registry/ui/calendar.json +2 -2
- package/registry/ui/card.json +2 -2
- package/registry/ui/carousel.json +2 -2
- package/registry/ui/checkbox-group.json +2 -2
- package/registry/ui/checkbox.json +2 -2
- package/registry/ui/combobox.json +2 -2
- package/registry/ui/command.json +2 -2
- package/registry/ui/cta-group.json +2 -2
- package/registry/ui/date-field.json +2 -2
- package/registry/ui/date-picker.json +2 -2
- package/registry/ui/date-range-picker.json +2 -2
- package/registry/ui/description.json +2 -2
- package/registry/ui/dialog-dismiss.json +13 -0
- package/registry/ui/dialog.json +2 -2
- package/registry/ui/disclosure.json +2 -2
- package/registry/ui/drawer.json +2 -2
- package/registry/ui/field-error.json +2 -2
- package/registry/ui/form.json +2 -2
- package/registry/ui/group.json +2 -2
- package/registry/ui/header.json +2 -2
- package/registry/ui/heading-scope.json +2 -2
- package/registry/ui/heading.json +3 -3
- package/registry/ui/highlight.json +3 -3
- package/registry/ui/hover-card.json +2 -2
- package/registry/ui/image-placeholder.json +2 -2
- package/registry/ui/input.json +2 -2
- package/registry/ui/item.json +2 -2
- package/registry/ui/keyboard.json +2 -2
- package/registry/ui/label.json +2 -2
- package/registry/ui/link-button.json +5 -3
- package/registry/ui/link.json +2 -2
- package/registry/ui/listbox.json +2 -2
- package/registry/ui/menu.json +2 -2
- package/registry/ui/meter.json +2 -2
- package/registry/ui/modal.json +2 -2
- package/registry/ui/nav-link.json +2 -2
- package/registry/ui/navigation-menu.json +2 -2
- package/registry/ui/number-field.json +2 -2
- package/registry/ui/otp-field.json +2 -2
- package/registry/ui/overlay-arrow.json +2 -2
- package/registry/ui/pagination.json +2 -2
- package/registry/ui/popover.json +2 -2
- package/registry/ui/progress-bar.json +2 -2
- package/registry/ui/radio-group.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/scroll-area.json +2 -2
- package/registry/ui/search-field.json +2 -2
- package/registry/ui/section.json +2 -2
- package/registry/ui/select.json +2 -2
- package/registry/ui/selection-indicator.json +2 -2
- package/registry/ui/sentinel-row.json +2 -2
- package/registry/ui/separator.json +2 -2
- package/registry/ui/shared-element.json +2 -2
- package/registry/ui/sheet.json +2 -2
- package/registry/ui/sidebar.json +2 -2
- package/registry/ui/slider.json +2 -2
- package/registry/ui/spinner.json +2 -2
- package/registry/ui/switch.json +2 -2
- package/registry/ui/tabs.json +2 -2
- package/registry/ui/tag-group.json +2 -2
- package/registry/ui/text-field.json +2 -2
- package/registry/ui/text.json +2 -2
- package/registry/ui/textarea.json +2 -2
- package/registry/ui/time-field.json +2 -2
- package/registry/ui/toggle-button.json +2 -2
- package/registry/ui/tooltip.json +2 -2
- package/registry/ui/typeset.json +2 -2
- package/registry/ui/youtube-embed.json +2 -2
- package/stubs/scaffold.controller.index.stub +1 -1
- package/registry/ui/attachment.json +0 -15
- package/registry/ui/bubble.json +0 -13
- package/registry/ui/chart.json +0 -13
- package/registry/ui/color-area.json +0 -13
- package/registry/ui/color-field.json +0 -20
- package/registry/ui/color-picker.json +0 -17
- package/registry/ui/color-slider.json +0 -13
- package/registry/ui/color-swatch-picker.json +0 -15
- package/registry/ui/color-swatch.json +0 -13
- package/registry/ui/color-wheel.json +0 -13
- package/registry/ui/context-menu.json +0 -16
- package/registry/ui/drop-indicator.json +0 -13
- package/registry/ui/drop-zone.json +0 -13
- package/registry/ui/empty.json +0 -15
- package/registry/ui/feature.json +0 -18
- package/registry/ui/file-trigger.json +0 -13
- package/registry/ui/grid-list.json +0 -18
- package/registry/ui/logo-cloud.json +0 -16
- package/registry/ui/marker.json +0 -13
- package/registry/ui/marketing-header.json +0 -18
- package/registry/ui/marketing-section.json +0 -16
- package/registry/ui/menubar.json +0 -13
- package/registry/ui/message-scroller.json +0 -16
- package/registry/ui/message.json +0 -13
- package/registry/ui/resizable.json +0 -13
- package/registry/ui/shortcut-list.json +0 -18
- package/registry/ui/skeleton.json +0 -13
- package/registry/ui/split.json +0 -16
- package/registry/ui/stat-strip.json +0 -16
- package/registry/ui/table.json +0 -16
- package/registry/ui/toast.json +0 -16
- package/registry/ui/toolbar.json +0 -13
- package/registry/ui/tree.json +0 -18
package/registry/ui/menu.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "menu",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"popover",
|
|
6
6
|
"separator"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"source": {
|
|
12
12
|
"path": "menu.tsx",
|
|
13
|
-
"content": "/**\n * A menu surface anchored to whatever invoker opens it, riding the same\n * native Popover API {@link Popover} does, sized to its own content and\n * padded around a compact stack of {@link Menu.Item} rows, {@link\n * Menu.Separator} dividers, or a `Section`/`Header` pair grouping related\n * rows together. Every row lands in the page's native Tab order out of the\n * box, since each renders as a real `<a>` or `<button>`.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {\n\tElementProps,\n\tHandle,\n\tMixinDescriptor,\n\tProps as TagProps,\n\tRemixNode,\n} from \"remix/component\";\n\nimport { bg, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, opacity } from \"@sdxc/u/effects\";\nimport { cursor } from \"@sdxc/u/general\";\nimport { flex, gap, items, shrink } from \"@sdxc/u/layout\";\nimport { bs, is, minIs, mb, pb, pi } from \"@sdxc/u/size\";\nimport { active, disabled, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { text, textAlign, textDecoration, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { surfaceInset } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { Popover } from \"@sdxc/ui/popover\";\nimport { Separator } from \"@sdxc/ui/separator\";\n\n/**\n * Side of the invoker {@link Menu} renders against when `placement` is left\n * unset, reading down and start-ward the way a dropdown conventionally does.\n */\nconst DEFAULT_PLACEMENT: Popover.Placement = \"bottom-start\";\n\n/**\n * `role` applied to {@link Menu}'s host through {@link attrs} unless a\n * consumer supplies its own, identifying the surface as an ARIA menu.\n */\nconst DEFAULT_ROLE = \"menu\";\n\n/**\n * `role` applied to {@link Menu.Item} through {@link attrs} unless a\n * consumer supplies its own — `\"menuitemcheckbox\"` and `\"menuitemradio\"` are\n * valid overrides for a row that toggles or selects on activation.\n */\nconst DEFAULT_ITEM_ROLE = \"menuitem\";\n\n/**\n * {@link Menu.ItemProps.type} applied to the `<button>` variant when a\n * consumer leaves it unset, keeping a click on the row from submitting a\n * surrounding `<form>` the way a bare `<button>` otherwise would.\n */\nconst DEFAULT_ITEM_TYPE: NonNullable<Menu.ItemProps[\"type\"]> = \"button\";\n\n/**\n * Prop types for {@link Menu} and its compound parts.\n */\nexport namespace Menu {\n\t/**\n\t * Every prop {@link Popover.Props} accepts, since {@link Menu} renders one\n\t * directly as its host.\n\t */\n\texport interface Props extends Popover.Props {\n\t\t/**\n\t\t * The menu's rows: {@link Menu.Item}, {@link Menu.Separator}, or a\n\t\t * `Section`/`Header` pair grouping related items together.\n\t\t */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<button>` attribute, plus `target`/`rel` for the anchor\n\t * variant `href` enables. Nest a row in a `<form>` for a submit action, or\n\t * compose a `mix`-applied event mixin for click handling.\n\t */\n\texport interface ItemProps extends TagProps<\"button\"> {\n\t\t/** Destination the row navigates to. Renders the row as a native `<a>` instead of a `<button>` when set. */\n\t\thref?: string;\n\t\t/** `target` for the link variant, applied only once `href` is set. */\n\t\ttarget?: TagProps<\"a\">[\"target\"];\n\t\t/** `rel` for the link variant, applied only once `href` is set. */\n\t\trel?: TagProps<\"a\">[\"rel\"];\n\t\t/**\n\t\t * Styles the row in the semantic danger tone, for a destructive action\n\t\t * like deleting a resource.\n\t\t */\n\t\tdanger?: boolean;\n\t\t/**\n\t\t * Extra mixin(s) applied to the row's host element, whichever of\n\t\t * `<a>`/`<button>` it renders as depending on {@link href}.\n\t\t */\n\t\tmix?: MixinDescriptor<HTMLAnchorElement | HTMLButtonElement, any, ElementProps>[];\n\t}\n\n\t/**\n\t * Every prop {@link Separator.Props} accepts, since {@link Menu.Separator}\n\t * renders one directly as its host.\n\t */\n\texport interface SeparatorProps extends Separator.Props {}\n}\n\n/**\n * Renders the menu's own host: a {@link Popover} defaulting to\n * `\"bottom-start\"` placement and `\"menu\"` role, sized to its content. Point a\n * row's `commandfor` at another `<Menu>`'s `id` to open it as a nested menu.\n *\n * @param handle Runtime handle carrying the host's {@link Popover} props.\n * @returns The render function producing the menu's markup.\n * @example\n * <Button commandfor=\"account-menu\" command=\"toggle-popover\">{t(\"nav.account\")}</Button>\n * <Menu id=\"account-menu\" aria-label={t(\"nav.accountMenu\")}>\n * \t<Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * \t<Menu.Item href=\"/settings/billing\">{t(\"nav.billing\")}</Menu.Item>\n * \t<Menu.Separator />\n * \t<Menu.Item danger>{t(\"actions.signOut\")}</Menu.Item>\n * </Menu>\n * @example\n * <Menu id=\"row-menu\" placement=\"left-start\" aria-label={t(\"table.rowActions\")}>\n * \t<Section aria-labelledby=\"row-menu-view-heading\">\n * \t\t<Header id=\"row-menu-view-heading\">{t(\"menu.view\")}</Header>\n * \t\t<Menu.Item href={viewUrl}>{t(\"actions.view\")}</Menu.Item>\n * \t\t<Menu.Item href={editUrl}>{t(\"actions.edit\")}</Menu.Item>\n * \t</Section>\n * \t<Menu.Separator />\n * \t<Menu.Item danger commandfor=\"confirm-delete\" command=\"show-modal\">{t(\"actions.delete\")}</Menu.Item>\n * </Menu>\n */\nexport function Menu(handle: Handle<Menu.Props>) {\n\treturn () => {\n\t\tlet { placement, children, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<Popover\n\t\t\t\t{...rest}\n\t\t\t\tplacement={resolvedPlacement}\n\t\t\t\tmix={[attrs({ role: DEFAULT_ROLE }), minIs(\"10rem\"), surfaceInset(), outline(\"none\"), mix]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</Popover>\n\t\t);\n\t};\n}\n\n/**\n * Renders a native `<a>` when `href` is set, else a `<button>`, defaulting\n * `role` to `\"menuitem\"`; only omitting or neutralizing `href` stops the\n * `<a>` variant's navigation, since `aria-disabled` mutes it visually only.\n *\n * @param handle Runtime handle carrying the host `<a>`/`<button>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * @example\n * <Menu.Item danger disabled>{t(\"actions.delete\")}</Menu.Item>\n * @example\n * <Menu.Item aria-selected={sort === \"name\" ? \"true\" : undefined}>{t(\"sort.name\")}</Menu.Item>\n */\nMenu.Item = function MenuItem(handle: Handle<Menu.ItemProps>) {\n\treturn () => {\n\t\tlet { href, target, rel, type, danger, children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Menu.Item: a row with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\tlet itemMix = [\n\t\t\tinteractiveTransition(),\n\t\t\tattrs({ role: DEFAULT_ITEM_ROLE }),\n\t\t\tflex(),\n\t\t\tis(\"full\"),\n\t\t\titems(\"center\"),\n\t\t\tgap(2),\n\t\t\t/**\n\t\t\t * A glyph in a row reads beside the row's own text, so it is sized against that text\n\t\t\t * and holds that size while a long label wraps.\n\t\t\t */\n\t\t\twhen(\"& > svg, & > [data-slot='icon']\", [is(\"1rem\"), bs(\"1rem\"), shrink()]),\n\t\t\trounded(\"md\"),\n\t\t\tpi(3),\n\t\t\tpb(2),\n\t\t\tfg(\"neutral.emphasis\"),\n\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\twhen(\"&:focus\", bg(\"brand.tint\")),\n\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\twhen('&[aria-selected=\"true\"]', [bg(\"brand.solid\"), fg(\"brand.onSolid\"), weight(500)]),\n\t\t\tdisabled([opacity(50), cursor(\"not-allowed\")]),\n\t\t\twhen(\"&[data-danger]\", [\n\t\t\t\tfg(\"danger\"),\n\t\t\t\thover(bg(\"danger.tint\")),\n\t\t\t\tactive(bg(\"danger.bg-tint-pressed\")),\n\t\t\t\twhen(\"&:focus\", bg(\"danger.tint\")),\n\t\t\t\tfocusVisible(outline(\"danger.ring\")),\n\t\t\t]),\n\t\t\tcursor(\"default\"),\n\t\t\ttextDecoration(\"none\"),\n\t\t\ttext(\"sm\"),\n\t\t\ttextAlign(\"start\"),\n\t\t\tmix,\n\t\t];\n\n\t\tif (href) {\n\t\t\t/**\n\t\t\t * `rest`'s fields (aria-*, data-*, id, event props, …) are all valid\n\t\t\t * on an `<a>` too, so retargeting its type here is safe; `role` is\n\t\t\t * left out since the anchor type narrows it conditionally on `href`.\n\t\t\t */\n\t\t\tlet anchorRest = rest as unknown as Omit<TagProps<\"a\">, \"href\" | \"target\" | \"rel\" | \"role\">;\n\n\t\t\treturn (\n\t\t\t\t<a\n\t\t\t\t\thref={href}\n\t\t\t\t\ttarget={target}\n\t\t\t\t\trel={rel}\n\t\t\t\t\t{...anchorRest}\n\t\t\t\t\tdata-danger={danger || undefined}\n\t\t\t\t\tmix={itemMix}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</a>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={type ?? DEFAULT_ITEM_TYPE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-danger={danger || undefined}\n\t\t\t\tmix={itemMix}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders a hairline divider between two runs of {@link Menu.Item}s: the\n * shared {@link Separator} component with the small block-axis margin a\n * menu's compact rows need on either side of it.\n *\n * @param handle Runtime handle carrying the host's {@link Separator} props.\n * @returns The render function producing the divider's markup.\n * @example\n * <Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * <Menu.Separator />\n * <Menu.Item danger>{t(\"actions.signOut\")}</Menu.Item>\n */\nMenu.Separator = function MenuSeparator(handle: Handle<Menu.SeparatorProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <Separator {...rest} mix={[mb(1), mix]} />;\n\t};\n};\n"
|
|
13
|
+
"content": "/**\n * A menu surface anchored to whatever invoker opens it, riding the same\n * native Popover API {@link Popover} does, sized to its own content and\n * padded around a compact stack of {@link Menu.Item} rows, {@link\n * Menu.Separator} dividers, or a `Section`/`Header` pair grouping related\n * rows together. Every row lands in the page's native Tab order out of the\n * box, since each renders as a real `<a>` or `<button>`.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {\n\tElementProps,\n\tHandle,\n\tMixinDescriptor,\n\tProps as TagProps,\n\tRemixNode,\n} from \"remix/component\";\n\nimport { bg, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, opacity } from \"@sdxc/u/effects\";\nimport { cursor, mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, items, shrink } from \"@sdxc/u/layout\";\nimport { bs, is, minIs, mb, pb, pi } from \"@sdxc/u/size\";\nimport { active, disabled, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { text, textAlign, textDecoration, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { surfaceInset } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { Popover } from \"@sdxc/ui/popover\";\nimport { Separator } from \"@sdxc/ui/separator\";\n\n/**\n * Side of the invoker {@link Menu} renders against when `placement` is left\n * unset, reading down and start-ward the way a dropdown conventionally does.\n */\nconst DEFAULT_PLACEMENT: Popover.Placement = \"bottom-start\";\n\n/**\n * `role` applied to {@link Menu}'s host through {@link attrs} unless a\n * consumer supplies its own, identifying the surface as an ARIA menu.\n */\nconst DEFAULT_ROLE = \"menu\";\n\n/**\n * `role` applied to {@link Menu.Item} through {@link attrs} unless a\n * consumer supplies its own — `\"menuitemcheckbox\"` and `\"menuitemradio\"` are\n * valid overrides for a row that toggles or selects on activation.\n */\nconst DEFAULT_ITEM_ROLE = \"menuitem\";\n\n/**\n * {@link Menu.ItemProps.type} applied to the `<button>` variant when a\n * consumer leaves it unset, keeping a click on the row from submitting a\n * surrounding `<form>` the way a bare `<button>` otherwise would.\n */\nconst DEFAULT_ITEM_TYPE: NonNullable<Menu.ItemProps[\"type\"]> = \"button\";\n\n/**\n * Prop types for {@link Menu} and its compound parts.\n */\nexport namespace Menu {\n\t/**\n\t * Every prop {@link Popover.Props} accepts, since {@link Menu} renders one\n\t * directly as its host.\n\t */\n\texport interface Props extends Popover.Props {\n\t\t/**\n\t\t * The menu's rows: {@link Menu.Item}, {@link Menu.Separator}, or a\n\t\t * `Section`/`Header` pair grouping related items together.\n\t\t */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<button>` attribute, plus `target`/`rel` for the anchor\n\t * variant `href` enables. Nest a row in a `<form>` for a submit action, or\n\t * compose a `mix`-applied event mixin for click handling.\n\t */\n\texport interface ItemProps extends TagProps<\"button\"> {\n\t\t/** Destination the row navigates to. Renders the row as a native `<a>` instead of a `<button>` when set. */\n\t\thref?: string;\n\t\t/** `target` for the link variant, applied only once `href` is set. */\n\t\ttarget?: TagProps<\"a\">[\"target\"];\n\t\t/** `rel` for the link variant, applied only once `href` is set. */\n\t\trel?: TagProps<\"a\">[\"rel\"];\n\t\t/**\n\t\t * Styles the row in the semantic danger tone, for a destructive action\n\t\t * like deleting a resource.\n\t\t */\n\t\tdanger?: boolean;\n\t\t/**\n\t\t * Extra mixin(s) applied to the row's host element, whichever of\n\t\t * `<a>`/`<button>` it renders as depending on {@link href}.\n\t\t */\n\t\tmix?: MixinDescriptor<HTMLAnchorElement | HTMLButtonElement, any, ElementProps>[];\n\t}\n\n\t/**\n\t * Every prop {@link Separator.Props} accepts, since {@link Menu.Separator}\n\t * renders one directly as its host.\n\t */\n\texport interface SeparatorProps extends Separator.Props {}\n}\n\n/**\n * Renders the menu's own host: a {@link Popover} defaulting to\n * `\"bottom-start\"` placement and `\"menu\"` role, sized to its content. Point a\n * row's `commandfor` at another `<Menu>`'s `id` to open it as a nested menu.\n *\n * @param handle Runtime handle carrying the host's {@link Popover} props.\n * @returns The render function producing the menu's markup.\n * @example\n * <Button commandfor=\"account-menu\" command=\"toggle-popover\">{t(\"nav.account\")}</Button>\n * <Menu id=\"account-menu\" aria-label={t(\"nav.accountMenu\")}>\n * \t<Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * \t<Menu.Item href=\"/settings/billing\">{t(\"nav.billing\")}</Menu.Item>\n * \t<Menu.Separator />\n * \t<Menu.Item danger>{t(\"actions.signOut\")}</Menu.Item>\n * </Menu>\n * @example\n * <Menu id=\"row-menu\" placement=\"left-start\" aria-label={t(\"table.rowActions\")}>\n * \t<Section aria-labelledby=\"row-menu-view-heading\">\n * \t\t<Header id=\"row-menu-view-heading\">{t(\"menu.view\")}</Header>\n * \t\t<Menu.Item href={viewUrl}>{t(\"actions.view\")}</Menu.Item>\n * \t\t<Menu.Item href={editUrl}>{t(\"actions.edit\")}</Menu.Item>\n * \t</Section>\n * \t<Menu.Separator />\n * \t<Menu.Item danger commandfor=\"confirm-delete\" command=\"show-modal\">{t(\"actions.delete\")}</Menu.Item>\n * </Menu>\n */\nexport function Menu(handle: Handle<Menu.Props>) {\n\treturn () => {\n\t\tlet { placement, children, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<Popover\n\t\t\t\t{...rest}\n\t\t\t\tplacement={resolvedPlacement}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[attrs({ role: DEFAULT_ROLE }), minIs(\"10rem\"), surfaceInset(), outline(\"none\")],\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</Popover>\n\t\t);\n\t};\n}\n\n/**\n * Renders a native `<a>` when `href` is set, else a `<button>`, defaulting\n * `role` to `\"menuitem\"`; only omitting or neutralizing `href` stops the\n * `<a>` variant's navigation, since `aria-disabled` mutes it visually only.\n *\n * @param handle Runtime handle carrying the host `<a>`/`<button>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * @example\n * <Menu.Item danger disabled>{t(\"actions.delete\")}</Menu.Item>\n * @example\n * <Menu.Item aria-selected={sort === \"name\" ? \"true\" : undefined}>{t(\"sort.name\")}</Menu.Item>\n */\nMenu.Item = function MenuItem(handle: Handle<Menu.ItemProps>) {\n\treturn () => {\n\t\tlet { href, target, rel, type, danger, children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Menu.Item: a row with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\tlet itemMix = mergeMix(\n\t\t\t[\n\t\t\t\tinteractiveTransition(),\n\t\t\t\tattrs({ role: DEFAULT_ITEM_ROLE }),\n\t\t\t\tflex(),\n\t\t\t\tis(\"full\"),\n\t\t\t\titems(\"center\"),\n\t\t\t\tgap(2),\n\t\t\t\t/**\n\t\t\t\t * A glyph in a row reads beside the row's own text, so it is sized against that text\n\t\t\t\t * and holds that size while a long label wraps.\n\t\t\t\t */\n\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", [is(\"1rem\"), bs(\"1rem\"), shrink()]),\n\t\t\t\trounded(\"md\"),\n\t\t\t\tpi(3),\n\t\t\t\tpb(2),\n\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\twhen(\"&:focus\", bg(\"brand.tint\")),\n\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\twhen('&[aria-selected=\"true\"]', [bg(\"brand.solid\"), fg(\"brand.onSolid\"), weight(500)]),\n\t\t\t\tdisabled([opacity(50), cursor(\"not-allowed\")]),\n\t\t\t\twhen(\"&[data-danger]\", [\n\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\thover(bg(\"danger.tint\")),\n\t\t\t\t\tactive(bg(\"danger.bg-tint-pressed\")),\n\t\t\t\t\twhen(\"&:focus\", bg(\"danger.tint\")),\n\t\t\t\t\tfocusVisible(outline(\"danger.ring\")),\n\t\t\t\t]),\n\t\t\t\tcursor(\"default\"),\n\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\ttext(\"sm\"),\n\t\t\t\ttextAlign(\"start\"),\n\t\t\t],\n\t\t\tmix,\n\t\t);\n\n\t\tif (href) {\n\t\t\t/**\n\t\t\t * `rest`'s fields (aria-*, data-*, id, event props, …) are all valid\n\t\t\t * on an `<a>` too, so retargeting its type here is safe; `role` is\n\t\t\t * left out since the anchor type narrows it conditionally on `href`.\n\t\t\t */\n\t\t\tlet anchorRest = rest as unknown as Omit<TagProps<\"a\">, \"href\" | \"target\" | \"rel\" | \"role\">;\n\n\t\t\treturn (\n\t\t\t\t<a\n\t\t\t\t\thref={href}\n\t\t\t\t\ttarget={target}\n\t\t\t\t\trel={rel}\n\t\t\t\t\t{...anchorRest}\n\t\t\t\t\tdata-danger={danger || undefined}\n\t\t\t\t\tmix={itemMix}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</a>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={type ?? DEFAULT_ITEM_TYPE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-danger={danger || undefined}\n\t\t\t\tmix={itemMix}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders a hairline divider between two runs of {@link Menu.Item}s: the\n * shared {@link Separator} component with the small block-axis margin a\n * menu's compact rows need on either side of it.\n *\n * @param handle Runtime handle carrying the host's {@link Separator} props.\n * @returns The render function producing the divider's markup.\n * @example\n * <Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * <Menu.Separator />\n * <Menu.Item danger>{t(\"actions.signOut\")}</Menu.Item>\n */\nMenu.Separator = function MenuSeparator(handle: Handle<Menu.SeparatorProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <Separator {...rest} mix={mergeMix(mb(1), mix)} />;\n\t};\n};\n"
|
|
14
14
|
},
|
|
15
15
|
"test": {
|
|
16
16
|
"path": "menu.test.tsx",
|
package/registry/ui/meter.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meter",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Meter"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
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={
|
|
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, mergeMix } 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={mergeMix(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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tappearance(),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tbs(\"var(--ui-meter-track-block-size, 0.5rem)\"),\n\t\t\t\t\t\tm(\"0\"),\n\t\t\t\t\t\tp(\"0\"),\n\t\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\tblock(),\n\t\t\t\t\t\tborder(\"none\"),\n\t\t\t\t\t\twhen(\"&::-webkit-meter-bar\", [bg(\"neutral.border\"), rounded(\"full\")]),\n\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, [rounded(\"full\"), transition(\"all\")])),\n\t\t\t\t\t\tdata(\n\t\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\t\"brand\",\n\t\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"brand.solid\"))),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdata(\n\t\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\t\"neutral\",\n\t\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"neutral.solid\"))),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdata(\n\t\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\t\"success\",\n\t\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"success.solid\"))),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdata(\n\t\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"warning.solid\"))),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdata(\n\t\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\t\"danger\",\n\t\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, bg(\"danger.solid\"))),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmedia(\n\t\t\t\t\t\t\t\"(prefers-reduced-motion: reduce)\",\n\t\t\t\t\t\t\tFILL_SELECTORS.map((selector) => when(selector, raw({ transitionDuration: \"0s\" }))),\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the 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={mergeMix([text(\"sm\"), tabularNums(), fg(\"neutral\")], mix)} />;\n\t};\n};\n"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|
package/registry/ui/modal.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modal",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"dialog"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
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={
|
|
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 { mergeMix } from \"@sdxc/u/general\";\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={mergeMix(\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
13
|
},
|
|
14
14
|
"test": null
|
|
15
15
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nav-link",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"NavLink"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
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.
|
|
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. Landing sticky headers usually mix `text(\"sm\")`\n * (~13–15px) and a quiet hover so the bar stays dense beside the brand.\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, mergeMix } from \"@sdxc/u/general\";\nimport { data, hover, when } from \"@sdxc/u/state\";\nimport { textDecoration, weight } from \"@sdxc/u/typography\";\n\nimport type { LinkPrefetch } from \"@sdxc/ui/utils\";\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { prefetchAttribute, rendersPrefetchHint } from \"@sdxc/ui/utils\";\n\n/** Semantic color role {@link NavLink} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: NavLink.Color = \"neutral\";\n\n/** Prefetch mode {@link NavLink} falls back to when `prefetch` is omitted. */\nconst DEFAULT_PREFETCH: NavLink.Prefetch = \"none\";\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 * When the destination starts loading: on intent, once in the viewport, on\n\t * render through a `<link rel=\"prefetch\">` that also serves full-document\n\t * navigations, or only on navigation (`\"none\"`).\n\t */\n\texport type Prefetch = LinkPrefetch;\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\t/**\n\t\t * Prefetch mode, for links whose GET is safe to repeat. `\"render\"` suits\n\t\t * multi-page navigations; a menu keeps it to its first few items, since each\n\t\t * hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.\n\t\t */\n\t\tprefetch?: Prefetch;\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\" prefetch=\"render\">{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, prefetch, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<a\n\t\t\t\t\t{...rest}\n\t\t\t\t\tdata-color={resolvedColor}\n\t\t\t\t\tdata-has-background={hasBackground || undefined}\n\t\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t\tmix={mergeMix(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\t\ttextDecoration(\"underline\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\ttextDecorationColor: colorMix(\n\t\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t\t{ color: \"currentcolor\", weight: 60 },\n\t\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\ttextUnderlineOffset: \"4px\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\thover(raw({ textDecorationColor: \"currentcolor\" })),\n\t\t\t\t\t\t\tdata(\"color\", \"brand\", [\n\t\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\t\t\tfg(\"brand.emphasis\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\t\t\tfg(\"success.emphasis\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\t\t\tfg(\"warning.emphasis\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tdata(\"color\", \"danger\", [\n\t\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\t\t\tfg(\"danger.emphasis\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\t\t\traw({ textDecorationThickness: \"2px\", textDecorationColor: \"currentcolor\" }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tdata(\"has-background\", textDecoration(\"none\")),\n\t\t\t\t\t\t\twhen(\n\t\t\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\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tmix,\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t{rendersPrefetchHint(resolvedPrefetch, rest.href) && (\n\t\t\t\t\t<link rel=\"prefetch\" href={rest.href} />\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
12
|
"test": {
|
|
13
13
|
"path": "nav-link.test.tsx",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "navigation-menu",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"popover"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
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 type { LinkPrefetch } from \"@sdxc/ui/utils\";\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\";\nimport { prefetchAttribute, rendersPrefetchHint } from \"@sdxc/ui/utils\";\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/** Prefetch mode {@link NavigationMenu.Link} falls back to when `prefetch` is omitted. */\nconst DEFAULT_PREFETCH: NavigationMenu.Prefetch = \"none\";\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\t/**\n\t\t * `\"intent\"`/`\"viewport\"` write `data-rmx-prefetch`; `\"render\"` adds a `<link rel=\"prefetch\">`\n\t\t * that also serves full-document navigations, so keep it to the first few links, since each\n\t\t * hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.\n\t\t */\n\t\tprefetch?: Prefetch;\n\t};\n\n\t/**\n\t * When a {@link NavigationMenu.Link}'s destination starts loading, the same\n\t * modes every link component in this library accepts.\n\t */\n\texport type Prefetch = LinkPrefetch;\n\n\t/**\n\t * Every native `<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>`, followed\n * by its `<link rel=\"prefetch\">` when `prefetch=\"render\"`. `aria-current` marks\n * the active page; `aria-disabled=\"true\"` only mutes it visually.\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=\"/docs\" prefetch=\"intent\">{t(\"nav.docs\")}</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 { prefetch, mix, ...rest } = handle.props;\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-slot=\"link\"\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\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\n\t\tif (!rendersPrefetchHint(resolvedPrefetch, rest.href)) return anchor;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{anchor}\n\t\t\t\t<link rel=\"prefetch\" href={rest.href} />\n\t\t\t</>\n\t\t);\n\t};\n};\n\n/**\n * Renders a 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"
|
|
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, mergeMix } 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 type { LinkPrefetch } from \"@sdxc/ui/utils\";\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\";\nimport { prefetchAttribute, rendersPrefetchHint } from \"@sdxc/ui/utils\";\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/** Prefetch mode {@link NavigationMenu.Link} falls back to when `prefetch` is omitted. */\nconst DEFAULT_PREFETCH: NavigationMenu.Prefetch = \"none\";\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\t/**\n\t\t * `\"intent\"`/`\"viewport\"` write `data-rmx-prefetch`; `\"render\"` adds a `<link rel=\"prefetch\">`\n\t\t * that also serves full-document navigations, so keep it to the first few links, since each\n\t\t * hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.\n\t\t */\n\t\tprefetch?: Prefetch;\n\t};\n\n\t/**\n\t * When a {@link NavigationMenu.Link}'s destination starts loading, the same\n\t * modes every link component in this library accepts.\n\t */\n\texport type Prefetch = LinkPrefetch;\n\n\t/**\n\t * Every native `<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={mergeMix(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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ role: DEFAULT_LIST_ROLE }),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tgap(1),\n\t\t\t\t\t\twhen('&[data-orientation=\"vertical\"]', [flexCol(), items(\"start\")]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * 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={mergeMix([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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\tpb(2),\n\t\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\tdisabled(opacity(50)),\n\t\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\twhen('&[aria-expanded=\"true\"]', [bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\tdisabled(cursor(\"not-allowed\")),\n\t\t\t\t\t\ttext(\"sm\"),\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.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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t\tminIs(\"11rem\"),\n\t\t\t\t\t\tsurfaceInset({ scale: 2 }),\n\t\t\t\t\t\tz(50),\n\t\t\t\t\t\topacity(0),\n\t\t\t\t\t\twhen('& [data-slot=\"link\"]', [is(\"full\"), justify(\"start\")]),\n\t\t\t\t\t\twhen('&[data-size=\"wide\"]', [is(\"28rem\"), maxIs(\"calc(100vw - 2rem)\")]),\n\t\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\t\ttransition(\"opacity, scale, display, overlay\", {\n\t\t\t\t\t\t\tduration: durations.fast,\n\t\t\t\t\t\t\teasing: easings.standard,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\toutlineStyle(\"none\"),\n\t\t\t\t\t\tscaleProperty(\"0.95\"),\n\t\t\t\t\t\ttransitionBehavior(\"allow-discrete\"),\n\t\t\t\t\t\twhen(\"&:popover-open\", [opacity(100), scaleProperty(\"none\")]),\n\t\t\t\t\t\tstartingStyle(when(\"&:popover-open\", [opacity(0), scaleProperty(\"0.95\")])),\n\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\t\tscaleProperty(\"none\"),\n\t\t\t\t\t\t\ttransitionProperty(\"opacity, display, overlay\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link NavigationMenu.LinkProps.children} as a native `<a>`, followed\n * by its `<link rel=\"prefetch\">` when `prefetch=\"render\"`. `aria-current` marks\n * the active page; `aria-disabled=\"true\"` only mutes it visually.\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=\"/docs\" prefetch=\"intent\">{t(\"nav.docs\")}</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 { prefetch, mix, ...rest } = handle.props;\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-slot=\"link\"\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\tpb(2),\n\t\t\t\t\t\tleading(1),\n\t\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [opacity(50), cursor(\"not-allowed\")]),\n\t\t\t\t\t\tuserSelect(),\n\t\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\n\t\tif (!rendersPrefetchHint(resolvedPrefetch, rest.href)) return anchor;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{anchor}\n\t\t\t\t<link rel=\"prefetch\" href={rest.href} />\n\t\t\t</>\n\t\t);\n\t};\n};\n\n/**\n * Renders a 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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tfloatingSurface(),\n\t\t\t\t\t\traw({ borderRadius: concentricRadius(surfacePadding(2)) }),\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tmbs(2),\n\t\t\t\t\t\toverflow(),\n\t\t\t\t\t\tis(\"var(--ui-navigation-menu-viewport-inline-size, auto)\"),\n\t\t\t\t\t\tbs(\"var(--ui-navigation-menu-viewport-block-size, auto)\"),\n\t\t\t\t\t\topacity(0),\n\t\t\t\t\t\ttransition(\"inline-size, block-size, opacity, scale\", {\n\t\t\t\t\t\t\tduration: durations.normal,\n\t\t\t\t\t\t\teasing: easings.decelerate,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tscaleProperty(\"0.95\"),\n\t\t\t\t\t\tdata(\"visible\", [opacity(100), scaleProperty(\"none\")]),\n\t\t\t\t\t\tstartingStyle(data(\"visible\", [opacity(0), scaleProperty(\"0.95\")])),\n\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\t\tscaleProperty(\"none\"),\n\t\t\t\t\t\t\ttransitionProperty(\"inline-size, block-size, opacity\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@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={mergeMix([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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tgrid(),\n\t\t\t\t\t\tgap(4),\n\t\t\t\t\t\tat(\"40rem\", CONTAINER_NAME, gridTemplate({ columns: \"repeat(2, minmax(0, 1fr))\" })),\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.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={mergeMix([grid(), gap(1)], mix)} />;\n\t};\n};\n"
|
|
13
13
|
},
|
|
14
14
|
"test": {
|
|
15
15
|
"path": "navigation-menu.test.tsx",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "number-field",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"input"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
11
|
"path": "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"
|
|
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, mergeMix } 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={mergeMix(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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ role: DEFAULT_ROLE }),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"stretch\"),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\thover(border(\"neutral.border-hover\")),\n\t\t\t\t\t\t/**\n\t\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\t * field, as every button here does; the border steps only to its hover weight, since a\n\t\t\t\t\t\t * darkened border flush with the ring reads as one thick slab.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&:focus-within\", [\n\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\t\tborder(\"neutral.border-hover\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@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={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\ttextAlign(\"center\"),\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\t\tgrow(),\n\t\t\t\t\t\tshrink(1),\n\t\t\t\t\t\tbasis(\"0%\"),\n\t\t\t\t\t\tborder({ width: \"0\", noStyleDefault: true }),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\"-moz-appearance\": \"textfield\",\n\n\t\t\t\t\t\t\t\"&::-webkit-inner-spin-button, &::-webkit-outer-spin-button\": {\n\t\t\t\t\t\t\t\t\"-webkit-appearance\": \"none\",\n\t\t\t\t\t\t\t\tmargin: \"0\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tfg(\"inherit\"),\n\t\t\t\t\t\twhen(\"&:disabled\", bg(\"transparent\")),\n\t\t\t\t\t\tfocusVisible(outlineWidth(\"0\")),\n\t\t\t\t\t\tinvalid([outlineWidth(\"0\"), fg(\"danger\")]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders 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={mergeMix(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={mergeMix(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
13
|
},
|
|
14
14
|
"test": null
|
|
15
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "otp-field",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"input"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
11
|
"path": "otp-field.tsx",
|
|
12
|
-
"content": "/**\n * A one-time-code field: a native `<input>` defaulting to a numeric virtual\n * keyboard and the platform's SMS/email autofill hint for one-time codes,\n * built on {@link Input} for its box, color, and interaction-state styling.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Maximum code length {@link OtpField} falls back to when `length` is omitted. */\nconst DEFAULT_LENGTH = 6;\n\n/** Virtual-keyboard hint {@link OtpField} falls back to when `inputMode` is omitted. */\nconst DEFAULT_INPUT_MODE = \"numeric\";\n\n/** Platform autofill hint {@link OtpField} falls back to when `autoComplete` is omitted. */\nconst DEFAULT_AUTO_COMPLETE = \"one-time-code\";\n\n/**\n * Prop types for {@link OtpField}.\n */\nexport namespace OtpField {\n\t/**\n\t * Every {@link Input} prop except `type`, `list`, `role`, `inputMode`,\n\t * `autoComplete`, and `maxLength`, fixed to a plain text control with\n\t * `inputMode`/`autoComplete`/`length` read from the fields below instead.\n\t */\n\texport interface Props extends Omit<\n\t\tInput.Props,\n\t\t\"type\" | \"list\" | \"role\" | \"inputMode\" | \"autoComplete\" | \"maxLength\"\n\t> {\n\t\t/**\n\t\t * The one-time code's character count, applied as the control's native\n\t\t * `maxLength`. Defaults to {@link DEFAULT_LENGTH}.\n\t\t */\n\t\tlength?: number;\n\t\t/**\n\t\t * Virtual-keyboard hint passed straight through to the native `inputMode`\n\t\t * attribute. Defaults to {@link DEFAULT_INPUT_MODE}, requesting the\n\t\t * numeric keypad; set it to `\"text\"` for a code that mixes in letters.\n\t\t */\n\t\tinputMode?: Input.Props[\"inputMode\"];\n\t\t/**\n\t\t * Platform autofill hint passed straight through to the native\n\t\t * `autoComplete` attribute. Defaults to {@link DEFAULT_AUTO_COMPLETE}, which\n\t\t * a browser or OS keyboard looks for to offer an SMS or email code inline.\n\t\t */\n\t\tautoComplete?: Input.Props[\"autoComplete\"];\n\t}\n}\n\n/**\n * Renders a single native `<input>` for entering a one-time verification\n * code, built on {@link Input}, sized as one full-width control since a\n * single `<input>` is what carries `autoComplete=\"one-time-code\"` reliably.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"otp\">{t(\"auth.otp.label\")}</Label>\n * <OtpField id=\"otp\" name=\"code\" autoFocus />\n * @example\n * <OtpField\n * \tid=\"otp\"\n * \tname=\"code\"\n * \taria-describedby=\"otp-error\"\n * \taria-invalid=\"true\"\n * />\n * <FieldError id=\"otp-error\">{t(\"auth.otp.invalid\")}</FieldError>\n * @example\n * <OtpField\n * \tid=\"invite-code\"\n * \tname=\"inviteCode\"\n * \tlength={8}\n * \tinputMode=\"text\"\n * \tautoComplete=\"off\"\n * \tpattern=\"[A-Za-z0-9]*\"\n * />\n */\nexport function OtpField(handle: Handle<OtpField.Props>) {\n\treturn () => {\n\t\tlet { length, inputMode, autoComplete, mix, ...rest } = handle.props;\n\t\tlet resolvedLength = length ?? DEFAULT_LENGTH;\n\t\tlet resolvedInputMode = inputMode ?? DEFAULT_INPUT_MODE;\n\t\tlet resolvedAutoComplete = autoComplete ?? DEFAULT_AUTO_COMPLETE;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputMode={resolvedInputMode}\n\t\t\t\tautoComplete={resolvedAutoComplete}\n\t\t\t\tmaxLength={resolvedLength}\n\t\t\t\tdata-slot=\"otp-field\"\n\t\t\t\tmix={[textAlign(\"center\"), weight(500), tabularNums(), text(\"base\"), mix
|
|
12
|
+
"content": "/**\n * A one-time-code field: a native `<input>` defaulting to a numeric virtual\n * keyboard and the platform's SMS/email autofill hint for one-time codes,\n * built on {@link Input} for its box, color, and interaction-state styling.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { mergeMix } from \"@sdxc/u/general\";\nimport { tabularNums, text, textAlign, weight } from \"@sdxc/u/typography\";\n\nimport { Input } from \"@sdxc/ui/input\";\n\n/** Maximum code length {@link OtpField} falls back to when `length` is omitted. */\nconst DEFAULT_LENGTH = 6;\n\n/** Virtual-keyboard hint {@link OtpField} falls back to when `inputMode` is omitted. */\nconst DEFAULT_INPUT_MODE = \"numeric\";\n\n/** Platform autofill hint {@link OtpField} falls back to when `autoComplete` is omitted. */\nconst DEFAULT_AUTO_COMPLETE = \"one-time-code\";\n\n/**\n * Prop types for {@link OtpField}.\n */\nexport namespace OtpField {\n\t/**\n\t * Every {@link Input} prop except `type`, `list`, `role`, `inputMode`,\n\t * `autoComplete`, and `maxLength`, fixed to a plain text control with\n\t * `inputMode`/`autoComplete`/`length` read from the fields below instead.\n\t */\n\texport interface Props extends Omit<\n\t\tInput.Props,\n\t\t\"type\" | \"list\" | \"role\" | \"inputMode\" | \"autoComplete\" | \"maxLength\"\n\t> {\n\t\t/**\n\t\t * The one-time code's character count, applied as the control's native\n\t\t * `maxLength`. Defaults to {@link DEFAULT_LENGTH}.\n\t\t */\n\t\tlength?: number;\n\t\t/**\n\t\t * Virtual-keyboard hint passed straight through to the native `inputMode`\n\t\t * attribute. Defaults to {@link DEFAULT_INPUT_MODE}, requesting the\n\t\t * numeric keypad; set it to `\"text\"` for a code that mixes in letters.\n\t\t */\n\t\tinputMode?: Input.Props[\"inputMode\"];\n\t\t/**\n\t\t * Platform autofill hint passed straight through to the native\n\t\t * `autoComplete` attribute. Defaults to {@link DEFAULT_AUTO_COMPLETE}, which\n\t\t * a browser or OS keyboard looks for to offer an SMS or email code inline.\n\t\t */\n\t\tautoComplete?: Input.Props[\"autoComplete\"];\n\t}\n}\n\n/**\n * Renders a single native `<input>` for entering a one-time verification\n * code, built on {@link Input}, sized as one full-width control since a\n * single `<input>` is what carries `autoComplete=\"one-time-code\"` reliably.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"otp\">{t(\"auth.otp.label\")}</Label>\n * <OtpField id=\"otp\" name=\"code\" autoFocus />\n * @example\n * <OtpField\n * \tid=\"otp\"\n * \tname=\"code\"\n * \taria-describedby=\"otp-error\"\n * \taria-invalid=\"true\"\n * />\n * <FieldError id=\"otp-error\">{t(\"auth.otp.invalid\")}</FieldError>\n * @example\n * <OtpField\n * \tid=\"invite-code\"\n * \tname=\"inviteCode\"\n * \tlength={8}\n * \tinputMode=\"text\"\n * \tautoComplete=\"off\"\n * \tpattern=\"[A-Za-z0-9]*\"\n * />\n */\nexport function OtpField(handle: Handle<OtpField.Props>) {\n\treturn () => {\n\t\tlet { length, inputMode, autoComplete, mix, ...rest } = handle.props;\n\t\tlet resolvedLength = length ?? DEFAULT_LENGTH;\n\t\tlet resolvedInputMode = inputMode ?? DEFAULT_INPUT_MODE;\n\t\tlet resolvedAutoComplete = autoComplete ?? DEFAULT_AUTO_COMPLETE;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputMode={resolvedInputMode}\n\t\t\t\tautoComplete={resolvedAutoComplete}\n\t\t\t\tmaxLength={resolvedLength}\n\t\t\t\tdata-slot=\"otp-field\"\n\t\t\t\tmix={mergeMix([textAlign(\"center\"), weight(500), tabularNums(), text(\"base\")], mix)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
13
13
|
},
|
|
14
14
|
"test": null
|
|
15
15
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "overlay-arrow",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"OverlayArrow"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "overlay-arrow.tsx",
|
|
10
|
-
"content": "/**\n * A small pointer glyph anchoring an overlay surface — a popover, a menu, a\n * tooltip — visually back to the trigger it floats beside. It renders as an\n * absolutely positioned host holding whatever arrow shape a consumer draws\n * as its child (typically an inline `<svg>`), oriented and offset by the\n * `data-placement` attribute contract.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { fill } from \"@sdxc/u/color\";\nimport { calc, pointerEvents, var as varUtility } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinsLeft,\n\tinsRight,\n\titems,\n\tjustify,\n} from \"@sdxc/u/layout\";\nimport { is, mb, mi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { attrs } from \"remix/component\";\n\n/**\n * Side of the overlay {@link OverlayArrow} attaches to when `placement` is\n * left unset. Matches the side an overlay renders on when its own placement\n * request goes unanswered by the positioning engine.\n */\nconst DEFAULT_PLACEMENT: OverlayArrow.Placement = \"bottom\";\n\n/**\n * `aria-hidden=\"true\"` applied through {@link attrs} unless a consumer\n * overrides it, keeping the purely decorative pointer glyph out of the\n * accessibility tree.\n */\nconst DEFAULT_ARIA_HIDDEN = \"true\";\n\n/**\n * Prop types for {@link OverlayArrow}.\n */\nexport namespace OverlayArrow {\n\t/**\n\t * Side (and, for the four corner variants, alignment) of the trigger an\n\t * overlay renders relative to. {@link OverlayArrow} reads only the leading\n\t * segment; the `-start`/`-end` suffix carries no visual effect on the arrow.\n\t */\n\texport type Placement =\n\t\t| \"top\"\n\t\t| \"top-start\"\n\t\t| \"top-end\"\n\t\t| \"bottom\"\n\t\t| \"bottom-start\"\n\t\t| \"bottom-end\"\n\t\t| \"left\"\n\t\t| \"left-start\"\n\t\t| \"left-end\"\n\t\t| \"right\"\n\t\t| \"right-start\"\n\t\t| \"right-end\";\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, plus the\n\t * `placement` that drives which edge of the overlay the arrow attaches to.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Side of the trigger the overlay renders on. Defaults to\n\t\t * {@link DEFAULT_PLACEMENT}.\n\t\t */\n\t\tplacement?: Placement;\n\t}\n}\n\n/**\n * Renders a decorative pointer glyph, rotating to point back at the trigger\n * from whichever edge the overlay attaches to. `\"left\"`/`\"right\"` name a\n * physical viewport side, so the arrow keeps attaching there under any `dir`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the arrow's markup.\n * @example\n * <Popover>\n * \t<OverlayArrow placement=\"bottom\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function OverlayArrow(handle: Handle<OverlayArrow.Props>) {\n\treturn () => {\n\t\tlet { placement, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ARIA_HIDDEN }),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\t/**\n\t\t\t\t\t * The host spans the whole edge it attaches to, so centring the glyph inside it\n\t\t\t\t\t * is what puts the point under the trigger the surface is anchored to.\n\t\t\t\t\t */\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tfill(\"neutral.tint\"),\n\t\t\t\t\tpointerEvents(),\n\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', [\n\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\trotate(180),\n\t\t\t\t\t\tinsBs(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"top\"]', [\n\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\tinsBe(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * A side placement sits past the surface's own inline edge, where the space\n\t\t\t\t\t * left to grow into is none, so the glyph is sized from its own content the\n\t\t\t\t\t * way the block placements are sized from theirs.\n\t\t\t\t\t */\n\t\t\t\t\twhen('&[data-placement^=\"left\"]', [\n\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\trotate(-90),\n\t\t\t\t\t\tinsLeft(\"100%\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"right\"]', [\n\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\trotate(90),\n\t\t\t\t\t\tinsRight(\"100%\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t
|
|
10
|
+
"content": "/**\n * A small pointer glyph anchoring an overlay surface — a popover, a menu, a\n * tooltip — visually back to the trigger it floats beside. It renders as an\n * absolutely positioned host holding whatever arrow shape a consumer draws\n * as its child (typically an inline `<svg>`), oriented and offset by the\n * `data-placement` attribute contract.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { fill } from \"@sdxc/u/color\";\nimport { calc, pointerEvents, var as varUtility, mergeMix } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tflex,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinsLeft,\n\tinsRight,\n\titems,\n\tjustify,\n} from \"@sdxc/u/layout\";\nimport { is, mb, mi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { attrs } from \"remix/component\";\n\n/**\n * Side of the overlay {@link OverlayArrow} attaches to when `placement` is\n * left unset. Matches the side an overlay renders on when its own placement\n * request goes unanswered by the positioning engine.\n */\nconst DEFAULT_PLACEMENT: OverlayArrow.Placement = \"bottom\";\n\n/**\n * `aria-hidden=\"true\"` applied through {@link attrs} unless a consumer\n * overrides it, keeping the purely decorative pointer glyph out of the\n * accessibility tree.\n */\nconst DEFAULT_ARIA_HIDDEN = \"true\";\n\n/**\n * Prop types for {@link OverlayArrow}.\n */\nexport namespace OverlayArrow {\n\t/**\n\t * Side (and, for the four corner variants, alignment) of the trigger an\n\t * overlay renders relative to. {@link OverlayArrow} reads only the leading\n\t * segment; the `-start`/`-end` suffix carries no visual effect on the arrow.\n\t */\n\texport type Placement =\n\t\t| \"top\"\n\t\t| \"top-start\"\n\t\t| \"top-end\"\n\t\t| \"bottom\"\n\t\t| \"bottom-start\"\n\t\t| \"bottom-end\"\n\t\t| \"left\"\n\t\t| \"left-start\"\n\t\t| \"left-end\"\n\t\t| \"right\"\n\t\t| \"right-start\"\n\t\t| \"right-end\";\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough, plus the\n\t * `placement` that drives which edge of the overlay the arrow attaches to.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Side of the trigger the overlay renders on. Defaults to\n\t\t * {@link DEFAULT_PLACEMENT}.\n\t\t */\n\t\tplacement?: Placement;\n\t}\n}\n\n/**\n * Renders a decorative pointer glyph, rotating to point back at the trigger\n * from whichever edge the overlay attaches to. `\"left\"`/`\"right\"` name a\n * physical viewport side, so the arrow keeps attaching there under any `dir`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the arrow's markup.\n * @example\n * <Popover>\n * \t<OverlayArrow placement=\"bottom\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t{content}\n * </Popover>\n */\nexport function OverlayArrow(handle: Handle<OverlayArrow.Props>) {\n\treturn () => {\n\t\tlet { placement, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ARIA_HIDDEN }),\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The host spans the whole edge it attaches to, so centring the glyph inside it\n\t\t\t\t\t\t * is what puts the point under the trigger the surface is anchored to.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tfill(\"neutral.tint\"),\n\t\t\t\t\t\tpointerEvents(),\n\t\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', [\n\t\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\t\trotate(180),\n\t\t\t\t\t\t\tinsBs(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-placement^=\"top\"]', [\n\t\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\t\tinsBe(calc(`${varUtility(\"ui-overlay-arrow-offset\", \"0.5rem\")} * -1`)),\n\t\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A side placement sits past the surface's own inline edge, where the space\n\t\t\t\t\t\t * left to grow into is none, so the glyph is sized from its own content the\n\t\t\t\t\t\t * way the block placements are sized from theirs.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen('&[data-placement^=\"left\"]', [\n\t\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\t\trotate(-90),\n\t\t\t\t\t\t\tinsLeft(\"100%\"),\n\t\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-placement^=\"right\"]', [\n\t\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\t\trotate(90),\n\t\t\t\t\t\t\tinsRight(\"100%\"),\n\t\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\t\tis(\"max-content\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|