@sdxc/kit 2026.10.30 → 2026.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/changelog.jsonl +346 -0
- package/config.schema.json +14 -0
- package/dist/ci/install.d.ts +15 -0
- package/dist/ci/install.js +27 -0
- package/dist/ci/locate.d.ts +23 -0
- package/dist/ci/locate.js +43 -0
- package/dist/cli.js +5 -0
- package/dist/commands/ci/list.d.ts +16 -0
- package/dist/commands/ci/list.js +24 -0
- package/dist/commands/ci/run.d.ts +65 -0
- package/dist/commands/ci/run.js +36 -0
- package/dist/commands/ci/signoff.d.ts +15 -0
- package/dist/commands/ci/signoff.js +15 -0
- package/dist/commands/ci/verify.d.ts +17 -0
- package/dist/commands/ci/verify.js +15 -0
- package/dist/commands/create.js +3 -0
- package/dist/commands/pkg.d.ts +16 -0
- package/dist/commands/pkg.js +71 -0
- package/dist/commands/routes.d.ts +1 -1
- package/dist/config.d.ts +10 -4
- package/dist/config.js +8 -0
- package/dist/contract.d.ts +60 -1
- package/dist/contract.js +46 -0
- package/dist/create/workspace.d.ts +15 -0
- package/dist/create/workspace.js +42 -0
- package/dist/doctor/checks.js +4 -0
- package/dist/doctor/ci.d.ts +15 -0
- package/dist/doctor/ci.js +63 -0
- package/dist/doctor/translations.d.ts +19 -0
- package/dist/doctor/translations.js +144 -0
- package/dist/make/declare.js +32 -11
- package/dist/package-manager.d.ts +2 -0
- package/dist/package-manager.js +16 -2
- package/dist/pkg/catalog.d.ts +12 -0
- package/dist/pkg/catalog.js +153 -0
- package/dist/pkg/resolve.d.ts +67 -0
- package/dist/pkg/resolve.js +147 -0
- package/dist/upgrade/changelog.d.ts +2 -2
- package/dist/upgrade/project.d.ts +2 -2
- package/package.json +10 -8
- package/registry/ui/accordion.json +2 -2
- package/registry/ui/alert-dialog.json +2 -2
- package/registry/ui/alert.json +2 -2
- package/registry/ui/aspect-ratio.json +2 -2
- package/registry/ui/avatar.json +6 -3
- package/registry/ui/badge.json +2 -2
- package/registry/ui/banner.json +16 -0
- package/registry/ui/breadcrumbs.json +2 -2
- package/registry/ui/button.json +5 -3
- package/registry/ui/calendar.json +2 -2
- package/registry/ui/card.json +2 -2
- package/registry/ui/carousel.json +2 -2
- package/registry/ui/checkbox-group.json +2 -2
- package/registry/ui/checkbox.json +2 -2
- package/registry/ui/combobox.json +2 -2
- package/registry/ui/command.json +2 -2
- package/registry/ui/confirm.json +8 -4
- package/registry/ui/cta-group.json +2 -2
- package/registry/ui/date-field.json +2 -2
- package/registry/ui/date-picker.json +2 -2
- package/registry/ui/date-range-picker.json +2 -2
- package/registry/ui/description.json +2 -2
- package/registry/ui/dialog-dismiss.json +13 -0
- package/registry/ui/dialog.json +2 -2
- package/registry/ui/disclosure.json +2 -2
- package/registry/ui/drawer.json +2 -2
- package/registry/ui/field-error.json +2 -2
- package/registry/ui/form.json +2 -2
- package/registry/ui/group.json +2 -2
- package/registry/ui/header.json +2 -2
- package/registry/ui/heading-scope.json +2 -2
- package/registry/ui/heading.json +3 -3
- package/registry/ui/highlight.json +3 -3
- package/registry/ui/hover-card.json +2 -2
- package/registry/ui/image-placeholder.json +2 -2
- package/registry/ui/input.json +2 -2
- package/registry/ui/item.json +2 -2
- package/registry/ui/keyboard.json +2 -2
- package/registry/ui/label.json +2 -2
- package/registry/ui/link-button.json +5 -3
- package/registry/ui/link.json +2 -2
- package/registry/ui/listbox.json +2 -2
- package/registry/ui/menu.json +2 -2
- package/registry/ui/meter.json +2 -2
- package/registry/ui/modal.json +2 -2
- package/registry/ui/nav-link.json +2 -2
- package/registry/ui/navigation-menu.json +2 -2
- package/registry/ui/number-field.json +2 -2
- package/registry/ui/otp-field.json +2 -2
- package/registry/ui/overlay-arrow.json +2 -2
- package/registry/ui/pagination.json +2 -2
- package/registry/ui/popover.json +2 -2
- package/registry/ui/progress-bar.json +2 -2
- package/registry/ui/property-list.json +18 -0
- package/registry/ui/radio-group.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/relative-time.json +17 -0
- package/registry/ui/scroll-area.json +2 -2
- package/registry/ui/search-field.json +2 -2
- package/registry/ui/section.json +2 -2
- package/registry/ui/select.json +2 -2
- package/registry/ui/selection-indicator.json +2 -2
- package/registry/ui/sentinel-row.json +2 -2
- package/registry/ui/separator.json +2 -2
- package/registry/ui/shared-element.json +2 -2
- package/registry/ui/sheet.json +2 -2
- package/registry/ui/sidebar.json +2 -2
- package/registry/ui/slider.json +2 -2
- package/registry/ui/spinner.json +2 -2
- package/registry/ui/status-dot.json +16 -0
- package/registry/ui/switch.json +2 -2
- package/registry/ui/tabs.json +2 -2
- package/registry/ui/tag-group.json +2 -2
- package/registry/ui/text-field.json +7 -3
- package/registry/ui/text.json +2 -2
- package/registry/ui/textarea.json +2 -2
- package/registry/ui/time-field.json +2 -2
- package/registry/ui/timeline.json +16 -0
- package/registry/ui/toggle-button.json +2 -2
- package/registry/ui/tooltip.json +2 -2
- package/registry/ui/typeset.json +2 -2
- package/registry/ui/youtube-embed.json +2 -2
- package/stubs/scaffold.controller.index.stub +1 -1
- package/templates/app/.config/sdxc/ci.ts +26 -0
- package/templates/app/.github/workflows/ci.yml +46 -0
- package/templates/app/README.md +4 -0
- package/templates/app/package.json +1 -0
- package/templates/app/public/_headers +4 -0
- package/registry/ui/attachment.json +0 -15
- package/registry/ui/bubble.json +0 -13
- package/registry/ui/chart.json +0 -13
- package/registry/ui/color-area.json +0 -13
- package/registry/ui/color-field.json +0 -20
- package/registry/ui/color-picker.json +0 -17
- package/registry/ui/color-slider.json +0 -13
- package/registry/ui/color-swatch-picker.json +0 -15
- package/registry/ui/color-swatch.json +0 -13
- package/registry/ui/color-wheel.json +0 -13
- package/registry/ui/context-menu.json +0 -16
- package/registry/ui/drop-indicator.json +0 -13
- package/registry/ui/drop-zone.json +0 -13
- package/registry/ui/empty.json +0 -15
- package/registry/ui/feature.json +0 -18
- package/registry/ui/file-trigger.json +0 -13
- package/registry/ui/grid-list.json +0 -18
- package/registry/ui/logo-cloud.json +0 -16
- package/registry/ui/marker.json +0 -13
- package/registry/ui/marketing-header.json +0 -18
- package/registry/ui/marketing-section.json +0 -16
- package/registry/ui/menubar.json +0 -13
- package/registry/ui/message-scroller.json +0 -16
- package/registry/ui/message.json +0 -13
- package/registry/ui/resizable.json +0 -13
- package/registry/ui/shortcut-list.json +0 -18
- package/registry/ui/skeleton.json +0 -13
- package/registry/ui/split.json +0 -16
- package/registry/ui/stat-strip.json +0 -16
- package/registry/ui/table.json +0 -16
- package/registry/ui/toast.json +0 -16
- package/registry/ui/toolbar.json +0 -13
- package/registry/ui/tree.json +0 -18
package/registry/ui/sidebar.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sidebar",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"dialog",
|
|
6
6
|
"scroll-area",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"source": {
|
|
13
13
|
"path": "sidebar.tsx",
|
|
14
|
-
"content": "/**\n * An application shell's primary navigation rail, composed from a layout\n * root, a collapsible rail, a main-content inset, and a family of\n * group/menu/item parts for organizing links. Collapsing rides a single\n * checkbox's native `:checked` state, so the whole shell works with zero\n * library JavaScript.\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 { PanelLeftIcon } from \"@sdxc/icons\";\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, borderEdge, colorMix, fg, outline, outlineStyle } from \"@sdxc/u/color\";\nimport {\n\tbackdropBlur,\n\tbackdropSaturate,\n\topacity,\n\trounded,\n\tshadow,\n\ttransition,\n\ttransitionBehavior,\n\ttransitionDuration,\n\ttransitionProperty,\n} from \"@sdxc/u/effects\";\nimport { cursor, pseudoContent, userSelect, willChange } from \"@sdxc/u/general\";\nimport { var as varUtility } from \"@sdxc/u/general/var\";\nimport {\n\tabsolute,\n\tcontainer,\n\tfixed,\n\tflex,\n\tflexCol,\n\tgap,\n\tgrow,\n\thidden,\n\tinlineFlex,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinsLeft,\n\tinsRight,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n\tvstack,\n} from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media, supports } from \"@sdxc/u/responsive\";\nimport {\n\tbs,\n\tis,\n\tm,\n\tmaxBs,\n\tmaxIs,\n\tmbe,\n\tmbs,\n\tminBs,\n\tminIs,\n\tmis,\n\tp,\n\tpb,\n\tpbe,\n\tpbs,\n\tpi,\n\tpis,\n\tsafeAreaPadding,\n} from \"@sdxc/u/size\";\nimport { z } from \"@sdxc/u/stacking\";\nimport { after, data, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { scaleProperty, translateProperty, translateX } from \"@sdxc/u/transform\";\nimport {\n\tfontSize,\n\ttabularNums,\n\ttextAlign,\n\ttextDecoration,\n\ttextTransform,\n\ttracking,\n\ttruncate,\n\tweight,\n} 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 { hitArea } from \"@sdxc/ui/styles\";\nimport { prefetchAttribute, rendersPrefetchHint } from \"@sdxc/ui/utils\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { Dialog } from \"@sdxc/ui/dialog\";\nimport { ScrollArea } from \"@sdxc/ui/scroll-area\";\nimport { Separator } from \"@sdxc/ui/separator\";\n\n/** Visual treatment {@link Sidebar} falls back to when `variant` is omitted. */\nconst DEFAULT_VARIANT: Sidebar.Variant = \"sidebar\";\n\n/** Collapse behavior {@link Sidebar} falls back to when `collapsible` is omitted. */\nconst DEFAULT_COLLAPSIBLE: Sidebar.Collapsible = \"offcanvas\";\n\n/**\n * Physical edge {@link Sidebar} docks against, and the edge\n * {@link Sidebar.MobileNav} slides in from, when `side` is omitted.\n */\nconst DEFAULT_SIDE: Sidebar.Side = \"left\";\n\n/** Semantic color role {@link Sidebar.Item} falls back to when `color` is omitted. */\nconst DEFAULT_ITEM_COLOR: Sidebar.Color = \"neutral\";\n\n/** Size variant {@link Sidebar.MenuButton} and {@link Sidebar.MenuLink} fall back to when `size` is omitted. */\nconst DEFAULT_MENU_BUTTON_SIZE: Sidebar.MenuButtonSize = \"md\";\n\n/** Whether {@link Sidebar.MenuAction} stays hidden until its row is hovered or focused, when `showOnHover` is omitted. */\nconst DEFAULT_SHOW_ON_HOVER = true;\n\n/** Whether {@link Sidebar.MenuSkeleton} renders a leading icon placeholder, when `showIcon` is omitted. */\nconst DEFAULT_SHOW_ICON = false;\n\n/** Prefetch mode {@link Sidebar.MenuLink} and {@link Sidebar.MenuSubLink} fall back to when `prefetch` is omitted. */\nconst DEFAULT_PREFETCH: Sidebar.Prefetch = \"none\";\n\n/**\n * Named container {@link Sidebar.Provider} declares on its own host, so\n * {@link Sidebar} and {@link Sidebar.Rail} can query the shell's overall\n * width for room to show a persistent rail, regardless of nesting depth.\n */\nconst PROVIDER_CONTAINER_NAME = \"ui-sidebar-provider\";\n\n/**\n * Named container {@link Sidebar.Inset} declares on its own host, so content\n * rendered inside it — a Card, a Table, anything sized by its surroundings —\n * responds to the inset's own available width as the rail expands or collapses.\n */\nconst INSET_CONTAINER_NAME = \"ui-sidebar-inset\";\n\n/**\n * Container query matching a shell wide enough to host the persistent rail\n * alongside its inset; below this width, {@link Sidebar}'s `\"icon\"` and\n * `\"offcanvas\"` collapse modes step aside for {@link Sidebar.MobileNav}.\n */\nconst WIDE_SHELL_QUERY = `@container ${PROVIDER_CONTAINER_NAME} (min-width: 48rem)`;\n\n/**\n * Selector matching {@link Sidebar.Trigger}'s own checkbox input once it\n * carries the platform's native `:checked` state — the single source of\n * truth every collapse-driven rule in {@link Sidebar} reads from.\n */\nconst TOGGLE_CHECKED_SELECTOR = '[data-slot=\"toggle\"]:checked';\n\n/**\n * Resolves the `aria-current` value an anchor-based nav part renders with:\n * an explicit `aria-current` always wins, and a `current`/`active`\n * shorthand of `true` falls back to `\"page\"` when nothing else was given.\n */\nfunction resolveAriaCurrent(\n\tcurrent: boolean | undefined,\n\tariaCurrent: TagProps<\"a\">[\"aria-current\"],\n): TagProps<\"a\">[\"aria-current\"] {\n\treturn ariaCurrent ?? (current ? \"page\" : undefined);\n}\n\n/**\n * Prop types for {@link Sidebar} and its compound parts.\n */\nexport namespace Sidebar {\n\t/**\n\t * Visual treatment the rail renders with: `\"sidebar\"` sits flush against\n\t * its edge, `\"floating\"` insets itself with a margin, a rounded, shadowed\n\t * panel, and a blurred backdrop; `\"inset\"` renders the same panel without blur.\n\t */\n\texport type Variant = \"sidebar\" | \"floating\" | \"inset\";\n\n\t/**\n\t * How the rail collapses: `\"none\"` always renders at full width, `\"icon\"`\n\t * narrows to an icon-only rail, and `\"offcanvas\"` narrows to nothing. Every\n\t * mode but `\"none\"` yields to {@link Sidebar.MobileNav} on narrow shells.\n\t */\n\texport type Collapsible = \"none\" | \"offcanvas\" | \"icon\";\n\n\t/**\n\t * Physical edge of the shell the rail docks against and, for\n\t * {@link Sidebar.MobileNav}, slides in from. `\"left\"` and `\"right\"` name\n\t * that edge regardless of `dir`, staying pinned to one physical side.\n\t */\n\texport type Side = \"left\" | \"right\";\n\n\t/**\n\t * Semantic color role {@link Sidebar.Item} renders its current-page\n\t * treatment in, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Size variant controlling {@link Sidebar.MenuButton}'s and\n\t * {@link Sidebar.MenuLink}'s padding, font size, and icon size.\n\t */\n\texport type MenuButtonSize = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough. Establishes\n\t * the shell's row layout — {@link Sidebar} beside {@link Sidebar.Inset} —\n\t * plus the {@link PROVIDER_CONTAINER_NAME} container the collapse rules query.\n\t */\n\texport interface ProviderProps extends TagProps<\"div\"> {\n\t\t/** {@link Sidebar} and {@link Sidebar.Inset}, in either order. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<aside>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"aside\"> {\n\t\t/** Visual treatment. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Collapse behavior. Defaults to {@link DEFAULT_COLLAPSIBLE}. */\n\t\tcollapsible?: Collapsible;\n\t\t/** Physical docking edge. Defaults to {@link DEFAULT_SIDE}. */\n\t\tside?: Side;\n\t}\n\n\t/**\n\t * Every prop {@link Dialog.Props} accepts, plus `side`. `id` stays the id\n\t * a trigger elsewhere on the page opens this drawer with — see\n\t * {@link Dialog.Props} for the full Invoker Commands contract.\n\t */\n\texport interface MobileNavProps extends Dialog.Props {\n\t\t/** Physical edge to dock against and slide in from. Defaults to {@link DEFAULT_SIDE}. */\n\t\tside?: Side;\n\t}\n\n\t/**\n\t * Every native `<header>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface HeaderProps extends TagProps<\"header\"> {}\n\n\t/**\n\t * Every prop {@link ScrollArea.ViewportProps} accepts, unchanged.\n\t */\n\texport interface ContentProps extends ScrollArea.ViewportProps {}\n\n\t/**\n\t * Every native `<footer>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface FooterProps extends TagProps<\"footer\"> {}\n\n\t/**\n\t * Every native `<nav>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface NavProps extends TagProps<\"nav\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.Item}, built as an intersection because\n\t * the underlying anchor prop type is a union keyed on `href` — the\n\t * accessible-anchor contract restricts `role` once `href` is present.\n\t */\n\texport type ItemProps = TagProps<\"a\"> & {\n\t\t/** Destination the item navigates to. */\n\t\thref: string;\n\t\t/** Semantic color role applied once the item is current. Defaults to {@link DEFAULT_ITEM_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Shorthand setting `aria-current=\"page\"` when true and `aria-current` is otherwise unset. */\n\t\tcurrent?: boolean;\n\t};\n\n\t/**\n\t * Every native `<section>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupProps extends TagProps<\"section\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupLabelProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<button>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupActionProps extends TagProps<\"button\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupContentProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<ul>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuProps extends TagProps<\"ul\"> {}\n\n\t/**\n\t * Every native `<li>` attribute, plus the `mix` passthrough. Its own\n\t * `:hover`/`:focus-within` state reveals a nested {@link Sidebar.MenuAction}\n\t * that would otherwise stay hidden.\n\t */\n\texport interface MenuItemProps extends TagProps<\"li\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuButton}.\n\t */\n\texport interface MenuButtonProps extends TagProps<\"button\"> {\n\t\t/** Size variant. Defaults to {@link DEFAULT_MENU_BUTTON_SIZE}. */\n\t\tsize?: MenuButtonSize;\n\t\t/** Marks the row as the current selection, independent of navigation. */\n\t\tactive?: boolean;\n\t}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuLink}. Built as an intersection for\n\t * the same reason as {@link Sidebar.ItemProps}.\n\t */\n\texport type MenuLinkProps = TagProps<\"a\"> & {\n\t\t/** Destination the link navigates to. */\n\t\thref: string;\n\t\t/** Size variant. Defaults to {@link DEFAULT_MENU_BUTTON_SIZE}. */\n\t\tsize?: MenuButtonSize;\n\t\t/** Shorthand setting `aria-current=\"page\"` when true and `aria-current` is otherwise unset. */\n\t\tactive?: boolean;\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 Sidebar.MenuLink} or {@link Sidebar.MenuSubLink} destination\n\t * starts loading, the same modes every link component in this library accepts.\n\t */\n\texport type Prefetch = LinkPrefetch;\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuAction}.\n\t */\n\texport interface MenuActionProps extends TagProps<\"button\"> {\n\t\t/**\n\t\t * Whether the control stays invisible until its ancestor\n\t\t * {@link Sidebar.MenuItem} is hovered or focused. Defaults to\n\t\t * {@link DEFAULT_SHOW_ON_HOVER}; set `false` to keep it always visible.\n\t\t */\n\t\tshowOnHover?: boolean;\n\t}\n\n\t/**\n\t * Every native `<span>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuBadgeProps extends TagProps<\"span\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuSkeleton}.\n\t */\n\texport interface MenuSkeletonProps extends TagProps<\"div\"> {\n\t\t/** Whether to render a leading icon-shaped placeholder. Defaults to {@link DEFAULT_SHOW_ICON}. */\n\t\tshowIcon?: boolean;\n\t}\n\n\t/**\n\t * Every native `<ul>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuSubProps extends TagProps<\"ul\"> {}\n\n\t/**\n\t * Every native `<li>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuSubItemProps extends TagProps<\"li\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuSubButton}.\n\t */\n\texport interface MenuSubButtonProps extends TagProps<\"button\"> {\n\t\t/** Marks the row as the current selection, independent of navigation. */\n\t\tactive?: boolean;\n\t}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuSubLink}. Built as an intersection\n\t * for the same reason as {@link Sidebar.ItemProps}.\n\t */\n\texport type MenuSubLinkProps = TagProps<\"a\"> & {\n\t\t/** Destination the link navigates to. */\n\t\thref: string;\n\t\t/** Shorthand setting `aria-current=\"page\"` when true and `aria-current` is otherwise unset. */\n\t\tactive?: boolean;\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 * Props accepted by {@link Sidebar.Rail}: every native `<label>` attribute\n\t * except `htmlFor`, narrowed to required since it names the id of\n\t * {@link Sidebar.Trigger}'s own checkbox, the control this rail mirrors.\n\t */\n\texport interface RailProps extends Omit<TagProps<\"label\">, \"htmlFor\"> {\n\t\t/** Id of the {@link Sidebar.Trigger} checkbox this rail toggles. */\n\t\thtmlFor: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link Sidebar.Trigger}: every native `<input>`\n\t * attribute except `type` and `role`, fixed by the platform's checkbox\n\t * semantics, so `id`, `checked`, `defaultChecked`, and `disabled` all work.\n\t */\n\texport interface TriggerProps extends Omit<TagProps<\"input\">, \"type\" | \"role\"> {\n\t\t/**\n\t\t * Accessible label for the icon-only control — required, since the\n\t\t * control carries no visible text for assistive technology to read.\n\t\t */\n\t\t\"aria-label\": string;\n\t}\n\n\t/**\n\t * Every prop {@link ScrollArea.ViewportProps} accepts, unchanged.\n\t */\n\texport interface InsetProps extends ScrollArea.ViewportProps {}\n\n\t/**\n\t * Every prop {@link Separator.Props} accepts, unchanged.\n\t */\n\texport interface SeparatorProps extends Separator.Props {}\n}\n\n/**\n * Renders the rail itself: a native `<aside>` styled through its `data-*`\n * attributes, with collapse rules keyed off {@link Sidebar.Provider}'s `:has()`\n * state and declared after its base size, so both directions animate.\n *\n * @param handle Runtime handle carrying the host `<aside>`'s props.\n * @returns The render function producing the rail's markup.\n * @example\n * <Sidebar.Provider>\n * \t<Sidebar variant=\"floating\" collapsible=\"icon\" side=\"right\">\n * \t\t<Sidebar.Header>{logo}</Sidebar.Header>\n * \t\t<Sidebar.Content>{nav}</Sidebar.Content>\n * \t</Sidebar>\n * \t<Sidebar.Inset>{children}</Sidebar.Inset>\n * </Sidebar.Provider>\n */\nexport function Sidebar(handle: Handle<Sidebar.Props>) {\n\treturn () => {\n\t\tlet { variant, collapsible, side, mix, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet resolvedCollapsible = collapsible ?? DEFAULT_COLLAPSIBLE;\n\t\tlet resolvedSide = side ?? DEFAULT_SIDE;\n\n\t\treturn (\n\t\t\t<aside\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"sidebar\"\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-collapsible={resolvedCollapsible}\n\t\t\t\tdata-side={resolvedSide}\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\tshrink(),\n\t\t\t\t\tbs(\"full\"),\n\t\t\t\t\tis(varUtility(\"sidebar-width\", \"16rem\")),\n\t\t\t\t\twillChange(\"transform\"),\n\t\t\t\t\tdata(\"side\", \"left\", [\n\t\t\t\t\t\tborderEdge(\"right\", { width: 1, style: \"solid\", color: \"neutral\" }),\n\t\t\t\t\t\tsafeAreaPadding(\"left\"),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"side\", \"right\", [\n\t\t\t\t\t\tborderEdge(\"left\", { width: 1, style: \"solid\", color: \"neutral\" }),\n\t\t\t\t\t\tsafeAreaPadding(\"right\"),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"floating\", [\n\t\t\t\t\t\tm(\"0.5rem\"),\n\t\t\t\t\t\tshadow(\"lg\"),\n\t\t\t\t\t\tsupports(\n\t\t\t\t\t\t\t\"(backdrop-filter: blur(0))\",\n\t\t\t\t\t\t\tmedia(\"(prefers-reduced-transparency: no-preference)\", [\n\t\t\t\t\t\t\t\tborder(\n\t\t\t\t\t\t\t\t\tcolorMix(\n\t\t\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", weight: 80 },\n\t\t\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tbg(\n\t\t\t\t\t\t\t\t\tcolorMix(\n\t\t\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-bg-tint)\", weight: 95 },\n\t\t\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tbackdropBlur(\"md\"),\n\t\t\t\t\t\t\t\tbackdropSaturate(1.4),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"inset\", shadow(\"base\")),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t`@container ${PROVIDER_CONTAINER_NAME} (max-width: 47.9375rem)`,\n\t\t\t\t\t\twhen('&[data-collapsible=\"icon\"], &[data-collapsible=\"offcanvas\"]', hidden()),\n\t\t\t\t\t),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", transitionProperty(\"none\")),\n\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\ttransition(\"inline-size, transform\", {\n\t\t\t\t\t\tduration: durations.normal,\n\t\t\t\t\t\teasing: easings.standard,\n\t\t\t\t\t}),\n\t\t\t\t\tdata(\"variant\", \"floating\", [rounded(\"xl\"), border({ color: \"neutral\", width: 1 })]),\n\t\t\t\t\tdata(\"variant\", \"inset\", [rounded(\"xl\"), border({ color: \"neutral\", width: 1 })]),\n\t\t\t\t\twhen(`[data-slot=\"provider\"]:has(${TOGGLE_CHECKED_SELECTOR}) &`, [\n\t\t\t\t\t\twhen('&[data-collapsible=\"icon\"]', [\n\t\t\t\t\t\t\tis(varUtility(\"sidebar-width-icon\", \"3rem\")),\n\t\t\t\t\t\t\twhen(\"[data-sidebar-collapsed-hide]\", visuallyHidden()),\n\t\t\t\t\t\t\twhen('[data-slot=\"group-label\"]', visuallyHidden()),\n\t\t\t\t\t\t\twhen('[data-slot=\"menu-badge\"]', hidden()),\n\t\t\t\t\t\t\twhen('[data-slot=\"menu-sub\"]', hidden()),\n\t\t\t\t\t\t\twhen('[data-slot=\"menu-button\"], [data-slot=\"menu-link\"]', [\n\t\t\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\t\t\tpi(\"0\"),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-collapsible=\"offcanvas\"][data-side=\"left\"]', [\n\t\t\t\t\t\t\ttranslateX(\"-100%\"),\n\t\t\t\t\t\t\tis(\"0\"),\n\t\t\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\t\t\tborder({ width: \"0\", noStyleDefault: true }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-collapsible=\"offcanvas\"][data-side=\"right\"]', [\n\t\t\t\t\t\t\ttranslateX(\"100%\"),\n\t\t\t\t\t\t\tis(\"0\"),\n\t\t\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\t\t\tborder({ width: \"0\", noStyleDefault: true }),\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 shell's layout root: a flex row placing {@link Sidebar} beside\n * {@link Sidebar.Inset}, whose subtree {@link Sidebar} watches for\n * {@link Sidebar.Trigger}'s checkbox reaching `:checked`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the shell's markup.\n * @example\n * <Sidebar.Provider>\n * \t<Sidebar collapsible=\"icon\">\n * \t\t<Sidebar.Header>\n * \t\t\t<Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * \t\t</Sidebar.Header>\n * \t\t<Sidebar.Content>\n * \t\t\t<Sidebar.Menu>\n * \t\t\t\t<Sidebar.MenuItem>\n * \t\t\t\t\t<Sidebar.MenuLink href=\"/dashboard\" active>\n * \t\t\t\t\t\t<HomeIcon aria-hidden />\n * \t\t\t\t\t\t<span data-sidebar-collapsed-hide>{t(\"nav.dashboard\")}</span>\n * \t\t\t\t\t</Sidebar.MenuLink>\n * \t\t\t\t</Sidebar.MenuItem>\n * \t\t\t</Sidebar.Menu>\n * \t\t</Sidebar.Content>\n * \t\t<Sidebar.Rail htmlFor=\"app-sidebar-toggle\" />\n * \t</Sidebar>\n * \t<Sidebar.Inset>{children}</Sidebar.Inset>\n * </Sidebar.Provider>\n */\nSidebar.Provider = function SidebarProvider(handle: Handle<Sidebar.ProviderProps>) {\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=\"provider\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"stretch\"),\n\t\t\t\t\tminBs(\"100dvh\"),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\tcontainer(PROVIDER_CONTAINER_NAME),\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 docked, edge-to-edge mobile substitute for {@link Sidebar}:\n * {@link Sidebar}'s nav content re-composed inside {@link Dialog}, docked\n * to `side` and opened via Invoker Commands, not a viewport check. A press\n * outside it closes it, which is the dismissal a touch device has.\n *\n * @param handle Runtime handle carrying the host `<dialog>`'s props, plus `side`.\n * @returns The render function producing the drawer's markup.\n * @example\n * <button commandfor=\"mobile-nav\" command=\"show-modal\" aria-label={t(\"nav.openMenu\")}>\n * \t<MenuIcon aria-hidden />\n * </button>\n * <Sidebar.MobileNav id=\"mobile-nav\" aria-label={t(\"nav.mainNavigation\")}>\n * \t<Sidebar.Header>{logo}</Sidebar.Header>\n * \t<Sidebar.Content>{nav}</Sidebar.Content>\n * </Sidebar.MobileNav>\n */\nSidebar.MobileNav = function SidebarMobileNav(handle: Handle<Sidebar.MobileNavProps>) {\n\treturn () => {\n\t\tlet { side, mix, ...rest } = handle.props;\n\t\tlet resolvedSide = side ?? DEFAULT_SIDE;\n\n\t\treturn (\n\t\t\t<Dialog\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"mobile-nav\"\n\t\t\t\tdata-side={resolvedSide}\n\t\t\t\tmix={[\n\t\t\t\t\t/**\n\t\t\t\t\t * A press outside closes the drawer, the way a drawer is dismissed on a phone: a modal\n\t\t\t\t\t * dialog otherwise closes only on Escape, which a touch device lacks. A consumer\n\t\t\t\t\t * holding the drawer open passes its own `closedby`.\n\t\t\t\t\t */\n\t\t\t\t\tattrs({ closedby: \"any\" }),\n\t\t\t\t\tfixed(),\n\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\tm(\"0\"),\n\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\tp(\"0\"),\n\t\t\t\t\tmaxBs(\"none\"),\n\t\t\t\t\tbs(\"full\"),\n\t\t\t\t\tis(varUtility(\"sidebar-width-mobile\", \"18rem\")),\n\t\t\t\t\tmaxIs(\"90vw\"),\n\t\t\t\t\t/** Gated on `[open]` so the UA's own `dialog:not([open])` hiding still applies. */\n\t\t\t\t\twhen(\"&[open]\", flex()),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\twillChange(\"transform\"),\n\t\t\t\t\ttransitionBehavior(\"allow-discrete\"),\n\t\t\t\t\tdata(\"side\", \"left\", [insLeft(\"0\"), safeAreaPadding(\"left\"), translateX(\"-100%\")]),\n\t\t\t\t\twhen('&[data-side=\"left\"][open]', translateX(\"0\")),\n\t\t\t\t\tdata(\"side\", \"right\", [insRight(\"0\"), safeAreaPadding(\"right\"), translateX(\"100%\")]),\n\t\t\t\t\twhen('&[data-side=\"right\"][open]', translateX(\"0\")),\n\t\t\t\t\twhen(\"@starting-style\", [\n\t\t\t\t\t\twhen('&[data-side=\"left\"][open]', translateX(\"-100%\")),\n\t\t\t\t\t\twhen('&[data-side=\"right\"][open]', translateX(\"100%\")),\n\t\t\t\t\t]),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", transitionProperty(\"none\")),\n\t\t\t\t\tpbs(\"env(safe-area-inset-top, 0px)\"),\n\t\t\t\t\tpbe(\"env(safe-area-inset-bottom, 0px)\"),\n\t\t\t\t\ttransition(\"transform, display, overlay\", {\n\t\t\t\t\t\tduration: durations.slow,\n\t\t\t\t\t\teasing: easings.decelerate,\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 rail's header slot: a `<header>` laying out its children in\n * a centered row, block-sized to a fixed height with a divider border\n * below it and safe-area padding on its block-start edge.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the header slot's markup.\n * @example\n * <Sidebar.Header>\n * \t<Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * </Sidebar.Header>\n */\nSidebar.Header = function SidebarHeader(handle: Handle<Sidebar.HeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<header\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"header\"\n\t\t\t\tmix={[\n\t\t\t\t\t/**\n\t\t\t\t\t * The slot paints the rail's background, so content scrolling behind a row held\n\t\t\t\t\t * against the viewport stays hidden; inheriting it matches whichever surface hosts\n\t\t\t\t\t * the row, the docked rail or the drawer.\n\t\t\t\t\t */\n\t\t\t\t\tbg(\"inherit\"),\n\t\t\t\t\tflex(),\n\t\t\t\t\tbs(\"4rem\"),\n\t\t\t\t\tshrink(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tborderEdge(\"block-end\", {\n\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\tstyle: \"solid\",\n\t\t\t\t\t\tcolor: colorMix(\n\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", weight: 80 },\n\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t),\n\t\t\t\t\t}),\n\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\tpi(\"1rem\"),\n\t\t\t\t\tpbs(\"calc(0.5rem + env(safe-area-inset-top, 0px))\"),\n\t\t\t\t\tpbe(\"0.5rem\"),\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 rail's own scrollable nav region: {@link ScrollArea.Viewport}\n * laid out as a padded, gap-separated column that scrolls independently of\n * {@link Sidebar.Header} and {@link Sidebar.Footer} once it overflows.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the content region's markup.\n * @example\n * <Sidebar.Content>\n * \t<Sidebar.Group>\n * \t\t<Sidebar.GroupLabel>{t(\"nav.workspace\")}</Sidebar.GroupLabel>\n * \t\t<Sidebar.Menu>...</Sidebar.Menu>\n * \t</Sidebar.Group>\n * </Sidebar.Content>\n */\nSidebar.Content = function SidebarContent(handle: Handle<Sidebar.ContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ScrollArea.Viewport\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"content\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\tgrow(),\n\t\t\t\t\tminBs(\"0\"),\n\t\t\t\t\tbs(\"auto\"),\n\t\t\t\t\tgap(\"1rem\"),\n\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\tpb(\"1rem\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the rail's footer slot: a `<footer>` laying out its children in\n * a centered row with a divider border above it and safe-area padding on\n * its block-end edge.\n *\n * @param handle Runtime handle carrying the host `<footer>`'s props.\n * @returns The render function producing the footer slot's markup.\n * @example\n * <Sidebar.Footer>\n * \t<Sidebar.MenuButton>{t(\"nav.account\")}</Sidebar.MenuButton>\n * </Sidebar.Footer>\n */\nSidebar.Footer = function SidebarFooter(handle: Handle<Sidebar.FooterProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<footer\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"footer\"\n\t\t\t\tmix={[\n\t\t\t\t\tbg(\"inherit\"),\n\t\t\t\t\tflex(),\n\t\t\t\t\tshrink(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tborderEdge(\"block-start\", {\n\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\tstyle: \"solid\",\n\t\t\t\t\t\tcolor: colorMix(\n\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", weight: 80 },\n\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t),\n\t\t\t\t\t}),\n\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\tpbs(\"1rem\"),\n\t\t\t\t\tpbe(\"calc(1rem + env(safe-area-inset-bottom, 0px))\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a flat navigation list: a `<nav>` stacking its {@link Sidebar.Item}\n * children in a column with a small gap, suited to a rail with a simple,\n * ungrouped set of links.\n *\n * @param handle Runtime handle carrying the host `<nav>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Sidebar.Nav aria-label={t(\"nav.mainNavigation\")}>\n * \t<Sidebar.Item href=\"/dashboard\" current>{t(\"nav.dashboard\")}</Sidebar.Item>\n * \t<Sidebar.Item href=\"/settings\">{t(\"nav.settings\")}</Sidebar.Item>\n * </Sidebar.Nav>\n */\nSidebar.Nav = function SidebarNav(handle: Handle<Sidebar.NavProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <nav {...rest} data-slot=\"nav\" mix={[vstack({ gap: \"0.25rem\" }), mix]} />;\n\t};\n};\n\n/**\n * Renders a single row inside {@link Sidebar.Nav}: a native `<a>` colored\n * through `data-color`, tinted once `aria-current` is set, matching\n * {@link Sidebar.MenuLink}; its focus ring always reads in that same color.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.Item href=\"/dashboard\" current>\n * \t<HomeIcon aria-hidden />\n * \t{t(\"nav.dashboard\")}\n * </Sidebar.Item>\n * @example\n * <Sidebar.Item href=\"/billing/cancel\" color=\"danger\" aria-current={pathname === \"/billing/cancel\" ? \"page\" : undefined}>\n * \t<XCircleIcon aria-hidden />\n * \t{t(\"nav.cancelPlan\")}\n * </Sidebar.Item>\n */\nSidebar.Item = function SidebarItem(handle: Handle<Sidebar.ItemProps>) {\n\treturn () => {\n\t\tlet { color, current, \"aria-current\": ariaCurrent, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_ITEM_COLOR;\n\t\tlet resolvedAriaCurrent = resolveAriaCurrent(current, ariaCurrent);\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\t{...rest}\n\t\t\t\taria-current={resolvedAriaCurrent}\n\t\t\t\tdata-slot=\"item\"\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", outline(\"neutral.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"success\", outline(\"success.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"warning\", outline(\"warning.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"danger\", outline(\"danger.ring\")),\n\t\t\t\t\t]),\n\t\t\t\t\tflex(),\n\t\t\t\t\tminBs(\"2.25rem\"),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\tweight(500),\n\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", [is(\"1rem\"), bs(\"1rem\"), shrink()]),\n\t\t\t\t\twhen(\"&:active\", scaleProperty(0.98)),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\tgap(\"0.75rem\"),\n\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\tpb(\"0.5rem\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\ttransition(\n\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t),\n\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"neutral.muted\")),\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\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"neutral.emphasis\")),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"brand\",\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tbg(\"brand.tint\"),\n\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"brand\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"success\",\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tbg(\"success.tint\"),\n\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"success\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tbg(\"warning.tint\"),\n\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"warning\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"color\",\n\t\t\t\t\t\t\"danger\",\n\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\tbg(\"danger.tint\"),\n\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"danger\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\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 related cluster of {@link Sidebar.Menu} items: a `<section>`\n * stacking its children in a column, gaining a divider border and extra\n * space above itself whenever it follows another {@link Sidebar.Group}.\n *\n * @param handle Runtime handle carrying the host `<section>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <Sidebar.Group>\n * \t<Sidebar.GroupLabel>{t(\"nav.workspace\")}</Sidebar.GroupLabel>\n * \t<Sidebar.GroupContent>\n * \t\t<Sidebar.Menu>...</Sidebar.Menu>\n * \t</Sidebar.GroupContent>\n * </Sidebar.Group>\n */\nSidebar.Group = function SidebarGroup(handle: Handle<Sidebar.GroupProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<section\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"group\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\twhen(\"& + &\", [\n\t\t\t\t\t\tmbs(\"0.5rem\"),\n\t\t\t\t\t\tborderEdge(\"block-start\", {\n\t\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\t\tstyle: \"solid\",\n\t\t\t\t\t\t\tcolor: colorMix(\n\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", weight: 60 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\n\t\t\t\t\tgap(\"0.25rem\"),\n\t\t\t\t\twhen(\"& + &\", pbs(\"1rem\")),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Sidebar.Group}'s label: a small, muted, uppercase heading\n * row, visually clipped once the ancestor {@link Sidebar} collapses to\n * icon-only, while staying announced to assistive technology.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the label's markup.\n * @example\n * <Sidebar.GroupLabel>{t(\"nav.workspace\")}</Sidebar.GroupLabel>\n */\nSidebar.GroupLabel = function SidebarGroupLabel(handle: Handle<Sidebar.GroupLabelProps>) {\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-label\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"between\"),\n\t\t\t\t\tmbe(\"0.25rem\"),\n\t\t\t\t\tweight(600),\n\t\t\t\t\tfontSize(\"xs\"),\n\t\t\t\t\ttextTransform(\"uppercase\"),\n\t\t\t\t\ttracking(\"wider\"),\n\t\t\t\t\tuserSelect(),\n\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\tpb(\"0.375rem\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a small icon-only action button anchored to {@link Sidebar.GroupLabel}'s\n * trailing edge, its pointer target grown to `--ui-target-size`. In dev mode, an\n * action with no plain text and no `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 action's markup.\n * @example\n * <Sidebar.GroupLabel>\n * \t{t(\"nav.workspace\")}\n * \t<Sidebar.GroupAction aria-label={t(\"nav.addWorkspace\")}>\n * \t\t<PlusIcon aria-hidden />\n * \t</Sidebar.GroupAction>\n * </Sidebar.GroupLabel>\n */\nSidebar.GroupAction = function SidebarGroupAction(handle: Handle<Sidebar.GroupActionProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Sidebar.GroupAction: an icon-only action needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"group-action\"\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\tis(\"1.25rem\"),\n\t\t\t\t\tbs(\"1.25rem\"),\n\t\t\t\t\thitArea(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\ttransition(\n\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral\")]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Sidebar.Group}'s body slot: a `<div>` stacking its children\n * — typically a {@link Sidebar.Menu} — in a column with a small gap.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the body slot's markup.\n * @example\n * <Sidebar.GroupContent>\n * \t<Sidebar.Menu>...</Sidebar.Menu>\n * </Sidebar.GroupContent>\n */\nSidebar.GroupContent = function SidebarGroupContent(handle: Handle<Sidebar.GroupContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"group-content\" mix={[vstack({ gap: \"0.125rem\" }), mix]} />;\n\t};\n};\n\n/**\n * Renders a list of nav rows: a native `<ul>` stacking {@link Sidebar.MenuItem}\n * children in a column with a small gap.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Sidebar.Menu>\n * \t<Sidebar.MenuItem>\n * \t\t<Sidebar.MenuLink href=\"/dashboard\">{t(\"nav.dashboard\")}</Sidebar.MenuLink>\n * \t</Sidebar.MenuItem>\n * </Sidebar.Menu>\n */\nSidebar.Menu = function SidebarMenu(handle: Handle<Sidebar.MenuProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu\"\n\t\t\t\tmix={[is(\"full\"), minIs(\"0\"), vstack({ gap: \"0.125rem\" }), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a single row inside {@link Sidebar.Menu}: a relatively positioned\n * `<li>` whose own `:hover`/`:focus-within` state reveals a nested\n * {@link Sidebar.MenuAction} that stays invisible at rest.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuItem>\n * \t<Sidebar.MenuLink href=\"/inbox\">{t(\"nav.inbox\")}</Sidebar.MenuLink>\n * \t<Sidebar.MenuAction aria-label={t(\"nav.inboxSettings\")}>\n * \t\t<SettingsIcon aria-hidden />\n * \t</Sidebar.MenuAction>\n * </Sidebar.MenuItem>\n */\nSidebar.MenuItem = function SidebarMenuItem(handle: Handle<Sidebar.MenuItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-item\"\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tflex(),\n\t\t\t\t\t/**\n\t\t\t\t\t * A plain row centres what it holds and a row carrying a sub-menu stacks, putting the\n\t\t\t\t\t * nested list under it at full width. The selectors never match at once, so the layout\n\t\t\t\t\t * holds whichever order the cascade puts the pair in.\n\t\t\t\t\t */\n\t\t\t\t\twhen('&:not(:has([data-slot=\"menu-sub\"]))', items(\"center\")),\n\t\t\t\t\twhen('&:has([data-slot=\"menu-sub\"])', [flexCol(), items(\"stretch\")]),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t\"&:hover [data-slot='menu-action'], &:focus-within [data-slot='menu-action']\",\n\t\t\t\t\t\topacity(100),\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>` row for an in-page action inside\n * {@link Sidebar.Menu}, sized through `data-size` and marked current via\n * `active`; its leading icon is muted, and a trailing label truncates.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuButton onClick={openCommandPalette}>\n * \t<SearchIcon aria-hidden />\n * \t<span data-sidebar-collapsed-hide>{t(\"nav.search\")}</span>\n * </Sidebar.MenuButton>\n */\nSidebar.MenuButton = function SidebarMenuButton(handle: Handle<Sidebar.MenuButtonProps>) {\n\treturn () => {\n\t\tlet { size, active, mix, ...rest } = handle.props;\n\t\tlet resolvedSize = size ?? DEFAULT_MENU_BUTTON_SIZE;\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-button\"\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-active={active || undefined}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t...menuRowMixins(),\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 `<a>` row for navigation inside {@link Sidebar.Menu},\n * visually identical to {@link Sidebar.MenuButton} and followed by its `<link\n * rel=\"prefetch\">` when `prefetch=\"render\"`. `active` sets `aria-current=\"page\"` when unset.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuLink href=\"/dashboard\" active>\n * \t<HomeIcon aria-hidden />\n * \t<span data-sidebar-collapsed-hide>{t(\"nav.dashboard\")}</span>\n * </Sidebar.MenuLink>\n * @example\n * <Sidebar.MenuLink href=\"/inbox\" prefetch=\"intent\">{t(\"nav.inbox\")}</Sidebar.MenuLink>\n */\nSidebar.MenuLink = function SidebarMenuLink(handle: Handle<Sidebar.MenuLinkProps>) {\n\treturn () => {\n\t\tlet { size, active, prefetch, \"aria-current\": ariaCurrent, mix, ...rest } = handle.props;\n\t\tlet resolvedSize = size ?? DEFAULT_MENU_BUTTON_SIZE;\n\t\tlet resolvedAriaCurrent = resolveAriaCurrent(active, ariaCurrent);\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t{...rest}\n\t\t\t\taria-current={resolvedAriaCurrent}\n\t\t\t\tdata-slot=\"menu-link\"\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-active={active || undefined}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t...menuRowMixins(),\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 * Shared `@sdxc/u` mixins for {@link Sidebar.MenuButton} and\n * {@link Sidebar.MenuLink}, factored out since the two differ only in host\n * element and how their current/active state is expressed.\n */\nfunction menuRowMixins() {\n\treturn [\n\t\tflex(),\n\t\tis(\"full\"),\n\t\tminIs(\"0\"),\n\t\titems(\"center\"),\n\t\toverflow(\"hidden\"),\n\t\ttextAlign(\"start\"),\n\t\tweight(500),\n\t\ttextDecoration(\"none\"),\n\t\tfontSize(\"sm\"),\n\t\toutlineStyle(\"none\"),\n\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", [\n\t\t\tis(\"1rem\"),\n\t\t\tbs(\"1rem\"),\n\t\t\tshrink(),\n\t\t]),\n\t\twhen(\"& > span\", truncate()),\n\t\tdata(\"size\", \"sm\", [\n\t\t\tminBs(\"1.75rem\"),\n\t\t\tpb(\"0.375rem\"),\n\t\t\tfontSize(\"xs\"),\n\t\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", [\n\t\t\t\tis(\"0.875rem\"),\n\t\t\t\tbs(\"0.875rem\"),\n\t\t\t]),\n\t\t]),\n\t\tdata(\"size\", \"md\", minBs(\"2.25rem\")),\n\t\tdata(\"size\", \"lg\", [\n\t\t\tminBs(\"2.75rem\"),\n\t\t\tpb(\"0.625rem\"),\n\t\t\tfontSize(\"base\"),\n\t\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", [\n\t\t\t\tis(\"1.25rem\"),\n\t\t\t\tbs(\"1.25rem\"),\n\t\t\t]),\n\t\t]),\n\t\twhen(\"&:active\", scaleProperty(0.98)),\n\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), opacity(50)]),\n\t\tgap(\"0.75rem\"),\n\t\trounded(\"lg\"),\n\t\tpi(\"0.5rem\"),\n\t\tpb(\"0.5rem\"),\n\t\tfg(\"neutral\"),\n\t\ttransition(\n\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t),\n\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", fg(\"neutral.muted\")),\n\t\twhen('&[data-active], &[aria-current]:not([aria-current=\"false\"])', [\n\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\tfg(\"neutral.emphasis\"),\n\t\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", fg(\"neutral.emphasis\")),\n\t\t]),\n\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t];\n}\n\n/**\n * Renders a small icon-only action anchored to {@link Sidebar.MenuItem}'s trailing\n * edge, revealed by `showOnHover`, with its pointer target grown to `--ui-target-size`.\n * In dev mode, an action with no accessible name logs a `console.warn`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the action's markup.\n * @example\n * <Sidebar.MenuAction aria-label={t(\"nav.inboxSettings\")}>\n * \t<SettingsIcon aria-hidden />\n * </Sidebar.MenuAction>\n * @example\n * <Sidebar.MenuAction showOnHover={false} aria-label={t(\"nav.starred\")}>\n * \t<StarIcon aria-hidden />\n * </Sidebar.MenuAction>\n */\nSidebar.MenuAction = function SidebarMenuAction(handle: Handle<Sidebar.MenuActionProps>) {\n\treturn () => {\n\t\tlet { showOnHover, children, mix, ...rest } = handle.props;\n\t\tlet resolvedShowOnHover = showOnHover ?? DEFAULT_SHOW_ON_HOVER;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Sidebar.MenuAction: an icon-only action needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-action\"\n\t\t\t\tdata-show-on-hover={resolvedShowOnHover ? undefined : \"false\"}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tinsIe(\"0.375rem\"),\n\t\t\t\t\tinsBs(\"50%\"),\n\t\t\t\t\ttranslateProperty(\"0 -50%\"),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\tis(\"1.5rem\"),\n\t\t\t\t\tbs(\"1.5rem\"),\n\t\t\t\t\thitArea(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\topacity(0),\n\t\t\t\t\tfocusVisible(opacity(100)),\n\t\t\t\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\tdata(\"show-on-hover\", \"false\", opacity(100)),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\ttransition(\n\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-pressed\"), fg(\"neutral\")]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders a small count or status pill pinned to the trailing edge of a\n * {@link Sidebar.MenuButton} or {@link Sidebar.MenuLink} row, hidden once\n * the ancestor {@link Sidebar} collapses to its icon-only rail.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the pill's markup.\n * @example\n * <Sidebar.MenuLink href=\"/inbox\">\n * \t{t(\"nav.inbox\")}\n * \t<Sidebar.MenuBadge>24</Sidebar.MenuBadge>\n * </Sidebar.MenuLink>\n */\nSidebar.MenuBadge = function SidebarMenuBadge(handle: Handle<Sidebar.MenuBadgeProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-badge\"\n\t\t\t\tmix={[\n\t\t\t\t\tmis(\"auto\"),\n\t\t\t\t\tshrink(),\n\t\t\t\t\tfontSize(\"xs\"),\n\t\t\t\t\tweight(600),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(\"0.375rem\"),\n\t\t\t\t\tpb(\"0.125rem\"),\n\t\t\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\t\t\tfg(\"neutral\"),\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 static loading placeholder shaped like {@link Sidebar.MenuButton}:\n * an optional icon-shaped {@link Skeleton} block followed by a text-shaped\n * one; compose `pulse()` or `shimmer()` through `mix` for a loading cue.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the placeholder's markup.\n * @example\n * <Sidebar.MenuSkeleton showIcon />\n * @example\n * <Sidebar.MenuSkeleton style={{ inlineSize: \"70%\" }} />\n */\nSidebar.MenuSkeleton = function SidebarMenuSkeleton(handle: Handle<Sidebar.MenuSkeletonProps>) {\n\treturn () => {\n\t\tlet { showIcon, mix, ...rest } = handle.props;\n\t\tlet resolvedShowIcon = showIcon ?? DEFAULT_SHOW_ICON;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-skeleton\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tbs(\"2.25rem\"),\n\t\t\t\t\tgap(\"0.75rem\"),\n\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{resolvedShowIcon && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tdata-slot=\"menu-skeleton-icon\"\n\t\t\t\t\t\tmix={[is(\"1rem\"), bs(\"1rem\"), shrink(), rounded(\"sm\"), bg(\"neutral.border\")]}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<span\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tdata-slot=\"menu-skeleton-text\"\n\t\t\t\t\tmix={[bs(\"1rem\"), grow(), is(\"60%\"), rounded(\"md\"), bg(\"neutral.border\")]}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders a nested list of sub-rows beneath a {@link Sidebar.MenuItem}: a\n * `<ul>` indented from and bordered against the rail's inline-start edge,\n * hidden once the ancestor {@link Sidebar} collapses to its icon-only rail.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the nested list's markup.\n * @example\n * <Sidebar.MenuSub>\n * \t<Sidebar.MenuSubItem>\n * \t\t<Sidebar.MenuSubLink href=\"/settings/profile\">{t(\"nav.profile\")}</Sidebar.MenuSubLink>\n * \t</Sidebar.MenuSubItem>\n * </Sidebar.MenuSub>\n */\nSidebar.MenuSub = function SidebarMenuSub(handle: Handle<Sidebar.MenuSubProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-sub\"\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tmis(\"1rem\"),\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\tborderEdge(\"inline-start\", { width: 1, style: \"solid\" }),\n\t\t\t\t\tpis(\"0.625rem\"),\n\t\t\t\t\tgap(\"0.125rem\"),\n\t\t\t\t\tborder(\"neutral\"),\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 row inside {@link Sidebar.MenuSub}: a plain `<li>`.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuSubItem>\n * \t<Sidebar.MenuSubLink href=\"/settings/profile\">{t(\"nav.profile\")}</Sidebar.MenuSubLink>\n * </Sidebar.MenuSubItem>\n */\nSidebar.MenuSubItem = function SidebarMenuSubItem(handle: Handle<Sidebar.MenuSubItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <li {...rest} data-slot=\"menu-sub-item\" mix={[flex(), items(\"center\"), mix]} />;\n\t};\n};\n\n/**\n * Renders a native `<button>` row for an in-page action inside\n * {@link Sidebar.MenuSub}, smaller and more muted than\n * {@link Sidebar.MenuButton}, marked current through `active`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuSubButton onClick={runQuickAction}>{t(\"nav.markAllRead\")}</Sidebar.MenuSubButton>\n */\nSidebar.MenuSubButton = function SidebarMenuSubButton(handle: Handle<Sidebar.MenuSubButtonProps>) {\n\treturn () => {\n\t\tlet { active, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-sub-button\"\n\t\t\t\tdata-active={active || undefined}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t...menuSubRowMixins(),\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 `<a>` row for navigation inside {@link Sidebar.MenuSub},\n * visually identical to {@link Sidebar.MenuSubButton} and followed by its `<link\n * rel=\"prefetch\">` when `prefetch=\"render\"`. `active` sets `aria-current=\"page\"` when unset.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuSubLink href=\"/settings/profile\" active>{t(\"nav.profile\")}</Sidebar.MenuSubLink>\n */\nSidebar.MenuSubLink = function SidebarMenuSubLink(handle: Handle<Sidebar.MenuSubLinkProps>) {\n\treturn () => {\n\t\tlet { active, prefetch, \"aria-current\": ariaCurrent, mix, ...rest } = handle.props;\n\t\tlet resolvedAriaCurrent = resolveAriaCurrent(active, ariaCurrent);\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t{...rest}\n\t\t\t\taria-current={resolvedAriaCurrent}\n\t\t\t\tdata-slot=\"menu-sub-link\"\n\t\t\t\tdata-active={active || undefined}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t...menuSubRowMixins(),\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 * Shared `@sdxc/u` mixins for {@link Sidebar.MenuSubButton} and\n * {@link Sidebar.MenuSubLink}.\n */\nfunction menuSubRowMixins() {\n\treturn [\n\t\tflex(),\n\t\tminBs(\"2rem\"),\n\t\tis(\"full\"),\n\t\titems(\"center\"),\n\t\ttextAlign(\"start\"),\n\t\ttextDecoration(\"none\"),\n\t\tfontSize(\"sm\"),\n\t\twhen('&[data-active], &[aria-current]:not([aria-current=\"false\"])', weight(500)),\n\t\twhen(\"&:active\", scaleProperty(0.98)),\n\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), opacity(50)]),\n\t\tgap(\"0.5rem\"),\n\t\trounded(\"lg\"),\n\t\tpi(\"0.625rem\"),\n\t\tpb(\"0.375rem\"),\n\t\tfg(\"neutral.muted\"),\n\t\ttransition(\n\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t),\n\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\twhen('&[data-active], &[aria-current]:not([aria-current=\"false\"])', [\n\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\tfg(\"neutral.emphasis\"),\n\t\t]),\n\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t];\n}\n\n/**\n * Renders a thin drag-styled affordance along {@link Sidebar}'s own edge,\n * toggling {@link Sidebar.Trigger}'s checkbox through a native `<label>`\n * association; marked `aria-hidden` since that checkbox is the accessible control.\n *\n * @param handle Runtime handle carrying the host `<label>`'s props.\n * @returns The render function producing the rail's markup.\n * @example\n * <Sidebar>\n * \t<Sidebar.Header>...</Sidebar.Header>\n * \t<Sidebar.Rail htmlFor=\"app-sidebar-toggle\" />\n * </Sidebar>\n */\nSidebar.Rail = function SidebarRail(handle: Handle<Sidebar.RailProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"rail\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": \"true\" }),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\tis(\"1rem\"),\n\t\t\t\t\tz(20),\n\t\t\t\t\thidden(),\n\t\t\t\t\tcursor(\"col-resize\"),\n\t\t\t\t\twhen('[data-side=\"left\"] &', insRight(\"-1rem\")),\n\t\t\t\t\twhen('[data-side=\"right\"] &', insLeft(\"-1rem\")),\n\t\t\t\t\tafter([\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\tis(\"2px\"),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tinsIs(\"50%\"),\n\t\t\t\t\t\ttranslateProperty(\"-50% 0\"),\n\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\ttransitionProperty(\"background-color\"),\n\t\t\t\t\t\ttransitionDuration(\"150ms\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(WIDE_SHELL_QUERY, [flex(), items(\"center\"), justify(\"center\")]),\n\t\t\t\t\thover(after(bg(\"neutral.border\"))),\n\t\t\t\t\twhen(\"&:active\", after(bg(\"brand.ring\"))),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the collapse toggle: a native, keyboard-reachable `<input type=\"checkbox\">`\n * in a button-styled `<label>` whose pointer target grows to `--ui-target-size`; its\n * `:checked` state drives every collapse rule in {@link Sidebar.Provider}.\n *\n * @param handle Runtime handle carrying the host checkbox's props.\n * @returns The render function producing the toggle's markup.\n * @example\n * <Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * @example\n * <Sidebar.Trigger id=\"app-sidebar-toggle\" defaultChecked aria-label={t(\"nav.toggleSidebar\")} />\n */\nSidebar.Trigger = function SidebarTrigger(handle: Handle<Sidebar.TriggerProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\tdata-slot=\"trigger\"\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:has(input:focus-visible)\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\tis(\"2rem\"),\n\t\t\t\t\tbs(\"2rem\"),\n\t\t\t\t\thitArea(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\twhen(\"& > svg\", [is(\"1rem\"), bs(\"1rem\")]),\n\t\t\t\t\twhen(\"&:has(input:disabled)\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\ttransition(\n\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t<PanelLeftIcon />\n\t\t\t\t<input type=\"checkbox\" {...rest} data-slot=\"toggle\" mix={[visuallyHidden(), mix]} />\n\t\t\t</label>\n\t\t);\n\t};\n};\n\n/**\n * Renders the shell's main content region: {@link ScrollArea.Viewport}\n * laid out as a growing flex column that resizes as {@link Sidebar}\n * collapses or expands, declaring {@link INSET_CONTAINER_NAME} for nested sizing.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the inset's markup.\n * @example\n * <Sidebar.Inset>\n * \t<Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * \t<main>{children}</main>\n * </Sidebar.Inset>\n */\nSidebar.Inset = function SidebarInset(handle: Handle<Sidebar.InsetProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ScrollArea.Viewport\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"inset\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\tflexCol(),\n\t\t\t\t\tgrow(),\n\t\t\t\t\tminIs(\"0\"),\n\t\t\t\t\tminBs(\"0\"),\n\t\t\t\t\tbs(\"auto\"),\n\t\t\t\t\tcontainer(INSET_CONTAINER_NAME),\n\t\t\t\t\tbg(\"neutral.tint\"),\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 hairline divider between two stretches of rail content:\n * identical to {@link Separator}, with the small block-axis and inline-axis\n * margins {@link Sidebar}'s own content regions expect around one.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the divider's markup.\n * @example\n * <Sidebar.Group>...</Sidebar.Group>\n * <Sidebar.Separator />\n * <Sidebar.Group>...</Sidebar.Group>\n */\nSidebar.Separator = function SidebarSeparator(handle: Handle<Sidebar.SeparatorProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <Separator {...rest} data-slot=\"separator\" mix={[m(\"0.5rem\"), mix]} />;\n\t};\n};\n"
|
|
14
|
+
"content": "/**\n * An application shell's primary navigation rail, composed from a layout\n * root, a collapsible rail, a main-content inset, and a family of\n * group/menu/item parts for organizing links. Collapsing rides a single\n * checkbox's native `:checked` state, so the whole shell works with zero\n * library JavaScript.\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 { PanelLeftIcon } from \"@sdxc/icons\";\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, border, borderEdge, colorMix, fg, outline, outlineStyle } from \"@sdxc/u/color\";\nimport {\n\tbackdropBlur,\n\tbackdropSaturate,\n\topacity,\n\trounded,\n\tshadow,\n\ttransition,\n\ttransitionBehavior,\n\ttransitionDuration,\n\ttransitionProperty,\n} from \"@sdxc/u/effects\";\nimport { cursor, pseudoContent, userSelect, willChange, mergeMix } from \"@sdxc/u/general\";\nimport { var as varUtility } from \"@sdxc/u/general/var\";\nimport {\n\tabsolute,\n\tcontainer,\n\tfixed,\n\tflex,\n\tflexCol,\n\tgap,\n\tgrow,\n\thidden,\n\tinlineFlex,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinsLeft,\n\tinsRight,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n\tvstack,\n} from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { media, supports } from \"@sdxc/u/responsive\";\nimport {\n\tbs,\n\tis,\n\tm,\n\tmaxBs,\n\tmaxIs,\n\tmbe,\n\tmbs,\n\tminBs,\n\tminIs,\n\tmis,\n\tp,\n\tpb,\n\tpbe,\n\tpbs,\n\tpi,\n\tpis,\n\tsafeAreaPadding,\n} from \"@sdxc/u/size\";\nimport { z } from \"@sdxc/u/stacking\";\nimport { after, data, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { scaleProperty, translateProperty, translateX } from \"@sdxc/u/transform\";\nimport {\n\tfontSize,\n\ttabularNums,\n\ttextAlign,\n\ttextDecoration,\n\ttextTransform,\n\ttracking,\n\ttruncate,\n\tweight,\n} 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 { hitArea } from \"@sdxc/ui/styles\";\nimport { prefetchAttribute, rendersPrefetchHint } from \"@sdxc/ui/utils\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { Dialog } from \"@sdxc/ui/dialog\";\nimport { ScrollArea } from \"@sdxc/ui/scroll-area\";\nimport { Separator } from \"@sdxc/ui/separator\";\n\n/** Visual treatment {@link Sidebar} falls back to when `variant` is omitted. */\nconst DEFAULT_VARIANT: Sidebar.Variant = \"sidebar\";\n\n/** Collapse behavior {@link Sidebar} falls back to when `collapsible` is omitted. */\nconst DEFAULT_COLLAPSIBLE: Sidebar.Collapsible = \"offcanvas\";\n\n/**\n * Physical edge {@link Sidebar} docks against, and the edge\n * {@link Sidebar.MobileNav} slides in from, when `side` is omitted.\n */\nconst DEFAULT_SIDE: Sidebar.Side = \"left\";\n\n/** Semantic color role {@link Sidebar.Item} falls back to when `color` is omitted. */\nconst DEFAULT_ITEM_COLOR: Sidebar.Color = \"neutral\";\n\n/** Size variant {@link Sidebar.MenuButton} and {@link Sidebar.MenuLink} fall back to when `size` is omitted. */\nconst DEFAULT_MENU_BUTTON_SIZE: Sidebar.MenuButtonSize = \"md\";\n\n/** Whether {@link Sidebar.MenuAction} stays hidden until its row is hovered or focused, when `showOnHover` is omitted. */\nconst DEFAULT_SHOW_ON_HOVER = true;\n\n/** Whether {@link Sidebar.MenuSkeleton} renders a leading icon placeholder, when `showIcon` is omitted. */\nconst DEFAULT_SHOW_ICON = false;\n\n/** Prefetch mode {@link Sidebar.MenuLink} and {@link Sidebar.MenuSubLink} fall back to when `prefetch` is omitted. */\nconst DEFAULT_PREFETCH: Sidebar.Prefetch = \"none\";\n\n/**\n * Named container {@link Sidebar.Provider} declares on its own host, so\n * {@link Sidebar} and {@link Sidebar.Rail} can query the shell's overall\n * width for room to show a persistent rail, regardless of nesting depth.\n */\nconst PROVIDER_CONTAINER_NAME = \"ui-sidebar-provider\";\n\n/**\n * Named container {@link Sidebar.Inset} declares on its own host, so content\n * rendered inside it — a Card, a Table, anything sized by its surroundings —\n * responds to the inset's own available width as the rail expands or collapses.\n */\nconst INSET_CONTAINER_NAME = \"ui-sidebar-inset\";\n\n/**\n * Container query matching a shell wide enough to host the persistent rail\n * alongside its inset; below this width, {@link Sidebar}'s `\"icon\"` and\n * `\"offcanvas\"` collapse modes step aside for {@link Sidebar.MobileNav}.\n */\nconst WIDE_SHELL_QUERY = `@container ${PROVIDER_CONTAINER_NAME} (min-width: 48rem)`;\n\n/**\n * Selector matching {@link Sidebar.Trigger}'s own checkbox input once it\n * carries the platform's native `:checked` state — the single source of\n * truth every collapse-driven rule in {@link Sidebar} reads from.\n */\nconst TOGGLE_CHECKED_SELECTOR = '[data-slot=\"toggle\"]:checked';\n\n/**\n * Resolves the `aria-current` value an anchor-based nav part renders with:\n * an explicit `aria-current` always wins, and a `current`/`active`\n * shorthand of `true` falls back to `\"page\"` when nothing else was given.\n */\nfunction resolveAriaCurrent(\n\tcurrent: boolean | undefined,\n\tariaCurrent: TagProps<\"a\">[\"aria-current\"],\n): TagProps<\"a\">[\"aria-current\"] {\n\treturn ariaCurrent ?? (current ? \"page\" : undefined);\n}\n\n/**\n * Prop types for {@link Sidebar} and its compound parts.\n */\nexport namespace Sidebar {\n\t/**\n\t * Visual treatment the rail renders with: `\"sidebar\"` sits flush against\n\t * its edge, `\"floating\"` insets itself with a margin, a rounded, shadowed\n\t * panel, and a blurred backdrop; `\"inset\"` renders the same panel without blur.\n\t */\n\texport type Variant = \"sidebar\" | \"floating\" | \"inset\";\n\n\t/**\n\t * How the rail collapses: `\"none\"` always renders at full width, `\"icon\"`\n\t * narrows to an icon-only rail, and `\"offcanvas\"` narrows to nothing. Every\n\t * mode but `\"none\"` yields to {@link Sidebar.MobileNav} on narrow shells.\n\t */\n\texport type Collapsible = \"none\" | \"offcanvas\" | \"icon\";\n\n\t/**\n\t * Physical edge of the shell the rail docks against and, for\n\t * {@link Sidebar.MobileNav}, slides in from. `\"left\"` and `\"right\"` name\n\t * that edge regardless of `dir`, staying pinned to one physical side.\n\t */\n\texport type Side = \"left\" | \"right\";\n\n\t/**\n\t * Semantic color role {@link Sidebar.Item} renders its current-page\n\t * treatment in, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Size variant controlling {@link Sidebar.MenuButton}'s and\n\t * {@link Sidebar.MenuLink}'s padding, font size, and icon size.\n\t */\n\texport type MenuButtonSize = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough. Establishes\n\t * the shell's row layout — {@link Sidebar} beside {@link Sidebar.Inset} —\n\t * plus the {@link PROVIDER_CONTAINER_NAME} container the collapse rules query.\n\t */\n\texport interface ProviderProps extends TagProps<\"div\"> {\n\t\t/** {@link Sidebar} and {@link Sidebar.Inset}, in either order. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<aside>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"aside\"> {\n\t\t/** Visual treatment. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Collapse behavior. Defaults to {@link DEFAULT_COLLAPSIBLE}. */\n\t\tcollapsible?: Collapsible;\n\t\t/** Physical docking edge. Defaults to {@link DEFAULT_SIDE}. */\n\t\tside?: Side;\n\t}\n\n\t/**\n\t * Every prop {@link Dialog.Props} accepts, plus `side`. `id` stays the id\n\t * a trigger elsewhere on the page opens this drawer with — see\n\t * {@link Dialog.Props} for the full Invoker Commands contract.\n\t */\n\texport interface MobileNavProps extends Dialog.Props {\n\t\t/** Physical edge to dock against and slide in from. Defaults to {@link DEFAULT_SIDE}. */\n\t\tside?: Side;\n\t}\n\n\t/**\n\t * Every native `<header>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface HeaderProps extends TagProps<\"header\"> {}\n\n\t/**\n\t * Every prop {@link ScrollArea.ViewportProps} accepts, unchanged.\n\t */\n\texport interface ContentProps extends ScrollArea.ViewportProps {}\n\n\t/**\n\t * Every native `<footer>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface FooterProps extends TagProps<\"footer\"> {}\n\n\t/**\n\t * Every native `<nav>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface NavProps extends TagProps<\"nav\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.Item}, built as an intersection because\n\t * the underlying anchor prop type is a union keyed on `href` — the\n\t * accessible-anchor contract restricts `role` once `href` is present.\n\t */\n\texport type ItemProps = TagProps<\"a\"> & {\n\t\t/** Destination the item navigates to. */\n\t\thref: string;\n\t\t/** Semantic color role applied once the item is current. Defaults to {@link DEFAULT_ITEM_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Shorthand setting `aria-current=\"page\"` when true and `aria-current` is otherwise unset. */\n\t\tcurrent?: boolean;\n\t};\n\n\t/**\n\t * Every native `<section>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupProps extends TagProps<\"section\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupLabelProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<button>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupActionProps extends TagProps<\"button\"> {}\n\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface GroupContentProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<ul>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuProps extends TagProps<\"ul\"> {}\n\n\t/**\n\t * Every native `<li>` attribute, plus the `mix` passthrough. Its own\n\t * `:hover`/`:focus-within` state reveals a nested {@link Sidebar.MenuAction}\n\t * that would otherwise stay hidden.\n\t */\n\texport interface MenuItemProps extends TagProps<\"li\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuButton}.\n\t */\n\texport interface MenuButtonProps extends TagProps<\"button\"> {\n\t\t/** Size variant. Defaults to {@link DEFAULT_MENU_BUTTON_SIZE}. */\n\t\tsize?: MenuButtonSize;\n\t\t/** Marks the row as the current selection, independent of navigation. */\n\t\tactive?: boolean;\n\t}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuLink}. Built as an intersection for\n\t * the same reason as {@link Sidebar.ItemProps}.\n\t */\n\texport type MenuLinkProps = TagProps<\"a\"> & {\n\t\t/** Destination the link navigates to. */\n\t\thref: string;\n\t\t/** Size variant. Defaults to {@link DEFAULT_MENU_BUTTON_SIZE}. */\n\t\tsize?: MenuButtonSize;\n\t\t/** Shorthand setting `aria-current=\"page\"` when true and `aria-current` is otherwise unset. */\n\t\tactive?: boolean;\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 Sidebar.MenuLink} or {@link Sidebar.MenuSubLink} destination\n\t * starts loading, the same modes every link component in this library accepts.\n\t */\n\texport type Prefetch = LinkPrefetch;\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuAction}.\n\t */\n\texport interface MenuActionProps extends TagProps<\"button\"> {\n\t\t/**\n\t\t * Whether the control stays invisible until its ancestor\n\t\t * {@link Sidebar.MenuItem} is hovered or focused. Defaults to\n\t\t * {@link DEFAULT_SHOW_ON_HOVER}; set `false` to keep it always visible.\n\t\t */\n\t\tshowOnHover?: boolean;\n\t}\n\n\t/**\n\t * Every native `<span>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuBadgeProps extends TagProps<\"span\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuSkeleton}.\n\t */\n\texport interface MenuSkeletonProps extends TagProps<\"div\"> {\n\t\t/** Whether to render a leading icon-shaped placeholder. Defaults to {@link DEFAULT_SHOW_ICON}. */\n\t\tshowIcon?: boolean;\n\t}\n\n\t/**\n\t * Every native `<ul>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuSubProps extends TagProps<\"ul\"> {}\n\n\t/**\n\t * Every native `<li>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface MenuSubItemProps extends TagProps<\"li\"> {}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuSubButton}.\n\t */\n\texport interface MenuSubButtonProps extends TagProps<\"button\"> {\n\t\t/** Marks the row as the current selection, independent of navigation. */\n\t\tactive?: boolean;\n\t}\n\n\t/**\n\t * Props accepted by {@link Sidebar.MenuSubLink}. Built as an intersection\n\t * for the same reason as {@link Sidebar.ItemProps}.\n\t */\n\texport type MenuSubLinkProps = TagProps<\"a\"> & {\n\t\t/** Destination the link navigates to. */\n\t\thref: string;\n\t\t/** Shorthand setting `aria-current=\"page\"` when true and `aria-current` is otherwise unset. */\n\t\tactive?: boolean;\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 * Props accepted by {@link Sidebar.Rail}: every native `<label>` attribute\n\t * except `htmlFor`, narrowed to required since it names the id of\n\t * {@link Sidebar.Trigger}'s own checkbox, the control this rail mirrors.\n\t */\n\texport interface RailProps extends Omit<TagProps<\"label\">, \"htmlFor\"> {\n\t\t/** Id of the {@link Sidebar.Trigger} checkbox this rail toggles. */\n\t\thtmlFor: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link Sidebar.Trigger}: every native `<input>`\n\t * attribute except `type` and `role`, fixed by the platform's checkbox\n\t * semantics, so `id`, `checked`, `defaultChecked`, and `disabled` all work.\n\t */\n\texport interface TriggerProps extends Omit<TagProps<\"input\">, \"type\" | \"role\"> {\n\t\t/**\n\t\t * Accessible label for the icon-only control — required, since the\n\t\t * control carries no visible text for assistive technology to read.\n\t\t */\n\t\t\"aria-label\": string;\n\t}\n\n\t/**\n\t * Every prop {@link ScrollArea.ViewportProps} accepts, unchanged.\n\t */\n\texport interface InsetProps extends ScrollArea.ViewportProps {}\n\n\t/**\n\t * Every prop {@link Separator.Props} accepts, unchanged.\n\t */\n\texport interface SeparatorProps extends Separator.Props {}\n}\n\n/**\n * Renders the rail itself: a native `<aside>` styled through its `data-*`\n * attributes, with collapse rules keyed off {@link Sidebar.Provider}'s `:has()`\n * state and declared after its base size, so both directions animate.\n *\n * @param handle Runtime handle carrying the host `<aside>`'s props.\n * @returns The render function producing the rail's markup.\n * @example\n * <Sidebar.Provider>\n * \t<Sidebar variant=\"floating\" collapsible=\"icon\" side=\"right\">\n * \t\t<Sidebar.Header>{logo}</Sidebar.Header>\n * \t\t<Sidebar.Content>{nav}</Sidebar.Content>\n * \t</Sidebar>\n * \t<Sidebar.Inset>{children}</Sidebar.Inset>\n * </Sidebar.Provider>\n */\nexport function Sidebar(handle: Handle<Sidebar.Props>) {\n\treturn () => {\n\t\tlet { variant, collapsible, side, mix, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet resolvedCollapsible = collapsible ?? DEFAULT_COLLAPSIBLE;\n\t\tlet resolvedSide = side ?? DEFAULT_SIDE;\n\n\t\treturn (\n\t\t\t<aside\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"sidebar\"\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-collapsible={resolvedCollapsible}\n\t\t\t\tdata-side={resolvedSide}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tflexCol(),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\tbs(\"full\"),\n\t\t\t\t\t\tis(varUtility(\"sidebar-width\", \"16rem\")),\n\t\t\t\t\t\twillChange(\"transform\"),\n\t\t\t\t\t\tdata(\"side\", \"left\", [\n\t\t\t\t\t\t\tborderEdge(\"right\", { width: 1, style: \"solid\", color: \"neutral\" }),\n\t\t\t\t\t\t\tsafeAreaPadding(\"left\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"side\", \"right\", [\n\t\t\t\t\t\t\tborderEdge(\"left\", { width: 1, style: \"solid\", color: \"neutral\" }),\n\t\t\t\t\t\t\tsafeAreaPadding(\"right\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"variant\", \"floating\", [\n\t\t\t\t\t\t\tm(\"0.5rem\"),\n\t\t\t\t\t\t\tshadow(\"lg\"),\n\t\t\t\t\t\t\tsupports(\n\t\t\t\t\t\t\t\t\"(backdrop-filter: blur(0))\",\n\t\t\t\t\t\t\t\tmedia(\"(prefers-reduced-transparency: no-preference)\", [\n\t\t\t\t\t\t\t\t\tborder(\n\t\t\t\t\t\t\t\t\t\tcolorMix(\n\t\t\t\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", weight: 80 },\n\t\t\t\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tbg(\n\t\t\t\t\t\t\t\t\t\tcolorMix(\n\t\t\t\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-bg-tint)\", weight: 95 },\n\t\t\t\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tbackdropBlur(\"md\"),\n\t\t\t\t\t\t\t\t\tbackdropSaturate(1.4),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"variant\", \"inset\", shadow(\"base\")),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t`@container ${PROVIDER_CONTAINER_NAME} (max-width: 47.9375rem)`,\n\t\t\t\t\t\t\twhen('&[data-collapsible=\"icon\"], &[data-collapsible=\"offcanvas\"]', hidden()),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", transitionProperty(\"none\")),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\ttransition(\"inline-size, transform\", {\n\t\t\t\t\t\t\tduration: durations.normal,\n\t\t\t\t\t\t\teasing: easings.standard,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tdata(\"variant\", \"floating\", [rounded(\"xl\"), border({ color: \"neutral\", width: 1 })]),\n\t\t\t\t\t\tdata(\"variant\", \"inset\", [rounded(\"xl\"), border({ color: \"neutral\", width: 1 })]),\n\t\t\t\t\t\twhen(`[data-slot=\"provider\"]:has(${TOGGLE_CHECKED_SELECTOR}) &`, [\n\t\t\t\t\t\t\twhen('&[data-collapsible=\"icon\"]', [\n\t\t\t\t\t\t\t\tis(varUtility(\"sidebar-width-icon\", \"3rem\")),\n\t\t\t\t\t\t\t\twhen(\"[data-sidebar-collapsed-hide]\", visuallyHidden()),\n\t\t\t\t\t\t\t\twhen('[data-slot=\"group-label\"]', visuallyHidden()),\n\t\t\t\t\t\t\t\twhen('[data-slot=\"menu-badge\"]', hidden()),\n\t\t\t\t\t\t\t\twhen('[data-slot=\"menu-sub\"]', hidden()),\n\t\t\t\t\t\t\t\twhen('[data-slot=\"menu-button\"], [data-slot=\"menu-link\"]', [\n\t\t\t\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\t\t\t\tpi(\"0\"),\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('&[data-collapsible=\"offcanvas\"][data-side=\"left\"]', [\n\t\t\t\t\t\t\t\ttranslateX(\"-100%\"),\n\t\t\t\t\t\t\t\tis(\"0\"),\n\t\t\t\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\t\t\t\tborder({ width: \"0\", noStyleDefault: true }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\twhen('&[data-collapsible=\"offcanvas\"][data-side=\"right\"]', [\n\t\t\t\t\t\t\t\ttranslateX(\"100%\"),\n\t\t\t\t\t\t\t\tis(\"0\"),\n\t\t\t\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\t\t\t\tborder({ width: \"0\", noStyleDefault: true }),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders the shell's layout root: a flex row placing {@link Sidebar} beside\n * {@link Sidebar.Inset}, whose subtree {@link Sidebar} watches for\n * {@link Sidebar.Trigger}'s checkbox reaching `:checked`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the shell's markup.\n * @example\n * <Sidebar.Provider>\n * \t<Sidebar collapsible=\"icon\">\n * \t\t<Sidebar.Header>\n * \t\t\t<Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * \t\t</Sidebar.Header>\n * \t\t<Sidebar.Content>\n * \t\t\t<Sidebar.Menu>\n * \t\t\t\t<Sidebar.MenuItem>\n * \t\t\t\t\t<Sidebar.MenuLink href=\"/dashboard\" active>\n * \t\t\t\t\t\t<HomeIcon aria-hidden />\n * \t\t\t\t\t\t<span data-sidebar-collapsed-hide>{t(\"nav.dashboard\")}</span>\n * \t\t\t\t\t</Sidebar.MenuLink>\n * \t\t\t\t</Sidebar.MenuItem>\n * \t\t\t</Sidebar.Menu>\n * \t\t</Sidebar.Content>\n * \t\t<Sidebar.Rail htmlFor=\"app-sidebar-toggle\" />\n * \t</Sidebar>\n * \t<Sidebar.Inset>{children}</Sidebar.Inset>\n * </Sidebar.Provider>\n */\nSidebar.Provider = function SidebarProvider(handle: Handle<Sidebar.ProviderProps>) {\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=\"provider\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"stretch\"),\n\t\t\t\t\t\tminBs(\"100dvh\"),\n\t\t\t\t\t\tis(\"full\"),\n\t\t\t\t\t\tcontainer(PROVIDER_CONTAINER_NAME),\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 docked, edge-to-edge mobile substitute for {@link Sidebar}:\n * {@link Sidebar}'s nav content re-composed inside {@link Dialog}, docked\n * to `side` and opened via Invoker Commands, not a viewport check. A press\n * outside it closes it, which is the dismissal a touch device has.\n *\n * @param handle Runtime handle carrying the host `<dialog>`'s props, plus `side`.\n * @returns The render function producing the drawer's markup.\n * @example\n * <button commandfor=\"mobile-nav\" command=\"show-modal\" aria-label={t(\"nav.openMenu\")}>\n * \t<MenuIcon aria-hidden />\n * </button>\n * <Sidebar.MobileNav id=\"mobile-nav\" aria-label={t(\"nav.mainNavigation\")}>\n * \t<Sidebar.Header>{logo}</Sidebar.Header>\n * \t<Sidebar.Content>{nav}</Sidebar.Content>\n * </Sidebar.MobileNav>\n */\nSidebar.MobileNav = function SidebarMobileNav(handle: Handle<Sidebar.MobileNavProps>) {\n\treturn () => {\n\t\tlet { side, mix, ...rest } = handle.props;\n\t\tlet resolvedSide = side ?? DEFAULT_SIDE;\n\n\t\treturn (\n\t\t\t<Dialog\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"mobile-nav\"\n\t\t\t\tdata-side={resolvedSide}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A press outside closes the drawer, the way a drawer is dismissed on a phone: a modal\n\t\t\t\t\t\t * dialog otherwise closes only on Escape, which a touch device lacks. A consumer\n\t\t\t\t\t\t * holding the drawer open passes its own `closedby`.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tattrs({ closedby: \"any\" }),\n\t\t\t\t\t\tfixed(),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tm(\"0\"),\n\t\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\t\tp(\"0\"),\n\t\t\t\t\t\tmaxBs(\"none\"),\n\t\t\t\t\t\tbs(\"full\"),\n\t\t\t\t\t\tis(varUtility(\"sidebar-width-mobile\", \"18rem\")),\n\t\t\t\t\t\tmaxIs(\"90vw\"),\n\t\t\t\t\t\t/** Gated on `[open]` so the UA's own `dialog:not([open])` hiding still applies. */\n\t\t\t\t\t\twhen(\"&[open]\", flex()),\n\t\t\t\t\t\tflexCol(),\n\t\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\t\twillChange(\"transform\"),\n\t\t\t\t\t\ttransitionBehavior(\"allow-discrete\"),\n\t\t\t\t\t\tdata(\"side\", \"left\", [insLeft(\"0\"), safeAreaPadding(\"left\"), translateX(\"-100%\")]),\n\t\t\t\t\t\twhen('&[data-side=\"left\"][open]', translateX(\"0\")),\n\t\t\t\t\t\tdata(\"side\", \"right\", [insRight(\"0\"), safeAreaPadding(\"right\"), translateX(\"100%\")]),\n\t\t\t\t\t\twhen('&[data-side=\"right\"][open]', translateX(\"0\")),\n\t\t\t\t\t\twhen(\"@starting-style\", [\n\t\t\t\t\t\t\twhen('&[data-side=\"left\"][open]', translateX(\"-100%\")),\n\t\t\t\t\t\t\twhen('&[data-side=\"right\"][open]', translateX(\"100%\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", transitionProperty(\"none\")),\n\t\t\t\t\t\tpbs(\"env(safe-area-inset-top, 0px)\"),\n\t\t\t\t\t\tpbe(\"env(safe-area-inset-bottom, 0px)\"),\n\t\t\t\t\t\ttransition(\"transform, display, overlay\", {\n\t\t\t\t\t\t\tduration: durations.slow,\n\t\t\t\t\t\t\teasing: easings.decelerate,\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 rail's header slot: a `<header>` laying out its children in\n * a centered row, block-sized to a fixed height with a divider border\n * below it and safe-area padding on its block-start edge.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the header slot's markup.\n * @example\n * <Sidebar.Header>\n * \t<Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * </Sidebar.Header>\n */\nSidebar.Header = function SidebarHeader(handle: Handle<Sidebar.HeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<header\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"header\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The slot paints the rail's background, so content scrolling behind a row held\n\t\t\t\t\t\t * against the viewport stays hidden; inheriting it matches whichever surface hosts\n\t\t\t\t\t\t * the row, the docked rail or the drawer.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tbg(\"inherit\"),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tbs(\"4rem\"),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tborderEdge(\"block-end\", {\n\t\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\t\tstyle: \"solid\",\n\t\t\t\t\t\t\tcolor: colorMix(\n\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", weight: 80 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\t\tpi(\"1rem\"),\n\t\t\t\t\t\tpbs(\"calc(0.5rem + env(safe-area-inset-top, 0px))\"),\n\t\t\t\t\t\tpbe(\"0.5rem\"),\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 rail's own scrollable nav region: {@link ScrollArea.Viewport}\n * laid out as a padded, gap-separated column that scrolls independently of\n * {@link Sidebar.Header} and {@link Sidebar.Footer} once it overflows.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the content region's markup.\n * @example\n * <Sidebar.Content>\n * \t<Sidebar.Group>\n * \t\t<Sidebar.GroupLabel>{t(\"nav.workspace\")}</Sidebar.GroupLabel>\n * \t\t<Sidebar.Menu>...</Sidebar.Menu>\n * \t</Sidebar.Group>\n * </Sidebar.Content>\n */\nSidebar.Content = function SidebarContent(handle: Handle<Sidebar.ContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ScrollArea.Viewport\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"content\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tflexCol(),\n\t\t\t\t\t\tgrow(),\n\t\t\t\t\t\tminBs(\"0\"),\n\t\t\t\t\t\tbs(\"auto\"),\n\t\t\t\t\t\tgap(\"1rem\"),\n\t\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\t\tpb(\"1rem\"),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the rail's footer slot: a `<footer>` laying out its children in\n * a centered row with a divider border above it and safe-area padding on\n * its block-end edge.\n *\n * @param handle Runtime handle carrying the host `<footer>`'s props.\n * @returns The render function producing the footer slot's markup.\n * @example\n * <Sidebar.Footer>\n * \t<Sidebar.MenuButton>{t(\"nav.account\")}</Sidebar.MenuButton>\n * </Sidebar.Footer>\n */\nSidebar.Footer = function SidebarFooter(handle: Handle<Sidebar.FooterProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<footer\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"footer\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tbg(\"inherit\"),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tborderEdge(\"block-start\", {\n\t\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\t\tstyle: \"solid\",\n\t\t\t\t\t\t\tcolor: colorMix(\n\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", weight: 80 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tgap(\"0.5rem\"),\n\t\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\t\tpbs(\"1rem\"),\n\t\t\t\t\t\tpbe(\"calc(1rem + env(safe-area-inset-bottom, 0px))\"),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a flat navigation list: a `<nav>` stacking its {@link Sidebar.Item}\n * children in a column with a small gap, suited to a rail with a simple,\n * ungrouped set of links.\n *\n * @param handle Runtime handle carrying the host `<nav>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Sidebar.Nav aria-label={t(\"nav.mainNavigation\")}>\n * \t<Sidebar.Item href=\"/dashboard\" current>{t(\"nav.dashboard\")}</Sidebar.Item>\n * \t<Sidebar.Item href=\"/settings\">{t(\"nav.settings\")}</Sidebar.Item>\n * </Sidebar.Nav>\n */\nSidebar.Nav = function SidebarNav(handle: Handle<Sidebar.NavProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <nav {...rest} data-slot=\"nav\" mix={mergeMix(vstack({ gap: \"0.25rem\" }), mix)} />;\n\t};\n};\n\n/**\n * Renders a single row inside {@link Sidebar.Nav}: a native `<a>` colored\n * through `data-color`, tinted once `aria-current` is set, matching\n * {@link Sidebar.MenuLink}; its focus ring always reads in that same color.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.Item href=\"/dashboard\" current>\n * \t<HomeIcon aria-hidden />\n * \t{t(\"nav.dashboard\")}\n * </Sidebar.Item>\n * @example\n * <Sidebar.Item href=\"/billing/cancel\" color=\"danger\" aria-current={pathname === \"/billing/cancel\" ? \"page\" : undefined}>\n * \t<XCircleIcon aria-hidden />\n * \t{t(\"nav.cancelPlan\")}\n * </Sidebar.Item>\n */\nSidebar.Item = function SidebarItem(handle: Handle<Sidebar.ItemProps>) {\n\treturn () => {\n\t\tlet { color, current, \"aria-current\": ariaCurrent, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_ITEM_COLOR;\n\t\tlet resolvedAriaCurrent = resolveAriaCurrent(current, ariaCurrent);\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\t{...rest}\n\t\t\t\taria-current={resolvedAriaCurrent}\n\t\t\t\tdata-slot=\"item\"\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\t\tdata(\"color\", \"neutral\", outline(\"neutral.ring\")),\n\t\t\t\t\t\t\tdata(\"color\", \"success\", outline(\"success.ring\")),\n\t\t\t\t\t\t\tdata(\"color\", \"warning\", outline(\"warning.ring\")),\n\t\t\t\t\t\t\tdata(\"color\", \"danger\", outline(\"danger.ring\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tminBs(\"2.25rem\"),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\t\tweight(500),\n\t\t\t\t\t\ttextDecoration(\"none\"),\n\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", [is(\"1rem\"), bs(\"1rem\"), shrink()]),\n\t\t\t\t\t\twhen(\"&:active\", scaleProperty(0.98)),\n\t\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\t\tgap(\"0.75rem\"),\n\t\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\t\tpb(\"0.5rem\"),\n\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\ttransition(\n\t\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\"&:hover\", [bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"neutral.muted\")),\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\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"neutral.emphasis\")),\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\"brand\",\n\t\t\t\t\t\t\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\tbg(\"brand.tint\"),\n\t\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"brand\")),\n\t\t\t\t\t\t\t]),\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\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\tbg(\"success.tint\"),\n\t\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"success\")),\n\t\t\t\t\t\t\t]),\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\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\tbg(\"warning.tint\"),\n\t\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"warning\")),\n\t\t\t\t\t\t\t]),\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\twhen('&[aria-current]:not([aria-current=\"false\"])', [\n\t\t\t\t\t\t\t\tbg(\"danger.tint\"),\n\t\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\t\twhen(\"& > svg, & > [data-slot='icon']\", fg(\"danger\")),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\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 related cluster of {@link Sidebar.Menu} items: a `<section>`\n * stacking its children in a column, gaining a divider border and extra\n * space above itself whenever it follows another {@link Sidebar.Group}.\n *\n * @param handle Runtime handle carrying the host `<section>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <Sidebar.Group>\n * \t<Sidebar.GroupLabel>{t(\"nav.workspace\")}</Sidebar.GroupLabel>\n * \t<Sidebar.GroupContent>\n * \t\t<Sidebar.Menu>...</Sidebar.Menu>\n * \t</Sidebar.GroupContent>\n * </Sidebar.Group>\n */\nSidebar.Group = function SidebarGroup(handle: Handle<Sidebar.GroupProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<section\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"group\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tflexCol(),\n\t\t\t\t\t\twhen(\"& + &\", [\n\t\t\t\t\t\t\tmbs(\"0.5rem\"),\n\t\t\t\t\t\t\tborderEdge(\"block-start\", {\n\t\t\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\t\t\tstyle: \"solid\",\n\t\t\t\t\t\t\t\tcolor: colorMix(\n\t\t\t\t\t\t\t\t\t\"oklab\",\n\t\t\t\t\t\t\t\t\t{ color: \"var(--ui-neutral-border)\", 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}),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tgap(\"0.25rem\"),\n\t\t\t\t\t\twhen(\"& + &\", pbs(\"1rem\")),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Sidebar.Group}'s label: a small, muted, uppercase heading\n * row, visually clipped once the ancestor {@link Sidebar} collapses to\n * icon-only, while staying announced to assistive technology.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the label's markup.\n * @example\n * <Sidebar.GroupLabel>{t(\"nav.workspace\")}</Sidebar.GroupLabel>\n */\nSidebar.GroupLabel = function SidebarGroupLabel(handle: Handle<Sidebar.GroupLabelProps>) {\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-label\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"between\"),\n\t\t\t\t\t\tmbe(\"0.25rem\"),\n\t\t\t\t\t\tweight(600),\n\t\t\t\t\t\tfontSize(\"xs\"),\n\t\t\t\t\t\ttextTransform(\"uppercase\"),\n\t\t\t\t\t\ttracking(\"wider\"),\n\t\t\t\t\t\tuserSelect(),\n\t\t\t\t\t\tpi(\"0.5rem\"),\n\t\t\t\t\t\tpb(\"0.375rem\"),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\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 small icon-only action button anchored to {@link Sidebar.GroupLabel}'s\n * trailing edge, its pointer target grown to `--ui-target-size`. In dev mode, an\n * action with no plain text and no `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 action's markup.\n * @example\n * <Sidebar.GroupLabel>\n * \t{t(\"nav.workspace\")}\n * \t<Sidebar.GroupAction aria-label={t(\"nav.addWorkspace\")}>\n * \t\t<PlusIcon aria-hidden />\n * \t</Sidebar.GroupAction>\n * </Sidebar.GroupLabel>\n */\nSidebar.GroupAction = function SidebarGroupAction(handle: Handle<Sidebar.GroupActionProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Sidebar.GroupAction: an icon-only action needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"group-action\"\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\trelative(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\tis(\"1.25rem\"),\n\t\t\t\t\t\tbs(\"1.25rem\"),\n\t\t\t\t\t\thitArea(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\ttransition(\n\t\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral\")]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Sidebar.Group}'s body slot: a `<div>` stacking its children\n * — typically a {@link Sidebar.Menu} — in a column with a small gap.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the body slot's markup.\n * @example\n * <Sidebar.GroupContent>\n * \t<Sidebar.Menu>...</Sidebar.Menu>\n * </Sidebar.GroupContent>\n */\nSidebar.GroupContent = function SidebarGroupContent(handle: Handle<Sidebar.GroupContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div {...rest} data-slot=\"group-content\" mix={mergeMix(vstack({ gap: \"0.125rem\" }), mix)} />\n\t\t);\n\t};\n};\n\n/**\n * Renders a list of nav rows: a native `<ul>` stacking {@link Sidebar.MenuItem}\n * children in a column with a small gap.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Sidebar.Menu>\n * \t<Sidebar.MenuItem>\n * \t\t<Sidebar.MenuLink href=\"/dashboard\">{t(\"nav.dashboard\")}</Sidebar.MenuLink>\n * \t</Sidebar.MenuItem>\n * </Sidebar.Menu>\n */\nSidebar.Menu = function SidebarMenu(handle: Handle<Sidebar.MenuProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu\"\n\t\t\t\tmix={mergeMix([is(\"full\"), minIs(\"0\"), vstack({ gap: \"0.125rem\" })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders a single row inside {@link Sidebar.Menu}: a relatively positioned\n * `<li>` whose own `:hover`/`:focus-within` state reveals a nested\n * {@link Sidebar.MenuAction} that stays invisible at rest.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuItem>\n * \t<Sidebar.MenuLink href=\"/inbox\">{t(\"nav.inbox\")}</Sidebar.MenuLink>\n * \t<Sidebar.MenuAction aria-label={t(\"nav.inboxSettings\")}>\n * \t\t<SettingsIcon aria-hidden />\n * \t</Sidebar.MenuAction>\n * </Sidebar.MenuItem>\n */\nSidebar.MenuItem = function SidebarMenuItem(handle: Handle<Sidebar.MenuItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-item\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A plain row centres what it holds and a row carrying a sub-menu stacks, putting the\n\t\t\t\t\t\t * nested list under it at full width. The selectors never match at once, so the layout\n\t\t\t\t\t\t * holds whichever order the cascade puts the pair in.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen('&:not(:has([data-slot=\"menu-sub\"]))', items(\"center\")),\n\t\t\t\t\t\twhen('&:has([data-slot=\"menu-sub\"])', [flexCol(), items(\"stretch\")]),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\"&:hover [data-slot='menu-action'], &:focus-within [data-slot='menu-action']\",\n\t\t\t\t\t\t\topacity(100),\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 a native `<button>` row for an in-page action inside\n * {@link Sidebar.Menu}, sized through `data-size` and marked current via\n * `active`; its leading icon is muted, and a trailing label truncates.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuButton onClick={openCommandPalette}>\n * \t<SearchIcon aria-hidden />\n * \t<span data-sidebar-collapsed-hide>{t(\"nav.search\")}</span>\n * </Sidebar.MenuButton>\n */\nSidebar.MenuButton = function SidebarMenuButton(handle: Handle<Sidebar.MenuButtonProps>) {\n\treturn () => {\n\t\tlet { size, active, mix, ...rest } = handle.props;\n\t\tlet resolvedSize = size ?? DEFAULT_MENU_BUTTON_SIZE;\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-button\"\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-active={active || undefined}\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\t...menuRowMixins(),\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 `<a>` row for navigation inside {@link Sidebar.Menu},\n * visually identical to {@link Sidebar.MenuButton} and followed by its `<link\n * rel=\"prefetch\">` when `prefetch=\"render\"`. `active` sets `aria-current=\"page\"` when unset.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuLink href=\"/dashboard\" active>\n * \t<HomeIcon aria-hidden />\n * \t<span data-sidebar-collapsed-hide>{t(\"nav.dashboard\")}</span>\n * </Sidebar.MenuLink>\n * @example\n * <Sidebar.MenuLink href=\"/inbox\" prefetch=\"intent\">{t(\"nav.inbox\")}</Sidebar.MenuLink>\n */\nSidebar.MenuLink = function SidebarMenuLink(handle: Handle<Sidebar.MenuLinkProps>) {\n\treturn () => {\n\t\tlet { size, active, prefetch, \"aria-current\": ariaCurrent, mix, ...rest } = handle.props;\n\t\tlet resolvedSize = size ?? DEFAULT_MENU_BUTTON_SIZE;\n\t\tlet resolvedAriaCurrent = resolveAriaCurrent(active, ariaCurrent);\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t{...rest}\n\t\t\t\taria-current={resolvedAriaCurrent}\n\t\t\t\tdata-slot=\"menu-link\"\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-active={active || undefined}\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\t...menuRowMixins(),\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 * Shared `@sdxc/u` mixins for {@link Sidebar.MenuButton} and\n * {@link Sidebar.MenuLink}, factored out since the two differ only in host\n * element and how their current/active state is expressed.\n */\nfunction menuRowMixins() {\n\treturn [\n\t\tflex(),\n\t\tis(\"full\"),\n\t\tminIs(\"0\"),\n\t\titems(\"center\"),\n\t\toverflow(\"hidden\"),\n\t\ttextAlign(\"start\"),\n\t\tweight(500),\n\t\ttextDecoration(\"none\"),\n\t\tfontSize(\"sm\"),\n\t\toutlineStyle(\"none\"),\n\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", [\n\t\t\tis(\"1rem\"),\n\t\t\tbs(\"1rem\"),\n\t\t\tshrink(),\n\t\t]),\n\t\twhen(\"& > span\", truncate()),\n\t\tdata(\"size\", \"sm\", [\n\t\t\tminBs(\"1.75rem\"),\n\t\t\tpb(\"0.375rem\"),\n\t\t\tfontSize(\"xs\"),\n\t\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", [\n\t\t\t\tis(\"0.875rem\"),\n\t\t\t\tbs(\"0.875rem\"),\n\t\t\t]),\n\t\t]),\n\t\tdata(\"size\", \"md\", minBs(\"2.25rem\")),\n\t\tdata(\"size\", \"lg\", [\n\t\t\tminBs(\"2.75rem\"),\n\t\t\tpb(\"0.625rem\"),\n\t\t\tfontSize(\"base\"),\n\t\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", [\n\t\t\t\tis(\"1.25rem\"),\n\t\t\t\tbs(\"1.25rem\"),\n\t\t\t]),\n\t\t]),\n\t\twhen(\"&:active\", scaleProperty(0.98)),\n\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), opacity(50)]),\n\t\tgap(\"0.75rem\"),\n\t\trounded(\"lg\"),\n\t\tpi(\"0.5rem\"),\n\t\tpb(\"0.5rem\"),\n\t\tfg(\"neutral\"),\n\t\ttransition(\n\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t),\n\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", fg(\"neutral.muted\")),\n\t\twhen('&[data-active], &[aria-current]:not([aria-current=\"false\"])', [\n\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\tfg(\"neutral.emphasis\"),\n\t\t\twhen(\"& > svg:first-child, & > [data-slot='icon']:first-child\", fg(\"neutral.emphasis\")),\n\t\t]),\n\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t];\n}\n\n/**\n * Renders a small icon-only action anchored to {@link Sidebar.MenuItem}'s trailing\n * edge, revealed by `showOnHover`, with its pointer target grown to `--ui-target-size`.\n * In dev mode, an action with no accessible name logs a `console.warn`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the action's markup.\n * @example\n * <Sidebar.MenuAction aria-label={t(\"nav.inboxSettings\")}>\n * \t<SettingsIcon aria-hidden />\n * </Sidebar.MenuAction>\n * @example\n * <Sidebar.MenuAction showOnHover={false} aria-label={t(\"nav.starred\")}>\n * \t<StarIcon aria-hidden />\n * </Sidebar.MenuAction>\n */\nSidebar.MenuAction = function SidebarMenuAction(handle: Handle<Sidebar.MenuActionProps>) {\n\treturn () => {\n\t\tlet { showOnHover, children, mix, ...rest } = handle.props;\n\t\tlet resolvedShowOnHover = showOnHover ?? DEFAULT_SHOW_ON_HOVER;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Sidebar.MenuAction: an icon-only action needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-action\"\n\t\t\t\tdata-show-on-hover={resolvedShowOnHover ? undefined : \"false\"}\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\tabsolute(),\n\t\t\t\t\t\tinsIe(\"0.375rem\"),\n\t\t\t\t\t\tinsBs(\"50%\"),\n\t\t\t\t\t\ttranslateProperty(\"0 -50%\"),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\tis(\"1.5rem\"),\n\t\t\t\t\t\tbs(\"1.5rem\"),\n\t\t\t\t\t\thitArea(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\topacity(0),\n\t\t\t\t\t\tfocusVisible(opacity(100)),\n\t\t\t\t\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\t\tdata(\"show-on-hover\", \"false\", opacity(100)),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\ttransition(\n\t\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\thover([bg(\"neutral.bg-tint-pressed\"), fg(\"neutral\")]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders a small count or status pill pinned to the trailing edge of a\n * {@link Sidebar.MenuButton} or {@link Sidebar.MenuLink} row, hidden once\n * the ancestor {@link Sidebar} collapses to its icon-only rail.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the pill's markup.\n * @example\n * <Sidebar.MenuLink href=\"/inbox\">\n * \t{t(\"nav.inbox\")}\n * \t<Sidebar.MenuBadge>24</Sidebar.MenuBadge>\n * </Sidebar.MenuLink>\n */\nSidebar.MenuBadge = function SidebarMenuBadge(handle: Handle<Sidebar.MenuBadgeProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-badge\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tmis(\"auto\"),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\tfontSize(\"xs\"),\n\t\t\t\t\t\tweight(600),\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tpi(\"0.375rem\"),\n\t\t\t\t\t\tpb(\"0.125rem\"),\n\t\t\t\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\t\t\t\tfg(\"neutral\"),\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 static loading placeholder shaped like {@link Sidebar.MenuButton}:\n * an optional icon-shaped {@link Skeleton} block followed by a text-shaped\n * one; compose `pulse()` or `shimmer()` through `mix` for a loading cue.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the placeholder's markup.\n * @example\n * <Sidebar.MenuSkeleton showIcon />\n * @example\n * <Sidebar.MenuSkeleton style={{ inlineSize: \"70%\" }} />\n */\nSidebar.MenuSkeleton = function SidebarMenuSkeleton(handle: Handle<Sidebar.MenuSkeletonProps>) {\n\treturn () => {\n\t\tlet { showIcon, mix, ...rest } = handle.props;\n\t\tlet resolvedShowIcon = showIcon ?? DEFAULT_SHOW_ICON;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-skeleton\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[flex(), items(\"center\"), bs(\"2.25rem\"), gap(\"0.75rem\"), pi(\"0.5rem\"), rounded(\"lg\")],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{resolvedShowIcon && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tdata-slot=\"menu-skeleton-icon\"\n\t\t\t\t\t\tmix={[is(\"1rem\"), bs(\"1rem\"), shrink(), rounded(\"sm\"), bg(\"neutral.border\")]}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<span\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tdata-slot=\"menu-skeleton-text\"\n\t\t\t\t\tmix={[bs(\"1rem\"), grow(), is(\"60%\"), rounded(\"md\"), bg(\"neutral.border\")]}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders a nested list of sub-rows beneath a {@link Sidebar.MenuItem}: a\n * `<ul>` indented from and bordered against the rail's inline-start edge,\n * hidden once the ancestor {@link Sidebar} collapses to its icon-only rail.\n *\n * @param handle Runtime handle carrying the host `<ul>`'s props.\n * @returns The render function producing the nested list's markup.\n * @example\n * <Sidebar.MenuSub>\n * \t<Sidebar.MenuSubItem>\n * \t\t<Sidebar.MenuSubLink href=\"/settings/profile\">{t(\"nav.profile\")}</Sidebar.MenuSubLink>\n * \t</Sidebar.MenuSubItem>\n * </Sidebar.MenuSub>\n */\nSidebar.MenuSub = function SidebarMenuSub(handle: Handle<Sidebar.MenuSubProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-sub\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tmis(\"1rem\"),\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tflexCol(),\n\t\t\t\t\t\tborderEdge(\"inline-start\", { width: 1, style: \"solid\" }),\n\t\t\t\t\t\tpis(\"0.625rem\"),\n\t\t\t\t\t\tgap(\"0.125rem\"),\n\t\t\t\t\t\tborder(\"neutral\"),\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 row inside {@link Sidebar.MenuSub}: a plain `<li>`.\n *\n * @param handle Runtime handle carrying the host `<li>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuSubItem>\n * \t<Sidebar.MenuSubLink href=\"/settings/profile\">{t(\"nav.profile\")}</Sidebar.MenuSubLink>\n * </Sidebar.MenuSubItem>\n */\nSidebar.MenuSubItem = function SidebarMenuSubItem(handle: Handle<Sidebar.MenuSubItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li {...rest} data-slot=\"menu-sub-item\" mix={mergeMix([flex(), items(\"center\")], mix)} />\n\t\t);\n\t};\n};\n\n/**\n * Renders a native `<button>` row for an in-page action inside\n * {@link Sidebar.MenuSub}, smaller and more muted than\n * {@link Sidebar.MenuButton}, marked current through `active`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuSubButton onClick={runQuickAction}>{t(\"nav.markAllRead\")}</Sidebar.MenuSubButton>\n */\nSidebar.MenuSubButton = function SidebarMenuSubButton(handle: Handle<Sidebar.MenuSubButtonProps>) {\n\treturn () => {\n\t\tlet { active, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"menu-sub-button\"\n\t\t\t\tdata-active={active || undefined}\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\t...menuSubRowMixins(),\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 `<a>` row for navigation inside {@link Sidebar.MenuSub},\n * visually identical to {@link Sidebar.MenuSubButton} and followed by its `<link\n * rel=\"prefetch\">` when `prefetch=\"render\"`. `active` sets `aria-current=\"page\"` when unset.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Sidebar.MenuSubLink href=\"/settings/profile\" active>{t(\"nav.profile\")}</Sidebar.MenuSubLink>\n */\nSidebar.MenuSubLink = function SidebarMenuSubLink(handle: Handle<Sidebar.MenuSubLinkProps>) {\n\treturn () => {\n\t\tlet { active, prefetch, \"aria-current\": ariaCurrent, mix, ...rest } = handle.props;\n\t\tlet resolvedAriaCurrent = resolveAriaCurrent(active, ariaCurrent);\n\t\tlet resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;\n\n\t\tlet anchor = (\n\t\t\t<a\n\t\t\t\tdata-rmx-prefetch={prefetchAttribute(resolvedPrefetch)}\n\t\t\t\t{...rest}\n\t\t\t\taria-current={resolvedAriaCurrent}\n\t\t\t\tdata-slot=\"menu-sub-link\"\n\t\t\t\tdata-active={active || undefined}\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\t...menuSubRowMixins(),\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 * Shared `@sdxc/u` mixins for {@link Sidebar.MenuSubButton} and\n * {@link Sidebar.MenuSubLink}.\n */\nfunction menuSubRowMixins() {\n\treturn [\n\t\tflex(),\n\t\tminBs(\"2rem\"),\n\t\tis(\"full\"),\n\t\titems(\"center\"),\n\t\ttextAlign(\"start\"),\n\t\ttextDecoration(\"none\"),\n\t\tfontSize(\"sm\"),\n\t\twhen('&[data-active], &[aria-current]:not([aria-current=\"false\"])', weight(500)),\n\t\twhen(\"&:active\", scaleProperty(0.98)),\n\t\twhen(\"&:disabled\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), opacity(50)]),\n\t\tgap(\"0.5rem\"),\n\t\trounded(\"lg\"),\n\t\tpi(\"0.625rem\"),\n\t\tpb(\"0.375rem\"),\n\t\tfg(\"neutral.muted\"),\n\t\ttransition(\n\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t),\n\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\twhen('&[data-active], &[aria-current]:not([aria-current=\"false\"])', [\n\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\tfg(\"neutral.emphasis\"),\n\t\t]),\n\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t];\n}\n\n/**\n * Renders a thin drag-styled affordance along {@link Sidebar}'s own edge,\n * toggling {@link Sidebar.Trigger}'s checkbox through a native `<label>`\n * association; marked `aria-hidden` since that checkbox is the accessible control.\n *\n * @param handle Runtime handle carrying the host `<label>`'s props.\n * @returns The render function producing the rail's markup.\n * @example\n * <Sidebar>\n * \t<Sidebar.Header>...</Sidebar.Header>\n * \t<Sidebar.Rail htmlFor=\"app-sidebar-toggle\" />\n * </Sidebar>\n */\nSidebar.Rail = function SidebarRail(handle: Handle<Sidebar.RailProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"rail\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ \"aria-hidden\": \"true\" }),\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tis(\"1rem\"),\n\t\t\t\t\t\tz(20),\n\t\t\t\t\t\thidden(),\n\t\t\t\t\t\tcursor(\"col-resize\"),\n\t\t\t\t\t\twhen('[data-side=\"left\"] &', insRight(\"-1rem\")),\n\t\t\t\t\t\twhen('[data-side=\"right\"] &', insLeft(\"-1rem\")),\n\t\t\t\t\t\tafter([\n\t\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\t\tis(\"2px\"),\n\t\t\t\t\t\t\tbg(\"transparent\"),\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\tinsIs(\"50%\"),\n\t\t\t\t\t\t\ttranslateProperty(\"-50% 0\"),\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\ttransitionProperty(\"background-color\"),\n\t\t\t\t\t\t\ttransitionDuration(\"150ms\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(WIDE_SHELL_QUERY, [flex(), items(\"center\"), justify(\"center\")]),\n\t\t\t\t\t\thover(after(bg(\"neutral.border\"))),\n\t\t\t\t\t\twhen(\"&:active\", after(bg(\"brand.ring\"))),\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 collapse toggle: a native, keyboard-reachable `<input type=\"checkbox\">`\n * in a button-styled `<label>` whose pointer target grows to `--ui-target-size`; its\n * `:checked` state drives every collapse rule in {@link Sidebar.Provider}.\n *\n * @param handle Runtime handle carrying the host checkbox's props.\n * @returns The render function producing the toggle's markup.\n * @example\n * <Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * @example\n * <Sidebar.Trigger id=\"app-sidebar-toggle\" defaultChecked aria-label={t(\"nav.toggleSidebar\")} />\n */\nSidebar.Trigger = function SidebarTrigger(handle: Handle<Sidebar.TriggerProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\tdata-slot=\"trigger\"\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:has(input:focus-visible)\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\tis(\"2rem\"),\n\t\t\t\t\tbs(\"2rem\"),\n\t\t\t\t\thitArea(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\twhen(\"& > svg\", [is(\"1rem\"), bs(\"1rem\")]),\n\t\t\t\t\twhen(\"&:has(input:disabled)\", [cursor(\"not-allowed\"), opacity(50)]),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\ttransition(\n\t\t\t\t\t\t\"color, background-color, border-color, outline-color, text-decoration-color, fill, stroke\",\n\t\t\t\t\t),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t<PanelLeftIcon />\n\t\t\t\t<input type=\"checkbox\" {...rest} data-slot=\"toggle\" mix={mergeMix(visuallyHidden(), mix)} />\n\t\t\t</label>\n\t\t);\n\t};\n};\n\n/**\n * Renders the shell's main content region: {@link ScrollArea.Viewport}\n * laid out as a growing flex column that resizes as {@link Sidebar}\n * collapses or expands, declaring {@link INSET_CONTAINER_NAME} for nested sizing.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the inset's markup.\n * @example\n * <Sidebar.Inset>\n * \t<Sidebar.Trigger id=\"app-sidebar-toggle\" aria-label={t(\"nav.toggleSidebar\")} />\n * \t<main>{children}</main>\n * </Sidebar.Inset>\n */\nSidebar.Inset = function SidebarInset(handle: Handle<Sidebar.InsetProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ScrollArea.Viewport\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"inset\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\tflexCol(),\n\t\t\t\t\t\tgrow(),\n\t\t\t\t\t\tminIs(\"0\"),\n\t\t\t\t\t\tminBs(\"0\"),\n\t\t\t\t\t\tbs(\"auto\"),\n\t\t\t\t\t\tcontainer(INSET_CONTAINER_NAME),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\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 hairline divider between two stretches of rail content:\n * identical to {@link Separator}, with the small block-axis and inline-axis\n * margins {@link Sidebar}'s own content regions expect around one.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the divider's markup.\n * @example\n * <Sidebar.Group>...</Sidebar.Group>\n * <Sidebar.Separator />\n * <Sidebar.Group>...</Sidebar.Group>\n */\nSidebar.Separator = function SidebarSeparator(handle: Handle<Sidebar.SeparatorProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <Separator {...rest} data-slot=\"separator\" mix={mergeMix(m(\"0.5rem\"), mix)} />;\n\t};\n};\n"
|
|
15
15
|
},
|
|
16
16
|
"test": {
|
|
17
17
|
"path": "sidebar.test.tsx",
|
package/registry/ui/slider.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slider",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Slider"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "slider.tsx",
|
|
10
|
-
"content": "/**\n * A single-value range control built on a native `<input type=\"range\">`,\n * paired with a track that draws its own background rail and a live fill\n * bar, plus an `<output>` for reporting the current value. The root shares\n * the resolved range and value with every part through component context,\n * so a track's fill bar and a thumb's native attributes always agree\n * without a consumer repeating the same numbers twice.\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 {\n\tabsolute,\n\tafter,\n\tappearance,\n\tbasis,\n\tbefore,\n\tbg,\n\tborder,\n\tbs,\n\tcursor,\n\tgrow,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinset,\n\tis,\n\titems,\n\tm,\n\tminBs,\n\tminIs,\n\toutlineStyle,\n\tpseudoContent,\n\traw,\n\trelative,\n\trounded,\n\tshrink,\n\ttabularNums,\n\ttranslateX,\n\ttranslateY,\n\tvstack,\n\twhen,\n\tz,\n} from \"@sdxc/u\";\n\nimport { outputCaptionText } from \"@sdxc/ui/styles\";\nimport { rangeThumbAppearance } from \"@sdxc/ui/styles\";\nimport { mergeStyle } from \"@sdxc/ui/utils\";\nimport { resolveFillPercent } from \"@sdxc/ui/utils\";\n\n/** Default {@link Slider.Props} orientation, applied when `orientation` is omitted. */\nconst DEFAULT_ORIENTATION: Slider.Orientation = \"horizontal\";\n\n/** Default {@link Slider.Props} lower bound, applied when `min` is omitted. */\nconst DEFAULT_MIN = 0;\n\n/** Default {@link Slider.Props} upper bound, applied when `max` is omitted. */\nconst DEFAULT_MAX = 100;\n\n/** Default {@link Slider.ThumbProps} step, applied when `step` is omitted. */\nconst DEFAULT_STEP = 1;\n\n/**\n * Negative inset growing {@link Slider.Thumb}'s native input across the track's thin\n * axis to the larger of the thumb and `--ui-target-size`, clamped at zero so a track\n * already that thick keeps its own box.\n */\nconst THUMB_HIT_INSET =\n\t\"min(0px, calc((100% - max(var(--ui-slider-thumb-size, 1.25rem), var(--ui-target-size, 1.5rem))) / 2))\";\n\n/**\n * Prop types for {@link Slider} and its compound parts.\n */\nexport namespace Slider {\n\t/**\n\t * Axis the track's fill bar and thumb travel along: a full-width row, or\n\t * a full-height column.\n\t */\n\texport type Orientation = \"horizontal\" | \"vertical\";\n\n\t/**\n\t * Value {@link Slider} shares through component context so every nested\n\t * {@link Slider.Track}, {@link Slider.Thumb}, and {@link Slider.Output}\n\t * reads the same resolved range, value, orientation, and thumb id.\n\t */\n\texport interface Context {\n\t\t/** Resolved lower bound of the range, shared with {@link Slider.Thumb}. */\n\t\tmin: number;\n\t\t/** Resolved upper bound of the range, shared with {@link Slider.Thumb}. */\n\t\tmax: number;\n\t\t/** Resolved current value, used to compute {@link Slider.Track}'s fill bar and default {@link Slider.Thumb}'s own value. */\n\t\tvalue: number;\n\t\t/** Layout axis, read by {@link Slider.Thumb} to set its accessible orientation. */\n\t\torientation: Orientation;\n\t\t/**\n\t\t * Id shared by {@link Slider.Thumb} (as its own `id`) and\n\t\t * {@link Slider.Output} (as its `htmlFor`) so the two associate\n\t\t * natively without either needing an explicit id from the consumer.\n\t\t */\n\t\tthumbId: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link Slider}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t\t/** Lower bound of the range. Defaults to {@link DEFAULT_MIN}. */\n\t\tmin?: number;\n\t\t/** Upper bound of the range. Defaults to {@link DEFAULT_MAX}. */\n\t\tmax?: number;\n\t\t/** Current value, for a slider whose value the consumer tracks itself. */\n\t\tvalue?: number;\n\t\t/** Starting value, for a slider that never tracks its own value. */\n\t\tdefaultValue?: number;\n\t}\n\n\t/**\n\t * Props accepted by {@link Slider.Track}.\n\t */\n\texport interface TrackProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<input>` attribute except `type` and `role`, fixed to\n\t * `\"range\"` and the platform's implicit `\"slider\"` role. `min`/`max`/`step`\n\t * override the range inherited from the nearest ancestor {@link Slider}.\n\t */\n\texport interface ThumbProps extends Omit<TagProps<\"input\">, \"type\" | \"role\"> {}\n\n\t/**\n\t * Props accepted by {@link Slider.Output}.\n\t */\n\texport interface OutputProps extends TagProps<\"output\"> {}\n}\n\n/**\n * Renders the root `<div>`, stacking its children and resolving range, value, orientation\n * and thumb id into context. Nested parts scope orientation rules to its `data-slot`, so an\n * ancestor carrying `data-orientation` (a toolbar, a scroll viewport) leaves its layout alone.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props and providing {@link Slider.Context}.\n * @returns The render function producing the root's markup.\n * @example\n * <Slider aria-label={t(\"settings.volume\")} min={0} max={100} defaultValue={40}>\n * \t<Slider.Output />\n * \t<Slider.Track>\n * \t\t<Slider.Thumb />\n * \t</Slider.Track>\n * </Slider>\n * @example\n * <Slider orientation=\"vertical\" min={0} max={10} defaultValue={6}>\n * \t<Slider.Track>\n * \t\t<Slider.Thumb aria-label={t(\"equalizer.band\", { hz: 250 })} />\n * \t</Slider.Track>\n * </Slider>\n */\nexport function Slider(handle: Handle<Slider.Props, Slider.Context>) {\n\treturn () => {\n\t\tlet { orientation, min, max, value, defaultValue, mix, ...rest } = handle.props;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\t\tlet resolvedMin = min ?? DEFAULT_MIN;\n\t\tlet resolvedMax = max ?? DEFAULT_MAX;\n\t\tlet resolvedValue = value ?? defaultValue ?? resolvedMin;\n\n\t\thandle.context.set({\n\t\t\tmin: resolvedMin,\n\t\t\tmax: resolvedMax,\n\t\t\tvalue: resolvedValue,\n\t\t\torientation: resolvedOrientation,\n\t\t\tthumbId: handle.id,\n\t\t});\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"slider\"\n\t\t\t\tdata-orientation={resolvedOrientation}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tvstack({ gap: \"0.5rem\" }),\n\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', [is(\"100%\"), minIs(\"10rem\")]),\n\t\t\t\t\twhen('&[data-orientation=\"vertical\"]', [bs(\"10rem\"), items(\"center\")]),\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 visual track: a `position: relative` `<div>` that draws a rail\n * and fill bar as pseudo-elements sized from context's resolved value, and\n * overlays a nested {@link Slider.Thumb} so native drag spans its full length.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the track's markup.\n * @example\n * <Slider.Track>\n * \t<Slider.Thumb />\n * </Slider.Track>\n */\nSlider.Track = function SliderTrack(handle: Handle<Slider.TrackProps>) {\n\treturn () => {\n\t\tlet { mix, style, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Slider);\n\t\tlet fillPercent = resolveFillPercent(context.min, context.max, context.value);\n\t\tlet resolvedStyle = mergeStyle(style, { \"--ui-slider-fill\": `${fillPercent}%` });\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tstyle={resolvedStyle}\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\twhen('[data-orientation=\"horizontal\"] &', [\n\t\t\t\t\t\tis(\"100%\"),\n\t\t\t\t\t\tbs(\"var(--ui-slider-thumb-size, 1.25rem)\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &', [\n\t\t\t\t\t\tis(\"var(--ui-slider-thumb-size, 1.25rem)\"),\n\t\t\t\t\t\tminBs(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\tbefore([absolute(), rounded(\"full\"), bg(\"neutral.border\"), pseudoContent('\"\"')]),\n\t\t\t\t\tafter([absolute(), rounded(\"full\"), bg(\"brand.solid\"), pseudoContent('\"\"')]),\n\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &', [\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]),\n\t\t\t\t\twhen('[data-orientation=\"horizontal\"] &::before', [\n\t\t\t\t\t\tbs(\"var(--ui-slider-track-thickness, 0.5rem)\"),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t\tinsBs(\"50%\"),\n\t\t\t\t\t\ttranslateY(\"-50%\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('[data-orientation=\"horizontal\"] &::after', [\n\t\t\t\t\t\tbs(\"var(--ui-slider-track-thickness, 0.5rem)\"),\n\t\t\t\t\t\tis(\"var(--ui-slider-fill, 0%)\"),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsBs(\"50%\"),\n\t\t\t\t\t\ttranslateY(\"-50%\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &::before', [\n\t\t\t\t\t\tis(\"var(--ui-slider-track-thickness, 0.5rem)\"),\n\t\t\t\t\t\tbs(\"100%\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsIs(\"50%\"),\n\t\t\t\t\t\ttranslateX(\"-50%\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &::after', [\n\t\t\t\t\t\tis(\"var(--ui-slider-track-thickness, 0.5rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-slider-fill, 0%)\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\tinsIs(\"50%\"),\n\t\t\t\t\t\ttranslateX(\"-50%\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the interactive thumb: a native `<input type=\"range\">` reset to\n * cover {@link Slider.Track}'s full box so native drag and keyboard control\n * span its whole length, rotating with `writing-mode` when vertical.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the thumb's markup.\n * @example\n * <Slider.Thumb aria-label={t(\"settings.volume\")} />\n * @example\n * <Slider.Thumb aria-label={t(\"settings.brightness\")} disabled />\n */\nSlider.Thumb = function SliderThumb(handle: Handle<Slider.ThumbProps>) {\n\treturn () => {\n\t\tlet { id, min, max, step, value, defaultValue, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Slider);\n\t\tlet resolvedStep = step ?? DEFAULT_STEP;\n\t\tlet resolvedValue = value ?? defaultValue ?? context.value;\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"range\"\n\t\t\t\tid={id ?? context.thumbId}\n\t\t\t\tmin={min ?? context.min}\n\t\t\t\tmax={max ?? context.max}\n\t\t\t\tstep={resolvedStep}\n\t\t\t\tdefaultValue={resolvedValue}\n\t\t\t\taria-orientation={context.orientation === \"vertical\" ? \"vertical\" : undefined}\n\t\t\t\tmix={[\n\t\t\t\t\trangeThumbAppearance(\"--ui-slider-thumb-size\", \"--ui-slider-thumb-border-width\"),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tinset(\"0\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * The native input reaches past the track across its thin axis to a full pointer\n\t\t\t\t\t * target, centred so the thumb stays on the visible rail. Its block axis is that\n\t\t\t\t\t * thin axis in both orientations, since a vertical input runs `vertical-lr`.\n\t\t\t\t\t */\n\t\t\t\t\tinsBs(THUMB_HIT_INSET),\n\t\t\t\t\tinsBe(THUMB_HIT_INSET),\n\t\t\t\t\tz(10),\n\t\t\t\t\tm(\"0\"),\n\t\t\t\t\tappearance(),\n\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\twhen(\"&:disabled\", cursor(\"not-allowed\")),\n\t\t\t\t\toutlineStyle(\"none\"),\n\t\t\t\t\twhen(\"&::-webkit-slider-runnable-track\", [appearance(), bs(\"100%\"), bg(\"transparent\")]),\n\t\t\t\t\twhen(\"&::-moz-range-track\", [\n\t\t\t\t\t\tappearance(),\n\t\t\t\t\t\tbs(\"100%\"),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tborder({ style: \"none\" }),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t'[data-slot=\"slider\"][data-orientation=\"vertical\"] &',\n\t\t\t\t\t\traw({ writingMode: \"vertical-lr\", direction: \"rtl\" }),\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 live readout: a native `<output>` associated by default with\n * the nearest ancestor {@link Slider}'s thumb via `htmlFor`, so assistive\n * technology knows which control it reports on. Pass the value as `children`.\n *\n * @param handle Runtime handle carrying the host `<output>`'s props.\n * @returns The render function producing the readout's markup.\n * @example\n * <Slider.Output>{new Intl.NumberFormat(locale, { style: \"percent\" }).format(0.4)}</Slider.Output>\n */\nSlider.Output = function SliderOutput(handle: Handle<Slider.OutputProps>) {\n\treturn () => {\n\t\tlet { htmlFor, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Slider);\n\n\t\treturn (\n\t\t\t<output\n\t\t\t\t{...rest}\n\t\t\t\thtmlFor={htmlFor ?? context.thumbId}\n\t\t\t\tmix={[outputCaptionText(), tabularNums(), mix]}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
10
|
+
"content": "/**\n * A single-value range control built on a native `<input type=\"range\">`,\n * paired with a track that draws its own background rail and a live fill\n * bar, plus an `<output>` for reporting the current value. The root shares\n * the resolved range and value with every part through component context,\n * so a track's fill bar and a thumb's native attributes always agree\n * without a consumer repeating the same numbers twice.\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 {\n\tabsolute,\n\tafter,\n\tappearance,\n\tbasis,\n\tbefore,\n\tbg,\n\tborder,\n\tbs,\n\tcursor,\n\tgrow,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\tinset,\n\tis,\n\titems,\n\tm,\n\tminBs,\n\tminIs,\n\toutlineStyle,\n\tpseudoContent,\n\traw,\n\trelative,\n\trounded,\n\tshrink,\n\ttabularNums,\n\ttranslateX,\n\ttranslateY,\n\tvstack,\n\twhen,\n\tz,\n} from \"@sdxc/u\";\nimport { mergeMix } from \"@sdxc/u/general\";\n\nimport { outputCaptionText } from \"@sdxc/ui/styles\";\nimport { rangeThumbAppearance } from \"@sdxc/ui/styles\";\nimport { mergeStyle } from \"@sdxc/ui/utils\";\nimport { resolveFillPercent } from \"@sdxc/ui/utils\";\n\n/** Default {@link Slider.Props} orientation, applied when `orientation` is omitted. */\nconst DEFAULT_ORIENTATION: Slider.Orientation = \"horizontal\";\n\n/** Default {@link Slider.Props} lower bound, applied when `min` is omitted. */\nconst DEFAULT_MIN = 0;\n\n/** Default {@link Slider.Props} upper bound, applied when `max` is omitted. */\nconst DEFAULT_MAX = 100;\n\n/** Default {@link Slider.ThumbProps} step, applied when `step` is omitted. */\nconst DEFAULT_STEP = 1;\n\n/**\n * Negative inset growing {@link Slider.Thumb}'s native input across the track's thin\n * axis to the larger of the thumb and `--ui-target-size`, clamped at zero so a track\n * already that thick keeps its own box.\n */\nconst THUMB_HIT_INSET =\n\t\"min(0px, calc((100% - max(var(--ui-slider-thumb-size, 1.25rem), var(--ui-target-size, 1.5rem))) / 2))\";\n\n/**\n * Prop types for {@link Slider} and its compound parts.\n */\nexport namespace Slider {\n\t/**\n\t * Axis the track's fill bar and thumb travel along: a full-width row, or\n\t * a full-height column.\n\t */\n\texport type Orientation = \"horizontal\" | \"vertical\";\n\n\t/**\n\t * Value {@link Slider} shares through component context so every nested\n\t * {@link Slider.Track}, {@link Slider.Thumb}, and {@link Slider.Output}\n\t * reads the same resolved range, value, orientation, and thumb id.\n\t */\n\texport interface Context {\n\t\t/** Resolved lower bound of the range, shared with {@link Slider.Thumb}. */\n\t\tmin: number;\n\t\t/** Resolved upper bound of the range, shared with {@link Slider.Thumb}. */\n\t\tmax: number;\n\t\t/** Resolved current value, used to compute {@link Slider.Track}'s fill bar and default {@link Slider.Thumb}'s own value. */\n\t\tvalue: number;\n\t\t/** Layout axis, read by {@link Slider.Thumb} to set its accessible orientation. */\n\t\torientation: Orientation;\n\t\t/**\n\t\t * Id shared by {@link Slider.Thumb} (as its own `id`) and\n\t\t * {@link Slider.Output} (as its `htmlFor`) so the two associate\n\t\t * natively without either needing an explicit id from the consumer.\n\t\t */\n\t\tthumbId: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link Slider}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */\n\t\torientation?: Orientation;\n\t\t/** Lower bound of the range. Defaults to {@link DEFAULT_MIN}. */\n\t\tmin?: number;\n\t\t/** Upper bound of the range. Defaults to {@link DEFAULT_MAX}. */\n\t\tmax?: number;\n\t\t/** Current value, for a slider whose value the consumer tracks itself. */\n\t\tvalue?: number;\n\t\t/** Starting value, for a slider that never tracks its own value. */\n\t\tdefaultValue?: number;\n\t}\n\n\t/**\n\t * Props accepted by {@link Slider.Track}.\n\t */\n\texport interface TrackProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<input>` attribute except `type` and `role`, fixed to\n\t * `\"range\"` and the platform's implicit `\"slider\"` role. `min`/`max`/`step`\n\t * override the range inherited from the nearest ancestor {@link Slider}.\n\t */\n\texport interface ThumbProps extends Omit<TagProps<\"input\">, \"type\" | \"role\"> {}\n\n\t/**\n\t * Props accepted by {@link Slider.Output}.\n\t */\n\texport interface OutputProps extends TagProps<\"output\"> {}\n}\n\n/**\n * Renders the root `<div>`, stacking its children and resolving range, value, orientation\n * and thumb id into context. Nested parts scope orientation rules to its `data-slot`, so an\n * ancestor carrying `data-orientation` (a toolbar, a scroll viewport) leaves its layout alone.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props and providing {@link Slider.Context}.\n * @returns The render function producing the root's markup.\n * @example\n * <Slider aria-label={t(\"settings.volume\")} min={0} max={100} defaultValue={40}>\n * \t<Slider.Output />\n * \t<Slider.Track>\n * \t\t<Slider.Thumb />\n * \t</Slider.Track>\n * </Slider>\n * @example\n * <Slider orientation=\"vertical\" min={0} max={10} defaultValue={6}>\n * \t<Slider.Track>\n * \t\t<Slider.Thumb aria-label={t(\"equalizer.band\", { hz: 250 })} />\n * \t</Slider.Track>\n * </Slider>\n */\nexport function Slider(handle: Handle<Slider.Props, Slider.Context>) {\n\treturn () => {\n\t\tlet { orientation, min, max, value, defaultValue, mix, ...rest } = handle.props;\n\t\tlet resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;\n\t\tlet resolvedMin = min ?? DEFAULT_MIN;\n\t\tlet resolvedMax = max ?? DEFAULT_MAX;\n\t\tlet resolvedValue = value ?? defaultValue ?? resolvedMin;\n\n\t\thandle.context.set({\n\t\t\tmin: resolvedMin,\n\t\t\tmax: resolvedMax,\n\t\t\tvalue: resolvedValue,\n\t\t\torientation: resolvedOrientation,\n\t\t\tthumbId: handle.id,\n\t\t});\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"slider\"\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\tvstack({ gap: \"0.5rem\" }),\n\t\t\t\t\t\twhen('&[data-orientation=\"horizontal\"]', [is(\"100%\"), minIs(\"10rem\")]),\n\t\t\t\t\t\twhen('&[data-orientation=\"vertical\"]', [bs(\"10rem\"), items(\"center\")]),\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 visual track: a `position: relative` `<div>` that draws a rail\n * and fill bar as pseudo-elements sized from context's resolved value, and\n * overlays a nested {@link Slider.Thumb} so native drag spans its full length.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the track's markup.\n * @example\n * <Slider.Track>\n * \t<Slider.Thumb />\n * </Slider.Track>\n */\nSlider.Track = function SliderTrack(handle: Handle<Slider.TrackProps>) {\n\treturn () => {\n\t\tlet { mix, style, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Slider);\n\t\tlet fillPercent = resolveFillPercent(context.min, context.max, context.value);\n\t\tlet resolvedStyle = mergeStyle(style, { \"--ui-slider-fill\": `${fillPercent}%` });\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tstyle={resolvedStyle}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\twhen('[data-orientation=\"horizontal\"] &', [\n\t\t\t\t\t\t\tis(\"100%\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-slider-thumb-size, 1.25rem)\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &', [\n\t\t\t\t\t\t\tis(\"var(--ui-slider-thumb-size, 1.25rem)\"),\n\t\t\t\t\t\t\tminBs(\"0\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tbefore([absolute(), rounded(\"full\"), bg(\"neutral.border\"), pseudoContent('\"\"')]),\n\t\t\t\t\t\tafter([absolute(), rounded(\"full\"), bg(\"brand.solid\"), pseudoContent('\"\"')]),\n\t\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &', [\n\t\t\t\t\t\t\tgrow(),\n\t\t\t\t\t\t\tshrink(1),\n\t\t\t\t\t\t\tbasis(\"0%\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('[data-orientation=\"horizontal\"] &::before', [\n\t\t\t\t\t\t\tbs(\"var(--ui-slider-track-thickness, 0.5rem)\"),\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\tinsBs(\"50%\"),\n\t\t\t\t\t\t\ttranslateY(\"-50%\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('[data-orientation=\"horizontal\"] &::after', [\n\t\t\t\t\t\t\tbs(\"var(--ui-slider-track-thickness, 0.5rem)\"),\n\t\t\t\t\t\t\tis(\"var(--ui-slider-fill, 0%)\"),\n\t\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\t\tinsBs(\"50%\"),\n\t\t\t\t\t\t\ttranslateY(\"-50%\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &::before', [\n\t\t\t\t\t\t\tis(\"var(--ui-slider-track-thickness, 0.5rem)\"),\n\t\t\t\t\t\t\tbs(\"100%\"),\n\t\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\t\tinsIs(\"50%\"),\n\t\t\t\t\t\t\ttranslateX(\"-50%\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('[data-slot=\"slider\"][data-orientation=\"vertical\"] &::after', [\n\t\t\t\t\t\t\tis(\"var(--ui-slider-track-thickness, 0.5rem)\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-slider-fill, 0%)\"),\n\t\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t\t\tinsIs(\"50%\"),\n\t\t\t\t\t\t\ttranslateX(\"-50%\"),\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 interactive thumb: a native `<input type=\"range\">` reset to\n * cover {@link Slider.Track}'s full box so native drag and keyboard control\n * span its whole length, rotating with `writing-mode` when vertical.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the thumb's markup.\n * @example\n * <Slider.Thumb aria-label={t(\"settings.volume\")} />\n * @example\n * <Slider.Thumb aria-label={t(\"settings.brightness\")} disabled />\n */\nSlider.Thumb = function SliderThumb(handle: Handle<Slider.ThumbProps>) {\n\treturn () => {\n\t\tlet { id, min, max, step, value, defaultValue, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Slider);\n\t\tlet resolvedStep = step ?? DEFAULT_STEP;\n\t\tlet resolvedValue = value ?? defaultValue ?? context.value;\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"range\"\n\t\t\t\tid={id ?? context.thumbId}\n\t\t\t\tmin={min ?? context.min}\n\t\t\t\tmax={max ?? context.max}\n\t\t\t\tstep={resolvedStep}\n\t\t\t\tdefaultValue={resolvedValue}\n\t\t\t\taria-orientation={context.orientation === \"vertical\" ? \"vertical\" : undefined}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trangeThumbAppearance(\"--ui-slider-thumb-size\", \"--ui-slider-thumb-border-width\"),\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\tinset(\"0\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The native input reaches past the track across its thin axis to a full pointer\n\t\t\t\t\t\t * target, centred so the thumb stays on the visible rail. Its block axis is that\n\t\t\t\t\t\t * thin axis in both orientations, since a vertical input runs `vertical-lr`.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tinsBs(THUMB_HIT_INSET),\n\t\t\t\t\t\tinsBe(THUMB_HIT_INSET),\n\t\t\t\t\t\tz(10),\n\t\t\t\t\t\tm(\"0\"),\n\t\t\t\t\t\tappearance(),\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\twhen(\"&:disabled\", cursor(\"not-allowed\")),\n\t\t\t\t\t\toutlineStyle(\"none\"),\n\t\t\t\t\t\twhen(\"&::-webkit-slider-runnable-track\", [appearance(), bs(\"100%\"), bg(\"transparent\")]),\n\t\t\t\t\t\twhen(\"&::-moz-range-track\", [\n\t\t\t\t\t\t\tappearance(),\n\t\t\t\t\t\t\tbs(\"100%\"),\n\t\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\t\tborder({ style: \"none\" }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t'[data-slot=\"slider\"][data-orientation=\"vertical\"] &',\n\t\t\t\t\t\t\traw({ writingMode: \"vertical-lr\", direction: \"rtl\" }),\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 a live readout: a native `<output>` associated by default with\n * the nearest ancestor {@link Slider}'s thumb via `htmlFor`, so assistive\n * technology knows which control it reports on. Pass the value as `children`.\n *\n * @param handle Runtime handle carrying the host `<output>`'s props.\n * @returns The render function producing the readout's markup.\n * @example\n * <Slider.Output>{new Intl.NumberFormat(locale, { style: \"percent\" }).format(0.4)}</Slider.Output>\n */\nSlider.Output = function SliderOutput(handle: Handle<Slider.OutputProps>) {\n\treturn () => {\n\t\tlet { htmlFor, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Slider);\n\n\t\treturn (\n\t\t\t<output\n\t\t\t\t{...rest}\n\t\t\t\thtmlFor={htmlFor ?? context.thumbId}\n\t\t\t\tmix={mergeMix([outputCaptionText(), tabularNums()], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
11
11
|
},
|
|
12
12
|
"test": {
|
|
13
13
|
"path": "slider.test.tsx",
|
package/registry/ui/spinner.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spinner",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Spinner"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "spinner.tsx",
|
|
10
|
-
"content": "/**\n * A busy indicator rendered as a rotating icon inside a `role=\"progressbar\"`\n * host, colored by a semantic color role and sized by a size variant. Its own\n * styling holds still — compose the `spin()` factory from the animation\n * layer through `mix` for the rotating loop, so a page can render the\n * indicator's shape before any motion-driving CSS lands.\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 { LoaderCircleIcon } from \"@sdxc/icons\";\nimport { bs, fg, inlineFlex, is, items, justify, when } from \"@sdxc/u\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\n/** Semantic color role {@link Spinner} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Spinner.Color = \"neutral\";\n\n/** Size variant {@link Spinner} falls back to when `size` is omitted. */\nconst DEFAULT_SIZE: Spinner.Size = \"md\";\n\n/**\n * Prop types for {@link Spinner}.\n */\nexport namespace Spinner {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*-fg` variable.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Size variant controlling the rotating icon's rendered dimensions.\n\t */\n\texport type Size = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Props accepted by {@link Spinner}.\n\t */\n\texport interface Props extends Omit<TagProps<\"div\">, \"aria-label\"> {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Size variant. Defaults to {@link DEFAULT_SIZE}. */\n\t\tsize?: Size;\n\t\t/**\n\t\t * Accessible label announced by assistive technology for as long as\n\t\t * the spinner is on screen. Required — the component ships no\n\t\t * built-in copy, so a consumer's own localized string drives it.\n\t\t */\n\t\t\"aria-label\": string;\n\t}\n}\n\n/**\n * Renders a busy indicator: a `role=\"progressbar\"` host with no\n * `aria-valuenow`, so assistive technology reads it as indeterminate. Pair\n * it with the `spin()` mixin from the animation layer for the rotating loop.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the indicator's markup.\n * @example\n * <Spinner aria-label={t(\"status.loading\")} />\n * @example\n * <Spinner color=\"danger\" size=\"lg\" aria-label={t(\"status.retrying\")} />\n * @example\n * <Spinner mix={[spin()]} aria-label={t(\"status.loading\")} />\n */\nexport function Spinner(handle: Handle<Spinner.Props>) {\n\treturn () => {\n\t\tlet { mix, color, size, \"aria-label\": ariaLabel, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedSize = size ?? DEFAULT_SIZE;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\trole=\"progressbar\"\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\n\t\t\t\t\twhen('&[data-color=\"brand\"]', fg(\"brand\")),\n\t\t\t\t\twhen('&[data-color=\"neutral\"]', fg(\"neutral\")),\n\t\t\t\t\twhen('&[data-color=\"success\"]', fg(\"success\")),\n\t\t\t\t\twhen('&[data-color=\"warning\"]', fg(\"warning\")),\n\t\t\t\t\twhen('&[data-color=\"danger\"]', fg(\"danger\")),\n\n\t\t\t\t\twhen(\"& svg\", [\n\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-size=\"sm\"] svg', [\n\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-size=\"lg\"] svg', [\n\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-lg, 1.75rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-lg, 1.75rem)\"),\n\t\t\t\t\t]),\n\t\t\t\t\tmix,\n\t\t\t\t
|
|
10
|
+
"content": "/**\n * A busy indicator rendered as a rotating icon inside a `role=\"progressbar\"`\n * host, colored by a semantic color role and sized by a size variant. Its own\n * styling holds still — compose the `spin()` factory from the animation\n * layer through `mix` for the rotating loop, so a page can render the\n * indicator's shape before any motion-driving CSS lands.\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 { LoaderCircleIcon } from \"@sdxc/icons\";\nimport { bs, fg, inlineFlex, is, items, justify, when } from \"@sdxc/u\";\nimport { mergeMix } from \"@sdxc/u/general\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\n/** Semantic color role {@link Spinner} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Spinner.Color = \"neutral\";\n\n/** Size variant {@link Spinner} falls back to when `size` is omitted. */\nconst DEFAULT_SIZE: Spinner.Size = \"md\";\n\n/**\n * Prop types for {@link Spinner}.\n */\nexport namespace Spinner {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*-fg` variable.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Size variant controlling the rotating icon's rendered dimensions.\n\t */\n\texport type Size = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Props accepted by {@link Spinner}.\n\t */\n\texport interface Props extends Omit<TagProps<\"div\">, \"aria-label\"> {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Size variant. Defaults to {@link DEFAULT_SIZE}. */\n\t\tsize?: Size;\n\t\t/**\n\t\t * Accessible label announced by assistive technology for as long as\n\t\t * the spinner is on screen. Required — the component ships no\n\t\t * built-in copy, so a consumer's own localized string drives it.\n\t\t */\n\t\t\"aria-label\": string;\n\t}\n}\n\n/**\n * Renders a busy indicator: a `role=\"progressbar\"` host with no\n * `aria-valuenow`, so assistive technology reads it as indeterminate. Pair\n * it with the `spin()` mixin from the animation layer for the rotating loop.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the indicator's markup.\n * @example\n * <Spinner aria-label={t(\"status.loading\")} />\n * @example\n * <Spinner color=\"danger\" size=\"lg\" aria-label={t(\"status.retrying\")} />\n * @example\n * <Spinner mix={[spin()]} aria-label={t(\"status.loading\")} />\n */\nexport function Spinner(handle: Handle<Spinner.Props>) {\n\treturn () => {\n\t\tlet { mix, color, size, \"aria-label\": ariaLabel, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedSize = size ?? DEFAULT_SIZE;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\trole=\"progressbar\"\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\tdata-color={resolvedColor}\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\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\n\t\t\t\t\t\twhen('&[data-color=\"brand\"]', fg(\"brand\")),\n\t\t\t\t\t\twhen('&[data-color=\"neutral\"]', fg(\"neutral\")),\n\t\t\t\t\t\twhen('&[data-color=\"success\"]', fg(\"success\")),\n\t\t\t\t\t\twhen('&[data-color=\"warning\"]', fg(\"warning\")),\n\t\t\t\t\t\twhen('&[data-color=\"danger\"]', fg(\"danger\")),\n\n\t\t\t\t\t\twhen(\"& svg\", [\n\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-md, 1.25rem)\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"sm\"] svg', [\n\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-sm, 1rem)\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen('&[data-size=\"lg\"] svg', [\n\t\t\t\t\t\t\tis(\"var(--ui-spinner-icon-size-lg, 1.75rem)\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-spinner-icon-size-lg, 1.75rem)\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<LoaderCircleIcon />\n\t\t\t</div>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
12
|
"test": null
|
|
13
13
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "status-dot",
|
|
3
|
+
"changedIn": "2026.11.3",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"StatusDot"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "status-dot.tsx",
|
|
10
|
+
"content": "/**\n * A small coloured dot that names a record's state beside its label, plus a dot cluster that\n * summarises a set of states as `n/N`. The tone comes from a semantic role, and only an\n * in-progress state pulses, so a list polled every few seconds stays still between changes.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { animationHost, keyframes } from \"@sdxc/u/animation\";\nimport { bg, fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { mergeMix, raw } from \"@sdxc/u/general\";\nimport { inlineFlex, items, relative, shrink } from \"@sdxc/u/layout\";\nimport { motionSafe } from \"@sdxc/u/responsive\";\nimport { bs, is } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { fontSize, nowrap, tabularNums } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\n/** Semantic role a dot takes when `color` is omitted: a state the page cannot name yet. */\nconst DEFAULT_COLOR: StatusDot.Color = \"neutral\";\n\n/** Dot diameter, overridable through `--ui-status-dot-size`. */\nconst DOT_SIZE = \"var(--ui-status-dot-size, 0.5rem)\";\n\n/**\n * Prop types for {@link StatusDot} and its compound parts.\n */\nexport namespace StatusDot {\n\t/**\n\t * The role a state reads in: up or ok is `success`, degraded or pending is `warning`, down\n\t * or failed is `danger`, paused or unknown is `neutral`, in progress is `brand`.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Every native `<span>` attribute plus the dot's tone. Children are the visible label; a dot\n\t * without one needs `aria-label` naming the state.\n\t */\n\texport interface Props extends TagProps<\"span\"> {\n\t\t/** Semantic role of the state. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/**\n\t\t * Marks a state still in progress (queued, deploying, checking): the dot pulses until the\n\t\t * state settles, and holds still for visitors who prefer reduced motion.\n\t\t */\n\t\tpulse?: boolean;\n\t\t/** The state's name, such as \"Up\" or \"Deploying\". */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<span>` attribute plus the states to draw and the count they summarise.\n\t */\n\texport interface SummaryProps extends TagProps<\"span\"> {\n\t\t/** One dot per chosen state, drawn overlapping in this order; an empty list shows `n/N` alone. */\n\t\tcolors?: Color[];\n\t\t/** How many states are chosen, the `n` of `n/N`. */\n\t\tcount: number;\n\t\t/** How many states exist, the `N` of `n/N`. */\n\t\ttotal: number;\n\t\t/** What the summary announces in full, such as \"4 of 5 statuses shown\". */\n\t\tlabel: string;\n\t}\n}\n\n/**\n * Renders a dot and its label. With a label the dot is `aria-hidden`, since the text already\n * names the state; without one the host becomes `role=\"img\"` and its `aria-label` is the name.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the dot's markup.\n * @example <StatusDot color=\"success\">{t(\"monitor.up\")}</StatusDot>\n * @example <StatusDot color=\"brand\" pulse>{t(\"deploy.building\")}</StatusDot>\n * @example <StatusDot color=\"danger\" aria-label={t(\"monitor.down\")} />\n */\nexport function StatusDot(handle: Handle<StatusDot.Props>) {\n\treturn () => {\n\t\tlet { color, pulse, children, mix, ...rest } = handle.props;\n\t\tlet labelled = children !== undefined && children !== null && children !== false;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\trole={labelled ? undefined : \"img\"}\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"status-dot\"\n\t\t\t\tdata-color={color ?? DEFAULT_COLOR}\n\t\t\t\tdata-pulse={pulse ? \"\" : undefined}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[inlineFlex(), items(\"center\"), raw({ gap: \"0.5em\" }), fontSize(\"sm\"), nowrap()],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<Dot pulse={pulse} />\n\t\t\t\t{labelled ? <span data-slot=\"status-dot-label\">{children}</span> : null}\n\t\t\t</span>\n\t\t);\n\t};\n}\n\n/**\n * Props for {@link Dot}, the one circle every status part draws.\n */\ninterface DotProps {\n\t/** Whether the circle pulses while its state is in progress. */\n\tpulse?: boolean;\n\t/** Overlap offset for a dot inside a cluster. */\n\toverlap?: boolean;\n\t/** Tone when the dot stands outside a coloured host. */\n\tcolor?: StatusDot.Color;\n}\n\n/**\n * Draws one `aria-hidden` circle coloured by the nearest `data-color`, its own or its host's.\n * The pulse is a ring that grows and fades from the dot, so the dot itself keeps its colour\n * steady for anyone reading it.\n *\n * @param handle Runtime handle carrying the dot's tone and motion.\n * @returns The render function producing the circle.\n */\nfunction Dot(handle: Handle<DotProps>) {\n\treturn () => {\n\t\tlet { pulse, overlap, color } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tdata-slot=\"status-dot-dot\"\n\t\t\t\tdata-color={color}\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tshrink(0),\n\t\t\t\t\tis(DOT_SIZE),\n\t\t\t\t\tbs(DOT_SIZE),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tbg(\"neutral.strong\"),\n\t\t\t\t\twhen(':is([data-color=\"success\"] > &, &[data-color=\"success\"])', bg(\"success.solid\")),\n\t\t\t\t\twhen(':is([data-color=\"warning\"] > &, &[data-color=\"warning\"])', bg(\"warning.solid\")),\n\t\t\t\t\twhen(':is([data-color=\"danger\"] > &, &[data-color=\"danger\"])', bg(\"danger.solid\")),\n\t\t\t\t\twhen(':is([data-color=\"brand\"] > &, &[data-color=\"brand\"])', bg(\"brand.solid\")),\n\t\t\t\t\toverlap\n\t\t\t\t\t\t? raw({\n\t\t\t\t\t\t\t\tboxShadow: \"0 0 0 2px var(--ui-bg, Canvas)\",\n\t\t\t\t\t\t\t\t\"&:not(:first-child)\": { marginInlineStart: \"-0.1875rem\" },\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tpulse\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tkeyframes(\"ui-status-dot-pulse\", {\n\t\t\t\t\t\t\t\t\tfrom: { opacity: 0.6, transform: \"scale(1)\" },\n\t\t\t\t\t\t\t\t\tto: { opacity: 0, transform: \"scale(2.5)\" },\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\t\t\"&::after\",\n\t\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\tcontent: '\"\"',\n\t\t\t\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\t\t\t\tinset: 0,\n\t\t\t\t\t\t\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\t\t\t\t\t\t\tbackgroundColor: \"inherit\",\n\t\t\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tmotionSafe(\n\t\t\t\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\t\t\t\"&::after\",\n\t\t\t\t\t\t\t\t\t\tanimationHost(\"ui-status-dot-pulse\", {\n\t\t\t\t\t\t\t\t\t\t\tduration: \"1.6s\",\n\t\t\t\t\t\t\t\t\t\t\teasing: \"cubic-bezier(0, 0, 0.2, 1)\",\n\t\t\t\t\t\t\t\t\t\t\titerationCount: \"infinite\",\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: undefined,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders a compact summary of several states, overlapping dots followed by `n/N`, for a\n * filter trigger that shows which statuses are on. The figures are visual; `label` is what\n * assistive technology reads.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the summary's markup.\n * @example <StatusDot.Summary colors={[\"success\", \"warning\"]} count={2} total={5} label={t(\"filters.statusCount\", { count: 2, total: 5 })} />\n */\nStatusDot.Summary = function StatusDotSummary(handle: Handle<StatusDot.SummaryProps>) {\n\treturn () => {\n\t\tlet { colors, count, total, label, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"status-dot-summary\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[inlineFlex(), items(\"center\"), raw({ gap: \"0.375em\" }), fontSize(\"sm\"), nowrap()],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<span aria-hidden=\"true\" mix={[inlineFlex(), items(\"center\")]}>\n\t\t\t\t\t{(colors ?? []).map((color, index) => (\n\t\t\t\t\t\t<Dot key={index} color={color} overlap />\n\t\t\t\t\t))}\n\t\t\t\t</span>\n\t\t\t\t<span aria-hidden=\"true\" mix={[tabularNums(), fg(\"neutral.muted\")]}>\n\t\t\t\t\t{count}/{total}\n\t\t\t\t</span>\n\t\t\t\t<span mix={[visuallyHidden()]}>{label}</span>\n\t\t\t</span>\n\t\t);\n\t};\n};\n"
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"path": "status-dot.browser.test.tsx",
|
|
14
|
+
"content": "/**\n * Draws status dots in a real browser: each tone resolves to its role's colour, a labelled dot\n * hides itself from assistive technology while a bare one is named, only an in-progress dot\n * pulses and it holds still under reduced motion, and the summary reads its label.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { cdp } from \"vitest/browser\";\n\nimport { StatusDot } from \"@sdxc/ui/status-dot\";\n\n/** Mounts `node` in a fresh host appended to the page and returns the host. */\nfunction mount(node: JSX.Element): HTMLElement {\n\tlet host = document.createElement(\"div\");\n\thost.style.setProperty(\"--ui-success-bg-solid\", \"rgb(0, 128, 0)\");\n\thost.style.setProperty(\"--ui-warning-bg-solid\", \"rgb(200, 150, 0)\");\n\thost.style.setProperty(\"--ui-danger-bg-solid\", \"rgb(200, 0, 0)\");\n\thost.style.setProperty(\"--ui-brand-bg-solid\", \"rgb(0, 0, 200)\");\n\thost.style.setProperty(\"--ui-neutral-border-strong\", \"rgb(120, 120, 120)\");\n\tdocument.body.appendChild(host);\n\trender(node, { container: host });\n\treturn host;\n}\n\n/** The circle inside the first status dot in `host`. */\nfunction dotOf(host: HTMLElement): HTMLElement {\n\treturn host.querySelector<HTMLElement>('[data-slot=\"status-dot-dot\"]')!;\n}\n\nafterEach(async () => {\n\tdocument.body.replaceChildren();\n\tawait cdp().send(\"Emulation.setEmulatedMedia\", { features: [] });\n});\n\ndescribe(\"StatusDot\", () => {\n\tfor (let [color, rgb] of [\n\t\t[\"success\", \"rgb(0, 128, 0)\"],\n\t\t[\"warning\", \"rgb(200, 150, 0)\"],\n\t\t[\"danger\", \"rgb(200, 0, 0)\"],\n\t\t[\"brand\", \"rgb(0, 0, 200)\"],\n\t\t[\"neutral\", \"rgb(120, 120, 120)\"],\n\t] as const) {\n\t\ttest(`paints a ${color} dot in its role's solid colour`, () => {\n\t\t\tlet host = mount(<StatusDot color={color}>State</StatusDot>);\n\t\t\texpect(getComputedStyle(dotOf(host)).backgroundColor).toBe(rgb);\n\t\t});\n\t}\n\n\ttest(\"draws an 8px circle\", () => {\n\t\tlet box = dotOf(mount(<StatusDot color=\"success\">Up</StatusDot>)).getBoundingClientRect();\n\t\texpect(box.width).toBe(8);\n\t\texpect(box.height).toBe(8);\n\t});\n\n\ttest(\"hides the dot when the label names the state\", () => {\n\t\tlet host = mount(<StatusDot color=\"success\">Up</StatusDot>);\n\t\tlet root = host.querySelector('[data-slot=\"status-dot\"]')!;\n\n\t\texpect(dotOf(host).getAttribute(\"aria-hidden\")).toBe(\"true\");\n\t\texpect(root.getAttribute(\"role\")).toBeNull();\n\t\texpect(root.textContent).toBe(\"Up\");\n\t});\n\n\ttest(\"names a label-less dot through aria-label as an image\", () => {\n\t\tlet host = mount(<StatusDot color=\"danger\" aria-label=\"Down\" />);\n\t\tlet root = host.querySelector('[data-slot=\"status-dot\"]')!;\n\n\t\texpect(root.getAttribute(\"role\")).toBe(\"img\");\n\t\texpect(root.getAttribute(\"aria-label\")).toBe(\"Down\");\n\t});\n\n\ttest(\"pulses only while in progress\", () => {\n\t\tlet still = mount(<StatusDot color=\"success\">Up</StatusDot>);\n\t\tlet busy = mount(\n\t\t\t<StatusDot color=\"brand\" pulse>\n\t\t\t\tDeploying\n\t\t\t</StatusDot>,\n\t\t);\n\n\t\texpect(getComputedStyle(dotOf(still), \"::after\").animationName).toBe(\"none\");\n\t\texpect(getComputedStyle(dotOf(busy), \"::after\").animationName).toBe(\"ui-status-dot-pulse\");\n\t});\n\n\ttest(\"holds the in-progress dot still under reduced motion\", async () => {\n\t\tawait cdp().send(\"Emulation.setEmulatedMedia\", {\n\t\t\tfeatures: [{ name: \"prefers-reduced-motion\", value: \"reduce\" }],\n\t\t});\n\t\tlet host = mount(\n\t\t\t<StatusDot color=\"brand\" pulse>\n\t\t\t\tDeploying\n\t\t\t</StatusDot>,\n\t\t);\n\n\t\texpect(getComputedStyle(dotOf(host), \"::after\").animationName).toBe(\"none\");\n\t});\n});\n\ndescribe(\"StatusDot.Summary\", () => {\n\ttest(\"shows one dot per state and n/N, and reads its label\", () => {\n\t\tlet host = mount(\n\t\t\t<StatusDot.Summary colors={[\"success\", \"danger\"]} count={2} total={5} label=\"2 of 5\" />,\n\t\t);\n\t\tlet root = host.querySelector('[data-slot=\"status-dot-summary\"]')!;\n\t\tlet dots = root.querySelectorAll<HTMLElement>('[data-slot=\"status-dot-dot\"]');\n\n\t\texpect(dots).toHaveLength(2);\n\t\texpect(getComputedStyle(dots[1]!).backgroundColor).toBe(\"rgb(200, 0, 0)\");\n\t\texpect(root.textContent).toContain(\"2/5\");\n\t\texpect(root.querySelector(':not([aria-hidden=\"true\"]) > span:last-child')?.textContent).toBe(\n\t\t\t\"2 of 5\",\n\t\t);\n\t});\n});\n"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/registry/ui/switch.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "switch",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Switch"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "switch.tsx",
|
|
10
|
-
"content": "/**\n * A native checkbox styled and wired as an on/off switch: a pill-shaped\n * track whose thumb slides from the inline-start edge to the inline-end\n * edge when checked, tinting with the semantic primary color along the way.\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 {\n\tabsolute,\n\tappearance,\n\tbefore,\n\tbg,\n\tbs,\n\tcursor,\n\tfocusVisible,\n\thstack,\n\tinlineBlock,\n\tinsBs,\n\tinsIs,\n\tis,\n\tm,\n\tmedia,\n\topacity,\n\toutline,\n\tpseudoContent,\n\tverticalAlign,\n\trelative,\n\trounded,\n\tscaleProperty,\n\tshadow,\n\tshrink,\n\ttransition,\n\ttransitionDuration,\n\twhen,\n} from \"@sdxc/u\";\nimport { attrs } from \"remix/component\";\n\nimport { durations, easings } from \"@sdxc/ui/animations\";\n\n/**\n * Applied through {@link attrs} so the host always carries the platform's\n * boolean `switch` attribute, letting recognizing browsers render native\n * switch semantics while others fall back to the host's own CSS and `role=\"switch\"`.\n */\nconst DEFAULT_SWITCH_ATTRIBUTE = true;\n\n/**\n * Prop types for {@link Switch}.\n */\nexport namespace Switch {\n\t/**\n\t * Every native `<input>` attribute except `type`, `role`, and\n\t * `aria-checked` — the host fixes the first two and withholds the third\n\t * so the control's own live checkedness stays the switch's only state.\n\t */\n\texport interface Props extends Omit<TagProps<\"input\">, \"type\" | \"role\" | \"aria-checked\"> {\n\t\t/**\n\t\t * Visible label text rendered after the track, inside the same native\n\t\t * `<label>` wrapping both, so clicking either half toggles the switch\n\t\t * with no separate `htmlFor`/`id` pairing required.\n\t\t */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Renders a single `<input type=\"checkbox\" role=\"switch\">`. It carries no\n * `aria-checked` because an authored value would go stale the instant the\n * switch is flipped; the live control's own checkedness is what persists.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the switch's markup.\n * @example\n * <Switch name=\"notifications\" defaultChecked>{t(\"settings.notifications.label\")}</Switch>\n * @example\n * <Label>\n * \t{t(\"settings.notifications.label\")}\n * \t<Switch name=\"notifications\" defaultChecked />\n * </Label>\n * @example\n * <Switch aria-label={t(\"settings.darkMode\")} checked={isDark} disabled={isLocked} />\n * @example\n * <Switch aria-label={t(\"settings.notifications\")} mix={[ariaChecked()]} />\n */\nexport function Switch(handle: Handle<Switch.Props>) {\n\treturn () => {\n\t\tlet { mix, children, ...rest } = handle.props;\n\n\t\tlet track = (\n\t\t\t<input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\t// oxlint-disable-next-line jsx-a11y/role-has-required-aria-props -- The host is a native checkbox, so its own checkedness supplies the switch's checked state; see the note above for why authoring one would be worse than omitting it.\n\t\t\t\trole=\"switch\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ switch: DEFAULT_SWITCH_ATTRIBUTE }),\n\t\t\t\t\tappearance(),\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineBlock(),\n\t\t\t\t\tm(\"0\"),\n\t\t\t\t\tis(\"var(--ui-switch-track-inline-size, 2.75rem)\"),\n\t\t\t\t\tbs(\"var(--ui-switch-track-block-size, 1.5rem)\"),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\tbefore([\n\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\tis(\"var(--ui-switch-thumb-size, 1.25rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-switch-thumb-size, 1.25rem)\"),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tbg(\"brand.onSolid\"),\n\t\t\t\t\t\ttransition(\"inset-inline-start, scale\", { duration: 150 }),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&:checked\", bg(\"brand.solid\")),\n\t\t\t\t\twhen(\"&:active\", bg(\"neutral.strong\")),\n\t\t\t\t\twhen(\"&:checked:active\", bg(\"brand.bg-solid-hover\")),\n\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\twhen(\"&:disabled\", opacity(50)),\n\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\tshrink(0),\n\t\t\t\t\ttransition(\"background-color\", { duration: durations.fast, easing: easings.standard }),\n\t\t\t\t\twhen(\"&:disabled\", cursor(\"not-allowed\")),\n\t\t\t\t\tverticalAlign(\"middle\"),\n\t\t\t\t\tbefore([\n\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\tinsBs(\"var(--ui-switch-thumb-inset, 0.125rem)\"),\n\t\t\t\t\t\tinsIs(\"var(--ui-switch-thumb-inset, 0.125rem)\"),\n\t\t\t\t\t\tshadow(\"base\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t\"&:checked\",\n\t\t\t\t\t\tbefore(\n\t\t\t\t\t\t\tinsIs(\n\t\t\t\t\t\t\t\t\"calc(var(--ui-switch-track-inline-size, 2.75rem) - var(--ui-switch-thumb-size, 1.25rem) - var(--ui-switch-thumb-inset, 0.125rem))\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\twhen(\"&:active\", before(scaleProperty(\"0.95\"))),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", before(transitionDuration(\"0s\"))),\n\t\t\t\t\tmix,\n\t\t\t\t
|
|
10
|
+
"content": "/**\n * A native checkbox styled and wired as an on/off switch: a pill-shaped\n * track whose thumb slides from the inline-start edge to the inline-end\n * edge when checked, tinting with the semantic primary color along the way.\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 {\n\tabsolute,\n\tappearance,\n\tbefore,\n\tbg,\n\tbs,\n\tcursor,\n\tfocusVisible,\n\thstack,\n\tinlineBlock,\n\tinsBs,\n\tinsIs,\n\tis,\n\tm,\n\tmedia,\n\topacity,\n\toutline,\n\tpseudoContent,\n\tverticalAlign,\n\trelative,\n\trounded,\n\tscaleProperty,\n\tshadow,\n\tshrink,\n\ttransition,\n\ttransitionDuration,\n\twhen,\n} from \"@sdxc/u\";\nimport { mergeMix } from \"@sdxc/u/general\";\nimport { attrs } from \"remix/component\";\n\nimport { durations, easings } from \"@sdxc/ui/animations\";\n\n/**\n * Applied through {@link attrs} so the host always carries the platform's\n * boolean `switch` attribute, letting recognizing browsers render native\n * switch semantics while others fall back to the host's own CSS and `role=\"switch\"`.\n */\nconst DEFAULT_SWITCH_ATTRIBUTE = true;\n\n/**\n * Prop types for {@link Switch}.\n */\nexport namespace Switch {\n\t/**\n\t * Every native `<input>` attribute except `type`, `role`, and\n\t * `aria-checked` — the host fixes the first two and withholds the third\n\t * so the control's own live checkedness stays the switch's only state.\n\t */\n\texport interface Props extends Omit<TagProps<\"input\">, \"type\" | \"role\" | \"aria-checked\"> {\n\t\t/**\n\t\t * Visible label text rendered after the track, inside the same native\n\t\t * `<label>` wrapping both, so clicking either half toggles the switch\n\t\t * with no separate `htmlFor`/`id` pairing required.\n\t\t */\n\t\tchildren?: RemixNode;\n\t}\n}\n\n/**\n * Renders a single `<input type=\"checkbox\" role=\"switch\">`. It carries no\n * `aria-checked` because an authored value would go stale the instant the\n * switch is flipped; the live control's own checkedness is what persists.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the switch's markup.\n * @example\n * <Switch name=\"notifications\" defaultChecked>{t(\"settings.notifications.label\")}</Switch>\n * @example\n * <Label>\n * \t{t(\"settings.notifications.label\")}\n * \t<Switch name=\"notifications\" defaultChecked />\n * </Label>\n * @example\n * <Switch aria-label={t(\"settings.darkMode\")} checked={isDark} disabled={isLocked} />\n * @example\n * <Switch aria-label={t(\"settings.notifications\")} mix={[ariaChecked()]} />\n */\nexport function Switch(handle: Handle<Switch.Props>) {\n\treturn () => {\n\t\tlet { mix, children, ...rest } = handle.props;\n\n\t\tlet track = (\n\t\t\t<input\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\t// oxlint-disable-next-line jsx-a11y/role-has-required-aria-props -- The host is a native checkbox, so its own checkedness supplies the switch's checked state; see the note above for why authoring one would be worse than omitting it.\n\t\t\t\trole=\"switch\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tattrs({ switch: DEFAULT_SWITCH_ATTRIBUTE }),\n\t\t\t\t\t\tappearance(),\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tinlineBlock(),\n\t\t\t\t\t\tm(\"0\"),\n\t\t\t\t\t\tis(\"var(--ui-switch-track-inline-size, 2.75rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-switch-track-block-size, 1.5rem)\"),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\tbefore([\n\t\t\t\t\t\t\tabsolute(),\n\t\t\t\t\t\t\tis(\"var(--ui-switch-thumb-size, 1.25rem)\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-switch-thumb-size, 1.25rem)\"),\n\t\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\t\tbg(\"brand.onSolid\"),\n\t\t\t\t\t\t\ttransition(\"inset-inline-start, scale\", { duration: 150 }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\"&:checked\", bg(\"brand.solid\")),\n\t\t\t\t\t\twhen(\"&:active\", bg(\"neutral.strong\")),\n\t\t\t\t\t\twhen(\"&:checked:active\", bg(\"brand.bg-solid-hover\")),\n\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\t\twhen(\"&:disabled\", opacity(50)),\n\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\tshrink(0),\n\t\t\t\t\t\ttransition(\"background-color\", { duration: durations.fast, easing: easings.standard }),\n\t\t\t\t\t\twhen(\"&:disabled\", cursor(\"not-allowed\")),\n\t\t\t\t\t\tverticalAlign(\"middle\"),\n\t\t\t\t\t\tbefore([\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\tinsBs(\"var(--ui-switch-thumb-inset, 0.125rem)\"),\n\t\t\t\t\t\t\tinsIs(\"var(--ui-switch-thumb-inset, 0.125rem)\"),\n\t\t\t\t\t\t\tshadow(\"base\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\t\"&:checked\",\n\t\t\t\t\t\t\tbefore(\n\t\t\t\t\t\t\t\tinsIs(\n\t\t\t\t\t\t\t\t\t\"calc(var(--ui-switch-track-inline-size, 2.75rem) - var(--ui-switch-thumb-size, 1.25rem) - var(--ui-switch-thumb-inset, 0.125rem))\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\"&:active\", before(scaleProperty(\"0.95\"))),\n\t\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", before(transitionDuration(\"0s\"))),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\n\t\tif (children === undefined) return track;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\tmix={[\n\t\t\t\t\thstack({ gap: 2, align: \"center\" }),\n\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\twhen(\"&:has(input:disabled)\", cursor(\"not-allowed\")),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{track}\n\t\t\t\t{children}\n\t\t\t</label>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
12
|
"test": {
|
|
13
13
|
"path": "switch.test.tsx",
|