@domphy/ui 0.21.5 → 0.21.6

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/patches/abbreviation.ts","../src/patches/accordion.ts","../src/utils/focusRing.ts","../src/patches/alert.ts","../src/patches/avatar.ts","../src/patches/badge.ts","../src/patches/blockquote.ts","../src/patches/breadcrumb.ts","../src/patches/breadcrumbEllipsis.ts","../src/patches/button.ts","../src/utils/buttonSize.ts","../src/patches/buttonGhost.ts","../src/patches/buttonSwitch.ts","../src/patches/card.ts","../src/utils/elevation.ts","../src/patches/code.ts","../src/patches/combobox.ts","../src/utils/floating.ts","../src/utils/openState.ts","../src/patches/tag.ts","../src/patches/command.ts","../src/patches/datePicker.ts","../src/patches/descriptionList.ts","../src/patches/details.ts","../src/patches/dialog.ts","../src/utils/scrollLock.ts","../src/patches/divider.ts","../src/patches/drawer.ts","../src/patches/emphasis.ts","../src/patches/empty.ts","../src/patches/errorBoundary.ts","../src/patches/fab.ts","../src/patches/figure.ts","../src/patches/formGroup.ts","../src/patches/grid.ts","../src/patches/heading.ts","../src/patches/horizontalRule.ts","../src/patches/icon.ts","../src/patches/image.ts","../src/patches/inputCheckbox.ts","../src/patches/inputColor.ts","../src/patches/inputDateTime.ts","../src/patches/inputFile.ts","../src/patches/inputNumber.ts","../src/patches/inputOTP.ts","../src/patches/inputPassword.ts","../src/patches/inputRadio.ts","../src/patches/inputRange.ts","../src/patches/inputSearch.ts","../src/patches/inputSwitch.ts","../src/patches/inputText.ts","../src/patches/keyboard.ts","../src/patches/label.ts","../src/patches/link.ts","../src/patches/linkButton.ts","../src/patches/list.ts","../src/patches/mark.ts","../src/patches/menu.ts","../src/patches/motion.ts","../src/patches/orderedList.ts","../src/patches/pagination.ts","../src/patches/panelSection.ts","../src/patches/paragraph.ts","../src/patches/popover.ts","../src/patches/popoverArrow.ts","../src/patches/preformated.ts","../src/patches/progress.ts","../src/patches/rating.ts","../src/patches/ringProgress.ts","../src/patches/row.ts","../src/patches/scrollArea.ts","../src/patches/segmented.ts","../src/patches/select.ts","../src/patches/selectBox.ts","../src/patches/selectItem.ts","../src/patches/selectList.ts","../src/patches/skeleton.ts","../src/patches/small.ts","../src/patches/spinner.ts","../src/patches/splitter.ts","../src/patches/stack.ts","../src/patches/steps.ts","../src/patches/strong.ts","../src/patches/subscript.ts","../src/patches/superscript.ts","../src/patches/table.ts","../src/patches/tabs.ts","../src/patches/textarea.ts","../src/patches/timeline.ts","../src/patches/toast.ts","../src/patches/toggleGroup.ts","../src/patches/toolbar.ts","../src/patches/tooltip.ts","../src/patches/transitionGroup.ts","../src/patches/unorderedList.ts","../src/patches/visuallyHidden.ts"],"sourcesContent":["export * from \"./classes.js\";\nexport * from \"./patches.js\";\nexport * from \"./types.js\";\nexport * from \"./utils.js\";\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles an abbreviation/acronym with a dotted underline and a \"help\" cursor,\n * shifting to the accent color on hover. Apply to an `<abbr>` element.\n *\n * @hostTag abbr\n * @param props.color - Base text/decoration color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @param props.accentColor - Hover color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @example { abbr: \"HTML\", title: \"HyperText Markup Language\", $: [abbreviation({ accentColor: \"primary\" })] }\n */\nfunction abbreviation(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"abbr\") {\n console.warn(`\"abbreviation\" primitive patch must use abbr tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n textDecorationLine: \"underline\",\n textDecorationStyle: \"dotted\",\n textDecorationColor: (listener) =>\n themeColor(listener, \"shift-7\", color.get(listener)),\n textUnderlineOffset: themeSpacing(0.72),\n cursor: \"help\",\n \"&:hover\": {\n color: (listener) =>\n themeColor(listener, \"shift-11\", accentColor.get(listener)),\n textDecorationColor: (listener) =>\n themeColor(listener, \"shift-9\", accentColor.get(listener)),\n },\n },\n };\n}\n\nexport { abbreviation };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Container patch that groups `<details>` elements into a bordered accordion.\n * In `type: \"single\"` mode (default), opening one item closes all siblings.\n *\n * @param props.type - `\"single\"` (default) or `\"multiple\"`. Single mode auto-closes siblings.\n * @param props.color - Theme color tone for borders and backgrounds. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color for focus rings on summary. Defaults to `\"primary\"`.\n * @example\n * { div: [\n * { details: [{ summary: \"Section A\" }, { p: \"Content A\" }], $: [details()] },\n * { details: [{ summary: \"Section B\" }, { p: \"Content B\" }], $: [details()] },\n * ], $: [accordion()] }\n */\nfunction accordion(\n props: {\n type?: \"single\" | \"multiple\";\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { type = \"single\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onMount: (node) => {\n if (type !== \"single\") return;\n\n const el = node.domElement;\n if (!el) return;\n const handler = (event: Event) => {\n const summary = (event.target as Element).closest(\"summary\");\n if (!summary) return;\n const item = summary.closest(\"details\") as HTMLDetailsElement | null;\n if (!item || item.parentElement !== el) return;\n if (!item.open) {\n Array.from(el.querySelectorAll(\":scope > details\")).forEach(\n (detail) => {\n if (detail !== item) (detail as HTMLDetailsElement).open = false;\n },\n );\n }\n };\n el.addEventListener(\"click\", handler);\n node.addHook(\"Remove\", () => el.removeEventListener(\"click\", handler));\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n outlineOffset: \"-1px\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n overflow: \"hidden\",\n \"& > details\": {\n borderBottom: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n },\n \"& > details:last-child\": {\n borderBottom: \"none\",\n },\n \"& > details > summary:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n },\n };\n}\n\nexport { accordion };\n","import type { Listener } from \"@domphy/core\";\nimport { type ThemeColor, themeColor } from \"@domphy/theme\";\n\n/**\n * Shared `:focus-visible` ring — ring-offset pattern used by Radix / shadcn /\n * Vercel / Linear:\n *\n * 1. 2px \"gap\" in the surface tone (reads as space between control + ring)\n * 2. 2px accent halo outside that gap\n *\n * Implemented as a layered `box-shadow` so it composes with a control's own\n * resting outline / elevation instead of replacing them. Prefer this over a\n * flush `0 0 0 2px` ring (looks like a thick pastel border glued to the edge)\n * and over the browser default outline.\n *\n * Accent at `shift-9` stays legible on both light and dark surfaces; the\n * washed `shift-6` flush ring is what made focus look broken in product UIs.\n */\nfunction focusRing(listener: Listener, color: ThemeColor = \"primary\"): string {\n const gap = themeColor(listener, \"surface\");\n const ring = themeColor(listener, \"shift-9\", color);\n return `0 0 0 2px ${gap}, 0 0 0 4px ${ring}`;\n}\n\nexport { focusRing };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A semantic alert surface block with a colored inset bar, padding, and\n * `role=\"alert\"`. Typically applied to a `<div>` (any block container).\n *\n * @param props.color - Surface/accent color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @example { div: \"Saved successfully\", $: [alert({ color: \"success\" })] }\n */\nfunction alert(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n\n return {\n role: \"alert\",\n // Alert is a semantic surface block, so it should shift the local surface context.\n dataTone: \"shift-2\",\n style: {\n display: \"flex\",\n alignItems: \"flex-start\",\n gap: themeSpacing(3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n boxShadow: (listener) =>\n `inset ${themeSpacing(1)} 0 0 0 ${themeColor(listener, \"shift-8\", color.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n },\n };\n}\n\nexport { alert };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A circular avatar container that centers initials/text and cover-fits any\n * child `<img>`. Typically applied to an inline-flex container such as a `<span>`.\n *\n * @param props.color - Background/foreground color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @example { span: \"JD\", $: [avatar({ color: \"primary\" })] }\n */\nfunction avatar(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n // Design-system initials weight (not app chrome) — consumers use avatar().\n _doctorDisable: \"inline-typography\",\n style: {\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n borderRadius: \"50%\",\n flexShrink: 0,\n width: themeSpacing(9),\n height: themeSpacing(9),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontWeight: \"600\",\n userSelect: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n // Hairline so the circle separates from same-tone surfaces.\n boxShadow: (listener) =>\n `0 0 0 1px ${themeColor(listener, \"border\", color.get(listener))}`,\n \"& img\": {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n },\n },\n };\n}\n\nexport { avatar };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Renders a small count/label bubble pinned to the top-right corner of its host\n * (via a `::after` pseudo-element). Typically applied to an inline container such\n * as a `<span>` wrapping an icon or element.\n *\n * @param props.color - Badge color tone. Optional `ValueOrState<ThemeColor>`, default \"danger\".\n * @param props.label - Text/number shown in the badge. Optional `ValueOrState<string | number>`, default 999.\n * @example { span: \"🔔\", $: [badge({ label: 3, color: \"danger\" })] }\n */\nfunction badge(\n props: {\n color?: ValueOrState<ThemeColor>;\n label?: ValueOrState<string | number>;\n } = {},\n): PartialElement {\n const { label = 999 } = props;\n const state = toState(label);\n const color = toState(props.color ?? \"danger\", \"color\");\n return {\n // Badge ::after uses a fixed size scale for the pill chrome.\n _doctorDisable: \"inline-typography\",\n style: {\n position: \"relative\",\n \"&::after\": {\n content: (l) => `\"${state.get(l)}\"`,\n position: \"absolute\",\n top: 0,\n right: 0,\n transform: \"translate(50%,-50%)\",\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n paddingInline: (l) => themeSpacing(themeDensity(l) * (1.5 / 1.5)),\n minWidth: themeSpacing(5),\n height: (l) => themeSpacing(themeDensity(l) * (5 / 1.5)),\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: (l) => themeSize(l, \"decrease-2\"),\n fontWeight: \"600\",\n lineHeight: 1,\n borderRadius: (l) => themeSpacing(themeDensity(l) * 999),\n backgroundColor: (l) => themeColor(l, \"shift-9\", color.get(l)),\n color: (l) => themeColor(l, \"shift-0\", color.get(l)),\n // Hairline ring so the pill pops on same-hue surfaces.\n boxShadow: (l) => `0 0 0 1px ${themeColor(l, \"shift-0\", color.get(l))}`,\n },\n },\n };\n}\n\nexport { badge };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a quotation block with a colored inset side bar, padded surface, and\n * shifted tone. Apply to a `<blockquote>` element.\n *\n * @hostTag blockquote\n * @param props.color - Surface/bar color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { blockquote: \"Design is how it works.\", $: [blockquote({ color: \"primary\" })] }\n */\nfunction blockquote(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"blockquote\") {\n console.warn(`\"blockquote\" primitive patch must use blockquote tag`);\n }\n },\n dataTone: \"shift-2\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n boxShadow: (listener) =>\n `inset ${themeSpacing(1)} 0 0 0 ${themeColor(listener, \"shift-4\", color.get(listener))}`,\n border: \"none\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n margin: 0,\n },\n };\n}\n\nexport { blockquote };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A horizontal breadcrumb navigation that lays out its children with a\n * separator between items and highlights the `[aria-current=page]` item.\n * Apply to a `<nav>` element.\n *\n * @hostTag nav\n * @param props.color - Color tone for links/separators. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @param props.separator - String inserted between items via `::after`. Optional `string`, default \"/\".\n * @example { nav: null, $: [breadcrumb({ separator: \"›\" })] }\n */\nfunction breadcrumb(\n props: { color?: ValueOrState<ThemeColor>; separator?: string } = {},\n): PartialElement {\n const { separator = \"/\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"nav\")\n console.warn('\"breadcrumb\" patch must use nav tag');\n },\n ariaLabel: \"breadcrumb\",\n style: {\n display: \"flex\",\n alignItems: \"center\",\n flexWrap: \"wrap\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n gap: themeSpacing(1),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n \"& > *\": {\n display: \"inline-flex\",\n alignItems: \"center\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n \"& > *:not(:last-child)::after\": {\n content: `\"${separator}\"`,\n color: (listener) =>\n themeColor(listener, \"shift-4\", color.get(listener)),\n paddingInlineStart: themeSpacing(1),\n },\n \"& > [aria-current=page]\": {\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { breadcrumb };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * An ellipsis trigger button for collapsed breadcrumb items, with hover and\n * focus-visible states. Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.color - Color tone for the trigger. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { button: \"…\", $: [breadcrumbEllipsis({ color: \"neutral\" })] }\n */\nfunction breadcrumbEllipsis(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn('\"breadcrumbEllipsis\" patch must use button tag');\n }\n },\n ariaLabel: \"More breadcrumb items\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n paddingInline: themeSpacing(1),\n border: \"none\",\n background: \"none\",\n cursor: \"pointer\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n borderRadius: themeSpacing(1),\n transition:\n \"color 140ms ease, background-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover\": {\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n },\n };\n}\n\nexport { breadcrumbEllipsis };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { BUTTON_SIZE_FONT, type ButtonSize } from \"../utils/buttonSize.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport { buttonGhost } from \"./buttonGhost.js\";\n\ntype ButtonVariant = \"solid\" | \"outline\" | \"ghost\";\n\nconst PADDING_STEPS: Record<ButtonSize, { block: number; inline: number }> = {\n small: { block: 0.5, inline: 2 },\n medium: { block: 1, inline: 3 },\n large: { block: 1.5, inline: 4 },\n};\n\n/**\n * A themed button control with density-aware padding/radius and hover, pressed\n * (`:active` ±2), focus-visible, `[disabled]`, and `[aria-busy=true]` states.\n * Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @param props.variant - Visual style: `\"outline\"` (tinted background + outline, default,\n * backward compatible), `\"solid\"` (filled background, readable contrast text), or `\"ghost\"`\n * (no background/border — delegates to `buttonGhost()` so the two stay visually identical).\n * @param props.size - Button size preset. Optional `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { button: \"Save\", $: [button({ color: \"primary\" })] }\n * @example { button: \"Delete\", $: [button({ color: \"error\", variant: \"solid\" })] }\n */\nfunction button(\n props: {\n color?: ValueOrState<ThemeColor>;\n variant?: ButtonVariant;\n size?: ButtonSize;\n } = {},\n): PartialElement {\n const variant = props.variant ?? \"outline\";\n if (variant === \"ghost\") {\n return buttonGhost({ color: props.color, size: props.size });\n }\n\n const color = toState(props.color ?? \"primary\", \"color\");\n const isSolid = variant === \"solid\";\n const padding = PADDING_STEPS[props.size ?? \"medium\"];\n const fontSize = BUTTON_SIZE_FONT[props.size ?? \"medium\"];\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn(`\"button\" primitive patch must use button tag`);\n }\n },\n // Solid: deep brand fill (shift-13) + light-end neutral text (shift-0).\n // Mid-ramp shift-8 failed WCAG (~2.2:1 white-on-medium). NOT dataTone-17\n // (that collapsed every color into a near-black pill). Outline text:\n // shift-13 for ≥4.5:1 on light surfaces (shift-9 failed at ~2.57).\n ...(isSolid\n ? {\n _doctorDisable: [\n \"low-contrast\",\n \"color-shift-minimum\",\n \"tone-background-inherit\",\n ] as const,\n }\n : {}),\n style: {\n appearance: \"none\",\n fontSize: (listener) => themeSize(listener, fontSize),\n // Single-line bounded control: block/radius = 1D, inline = 3D.\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding.block),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding.inline),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n width: \"fit-content\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outlineWidth: \"1px\",\n outline: isSolid\n ? \"none\"\n : (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-13\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-13\", color.get(listener))\n : themeColor(listener, \"inherit\", color.get(listener)),\n transition:\n \"background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-14\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-14\", color.get(listener))\n : themeColor(listener, \"hover\", color.get(listener)),\n },\n // Pressed: solid steps deeper on the brand ramp; outline uses +2 surface.\n \"&:active:not([disabled]):not([aria-busy=true])\": {\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-15\", color.get(listener))\n : themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n \"&[aria-busy=true]\": {\n opacity: 0.7,\n cursor: \"wait\",\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { button };\nexport type { ButtonVariant };\n","/**\n * The `fontSize` step for `button()`/`buttonGhost()`'s `size` prop. Padding stays\n * per-component (button and buttonGhost start from different base paddings) so\n * only the part that's genuinely identical — the font-size step — lives here.\n */\nconst BUTTON_SIZE_FONT = {\n small: \"decrease-1\",\n medium: \"inherit\",\n large: \"increase-1\",\n} as const;\n\ntype ButtonSize = keyof typeof BUTTON_SIZE_FONT;\n\nexport { BUTTON_SIZE_FONT };\nexport type { ButtonSize };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { BUTTON_SIZE_FONT, type ButtonSize } from \"../utils/buttonSize.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst PADDING_STEPS: Record<ButtonSize, number> = {\n small: 0.5,\n medium: 1,\n large: 1.5,\n};\n\n/**\n * A transparent button with no border or background — suitable for icon\n * actions, inline controls, and delete/close triggers. Apply to a `<button>`\n * element.\n *\n * @hostTag button\n * @param props.color - Text color tone. Optional `ValueOrState<ThemeColor>`, defaults to `\"neutral\"`.\n * @param props.size - Button size preset. Optional `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { button: \"×\", $: [buttonGhost()] }\n * @example { button: { span: null, $: [icon({ name: \"trash\" })] }, $: [buttonGhost({ color: \"error\" })] }\n */\nfunction buttonGhost(\n props: { color?: ValueOrState<ThemeColor>; size?: ButtonSize } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const padding = PADDING_STEPS[props.size ?? \"medium\"];\n const fontSize = BUTTON_SIZE_FONT[props.size ?? \"medium\"];\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn(`\"buttonGhost\" primitive patch must use button tag`);\n }\n },\n style: {\n appearance: \"none\",\n fontSize: (listener) => themeSize(listener, fontSize),\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n display: \"inline-flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n background: \"none\",\n outline: \"none\",\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n // Resting text uses the \"text\" alias (shift-9) — NOT the semantic-zone\n // shift-6 the patch previously used. A ghost button's label is essential\n // interactive content, and shift-6 on an edge surface measures ~2.4:1,\n // failing WCAG AA (axe color-contrast). shadcn's ghost variant likewise\n // rests at full foreground; hover/active keep the same text color and\n // differentiate via background only.\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:active:not([disabled]):not([aria-busy=true])\": {\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"border-strong\", \"neutral\"),\n },\n \"&[aria-busy=true]\": {\n opacity: 0.7,\n cursor: \"wait\",\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { buttonGhost };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * A pill-shaped toggle switch with `role=\"switch\"`; clicking flips the bound\n * `checked` state and slides the thumb. Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.checked - Toggle state. Optional `ValueOrState<boolean>`, default false.\n * @param props.accentColor - Color tone when checked (on). Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @param props.color - Color tone when unchecked (off track). Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { button: { span: null }, $: [buttonSwitch({ checked: true })] }\n */\nfunction buttonSwitch(\n props: {\n checked?: ValueOrState<boolean>;\n accentColor?: ValueOrState<ThemeColor>;\n color?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { checked = false } = props;\n\n const check = toState(checked);\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onSchedule: (node) => {\n if (node.tagName !== \"button\") {\n console.warn(`\"buttonSwitch\" primitive patch must use button tag`);\n }\n },\n role: \"switch\",\n ariaChecked: (listener) => check.get(listener),\n dataTone: \"shift-2\",\n onClick: () => check.set(!check.get()),\n style: {\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n fontSize: (listener) => themeSize(listener),\n border: \"none\",\n outlineWidth: \"1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color.get(listener))}`,\n minWidth: themeSpacing(12),\n minHeight: themeSpacing(6),\n borderRadius: themeSpacing(999),\n paddingLeft: themeSpacing(7),\n paddingRight: themeSpacing(2),\n cursor: \"pointer\",\n transition:\n \"padding-left 0.3s, padding-right 0.3s, background-color 140ms ease, box-shadow 140ms ease\",\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"& > :first-child\": {\n content: '\"\"',\n position: \"absolute\",\n display: \"inline-flex\",\n alignItems: \"center\",\n left: themeSpacing(0.5),\n top: \"50%\",\n transform: \"translateY(-50%)\",\n transition: \"left 0.3s\",\n width: themeSpacing(5),\n height: themeSpacing(5),\n borderRadius: themeSpacing(999),\n color: (listener) => themeColor(listener, \"text\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"decrease-2\", color.get(listener)),\n },\n \"&[aria-checked=true]\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-3\", accentColor.get(listener)),\n outline: \"none\",\n color: (listener) => themeColor(listener, \"decrease-2\"),\n paddingLeft: themeSpacing(2),\n paddingRight: themeSpacing(7),\n },\n \"&[aria-checked=true] > :first-child\": {\n left: `calc(100% - ${themeSpacing(5.5)})`,\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n };\n}\n\nexport { buttonSwitch };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\n\n/**\n * A grid-based card surface that auto-places known child elements into named\n * regions: `<img>` (image), headings (title), `<p>` (description), `<aside>`\n * (aside), `<div>` (content), and `<footer>` (footer). Typically applied to a\n * `<div>` (any block container).\n *\n * @param props.color - Surface/border color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { div: { h3: \"Title\", p: \"Body\" }, $: [card({ color: \"neutral\" })] }\n */\nfunction card(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n // Title weight is design-system chrome for the card region layout.\n _doctorDisable: \"inline-typography\",\n style: {\n display: \"grid\",\n gridTemplateColumns: \"1fr auto\",\n gridTemplateAreas:\n '\"image image\" \"title aside\" \"desc aside\" \"content content\" \"footer footer\"',\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n outlineOffset: \"-1px\",\n // Soft lift so cards separate from the page without looking like dialogs.\n boxShadow: elevation(\"low\"),\n overflow: \"hidden\",\n \"& > img\": {\n gridArea: \"image\",\n width: \"100%\",\n height: \"auto\",\n display: \"block\",\n },\n \"& > :is(h1,h2,h3,h4,h5,h6)\": {\n gridArea: \"title\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n fontWeight: \"600\",\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n margin: 0,\n },\n \"& > p\": {\n gridArea: \"desc\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n paddingBottom: (listener) => themeSpacing(themeDensity(listener) * 2),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n margin: 0,\n },\n \"& > aside\": {\n gridArea: \"aside\",\n alignSelf: \"center\",\n padding: (listener) => themeSpacing(themeDensity(listener) * 2),\n height: \"auto\",\n },\n \"& > div\": {\n gridArea: \"content\",\n padding: (listener) => themeSpacing(themeDensity(listener) * 4),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n \"& > footer\": {\n gridArea: \"footer\",\n display: \"flex\",\n gap: themeSpacing(2),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n borderTop: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color.get(listener))}`,\n },\n },\n };\n}\n\nexport { card };\n","/** Named elevation levels for floating/raised surfaces. */\ntype ElevationLevel = \"low\" | \"medium\" | \"high\";\n\n// Layered soft shadows (a tight contact shadow + a broad ambient one), black at\n// low alpha so the same value reads correctly on both light and dark surfaces\n// without a theme/context lookup.\nconst SHADOWS: Record<ElevationLevel, string> = {\n low: \"0 1px 2px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.10)\",\n medium: \"0 2px 4px rgba(0,0,0,0.10), 0 10px 24px rgba(0,0,0,0.14)\",\n high: \"0 6px 12px rgba(0,0,0,0.14), 0 24px 48px rgba(0,0,0,0.20)\",\n};\n\n/**\n * Shared box-shadow value for a named elevation level. Used by floating/raised\n * surface patches (popover, menu, dialog, drawer, toast, tooltip, combobox/\n * selectBox dropdown, datePicker popup, fab) so elevation reads consistently\n * across the library instead of each patch picking its own shadow.\n */\nfunction elevation(level: ElevationLevel): string {\n return SHADOWS[level];\n}\n\nexport { elevation };\nexport type { ElevationLevel };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles an inline code snippet with a subtle surface background, rounded corners,\n * and shifted tone. Apply to a `<code>` element.\n *\n * @hostTag code\n * @param props.color - Surface/text color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { code: \"npm install\", $: [code({ color: \"neutral\" })] }\n */\nfunction code(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n _onInsert: (node) => {\n if (node.tagName !== \"code\") {\n console.warn(`\"code\" primitive patch must use code tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n whiteSpace: \"nowrap\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n height: (listener) => themeSpacing(themeDensity(listener) * (6 / 1.5)),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * (1.5 / 1.5)),\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * (1 / 1.5)),\n },\n };\n}\n\nexport { code };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n merge,\n type PartialElement,\n type State,\n type StyleObject,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport { tag } from \"./tag.js\";\n\n/**\n * A combobox/multi-select control: renders selected options as removable tags\n * plus an input, and shows a floating popover (`content`) anchored to the host.\n * Apply to a `<div>` element.\n *\n * @hostTag div\n * @param props.multiple - Allow selecting multiple values (popover stays open on click). Optional `boolean`, default false.\n * @param props.value - Selected value(s). Optional `ValueOrState<Array<number | string | null | undefined> | number | string | null | undefined>`, no default.\n * @param props.options - Available `{ label, value }` options used to render selected tags. Optional `Array<{ label: string; value: string }>`, default `[]`.\n * @param props.placement - Floating popover placement. Optional `ValueOrState<Placement>`, default \"bottom\".\n * @param props.content - The floating popover content element. Required `DomphyElement`.\n * @param props.color - Color tone for the control. Optional `ThemeColor`, default \"neutral\".\n * @param props.open - Whether the popover is open. Optional `ValueOrState<boolean>` (including `Computed`/`ReadableState`), default false. When the source is read-only, pass `onDismiss` so dismiss can close.\n * @param props.onDismiss - Called when the popover requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.input - Custom input element; when omitted a default `<input>` is created. Optional `DomphyElement`.\n * @example { div: null, $: [combobox({ options: [{ label: \"A\", value: \"a\" }], content: { div: null } })] }\n */\nfunction combobox(props: {\n multiple?: boolean;\n value?: ValueOrState<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n options?: Array<{ label: string; value: string }>;\n placement?: ValueOrState<Placement>;\n content: DomphyElement;\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n input?: DomphyElement;\n}): PartialElement {\n const {\n options = [],\n placement = \"bottom\",\n color = \"neutral\",\n open = false,\n multiple = false,\n } = props;\n\n const state = toState(props.value);\n const openState = toState(open);\n const { show, hide, anchorPartial } = createFloating({\n kind: \"combobox\",\n open: openState,\n onDismiss: props.onDismiss,\n placement: toState(placement),\n content: props.content,\n });\n\n const popoverPartial: PartialElement = {\n onClick: (_e, node) => !multiple && hide(node),\n dataTone: \"shift-14\",\n style: {\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n // Surface contract (dataTone-surface-contract): a tone-anchored panel\n // must declare BOTH background and text color — on the dark shift-14\n // surface, inherited portal context colors can fall below contrast.\n color: (listener) => themeColor(listener, \"text\"),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n\n merge(props.content, popoverPartial);\n\n const inputStyle: StyleObject = {\n border: \"none\",\n outline: \"none\",\n padding: 0,\n margin: 0,\n flex: 1,\n height: themeSpacing(6),\n marginInlineStart: themeSpacing(2),\n fontSize: (listener: any) => themeSize(listener, \"inherit\"),\n color: (listener: any) => themeColor(listener, \"text\", color),\n backgroundColor: (listener: any) => themeColor(listener, \"inherit\", color),\n };\n\n type InnerProps = {\n options: Array<{ label: string; value: string }>;\n multiple: boolean;\n color: ThemeColor;\n state: State<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n input?: DomphyElement;\n };\n\n type ComboboxInner = BehaviorInstance<InnerProps> & {\n query: State<string>;\n };\n\n const readQuery = (listener?: { elementNode?: ElementNode }) =>\n listener?.elementNode?.getBehavior<ComboboxInner>(\"comboboxInner\")?.query;\n\n const findComboboxAnchor = (from: ElementNode): ElementNode => {\n let current: ElementNode | null = from;\n while (current) {\n if (current._behaviorInstances.has(\"floating:combobox\")) return current;\n current = current.parent;\n }\n return from;\n };\n\n const inputAria: PartialElement = {\n role: \"combobox\",\n ariaHaspopup: \"listbox\",\n ariaExpanded: (listener) => openState.get(listener),\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"combobox\", findComboboxAnchor(listener.elementNode))\n : undefined,\n };\n\n const buildInput = (custom?: DomphyElement): DomphyElement => {\n if (custom) {\n merge(custom, {\n onFocus: (_e: Event, node: ElementNode) => show(node),\n style: inputStyle,\n _key: \"combobox-input\",\n ...inputAria,\n });\n return custom;\n }\n return {\n input: null,\n // Accessible name for the filter field (critical for axe label rule).\n ariaLabel: \"Filter options\",\n onFocus: (_e: Event, node: ElementNode) => show(node),\n value: (listener: { elementNode?: ElementNode }) =>\n readQuery(listener)?.get(listener as never) ?? \"\",\n onInput: (event: Event, node: ElementNode) => {\n node\n .getBehavior<ComboboxInner>(\"comboboxInner\")\n ?.query.set((event.target as HTMLInputElement).value);\n },\n style: inputStyle,\n _key: \"combobox-input\",\n ...inputAria,\n };\n };\n\n const buildWrap = (inner: InnerProps): DomphyElement<\"div\"> => ({\n div: (listener) => {\n openState.get(listener);\n const val = inner.state.get(listener);\n const vals = Array.isArray(val) ? val : [val];\n const opts = inner.options.filter((opt) => vals.includes(opt.value));\n const items: DomphyElement[] = opts.map((opt) => {\n return {\n span: opt.label,\n $: [tag({ color: inner.color, removable: true })],\n _key: opt.value,\n _onRemove: (_node: ElementNode) => {\n const cur = inner.state.get();\n const curVals = Array.isArray(cur) ? cur : [cur];\n const filter = curVals.filter((v) => v !== opt.value);\n inner.multiple\n ? inner.state.set(filter as any)\n : inner.state.set(filter[0] as any);\n },\n };\n });\n items.push(buildInput(inner.input));\n return items;\n },\n _key: \"comboboxWrap\",\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: themeSpacing(1),\n },\n });\n\n const attachInner = (\n node: ElementNode,\n _inner: InnerProps,\n ): ComboboxInner => {\n let query = node.getMetadata(\"comboboxQuery\") as State<string> | undefined;\n if (!query) {\n query = toState(\"\");\n node.setMetadata(\"comboboxQuery\", query);\n }\n return {\n query,\n update(next) {\n node.children.update([buildWrap(next)]);\n },\n };\n };\n\n const partial: PartialElement = {\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"combobox\" primitive patch must use div tag`);\n }\n },\n _onSchedule: (node, element) => {\n (element as Record<string, unknown>)[node.tagName] = [\n buildWrap({\n options,\n multiple,\n color,\n state,\n input: props.input,\n }),\n ];\n },\n ...behavior<InnerProps>(\"comboboxInner\", attachInner, {\n options,\n multiple,\n color,\n state,\n input: props.input,\n }),\n style: {\n minWidth: themeSpacing(32),\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n transition:\n \"background-color 140ms ease, outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-within\": {\n boxShadow: (listener) => focusRing(listener, color),\n },\n },\n };\n\n merge(anchorPartial, partial);\n return anchorPartial;\n}\n\nexport { combobox };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n merge,\n type PartialElement,\n type ReadableState,\n type State,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n autoUpdate,\n computePosition,\n flip,\n offset,\n type Placement,\n shift,\n} from \"@domphy/floating\";\nimport {\n asOpenState,\n dismissOpen,\n subscribeOpen,\n writeOpen,\n} from \"./openState.js\";\n\ntype FloatingProps = {\n kind: string;\n openState: ReadableState<boolean>;\n // Lives on the behavior instance so a reused node gets the latest callback\n // via update() — do not close over factory-generation onDismiss.\n onDismiss?: () => void;\n placement: State<Placement>;\n content: DomphyElement;\n // popover's openOn === \"hover\" case: hovering the floating PANEL itself\n // (not just the anchor) must keep it open, so the pointer can travel from\n // trigger to panel without the debounced hide() firing first.\n keepOpenOnContentHover: boolean;\n};\n\n// The panel id every floating component gets, derived deterministically from\n// the ANCHOR's nodeId (stable across generations — a reused node keeps its\n// nodeId — and across SSR/hydration, unlike Math.random()). The anchor's\n// trigger partial references the same id via _onSchedule (aria-controls /\n// aria-describedby), so trigger and panel agree without any factory-scope\n// mutable variable that a fresh generation would lose.\nfunction floatingPanelId(kind: string, node: ElementNode): string {\n return `domphy-${kind}-${node.nodeId}`;\n}\n\ntype FloatingInstance = BehaviorInstance<FloatingProps> & {\n show: () => void;\n hide: () => void;\n panelId: string;\n};\n\n// The per-anchor persistent state a floating component needs (position\n// cleanup, the inserted panel node, debounce timer) used to live in\n// createFloating()'s own closure — but that closure is recreated fresh every\n// time a reactive ancestor re-renders the anchor (popover()/tooltip() called\n// again on the SAME reused DOM element). Only the FIRST-ever generation's\n// _onMount ever fires (ElementNode hooks run once per node), so imperative,\n// document-level listeners (outside-click, Escape-inside-panel) that closed\n// over that generation's `openState`/`reference`/`floating` kept acting on an\n// orphaned copy forever, while live-rebound trigger events (onClick etc.)\n// moved on to whatever generation was actually current — the trigger opened\n// the panel, but nothing could ever close it again from outside.\n//\n// Fixed by moving all of this into ONE `behavior()` instance per (anchor,\n// kind): `attach` runs once, and every later generation's `show`/`hide`\n// calls and `_behaviors` re-declaration route into that SAME instance via\n// `getBehavior`/`update()` — so there is exactly one canonical `openState`/\n// `reference`/`floating` for the anchor's whole lifetime, not one per\n// generation.\nfunction attachFloating(\n node: ElementNode,\n initialProps: FloatingProps,\n): FloatingInstance {\n let { openState, onDismiss, placement, content, keepOpenOnContentHover } =\n initialProps;\n const { kind } = initialProps;\n const behaviorKey = `floating:${kind}`;\n\n let timer: ReturnType<typeof setTimeout> | null = null;\n let cleanup: (() => void) | null = null;\n let floating: HTMLElement | null = null;\n let floatingNode: ElementNode | null = null;\n let mounted = false;\n\n const reference = node.domElement as HTMLElement;\n const rootNode = node.getRoot();\n const panelId = floatingPanelId(kind, node);\n\n const floatingPartial: PartialElement = {\n style: {\n position: \"fixed\",\n pointerEvents: \"auto\",\n visibility: (listener) =>\n openState.get(listener) ? \"visible\" : \"hidden\",\n },\n // Escape must dismiss the panel from INSIDE it too: the content is\n // portaled as a DOM sibling of the anchor, so a keydown on a focused\n // element within the panel (menu item, calendar cell, footer button)\n // never bubbles to the anchor's own Escape handler.\n onKeyDown: (event) => {\n if ((event as KeyboardEvent).key === \"Escape\") hide();\n },\n onMouseEnter: () => keepOpenOnContentHover && show(),\n onMouseLeave: () => keepOpenOnContentHover && hide(),\n _onMount: (mountedNode) => {\n floating = mountedNode.domElement as HTMLElement;\n // Stamped as a plain DOM property (not node.attributes.set) so a later\n // floatingNode.patch(content) — which strips undeclared ATTRIBUTES from\n // its own bookkeeping — never removes it. A consumer-declared id on the\n // content element wins.\n if (!floating.id) floating.id = panelId;\n // Propagate data-theme from the trigger's ancestor so floating content\n // inherits CSS variable scope. Stamped on the PANEL, not the shared\n // overlay: the one overlay serves every floating component under the\n // root, so an overlay-level stamp would let whichever anchor opened\n // FIRST permanently impose its theme on later panels anchored under a\n // different [data-theme] scope. Skipped when the content declares its\n // own data-theme.\n if (reference && floating && !floating.hasAttribute(\"data-theme\")) {\n const dataTheme = reference\n .closest(\"[data-theme]\")\n ?.getAttribute(\"data-theme\");\n if (dataTheme) floating.setAttribute(\"data-theme\", dataTheme);\n }\n },\n _portal: (rNode) => {\n // showModal() puts the dialog in the top layer, above every z-index.\n // A panel portaled to the root overlay (z-index 20) would paint UNDER\n // an open dialog — drop it into the ancestor dialog instead so it\n // shares the top layer.\n const dialogHost = reference.closest(\"dialog\");\n if (dialogHost) {\n let overlay = dialogHost.querySelector(\":scope > #domphy-floating\");\n if (!overlay) {\n overlay = dialogHost.ownerDocument.createElement(\"div\");\n overlay.id = \"domphy-floating\";\n Object.assign((overlay as HTMLElement).style, {\n position: \"fixed\",\n inset: \"0\",\n zIndex: \"20\",\n pointerEvents: \"none\",\n });\n dialogHost.appendChild(overlay);\n }\n return overlay;\n }\n let overlay = rNode.domElement!.querySelector(`#domphy-floating`);\n if (!overlay) {\n const overlayEle: DomphyElement<\"div\"> = {\n div: [],\n id: `domphy-floating`,\n style: {\n position: \"fixed\",\n inset: 0,\n zIndex: 20,\n pointerEvents: \"none\",\n },\n };\n const overlayNode = rNode.children!.insert(overlayEle) as ElementNode;\n overlay = overlayNode.domElement!;\n }\n return overlay;\n },\n };\n\n // Later generations declare their OWN fresh `content` object (a new object\n // literal at the popover()/tooltip() call site) — wire it every time, not\n // just at attach, so the panel wiring (theming, portal, dismiss handlers)\n // is present regardless of which generation's content ends up mounted.\n const wireContent = (target: DomphyElement) => merge(target, floatingPartial);\n wireContent(content);\n\n const ensureMounted = () => {\n if (mounted) return;\n mounted = true;\n floatingNode = rootNode.children!.insert(content) as ElementNode;\n // Expose THIS instance on the panel node too: the panel is portaled as a\n // child of the ROOT (not of the anchor), so getBehavior's ancestor walk\n // from a panel descendant (a selectBox/combobox option, a datePicker day\n // cell) never reaches the anchor's registration. Registering the same\n // instance on the panel lets panel-originated events resolve it via\n // `node.getBehavior(behaviorKey)` — the documented walk-up pattern. No\n // teardown wiring here: the instance's lifetime is owned by the anchor\n // (destroy there), the registration simply dies with the panel node.\n floatingNode._behaviorInstances.set(behaviorKey, instance);\n };\n\n const instantShow = () => {\n // A re-render can detach the panel DOM without going through\n // instantHide (overlay reconcile, in-place patch). If we still think\n // we are mounted, skip insert and the panel never comes back.\n if (mounted && (!floating || !floating.isConnected)) {\n cleanup?.();\n cleanup = null;\n floatingNode = null;\n floating = null;\n mounted = false;\n }\n ensureMounted();\n if (reference && floating) {\n cleanup?.();\n cleanup = autoUpdate(reference, floating, () => {\n computePosition(reference as HTMLElement, floating as HTMLElement, {\n placement: placement.get() as Placement,\n // rootBoundary deliberately stays at the upstream default\n // ('viewport', i.e. the VISUAL viewport): with strategy \"fixed\" the\n // 1.8.0 'layoutViewport' option would stop clamping flip/shift to\n // the visible area, letting a panel land (partly) outside the\n // visible viewport during mobile pinch-zoom — a worse failure than\n // the jumpiness it fixes. Pinch-zoom/keyboard drift is already\n // handled by autoUpdate's post-1.8.0 observeMove re-anchoring.\n middleware: [offset(12), flip(), shift()],\n strategy: \"fixed\",\n }).then(({ x, y, placement: resolved }) => {\n // Teardown can run while computePosition's async work is in\n // flight (it nulls `floating` and removes the panel) — skip the\n // late positioning instead of dereferencing null.\n if (!floating) return;\n Object.assign(floating.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n placement.set(resolved);\n });\n });\n writeOpen(openState, true);\n }\n };\n // Fully unmounts (not just CSS-hides) the panel — mirrors show()'s own\n // insert-on-demand: a closed floating component holds no DOM/listeners.\n // ensureMounted() re-inserts a fresh panel node next time show() runs.\n // Visual unmount runs even when the source is read-only (Computed).\n const instantHide = () => {\n cleanup?.();\n cleanup = null;\n if (floatingNode) {\n floatingNode.remove();\n floatingNode = null;\n }\n floating = null;\n mounted = false;\n dismissOpen(openState, onDismiss);\n };\n const show = () => {\n timer && clearTimeout(timer);\n timer = setTimeout(instantShow, 100);\n };\n const hide = () => {\n timer && clearTimeout(timer);\n timer = setTimeout(instantHide, 100);\n };\n\n const handleOutside = (event: MouseEvent) => {\n if (!openState.get() || !reference || !floating) return;\n const target = event.target as Node;\n if (!reference.contains(target) && !floating.contains(target)) hide();\n };\n rootNode.domElement?.addEventListener(\"click\", handleOutside);\n\n // Escape must dismiss an open panel from ANYWHERE, not just from the\n // trigger or inside the panel (peer parity: Radix DismissableLayer closes\n // on a document-level Escape) — a hover-opened tooltip with focus sitting\n // on <body> otherwise ignores Escape entirely. Keyboard events target the\n // FOCUSED element and bubble UP, so unlike the outside-click listener this\n // one must live on the document (keydown is composed, so panels inside a\n // shadow root still reach it). Idempotent alongside the trigger/panel-level\n // Escape handlers: hide() is debounced and re-arming it on an\n // already-closed panel is a no-op.\n const handleEscape = (event: Event) => {\n if ((event as KeyboardEvent).key === \"Escape\" && openState.get()) hide();\n };\n const escapeTarget: EventTarget | null =\n rootNode.domElement?.ownerDocument ?? rootNode.domElement ?? null;\n escapeTarget?.addEventListener(\"keydown\", handleEscape);\n\n // Caller-driven open (open.set(true) / open:true) must insert the panel —\n // show()/hide() are only the trigger-event path. Guard with `mounted` so\n // instantShow/instantHide's own writeOpen/dismissOpen does not recurse\n // (writable State.set notifies listeners).\n const onOpen = (val: boolean) => {\n if (val) {\n if (!mounted) instantShow();\n } else if (mounted) {\n instantHide();\n }\n };\n let release = () => {};\n let destroyed = false;\n let updating = false;\n let instance: FloatingInstance;\n\n // Stamped after `instance` exists. The panel is patched in place on every\n // generation; patch() prunes _behaviorInstances keys absent from the new\n // descriptor and destroy()s them. The instance is SHARED with the anchor —\n // pruning it unmounts the live panel. Declaring the key on the content\n // keeps prune from treating it as leftover.\n const stampPanelBehavior = (target: DomphyElement) => {\n target._behaviors = {\n ...(target._behaviors ?? {}),\n [behaviorKey]: { attach: () => instance, props: {} },\n };\n };\n\n instance = {\n show,\n hide,\n panelId,\n update(props) {\n if (updating) return;\n onDismiss = props.onDismiss;\n if (props.openState !== openState) {\n release();\n openState = props.openState;\n // emitCurrent false: a fresh uncontrolled toState(false) on a reused\n // node is not a caller close.\n release = subscribeOpen(openState, onOpen, false);\n // Show if the new object is already true (open:true / caller-owned).\n if (openState.get()) instantShow();\n }\n placement = props.placement;\n content = props.content;\n keepOpenOnContentHover = props.keepOpenOnContentHover;\n wireContent(content);\n stampPanelBehavior(content);\n // Reflect the new generation's declared content into the already-\n // mounted panel in place (same DOM node, no flicker/teardown) — the\n // ordinary reused-node \"patch, don't recreate\" contract, applied to\n // the imperatively-inserted panel too.\n if (floatingNode) {\n updating = true;\n try {\n floatingNode.patch(content);\n } finally {\n updating = false;\n }\n }\n },\n destroy() {\n if (destroyed) return;\n destroyed = true;\n if (timer) clearTimeout(timer);\n timer = null;\n cleanup?.();\n cleanup = null;\n floatingNode?.remove();\n floatingNode = null;\n floating = null;\n mounted = false;\n release();\n release = () => {};\n rootNode.domElement?.removeEventListener(\"click\", handleOutside);\n escapeTarget?.removeEventListener(\"keydown\", handleEscape);\n },\n };\n stampPanelBehavior(content);\n // After `instance` exists: ensureMounted registers it on the panel node.\n // subscribeOpen notifies immediately (replaces onOpen(openState.get())).\n release = subscribeOpen(openState, onOpen);\n return instance;\n}\n\nfunction createFloating(props: {\n kind: string;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement: State<Placement>;\n content: DomphyElement;\n keepOpenOnContentHover?: boolean;\n}) {\n const { kind, placement, onDismiss } = props;\n const openState = asOpenState(props.open);\n const behaviorKey = `floating:${kind}`;\n\n // Trigger event handlers ARE live-rebound on every patch and already\n // receive the current ElementNode as their 2nd argument (unlike lifecycle\n // hooks) — so show(node)/hide(node) just forward to whatever instance is\n // attached there, regardless of which generation's closure is calling.\n const show = (node?: ElementNode) =>\n node?.getBehavior<FloatingInstance>(behaviorKey)?.show();\n const hide = (node?: ElementNode) =>\n node?.getBehavior<FloatingInstance>(behaviorKey)?.hide();\n\n // Plain spread, NOT merge(): merge() defensively deep-clones its `target`\n // argument, which would snapshot `props.content` right now — but the\n // caller (popover()/tooltip()) hasn't finished mutating it yet (it pushes\n // its OWN partial onto `content.$` right after this call returns). A\n // premature clone silently drops that later mutation, so the panel loses\n // its role/style/dismiss wiring. Spread keeps the `_behaviors` record's\n // `props.content` a live reference to the SAME object the caller mutates.\n const anchorPartial: PartialElement = {\n onKeyDown: (e: Event, node: ElementNode) =>\n (e as KeyboardEvent).key === \"Escape\" && hide(node),\n ...behavior<FloatingProps>(behaviorKey, attachFloating, {\n kind,\n openState,\n onDismiss,\n placement,\n content: props.content,\n keepOpenOnContentHover: !!props.keepOpenOnContentHover,\n }),\n };\n\n return { show, hide, anchorPartial };\n}\n\nexport { createFloating, floatingPanelId };\n","import {\n effect,\n type ReadableState,\n type State,\n type ValueOrState,\n toState,\n} from \"@domphy/core\";\n\nexport function isWritableState<T>(\n source: ReadableState<T>,\n): source is State<T> {\n return typeof (source as State<T>).set === \"function\";\n}\n\n/**\n * Subscribe to overlay `open`. Writable State uses `addListener` (no\n * fabricated `.set()`, existing listenerCount-on-remove tests). Computed has\n * no `addListener` — `effect()` reads `get()`.\n *\n * `emitCurrent` (default true) delivers the value once on subscribe, matching\n * first-attach `update(state.get())`. Pass false when re-subscribing on a\n * reused node so a fresh uncontrolled `toState(false)` is not a caller close.\n */\nexport function subscribeOpen(\n source: ReadableState<boolean>,\n onChange: (open: boolean) => void,\n emitCurrent = true,\n): () => void {\n if (typeof (source as State<boolean>).addListener === \"function\") {\n if (emitCurrent) onChange(source.get());\n return (source as State<boolean>).addListener(onChange);\n }\n if (emitCurrent) {\n return effect(() => {\n onChange(source.get());\n });\n }\n let skipInitial = true;\n const release = effect(() => {\n const value = source.get();\n if (skipInitial) return;\n onChange(value);\n });\n skipInitial = false;\n return release;\n}\n\nexport function writeOpen(\n source: ReadableState<boolean>,\n value: boolean,\n): void {\n if (isWritableState(source)) source.set(value);\n}\n\nexport function dismissOpen(\n source: ReadableState<boolean>,\n onDismiss?: () => void,\n): void {\n onDismiss?.();\n writeOpen(source, false);\n}\n\nexport function asOpenState(\n open: ValueOrState<boolean> | undefined,\n): ReadableState<boolean> {\n return toState(open ?? false);\n}\n","import {\n behavior,\n type DomphyElement,\n ElementNode,\n type PartialElement,\n rawHtml,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst xSvg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M6.707 5.293l5.293 5.292l5.293 -5.292a1 1 0 0 1 1.414 1.414l-5.292 5.293l5.292 5.293a1 1 0 0 1 -1.414 1.414l-5.293 -5.292l-5.293 5.292a1 1 0 1 1 -1.414 -1.414l5.292 -5.293l-5.292 -5.293a1 1 0 0 1 1.414 -1.414\" /></svg>`;\n\n// Compact-chip chrome was bare `themeSpacing(U)` (catalog snapshots). Default\n// density is 1.5 (`light.densities[2]`, density.ts origin index 2). n = U / 1.5\n// keeps those pixels at default while dataDensity still scales. Height 6U must\n// stay below selectBox/combobox minHeight `(6 + 2d)U` or the chip fills the trigger.\nconst DEFAULT_DENSITY = 1.5;\nconst TAG_HEIGHT = 6 / DEFAULT_DENSITY;\nconst TAG_PAD_INLINE = 2.5 / DEFAULT_DENSITY;\nconst TAG_PAD_END_REMOVABLE = 1 / DEFAULT_DENSITY;\nconst TAG_REMOVE = 4 / DEFAULT_DENSITY;\nconst TAG_REMOVE_RADIUS = 1 / DEFAULT_DENSITY;\n\ntype TagRemoveProps = { removable: boolean };\n\n/**\n * Styles an inline chip/tag (rounded, bordered, optional remove button).\n * No host tag check; typically applied to a `<span>`. When `removable` is true,\n * a close button is inserted that removes the host node on click or Enter/Space.\n *\n * @hostTag span\n * @param props.color - Theme color for the chip background/border/text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @param props.removable - When true, renders a remove (x) button that removes the tag on click or Enter/Space. Optional. Defaults to `false`.\n * @example { span: \"Label\", $: [tag({ removable: true })] }\n */\nfunction tag(\n props: { color?: ValueOrState<ThemeColor>; removable?: boolean } = {},\n): PartialElement {\n const { removable = false } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n // _onInit would miss/orphan the button when a reused node is re-patched\n // with a flipped `removable`. behavior() attaches once and routes later\n // generations through update().\n ...behavior<TagRemoveProps>(\n \"tag-remove\",\n (node, initial) => {\n const removeHost = () => node.remove();\n const makeButton = (): DomphyElement<\"span\"> => ({\n span: rawHtml(xSvg),\n _key: \"tag-remove\",\n onClick: (e) => {\n (e as Event).stopPropagation();\n removeHost();\n },\n onKeyDown: (e) => {\n const event = e as KeyboardEvent;\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n event.stopPropagation();\n removeHost();\n },\n tabindex: 0,\n role: \"button\",\n ariaLabel: \"Remove\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n cursor: \"pointer\",\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_REMOVE_RADIUS),\n width: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_REMOVE),\n height: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_REMOVE),\n flexShrink: 0,\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-4\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n },\n });\n const findButton = () =>\n node.children.items.find(\n (item) => item instanceof ElementNode && item.key === \"tag-remove\",\n ) ?? null;\n // attach() runs from the host Mount hook, which fires BEFORE\n // render() walks children. Inserting with updateDom=true would\n // create a DOM node that render() then creates a second time.\n // First paint: list-only insert, let render() materialize it.\n // Later update(): the walk already finished, so mutate the live DOM.\n const sync = (next: TagRemoveProps, updateDom: boolean) => {\n const existing = findButton();\n if (next.removable && !existing) {\n node.children.insert(makeButton(), undefined, updateDom);\n } else if (!next.removable && existing) {\n node.children.remove(existing);\n }\n };\n sync(initial, false);\n return {\n update: (next) => sync(next, true),\n };\n },\n { removable },\n ),\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n whiteSpace: \"nowrap\",\n userSelect: \"none\",\n height: (listener) => themeSpacing(themeDensity(listener) * TAG_HEIGHT),\n paddingBlock: 0,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 999),\n paddingInlineStart: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_PAD_INLINE),\n paddingInlineEnd: (listener) =>\n themeSpacing(\n themeDensity(listener) *\n (removable ? TAG_PAD_END_REMOVABLE : TAG_PAD_INLINE),\n ),\n gap: themeSpacing(1.5),\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n },\n };\n}\n\nexport { tag };\n","import { merge, type PartialElement, toState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Command-palette container patch. Sets up a vertical flex column and provides a\n * shared `command` context (a query State) consumed by `commandSearch` and\n * `commandItem` descendants to filter the list. Typically applied to a `<div>`.\n *\n * @example { div: [...], $: [command()] }\n */\nfunction command(): PartialElement {\n return {\n // Group (not listbox): search input + option buttons share one container;\n // listbox forbids non-option children (aria-required-children).\n role: \"group\",\n ariaLabel: \"Commands\",\n _onSchedule: (_node, element) => {\n merge(element, {\n _context: {\n command: {\n query: toState(\"\"),\n },\n },\n });\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n },\n };\n}\n\n/**\n * Search input for a command palette. Wires the input's value into the parent\n * `command` context's query State so descendant `commandItem`s filter live.\n * Apply to an `<input>` element used inside a `command()`.\n *\n * @hostTag input\n * @param props.color - Base theme color tone. Defaults to \"neutral\".\n * @param props.accentColor - Accent color used for the focus border. Defaults to \"primary\".\n * @example { input: \"\", $: [commandSearch({ accentColor: \"primary\" })] }\n */\nfunction commandSearch(\n props: { color?: ThemeColor; accentColor?: ThemeColor } = {},\n): PartialElement {\n const { color = \"neutral\", accentColor = \"primary\" } = props;\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"commandSearch\" patch must use input tag`);\n }\n },\n _onMount: (node) => {\n const ctx = node.getContext(\"command\");\n if (!ctx) {\n console.warn(`\"commandSearch\" patch must be used inside a \"command\"`);\n return;\n }\n const input = node.domElement as HTMLInputElement;\n const onInput = () => ctx.query.set(input.value);\n input.addEventListener(\"input\", onInput);\n node.addHook(\"Remove\", () => input.removeEventListener(\"input\", onInput));\n },\n style: {\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n border: \"none\",\n borderBottom: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color)}`,\n outline: \"none\",\n color: (listener) => themeColor(listener, \"shift-10\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n \"&::placeholder\": {\n color: (listener) => themeColor(listener, \"shift-7\"),\n },\n transition: \"border-bottom-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n borderBottomColor: (listener) =>\n themeColor(listener, \"shift-6\", accentColor),\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n },\n };\n}\n\n/**\n * Selectable item in a command palette. On mount, immediately hides itself if\n * the current query doesn't match its text content, and subscribes to future\n * query changes — so items added dynamically after a search is typed are\n * correctly filtered. Typically applied to a `<button>` (or any clickable\n * element) used inside a `command()`. Uses native button semantics (not\n * `role=option`) so the search input may sit as a sibling without a listbox\n * parent requirement.\n *\n * @param props.color - Base theme color tone. Defaults to \"neutral\".\n * @param props.accentColor - Accent color used for the focus ring. Defaults to \"primary\".\n * @example { button: \"Open file\", $: [commandItem({ color: \"neutral\" })] }\n */\nfunction commandItem(\n props: { color?: ThemeColor; accentColor?: ThemeColor } = {},\n): PartialElement {\n const { color = \"neutral\", accentColor = \"primary\" } = props;\n return {\n _onMount: (node) => {\n const ctx = node.getContext(\"command\");\n if (!ctx) {\n console.warn(`\"commandItem\" patch must be used inside a \"command\"`);\n return;\n }\n const el = node.domElement as HTMLElement;\n const text = el.textContent?.toLowerCase() ?? \"\";\n const applyFilter = (q: string) => {\n el.hidden = q.length > 0 && !text.includes(q.toLowerCase());\n };\n applyFilter(ctx.query.get());\n const release = ctx.query.addListener(applyFilter);\n node.addHook(\"Remove\", release);\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n width: \"100%\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n border: \"none\",\n outline: \"none\",\n // shift-13: menu-row labels need ≥4.5:1 on light surface (visual catalog).\n color: (listener) => themeColor(listener, \"shift-13\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled])\": {\n color: (listener) => themeColor(listener, \"shift-13\", color),\n backgroundColor: (listener) => themeColor(listener, \"hover\", color),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n },\n };\n}\n\nexport { command, commandSearch, commandItem };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n type Listener,\n merge,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** A single date selection, or a `[start, end]` tuple in range mode. */\nexport type DatePickerValue = Date | null | [Date | null, Date | null];\n\nexport interface DatePickerProps {\n /** Controlled value: a `Date` in single mode, a `[start, end]` tuple in range mode. */\n value?: ValueOrState<DatePickerValue>;\n /** Selection mode. */\n mode?: \"single\" | \"range\";\n /** Also pick hour + minute. The chosen time applies to the selected date(s). */\n time?: boolean;\n /** Earliest selectable day (inclusive). */\n min?: Date;\n /** Latest selectable day (inclusive). */\n max?: Date;\n /** Disable arbitrary days. */\n disabledDate?: (date: Date) => boolean;\n /** BCP-47 locale for month/weekday names, first-day-of-week, and formatting. */\n locale?: string;\n /** Override the first day of the week (0 = Sunday … 6 = Saturday). */\n weekStartsOn?: number;\n /** Override the input display string. */\n format?: (value: DatePickerValue) => string;\n /** Called whenever the selection changes. */\n onChange?: (value: DatePickerValue) => void;\n /** Accent color for the selected/active days. */\n accentColor?: ValueOrState<ThemeColor>;\n /** Popover placement relative to the input. */\n placement?: ValueOrState<Placement>;\n}\n\n// --- date helpers (no third-party library) -----------------------------------\n\nconst atMidnight = (date: Date): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate());\nconst addDays = (date: Date, count: number): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate() + count);\nconst addMonths = (date: Date, count: number): Date =>\n new Date(date.getFullYear(), date.getMonth() + count, date.getDate());\nconst sameDay = (a: Date | null, b: Date | null): boolean =>\n !!a &&\n !!b &&\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate();\nconst isoOf = (date: Date): string =>\n `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, \"0\")}-${String(\n date.getDate(),\n ).padStart(2, \"0\")}`;\nconst startOfWeek = (date: Date, weekStart: number): Date =>\n addDays(date, -((date.getDay() - weekStart + 7) % 7));\n\n/** Resolves the locale's first day of week, falling back to Sunday. */\nfunction localeWeekStart(locale: string): number {\n try {\n const localeObject = new Intl.Locale(locale) as Intl.Locale & {\n weekInfo?: { firstDay: number };\n getWeekInfo?: () => { firstDay: number };\n };\n const info = localeObject.getWeekInfo?.() ?? localeObject.weekInfo;\n if (info?.firstDay) return info.firstDay % 7; // Intl uses 1=Mon … 7=Sun\n } catch {\n // unsupported locale or engine — fall through to Sunday\n }\n return 0;\n}\n\n// --- per-node state preservation (reused-node lifecycle) -------------------\n\ntype DatePickerStates = {\n selection: State<DatePickerValue>;\n // When the caller passed `value`, each generation's toState(Date) is a\n // new object whose current value IS the caller's Date — copying the\n // previous internal selection onto it would overwrite that Date.\n selectionIsCallerOwned: boolean;\n viewYear: State<number>;\n viewMonth: State<number>;\n focused: State<Date>;\n hovered: State<Date | null>;\n hour: State<number>;\n minute: State<number>;\n open: State<boolean>;\n onChange?: (value: DatePickerValue) => void;\n};\n\n// Every ancestor re-render re-invokes datePicker() on the SAME reused input\n// node, allocating a fresh set of internal states with INITIAL values —\n// without carry-forward the user's uncontrolled selection, calendar view and\n// time silently reset on the next re-render, and the onChange subscription\n// (wired to the first generation's selection object) goes stale. ONE\n// behavior instance per node copies the live values into each new\n// generation's states (update() runs during patch(), before the fresh\n// input/calendar bindings evaluate) and keeps exactly one onChange\n// subscription on the CURRENT generation's selection.\nfunction attachDatePicker(\n _node: ElementNode,\n initialProps: DatePickerStates,\n): BehaviorInstance<DatePickerStates> {\n let current = initialProps;\n let releaseOnChange: (() => void) | null = null;\n const subscribe = (props: DatePickerStates) => {\n releaseOnChange?.();\n releaseOnChange = props.onChange\n ? props.selection.addListener((value) => props.onChange!(value))\n : null;\n };\n const carryForward = (next: State<any>, prev: State<any>) => {\n if (next !== prev) next.set(prev.get());\n };\n subscribe(current);\n return {\n update(next) {\n if (!next.selectionIsCallerOwned) {\n carryForward(next.selection, current.selection);\n }\n carryForward(next.viewYear, current.viewYear);\n carryForward(next.viewMonth, current.viewMonth);\n carryForward(next.focused, current.focused);\n carryForward(next.hovered, current.hovered);\n carryForward(next.hour, current.hour);\n carryForward(next.minute, current.minute);\n carryForward(next.open, current.open);\n if (\n next.selection !== current.selection ||\n next.onChange !== current.onChange\n ) {\n // Re-subscribe AFTER the carry-forward so it never fires onChange.\n subscribe(next);\n }\n current = next;\n },\n destroy() {\n releaseOnChange?.();\n releaseOnChange = null;\n },\n };\n}\n\n/**\n * A native, themeable date picker patch for an `<input>`. Opens a calendar\n * popover (rendered with Domphy elements, positioned via `@domphy/floating`)\n * supporting single/range selection, optional time, min/max + disabled days,\n * localized names, and keyboard navigation. The input is read-only and shows the\n * formatted selection; compose with `inputText()` for the input's look.\n *\n * @hostTag input\n * @param props.value - Controlled value (`ValueOrState<DatePickerValue>`): a `Date`/`null` in single mode, a `[start, end]` tuple in range mode.\n * @param props.mode - Selection mode, \"single\" | \"range\". Defaults to \"single\".\n * @param props.time - When true, also pick hour + minute (applied to the selected date(s)). Defaults to false.\n * @param props.min - Earliest selectable day (inclusive), a `Date`.\n * @param props.max - Latest selectable day (inclusive), a `Date`.\n * @param props.disabledDate - Predicate `(date: Date) => boolean` to disable arbitrary days.\n * @param props.locale - BCP-47 locale for names/first-day-of-week/formatting. Defaults to `navigator.language` (or \"en-US\" in non-browser).\n * @param props.weekStartsOn - Override first day of week (0 = Sunday … 6 = Saturday). Defaults to the locale's first day.\n * @param props.format - Override the input display string, `(value: DatePickerValue) => string`.\n * @param props.onChange - Called with the new value whenever the selection changes, `(value: DatePickerValue) => void`.\n * @param props.accentColor - Accent color (`ValueOrState<ThemeColor>`) for selected/active days. Defaults to \"primary\".\n * @param props.placement - Popover placement (`ValueOrState<Placement>`) relative to the input. Defaults to \"bottom-start\".\n * @example { input: \"\", $: [inputText(), datePicker({ mode: \"range\" })] }\n */\nfunction datePicker(props: DatePickerProps = {}): PartialElement {\n const {\n mode = \"single\",\n time = false,\n min,\n max,\n disabledDate,\n locale = typeof navigator !== \"undefined\" ? navigator.language : \"en-US\",\n format,\n onChange,\n } = props;\n\n const weekStart = props.weekStartsOn ?? localeWeekStart(locale);\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n const placeState = toState(props.placement ?? \"bottom-start\");\n\n const selection = toState<DatePickerValue>(\n props.value ?? (mode === \"range\" ? [null, null] : null),\n );\n\n const primaryDate = ((): Date => {\n const current = selection.get();\n const base =\n mode === \"range\" ? (current as [Date | null, Date | null])?.[0] : current;\n return base instanceof Date ? base : new Date();\n })();\n\n const viewYear = toState(primaryDate.getFullYear(), \"viewYear\");\n const viewMonth = toState(primaryDate.getMonth(), \"viewMonth\");\n const focused = toState<Date>(atMidnight(primaryDate), \"focused\");\n const hovered = toState<Date | null>(null, \"hovered\");\n const hour = toState(primaryDate.getHours(), \"hour\");\n const minute = toState(primaryDate.getMinutes(), \"minute\");\n\n // --- formatting -----------------------------------------------------------\n const dateFormatter = new Intl.DateTimeFormat(locale, {\n dateStyle: \"medium\",\n ...(time ? { timeStyle: \"short\" as const } : {}),\n });\n const monthFormatter = new Intl.DateTimeFormat(locale, {\n month: \"long\",\n year: \"numeric\",\n });\n const weekdayFormatter = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n });\n const fullDateFormatter = new Intl.DateTimeFormat(locale, {\n dateStyle: \"full\",\n });\n\n const formatOne = (date: Date | null): string =>\n date ? dateFormatter.format(date) : \"\";\n const formatDisplay = (value: DatePickerValue): string => {\n if (format) return format(value);\n if (mode === \"range\") {\n const [start, end] = (value as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n return start ? `${formatOne(start)} – ${formatOne(end)}` : \"\";\n }\n return formatOne(value as Date | null);\n };\n\n // 2023-01-01 is a Sunday, so index 0 maps to Sunday before the week-start shift.\n const weekdayNames = Array.from({ length: 7 }, (_unused, index) =>\n weekdayFormatter.format(new Date(2023, 0, 1 + ((index + weekStart) % 7))),\n );\n\n // --- selection logic ------------------------------------------------------\n const isDisabled = (date: Date): boolean =>\n (!!min && atMidnight(date) < atMidnight(min)) ||\n (!!max && atMidnight(date) > atMidnight(max)) ||\n (!!disabledDate && disabledDate(date));\n\n const withTime = (date: Date): Date => {\n if (!time) return atMidnight(date);\n const result = atMidnight(date);\n result.setHours(hour.get(), minute.get(), 0, 0);\n return result;\n };\n\n const selectDate = (date: Date, node?: ElementNode): void => {\n if (isDisabled(date)) return;\n if (mode === \"single\") {\n selection.set(withTime(date));\n // Close via the cell's node: the floating behavior instance is\n // registered on the panel node (floating.ts), so getBehavior's\n // ancestor walk from any panel descendant resolves it.\n if (!time) hide(node);\n return;\n }\n const [start, end] = (selection.get() as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n if (!start || (start && end)) {\n selection.set([withTime(date), null]);\n } else if (atMidnight(date) < atMidnight(start)) {\n selection.set([withTime(date), withTime(start)]);\n if (!time) hide(node);\n } else {\n selection.set([start, withTime(date)]);\n if (!time) hide(node);\n }\n };\n\n const reapplyTime = (): void => {\n if (!time) return;\n if (mode === \"single\") {\n const current = selection.get() as Date | null;\n if (current) selection.set(withTime(current));\n } else {\n const [start, end] = (selection.get() as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n selection.set([\n start ? withTime(start) : start,\n end ? withTime(end) : end,\n ]);\n }\n };\n\n const inSelectedRange = (date: Date, listener?: Listener): boolean => {\n if (mode !== \"range\") return false;\n const [start, end] = (selection.get(listener) as [\n Date | null,\n Date | null,\n ]) ?? [null, null];\n const tail = end ?? hovered.get(listener);\n if (!start || !tail) return false;\n const low = atMidnight(start) <= atMidnight(tail) ? start : tail;\n const high = atMidnight(start) <= atMidnight(tail) ? tail : start;\n const day = atMidnight(date);\n return day >= atMidnight(low) && day <= atMidnight(high);\n };\n\n const isSelectedEnd = (date: Date, listener?: Listener): boolean => {\n const current = selection.get(listener);\n if (mode === \"range\") {\n const [start, end] = (current as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n return sameDay(date, start) || sameDay(date, end);\n }\n return sameDay(date, current as Date | null);\n };\n\n // --- view navigation ------------------------------------------------------\n const goToDate = (date: Date): void => {\n viewYear.set(date.getFullYear());\n viewMonth.set(date.getMonth());\n };\n const shiftMonth = (delta: number): void => {\n const next = addMonths(new Date(viewYear.get(), viewMonth.get(), 1), delta);\n goToDate(next);\n };\n const shiftYear = (delta: number): void =>\n viewYear.set(viewYear.get() + delta);\n\n const focusActiveCell = (node?: ElementNode): void => {\n // Resolve the panel from the caller's live node (trigger or grid cell):\n // the old factory-scope `contentElement` was only ever assigned by the\n // first panel generation's _onMount, so later generations (reused node,\n // fresh closure) could never move focus into the grid.\n const root = node?.getRoot()?.domElement;\n setTimeout(() => {\n root\n ?.querySelector<HTMLElement>(`[data-date=\"${isoOf(focused.get())}\"]`)\n ?.focus();\n }, 0);\n };\n\n // --- floating popover ------------------------------------------------------\n const calendar = buildCalendar();\n const openState = toState(false);\n const { show, hide, anchorPartial } = createFloating({\n kind: \"datePicker\",\n open: openState,\n placement: placeState,\n content: calendar,\n });\n\n // Move focus into the grid when the popover opens.\n const triggerPartial: PartialElement = {\n type: \"text\",\n readonly: true,\n value: (listener) => formatDisplay(selection.get(listener)),\n role: \"combobox\",\n ariaHaspopup: \"dialog\",\n ariaExpanded: (listener) => openState.get(listener),\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"datePicker\", listener.elementNode)\n : undefined,\n ariaLabel: \"Choose date\",\n style: { cursor: \"pointer\" },\n onClick: (_e, node) => {\n openAndFocus(node);\n },\n onFocus: (_e, node) => {\n openAndFocus(node);\n },\n onKeyDown: (event, node) => {\n const key = (event as KeyboardEvent).key;\n if (key === \"ArrowDown\" || key === \"Enter\") {\n event.preventDefault();\n openAndFocus(node);\n }\n },\n ...behavior<DatePickerStates>(\"datePicker\", attachDatePicker, {\n selection,\n selectionIsCallerOwned: props.value !== undefined,\n viewYear,\n viewMonth,\n focused,\n hovered,\n hour,\n minute,\n open: openState,\n onChange,\n }),\n };\n function openAndFocus(node?: ElementNode): void {\n const current = isSelectedPrimary() ?? new Date();\n focused.set(atMidnight(current));\n goToDate(current);\n show(node);\n focusActiveCell(node);\n }\n function isSelectedPrimary(): Date | null {\n const current = selection.get();\n if (mode === \"range\")\n return (current as [Date | null, Date | null])?.[0] ?? null;\n return (current as Date | null) ?? null;\n }\n merge(anchorPartial, triggerPartial);\n return anchorPartial;\n\n // --- calendar builder -----------------------------------------------------\n function buildCalendar(): DomphyElement<\"div\"> {\n const navButton = (label: string, ariaLabel: string, onClick: () => void) =>\n ({\n button: label,\n type: \"button\",\n ariaLabel,\n onClick,\n style: navButtonStyle(),\n }) as DomphyElement;\n\n const header: DomphyElement<\"div\"> = {\n div: [\n navButton(\"«\", \"Previous year\", () => shiftYear(-1)),\n navButton(\"‹\", \"Previous month\", () => shiftMonth(-1)),\n {\n div: (listener) =>\n monthFormatter.format(\n new Date(viewYear.get(listener), viewMonth.get(listener), 1),\n ),\n ariaLive: \"polite\",\n // Calendar chrome (month/year header), not prose — weight is part\n // of the widget's visual design, not the theme's type scale.\n _doctorDisable: \"inline-typography\",\n style: {\n flex: \"1\",\n textAlign: \"center\",\n fontWeight: \"bold\",\n fontSize: (listener) => themeSize(listener),\n },\n },\n navButton(\"›\", \"Next month\", () => shiftMonth(1)),\n navButton(\"»\", \"Next year\", () => shiftYear(1)),\n ],\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(1),\n marginBottom: themeSpacing(2),\n },\n };\n\n const weekdayHeader: DomphyElement<\"div\"> = {\n div: weekdayNames.map((name, index) => ({\n div: name,\n // Calendar chrome (weekday column labels) — weight is widget design,\n // not theme typography.\n _doctorDisable: \"inline-typography\",\n style: {\n textAlign: \"center\",\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n fontWeight: \"bold\",\n color: (listener) => themeColor(listener, \"shift-7\"),\n paddingBlock: themeSpacing(1),\n },\n _key: index,\n })),\n role: \"row\",\n style: gridRowStyle(),\n };\n\n const grid: DomphyElement<\"div\"> = {\n div: (listener) => buildWeeks(listener),\n role: \"grid\",\n ariaLabel: \"Calendar\",\n onKeyDown: onGridKey,\n onMouseLeave: () => mode === \"range\" && hovered.set(null),\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: themeSpacing(0.5),\n },\n };\n\n const children: DomphyElement[] = [header, weekdayHeader, grid];\n if (time) children.push(buildTimeRow());\n children.push(buildFooter());\n\n return {\n div: children,\n role: \"dialog\",\n ariaModal: \"false\",\n // Surface contract (same as popover/combobox): edge-anchor dataTone +\n // inherit background + \"text\" color. The previous `themeColor(l, \"base\")`\n // resolved to the ramp's MID anchor (var(--neutral-8), gray) with text\n // only 2 tone steps away — an unreadable washed-out panel, invisible to\n // doctor because the calendar is mounted imperatively at runtime.\n dataTone: \"shift-14\",\n style: {\n minWidth: themeSpacing(70),\n padding: themeSpacing(3),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n }\n\n function buildWeeks(listener: Listener): DomphyElement[] {\n const first = new Date(viewYear.get(listener), viewMonth.get(listener), 1);\n const month = viewMonth.get(listener);\n const start = startOfWeek(first, weekStart);\n const weeks: DomphyElement[] = [];\n for (let week = 0; week < 6; week++) {\n const cells: DomphyElement[] = [];\n for (let day = 0; day < 7; day++) {\n const date = addDays(start, week * 7 + day);\n cells.push(buildDayCell(date, month, listener));\n }\n weeks.push({\n div: cells,\n role: \"row\",\n style: gridRowStyle(),\n _key: week,\n });\n }\n return weeks;\n }\n\n function buildDayCell(\n date: Date,\n month: number,\n listener: Listener,\n ): DomphyElement {\n const disabled = isDisabled(date);\n const selected = isSelectedEnd(date, listener);\n const within = inSelectedRange(date, listener);\n const outside = date.getMonth() !== month;\n const isFocused = sameDay(date, focused.get(listener));\n const isToday = sameDay(date, new Date());\n\n return {\n button: String(date.getDate()),\n type: \"button\",\n role: \"gridcell\",\n tabIndex: isFocused ? 0 : -1,\n ariaSelected: selected,\n ariaDisabled: disabled,\n disabled,\n ariaLabel: fullDateFormatter.format(date),\n dataDate: isoOf(date),\n onClick: (_e: Event, node: ElementNode) => selectDate(date, node),\n onMouseEnter: () => mode === \"range\" && hovered.set(date),\n style: {\n appearance: \"none\",\n border: \"none\",\n cursor: disabled ? \"not-allowed\" : \"pointer\",\n aspectRatio: \"1\",\n borderRadius: themeSpacing(1),\n fontSize: (l: Listener) => themeSize(l),\n fontFamily: \"inherit\",\n opacity: disabled ? 0.35 : outside ? 0.5 : 1,\n backgroundColor: (l: Listener) =>\n selected\n ? themeColor(l, \"shift-7\", accentColor.get(l))\n : within\n ? themeColor(l, \"hover\", accentColor.get(l))\n : \"transparent\",\n color: (l: Listener) =>\n selected\n ? themeColor(l, \"shift-0\", accentColor.get(l))\n : themeColor(l, \"text\"),\n outline: isToday\n ? (l: Listener) =>\n `1px solid ${themeColor(l, \"shift-6\", accentColor.get(l))}`\n : \"none\",\n outlineOffset: \"-2px\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (l: Listener) =>\n selected\n ? themeColor(l, \"shift-7\", accentColor.get(l))\n : themeColor(l, \"shift-3\", accentColor.get(l)),\n },\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor.get(l)),\n },\n },\n _key: isoOf(date),\n } as DomphyElement;\n }\n\n function buildTimeRow(): DomphyElement<\"div\"> {\n const numberSelect = (\n count: number,\n state: ReturnType<typeof toState<number>>,\n ariaLabel: string,\n ): DomphyElement => ({\n select: Array.from({ length: count }, (_unused, value) => ({\n option: String(value).padStart(2, \"0\"),\n value: String(value),\n selected: (listener) => state.get(listener) === value,\n _key: value,\n })) as DomphyElement[],\n ariaLabel,\n onChange: (event) => {\n state.set(Number((event.target as HTMLSelectElement).value));\n reapplyTime();\n },\n style: timeSelectStyle(),\n });\n\n return {\n div: [\n numberSelect(24, hour, \"Hour\"),\n // Time separator glyph — widget chrome, not prose.\n {\n span: \":\",\n _doctorDisable: \"inline-typography\",\n style: { fontWeight: \"bold\" },\n },\n numberSelect(60, minute, \"Minute\"),\n ],\n style: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: themeSpacing(1),\n marginTop: themeSpacing(3),\n },\n };\n }\n\n function buildFooter(): DomphyElement<\"div\"> {\n const action = (\n label: string,\n onClick: (node: ElementNode) => void,\n ): DomphyElement => ({\n button: label,\n type: \"button\",\n onClick: (_e: Event, node: ElementNode) => onClick(node),\n style: {\n appearance: \"none\",\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n fontSize: (l: Listener) => themeSize(l, \"decrease-1\"),\n color: (l: Listener) => themeColor(l, \"muted\", accentColor.get(l)),\n padding: themeSpacing(1),\n },\n });\n return {\n div: [\n action(\"Today\", (node) => {\n const today = new Date();\n focused.set(atMidnight(today));\n goToDate(today);\n focusActiveCell(node);\n }),\n action(\"Clear\", () => {\n selection.set(mode === \"range\" ? [null, null] : null);\n hovered.set(null);\n }),\n ],\n style: {\n display: \"flex\",\n justifyContent: \"space-between\",\n marginTop: themeSpacing(2),\n paddingTop: themeSpacing(2),\n borderTop: (l: Listener) => `1px solid ${themeColor(l, \"border\")}`,\n },\n };\n }\n\n function onGridKey(event: Event, node: ElementNode): void {\n const keyboard = event as KeyboardEvent;\n const current = focused.get();\n let next: Date | null = null;\n switch (keyboard.key) {\n case \"ArrowLeft\":\n next = addDays(current, -1);\n break;\n case \"ArrowRight\":\n next = addDays(current, 1);\n break;\n case \"ArrowUp\":\n next = addDays(current, -7);\n break;\n case \"ArrowDown\":\n next = addDays(current, 7);\n break;\n case \"Home\":\n next = startOfWeek(current, weekStart);\n break;\n case \"End\":\n next = addDays(startOfWeek(current, weekStart), 6);\n break;\n case \"PageUp\":\n next = addMonths(current, keyboard.shiftKey ? -12 : -1);\n break;\n case \"PageDown\":\n next = addMonths(current, keyboard.shiftKey ? 12 : 1);\n break;\n case \"Enter\":\n case \" \":\n keyboard.preventDefault();\n selectDate(current, node);\n return;\n default:\n return;\n }\n keyboard.preventDefault();\n focused.set(next);\n goToDate(next);\n focusActiveCell(node);\n }\n}\n\n// --- shared style fragments --------------------------------------------------\n\nfunction gridRowStyle() {\n return {\n display: \"grid\",\n gridTemplateColumns: \"repeat(7, 1fr)\",\n gap: themeSpacing(0.5),\n };\n}\n\nfunction navButtonStyle() {\n return {\n appearance: \"none\" as const,\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n fontSize: (l: Listener) => themeSize(l),\n color: (l: Listener) => themeColor(l, \"muted\"),\n width: themeSpacing(7),\n height: themeSpacing(7),\n borderRadius: themeSpacing(1),\n \"&:hover\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\"),\n },\n };\n}\n\nfunction timeSelectStyle() {\n return {\n fontFamily: \"inherit\",\n fontSize: (l: Listener) => themeSize(l),\n padding: themeSpacing(1),\n borderRadius: themeSpacing(1),\n // outline, not border — bounded control, keep the geometry formula exact.\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (l: Listener) => `1px solid ${themeColor(l, \"border-strong\")}`,\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n color: (l: Listener) => themeColor(l, \"text\"),\n };\n}\n\nexport { datePicker };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a description list as a two-column grid (terms in the first column,\n * descriptions in the second), theming the nested `<dt>`/`<dd>` elements.\n * Apply to a `<dl>` element.\n *\n * @hostTag dl\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the term/description text. Defaults to \"neutral\".\n * @example { dl: [{ dt: \"Name\" }, { dd: \"Domphy\" }], $: [descriptionList()] }\n */\nfunction descriptionList(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"dl\") {\n console.warn(`\"descriptionList\" primitive patch must use dl tag`);\n }\n },\n // Term weight is design-system chrome for description lists.\n _doctorDisable: \"inline-typography\",\n style: {\n display: \"grid\",\n gridTemplateColumns: `minmax(${themeSpacing(24)}, max-content) 1fr`,\n columnGap: themeSpacing(4),\n margin: 0,\n \"& dt\": {\n margin: 0,\n fontWeight: 600,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n \"& dd\": {\n margin: 0,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n },\n };\n}\n\nexport { descriptionList };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native disclosure widget: a themed `<summary>` header with an\n * animated rotating chevron and an expand/collapse transition on the body\n * content. Apply to a `<details>` element.\n *\n * @hostTag details\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the body/summary. Defaults to \"neutral\".\n * @param props.accentColor - Accent color (`ValueOrState<ThemeColor>`) for the summary's focus ring. Defaults to \"primary\".\n * @param props.duration - Open/close transition duration in milliseconds. Defaults to 240.\n * @example { details: [{ summary: \"More\" }, { div: \"Body\" }], $: [details()] }\n */\nfunction details(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n duration?: number;\n } = {},\n): PartialElement {\n const { duration = 240 } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"details\") {\n console.warn(`\"details\" primitive patch must use details tag`);\n }\n },\n // Summary weight is design-system chrome for disclosure headers.\n _doctorDisable: \"inline-typography\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n\n overflow: \"hidden\",\n \"& > summary\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n listStyle: \"none\",\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n cursor: \"pointer\",\n userSelect: \"none\",\n fontWeight: 500,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n height: themeSpacing(10),\n },\n \"& > summary::-webkit-details-marker\": {\n display: \"none\",\n },\n \"& > summary::marker\": {\n content: `\"\"`,\n },\n \"& > summary::after\": {\n content: `\"\"`,\n width: themeSpacing(2),\n height: themeSpacing(2),\n flexShrink: 0,\n marginTop: themeSpacing(-0.5),\n borderInlineEnd: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-9\", color.get(listener))}`,\n borderBottom: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-9\", color.get(listener))}`,\n transform: \"rotate(45deg)\",\n transition: `transform ${duration}ms ease`,\n },\n \"&[open] > summary::after\": {\n transform: \"rotate(-135deg)\",\n },\n \"& > summary:hover\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", color.get(listener)),\n },\n \"& > summary:focus-visible\": {\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"& > :not(summary)\": {\n maxHeight: 0,\n opacity: 0,\n overflow: \"hidden\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingTop: 0,\n paddingBottom: 0,\n transition: `max-height ${duration}ms ease, opacity ${duration}ms ease, padding ${duration}ms ease`,\n },\n \"&[open] > :not(summary)\": {\n // Non-clipping open state: a bounded max-height here (previously\n // themeSpacing(250) ≈ 1000px) silently CUT OFF body content taller\n // than the cap while fully open. CSS cannot transition max-height\n // to/from `none`, so the open transition is carried by opacity +\n // padding (both still animate over `duration`); max-height jumps\n // straight to none and tall content is never clipped.\n maxHeight: \"none\",\n opacity: 1,\n paddingTop: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingBottom: (listener) => themeSpacing(themeDensity(listener) * 3),\n },\n },\n };\n}\n\nexport { details };\n","import {\n type BehaviorInstance,\n behavior,\n type ElementNode,\n type PartialElement,\n type ReadableState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport {\n asOpenState,\n dismissOpen,\n subscribeOpen,\n} from \"../utils/openState.js\";\nimport { lockScroll, unlockScroll } from \"../utils/scrollLock.js\";\n\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), details, [tabindex]:not([tabindex=\"-1\"])';\n\ntype DialogProps = {\n state: ReadableState<boolean>;\n // Lives on the behavior instance so a reused node gets the latest callback\n // via update() — do not close over factory-generation onDismiss.\n onDismiss?: () => void;\n};\n\ntype DialogInstance = BehaviorInstance<DialogProps> & {\n // Close via the instance's CURRENT state — routing through the behavior\n // guarantees the state being set is the one the open/close subscription\n // listens to, even when a re-rendered generation's closure would otherwise\n // set its own fresh (unsubscribed) default state.\n requestClose: () => void;\n onTransitionEnd: (e: Event) => void;\n};\n\n// All close-finalization state (closing flag, previousFocus, scrollLocked,\n// the fallback timer) lives in ONE behavior instance per dialog node. It used\n// to be factory-scope variables captured by _onMount — but _onMount runs once\n// for the FIRST generation only, while onTransitionEnd (live-rebound every\n// patch) belongs to the LATEST generation: gen-1's update() set gen-1's\n// `closing = true` and the live gen-N handler read gen-N's `closing` (false)\n// and early-returned, so every close fell back to the 350ms timer and focus\n// restore scrolled through stale closures. behavior() attaches once and\n// routes every later generation's props into the same instance (floating.ts\n// pattern).\nfunction attachDialog(\n node: ElementNode,\n initialProps: DialogProps,\n): DialogInstance {\n let { state, onDismiss } = initialProps;\n let previousFocus: HTMLElement | null = null;\n let closing = false;\n let scrollLocked = false;\n let closeTimer: ReturnType<typeof setTimeout> | null = null;\n\n const dlg = node.domElement as HTMLDialogElement;\n dlg.setAttribute(\"aria-modal\", \"true\");\n\n const finalizeClose = () => {\n closing = false;\n // Guard for environments with HTMLDialogElement but no close()\n // implementation (e.g. jsdom in tests).\n if (typeof dlg.close === \"function\") dlg.close();\n // visibility/pointer-events/display (not just opacity) must reflect the\n // closed state: opacity alone leaves a closed dialog's content fully\n // reachable by Tab and exposed to the accessibility tree (opacity, unlike\n // visibility, never removes an element from either) — and a consumer\n // that sets its own `style: { display: ... }` on the dialog (a common\n // pattern for centering content) overrides the UA stylesheet's\n // `dialog:not([open]) { display: none }`, so `dlg.close()` alone doesn't\n // reliably hide it either. visibility+pointer-events still leave the\n // node in the layout and in the document for password-managers / autofocus.\n // Set INLINE so it always wins regardless of what the consumer's own\n // style object declares. Do not put `display: none` on the patch CSS\n // class — native `style.display` would lose to that class on reopen.\n dlg.style.visibility = \"hidden\";\n dlg.style.pointerEvents = \"none\";\n dlg.style.display = \"none\";\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n previousFocus?.focus();\n previousFocus = null;\n };\n\n const trapFocus = (e: KeyboardEvent) => {\n if (e.key !== \"Tab\") return;\n const focusables = Array.from(\n dlg.querySelectorAll<HTMLElement>(FOCUSABLE),\n ).filter(\n (el) => !el.closest(\"[aria-hidden='true']\") && el.offsetParent !== null,\n );\n if (!focusables.length) {\n e.preventDefault();\n return;\n }\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n if (e.shiftKey) {\n if (document.activeElement === first || document.activeElement === dlg) {\n e.preventDefault();\n last.focus();\n }\n } else {\n if (document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n }\n };\n\n const onCancel = (e: Event) => {\n e.preventDefault();\n dismissOpen(state, onDismiss);\n };\n dlg.addEventListener(\"cancel\", onCancel);\n\n const update = (val: boolean) => {\n if (val) {\n // Cancel any in-flight close: a pending fallback timer or a true\n // `closing` flag left over from the previous close (e.g. reopening\n // within the 350ms window, or the mount-time close of an\n // initially-closed dialog) would otherwise finalize-close the\n // just-opened dialog on the open fade's own transitionend.\n closing = false;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n previousFocus = document.activeElement as HTMLElement;\n dlg.style.visibility = \"visible\";\n dlg.style.pointerEvents = \"auto\";\n // Drop the closed-state inline display so the consumer's own\n // `style.display` (or the UA open-dialog rule) can apply.\n dlg.style.display = \"\";\n // Guard for environments with HTMLDialogElement but no showModal()\n // implementation (e.g. jsdom in tests). Also guard against re-entering\n // on an already-open dialog — showModal() throws InvalidStateError in\n // real browsers when the dialog is already open.\n if (typeof dlg.showModal === \"function\" && !dlg.open) dlg.showModal();\n if (!scrollLocked) {\n lockScroll();\n scrollLocked = true;\n }\n dlg.addEventListener(\"keydown\", trapFocus);\n requestAnimationFrame(() => {\n dlg.style.opacity = \"1\";\n const focusable = dlg.querySelector<HTMLElement>(FOCUSABLE);\n focusable?.focus();\n });\n } else {\n closing = true;\n dlg.style.opacity = \"0\";\n dlg.removeEventListener(\"keydown\", trapFocus);\n // Mounted already-closed (never opened): no fade to play — hide now\n // so a consumer `display: flex` cannot keep the closed node in layout\n // for the 350ms timer (or forever, if transitionend also never fires).\n if (!dlg.open) {\n finalizeClose();\n return;\n }\n // Fallback: if transitionend never fires (reduced-motion, display:none),\n // unblock close after the transition duration + buffer.\n closeTimer = setTimeout(() => {\n closeTimer = null;\n if (!closing) return;\n finalizeClose();\n }, 350);\n }\n };\n let release = subscribeOpen(state, update);\n\n return {\n requestClose: () => dismissOpen(state, onDismiss),\n onTransitionEnd: (e: Event) => {\n if (!closing) return;\n // Guard against bubbled transitionend from nested content (e.g. an\n // accordion/details transition inside the dialog) prematurely\n // triggering close-finalization.\n if (e.target !== dlg) return;\n if ((e as TransitionEvent).propertyName !== \"opacity\") return;\n finalizeClose();\n },\n update(props) {\n onDismiss = props.onDismiss;\n // Re-subscribe when a later generation brings a genuinely different\n // state object (e.g. the default `toState(false)` allocated per\n // factory call); a caller-owned state arrives as the SAME object and\n // keeps its existing subscription untouched.\n if (props.state !== state) {\n release();\n state = props.state;\n release = subscribeOpen(state, update, false);\n }\n },\n destroy() {\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n release();\n dlg.removeEventListener(\"cancel\", onCancel);\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n dlg.removeEventListener(\"keydown\", trapFocus);\n previousFocus?.focus();\n previousFocus = null;\n },\n };\n}\n\n/**\n * Modal dialog patch driven by an `open` State. Calls `showModal()`/`close()`,\n * fades via opacity, locks page scroll while open, traps Tab focus within the\n * dialog, restores focus to the previously focused element on close, sets\n * `aria-modal`, and closes on outside (backdrop) click. Apply to a `<dialog>`.\n * Closed state is inline `visibility`/`pointer-events`/`display:none` so a\n * consumer `style.display` cannot keep the node in layout.\n *\n * Accessible name/description: pass `labelledBy`/`describedBy` the `id` of a\n * heading/paragraph inside the dialog (Radix Title/Description parity). The\n * native `ariaLabelledby`/`ariaDescribedby` attributes on the host element\n * remain an equivalent escape hatch (the native element always wins).\n *\n * @hostTag dialog\n * @param props.color - Theme color tone for the dialog surface. Defaults to \"neutral\".\n * @param props.open - Open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so Escape/backdrop can close. Defaults to false.\n * @param props.onDismiss - Called when Escape/backdrop/`requestClose` request close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.labelledBy - `id` of the element labeling the dialog (wired to `aria-labelledby`). Optional.\n * @param props.describedBy - `id` of the element describing the dialog (wired to `aria-describedby`). Optional.\n * @example { dialog: [{ h2: \"Confirm\", id: \"dlg-title\" }], $: [dialog({ open, labelledBy: \"dlg-title\" })] }\n */\nfunction dialog(\n props: {\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n labelledBy?: string;\n describedBy?: string;\n } = {},\n): PartialElement {\n const {\n color = \"neutral\",\n open = false,\n labelledBy,\n describedBy,\n onDismiss,\n } = props;\n const state = asOpenState(open);\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"dialog\") {\n console.warn(`\"dialog\" primitive patch must use dialog tag`);\n }\n },\n ...behavior<DialogProps>(\"dialog\", attachDialog, { state, onDismiss }),\n ariaLabelledby: labelledBy,\n ariaDescribedby: describedBy,\n onClick: (e: MouseEvent, node) => {\n if (e.target !== node.domElement) return;\n const r = node.domElement!.getBoundingClientRect();\n const inside =\n e.clientX >= r.left &&\n e.clientX <= r.right &&\n e.clientY >= r.top &&\n e.clientY <= r.bottom;\n if (!inside) node.getBehavior<DialogInstance>(\"dialog\")?.requestClose();\n },\n onTransitionEnd: (e, node) =>\n node.getBehavior<DialogInstance>(\"dialog\")?.onTransitionEnd(e),\n style: {\n opacity: \"0\",\n // Matches finalizeClose's inline defaults — a dialog that mounts\n // already-closed (the common case: `open` defaults to false) must\n // start out of the tab order/accessibility tree from first paint, not\n // just after its first open->close cycle runs finalizeClose.\n visibility: \"hidden\",\n pointerEvents: \"none\",\n transition: \"opacity 200ms ease\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"shift-10\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n border: \"none\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n padding: (listener) => themeSpacing(themeDensity(listener) * 3),\n boxShadow: elevation(\"high\"),\n \"&::backdrop\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n opacity: 0.75,\n },\n },\n };\n}\n\nexport { dialog };\n","// Shared page-scroll lock for modal-like patches (dialog, drawer). A\n// module-level counter (not a plain boolean) is required because two\n// overlays can be open at once (e.g. a dialog opened from within a drawer);\n// without a counter, closing the inner one would clear `overflow` while the\n// outer one is still open.\nlet lockCount = 0;\n\nfunction lockScroll(): void {\n lockCount++;\n if (lockCount === 1) document.body.style.overflow = \"hidden\";\n}\n\nfunction unlockScroll(): void {\n lockCount = Math.max(0, lockCount - 1);\n if (lockCount === 0) document.body.style.overflow = \"\";\n}\n\n// Test-only: reset the module-level counter so a test that unmounts its tree\n// via `document.body.innerHTML = \"\"` (skipping the Remove hook / unlockScroll\n// call) doesn't leak a locked count into the next test.\nfunction _resetScrollLock(): void {\n lockCount = 0;\n}\n\nexport { lockScroll, unlockScroll, _resetScrollLock };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A horizontal separator (`role=\"separator\"`) with a line on each side of its\n * content, suitable for labelled dividers (\"or\"). Apply to a `<div>` element.\n *\n * @hostTag div\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the label text and rules. Defaults to \"neutral\".\n * @example { div: \"or\", $: [divider()] }\n */\nfunction divider(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n role: \"separator\",\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"divider\" patch should be used with <div>`);\n }\n },\n style: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"baseline\",\n gap: themeSpacing(2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n minHeight: \"1lh\",\n \"&::before\": {\n content: `\"\"`,\n flex: 1,\n borderColor: (listener) =>\n themeColor(listener, \"border-strong\", color.get(listener)),\n borderWidth: \"1px\",\n borderBottomStyle: \"solid\",\n },\n \"&::after\": {\n content: `\"\"`,\n flex: 1,\n borderColor: (listener) =>\n themeColor(listener, \"border-strong\", color.get(listener)),\n borderWidth: \"1px\",\n borderBottomStyle: \"solid\",\n },\n },\n };\n}\n\nexport { divider };\n","import {\n type BehaviorInstance,\n behavior,\n type ElementNode,\n type PartialElement,\n type ReadableState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport {\n asOpenState,\n dismissOpen,\n subscribeOpen,\n} from \"../utils/openState.js\";\nimport { lockScroll, unlockScroll } from \"../utils/scrollLock.js\";\n\ntype PhysicalPlacement = \"left\" | \"right\" | \"top\" | \"bottom\";\ntype Placement = PhysicalPlacement | \"start\" | \"end\";\n\nconst translateOut: Record<PhysicalPlacement, string> = {\n left: \"translateX(-100%)\",\n right: \"translateX(100%)\",\n top: \"translateY(-100%)\",\n bottom: \"translateY(100%)\",\n};\n\nconst marginMap: Record<PhysicalPlacement, string> = {\n left: \"0 auto 0 0\",\n right: \"0 0 0 auto\",\n top: \"0 0 auto 0\",\n bottom: \"auto 0 0 0\",\n};\n\nconst isVertical = (p: PhysicalPlacement) => p === \"left\" || p === \"right\";\n\nfunction resolvePhysical(\n placement: Placement,\n isRTL: boolean,\n): PhysicalPlacement {\n if (placement === \"start\") return isRTL ? \"right\" : \"left\";\n if (placement === \"end\") return isRTL ? \"left\" : \"right\";\n return placement;\n}\n\ntype DrawerProps = {\n state: ReadableState<boolean>;\n // Lives on the behavior instance so a reused node gets the latest callback\n // via update() — do not close over factory-generation onDismiss.\n onDismiss?: () => void;\n placement: Placement;\n size?: string;\n};\n\ntype DrawerInstance = BehaviorInstance<DrawerProps> & {\n requestClose: () => void;\n};\n\nfunction attachDrawer(\n node: ElementNode,\n initialProps: DrawerProps,\n): DrawerInstance {\n let { state, onDismiss, placement, size } = initialProps;\n\n const dlg = node.domElement as HTMLDialogElement;\n dlg.setAttribute(\"aria-modal\", \"true\");\n\n const onCancel = (e: Event) => {\n e.preventDefault();\n dismissOpen(state, onDismiss);\n };\n dlg.addEventListener(\"cancel\", onCancel);\n\n const resolve = (nextPlacement: Placement, nextSize?: string) => {\n const isLogical = nextPlacement === \"start\" || nextPlacement === \"end\";\n const isRTL =\n isLogical &&\n (dlg.ownerDocument.documentElement.dir === \"rtl\" ||\n dlg.ownerDocument.dir === \"rtl\");\n const physical = resolvePhysical(nextPlacement, isRTL);\n const drawerSize =\n nextSize ?? (isVertical(physical) ? themeSpacing(80) : themeSpacing(64));\n dlg.style.margin = marginMap[physical];\n dlg.style.width = isVertical(physical) ? drawerSize : \"100dvw\";\n dlg.style.height = isVertical(physical) ? \"100dvh\" : drawerSize;\n return physical;\n };\n\n let physical = resolve(placement, size);\n\n let closing = false;\n let scrollLocked = false;\n let closeTimer: ReturnType<typeof setTimeout> | null = null;\n\n const finishClose = () => {\n closeTimer = null;\n if (!closing) return;\n closing = false;\n // Guard for environments with HTMLDialogElement but no close()\n // implementation (e.g. jsdom in tests).\n if (typeof dlg.close === \"function\") dlg.close();\n // Same fix as dialog.ts: the closed state was only ever represented\n // by an off-screen `transform`, never visibility/pointer-events/display\n // — a closed drawer stayed fully reachable by Tab and exposed to the\n // accessibility tree (a CSS transform, like opacity, does neither),\n // and a consumer's own `style: { display: ... }` overrides the UA\n // stylesheet's `dialog:not([open])` rule anyway. Set INLINE so it\n // always wins. Do not put `display: none` on the patch CSS class —\n // native `style.display` would lose to that class on reopen.\n dlg.style.visibility = \"hidden\";\n dlg.style.pointerEvents = \"none\";\n dlg.style.display = \"none\";\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n };\n\n const onTransitionEnd = (e: Event) => {\n if (e.target !== dlg) return;\n if ((e as TransitionEvent).propertyName !== \"transform\") return;\n finishClose();\n };\n dlg.addEventListener(\"transitionend\", onTransitionEnd);\n\n const update = (val: boolean) => {\n if (val) {\n // Cancel any in-flight close: a pending fallback timer or a leftover\n // `closing` flag would otherwise finalize-close the just-opened drawer\n // when the open slide's own transitionend (or the 350ms timer) fires.\n closing = false;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n dlg.style.visibility = \"visible\";\n dlg.style.pointerEvents = \"auto\";\n dlg.style.display = \"\";\n // Guard for environments with HTMLDialogElement but no showModal()\n // implementation (e.g. jsdom in tests). Also guard against re-entering\n // on an already-open dialog — showModal() throws InvalidStateError in\n // real browsers when the dialog is already open.\n if (typeof dlg.showModal === \"function\" && !dlg.open) dlg.showModal();\n if (!scrollLocked) {\n lockScroll();\n scrollLocked = true;\n }\n requestAnimationFrame(() => {\n dlg.style.transform = \"translate(0, 0)\";\n });\n } else {\n closing = true;\n dlg.style.transform = translateOut[physical];\n if (!dlg.open) {\n finishClose();\n return;\n }\n closeTimer = setTimeout(finishClose, 350);\n }\n };\n let release = subscribeOpen(state, update);\n\n return {\n requestClose: () => dismissOpen(state, onDismiss),\n update(props) {\n onDismiss = props.onDismiss;\n if (props.state !== state) {\n release();\n state = props.state;\n release = subscribeOpen(state, update, false);\n }\n if (props.placement !== placement || props.size !== size) {\n placement = props.placement;\n size = props.size;\n physical = resolve(placement, size);\n if (!state.get()) dlg.style.transform = translateOut[physical];\n }\n },\n destroy() {\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n release();\n dlg.removeEventListener(\"cancel\", onCancel);\n dlg.removeEventListener(\"transitionend\", onTransitionEnd);\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n },\n };\n}\n\n/**\n * Edge-anchored modal drawer driven by an `open` State. Slides in/out from a\n * chosen edge via a 250 ms transform transition, calls `showModal()`/`close()`,\n * locks page scroll while open, and closes on backdrop click. A 350 ms fallback\n * ensures `close()` is always called even when `transitionend` doesn't fire\n * (reduced-motion, `display:none`, detached element). Apply to a `<dialog>`.\n *\n * Because the patch uses the native `<dialog>` `showModal()` API, the browser\n * traps focus inside the drawer while it is open and restores focus to the\n * previously focused element when `close()` is called. Sets `aria-modal=\"true\"`.\n * Escape key closes the drawer via the animated state path (not immediate close).\n *\n * `\"start\"` and `\"end\"` placements resolve to left/right based on the\n * document's `dir` attribute at mount time, enabling RTL-aware drawers:\n * `\"start\"` → left (LTR) / right (RTL); `\"end\"` → right (LTR) / left (RTL).\n *\n * @hostTag dialog\n * @param props.color - Theme color tone for the drawer surface. Defaults to \"neutral\".\n * @param props.open - Open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so Escape/backdrop can close. Defaults to false.\n * @param props.onDismiss - Called when Escape/backdrop/`requestClose` request close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.placement - Edge to anchor to. \"left\" | \"right\" | \"top\" | \"bottom\" | \"start\" | \"end\". Defaults to \"end\".\n * @param props.size - CSS length for the drawer's width (left/right/start/end) or height (top/bottom). Defaults to themeSpacing(80) for left/right, themeSpacing(64) for top/bottom.\n * @example { dialog: [...], $: [drawer({ open, placement: \"start\" })] }\n */\nfunction drawer(\n props: {\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement?: Placement;\n size?: string;\n } = {},\n): PartialElement {\n const {\n color = \"neutral\",\n open = false,\n onDismiss,\n placement = \"end\",\n size,\n } = props;\n const state = asOpenState(open);\n\n // For static rendering / SSR assume LTR as fallback; corrected at mount time.\n const physicalFallback = resolvePhysical(placement, false);\n const defaultSize = isVertical(physicalFallback)\n ? themeSpacing(80)\n : themeSpacing(64);\n const drawerSize = size ?? defaultSize;\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"dialog\") {\n console.warn(`\"drawer\" patch must use dialog tag`);\n }\n },\n ...behavior<DrawerProps>(\"drawer\", attachDrawer, {\n state,\n onDismiss,\n placement,\n size,\n }),\n onClick: (e: MouseEvent, node) => {\n if (e.target !== node.domElement) return;\n const r = node.domElement!.getBoundingClientRect();\n const inside =\n e.clientX >= r.left &&\n e.clientX <= r.right &&\n e.clientY >= r.top &&\n e.clientY <= r.bottom;\n if (!inside) node.getBehavior<DrawerInstance>(\"drawer\")?.requestClose();\n },\n style: {\n transform: translateOut[physicalFallback],\n // Matches finishClose's inline defaults — a drawer that mounts\n // already-closed (the common case) must start out of the tab\n // order/accessibility tree from first paint, not just after its first\n // open->close cycle runs finishClose.\n visibility: \"hidden\",\n pointerEvents: \"none\",\n transition: \"transform 0.25s ease\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"shift-10\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n border: \"none\",\n padding: (listener) => themeSpacing(themeDensity(listener) * 3),\n margin: marginMap[physicalFallback],\n width: isVertical(physicalFallback) ? drawerSize : \"100dvw\",\n height: isVertical(physicalFallback) ? \"100dvh\" : drawerSize,\n maxWidth: \"100dvw\",\n maxHeight: \"100dvh\",\n boxShadow: elevation(\"high\"),\n \"&::backdrop\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n opacity: 0.75,\n },\n },\n };\n}\n\nexport { drawer };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Italic emphasized inline text. Apply to an `<em>` element.\n *\n * @hostTag em\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the text. Defaults to \"neutral\".\n * @example { em: \"important\", $: [emphasis()] }\n */\nfunction emphasis(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"em\") {\n console.warn(`\"emphasis\" primitive patch must use em tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontStyle: \"italic\",\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n };\n}\n\nexport { emphasis };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Styles a container as an empty-state placeholder: centered flex column with\n * muted coloring and comfortable padding. Provide the icon, title, and\n * description as child elements.\n *\n * @param props.color - Theme color tone for the muted text/icon. Defaults to `\"neutral\"`.\n * @example\n * { div: [\n * { span: \"📭\" },\n * { p: \"No items yet\", $: [paragraph()] },\n * { span: \"Add your first item to get started\", $: [small()] },\n * ], $: [empty()] }\n */\nfunction empty(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: themeSpacing(3),\n paddingBlock: themeSpacing(12),\n paddingInline: themeSpacing(6),\n textAlign: \"center\",\n // Body / description text sits in the muted zone.\n color: (listener) => themeColor(listener, \"muted\", color.get(listener)),\n // Icon area: slightly softer so it recedes behind the title.\n \"& > :first-child\": {\n color: (listener) =>\n themeColor(listener, \"shift-5\", color.get(listener)),\n opacity: 0.9,\n },\n // Title (typically second child): stronger body text for hierarchy.\n \"& > :nth-child(2)\": {\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n },\n };\n}\n\nexport { empty };\n","import type { DomphyElement, ElementNode, PartialElement } from \"@domphy/core\";\n\nconst ORIGINAL_CHILDREN = \"errorBoundaryOriginal\";\n\nfunction restoreOriginalChildren(node: ElementNode): void {\n const original = node.getMetadata(ORIGINAL_CHILDREN);\n if (typeof original === \"function\") {\n node._childrenRelease?.();\n node._setupFunctionChildren(original);\n return;\n }\n if (original != null) {\n node.children.update(Array.isArray(original) ? original : [original]);\n return;\n }\n node.children.update([]);\n}\n\n/**\n * Catches errors thrown inside reactive child expressions and renders a\n * fallback element instead of crashing the whole tree. Apply to any container.\n *\n * Only errors in *reactive* children (functions returning element arrays) are\n * caught. Errors during static construction propagate normally — those are\n * programming errors, not runtime data errors.\n *\n * `reset()` restores the original children (including a reactive children\n * function) so the next evaluation runs again — it does not leave the host\n * empty.\n *\n * @hostTag any\n * @param props.fallback - Fallback element or factory `(error, reset) => element`. Defaults to a plain error message div.\n * @param props.onError - Optional callback for logging/telemetry.\n * @example { div: (l) => renderUserContent(l), $: [errorBoundary({ fallback: { p: \"Something went wrong.\" } })] }\n */\nfunction errorBoundary(\n props: {\n fallback?:\n | DomphyElement\n | ((error: unknown, reset: () => void) => DomphyElement);\n onError?: (error: unknown) => void;\n } = {},\n): PartialElement {\n return {\n _onSchedule: (node, element) => {\n if (node.getMetadata(ORIGINAL_CHILDREN) !== undefined) return;\n node.setMetadata(\n ORIGINAL_CHILDREN,\n (element as Record<string, unknown>)[node.tagName],\n );\n },\n _onError: (node, error) => {\n props.onError?.(error);\n const reset = () => restoreOriginalChildren(node);\n const fallbackEl =\n typeof props.fallback === \"function\"\n ? props.fallback(error, reset)\n : (props.fallback ??\n ({ div: \"An error occurred.\" } as DomphyElement));\n node.children.update([fallbackEl]);\n },\n };\n}\n\nexport { errorBoundary };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst SIZE_MAP = { small: 8, medium: 10, large: 14 } as const;\n\n/**\n * Floating Action Button — a circular elevated button typically used for the\n * primary action on a screen. Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, defaults to `\"primary\"`.\n * @param props.size - Button size preset. Optional `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { button: \"+\", $: [fab()] }\n * @example { button: \"+\", $: [fab({ size: \"small\", color: \"neutral\" })] }\n */\nfunction fab(\n props: {\n color?: ValueOrState<ThemeColor>;\n size?: \"small\" | \"medium\" | \"large\";\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n const dim = themeSpacing(SIZE_MAP[props.size ?? \"medium\"]);\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn('\"fab\" patch must use button tag');\n }\n },\n // Deep brand disc (shift-13) + light icon — mid-ramp shift-8 failed WCAG\n // (~2.2:1). tone-background-inherit wants inherit+dataTone; explicit fill\n // silences it the same way as button solid.\n _doctorDisable: [\n \"low-contrast\",\n \"color-shift-minimum\",\n \"tone-background-inherit\",\n ],\n style: {\n appearance: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n flexShrink: 0,\n width: dim,\n height: dim,\n borderRadius: \"50%\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-13\", color.get(listener)),\n color: (listener) => themeColor(listener, \"shift-0\", \"neutral\"),\n boxShadow: elevation(\"low\"),\n transition: \"background-color 200ms ease, box-shadow 200ms ease\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-14\", color.get(listener)),\n boxShadow: elevation(\"medium\"),\n },\n \"&:active:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-15\", color.get(listener)),\n boxShadow: elevation(\"low\"),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) =>\n `${elevation(\"medium\")}, ${focusRing(listener, color.get(listener))}`,\n },\n \"&[disabled]\": { opacity: 0.5, cursor: \"not-allowed\" },\n },\n };\n}\n\nexport { fab };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Lays out a figure as a column with block-level media (img/svg/video/canvas)\n * and a themed `<figcaption>`. Apply to a `<figure>` element.\n *\n * @hostTag figure\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the figure/caption text. Defaults to \"neutral\".\n * @example { figure: [{ img: \"\", src }, { figcaption: \"A caption\" }], $: [figure()] }\n */\nfunction figure(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"figure\") {\n console.warn(`\"figure\" primitive patch must use figure tag`);\n }\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: themeSpacing(2),\n marginInline: 0,\n marginTop: themeSpacing(3),\n marginBottom: themeSpacing(3),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"& img, & svg, & video, & canvas\": {\n display: \"block\",\n maxWidth: \"100%\",\n borderRadius: themeSpacing(2),\n },\n \"& figcaption\": {\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n color: (listener) => themeColor(listener, \"muted\", color.get(listener)),\n lineHeight: 1.45,\n },\n },\n };\n}\n\nexport { figure };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Layout patch for a group of form fields. Arranges a `<legend>`, `<label>`s,\n * controls, and helper `<p>`s in a grid — labels beside controls (horizontal)\n * or stacked above them (vertical). Apply to a `<fieldset>` element.\n *\n * @hostTag fieldset\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for legend/text/surface. Defaults to \"neutral\".\n * @param props.layout - Field arrangement, \"horizontal\" (label beside control) | \"vertical\" (label above). Defaults to \"horizontal\".\n * @example { fieldset: [{ legend: \"Profile\" }, { label: \"Name\" }, { input: \"\" }], $: [formGroup({ layout: \"vertical\" })] }\n */\nfunction formGroup(\n props: {\n color?: ValueOrState<ThemeColor>;\n layout?: \"horizontal\" | \"vertical\";\n } = {},\n): PartialElement {\n const { layout = \"horizontal\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n const isVertical = layout === \"vertical\";\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"fieldset\") {\n console.warn(`\"formGroup\" patch must use fieldset tag`);\n }\n },\n // Legend weight is design-system chrome for field groups.\n _doctorDisable: \"inline-typography\",\n style: {\n margin: 0,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 3),\n border: \"none\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n display: \"grid\",\n gridTemplateColumns: isVertical\n ? `minmax(0, 1fr)`\n : `max-content minmax(0, 1fr)`,\n columnGap: themeSpacing(4),\n rowGap: themeSpacing(3),\n alignItems: \"start\",\n \"& > legend\": {\n gridColumn: \"1 / -1\",\n margin: 0,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontWeight: 600,\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n },\n \"& > label\": {\n gridColumn: \"1\",\n alignSelf: \"start\",\n margin: 0,\n paddingBlock: (listener) =>\n isVertical ? 0 : themeSpacing(themeDensity(listener) * 1),\n },\n \"& > label:has(+ :not(legend, label, p) + p)\": {\n gridRow: isVertical ? \"auto\" : \"span 2\",\n },\n \"& > :not(legend, label, p)\": {\n gridColumn: isVertical ? \"1\" : \"2\",\n minWidth: 0,\n width: \"100%\",\n boxSizing: \"border-box\",\n },\n \"& > p\": {\n gridColumn: isVertical ? \"1\" : \"2\",\n minWidth: 0,\n margin: 0,\n marginBlockStart: `calc(${themeSpacing(2)} * -1)`,\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n },\n };\n}\n\nexport { formGroup };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeDensity, themeSpacing } from \"@domphy/theme\";\nimport type { FlexAlign } from \"./stack.js\";\n\n/**\n * A CSS grid with a column template and spacing between cells — the\n * general-purpose primitive for card/property/stat grids instead of\n * hand-rolling `display: \"grid\"; gridTemplateColumns: ...; gap: ...`.\n * Mirrors `row()`'s contract. Styles the host only; apply to any block\n * element.\n *\n * @param props.columns - Column count (expanded to `repeat(N, minmax(0, 1fr))`)\n * or a raw `grid-template-columns` value. Defaults to `1`.\n * @param props.gap - Spacing multiplier for gap between cells (default 4 = 1em at density 1).\n * @param props.align - Block-axis alignment of items (`alignItems`). Unset by default.\n * @example { div: [{ div: \"A\" }, { div: \"B\" }], $: [grid({ columns: 2 })] }\n * @example { div: [...], $: [grid({ columns: \"repeat(auto-fill, minmax(12em, 1fr))\", gap: 6 })] }\n */\nfunction grid(\n props: { columns?: number | string; gap?: number; align?: FlexAlign } = {},\n): PartialElement {\n const { columns = 1, gap = 4, align } = props;\n return {\n style: {\n display: \"grid\",\n gridTemplateColumns:\n typeof columns === \"number\"\n ? `repeat(${columns}, minmax(0, 1fr))`\n : columns,\n gap: (listener) => themeSpacing(themeDensity(listener) * gap),\n ...(align ? { alignItems: align } : {}),\n },\n };\n}\n\nexport { grid };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ElementSize,\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\nconst HeadingShift: Record<string, ElementSize> = {\n h6: \"decrease-1\",\n h5: \"inherit\",\n h4: \"increase-1\",\n h3: \"increase-2\",\n h2: \"increase-3\",\n h1: \"increase-4\",\n};\n\n/**\n * Styles a heading, scaling its font size by level (h1 largest … h6 smallest)\n * relative to the theme base size. Apply to a heading element `<h1>`–`<h6>`.\n *\n * @hostTag h1\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the heading text. Defaults to \"neutral\".\n * @param props.size - Optional `ElementSize` (`\"inherit\"` | `\"increase-N\"` | `\"decrease-N\"`, N ≤ 7). When set, font size is `themeSize(listener, size)` including `\"inherit\"` (no tag bump). When omitted, follows the host tag (`h1` increase-4 … `h6` decrease-1).\n * @example { h2: \"Section title\", $: [heading()] }\n * @example { h3: \"Panel title\", $: [heading({ size: \"inherit\" })] }\n */\nfunction heading(\n props: { color?: ValueOrState<ThemeColor>; size?: ElementSize } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const size = props.size;\n\n return {\n _onInsert: (node) => {\n if (![\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"].includes(node.tagName)) {\n console.warn(\n `\"heading\" primitive patch must use heading tags [h1...h6]`,\n );\n }\n },\n style: {\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n marginTop: 0,\n marginBottom: themeSpacing(2),\n fontSize: (listener) => {\n if (size !== undefined) {\n return themeSize(listener, size);\n }\n const offset = HeadingShift[listener.elementNode.tagName] || \"inherit\";\n return themeSize(listener, offset);\n },\n },\n };\n}\n\nexport { heading };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * A thematic break rendered as a thin 1px themed line with vertical margin.\n * Apply to an `<hr>` element.\n *\n * @hostTag hr\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the rule. Defaults to \"neutral\".\n * @example { hr: \"\", $: [horizontalRule()] }\n */\nfunction horizontalRule(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"hr\") {\n console.warn(`\"horizontalRule\" primitive patch must use hr tag`);\n }\n },\n // Soft rule surface — edge anchor (shift-3 = border) + inherit paint.\n dataTone: \"shift-3\",\n style: {\n border: 0,\n height: \"1px\",\n marginInline: 0,\n marginTop: themeSpacing(3),\n marginBottom: themeSpacing(3),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { horizontalRule };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles an inline icon container: square box that centers its content and\n * applies the themed icon color. Apply to a `<span>` element.\n *\n * @hostTag span\n * @param props.color - Optional theme color tone for the icon (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @example { span: null, $: [icon()] }\n */\nfunction icon(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"span\") {\n console.warn(`\"icon\" primitive patch should use span tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n alignSelf: \"center\",\n justifySelf: \"center\",\n verticalAlign: \"middle\",\n width: themeSpacing(4),\n height: themeSpacing(4),\n flexShrink: \"0\",\n fontSize: (listener) => themeSize(listener),\n backgroundColor: \"transparent\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { icon };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Styles a responsive image: full-width, cover-fit, rounded corners with a\n * themed placeholder background. Apply to an `<img>` element.\n *\n * @hostTag img\n * @param props.color - Optional theme color tone for the placeholder background (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @example { img: null, src: \"photo.jpg\", alt: \"Photo\", $: [image()] }\n */\nfunction image(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n _onInsert: (node) => {\n if (node.tagName !== \"img\") {\n console.warn(`\"image\" primitive patch must use img tag`);\n }\n },\n style: {\n display: \"block\",\n width: \"100%\",\n maxWidth: \"100%\",\n height: \"auto\",\n objectFit: \"cover\",\n borderRadius: themeSpacing(2),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { image };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a custom checkbox with themed box, check mark, indeterminate state,\n * hover, focus and disabled styling. Apply to an `<input>` element of\n * type `checkbox` (the patch sets `type: \"checkbox\"`).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for the box/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the checked/indeterminate fill and focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"checkbox\", $: [inputCheckbox()] }\n */\nfunction inputCheckbox(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n type: \"checkbox\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputCheckbox\" primitive patch must use input tag`);\n }\n },\n style: {\n appearance: \"none\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n display: \"inline-flex\",\n position: \"relative\",\n width: themeSpacing(6),\n height: themeSpacing(6),\n justifyContent: \"center\",\n alignItems: \"center\",\n transition: \"background-color 300ms, outline-color 300ms\",\n margin: 0,\n padding: 0,\n \"&::before\": {\n content: `\"\"`,\n display: \"block\",\n borderRadius: themeSpacing(1),\n lineHeight: 1,\n cursor: \"pointer\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n width: themeSpacing(4),\n height: themeSpacing(4),\n },\n \"&:hover::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:checked::before\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-6\", accentColor.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-8\", accentColor.get(listener)),\n },\n \"&:checked:hover:not([disabled])::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-7\", accentColor.get(listener)),\n },\n \"&:checked::after\": {\n content: `\"\"`,\n display: \"block\",\n position: \"absolute\",\n top: \"25%\",\n insetInlineStart: \"37%\",\n width: \"20%\",\n height: \"30%\",\n border: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"inherit\", accentColor.get(listener))}`,\n borderTop: 0,\n borderInlineStart: 0,\n transform: \"rotate(45deg)\",\n },\n \"&:indeterminate::before\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-6\", accentColor.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", accentColor.get(listener)),\n },\n \"&:indeterminate::after\": {\n content: `\"\"`,\n position: \"absolute\",\n inset: \"30%\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-8\", accentColor.get(listener)),\n },\n \"&:indeterminate:hover:not([disabled])::after\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-7\", accentColor.get(listener)),\n },\n \"&:focus-visible\": {\n borderRadius: themeSpacing(1.5),\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n cursor: \"not-allowed\",\n },\n \"&[disabled]::before, &[disabled]::after\": {\n outline: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-4\", \"neutral\"),\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { inputCheckbox };\n","import type { PartialElement, ValueOrState } from \"@domphy/core\";\nimport { toState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native color picker swatch with themed padding, rounded swatch and\n * disabled styling. Apply to an `<input>` element of type `color` (the patch\n * default is `type: \"color\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone used for the disabled state (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"color\", $: [inputColor()] }\n */\nfunction inputColor(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"color\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputColor\" primitive patch must use input tag`);\n }\n },\n style: {\n appearance: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 1),\n blockSize: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n inlineSize: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n backgroundColor: \"transparent\",\n transition: \"box-shadow 140ms ease\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&::-webkit-color-swatch-wrapper\": {\n margin: 0,\n padding: 0,\n },\n \"&::-webkit-color-swatch\": {\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n },\n },\n };\n}\n\nexport { inputColor };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\ntype InputDateTimeMode = \"date\" | \"time\" | \"week\" | \"month\" | \"datetime-local\";\n\n/**\n * Styles a native date/time input with themed border, padding, hover, focus,\n * invalid and disabled states. The `mode` selects the input `type`. Apply to\n * an `<input>` element (the patch default `type` is the chosen `mode`; a native `type` wins).\n *\n * @hostTag input\n * @param props.mode - Input mode selecting the host `type`: `\"date\" | \"time\" | \"week\" | \"month\" | \"datetime-local\"`. Defaults to `\"datetime-local\"`.\n * @param props.color - Optional theme color tone for text/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"datetime-local\", $: [inputDateTime()] }\n */\nfunction inputDateTime(\n props: {\n mode?: InputDateTimeMode;\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { mode = \"datetime-local\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: mode,\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputDateTime\" primitive patch must use input tag`);\n }\n },\n style: {\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::-webkit-calendar-picker-indicator\": {\n cursor: \"pointer\",\n opacity: 0.85,\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n },\n \"&:invalid\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"error\")}`,\n },\n },\n };\n}\n\nexport { inputDateTime };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native file input with a themed upload button, border, hover, focus\n * and disabled states. Apply to an `<input>` element of type `file` (the patch\n * default is `type: \"file\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for text/border and the upload button (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"file\", $: [inputFile()] }\n */\nfunction inputFile(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"file\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputFile\" primitive patch must use input tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 1),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::-webkit-file-upload-button\": {\n marginTop: (listener) => themeSpacing(themeDensity(listener)),\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n border: \"none\",\n borderRadius: themeSpacing(1),\n height: themeSpacing(6),\n paddingInline: themeSpacing(2),\n cursor: \"pointer\",\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"surface\", color.get(listener)),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.8,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"surface\", \"neutral\"),\n },\n \"&[disabled]::-webkit-file-upload-button\": {\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", \"neutral\"),\n },\n },\n };\n}\n\nexport { inputFile };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native number input with themed border, padding, visible spin\n * buttons, hover, focus and disabled states. Apply to an `<input>` element of\n * type `number` (the patch default is `type: \"number\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for text/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"number\", $: [inputNumber()] }\n */\nfunction inputNumber(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"number\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputNumber\" primitive patch must use input tag`);\n }\n },\n style: {\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n minWidth: themeSpacing(10),\n paddingInlineStart: (listener) =>\n themeSpacing(themeDensity(listener) * 3),\n paddingInlineEnd: (listener) =>\n themeSpacing(themeDensity(listener) * 1.5),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::-webkit-inner-spin-button, &::-webkit-outer-spin-button\": {\n opacity: 1,\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { inputNumber };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeSpacing } from \"@domphy/theme\";\n\n/**\n * Lays out a one-time-password container as a horizontal row of inputs and\n * wires keyboard navigation: auto-advance on input, backspace/arrow movement,\n * and paste distribution across the child inputs. Apply to a container element\n * (e.g. `<div>`) whose direct children are the OTP `<input>` boxes. Takes no\n * props.\n *\n * @example { div: null, $: [inputOTP()], children: [{ input: null }, { input: null }] }\n */\nfunction inputOTP(): PartialElement {\n return {\n // Group naming so aria-label on the host is valid (not a bare div).\n role: \"group\",\n ariaLabel: \"One-time password\",\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n \"& > *\": {\n minWidth: `${themeSpacing(9)}!important`,\n },\n },\n _onMount: (node) => {\n const container = node.domElement as HTMLElement;\n const getInputs = () =>\n Array.from(container.querySelectorAll(\"input\")) as HTMLInputElement[];\n\n const onInput = (e: Event) => {\n const inputs = getInputs();\n const target = e.target as HTMLInputElement;\n const idx = inputs.indexOf(target);\n if (target.value && idx < inputs.length - 1) {\n inputs[idx + 1].focus();\n }\n };\n\n const onKeydown = (e: KeyboardEvent) => {\n const inputs = getInputs();\n const target = e.target as HTMLInputElement;\n const idx = inputs.indexOf(target);\n if (e.key === \"Backspace\" && !target.value && idx > 0) {\n inputs[idx - 1].focus();\n }\n if (e.key === \"ArrowLeft\" && idx > 0) inputs[idx - 1].focus();\n if (e.key === \"ArrowRight\" && idx < inputs.length - 1)\n inputs[idx + 1].focus();\n };\n\n const onPaste = (e: ClipboardEvent) => {\n e.preventDefault();\n const text = e.clipboardData?.getData(\"text\") ?? \"\";\n const inputs = getInputs();\n const found = inputs.indexOf(e.target as HTMLInputElement);\n const startIdx = found === -1 ? 0 : found;\n [...text].forEach((char, i) => {\n const field = inputs[startIdx + i];\n if (!field) return;\n field.value = char;\n field.dispatchEvent(new Event(\"input\", { bubbles: true }));\n field.dispatchEvent(new Event(\"change\", { bubbles: true }));\n });\n const lastFilled = Math.min(\n startIdx + text.length - 1,\n inputs.length - 1,\n );\n inputs[lastFilled]?.focus();\n };\n\n container.addEventListener(\"input\", onInput);\n container.addEventListener(\"keydown\", onKeydown as EventListener);\n container.addEventListener(\"paste\", onPaste as EventListener);\n\n node.addHook(\"Remove\", () => {\n container.removeEventListener(\"input\", onInput);\n container.removeEventListener(\"keydown\", onKeydown as EventListener);\n container.removeEventListener(\"paste\", onPaste as EventListener);\n });\n },\n };\n}\n\nexport { inputOTP };\n","import type {\n DomphyElement,\n Listener,\n PartialElement,\n StyleObject,\n} from \"@domphy/core\";\nimport { isState, rawHtml, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n// Tabler Icons (MIT) — eye and eye-off outlines.\nconst EYE_SVG =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" ` +\n `stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" ` +\n `width=\"1em\" height=\"1em\">` +\n `<path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>` +\n `<path d=\"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0\"/>` +\n `<path d=\"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6\"/>` +\n `</svg>`;\n\nconst EYE_OFF_SVG =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" ` +\n `stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" ` +\n `width=\"1em\" height=\"1em\">` +\n `<path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>` +\n `<path d=\"M10.585 10.587a2 2 0 0 0 2.829 2.828\"/>` +\n `<path d=\"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6` +\n `c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18` +\n `c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87\"/>` +\n `<path d=\"M3 3l18 18\"/>` +\n `</svg>`;\n\nconst HOST_FIELD_KEYS = [\n \"name\",\n \"value\",\n \"onInput\",\n \"disabled\",\n \"required\",\n] as const;\n\ntype HostFieldKey = (typeof HOST_FIELD_KEYS)[number];\n\ntype HostFields = {\n name?: string;\n value?: unknown;\n onInput?: (event: Event) => void;\n disabled?: unknown;\n required?: boolean;\n};\n\nfunction bindReadable<T>(\n value: T | ValueOrState<T> | ((listener: Listener) => T) | undefined,\n): T | ((listener: Listener) => T) | undefined {\n if (value == null) return undefined;\n if (typeof value === \"function\") return value as (listener: Listener) => T;\n if (isState(value)) {\n return (listener) => (value as { get: (l?: Listener) => T }).get(listener);\n }\n return value as T;\n}\n\n/**\n * Password input wrapper: a styled `<div>` that inserts an `<input type=\"password\">`\n * and a show/hide toggle button. The outer div carries the focus-ring outline via\n * `:focus-within`. Apply to an empty `<div>`. Host `value`/`name`/`onInput`/\n * `disabled`/`required` are forwarded onto the real input so the field\n * participates in FormData.\n *\n * @hostTag div\n * @param props.color - Base color tone for border/background/text. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent outline color on focus-within. Defaults to `\"primary\"`.\n * @param props.value - Forwarded onto the inner input. Optional.\n * @param props.name - Forwarded onto the inner input (FormData key). Optional.\n * @param props.onInput - Forwarded onto the inner input. Optional.\n * @param props.disabled - Forwarded onto the inner input. Optional.\n * @param props.required - Forwarded onto the inner input. Optional.\n * @param props.autocomplete - Native autocomplete token. Defaults to `\"current-password\"`.\n * @param props.ariaLabel - Accessible name for the inner input. Defaults to `\"Password\"`.\n * @example { div: null, name: \"password\", $: [inputPassword()] }\n */\nfunction inputPassword(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n value?: ValueOrState<string>;\n name?: string;\n onInput?: (event: Event) => void;\n disabled?: ValueOrState<boolean>;\n required?: boolean;\n autocomplete?: string;\n ariaLabel?: string;\n } = {},\n): PartialElement {\n const colorState = toState(props.color ?? \"neutral\", \"color\");\n const accentState = toState(props.accentColor ?? \"primary\", \"accentColor\");\n const visibleState = toState(false);\n const hostFields: HostFields = {};\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn('\"inputPassword\" patch must use div tag');\n }\n },\n // Lift form fields off the host before merge so they land on the real\n // <input> (a div is not form-associated; FormData would omit them).\n _onSchedule: (_node, element) => {\n const host = element as PartialElement & HostFields;\n for (const key of HOST_FIELD_KEYS) {\n if (host[key] !== undefined) {\n hostFields[key] = host[key] as never;\n delete (host as Record<HostFieldKey, unknown>)[key];\n }\n }\n },\n // Build the input/toggle as real child elements (not imperative DOM\n // mutation in _onMount) so generateHTML()/SSR emits the actual markup.\n _onInit: (node) => {\n const name = props.name ?? hostFields.name;\n const value = bindReadable<string>(\n (props.value ?? hostFields.value) as ValueOrState<string> | undefined,\n );\n const onInput = props.onInput ?? hostFields.onInput;\n const disabled = bindReadable<boolean>(\n (props.disabled ?? hostFields.disabled) as\n | ValueOrState<boolean>\n | undefined,\n );\n const required = props.required ?? hostFields.required;\n\n const field: DomphyElement<\"input\"> = {\n input: null,\n type: (l) => (visibleState.get(l) ? \"text\" : \"password\"),\n ariaLabel: props.ariaLabel ?? \"Password\",\n autocomplete: props.autocomplete ?? \"current-password\",\n ...(name != null ? { name } : {}),\n ...(value != null ? { value } : {}),\n ...(onInput != null ? { onInput } : {}),\n ...(disabled != null ? { disabled } : {}),\n ...(required != null ? { required } : {}),\n style: {\n flex: 1,\n minWidth: 0,\n border: \"none\",\n outline: \"none\",\n backgroundColor: \"transparent\",\n padding: 0,\n margin: 0,\n font: \"inherit\",\n color: \"inherit\",\n },\n };\n\n const toggle: DomphyElement<\"button\"> = {\n button: (l) => rawHtml(visibleState.get(l) ? EYE_OFF_SVG : EYE_SVG),\n type: \"button\",\n ariaLabel: (l) =>\n visibleState.get(l) ? \"Hide password\" : \"Show password\",\n onClick: () => visibleState.set(!visibleState.get()),\n style: {\n background: \"none\",\n border: \"none\",\n padding: 0,\n margin: 0,\n cursor: \"pointer\",\n color: \"inherit\",\n display: \"flex\",\n alignItems: \"center\",\n flexShrink: 0,\n opacity: 0.6,\n },\n };\n\n node.children.insert(field);\n node.children.insert(toggle);\n },\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: (l) => themeSpacing(themeDensity(l) * 1),\n paddingBlock: (l) => themeSpacing(themeDensity(l) * 1),\n paddingInline: (l) => themeSpacing(themeDensity(l) * 3),\n borderRadius: (l) => themeSpacing(themeDensity(l) * 1.5),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (l) =>\n `1px solid ${themeColor(l, \"border-strong\", colorState.get(l))}`,\n color: (l) => themeColor(l, \"text\", colorState.get(l)),\n backgroundColor: (l) => themeColor(l, \"inherit\", colorState.get(l)),\n fontSize: (l) => themeSize(l, \"inherit\"),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not(:has([disabled])):not(:focus-within)\": {\n outline: (l) =>\n `1px solid ${themeColor(l, \"shift-5\", accentState.get(l))}`,\n },\n \"&:focus-within\": {\n boxShadow: (l) => focusRing(l, accentState.get(l)),\n },\n } as StyleObject,\n };\n}\n\nexport { inputPassword };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a custom radio button with a themed circular box, checked dot, hover,\n * focus and disabled states. Apply to an `<input>` element of type `radio`\n * (the patch sets `type: \"radio\"`).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for the box/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the checked dot and focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"radio\", $: [inputRadio()] }\n */\nfunction inputRadio(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n type: \"radio\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(\n `\"inputRadio\" primitive patch must use input tag and radio type`,\n );\n return;\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n appearance: \"none\",\n display: \"inline-flex\",\n position: \"relative\",\n width: themeSpacing(6),\n height: themeSpacing(6),\n justifyContent: \"center\",\n alignItems: \"center\",\n transition: \"background-color 300ms, outline-color 300ms\",\n margin: 0,\n padding: 0,\n \"&::before\": {\n content: `\"\"`,\n display: \"block\",\n borderRadius: \"50%\",\n lineHeight: 1,\n cursor: \"pointer\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n width: themeSpacing(4),\n height: themeSpacing(4),\n },\n \"&:hover::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:checked::before\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-6\", accentColor.get(listener))}`,\n },\n \"&:checked::after\": {\n content: `\"\"`,\n position: \"absolute\",\n inset: \"30%\",\n borderRadius: \"50%\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-8\", accentColor.get(listener)),\n },\n \"&:checked:hover:not([disabled])::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-7\", accentColor.get(listener)),\n },\n \"&:focus-visible\": {\n borderRadius: \"50%\",\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n cursor: \"not-allowed\",\n },\n \"&[disabled]::before, &[disabled]::after\": {\n outline: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-4\", \"neutral\"),\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { inputRadio };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a range slider with a themed track and thumb, hover, focus and\n * disabled states. Apply to an `<input>` element of type `range` (the patch\n * sets `type: \"range\"`).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for the slider track (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the thumb and focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"range\", $: [inputRange()] }\n */\nfunction inputRange(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n type: \"range\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputRange\" primitive patch must use input tag`);\n }\n },\n style: {\n appearance: \"none\",\n width: \"100%\",\n margin: 0,\n padding: 0,\n height: themeSpacing(4),\n background: \"transparent\",\n cursor: \"pointer\",\n \"&::-webkit-slider-runnable-track\": {\n height: themeSpacing(1.5),\n borderRadius: themeSpacing(999),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", color.get(listener)),\n },\n \"&::-webkit-slider-thumb\": {\n appearance: \"none\",\n width: themeSpacing(4),\n height: themeSpacing(4),\n borderRadius: themeSpacing(999),\n border: \"none\",\n marginTop: `calc((${themeSpacing(1.5)} - ${themeSpacing(4)}) / 2)`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-9\", accentColor.get(listener)),\n },\n \"&:hover:not([disabled])::-webkit-slider-thumb\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-10\", accentColor.get(listener)),\n },\n borderRadius: themeSpacing(2),\n transition: \"box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n };\n}\n\nexport { inputRange };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a search input with themed border, padding, placeholder color, native\n * search decorations, hover, focus and disabled states. Apply to an `<input>`\n * element of type `search` (the patch default is `type: \"search\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for text/border/placeholder (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"search\", $: [inputSearch()] }\n */\nfunction inputSearch(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"search\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputSearch\" primitive patch must use input tag`);\n }\n },\n style: {\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n minWidth: themeSpacing(32),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::placeholder\": {\n color: (listener) =>\n themeColor(listener, \"shift-7\", color.get(listener)),\n },\n \"&::-webkit-search-decoration\": {\n display: \"none\",\n },\n \"&::-webkit-search-cancel-button\": {\n cursor: \"pointer\",\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n },\n },\n };\n}\n\nexport { inputSearch };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a checkbox as a toggle switch: themed track and sliding knob that\n * animates and recolors on checked, plus a disabled state. Apply to an\n * `<input>` element of type `checkbox` (the patch sets `type: \"checkbox\"`).\n *\n * @hostTag input\n * @param props.accentColor - Optional theme color tone for the checked track (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"checkbox\", $: [inputSwitch()] }\n */\nfunction inputSwitch(\n props: { accentColor?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n role: \"switch\",\n dataTone: \"shift-2\",\n type: \"checkbox\",\n _onSchedule: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputSwitch\" primitive patch must use input tag`);\n return;\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n // Surface contract: dataTone is set; paint track via inherit + text color.\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n appearance: \"none\",\n position: \"relative\",\n display: \"inline-flex\",\n width: themeSpacing(9),\n height: themeSpacing(6),\n cursor: \"pointer\",\n margin: `0`,\n paddingBlock: themeSpacing(1),\n transition: \"box-shadow 140ms ease\",\n borderRadius: themeSpacing(999),\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&:checked\": {\n \"&::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-3\", accentColor.get(listener)),\n },\n \"&::after\": {\n left: `calc(100% - ${themeSpacing(3.5)})`,\n },\n },\n \"&::after\": {\n content: `\"\"`,\n aspectRatio: `1/1`,\n position: \"absolute\",\n width: themeSpacing(3),\n height: themeSpacing(3),\n borderRadius: themeSpacing(999),\n left: themeSpacing(0.5),\n top: \"50%\",\n transform: \"translateY(-50%)\",\n transition: \"left 0.3s\",\n backgroundColor: (listener) => themeColor(listener, \"decrease-3\"),\n },\n \"&::before\": {\n content: '\"\"',\n width: \"100%\",\n borderRadius: themeSpacing(999),\n display: \"inline-block\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: 1,\n backgroundColor: (listener) => themeColor(listener),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n };\n}\n\nexport { inputSwitch };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Themed single-line text input primitive. Sets `type` (default `\"text\"`) and\n * styles the field with themed border, focus ring, placeholder, disabled and\n * validation (`data-status`) states. Apply to an `<input>` element.\n *\n * @hostTag input\n * @param props - Optional configuration.\n * @param props.type - The input's `type` attribute (e.g. `\"email\"`, `\"url\"`, `\"tel\"`). Defaults to `\"text\"`.\n * @param props.color - Base color tone for text/border/background. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color tone for the hover/focus outline. Defaults to `\"primary\"`.\n * @example { input: \"\", type: \"text\", placeholder: \"Name\", $: [inputText()] }\n */\nfunction inputText(\n props: {\n type?: string;\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { type = \"text\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type,\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(\n `\"inputText\" primitive patch must use input tag and text type`,\n );\n }\n },\n style: {\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n minWidth: themeSpacing(10),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::placeholder\": {\n color: (listener) => themeColor(listener, \"shift-7\"),\n },\n \"&:not(:placeholder-shown)\": {\n color: (listener) => themeColor(listener, \"shift-10\"),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n \"&:invalid:not(:placeholder-shown)\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"error\")}`,\n },\n \"&[data-status=error]\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"error\")}`,\n },\n \"&[data-status=warning]\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"warning\")}`,\n },\n },\n };\n}\n\nexport { inputText };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Renders keyboard-key styling (themed background, border and padding) for a\n * keystroke hint. Apply to a `<kbd>` element.\n *\n * @hostTag kbd\n * @param props - Optional configuration.\n * @param props.color - Color tone for text/background/border. Defaults to `\"neutral\"`.\n * @example { kbd: \"Ctrl\", $: [keyboard()] }\n */\nfunction keyboard(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"kbd\") {\n console.warn(`\"keyboard\" primitive patch must use kbd tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * (0.5 / 1.5)),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * (1.5 / 1.5)),\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * (1 / 1.5)),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n },\n };\n}\n\nexport { keyboard };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Themed form-label primitive: inline-flex layout with gap, themed text color,\n * focus-within highlighting and a disabled (`aria-disabled`) state. Apply to a\n * `<label>` element.\n *\n * @hostTag label\n * @param props - Optional configuration.\n * @param props.color - Base color tone for the label text. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color tone applied on focus-within. Defaults to `\"primary\"`.\n * @example { label: \"Email\", htmlFor: \"email\", $: [label()] }\n */\nfunction label(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"label\") {\n console.warn(`\"label\" primitive patch must use label tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n cursor: \"pointer\",\n \"&:focus-within\": {\n color: (listener) =>\n themeColor(listener, \"shift-10\", accentColor.get(listener)),\n },\n \"&[aria-disabled=true]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { label };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Themed hyperlink primitive: styles text color, hover underline, visited,\n * focus ring and a disabled state. Apply to an `<a>` element.\n *\n * @hostTag a\n * @param props - Optional configuration.\n * @param props.color - Base color tone for the link text. Defaults to `\"primary\"`.\n * @param props.accentColor - Accent color tone for visited/focus states. Defaults to `\"secondary\"`.\n * @example { a: \"Home\", href: \"/\", $: [link()] }\n */\nfunction link(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n const accentColor = toState(props.accentColor ?? \"secondary\", \"accentColor\");\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"a\") {\n console.warn(`\"link\" primitive patch must use a tag`);\n }\n },\n // `<a disabled>` is not a native navigation block — stop click/Enter.\n onClick: (event, node) => {\n const el = node.domElement;\n if (\n el?.hasAttribute(\"disabled\") ||\n el?.getAttribute(\"aria-disabled\") === \"true\"\n ) {\n event.preventDefault();\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n // shift-13 (not \"text\"/shift-9): brand hues need extra depth for ≥4.5:1\n // on a light surface (primary orange failed at 2.57 with shift-9).\n color: (listener) =>\n themeColor(listener, \"shift-13\", color.get(listener)),\n textDecoration: \"none\",\n \"&:visited\": {\n color: (listener) =>\n themeColor(listener, \"shift-13\", accentColor.get(listener)),\n },\n \"&:hover:not([disabled])\": {\n color: (listener) =>\n themeColor(listener, \"shift-14\", color.get(listener)),\n textDecoration: \"underline\",\n },\n borderRadius: themeSpacing(1),\n // Kill the browser default outline so only the shared focusRing shows.\n outline: \"none\",\n transition: \"color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n pointerEvents: \"none\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { link };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { BUTTON_SIZE_FONT, type ButtonSize } from \"../utils/buttonSize.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport type { ButtonVariant } from \"./button.js\";\n\nconst PADDING_STEPS: Record<ButtonSize, { block: number; inline: number }> = {\n small: { block: 0.5, inline: 2 },\n medium: { block: 1, inline: 3 },\n large: { block: 1.5, inline: 4 },\n};\n\nconst GHOST_PADDING: Record<ButtonSize, number> = {\n small: 0.5,\n medium: 1,\n large: 1.5,\n};\n\n/**\n * An `<a>` element styled to look like a button — same visual system as\n * `button()` (`variant` / `size` / color) while preserving link semantics\n * (href, middle-click, right-click). Apply to an `<a>` element.\n *\n * @hostTag a\n * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @param props.variant - `\"outline\"` (default) | `\"solid\"` | `\"ghost\"` — matches `button()`.\n * @param props.size - `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { a: \"Open app\", href: \"/app\", $: [linkButton({ color: \"primary\" })] }\n * @example { a: \"Get started\", href: \"/start\", $: [linkButton({ variant: \"solid\" })] }\n */\nfunction linkButton(\n props: {\n color?: ValueOrState<ThemeColor>;\n variant?: ButtonVariant;\n size?: ButtonSize;\n } = {},\n): PartialElement {\n const variant = props.variant ?? \"outline\";\n const color = toState(\n props.color ?? (variant === \"ghost\" ? \"neutral\" : \"primary\"),\n \"color\",\n );\n const size = props.size ?? \"medium\";\n const fontSize = BUTTON_SIZE_FONT[size];\n\n if (variant === \"ghost\") {\n const padding = GHOST_PADDING[size];\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"a\") {\n console.warn(`\"linkButton\" primitive patch must use a tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, fontSize),\n textDecoration: \"none\",\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n display: \"inline-flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n background: \"none\",\n outline: \"none\",\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n // Resting text uses the \"text\" alias (shift-9), matching buttonGhost:\n // a text-labeled ghost control fails WCAG AA at the previous shift-6\n // (~2.4:1 on an edge surface). Hover/active differentiate via\n // background only.\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&:hover:not([aria-disabled=true])\": {\n color: (listener) =>\n themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n textDecoration: \"none\",\n },\n \"&:active:not([aria-disabled=true])\": {\n color: (listener) =>\n themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[aria-disabled=true]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n pointerEvents: \"none\",\n color: (listener) => themeColor(listener, \"border-strong\", \"neutral\"),\n },\n },\n };\n }\n\n const isSolid = variant === \"solid\";\n const padding = PADDING_STEPS[size];\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"a\") {\n console.warn(`\"linkButton\" primitive patch must use a tag`);\n }\n },\n ...(isSolid\n ? {\n _doctorDisable: [\n \"low-contrast\",\n \"color-shift-minimum\",\n \"tone-background-inherit\",\n ] as const,\n }\n : {}),\n style: {\n fontSize: (listener) => themeSize(listener, fontSize),\n textDecoration: \"none\",\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding.block),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding.inline),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n width: \"fit-content\",\n display: \"inline-flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outlineWidth: \"1px\",\n outline: isSolid\n ? \"none\"\n : (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n // Solid: deep brand (shift-13) + light-end text (not mid-ramp ~2.2:1).\n // Outline: shift-13 for ≥4.5:1 on light bg.\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-13\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-13\", color.get(listener))\n : themeColor(listener, \"inherit\", color.get(listener)),\n transition:\n \"background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([aria-disabled=true])\": {\n textDecoration: \"none\",\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-14\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-14\", color.get(listener))\n : themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:active:not([aria-disabled=true])\": {\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-15\", color.get(listener))\n : themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[aria-disabled=true]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n pointerEvents: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { linkButton };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a navigation/display list container. Sets `list-style: none` and\n * zero padding; pairs with `listItem` and `listItemButton`. Apply to `<ul>`.\n *\n * @hostTag ul\n * @param props.color - Surface color tone. Optional `ThemeColor`, defaults to `\"neutral\"`.\n * @example { ul: [...], $: [list()] }\n */\nfunction list(props: { color?: ThemeColor } = {}): PartialElement {\n const color = props.color ?? \"neutral\";\n return {\n style: {\n listStyle: \"none\",\n margin: 0,\n padding: 0,\n display: \"flex\",\n flexDirection: \"column\",\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n color: (listener) => themeColor(listener, \"text\", color),\n },\n };\n}\n\n/**\n * A non-interactive list row. Typically wraps an icon + text. Apply to `<li>`.\n *\n * @hostTag li\n * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.\n * @example { li: \"Item\", $: [listItem()] }\n */\nfunction listItem(props: { dense?: boolean } = {}): PartialElement {\n const { dense = false } = props;\n return {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBlock: (listener) =>\n themeSpacing(dense ? 1 : themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n },\n };\n}\n\n/**\n * An interactive (clickable) list row with hover/focus-visible states. Apply\n * to `<button>` or `<a>` inside an `<li>`.\n *\n * @param props.color - Color tone. Optional `ValueOrState<ThemeColor>`, defaults to `\"neutral\"`.\n * @param props.accentColor - Focus/active accent. Optional `ThemeColor`, defaults to `\"primary\"`.\n * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.\n * @example { button: \"Action\", $: [listItemButton()] }\n */\nfunction listItemButton(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ThemeColor;\n dense?: boolean;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = props.accentColor ?? \"primary\";\n const { dense = false } = props;\n\n return {\n style: {\n cursor: \"pointer\",\n appearance: \"none\",\n border: \"none\",\n background: \"transparent\",\n textDecoration: \"none\",\n textAlign: \"left\",\n display: \"flex\",\n alignItems: \"center\",\n width: \"100%\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBlock: (listener) =>\n themeSpacing(dense ? 1 : themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n transition: \"background-color 150ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:active:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&[aria-current=page], &[aria-selected=true]\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", accentColor),\n color: (listener) => themeColor(listener, \"shift-12\", accentColor),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n \"&[disabled]\": { opacity: 0.5, cursor: \"not-allowed\" },\n },\n };\n}\n\nexport { list, listItem, listItemButton };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Themed highlight primitive: gives marked/highlighted inline text a tinted\n * background, rounded corners and padding. Apply to a `<mark>` element.\n *\n * @hostTag mark\n * @param props - Optional configuration.\n * @param props.accentColor - Accent color tone for the highlight fill and text. Defaults to `\"highlight\"`.\n * @example { mark: \"important\", $: [mark()] }\n */\nfunction mark(\n props: { accentColor?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const accentColor = toState(props.accentColor ?? \"highlight\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"mark\") {\n console.warn(`\"mark\" primitive patch must use mark tag`);\n }\n },\n dataTone: \"shift-2\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) =>\n themeColor(listener, \"text\", accentColor.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", accentColor.get(listener)),\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n height: (listener) => themeSpacing(themeDensity(listener) * (6 / 1.5)),\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * (1 / 1.5)),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * (1.5 / 1.5)),\n },\n };\n}\n\nexport { mark };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One item inside a menu. */\ntype MenuItem = {\n /** Button label — plain string (auto-wrapped) or any DomphyElement (e.g. icon + text). */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index. */\n key?: string | number;\n /** Called when the item is clicked. */\n onClick?: () => void;\n};\n\n/**\n * All-in-one vertical menu. Generates `<button>` `[role=menuitem]` elements\n * from the `items` array with keyboard navigation (Arrow/Home/End/Enter/Space).\n * Apply to any wrapper element (`div`, `ul`, …).\n *\n * @param props.items - Item definitions `{ label, key?, onClick? }`. Pass `[]`\n * to keep the wrapper's own children (escape hatch for fully custom rows —\n * only the menu container styling and `role=\"menu\"` semantics apply then).\n * @param props.activeKey - Currently selected key (value or State). Defaults to `null`.\n * @param props.selectable - Whether items track and update the active selection. Defaults to `true`.\n * @param props.color - Background color tone for the menu. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color for the active/focus item. Defaults to `\"primary\"`.\n * @example\n * { div: null, $: [menu({ items: [\n * { label: \"Profile\", key: \"profile\", onClick: () => navigate(\"/profile\") },\n * { label: \"Settings\", key: \"settings\", onClick: () => navigate(\"/settings\") },\n * ] })] }\n */\nfunction menu(\n props: {\n items: MenuItem[];\n activeKey?: ValueOrState<number | string | null>;\n selectable?: boolean;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const {\n items = [],\n selectable = true,\n color = \"neutral\",\n accentColor = \"primary\",\n } = props;\n const activeKey = toState(props.activeKey ?? null);\n const activeKeyIsCallerOwned = props.activeKey !== undefined;\n\n type MenuInner = {\n items: MenuItem[];\n activeKey: State<number | string | null>;\n activeKeyIsCallerOwned: boolean;\n selectable: boolean;\n color: ThemeColor;\n accentColor: ThemeColor;\n };\n\n const buildItems = (\n node: ElementNode,\n inner: MenuInner,\n ): DomphyElement<\"button\">[] => {\n const id = node.nodeId;\n return inner.items.map((item, index) => {\n const key = item.key ?? index;\n return {\n button:\n typeof item.label === \"string\"\n ? [{ span: item.label } as DomphyElement<\"span\">]\n : [item.label],\n _key: key,\n type: \"button\",\n id: `menuitem${id}${key}`,\n role: \"menuitem\",\n ...(inner.selectable\n ? {\n ariaCurrent: (l: Listener) =>\n inner.activeKey.get(l) === key || undefined,\n }\n : {}),\n onClick: () => {\n if (inner.selectable) inner.activeKey.set(key);\n item.onClick?.();\n },\n onKeyDown: (e: Event) => {\n const k = (e as KeyboardEvent).key;\n if (k === \"Enter\" || k === \" \") {\n e.preventDefault();\n (e.target as HTMLElement).click();\n return;\n }\n if (![\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = inner.items.map((it, i) => it.key ?? i);\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowDown\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowUp\")\n next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n (\n document.getElementById(`menuitem${id}${keys[next]}`) as HTMLElement\n )?.focus();\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n width: \"100%\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: (l: Listener) => themeSpacing(6 + themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 3),\n border: \"none\",\n outline: \"none\",\n // Menu panel is a light (shift-0) surface: \"text\" resolves to a\n // dark-on-light reading tone in both light and dark themes.\n color: (l: Listener) => themeColor(l, \"text\", inner.color),\n backgroundColor: (l: Listener) =>\n themeColor(l, \"inherit\", inner.color),\n transition:\n \"background-color 140ms ease, box-shadow 140ms ease, color 140ms ease\",\n \"&:hover:not([disabled]):not([aria-current=true])\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"hover\", inner.color),\n },\n \"&[aria-current=true]\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-3\", inner.accentColor),\n color: (l: Listener) =>\n themeColor(l, \"shift-13\", inner.accentColor),\n },\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, inner.accentColor),\n },\n },\n } as DomphyElement<\"button\">;\n });\n };\n\n const attachMenu = (\n _node: ElementNode,\n initial: MenuInner,\n ): BehaviorInstance<MenuInner> => {\n let current = initial;\n return {\n update(next) {\n if (\n next.activeKey !== current.activeKey &&\n !next.activeKeyIsCallerOwned\n ) {\n next.activeKey.set(current.activeKey.get());\n }\n current = next;\n // Empty items = the caller renders its own rows; leave children alone.\n if (current.items.length === 0) return;\n _node.children.update(buildItems(_node, current));\n },\n };\n };\n\n const inner: MenuInner = {\n items,\n activeKey,\n activeKeyIsCallerOwned,\n selectable,\n color,\n accentColor,\n };\n\n return {\n role: \"menu\",\n dataTone: \"shift-0\",\n _onSchedule: (node, element) => {\n // Empty items = the caller renders its own rows; leave children alone.\n if (items.length === 0) return;\n (element as Record<string, unknown>)[node.tagName] = buildItems(\n node,\n inner,\n );\n },\n ...behavior<MenuInner>(\"menu\", attachMenu, inner),\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n paddingBlock: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n color: (l: Listener) => themeColor(l, \"text\", color),\n borderRadius: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n outline: (l: Listener) =>\n `1px solid ${themeColor(l, \"border-strong\", color)}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n}\n\nexport { menu };\nexport type { MenuItem };\n","import {\n type BehaviorInstance,\n behavior,\n type PartialElement,\n type State,\n} from \"@domphy/core\";\n\n/**\n * One keyframe. Shorthands `x`/`y` (px), `scale`, `rotate` (deg) compose into a\n * single `transform`; any other key is a raw CSS property (e.g. `opacity`,\n * `backgroundColor`).\n */\nexport type MotionKeyframe = {\n x?: number | string;\n y?: number | string;\n scale?: number | string;\n rotate?: number | string;\n} & Record<string, string | number>;\n\nexport interface MotionProps {\n /** Starting keyframe applied before the enter animation. */\n initial?: MotionKeyframe;\n /** Target keyframe. Pass a `State` to re-animate whenever it changes. */\n animate?: MotionKeyframe | State<MotionKeyframe>;\n /** Keyframe animated to before the element is removed. */\n exit?: MotionKeyframe;\n transition?: {\n /** ms, default 300. */\n duration?: number;\n /** ms, default 0. */\n delay?: number;\n /** CSS easing, default \"ease\". */\n easing?: string;\n iterations?: number;\n };\n}\n\ntype MotionInstance = BehaviorInstance<MotionProps> & {\n play: (props: MotionProps, mode: \"enter\" | \"update\") => void;\n getExit: () => MotionKeyframe | undefined;\n getTransition: () => MotionProps[\"transition\"];\n};\n\nconst isMotionState = (value: unknown): value is State<MotionKeyframe> =>\n !!value &&\n typeof (value as State<MotionKeyframe>).get === \"function\" &&\n (value as { _isState?: boolean })._isState === true;\n\nconst toStyles = (frame: MotionKeyframe): Keyframe => {\n const out: Record<string, string | number> = {};\n const transforms: string[] = [];\n for (const key in frame) {\n const value = frame[key];\n if (key === \"x\") {\n transforms.push(\n `translateX(${typeof value === \"number\" ? `${value}px` : value})`,\n );\n } else if (key === \"y\") {\n transforms.push(\n `translateY(${typeof value === \"number\" ? `${value}px` : value})`,\n );\n } else if (key === \"scale\") {\n transforms.push(`scale(${value})`);\n } else if (key === \"rotate\") {\n transforms.push(\n `rotate(${typeof value === \"number\" ? `${value}deg` : value})`,\n );\n } else {\n out[key] = value;\n }\n }\n if (transforms.length) out.transform = transforms.join(\" \");\n return out as Keyframe;\n};\n\nfunction toOptions(\n transition: MotionProps[\"transition\"] = {},\n): KeyframeAnimationOptions {\n return {\n duration: transition.duration ?? 300,\n delay: transition.delay ?? 0,\n easing: transition.easing ?? \"ease\",\n iterations: transition.iterations ?? 1,\n fill: \"both\",\n };\n}\n\n/**\n * Animation primitive driven by the Web Animations API. Runs an enter\n * animation on mount (`initial` -> `animate`), re-animates whenever `animate`\n * is a `State` that changes, and plays the `exit` keyframe before removal.\n * Has no host-tag restriction; apply to any element you want to animate.\n *\n * Later generations route a fresh `animate`/`exit`/`transition` into the same\n * `behavior()` instance via `update()`, so a reused node is not stuck on\n * generation-1 keyframes.\n *\n * @param props - Optional configuration (see {@link MotionProps}).\n * @param props.initial - Starting keyframe applied before the enter animation.\n * @param props.animate - Target keyframe, or a `State` to re-animate on change.\n * @param props.exit - Keyframe animated to before the element is removed.\n * @param props.transition - Timing options.\n * @param props.transition.duration - Duration in ms. Defaults to `300`.\n * @param props.transition.delay - Delay in ms. Defaults to `0`.\n * @param props.transition.easing - CSS easing. Defaults to `\"ease\"`.\n * @param props.transition.iterations - Number of iterations. Defaults to `1`.\n * @example { div: \"Hello\", $: [motion({ initial: { opacity: 0 }, animate: { opacity: 1 } })] }\n */\nfunction prefersReducedMotion(): boolean {\n if (typeof matchMedia !== \"function\") return false;\n try {\n return matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n } catch {\n return false;\n }\n}\n\nfunction attachMotion(\n node: { domElement?: HTMLElement | null },\n initial: MotionProps,\n): MotionInstance {\n const el = node.domElement as HTMLElement | null;\n let current = initial;\n let release: (() => void) | undefined;\n\n const bindAnimate = (animate: MotionProps[\"animate\"]) => {\n release?.();\n release = undefined;\n if (!el || !isMotionState(animate)) return;\n release = animate.addListener((next: MotionKeyframe) => {\n if (prefersReducedMotion()) {\n Object.assign(el.style, toStyles(next));\n } else if (typeof el.animate === \"function\") {\n el.animate([toStyles(next)], toOptions(current.transition));\n }\n });\n };\n\n const play = (props: MotionProps, mode: \"enter\" | \"update\") => {\n if (!el) return;\n const target = isMotionState(props.animate)\n ? props.animate.get()\n : props.animate;\n if (prefersReducedMotion()) {\n if (target) Object.assign(el.style, toStyles(target));\n else if (mode === \"enter\" && props.initial) {\n Object.assign(el.style, toStyles(props.initial));\n }\n return;\n }\n if (typeof el.animate !== \"function\") return;\n if (target) {\n const frames =\n mode === \"enter\" && props.initial\n ? [toStyles(props.initial), toStyles(target)]\n : [toStyles(target)];\n el.animate(frames, toOptions(props.transition));\n } else if (mode === \"enter\" && props.initial) {\n Object.assign(el.style, toStyles(props.initial));\n }\n };\n\n play(initial, \"enter\");\n bindAnimate(initial.animate);\n\n return {\n play,\n getExit: () => current.exit,\n getTransition: () => current.transition,\n update(next) {\n current = next;\n play(next, \"update\");\n bindAnimate(next.animate);\n },\n destroy() {\n release?.();\n },\n };\n}\n\nfunction motion(props: MotionProps = {}): PartialElement {\n return {\n ...behavior<MotionProps>(\n \"motion\",\n (node, next) => attachMotion(node, next),\n props,\n ),\n _onBeforeRemove: (node, done) => {\n const el = node.domElement as HTMLElement | null;\n const inst = node.getBehavior<MotionInstance>(\"motion\");\n const exit = inst?.getExit() ?? props.exit;\n if (!el || !exit || typeof el.animate !== \"function\") return done();\n if (prefersReducedMotion()) {\n Object.assign(el.style, toStyles(exit));\n return done();\n }\n el.animate(\n [toStyles(exit)],\n toOptions(inst?.getTransition() ?? props.transition),\n ).finished.then(done, done);\n },\n };\n}\n\nexport { motion };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Themed ordered-list primitive: decimal markers positioned outside, reset\n * margins and themed text color. Apply to an `<ol>` element.\n *\n * @hostTag ol\n * @param props - Optional configuration.\n * @param props.color - Color tone for the list text. Defaults to `\"neutral\"`.\n * @example { ol: \"\", $: [orderedList()], children: [{ li: \"First\" }] }\n */\nfunction orderedList(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"ol\") {\n console.warn(`\"orderedList\" primitive patch must use ol tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n marginTop: 0,\n marginBottom: 0,\n paddingLeft: themeSpacing(3),\n listStyleType: \"decimal\",\n listStylePosition: \"outside\",\n },\n };\n}\n\nexport { orderedList };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nfunction getPages(current: number, total: number): (number | \"...\")[] {\n if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1);\n const pages: (number | \"...\")[] = [1];\n if (current > 3) pages.push(\"...\");\n const start = Math.max(2, current - 1);\n const end = Math.min(total - 1, current + 1);\n for (let i = start; i <= end; i++) pages.push(i);\n if (current < total - 2) pages.push(\"...\");\n pages.push(total);\n return pages;\n}\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction persistTotal(node: ElementNode, total: number): State<number> {\n let stored = node.getMetadata(\"paginationTotal\") as State<number> | undefined;\n if (!stored) {\n stored = toState(total);\n node.setMetadata(\"paginationTotal\", stored);\n }\n return stored;\n}\n\n/**\n * Themed pagination control. Renders previous/next buttons plus truncated page\n * numbers (with ellipses), tracks the current page in a `State`, and updates it\n * on click. Apply to a `<div>` element.\n *\n * @hostTag div\n * @param props - Configuration.\n * @param props.total - Required. Total number of pages.\n * @param props.value - Current page, accepts a value or `State`. Defaults to `1`.\n * @param props.color - Base color tone for the page buttons. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color tone for the active page. Defaults to `\"primary\"`.\n * @example { div: \"\", $: [pagination({ total: 10, value: 1 })] }\n */\nfunction pagination(props: {\n value?: ValueOrState<number>;\n total: number;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n}): PartialElement {\n const { total, color = \"neutral\", accentColor = \"primary\" } = props;\n\n const btnBase = {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minWidth: (listener: any) => themeSpacing(6 + themeDensity(listener) * 2),\n height: (listener: any) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener: any) => themeSpacing(themeDensity(listener) * 2),\n borderRadius: (listener: any) => themeSpacing(themeDensity(listener) * 1.5),\n border: \"none\",\n cursor: \"pointer\",\n fontSize: (listener: any) => themeSize(listener, \"inherit\"),\n backgroundColor: \"transparent\",\n // Page numbers: shift-13 for readable inactive digits (catalog contrast).\n color: (listener: any) => themeColor(listener, \"shift-13\", color),\n transition:\n \"background-color 140ms ease, box-shadow 140ms ease, color 140ms ease\",\n \"&:hover:not([disabled])\": {\n color: (listener: any) => themeColor(listener, \"shift-13\", color),\n backgroundColor: (listener: any) => themeColor(listener, \"hover\", color),\n },\n \"&:focus-visible\": {\n boxShadow: (listener: any) => focusRing(listener, accentColor),\n },\n \"&[disabled]\": {\n opacity: 0.4,\n cursor: \"not-allowed\",\n },\n };\n\n const activeStyle = {\n ...btnBase,\n // Deep accent fill + light text (mid-ramp + mid text failed catalog).\n backgroundColor: (listener: any) =>\n themeColor(listener, \"shift-13\", accentColor),\n color: (listener: any) => themeColor(listener, \"shift-0\", \"neutral\"),\n fontWeight: \"bold\",\n cursor: \"default\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (listener: any) =>\n themeColor(listener, \"shift-13\", accentColor),\n },\n };\n\n return {\n role: \"navigation\",\n ariaLabel: \"Pagination\",\n // Active page weight is design-system chrome for the control.\n _doctorDisable: \"inline-typography\",\n _onInsert: (node) => {\n if (node.tagName !== \"div\")\n console.warn('\"pagination\" patch must use div tag');\n },\n _onInit: (node) => {\n const state = persistValue(node, \"paginationPage\", props.value, 1);\n const totalState = persistTotal(node, total);\n const content: DomphyElement<\"div\"> = {\n div: (listener) => {\n const page = state.get(listener);\n const pageCount = totalState.get(listener);\n const items: DomphyElement[] = [];\n\n // Prev button\n items.push({\n button: \"‹\",\n _key: \"prev\",\n type: \"button\",\n ariaLabel: \"Previous page\",\n disabled: page <= 1,\n onClick: () => page > 1 && state.set(page - 1),\n style: btnBase,\n });\n\n // Page buttons. Keyed by page number (or a running ellipsis index —\n // there can be up to two \"...\" spans) so the list survives length\n // changes across pages without the unkeyed-reuse footgun.\n let ellipsisIndex = 0;\n for (const p of getPages(page, pageCount)) {\n if (p === \"...\") {\n items.push({\n span: \"…\",\n _key: `ellipsis-${ellipsisIndex++}`,\n ariaHidden: \"true\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n paddingInline: (listener: any) =>\n themeSpacing(themeDensity(listener) * 2),\n color: (listener: any) =>\n themeColor(listener, \"shift-7\", color),\n },\n });\n } else {\n const isActive = p === page;\n items.push({\n button: String(p),\n _key: `page-${p}`,\n type: \"button\",\n ariaLabel: `Page ${p}`,\n ariaCurrent: isActive ? \"page\" : undefined,\n disabled: isActive,\n onClick: () => state.set(p),\n style: isActive ? activeStyle : btnBase,\n });\n }\n }\n\n // Next button\n items.push({\n button: \"›\",\n _key: \"next\",\n type: \"button\",\n ariaLabel: \"Next page\",\n disabled: page >= pageCount,\n onClick: () => page < pageCount && state.set(page + 1),\n style: btnBase,\n });\n\n return items;\n },\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(1),\n },\n };\n node.children.insert(content);\n },\n ...behavior<{ total: number }>(\n \"pagination-total\",\n (node) => ({\n update(snapshot) {\n persistTotal(node, snapshot.total).set(snapshot.total);\n },\n }),\n { total },\n ),\n style: {\n display: \"inline-flex\",\n },\n };\n}\n\nexport { pagination };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A padded section for side-panel/inspector UIs — density-aware padding on\n * all sides, with an optional bottom divider for sections stacked one after\n * another. A thin wrapper: it does not impose flex layout on its children —\n * pair it with `stack()` or `row()` for that. No host-tag check; apply to\n * any block element.\n *\n * @param props.padding - Spacing multiplier for padding on all sides (default 4 = 1em at density 1).\n * @param props.divider - Adds a bottom border, for sections stacked one after another. Defaults to `false`.\n * @param props.color - Theme color tone for the divider border. Defaults to `\"neutral\"`.\n * @example { div: [{ h3: \"Parameters\" }, { p: \"...\" }], $: [panelSection()] }\n * @example\n * { div: [\n * { div: \"Section A\", $: [panelSection({ divider: true })] },\n * { div: \"Section B\", $: [panelSection()] },\n * ], $: [stack({ gap: 0 })] }\n */\nfunction panelSection(\n props: {\n padding?: number;\n divider?: boolean;\n color?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { padding = 4, divider = false } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n style: {\n padding: (listener) => themeSpacing(themeDensity(listener) * padding),\n ...(divider\n ? {\n borderBottom: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color.get(listener))}`,\n }\n : {}),\n },\n };\n}\n\nexport { panelSection };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Themed paragraph primitive: comfortable line-height, reset margins and themed\n * text color. Apply to a `<p>` element.\n *\n * @hostTag p\n * @param props - Optional configuration.\n * @param props.color - Color tone for the paragraph text. Defaults to `\"neutral\"`.\n * @example { p: \"Hello world\", $: [paragraph()] }\n */\nfunction paragraph(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"p\") {\n console.warn(`\"paragraph\" primitive patch must use p tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n lineHeight: 1.5,\n marginTop: 0,\n marginBottom: 0,\n },\n };\n}\n\nexport { paragraph };\n","import {\n type DomphyElement,\n type Listener,\n merge,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport { themeColor, themeDensity, themeSpacing } from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\n\n/**\n * Floating popover primitive. Attaches to its host as the anchor/trigger and\n * shows a floating `content` element (with `role=\"dialog\"`) on click or hover,\n * positioned via `@domphy/floating`. Returns the anchor partial, which merges\n * trigger wiring (haspopup/expanded, focus/blur dismissal). Apply to the\n * trigger element you want the popover anchored to.\n *\n * @param props - Configuration.\n * @param props.openOn - Interaction that opens the popover: `\"click\"` or `\"hover\"`. Defaults to `\"click\"`.\n * @param props.open - Open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so Escape/outside click can close. Defaults to `false`.\n * @param props.onDismiss - Called when the panel requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.placement - Floating placement (e.g. `\"bottom\"`, `\"top-start\"`), value or `State`. Defaults to `\"bottom\"`.\n * @param props.content - The floating content element to display.\n * @example { button: \"Open\", $: [popover({ openOn: \"click\", content: { div: \"Hi\" } })] }\n */\nfunction popover(props: {\n openOn?: \"click\" | \"hover\";\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement?: ValueOrState<Placement>;\n content: DomphyElement;\n}): PartialElement {\n const { open = false, placement = \"bottom\", openOn = \"click\" } = props;\n\n const openState = toState(open);\n const placeState = toState(placement);\n\n const { show, hide, anchorPartial } = createFloating({\n kind: \"popover\",\n open: openState,\n onDismiss: props.onDismiss,\n placement: placeState,\n content: props.content,\n // Hovering the panel itself (not just the trigger) must keep it open —\n // handled generically inside floating.ts's behavior instance.\n keepOpenOnContentHover: openOn === \"hover\",\n });\n\n // The panel id is derived from the ANCHOR's nodeId and stamped by the\n // shared floating behavior when the panel mounts (see floating.ts) — no\n // factory-scope id variable, which a re-rendered generation would lose.\n const popoverPartial: PartialElement = {\n role: \"dialog\",\n dataTone: \"shift-14\",\n style: {\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n // Surface contract (dataTone-surface-contract): a tone-anchored panel\n // must declare BOTH background and text color — on the dark shift-14\n // surface, inherited portal context colors can fall below contrast.\n color: (l: Listener) => themeColor(l, \"text\"),\n borderRadius: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n outline: (l: Listener) => `1px solid ${themeColor(l, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n\n props.content.$ ||= [];\n props.content.$.push(popoverPartial);\n\n const triggerPartial: PartialElement = {\n ariaHaspopup: \"dialog\",\n ariaExpanded: (listener) => openState.get(listener),\n // Declared as a reactive attribute (listener.elementNode is the anchor) so\n // it is present from first render — before the panel's first show() — and\n // is re-declared on every patch: attributes set imperatively (the old\n // _onMount attributes.set) are stripped by patch() on ancestor re-render.\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"popover\", listener.elementNode)\n : undefined,\n onMouseEnter: (_e, node) => openOn === \"hover\" && show(node),\n onMouseLeave: (_e, node) => openOn === \"hover\" && hide(node),\n onClick: (_e, node) => {\n if (openOn === \"click\") {\n if (openState.get()) {\n hide(node);\n } else {\n show(node);\n }\n }\n },\n onKeyDown: (e, node) => {\n if ((e as KeyboardEvent).key === \"Escape\" && openState.get()) hide(node);\n },\n onFocus: (_e, node) => openOn === \"hover\" && show(node),\n onBlur: (e, node) => {\n // Docs: focus has no effect when openOn is click — only hover-mode\n // blur dismisses (and even then, not when focus moved INTO the panel).\n if (openOn !== \"hover\") return;\n const related = (e as FocusEvent).relatedTarget as Node | null;\n const root = node.getRoot().domElement as Element;\n // Tabbing from the trigger INTO the panel must not close the popover.\n // The id is deterministic and selector-safe ([a-z0-9-] only — nodeId is\n // a letter + hex hash), so this lookup works for every generation —\n // the old factory-scope `popoverId` was null in any generation whose\n // content _onInsert had never run, letting the guard fall through.\n const floatingEl = root.querySelector(\n `#${floatingPanelId(\"popover\", node)}`,\n );\n if (related && floatingEl?.contains(related)) return;\n hide(node);\n },\n };\n merge(anchorPartial, triggerPartial);\n\n return anchorPartial;\n}\n\nexport { popover };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Renders a small rotated arrow (via a `::after` pseudo-element) that points from a\n * popover/tooltip toward its anchor, positioned and oriented based on the floating placement.\n * The arrow direction is computed by flipping the given placement. No host-tag check is\n * performed; apply it to the popover container element.\n *\n * @param props.placement - Floating placement the popover sits at; the arrow is drawn on the\n * opposite (flipped) side. Accepts a value or reactive state. Defaults to `\"bottom-end\"`.\n * One of: `top` | `bottom` | `left` | `right` | `top-start` | `top-end` | `bottom-start` |\n * `bottom-end` | `left-start` | `left-end` | `right-start` | `right-end`.\n * @param props.sideOffset - CSS length used to offset the arrow toward the start/end edge.\n * Defaults to `themeSpacing(6)`.\n * @param props.color - Theme color tone for the arrow fill and border. Defaults to `\"neutral\"`.\n * @param props.bordered - Whether the arrow draws a 1px border (set to `0px` when false).\n * Defaults to `true`.\n * @example { div: [...], $: [popoverArrow({ placement: \"top\" })] }\n */\nfunction popoverArrow(\n props: {\n placement?: ValueOrState<Placement>;\n sideOffset?: string;\n color?: ThemeColor;\n bordered?: boolean;\n } = {},\n): PartialElement {\n const {\n placement = \"bottom-end\",\n color = \"neutral\",\n sideOffset = themeSpacing(6),\n bordered = true,\n } = props;\n\n const place = toState(placement);\n\n const flipMap: Record<Placement, Placement> = {\n top: \"bottom\",\n bottom: \"top\",\n left: \"right\",\n right: \"left\",\n \"top-start\": \"bottom-end\",\n \"top-end\": \"bottom-start\",\n \"bottom-start\": \"top-end\",\n \"bottom-end\": \"top-start\",\n \"left-start\": \"right-end\",\n \"left-end\": \"right-start\",\n \"right-start\": \"left-end\",\n \"right-end\": \"left-start\",\n };\n\n const getFlipped = (listener: any) =>\n flipMap[place.get(listener)] ?? flipMap[\"bottom-end\"];\n const start = (pos: string) =>\n pos.includes(\"start\") ? sideOffset : pos.includes(\"end\") ? \"auto\" : \"50%\";\n const end = (pos: string) =>\n pos.includes(\"end\") ? sideOffset : pos.includes(\"start\") ? \"auto\" : \"50%\";\n\n return {\n style: {\n fontSize: (listener) => themeSize(listener),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color),\n position: \"relative\",\n \"&::after\": {\n content: `\"\"`,\n position: \"absolute\",\n width: themeSpacing(1.5),\n height: themeSpacing(1.5),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n borderWidth: bordered ? \"1px\" : 0,\n borderColor: (listener) => themeColor(listener, \"border-strong\", color),\n borderTopStyle: (listener) => {\n const pos = getFlipped(listener);\n\n return pos.includes(\"top\") || pos.includes(\"right\")\n ? `solid`\n : \"none\";\n },\n borderBottomStyle: (listener) => {\n const pos = getFlipped(listener);\n\n return pos.includes(\"bottom\") || pos.includes(\"left\")\n ? `solid`\n : \"none\";\n },\n borderLeftStyle: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"top\") || pos.includes(\"left\") ? `solid` : \"none\";\n },\n borderRightStyle: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"bottom\") || pos.includes(\"right\")\n ? `solid`\n : \"none\";\n },\n top: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"top\")\n ? 0\n : pos.includes(\"bottom\")\n ? \"auto\"\n : start(pos);\n },\n right: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"right\")\n ? 0\n : pos.includes(\"left\")\n ? \"auto\"\n : end(pos);\n },\n bottom: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"bottom\")\n ? 0\n : pos.includes(\"top\")\n ? \"auto\"\n : end(pos);\n },\n left: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"left\")\n ? 0\n : pos.includes(\"right\")\n ? \"auto\"\n : start(pos);\n },\n transform: (listener) => {\n const pos = getFlipped(listener);\n const x =\n pos.includes(\"right\") ||\n (pos.includes(\"end\") && !pos.includes(\"left\"))\n ? \"50%\"\n : \"-50%\";\n const y =\n pos.includes(\"bottom\") ||\n (pos.includes(\"end\") && !pos.includes(\"top\"))\n ? \"50%\"\n : \"-50%\";\n return `translate(${x},${y}) rotate(45deg)`;\n },\n },\n },\n };\n}\n\nexport { popoverArrow };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a preformatted text block: inherited font size, themed foreground/background,\n * no border, density-scaled padding and rounded corners.\n *\n * @hostTag pre\n * @param props.color - Theme color tone for text and background. Accepts a value or reactive\n * state. Defaults to `\"neutral\"`.\n * @example { pre: \"const x = 1\", $: [preformated()] }\n */\nfunction preformated(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n _onInsert: (node) => {\n if (node.tagName !== \"pre\") {\n console.warn(`\"preformated\" primitive patch must use pre tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n },\n };\n}\n\nexport { preformated };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Styles a native progress bar: full-width, pill-shaped track with a themed fill,\n * including the WebKit progress-bar/value pseudo-elements and a width transition.\n *\n * @hostTag progress\n * @param props.color - Theme color tone for the track/background. Accepts a value or reactive\n * state. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color tone for the filled value. Accepts a value or reactive\n * state. Defaults to `\"primary\"`.\n * @example { progress: null, value: 40, max: 100, $: [progress()] }\n */\nfunction progress(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"progress\") {\n console.warn(`\"progress\" primitive patch must use progress tag`);\n }\n },\n // Track surface — shift via dataTone, paint with inherit.\n dataTone: \"shift-3\",\n style: {\n appearance: \"none\",\n width: \"100%\",\n height: themeSpacing(2),\n border: 0,\n borderRadius: themeSpacing(999),\n overflow: \"hidden\",\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&::-webkit-progress-bar\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n borderRadius: themeSpacing(999),\n },\n \"&::-webkit-progress-value\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-9\", accentColor.get(listener)),\n borderRadius: themeSpacing(999),\n transition: \"width 220ms ease\",\n },\n },\n };\n}\n\nexport { progress };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n rawHtml,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst STAR_FILLED =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" width=\"1em\" height=\"1em\">` +\n `<path d=\"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z\"/>` +\n `</svg>`;\nconst STAR_EMPTY =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" width=\"1em\" height=\"1em\">` +\n `<path d=\"M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z\"/>` +\n `</svg>`;\n\ntype RatingProps = {\n value?: ValueOrState<number>;\n max?: number;\n onChange?: (value: number) => void;\n readOnly?: boolean;\n color?: ThemeColor;\n};\n\ntype RatingLive = {\n valueState: State<number>;\n onChange?: (value: number) => void;\n readOnly: boolean;\n max: number;\n color: ThemeColor;\n};\n\nfunction applyRatingProps(live: RatingLive, next: RatingProps): void {\n live.onChange = next.onChange;\n live.readOnly = next.readOnly ?? false;\n live.max = next.max ?? 5;\n live.color = next.color ?? \"warning\";\n if (isState(next.value)) {\n if (next.value !== live.valueState) {\n live.valueState.set(next.value.get());\n }\n } else if (next.value !== undefined) {\n // Plain number stays live. Omitted value leaves the internal state\n // alone so an uncontrolled click is not reset on a later factory call.\n live.valueState.set(next.value);\n }\n}\n\nfunction insertStar(\n node: ElementNode,\n index: number,\n live: RatingLive,\n hoveredState: State<number>,\n): void {\n const activeCount = (listener: Listener) => {\n const hovered = hoveredState.get(listener);\n return hovered > 0 ? hovered : live.valueState.get(listener);\n };\n\n const star: DomphyElement<\"button\"> = {\n button: (listener) =>\n rawHtml(index <= activeCount(listener) ? STAR_FILLED : STAR_EMPTY),\n _key: index,\n type: \"button\",\n ariaLabel: `${index} star${index > 1 ? \"s\" : \"\"}`,\n onClick: () => {\n if (live.readOnly) return;\n const next = index === live.valueState.get() ? 0 : index;\n live.valueState.set(next);\n live.onChange?.(next);\n hoveredState.set(0);\n },\n onMouseEnter: () => {\n if (live.readOnly) return;\n hoveredState.set(index);\n },\n onMouseLeave: () => hoveredState.set(0),\n onKeyDown: (e: KeyboardEvent) => {\n if (live.readOnly) return;\n const current = live.valueState.get();\n let next = current;\n if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") {\n next = Math.min(live.max, current + 1);\n e.preventDefault();\n } else if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") {\n next = Math.max(0, current - 1);\n e.preventDefault();\n } else {\n return;\n }\n live.valueState.set(next);\n live.onChange?.(next);\n const target = next > 0 ? next - 1 : 0;\n (node.domElement?.children[target] as HTMLElement)?.focus();\n },\n style: {\n background: \"none\",\n border: \"none\",\n outline: \"none\",\n borderRadius: themeSpacing(1),\n padding: 0,\n cursor: \"inherit\",\n color: \"inherit\",\n fontSize: \"inherit\",\n display: \"flex\",\n alignItems: \"center\",\n transition: \"box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, live.color),\n },\n },\n };\n node.children.insert(star);\n}\n\nfunction syncStars(\n node: ElementNode,\n live: RatingLive,\n hoveredState: State<number>,\n): void {\n const children = node.children.items;\n while (children.length > live.max) {\n node.children.remove(children[children.length - 1]);\n }\n for (let index = children.length + 1; index <= live.max; index++) {\n insertStar(node, index, live, hoveredState);\n }\n}\n\n/**\n * Interactive star rating applied to a container `<div>`. Manages its own star\n * children: click to set, Arrow keys to adjust, hover to preview. In `readOnly`\n * mode stars are non-interactive. Apply to a `<div>` element.\n *\n * Star insert runs in `_onInit` (SSR markup). `onChange`/`readOnly`/`max` and\n * a plain-number `value` stay live via `behavior()` `update()` so a reused\n * node picks up the latest factory props.\n *\n * @hostTag div\n * @param props.value - Current rating (0 – max). `ValueOrState<number>`, defaults to `0`.\n * @param props.max - Total number of stars. Optional `number`, defaults to `5`.\n * @param props.onChange - Called with the new value when the user picks a star.\n * @param props.readOnly - Disable interaction. Optional `boolean`, defaults to `false`.\n * @param props.color - Star color tone. Optional `ThemeColor`, defaults to `\"warning\"`.\n * @example { div: null, $: [rating({ value: ratingState, onChange: (v) => ratingState.set(v) })] }\n */\nfunction rating(props: RatingProps = {}): PartialElement {\n const live: RatingLive = {\n valueState: toState(props.value ?? 0),\n onChange: props.onChange,\n readOnly: props.readOnly ?? false,\n max: props.max ?? 5,\n color: props.color ?? \"warning\",\n };\n const hoveredState = toState(0);\n\n return {\n role: \"group\",\n ariaLabel: \"Rating\",\n style: {\n display: \"inline-flex\",\n gap: themeSpacing(0.5),\n // 1.5× inherited control size (theme-owned type scale, not a px/rem literal).\n fontSize: (listener) => themeSize(listener, \"increase-1\"),\n cursor: live.readOnly ? \"default\" : \"pointer\",\n color: (listener) => themeColor(listener, \"muted\", live.color),\n },\n ...behavior<RatingProps>(\n \"rating\",\n (node, initial) => {\n applyRatingProps(live, initial);\n syncStars(node, live, hoveredState);\n return {\n update(next) {\n applyRatingProps(live, next);\n syncStars(node, live, hoveredState);\n },\n };\n },\n {\n value: props.value,\n max: props.max ?? 5,\n onChange: props.onChange,\n readOnly: props.readOnly ?? false,\n color: props.color ?? \"warning\",\n },\n ),\n // Build stars as real child elements (not imperative DOM mutation in\n // _onMount) so generateHTML()/SSR emits the actual star markup.\n _onInit: (node) => {\n syncStars(node, live, hoveredState);\n },\n };\n}\n\nexport { rating };\n","import type { PartialElement, StyleObject } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Circular ring progress indicator rendered via CSS `conic-gradient` and a\n * circular `mask`. Progress starts at 12 o'clock and advances clockwise.\n * Exposes `role=\"progressbar\"` with `aria-valuenow/min/max`. Apply to a `<div>`.\n *\n * @hostTag div\n * @param props.value - Progress percentage 0–100. Accepts a value or reactive state. Defaults to `0`.\n * @param props.color - Theme color for the filled arc. Accepts a value or reactive state. Defaults to `\"primary\"`.\n * @param props.trackColor - Theme color for the background track. Accepts a value or reactive state. Defaults to `\"neutral\"`.\n * @param props.size - Diameter in `themeSpacing` units. Defaults to `16` (= `4em`).\n * @param props.thickness - Ring stroke as a fraction of the radius (0–0.5). Defaults to `0.25`.\n * @example { div: null, $: [ringProgress({ value: 65 })] }\n * @example { div: null, $: [ringProgress({ value: loadingState, color: \"success\", size: 20 })] }\n */\nfunction ringProgress(\n props: {\n value?: ValueOrState<number>;\n color?: ValueOrState<ThemeColor>;\n trackColor?: ValueOrState<ThemeColor>;\n size?: number;\n thickness?: number;\n } = {},\n): PartialElement {\n const { size = 16, thickness = 0.25 } = props;\n const value = toState(props.value ?? 0, \"value\");\n const color = toState(props.color ?? \"primary\", \"color\");\n const trackColor = toState(props.trackColor ?? \"neutral\", \"trackColor\");\n\n // Mask cuts the center to create a donut shape.\n // Uses `closest-side` so the gradient circle matches the visible element circle\n // exactly, making `holePercent` directly represent the fraction of outer radius.\n const holePercent = Math.round((1 - thickness) * 100);\n const mask = `radial-gradient(circle closest-side, transparent ${holePercent}%, black ${holePercent}%)`;\n\n return {\n role: \"progressbar\",\n ariaValuenow: (l) => String(Math.round(value.get(l))),\n ariaValuemin: \"0\",\n ariaValuemax: \"100\",\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn('\"ringProgress\" patch must use div tag');\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: themeSpacing(size),\n height: themeSpacing(size),\n borderRadius: \"50%\",\n // Text color tracks the filled arc so any overlay label inherits it.\n color: (l) => themeColor(l, \"shift-9\", color.get(l)),\n // Fill arc from 12 o'clock clockwise; `from -90deg` rotates the start point.\n background: (l) =>\n `conic-gradient(from -90deg, ${themeColor(l, \"shift-9\", color.get(l))} ${value.get(l)}%, ${themeColor(l, \"shift-3\", trackColor.get(l))} 0%)`,\n WebkitMask: mask,\n mask,\n } as StyleObject,\n };\n}\n\nexport { ringProgress };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeDensity, themeSpacing } from \"@domphy/theme\";\nimport type { FlexAlign, FlexJustify } from \"./stack.js\";\n\n/**\n * A horizontal flex row with spacing between children, vertically centered by\n * default. The general-purpose primitive for icon+label rows, field rows,\n * and button groups — instead of hand-rolling `display: flex; alignItems:\n * center; gap: ...`. `toolbar()` is a semantic alias of this same shape for\n * headers/nav bars. Styles the host only; apply to any block element.\n *\n * @param props.gap - Spacing multiplier for gap between items (default 4).\n * Bounded-control mode (`density: true`, default): `themeSpacing(themeDensity(l) * gap)`\n * — at default density 1.5, gap 4 = 1.5em.\n * Structural/page-column mode (`density: false`): bare `themeSpacing(gap)` with no\n * density multiply — gap 4 = 1em, matching AGENTS.md \"bare themeSpacing(n)\".\n * @param props.align - Cross-axis alignment (`alignItems`). Defaults to `\"center\"`.\n * @param props.justify - Main-axis distribution (`justifyContent`). Unset by default (flex-start).\n * @param props.wrap - Allow items to wrap onto multiple lines. Defaults to `false`.\n * @param props.density - When true (default), gap is multiplied by theme density\n * (bounded controls). When false, gap is structural `themeSpacing(n)` — use this\n * for page/form columns.\n * @example { div: [{ span: \"Icon\" }, { span: \"Label\" }], $: [row()] }\n * @example { div: [...], $: [row({ justify: \"space-between\", wrap: true })] }\n * @example { div: [...], $: [row({ gap: 4, density: false })] }\n */\nfunction row(\n props: {\n gap?: number;\n align?: FlexAlign;\n justify?: FlexJustify;\n wrap?: boolean;\n density?: boolean;\n } = {},\n): PartialElement {\n const { gap = 4, align = \"center\", justify, wrap = false, density = true } =\n props;\n return {\n style: {\n display: \"flex\",\n alignItems: align,\n gap: density\n ? (listener) => themeSpacing(themeDensity(listener) * gap)\n : () => themeSpacing(gap),\n ...(justify ? { justifyContent: justify } : {}),\n ...(wrap ? { flexWrap: \"wrap\" } : {}),\n },\n };\n}\n\nexport { row };\nexport type { FlexJustify };\n","import type { PartialElement, StyleObject } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Applies thin, themed overlay scrollbars to any scrollable container.\n * Covers WebKit (Chrome/Safari/Edge) via `::-webkit-scrollbar` pseudo-elements\n * and Firefox via `scrollbar-width`/`scrollbar-color`. Sets `overflow: auto`.\n * No host-tag check; apply to any block element.\n *\n * @param props.color - Theme color for the scrollbar thumb. Accepts a value or\n * reactive state. Defaults to `\"neutral\"`.\n * @example { div: [...], style: { maxHeight: \"300px\" }, $: [scrollArea()] }\n */\nfunction scrollArea(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n style: {\n overflow: \"auto\",\n // Container text color so theme token usage also carries a reactive `color`.\n color: (l) => themeColor(l, \"text\", color.get(l)),\n \"&::-webkit-scrollbar\": {\n width: themeSpacing(2),\n height: themeSpacing(2),\n },\n \"&::-webkit-scrollbar-track\": {\n background: \"transparent\",\n },\n \"&::-webkit-scrollbar-thumb\": {\n backgroundColor: (l) => themeColor(l, \"shift-5\", color.get(l)),\n borderRadius: themeSpacing(999),\n // Transparent border creates visual padding around the thumb.\n border: `${themeSpacing(0.5)} solid transparent`,\n backgroundClip: \"content-box\",\n },\n \"&::-webkit-scrollbar-thumb:hover\": {\n backgroundColor: (l) => themeColor(l, \"shift-7\", color.get(l)),\n },\n // Firefox thin scrollbar with matching thumb/track colors.\n scrollbarWidth: \"thin\",\n scrollbarColor: (l) =>\n `${themeColor(l, \"shift-5\", color.get(l))} transparent`,\n } as StyleObject,\n };\n}\n\nexport { scrollArea };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One item inside a segmented control. */\ntype SegmentedItem = {\n /** Button label — plain string (auto-wrapped) or any DomphyElement. */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index. */\n key?: string;\n};\n\ntype SegmentedLive = {\n items: SegmentedItem[];\n color: ThemeColor;\n accentColor: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction moveSegment(\n e: Event,\n items: SegmentedItem[],\n key: string,\n value: State<string>,\n): void {\n const k = (e as KeyboardEvent).key;\n if (![\"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = items.map((item, index) => item.key ?? String(index));\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowRight\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowLeft\") next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n value.set(keys[next]);\n const group = (e.target as HTMLElement).closest(\"[role=radiogroup]\");\n group?.querySelectorAll<HTMLElement>(\"[role=radio]\")[next]?.focus();\n}\n\nfunction buildSegmentButtons(\n items: SegmentedItem[],\n value: State<string>,\n color: ThemeColor,\n accentColor: ThemeColor,\n): DomphyElement<\"button\">[] {\n return items.map((item, index) => {\n const key = item.key ?? String(index);\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n button: [labelEl],\n _key: key,\n type: \"button\",\n role: \"radio\",\n ariaChecked: (l: Listener) => value.get(l) === key,\n tabIndex: (l: Listener) => {\n const current = value.get(l);\n if (current === key) return 0;\n if (current === \"\" && key === (items[0]?.key ?? \"\")) return 0;\n return -1;\n },\n onClick: () => value.set(key),\n onKeyDown: (e: Event) => moveSegment(e, items, key, value),\n style: {\n cursor: \"pointer\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: themeSpacing(6),\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(3),\n border: \"none\",\n borderRadius: themeSpacing(10),\n color: (l: Listener) => themeColor(l, \"text\", color),\n backgroundColor: \"transparent\",\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled]):not([aria-checked=true])\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\", color),\n },\n \"&:active:not([disabled]):not([aria-checked=true])\": {\n backgroundColor: (l: Listener) => themeColor(l, \"increase-2\", color),\n },\n \"&[aria-checked=true]\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-0\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-10\", accentColor),\n // Selected segment sits slightly above the track.\n boxShadow: elevation(\"low\"),\n },\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor),\n },\n \"&[aria-checked=true]:focus-visible\": {\n boxShadow: (l: Listener) =>\n `${elevation(\"low\")}, ${focusRing(l, accentColor)}`,\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n } as DomphyElement<\"button\">;\n });\n}\n\n/**\n * All-in-one single-select segmented control. Generates `<button>` option\n * elements from the `items` array. Apply to any wrapper element.\n *\n * @param props.items - Item definitions `{ label, key? }`.\n * @param props.value - Initially selected key (value or State). Defaults to the first item's key.\n * @param props.color - Theme color for the control background. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for the selected item. Defaults to `\"primary\"`.\n * @example\n * { div: null, $: [segmented({ items: [\n * { label: \"Day\", key: \"day\" },\n * { label: \"Month\", key: \"month\" },\n * { label: \"Year\", key: \"year\" },\n * ] })] }\n */\nfunction segmented(\n props: {\n items: SegmentedItem[];\n value?: ValueOrState<string>;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const { items = [], color = \"neutral\", accentColor = \"primary\" } = props;\n const live: SegmentedLive = { items, color, accentColor };\n\n return {\n role: \"radiogroup\",\n // Publish value so descendants can read the selected segment.\n _context: {\n segmented: { value: toState(props.value ?? items[0]?.key ?? \"\") },\n },\n _onSchedule: (node, element) => {\n const value = persistValue(\n node,\n \"segmentedValue\",\n props.value,\n items[0]?.key ?? \"\",\n );\n (element as Record<string, unknown>)[node.tagName] = buildSegmentButtons(\n items,\n value,\n color,\n accentColor,\n );\n },\n ...behavior<SegmentedLive>(\n \"segmented-items\",\n (node) => ({\n update(snapshot) {\n const value = persistValue(\n node,\n \"segmentedValue\",\n props.value,\n snapshot.items[0]?.key ?? \"\",\n );\n node.children.update(\n buildSegmentButtons(\n snapshot.items,\n value,\n snapshot.color,\n snapshot.accentColor,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n // Track is a soft surface anchor — shift via dataTone, paint with inherit.\n dataTone: \"shift-2\",\n style: {\n display: \"inline-flex\",\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(1),\n gap: themeSpacing(0.5),\n borderRadius: themeSpacing(10),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n color: (l: Listener) => themeColor(l, \"text\", color),\n },\n };\n}\n\nexport { segmented };\nexport type { SegmentedItem };\n","import type { Listener, PartialElement } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeColorToken,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native `<select>` control: removes the default appearance, applies themed\n * colors, outline, density-scaled padding/radius, a custom chevron background icon, and\n * hover/focus/disabled/optgroup/option states.\n *\n * @hostTag select\n * @param props.color - Theme color tone for text, background and outline. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color tone for hover/focus outlines. Defaults to `\"primary\"`.\n * @example { select: [{ option: \"A\" }], $: [select()] }\n */\nfunction select(\n props: { color?: ThemeColor; accentColor?: ThemeColor } = {},\n): PartialElement {\n const { color = \"neutral\", accentColor = \"primary\" } = props;\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"select\") {\n console.warn(`\"select\" primitive patch must use select tag`);\n }\n },\n style: {\n appearance: \"none\",\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color)}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingLeft: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingRight: (listener) => themeSpacing(themeDensity(listener) * 5),\n backgroundImage: (l: Listener) => {\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 10 6\"><path d=\"M1 1l4 4 4-4\" stroke=\"${themeColorToken(l, \"shift-7\")}\" stroke-width=\"1.5\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n return `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`;\n },\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: `right ${themeSpacing(2)} center`,\n backgroundSize: `${themeSpacing(2.5)} ${themeSpacing(1.5)}`,\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:not([multiple])\": {\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor)}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n \"& optgroup\": {\n color: (listener) => themeColor(listener, \"shift-11\", color),\n },\n \"& option[disabled]\": {\n color: (listener) => themeColor(listener, \"shift-7\", \"neutral\"),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n },\n },\n };\n}\n\nexport { select };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n merge,\n type PartialElement,\n type State,\n type StyleObject,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport { tag } from \"./tag.js\";\n\n// Typeahead (Radix Select character-search parity): printable characters\n// accumulate into a buffer that resets after 1s of idle; the buffer is a\n// case-insensitive prefix match against option labels. CLOSED trigger: the\n// match becomes the selection (native <select> behavior). OPEN panel: focus\n// moves to the matching [role=option] — focus is the keyboard highlight.\n// A buffer of one repeated character (\"aaa\") cycles through that char's\n// matches instead of pinning the first; disabled options are skipped.\nconst TYPEAHEAD_RESET_MS = 1000;\n\ntype TypeaheadMeta = {\n buffer: string;\n timer: ReturnType<typeof setTimeout> | null;\n};\n\n// The buffer lives on the NODE (not the factory closure): a selectBox inside\n// a reactive parent gets a fresh closure per ancestor re-render, and a\n// closure-local buffer would silently reset mid-typing on the reused node.\nfunction resolveTypeahead(node: ElementNode): TypeaheadMeta {\n let meta = node.getMetadata(\"selectBoxTypeahead\") as\n | TypeaheadMeta\n | undefined;\n if (!meta) {\n meta = { buffer: \"\", timer: null };\n node.setMetadata(\"selectBoxTypeahead\", meta);\n }\n return meta;\n}\n\nconst matchesPrefix = (label: string, needle: string) =>\n label.trim().toLowerCase().startsWith(needle);\n\nfunction enabledPanelOptions(panel: Element | null): HTMLElement[] {\n if (!panel) return [];\n return Array.from(\n panel.querySelectorAll<HTMLElement>(\"[role=option]\"),\n ).filter(\n (el) =>\n el.getAttribute(\"aria-disabled\") !== \"true\" &&\n !el.hasAttribute(\"disabled\"),\n );\n}\n\n/**\n * A clickable select trigger box that renders the currently selected option(s) as removable\n * tags and toggles a floating popover (the dropdown content) anchored to itself. Selected\n * labels are derived from `options` matching the bound `value`; removing a tag updates the value.\n * Keyboard: Enter/Space toggle, ArrowDown opens, Escape closes, and printable characters\n * typeahead-search options (closed: selects the match; open: focuses the matching\n * `[role=option]` in the panel; a repeated character cycles matches).\n *\n * @hostTag div\n * @param props.multiple - Whether multiple selection is allowed (renders removable tags and\n * keeps the popover open on click). Defaults to `false`.\n * @param props.value - Bound selection value(s). Accepts a value or reactive state of an array of\n * `number | string | null | undefined`, or a single `number | string | null | undefined`.\n * @param props.options - List of `{ label, value }` options used to resolve selected labels.\n * Defaults to `[]`.\n * @param props.placement - Floating placement of the dropdown popover. Accepts a value or\n * reactive state. Defaults to `\"bottom\"`.\n * @param props.content - Required. The popover/dropdown content element shown when open.\n * @param props.color - Theme color tone for the box text/background. Defaults to `\"neutral\"`.\n * @param props.open - Whether the popover is open. Accepts a value or reactive state (`ValueOrState<boolean>`, including `Computed`/`ReadableState`). Defaults to `false`. When the source is read-only, pass `onDismiss` so dismiss can close.\n * @param props.onDismiss - Called when the popover requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @example { div: null, $: [selectBox({ content: { div: [...] }, options: [{ label: \"A\", value: \"a\" }] })] }\n */\nfunction selectBox(props: {\n multiple?: boolean;\n value?: ValueOrState<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n options?: Array<{ label: string; value: string }>;\n placement?: ValueOrState<Placement>;\n content: DomphyElement;\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n}): PartialElement {\n const {\n options = [],\n placement = \"bottom\",\n color = \"neutral\",\n open = false,\n multiple = false,\n } = props;\n\n const state = toState(props.value);\n const openState = toState(open);\n const { show, hide, anchorPartial } = createFloating({\n kind: \"selectBox\",\n open: openState,\n onDismiss: props.onDismiss,\n placement: toState(placement),\n content: props.content,\n });\n\n const popoverPartial: PartialElement = {\n onClick: (_e, node) => !multiple && hide(node),\n dataTone: \"shift-14\",\n style: {\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n // Surface contract (dataTone-surface-contract): a tone-anchored panel\n // must declare BOTH background and text color — on the dark shift-14\n // surface, inherited portal context colors can fall below contrast.\n color: (listener) => themeColor(listener, \"text\"),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n\n merge(props.content, popoverPartial);\n\n type InnerProps = {\n options: Array<{ label: string; value: string }>;\n multiple: boolean;\n color: ThemeColor;\n state: State<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n };\n\n const buildWrap = (inner: InnerProps): DomphyElement<\"div\"> => ({\n div: (listener) => {\n const val = inner.state.get(listener);\n const vals = Array.isArray(val) ? val : [val];\n const opts = inner.options.filter((opt) => vals.includes(opt.value));\n return opts.map((opt) => ({\n span: opt.label,\n $: [tag({ color: inner.color, removable: inner.multiple })],\n _key: opt.value,\n _onRemove: (_node: ElementNode) => {\n const cur = inner.state.get();\n const curVals = Array.isArray(cur) ? cur : [cur];\n const filter = curVals.filter((v) => v !== opt.value);\n inner.multiple\n ? inner.state.set(filter as any)\n : inner.state.set(filter[0] as any);\n },\n })) as DomphyElement<\"span\">[];\n },\n _key: \"selectBoxWrap\",\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: themeSpacing(1),\n flex: 1,\n } as StyleObject,\n });\n\n const attachInner = (\n node: ElementNode,\n _inner: InnerProps,\n ): BehaviorInstance<InnerProps> => {\n return {\n update(next) {\n node.children.update([buildWrap(next)]);\n },\n };\n };\n\n const toggle = (node?: ElementNode) =>\n openState.get() ? hide(node) : show(node);\n\n const typeahead = (key: string, node: ElementNode) => {\n const meta = resolveTypeahead(node);\n if (meta.timer) clearTimeout(meta.timer);\n meta.buffer += key.toLowerCase();\n meta.timer = setTimeout(() => {\n meta.buffer = \"\";\n }, TYPEAHEAD_RESET_MS);\n // \"aaa\" cycles through the a* matches rather than matching \"aaa\" literally.\n const repeated = meta.buffer.length > 1 && new Set(meta.buffer).size === 1;\n const needle = repeated ? meta.buffer[0]! : meta.buffer;\n\n if (openState.get()) {\n // Panel is portaled under the root (see floating.ts); its id is\n // deterministic, same lookup pattern as popover's onBlur guard.\n const root = node.getRoot().domElement as Element | null;\n const panel =\n root?.querySelector(`#${floatingPanelId(\"selectBox\", node)}`) ?? null;\n const matches = enabledPanelOptions(panel).filter((el) =>\n matchesPrefix(el.textContent ?? \"\", needle),\n );\n if (!matches.length) return;\n const active = node.domElement?.ownerDocument\n ?.activeElement as HTMLElement | null;\n const from = repeated && active ? matches.indexOf(active) : -1;\n const target = matches[(from + 1) % matches.length]!;\n target.focus();\n target.scrollIntoView?.({ block: \"nearest\" });\n return;\n }\n\n // Closed trigger: selection follows typeahead. Single-select only — a\n // multi-select tag set has no \"current option\" to move from.\n if (multiple) return;\n const matches = options.filter((opt) => matchesPrefix(opt.label, needle));\n if (!matches.length) return;\n const from = repeated\n ? matches.findIndex((opt) => opt.value === state.get())\n : -1;\n const next = matches[(from + 1) % matches.length]!;\n state.set(next.value as any);\n };\n\n const partial: PartialElement = {\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"selectBox\" patch must use div tag`);\n }\n },\n _onSchedule: (node, element) => {\n (element as Record<string, unknown>)[node.tagName] = [\n buildWrap({ options, multiple, color, state }),\n ];\n },\n ...behavior<InnerProps>(\"selectBoxInner\", attachInner, {\n options,\n multiple,\n color,\n state,\n }),\n onClick: (_e, node) => toggle(node),\n // Focusable trigger: click + Enter/Space/ArrowDown open (APG button+listbox).\n // Escape dismiss composes with createFloating's hide path.\n tabindex: 0,\n role: \"button\",\n // Reactive boolean (same pattern as popover) — do NOT pin a static\n // ariaExpanded or patch re-apply will overwrite after keyboard open.\n ariaExpanded: (listener) => openState.get(listener),\n ariaHaspopup: \"listbox\",\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"selectBox\", listener.elementNode)\n : undefined,\n onKeyDown: (e, node) => {\n const key = (e as KeyboardEvent).key;\n if (key === \"Escape\") {\n hide(node);\n return;\n }\n if (key === \"Enter\" || key === \" \") {\n e.preventDefault();\n toggle(node);\n return;\n }\n if (key === \"ArrowDown\" && !openState.get()) {\n e.preventDefault();\n show(node);\n return;\n }\n // Character typeahead (Radix Select parity) — modifier chords are\n // shortcuts, not search input.\n const kb = e as KeyboardEvent;\n if (key.length === 1 && !kb.ctrlKey && !kb.metaKey && !kb.altKey) {\n typeahead(key, node);\n }\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n minHeight: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n minWidth: themeSpacing(32),\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 2),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n transition:\n \"background-color 140ms ease, outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color),\n },\n },\n };\n\n merge(anchorPartial, partial);\n return anchorPartial;\n}\n\nexport { selectBox };\n","import type { PartialElement } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * A single selectable option row (`role=\"option\"`) for use inside a `selectList`. Reads the\n * `select` context to reflect/toggle selection: it sets `aria-selected` from the bound value and\n * toggles the value (single or multiple) on click. Styles hover/selected/focus states.\n *\n * @hostTag div\n * @param props.accentColor - Theme color tone for the selected/focus state. Defaults to `\"primary\"`.\n * @param props.color - Theme color tone for text/background. Defaults to `\"neutral\"`.\n * @param props.value - The option value compared against and written to the select state.\n * Defaults to `null`.\n * @example { div: \"Option A\", $: [selectItem({ value: \"a\" })] }\n */\nfunction selectItem(\n props: {\n accentColor?: ThemeColor;\n color?: ThemeColor;\n value?: number | string;\n } = {},\n): PartialElement {\n const { accentColor = \"primary\", color = \"neutral\", value = null } = props;\n\n const partial: PartialElement = {\n role: \"option\",\n // Programmatically focusable (not tabbable): selectBox typeahead and\n // keyboard navigation move focus between options roving-style.\n tabindex: -1,\n // aria-selected and the click toggler must be DECLARED on the partial, not\n // wired imperatively in _onInit: hooks run once per real DOM node, but\n // patch() resets _events and strips undeclared attributes on every\n // ancestor re-render — so imperative wiring was lost on the first reuse\n // while the (once-run) hook never re-installed it. The reactive reader\n // resolves the `select` context lazily through listener.elementNode, so\n // every generation re-binds to whatever context is actually live.\n ariaSelected: (listener) => {\n const select = listener?.elementNode?.getContext(\"select\");\n if (!select) return undefined;\n const val = select.value.get(listener);\n return select.multiple ? val.includes(value) : val === value;\n },\n onClick: (_e, node) => {\n const select = node.getContext(\"select\");\n if (!select) return;\n const state = select.value;\n const val = state.get();\n if (select.multiple) {\n val.includes(value)\n ? state.set(val.filter((v: number | string) => v !== value))\n : state.set(val.concat([value]));\n } else {\n val !== value && state.set(value);\n }\n },\n _onInit: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"selectItem\" patch must use div tag`);\n }\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n border: \"none\",\n outline: \"none\",\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n \"&:hover:not([disabled]):not([aria-selected=true])\": {\n backgroundColor: (listener) => themeColor(listener, \"hover\", color),\n },\n \"&[aria-selected=true]\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-6\", accentColor),\n color: (listener) => themeColor(listener, \"shift-11\"),\n },\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n },\n };\n return partial;\n}\n\nexport { selectItem };\n","import {\n type DomphyElement,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Container for a list of `selectItem`s that owns the selection state. It exposes a `select`\n * context (`{ value, multiple }`) consumed by child items, and injects hidden `<input>`(s)\n * carrying the selected value(s) under `name` for form submission.\n *\n * @hostTag div\n * @param props.multiple - Whether multiple selection is allowed; also sets the default empty\n * value (`[]` vs `null`). Defaults to `false`.\n * @param props.value - Bound selection value(s). Accepts a value or reactive state of an array of\n * `number | string | null`, or a single `number | string | null`. Defaults to `[]` when\n * `multiple`, otherwise `null`.\n * @param props.color - Theme color tone for the background. Defaults to `\"neutral\"`.\n * @param props.name - Name attribute for the hidden inputs (form field name).\n * @example { div: [{ div: \"A\", $: [selectItem({ value: \"a\" })] }], $: [selectList({ name: \"pick\" })] }\n */\nfunction selectList(\n props: {\n multiple?: boolean;\n value?: ValueOrState<\n Array<number | string | null> | number | string | null\n >;\n color?: ThemeColor;\n name?: string;\n } = {},\n): PartialElement {\n const { color = \"neutral\", multiple = false } = props;\n const state = toState(props.value ?? (multiple ? [] : null));\n\n // type=hidden form fields (not a visible input) — avoid axe label/listbox noise.\n const inputs: DomphyElement<\"div\"> = {\n div: (listener) => {\n const val = state.get(listener);\n const vals = Array.isArray(val) ? val : [val];\n return vals.map((v) => ({\n input: null,\n type: \"hidden\",\n name: props.name,\n // Preserve a legitimate numeric 0 (and other falsy-but-valid values);\n // `v || \"\"` would drop them.\n value: v == null ? \"\" : String(v),\n }));\n },\n // Keep out of the a11y tree; listbox children must be options.\n ariaHidden: \"true\",\n hidden: true,\n };\n\n const partial: PartialElement = {\n dataTone: \"shift-0\",\n // selectItem uses role=option; options require a listbox parent (WAI-ARIA).\n role: \"listbox\",\n ariaLabel: \"Options\",\n ariaMultiselectable: multiple ? \"true\" : undefined,\n _context: {\n select: {\n value: state,\n multiple,\n },\n },\n _onInit: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"selectList\" patch must use a div tag`);\n }\n node.children.insert(inputs);\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n color: (listener) => themeColor(listener, \"text\", color),\n },\n };\n return partial;\n}\n\nexport { selectList };\n","import {\n hashString,\n type PartialElement,\n type StyleObject,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A loading placeholder block with a left-to-right shimmer gradient. Marked\n * `aria-hidden`, themed background/foreground, fixed height, slight rounding.\n * No host-tag check; typically applied to a block-level element such as a\n * `div` or `span`.\n *\n * @param props.color - Theme color tone for the placeholder. Accepts a value or reactive state.\n * Defaults to `\"neutral\"`.\n * @example { div: null, $: [skeleton()] }\n */\nfunction skeleton(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n // Shimmer sweeps left→right over a near-white base (reads as loading, not\n // a flat opacity blink). Base + highlight are both theme tokens so the\n // effect adapts to light/dark surfaces. Highlight stays close to the base\n // (shift-2) — a deeper step reads as dirty banding on light themes.\n const keyframes = {\n \"0%\": { backgroundPosition: \"200% 0\" },\n \"100%\": { backgroundPosition: \"-200% 0\" },\n };\n const animationName = hashString(JSON.stringify(keyframes));\n return {\n ariaHidden: \"true\",\n dataTone: \"shift-1\",\n style: {\n fontSize: (listener) => themeSize(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n height: themeSpacing(6),\n display: \"block\",\n borderRadius: themeSpacing(1),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n backgroundImage: (listener) =>\n `linear-gradient(90deg, ${themeColor(listener, \"inherit\", color.get(listener))} 0%, ${themeColor(listener, \"shift-2\", color.get(listener))} 50%, ${themeColor(listener, \"inherit\", color.get(listener))} 100%)`,\n backgroundSize: \"200% 100%\",\n animation: `${animationName} 1.6s ease-in-out infinite`,\n [`@keyframes ${animationName}`]: keyframes,\n } as StyleObject,\n };\n}\n\nexport { skeleton };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Styles small/secondary text: one step smaller font size (`data-size=\"decrease-1\"`) with a\n * themed foreground color.\n *\n * @hostTag small\n * @param props.color - Theme color tone for the text. Accepts a value or reactive state.\n * Defaults to `\"neutral\"`.\n * @example { small: \"fine print\", $: [small()] }\n */\nfunction small(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"small\") {\n console.warn('\"small\" patch must use small tag');\n }\n },\n dataSize: \"decrease-1\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n // shift-10 (not muted/shift-8) keeps WCAG AA ≥4.5:1 on light surfaces for small type.\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n };\n}\n\nexport { small };\n","import type { PartialElement, StyleObject } from \"@domphy/core\";\nimport { hashString, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\nconst keyframes = { to: { transform: \"rotate(360deg)\" } };\nconst animationName = hashString(JSON.stringify(keyframes));\n\n/**\n * A circular loading spinner: a themed ring with a contrasting top border that rotates\n * continuously. Marked `role=\"status\"` with `aria-label=\"loading\"`.\n *\n * @hostTag span\n * @param props.color - Theme color tone for the ring/highlight. Accepts a value or reactive\n * state. Defaults to `\"neutral\"`.\n * @example { span: null, $: [spinner()] }\n */\nfunction spinner(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n role: \"status\",\n ariaLabel: \"loading\",\n _onInsert: (node) => {\n if (node.tagName !== \"span\") {\n console.warn(`\"spinner\" patch must use span tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n display: \"inline-block\",\n margin: 0,\n flexShrink: 0,\n width: themeSpacing(6),\n height: themeSpacing(6),\n borderRadius: \"50%\",\n border: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderTopColor: (listener) =>\n themeColor(listener, \"shift-9\", color.get(listener)),\n boxSizing: \"border-box\",\n padding: 0,\n animation: `${animationName} 0.7s linear infinite`,\n [`@keyframes ${animationName}`]: keyframes,\n } as StyleObject,\n };\n}\n\nexport { spinner };\n","import { ElementNode, merge, type PartialElement, toState } from \"@domphy/core\";\nimport { themeColor, themeSpacing } from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Root of a resizable split layout. Lays out children as a flex row (horizontal) or column\n * (vertical) and provides a `splitter` context (`{ direction, size, min, max }`) consumed by\n * `splitterPanel` and `splitterHandle`. `size` is a reactive state holding the first panel's\n * percentage. No host-tag check; typically applied to a `div`.\n *\n * @param props.direction - Split orientation, `\"horizontal\"` | `\"vertical\"`. Defaults to `\"horizontal\"`.\n * @param props.defaultSize - Initial size (percentage) of the resizable panel. Defaults to `50`.\n * @param props.min - Minimum panel size (percentage). Defaults to `10`.\n * @param props.max - Maximum panel size (percentage). Defaults to `90`.\n * @example { div: [...], $: [splitter({ direction: \"vertical\" })] }\n */\nfunction splitter(\n props: {\n direction?: \"horizontal\" | \"vertical\";\n defaultSize?: number;\n min?: number;\n max?: number;\n } = {},\n): PartialElement {\n const {\n direction = \"horizontal\",\n defaultSize = 50,\n min = 10,\n max = 90,\n } = props;\n return {\n _onSchedule: (_node, element) => {\n merge(element, {\n _context: {\n splitter: {\n direction,\n size: toState(defaultSize),\n min,\n max,\n // Legacy bookkeeping kept on the context object for compatibility.\n // First-vs-second assignment uses sibling order (see splitterPanel).\n panelCount: 0,\n },\n },\n });\n },\n style: {\n display: \"flex\",\n flexDirection: direction === \"horizontal\" ? \"row\" : \"column\",\n overflow: \"hidden\",\n },\n };\n}\n\n/**\n * The resizable panel inside a `splitter`. Reads the `splitter` context and binds its\n * width (horizontal) or height (vertical) to the context `size` state, updating reactively as\n * the handle is dragged. Intended for exactly two panels either side of one `splitterHandle`:\n * the first `splitterPanel` mounted takes `size`%, and the second takes the complementary\n * `100 - size`% — so the pair always sums to the full width/height instead of both tracking\n * the same number (which would make them grow and shrink together instead of trading space).\n * Warns if used outside a `splitter`. Takes no props.\n *\n * @example { div: [...], $: [splitterPanel()] }\n */\nfunction isFirstSplitterPanel(node: ElementNode): boolean {\n const parent = node.parent;\n if (!parent) return true;\n for (const item of parent.children.items) {\n if (item instanceof ElementNode && item.getMetadata(\"splitterPanel\")) {\n return item === node;\n }\n }\n return true;\n}\n\nfunction splitterPanel(): PartialElement {\n return {\n _metadata: { splitterPanel: true },\n _onMount: (node) => {\n const ctx = node.getContext(\"splitter\");\n if (!ctx) {\n console.warn(`\"splitterPanel\" patch must be used inside a \"splitter\"`);\n return;\n }\n const el = node.domElement as HTMLElement;\n const prop = ctx.direction === \"horizontal\" ? \"width\" : \"height\";\n\n const apply = (size: number) => {\n el.style[prop] = `${isFirstSplitterPanel(node) ? size : 100 - size}%`;\n };\n apply(ctx.size.get());\n el.style.flexShrink = \"0\";\n el.style.overflow = \"auto\";\n\n const release = ctx.size.addListener(apply);\n node.addHook(\"Remove\", () => {\n ctx.panelCount = Math.max(0, (ctx.panelCount ?? 1) - 1);\n release();\n });\n },\n };\n}\n\n/**\n * The draggable divider inside a `splitter`. Reads the `splitter` context, shows the\n * appropriate resize cursor, and updates the context `size` state (clamped to `min`/`max`)\n * via mouse drag or keyboard: Arrow keys move by 1%, Home/End jump to min/max, hold Shift\n * for 10× step. Sets `role=\"separator\"`, `tabindex=\"0\"`, and `aria-value*` attributes.\n * Warns if used outside a `splitter`. Takes no props.\n *\n * @example { div: null, $: [splitterHandle()] }\n */\nfunction splitterHandle(): PartialElement {\n return {\n role: \"separator\",\n tabindex: 0,\n _onMount: (node) => {\n const ctx = node.getContext(\"splitter\");\n if (!ctx) {\n console.warn(`\"splitterHandle\" patch must be used inside a \"splitter\"`);\n return;\n }\n const handle = node.domElement as HTMLElement;\n const isHorizontal = ctx.direction === \"horizontal\";\n\n handle.style.cursor = isHorizontal ? \"col-resize\" : \"row-resize\";\n handle.setAttribute(\n \"aria-orientation\",\n isHorizontal ? \"vertical\" : \"horizontal\",\n );\n handle.setAttribute(\"aria-valuemin\", String(ctx.min));\n handle.setAttribute(\"aria-valuemax\", String(ctx.max));\n handle.setAttribute(\"aria-valuenow\", String(Math.round(ctx.size.get())));\n\n const releaseAriaValue = ctx.size.addListener((size: number) => {\n handle.setAttribute(\"aria-valuenow\", String(Math.round(size)));\n });\n\n const onKeydown = (e: KeyboardEvent) => {\n const step = e.shiftKey ? 10 : 1;\n let next: number | null = null;\n if (isHorizontal) {\n if (e.key === \"ArrowRight\")\n next = Math.min(ctx.size.get() + step, ctx.max);\n else if (e.key === \"ArrowLeft\")\n next = Math.max(ctx.size.get() - step, ctx.min);\n } else {\n if (e.key === \"ArrowDown\")\n next = Math.min(ctx.size.get() + step, ctx.max);\n else if (e.key === \"ArrowUp\")\n next = Math.max(ctx.size.get() - step, ctx.min);\n }\n if (e.key === \"Home\") next = ctx.min;\n else if (e.key === \"End\") next = ctx.max;\n if (next !== null) {\n e.preventDefault();\n ctx.size.set(next);\n }\n };\n\n let cancelDrag: (() => void) | null = null;\n\n const onMousedown = (e: MouseEvent) => {\n e.preventDefault();\n const container = handle.parentElement!;\n\n const onMousemove = (e: MouseEvent) => {\n const rect = container.getBoundingClientRect();\n const raw = isHorizontal\n ? ((e.clientX - rect.left) / rect.width) * 100\n : ((e.clientY - rect.top) / rect.height) * 100;\n ctx.size.set(Math.min(Math.max(raw, ctx.min), ctx.max));\n };\n\n const onMouseup = () => {\n document.removeEventListener(\"mousemove\", onMousemove);\n document.removeEventListener(\"mouseup\", onMouseup);\n cancelDrag = null;\n };\n\n cancelDrag = () => {\n document.removeEventListener(\"mousemove\", onMousemove);\n document.removeEventListener(\"mouseup\", onMouseup);\n cancelDrag = null;\n };\n\n document.addEventListener(\"mousemove\", onMousemove);\n document.addEventListener(\"mouseup\", onMouseup);\n };\n\n handle.addEventListener(\"keydown\", onKeydown);\n handle.addEventListener(\"mousedown\", onMousedown);\n node.addHook(\"Remove\", () => {\n cancelDrag?.();\n releaseAriaValue();\n handle.removeEventListener(\"keydown\", onKeydown);\n handle.removeEventListener(\"mousedown\", onMousedown);\n });\n },\n // Soft divider surface — shift via dataTone, paint with inherit.\n dataTone: \"shift-2\",\n style: {\n flexShrink: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n \"&:hover\": {\n backgroundColor: (listener) => themeColor(listener, \"increase-1\"),\n },\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, \"primary\"),\n },\n \"&::after\": {\n content: '\"\"',\n // A small grip dot so the handle is visibly draggable. Without an\n // explicit size the pseudo-element collapses to 0x0 and is invisible.\n width: themeSpacing(1),\n height: themeSpacing(1),\n borderRadius: themeSpacing(999),\n backgroundColor: (listener) => themeColor(listener, \"shift-4\"),\n },\n },\n };\n}\n\nexport { splitter, splitterPanel, splitterHandle };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeDensity, themeSpacing } from \"@domphy/theme\";\n\ntype FlexAlign = \"flex-start\" | \"center\" | \"flex-end\" | \"stretch\" | \"baseline\";\n\ntype FlexJustify =\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n\n/**\n * A vertical flex column with spacing between children. The general-purpose\n * primitive for stacking blocks — form sections, panel content, card bodies —\n * instead of hand-rolling `display: flex; flexDirection: column; gap: ...`.\n * Styles the host only; apply to any block element.\n *\n * @param props.gap - Spacing multiplier for gap between children (default 3).\n * Bounded-control mode (`density: true`, default): `themeSpacing(themeDensity(l) * gap)`\n * — at default density 1.5, gap 3 = 1.125em.\n * Structural/page-column mode (`density: false`): bare `themeSpacing(gap)` with no\n * density multiply — gap 3 = 0.75em, matching AGENTS.md \"bare themeSpacing(n)\".\n * @param props.align - Cross-axis alignment (`alignItems`). Unset by default (flex default, stretch).\n * @param props.justify - Main-axis distribution (`justifyContent`). Unset by default (flex-start).\n * @param props.density - When true (default), gap is multiplied by theme density\n * (bounded controls). When false, gap is structural `themeSpacing(n)` — use this\n * for page/form columns.\n * @example { div: [{ h3: \"Title\" }, { p: \"Body\" }], $: [stack()] }\n * @example { div: [...], $: [stack({ gap: 2, align: \"center\" })] }\n * @example { div: [...], $: [stack({ gap: 3, density: false, justify: \"space-between\" })] }\n */\nfunction stack(\n props: {\n gap?: number;\n align?: FlexAlign;\n justify?: FlexJustify;\n density?: boolean;\n } = {},\n): PartialElement {\n const { gap = 3, align, justify, density = true } = props;\n return {\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: density\n ? (listener) => themeSpacing(themeDensity(listener) * gap)\n : () => themeSpacing(gap),\n ...(align ? { alignItems: align } : {}),\n ...(justify ? { justifyContent: justify } : {}),\n },\n };\n}\n\nexport { stack };\nexport type { FlexAlign, FlexJustify };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/** One step entry. */\ntype StepItem = {\n /** Step label — plain string (auto-wrapped) or any DomphyElement. */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index. */\n key?: string | number;\n};\n\ntype StepsLive = {\n items: StepItem[];\n direction: \"horizontal\" | \"vertical\";\n color: ThemeColor;\n accentColor: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction stepConnectorStyle(\n direction: \"horizontal\" | \"vertical\",\n color: ThemeColor,\n accentColor: ThemeColor,\n) {\n if (direction === \"vertical\") {\n // Outgoing track: from this badge's bottom through the host gap to the\n // next badge. Incoming-from-current-item cannot span the previous\n // item's variable label height.\n return {\n \"&:not(:last-child)::after\": {\n content: '\"\"',\n position: \"absolute\",\n left: themeSpacing(3),\n top: themeSpacing(6),\n bottom: `-${themeSpacing(2)}`,\n width: \"2px\",\n height: \"auto\",\n right: \"auto\",\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\", color),\n zIndex: \"0\",\n },\n \"&[data-status=done]:not(:last-child)::after\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n },\n };\n }\n return {\n \"&:not(:first-child)::after\": {\n content: '\"\"',\n position: \"absolute\",\n top: themeSpacing(3),\n right: `calc(50% + ${themeSpacing(3)})`,\n left: `calc(-50% + ${themeSpacing(3)})`,\n height: \"2px\",\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\", color),\n zIndex: \"0\",\n },\n \"&[data-status=done]:not(:first-child)::after\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n },\n \"&[data-status=active]:not(:first-child)::after\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n },\n };\n}\n\nfunction buildStepItems(\n items: StepItem[],\n current: State<number>,\n direction: \"horizontal\" | \"vertical\",\n color: ThemeColor,\n accentColor: ThemeColor,\n): DomphyElement<\"li\">[] {\n const vertical = direction === \"vertical\";\n const connector = stepConnectorStyle(direction, color, accentColor);\n\n return items.map((item, index) => {\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n li: [labelEl],\n _key: item.key ?? index,\n dataStep: String(index + 1),\n dataStatus: (l: Listener) => {\n const cur = current.get(l);\n if (index < cur) return \"done\";\n if (index === cur) return \"active\";\n return \"pending\";\n },\n ariaCurrent: (l: Listener) =>\n current.get(l) === index ? \"step\" : undefined,\n style: {\n position: \"relative\",\n display: \"flex\",\n flexDirection: vertical ? \"row\" : \"column\",\n alignItems: vertical ? \"flex-start\" : \"center\",\n gap: themeSpacing(1),\n flex: vertical ? \"none\" : \"1\",\n fontSize: (l: Listener) => themeSize(l, \"decrease-1\"),\n textAlign: vertical ? \"left\" : \"center\",\n \"&::before\": {\n content: \"attr(data-step)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: themeSpacing(6),\n height: themeSpacing(6),\n borderRadius: themeSpacing(999),\n fontSize: (l: Listener) => themeSize(l, \"decrease-1\"),\n fontWeight: \"bold\",\n flexShrink: \"0\",\n border: (l: Listener) =>\n `2px solid ${themeColor(l, \"border-strong\", color)}`,\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n color: (l: Listener) => themeColor(l, \"muted\"),\n transition:\n \"background-color 200ms ease, color 200ms ease, border-color 200ms ease\",\n zIndex: \"1\",\n },\n ...connector,\n \"&[data-status=active]::before\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-9\", accentColor),\n borderColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-0\", accentColor),\n boxShadow: (l: Listener) =>\n `0 0 0 3px ${themeColor(l, \"shift-3\", accentColor)}`,\n },\n // Completed steps: filled accent + check, matching active track.\n \"&[data-status=done]::before\": {\n content: '\"✓\"',\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-9\", accentColor),\n borderColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-0\", accentColor),\n },\n \"&[data-status=pending]\": {\n color: (l: Listener) => themeColor(l, \"muted\"),\n },\n \"&[data-status=active]\": {\n color: (l: Listener) => themeColor(l, \"shift-11\", accentColor),\n fontWeight: \"bold\",\n },\n \"&[data-status=done]\": {\n color: (l: Listener) => themeColor(l, \"text\", color),\n },\n },\n } as DomphyElement<\"li\">;\n });\n}\n\n/**\n * All-in-one step-progress indicator. Generates `<li>` step elements from the\n * `items` array. Apply to an `<ol>` or `<ul>` element.\n *\n * @param props.items - Step definitions `{ label, key? }`.\n * @param props.current - Zero-based index of the active step (value or State). Defaults to `0`.\n * @param props.direction - `\"horizontal\"` (default) or `\"vertical\"` layout.\n * @param props.color - Theme color for pending/track elements. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for active/completed elements. Defaults to `\"primary\"`.\n * @example\n * { ol: null, $: [steps({ current: 1, items: [\n * { label: \"Cart\" },\n * { label: \"Shipping\" },\n * { label: \"Payment\" },\n * ] })] }\n */\nfunction steps(\n props: {\n items: StepItem[];\n current?: ValueOrState<number>;\n direction?: \"horizontal\" | \"vertical\";\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const {\n items = [],\n direction = \"horizontal\",\n color = \"neutral\",\n accentColor = \"primary\",\n } = props;\n const live: StepsLive = { items, direction, color, accentColor };\n\n return {\n // Step badge weight is design-system chrome for the progress control.\n _doctorDisable: \"inline-typography\",\n // Publish current/direction/colors so descendants can read the indicator.\n _context: {\n steps: {\n current: toState(props.current ?? 0),\n direction,\n color,\n accentColor,\n },\n },\n _onSchedule: (node, element) => {\n const current = persistValue(node, \"stepsCurrent\", props.current, 0);\n (element as Record<string, unknown>)[node.tagName] = buildStepItems(\n items,\n current,\n direction,\n color,\n accentColor,\n );\n },\n ...behavior<StepsLive>(\n \"steps-items\",\n (node) => ({\n update(snapshot) {\n const current = persistValue(node, \"stepsCurrent\", props.current, 0);\n node.children.update(\n buildStepItems(\n snapshot.items,\n current,\n snapshot.direction,\n snapshot.color,\n snapshot.accentColor,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n style: {\n display: \"flex\",\n flexDirection: direction === \"vertical\" ? \"column\" : \"row\",\n alignItems: direction === \"vertical\" ? \"flex-start\" : \"center\",\n gap: themeSpacing(2),\n listStyle: \"none\",\n margin: \"0\",\n padding: \"0\",\n },\n };\n}\n\nexport { steps };\nexport type { StepItem };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Styles strongly emphasized (bold) text: inherited font size, `font-weight: 700`, and a\n * themed foreground color.\n *\n * @hostTag strong\n * @param props.color - Theme color tone for the text. Accepts a value or reactive state.\n * Defaults to `\"neutral\"`.\n * @example { strong: \"important\", $: [strong()] }\n */\nfunction strong(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"strong\") {\n console.warn(`\"strong\" primitive patch must use strong tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontWeight: \"bold\",\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n backgroundColor: (listener) => themeColor(listener),\n },\n };\n}\n\nexport { strong };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Renders subscript text (shrunk, baseline-lowered) for the host `<sub>` element.\n *\n * @hostTag sub\n * @param props.color - Theme color for the text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { sub: \"2\", $: [subscript()] }\n */\nfunction subscript(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"sub\") {\n console.warn(`\"subscript\" primitive patch must use sub tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n verticalAlign: \"sub\",\n lineHeight: 0,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { subscript };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Renders superscript text (shrunk, baseline-raised) for the host `<sup>` element.\n *\n * @hostTag sup\n * @param props.color - Theme color for the text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { sup: \"2\", $: [superscript()] }\n */\nfunction superscript(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"sup\") {\n console.warn(`\"superscript\" primitive patch must use sup tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n verticalAlign: \"super\",\n lineHeight: 0,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { superscript };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a data table (header/body/footer cells, caption, row hover, borders)\n * on the host `<table>` element.\n *\n * @hostTag table\n * @param props.color - Theme color applied across cells and text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { table: null, $: [table()] }\n */\nfunction table(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"table\") {\n console.warn(`\"table\" primitive patch must use table tag`);\n }\n },\n // Header/footer weights are design-system table chrome.\n _doctorDisable: \"inline-typography\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n width: \"100%\",\n borderCollapse: \"collapse\",\n \"& caption\": {\n captionSide: \"bottom\",\n },\n \"& th, & thead td\": {\n textAlign: \"left\",\n fontWeight: 500,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n },\n \"& td\": {\n textAlign: \"left\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n boxShadow: (listener) =>\n `inset 0 1px 0 ${themeColor(listener, \"shift-3\", color.get(listener))}`,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n },\n \"& tfoot th, & tfoot td\": {\n textAlign: \"left\",\n fontWeight: 500,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n color: (l) => themeColor(l, \"shift-10\", color.get(l)),\n backgroundColor: (l) => themeColor(l, \"inherit\"),\n boxShadow: (l) =>\n `inset 0 -1px 0 ${themeColor(l, \"shift-4\", color.get(l))}`,\n },\n \"& tr\": {\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n },\n\n // No !important needed: \".scope tbody tr:hover\" (two classes + two\n // elements) already out-specifies any row's own auto-scope class rule.\n \"& tbody tr:hover\": {\n backgroundColor: (listener) => themeColor(listener, \"hover\"),\n },\n },\n };\n}\n\nexport { table };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One tab entry: a trigger label and its panel content. */\ntype TabItem = {\n /** Tab button label — a plain string (auto-wrapped in span) or any DomphyElement. */\n label: string | DomphyElement;\n /** Panel content rendered when this tab is active. */\n content: DomphyElement;\n /** Stable identity key. Defaults to the item's zero-based index. */\n key?: string | number;\n};\n\ntype TabsLive = {\n items: TabItem[];\n accentColor: ThemeColor;\n color: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction buildTabsChildren(\n node: ElementNode,\n items: TabItem[],\n activeKey: State<string | number>,\n accentColor: ThemeColor,\n color: ThemeColor,\n): DomphyElement[] {\n const id = node.nodeId;\n\n const buttons: DomphyElement<\"button\">[] = items.map((item, index) => {\n const key = item.key ?? index;\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n button: [labelEl],\n _key: key,\n type: \"button\",\n role: \"tab\",\n id: `tab${id}${key}`,\n ariaControls: `panel${id}${key}`,\n ariaSelected: (l: Listener) => activeKey.get(l) === key,\n // Roving tabindex (APG tabs pattern): only the selected tab is in\n // the tab order; arrow keys move both selection and focus.\n tabIndex: (l: Listener) => (activeKey.get(l) === key ? 0 : -1),\n onClick: () => activeKey.set(key),\n onKeyDown: (e: Event) => {\n const k = (e as KeyboardEvent).key;\n if (![\"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = items.map((it, i) => it.key ?? i);\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowRight\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowLeft\")\n next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n activeKey.set(keys[next]);\n // Focus must follow selection: without this the next arrow key\n // fires on the OLD tab and re-navigates from its stale position,\n // making later tabs unreachable by keyboard. Resolved via the\n // event target's own tablist — shadow-root safe (unlike a\n // document.getElementById lookup).\n const list = (e.target as HTMLElement).closest(\"[role=tablist]\");\n list?.querySelectorAll<HTMLElement>(\"[role=tab]\")[next]?.focus();\n },\n style: {\n cursor: \"pointer\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: (l: Listener) => themeSpacing(6 + themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 4),\n border: \"none\",\n outline: \"none\",\n // Resting tabs: shift-13 for ≥4.5:1 on surface (catalog low-contrast).\n color: (l: Listener) => themeColor(l, \"shift-13\"),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n boxShadow: (l: Listener) =>\n `inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-1\", color)}`,\n transition: \"box-shadow 140ms ease, color 140ms ease\",\n \"&:hover:not([disabled]):not([aria-selected=true])\": {\n color: (l: Listener) => themeColor(l, \"shift-13\"),\n boxShadow: (l: Listener) =>\n `inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-2\", color)}`,\n },\n \"&[aria-selected=true]:not([disabled])\": {\n color: (l: Listener) => themeColor(l, \"shift-13\", accentColor),\n boxShadow: (l: Listener) =>\n `inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-8\", accentColor)}`,\n },\n // Focus ring must compose with the selected underline (both use\n // box-shadow) so keyboard focus doesn't erase the active indicator.\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor),\n },\n \"&[aria-selected=true]:focus-visible\": {\n boxShadow: (l: Listener) =>\n `${focusRing(l, accentColor)}, inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-6\", accentColor)}`,\n },\n },\n } as DomphyElement<\"button\">;\n });\n\n const tablist: DomphyElement<\"div\"> = {\n div: buttons,\n _key: \"tablist\",\n role: \"tablist\",\n ariaOrientation: \"horizontal\",\n style: { display: \"flex\" },\n } as DomphyElement<\"div\">;\n\n const panels: DomphyElement<\"div\">[] = items.map((item, index) => {\n const key = item.key ?? index;\n return {\n div: [item.content],\n _key: key,\n role: \"tabpanel\",\n id: `panel${id}${key}`,\n ariaLabelledby: `tab${id}${key}`,\n hidden: (l: Listener) => activeKey.get(l) !== key,\n style: {\n paddingBlock: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n },\n } as DomphyElement<\"div\">;\n });\n\n return [tablist, ...panels];\n}\n\n/**\n * All-in-one tabs patch. Generates a `[role=tablist]` button row and\n * `[role=tabpanel]` panels from the `items` array. Apply to any wrapper\n * element (`div`, `section`, …). No companion `tab()` / `tabPanel()` needed.\n *\n * To control the active tab programmatically, pass an external `State` as\n * `activeKey` and call `.set()` on it from outside.\n *\n * @param props.items - Tab definitions `{ label, content, key? }`.\n * @param props.activeKey - Initially active key (value or State). Defaults to the first item's key.\n * @param props.accentColor - Theme color for the active underline indicator. Defaults to `\"primary\"`.\n * @param props.color - Theme color for the resting underline. Defaults to `\"neutral\"`.\n * @example\n * { div: null, $: [tabs({ items: [\n * { label: \"Overview\", content: { p: \"Overview content\" } },\n * { label: \"API\", content: { p: \"API content\" } },\n * ] })] }\n */\nfunction tabs(\n props: {\n items: TabItem[];\n activeKey?: ValueOrState<string | number>;\n accentColor?: ThemeColor;\n color?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const { items = [], accentColor = \"primary\", color = \"neutral\" } = props;\n const live: TabsLive = { items, accentColor, color };\n\n return {\n _onSchedule: (node, element) => {\n const activeKey = persistValue(\n node,\n \"tabsActiveKey\",\n props.activeKey,\n items[0]?.key ?? 0,\n );\n (element as Record<string, unknown>)[node.tagName] = buildTabsChildren(\n node,\n items,\n activeKey,\n accentColor,\n color,\n );\n },\n ...behavior<TabsLive>(\n \"tabs-items\",\n (node) => ({\n update(snapshot) {\n const activeKey = persistValue(\n node,\n \"tabsActiveKey\",\n props.activeKey,\n snapshot.items[0]?.key ?? 0,\n );\n node.children.update(\n buildTabsChildren(\n node,\n snapshot.items,\n activeKey,\n snapshot.accentColor,\n snapshot.color,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n };\n}\n\nexport { tabs };\nexport type { TabItem };\n","import {\n type BehaviorInstance,\n behavior,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a multi-line text input (border, focus/hover/invalid/disabled states)\n * on the host `<textarea>` element, with optional auto-resize to content.\n *\n * @hostTag textarea\n * @param props.color - Theme color for the border and text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for hover/focus outline. Optional, accepts a value or state. Defaults to `\"primary\"`.\n * @param props.autoResize - When true, grows the textarea height to fit its content on input and when `value` updates, and remeasures when the host becomes visible (IntersectionObserver) and when its box size changes (ResizeObserver). Optional. Defaults to `false`.\n * @example { textarea: null, $: [textarea({ autoResize: true })] }\n */\nfunction textarea(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n autoResize?: boolean;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n const { autoResize = false } = props;\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"textarea\") {\n console.warn(`\"textarea\" primitive patch must use textarea tag`);\n }\n },\n // Resize on mount, on input, and when the host `value` attribute updates\n // (controlled writes skip the input event).\n ...behavior(\n \"textarea-auto-resize\",\n (node, initial) => {\n const el = node.domElement as HTMLTextAreaElement;\n let enabled = initial.autoResize;\n let measuring = false;\n let intersectionObserver: IntersectionObserver | undefined;\n let resizeObserver: ResizeObserver | undefined;\n const resize = () => {\n if (!enabled || measuring) return;\n measuring = true;\n // Unobserve during the height write so ResizeObserver cannot\n // re-enter from the measure itself (jsdom may deliver RO sync).\n resizeObserver?.unobserve(el);\n el.style.overflow = \"hidden\";\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight}px`;\n measuring = false;\n if (enabled) resizeObserver?.observe(el);\n };\n const observe = () => {\n if (typeof IntersectionObserver !== \"undefined\") {\n if (!intersectionObserver) {\n intersectionObserver = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) resize();\n });\n }\n intersectionObserver.observe(el);\n }\n if (typeof ResizeObserver !== \"undefined\") {\n if (!resizeObserver) {\n resizeObserver = new ResizeObserver(() => {\n if (measuring) return;\n resize();\n });\n }\n resizeObserver.observe(el);\n }\n };\n const unobserve = () => {\n intersectionObserver?.unobserve(el);\n resizeObserver?.unobserve(el);\n };\n el.addEventListener(\"input\", resize);\n node.attributes.addListener(\"value\", resize);\n if (enabled) {\n observe();\n resize();\n }\n return {\n resize,\n update(next) {\n enabled = next.autoResize;\n node.attributes.addListener(\"value\", resize);\n if (enabled) {\n observe();\n resize();\n } else {\n unobserve();\n }\n },\n destroy() {\n el.removeEventListener(\"input\", resize);\n intersectionObserver?.disconnect();\n resizeObserver?.disconnect();\n },\n };\n },\n { autoResize },\n ),\n _onUpdate: (node) => {\n node\n .getBehavior<\n BehaviorInstance<{ autoResize: boolean }> & { resize: () => void }\n >(\"textarea-auto-resize\")\n ?.resize();\n },\n style: {\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n resize: \"vertical\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n border: \"none\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::placeholder\": {\n color: (listener) => themeColor(listener, \"shift-7\"),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&:invalid\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-5\", \"error\")}`,\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n },\n },\n };\n}\n\nexport { textarea };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Container for a vertical timeline. Sets list reset styles. Apply to `<ol>` or `<ul>`.\n *\n * @example { ol: [...], $: [timeline()] }\n */\nfunction timeline(): PartialElement {\n return {\n style: {\n listStyle: \"none\",\n margin: 0,\n padding: 0,\n display: \"flex\",\n flexDirection: \"column\",\n },\n };\n}\n\n/**\n * A single event row in a `timeline`. Uses a 2-column grid: the left column holds\n * a dot (`::before`) and optional connector line (`::after`); the right column holds\n * the user's content. Apply to `<li>`.\n *\n * @param props.active - Full-opacity dot (accent color). `ValueOrState<boolean>`, defaults to `false`.\n * @param props.last - Suppress the vertical connector below this item. `boolean`, defaults to `false`.\n * @param props.color - Dot/connector color tone. `ThemeColor`, defaults to `\"neutral\"`.\n * @param props.accentColor - Active dot color tone. `ThemeColor`, defaults to `\"primary\"`.\n * @example { li: [{ b: \"2024\" }, { p: \"Event\" }], $: [timelineItem({ active: true })] }\n */\nfunction timelineItem(\n props: {\n active?: ValueOrState<boolean>;\n last?: boolean;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = {},\n): PartialElement {\n const { last = false } = props;\n const color = props.color ?? \"neutral\";\n const accentColor = props.accentColor ?? \"primary\";\n const activeState = toState(props.active ?? false);\n\n return {\n style: {\n display: \"grid\",\n gridTemplateColumns: \"2rem 1fr\",\n columnGap: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBottom: (listener) =>\n last ? \"0\" : themeSpacing(themeDensity(listener) * 4),\n position: \"relative\",\n\n // Dot\n \"&::before\": {\n content: '\"\"',\n display: \"block\",\n width: \"0.75rem\",\n height: \"0.75rem\",\n borderRadius: \"50%\",\n justifySelf: \"center\",\n marginTop: themeSpacing(1),\n transition: \"background-color 200ms ease, opacity 200ms ease\",\n backgroundColor: (listener) =>\n themeColor(\n listener,\n \"shift-8\",\n activeState.get(listener) ? accentColor : color,\n ),\n opacity: (listener) => (activeState.get(listener) ? \"1\" : \"0.4\"),\n },\n\n // Vertical connector to the next item\n ...(last\n ? {}\n : {\n \"&::after\": {\n content: '\"\"',\n position: \"absolute\",\n left: \"calc(1rem - 1px)\",\n top: \"1.25rem\",\n bottom: (listener) => themeSpacing(themeDensity(listener) * -4),\n width: \"2px\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", color),\n },\n }),\n },\n };\n}\n\nexport { timeline, timelineItem };\n","import type {\n DomphyElement,\n ElementNode,\n PartialElement,\n State,\n} from \"@domphy/core\";\nimport { toState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\n\ntype ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\n// The open state must live on the NODE, not in the factory closure: a toast\n// inside a reactive parent gets a fresh toast() closure per ancestor\n// re-render (fresh `toState(false)`), while `_onMount` (which flips the state\n// to visible via rAF) runs ONCE for the first generation. The reused node's\n// re-patched style bindings would read the new generation's still-false\n// state and snap the visible toast back to opacity 0 / translated out.\n// Resolving through node metadata gives every generation the SAME state.\nfunction resolveOpenState(node: ElementNode): State<boolean> {\n let state = node.getMetadata(\"toastOpen\") as State<boolean> | undefined;\n if (!state) {\n state = toState(false);\n node.setMetadata(\"toastOpen\", state);\n }\n return state;\n}\n\nconst readOpen = (listener: any): boolean => {\n const node = listener?.elementNode as ElementNode | undefined;\n return node ? resolveOpenState(node).get(listener) : false;\n};\n\n/**\n * Renders a transient notification surface as a fixed-position overlay (portaled\n * into a corner stack), animating in on mount and out before removal. No host\n * tag check; typically applied to a `<div>`.\n *\n * @param props.position - Corner of the screen for the toast stack. Optional, one of `\"top-left\" | \"top-center\" | \"top-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\"`. Defaults to `\"top-center\"`.\n * @param props.color - Theme color for the toast surface. Optional. Defaults to `\"neutral\"`.\n * @example { div: \"Saved!\", $: [toast({ position: \"top-right\" })] }\n */\nfunction toast(\n props: { position?: ToastPosition; color?: ThemeColor } = {},\n): PartialElement {\n const { position = \"top-center\", color = \"neutral\" } = props;\n\n const isTop = position.startsWith(\"top\");\n const isCenter = position.endsWith(\"center\");\n const isRight = position.endsWith(\"right\");\n\n const overlayEle: DomphyElement<\"div\"> = {\n div: [],\n id: `domphy-toast-${position}`,\n style: {\n position: \"fixed\",\n display: \"flex\",\n flexDirection: isTop ? \"column\" : \"column-reverse\",\n alignItems: isCenter ? \"center\" : isRight ? \"end\" : \"start\",\n inset: 0,\n gap: themeSpacing(4),\n zIndex: 30,\n padding: themeSpacing(6),\n pointerEvents: \"none\",\n },\n };\n\n return {\n _portal: (rootNode) => {\n let overlay = rootNode.domElement!.querySelector(\n `#domphy-toast-${position}`,\n );\n if (!overlay) {\n const overlayNode = rootNode.children!.insert(\n overlayEle,\n ) as ElementNode;\n overlay = overlayNode.domElement!;\n }\n return overlay;\n },\n role: \"status\",\n ariaAtomic: \"true\",\n // Toast is rendered as an overlay surface, so it uses the inverted branch.\n dataTone: \"shift-17\",\n style: {\n minWidth: themeSpacing(32),\n pointerEvents: \"auto\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n boxShadow: elevation(\"medium\"),\n opacity: (listener) => Number(readOpen(listener)),\n transform: (listener) =>\n readOpen(listener)\n ? \"translateY(0)\"\n : isTop\n ? \"translateY(-100%)\"\n : \"translateY(100%)\",\n transition: \"opacity 300ms ease, transform 300ms ease\",\n },\n _onMount: (node) =>\n requestAnimationFrame(() => resolveOpenState(node).set(true)),\n _onBeforeRemove: (node, done) => {\n let finished = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let overlayRemoved = false;\n const rootNode = node.getRoot();\n const overlayEl = node.domElement?.parentElement ?? null;\n // The #domphy-toast-{position} overlay is inserted into the root on\n // first use and shared by every toast at that position — remove it once\n // its LAST toast is gone instead of leaking one empty fixed container\n // per used position for the app's whole lifetime.\n const removeOverlayIfEmpty = () => {\n if (overlayRemoved) return;\n if (\n !overlayEl ||\n overlayEl.id !== `domphy-toast-${position}` ||\n overlayEl.childElementCount > 0\n ) {\n return;\n }\n overlayRemoved = true;\n const item = rootNode.children?.items.find(\n (it) => (it as ElementNode).domElement === overlayEl,\n );\n if (item) rootNode.children!.remove(item);\n else overlayEl.remove();\n };\n const finish = () => {\n if (finished) return;\n finished = true;\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n node.domElement!.removeEventListener(\"transitionend\", onEnd);\n done();\n removeOverlayIfEmpty();\n };\n const onEnd = (e: Event) => {\n if ((e as TransitionEvent).propertyName === \"transform\") finish();\n };\n node.domElement!.addEventListener(\"transitionend\", onEnd);\n // Fallback: if transitionend never fires (reduced-motion, display:none,\n // early detach), unblock removal after the transition duration + buffer.\n timer = setTimeout(finish, 350);\n // If the node is detached before the exit animation settles, clear the\n // pending fallback timer and the transitionend listener so they cannot\n // fire on a removed node.\n node.addHook(\"Remove\", () => {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n node.domElement?.removeEventListener(\"transitionend\", onEnd);\n removeOverlayIfEmpty();\n });\n resolveOpenState(node).set(false);\n },\n };\n}\n\nexport { toast };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One item inside a toggle group. */\ntype ToggleItem = {\n /** Button label — plain string (auto-wrapped) or any DomphyElement. */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index as a string. */\n key?: string;\n};\n\ntype ToggleLive = {\n items: ToggleItem[];\n multiple: boolean;\n color: ThemeColor;\n accentColor: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction isPressed(val: string | string[], key: string): boolean {\n return Array.isArray(val) ? val.includes(key) : val === key;\n}\n\nfunction moveToggle(\n e: Event,\n items: ToggleItem[],\n key: string,\n value: State<string | string[]>,\n multiple: boolean,\n): void {\n const k = (e as KeyboardEvent).key;\n if (![\"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = items.map((item, index) => item.key ?? String(index));\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowRight\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowLeft\") next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n if (!multiple) value.set(keys[next]);\n const group = (e.target as HTMLElement).closest(\"[role=group]\");\n group?.querySelectorAll<HTMLElement>(\"button\")[next]?.focus();\n}\n\nfunction buildToggleButtons(\n items: ToggleItem[],\n value: State<string | string[]>,\n multiple: boolean,\n color: ThemeColor,\n accentColor: ThemeColor,\n): DomphyElement<\"button\">[] {\n return items.map((item, index) => {\n const key = item.key ?? String(index);\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n button: [labelEl],\n _key: key,\n type: \"button\",\n role: \"button\",\n ariaPressed: (l: Listener) => isPressed(value.get(l), key),\n tabIndex: (l: Listener) => {\n const val = value.get(l);\n if (multiple) {\n const arr = Array.isArray(val) ? val : [];\n const focusKey = arr[0] ?? items[0]?.key ?? \"0\";\n return key === focusKey ? 0 : -1;\n }\n if (val === key) return 0;\n if (val === \"\" && key === (items[0]?.key ?? \"0\")) return 0;\n return -1;\n },\n onClick: () => {\n const val = value.get();\n if (multiple) {\n const arr = Array.isArray(val) ? [...val] : [];\n value.set(\n arr.includes(key) ? arr.filter((v) => v !== key) : [...arr, key],\n );\n } else {\n value.set(val === key ? \"\" : key);\n }\n },\n onKeyDown: (e: Event) => moveToggle(e, items, key, value, multiple),\n style: {\n cursor: \"pointer\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: themeSpacing(6),\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(2),\n border: \"none\",\n borderRadius: themeSpacing(1.5),\n // Unpressed: shift-13 for readable resting labels (catalog contrast).\n color: (l: Listener) => themeColor(l, \"shift-13\", color),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled]):not([aria-pressed=true])\": {\n color: (l: Listener) => themeColor(l, \"shift-13\", color),\n backgroundColor: (l: Listener) => themeColor(l, \"hover\", color),\n },\n \"&:active:not([disabled])\": {\n backgroundColor: (l: Listener) => themeColor(l, \"increase-2\", color),\n },\n \"&[aria-pressed=true]\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-3\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-13\", accentColor),\n },\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n } as DomphyElement<\"button\">;\n });\n}\n\n/**\n * All-in-one toggle group — single or multi-select button group. Generates\n * `<button>` toggle elements from the `items` array. Apply to any wrapper element.\n *\n * @param props.items - Item definitions `{ label, key? }`.\n * @param props.value - Selected key(s) (value or State). Defaults to `[]` (multiple) or `\"\"` (single).\n * @param props.multiple - Allow multiple items selected at once. Defaults to `false`.\n * @param props.color - Theme color for the group background/border. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for the pressed state. Defaults to `\"primary\"`.\n * @example\n * { div: null, $: [toggleGroup({ multiple: true, items: [\n * { label: \"Bold\", key: \"bold\" },\n * { label: \"Italic\", key: \"italic\" },\n * ] })] }\n */\nfunction toggleGroup(\n props: {\n items: ToggleItem[];\n value?: ValueOrState<string | string[]>;\n multiple?: boolean;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const {\n items = [],\n multiple = false,\n color = \"neutral\",\n accentColor = \"primary\",\n } = props;\n const live: ToggleLive = { items, multiple, color, accentColor };\n\n return {\n role: \"group\",\n // Publish value + multiple so descendants can read the group selection.\n _context: {\n toggleGroup: {\n value: toState(props.value ?? (multiple ? [] : \"\")),\n multiple,\n },\n },\n _onSchedule: (node, element) => {\n const value = persistValue(\n node,\n \"toggleGroupValue\",\n props.value,\n multiple ? [] : \"\",\n );\n (element as Record<string, unknown>)[node.tagName] = buildToggleButtons(\n items,\n value,\n multiple,\n color,\n accentColor,\n );\n },\n ...behavior<ToggleLive>(\n \"toggle-items\",\n (node) => ({\n update(snapshot) {\n const value = persistValue(\n node,\n \"toggleGroupValue\",\n props.value,\n snapshot.multiple ? [] : \"\",\n );\n node.children.update(\n buildToggleButtons(\n snapshot.items,\n value,\n snapshot.multiple,\n snapshot.color,\n snapshot.accentColor,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n style: {\n display: \"flex\",\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(1),\n gap: themeSpacing(1),\n borderRadius: themeSpacing(2),\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n color: (l: Listener) => themeColor(l, \"text\", color),\n outline: (l: Listener) => `1px solid ${themeColor(l, \"border\", color)}`,\n outlineOffset: \"-1px\",\n },\n };\n}\n\nexport { toggleGroup };\nexport type { ToggleItem };\n","import type { DomphyElement, PartialElement } from \"@domphy/core\";\nimport { row } from \"./row.js\";\nimport type { FlexAlign, FlexJustify } from \"./stack.js\";\n\n/**\n * A horizontal flex row with vertically centered items. Useful for headers,\n * toolbars, navigation bars, and action strips. A semantic alias of `row()`;\n * wrap/justify/align/density are forwarded so callers do not drop down to\n * hand-rolled flex.\n *\n * @param props.gap - Spacing multiplier for gap between items (default 4).\n * Bounded-control mode (`density: true`, default): `themeSpacing(themeDensity(l) * gap)`.\n * Structural mode (`density: false`): bare `themeSpacing(gap)`.\n * @param props.wrap - Allow items to wrap onto multiple lines. Defaults to `false`.\n * @param props.justify - Main-axis distribution (`justifyContent`). Unset by default.\n * @param props.align - Cross-axis alignment (`alignItems`). Defaults to `\"center\"` (row default).\n * @param props.density - When true (default), gap is multiplied by theme density.\n * When false, gap is structural `themeSpacing(n)`.\n * @example { header: [...], $: [toolbar()] }\n * @example { nav: [...], $: [toolbar({ gap: 3 })] }\n * @example { header: [...], $: [toolbar({ wrap: true, justify: \"space-between\" })] }\n */\nfunction toolbar(\n props: {\n gap?: number;\n wrap?: boolean;\n justify?: FlexJustify;\n align?: FlexAlign;\n density?: boolean;\n } = {},\n): PartialElement {\n return row(props);\n}\n\n/**\n * A flex spacer that expands to fill available space in a toolbar, pushing\n * subsequent items to the far end.\n *\n * @example { header: [logo, toolbarSpacer(), nav, actions], $: [toolbar()] }\n */\nfunction toolbarSpacer(): DomphyElement {\n return { div: null, style: { flex: \"1 1 0\" } };\n}\n\nexport { toolbar, toolbarSpacer };\n","import {\n type DomphyElement,\n merge,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { popoverArrow } from \"./popoverArrow.js\";\n\n/**\n * Attaches a floating tooltip to the host element, shown on hover/focus and\n * hidden on leave/blur/Escape. Returns the anchor (trigger) partial; the tooltip\n * surface is positioned via the floating utility and linked with\n * `aria-describedby`. No host tag check; applied to the trigger element.\n *\n * @param props.open - Controlled open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so leave/blur/Escape can close. Optional. Defaults to `false`.\n * @param props.onDismiss - Called when the tooltip requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.placement - Floating placement relative to the trigger. Optional, accepts a value or state (`Placement`). Defaults to `\"top\"`.\n * @param props.content - Tooltip text content. Optional, accepts a value or state (string only). Defaults to `\"Tooltip Content\"`.\n * @example { button: \"Hover me\", $: [tooltip({ content: \"Help text\" })] }\n */\nfunction tooltip(\n props: {\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement?: ValueOrState<Placement>;\n content?: ValueOrState<string>;\n } = {},\n): PartialElement {\n const {\n open = false,\n placement = \"top\",\n content = \"Tooltip Content\",\n } = props;\n\n const placeState = toState(placement);\n const contentState = toState(content);\n\n // The tooltip id is NOT pre-generated here: a factory-scope id (previously\n // Math.random()-based) churns per generation and mismatches SSR/hydration.\n // Instead the shared floating behavior stamps a deterministic id derived\n // from the anchor's nodeId when the panel mounts (see floating.ts), and the\n // trigger references the same id via _onSchedule below.\n const contentElement: DomphyElement<\"span\"> = {\n span: (listener) => contentState.get(listener),\n };\n\n const { show, hide, anchorPartial } = createFloating({\n kind: \"tooltip\",\n open,\n onDismiss: props.onDismiss,\n placement: placeState,\n content: contentElement,\n });\n\n const tooltipPartial: PartialElement = {\n role: \"tooltip\",\n dataSize: \"decrease-1\",\n dataTone: \"shift-17\",\n style: {\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n color: (listener) => themeColor(listener, \"text\"),\n backgroundColor: (listener) => themeColor(listener),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n boxShadow: elevation(\"low\"),\n },\n $: [popoverArrow({ placement: placeState, bordered: false })],\n };\n contentElement.$ ||= [];\n contentElement.$.push(tooltipPartial);\n\n const triggerPartial: PartialElement = {\n // Declared as a reactive attribute (listener.elementNode is the anchor) so\n // it is present from first render — before the tooltip's first show() —\n // and is re-declared on every patch (patch() strips attributes that are\n // no longer declared, so imperative wiring would not survive re-render).\n ariaDescribedby: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"tooltip\", listener.elementNode)\n : undefined,\n onMouseEnter: (_e, node) => show(node),\n onMouseLeave: (_e, node) => hide(node),\n onFocus: (_e, node) => show(node),\n onBlur: (_e, node) => hide(node),\n onKeyDown: (e, node) => (e as KeyboardEvent).key === \"Escape\" && hide(node),\n };\n\n merge(anchorPartial, triggerPartial);\n\n return anchorPartial;\n}\n\nexport { tooltip };\n","import { ElementNode, type PartialElement } from \"@domphy/core\";\n\ntype RectMap = Map<string, DOMRect>;\n\nfunction getItemId(node: ElementNode, index: number): string {\n if (node.key !== undefined && node.key !== null) {\n return String(node.key);\n }\n return `index-${index}`;\n}\n\n/**\n * Animates child reordering using the FLIP technique: records each child's\n * position before an update and smoothly transitions it from its old to new\n * position afterward. No host tag check; applied to the list container.\n *\n * @param props.duration - Transition duration in milliseconds. Optional. Defaults to `300`.\n * @param props.delay - Transition delay in milliseconds. Optional. Defaults to `0`.\n * @example { ul: null, $: [transitionGroup({ duration: 300 })] }\n */\nfunction transitionGroup(\n props: { duration?: number; delay?: number } = {},\n): PartialElement {\n const { duration = 300, delay = 0 } = props;\n\n let previousRects: RectMap = new Map();\n // Cancels any in-flight animation for a given DOM element before starting a new one.\n const cancelMap = new Map<HTMLElement, () => void>();\n // Pending fallback timers and queued rAF callbacks, tracked so a removal of\n // the container mid-animation can clear them instead of firing on a detached node.\n const pendingTimers = new Set<ReturnType<typeof setTimeout>>();\n const pendingFrames = new Set<number>();\n\n return {\n _onMount: (node) => {\n node.addHook(\"Remove\", () => {\n // Stop every in-flight animation: removes transitionend listeners.\n for (const cancel of Array.from(cancelMap.values())) cancel();\n cancelMap.clear();\n // Clear queued fallback timers.\n for (const timer of pendingTimers) clearTimeout(timer);\n pendingTimers.clear();\n // Cancel queued animation frames.\n for (const frame of pendingFrames) cancelAnimationFrame(frame);\n pendingFrames.clear();\n });\n },\n _onBeforeUpdate: (node) => {\n previousRects = new Map();\n node.children.items.forEach((item, index) => {\n if (!(item instanceof ElementNode)) return;\n const dom = item.domElement as HTMLElement | undefined;\n if (!dom) return;\n previousRects.set(getItemId(item, index), dom.getBoundingClientRect());\n });\n },\n _onUpdate: (node) => {\n node.children.items.forEach((item, index) => {\n if (!(item instanceof ElementNode)) return;\n const dom = item.domElement as HTMLElement | undefined;\n if (!dom) return;\n\n const key = getItemId(item, index);\n const prev = previousRects.get(key);\n if (!prev) return;\n\n const next = dom.getBoundingClientRect();\n const deltaX = prev.left - next.left;\n const deltaY = prev.top - next.top;\n if (Math.abs(deltaX) < 0.5 && Math.abs(deltaY) < 0.5) return;\n\n // Cancel any in-flight animation on this element before starting a new one.\n cancelMap.get(dom)?.();\n\n dom.style.transition = \"none\";\n dom.style.transform = `translate(${deltaX}px, ${deltaY}px)`;\n dom.getBoundingClientRect();\n\n const frame = requestAnimationFrame(() => {\n pendingFrames.delete(frame);\n dom.style.transition = `transform ${duration}ms ease ${delay}ms`;\n dom.style.transform = \"translate(0px, 0px)\";\n });\n pendingFrames.add(frame);\n\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n const finish = () => {\n if (cancelled) return;\n cancelled = true;\n if (timer) {\n pendingTimers.delete(timer);\n timer = null;\n }\n cancelMap.delete(dom);\n dom.removeEventListener(\"transitionend\", onEnd);\n dom.style.transition = \"\";\n dom.style.transform = \"\";\n };\n\n const onEnd = (event: Event) => {\n if ((event as TransitionEvent).propertyName === \"transform\") finish();\n };\n\n cancelMap.set(dom, () => {\n cancelled = true;\n if (timer) {\n clearTimeout(timer);\n pendingTimers.delete(timer);\n timer = null;\n }\n cancelMap.delete(dom);\n dom.removeEventListener(\"transitionend\", onEnd);\n });\n\n dom.addEventListener(\"transitionend\", onEnd);\n timer = setTimeout(finish, duration + delay + 34);\n pendingTimers.add(timer);\n });\n previousRects.clear();\n },\n };\n}\n\nexport { transitionGroup };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a bulleted list (disc markers, reset margins, themed text) on the host\n * `<ul>` element.\n *\n * @hostTag ul\n * @param props.color - Theme color for the list text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { ul: null, $: [unorderedList()] }\n */\nfunction unorderedList(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"ul\") {\n console.warn(`\"unorderedList\" primitive patch must use ul tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n marginTop: 0,\n marginBottom: 0,\n paddingLeft: themeSpacing(3),\n listStyleType: \"disc\",\n listStylePosition: \"outside\",\n },\n };\n}\n\nexport { unorderedList };\n","import type { PartialElement } from \"@domphy/core\";\n\n/**\n * Visually hides an element while keeping it in the accessibility tree — the\n * classic \"sr-only\" recipe for screen-reader-only labels, live-region text,\n * and skip links (before focus). Styles the host only; apply to any element.\n *\n * @example { span: \"Opens in a new tab\", $: [visuallyHidden()] }\n */\nfunction visuallyHidden(): PartialElement {\n return {\n style: {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n margin: \"-1px\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n whiteSpace: \"nowrap\",\n border: \"0\",\n },\n };\n}\n\nexport { visuallyHidden };\n"],"mappings":"gyBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,kBAAAE,GAAA,cAAAC,GAAA,UAAAC,GAAA,WAAAC,GAAA,UAAAC,GAAA,eAAAC,GAAA,eAAAC,GAAA,uBAAAC,GAAA,WAAAC,GAAA,gBAAAC,GAAA,iBAAAC,GAAA,SAAAC,GAAA,SAAAC,GAAA,aAAAC,GAAA,YAAAC,GAAA,gBAAAC,GAAA,kBAAAC,GAAA,eAAAC,GAAA,oBAAAC,GAAA,YAAAC,GAAA,WAAAC,GAAA,YAAAC,GAAA,WAAAC,GAAA,cAAAC,EAAA,aAAAC,GAAA,UAAAC,GAAA,kBAAAC,GAAA,QAAAC,GAAA,WAAAC,GAAA,cAAAC,EAAA,cAAAC,GAAA,SAAAC,GAAA,YAAAC,GAAA,mBAAAC,GAAA,SAAAC,GAAA,UAAAC,GAAA,kBAAAC,GAAA,eAAAC,GAAA,kBAAAC,GAAA,cAAAC,GAAA,gBAAAC,GAAA,aAAAC,GAAA,kBAAAC,GAAA,eAAAC,GAAA,eAAAC,GAAA,gBAAA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CC1HA,IAAAmB,GAAgE,wBAChEC,GAKO,yBAUP,SAASC,GACPC,EAA8C,CAAC,EAC/B,CAlBlB,IAAAC,EAmBE,IAAMC,KAAQ,aAAQD,EAAAD,EAAM,QAAN,KAAAC,EAAe,UAAW,OAAO,EAEvD,MAAO,CACL,UAAYE,GAAS,CACfA,EAAK,UAAY,MACnB,QAAQ,KAAK,iDAAiD,CAElE,EACA,MAAO,CACL,SAAWC,MAAa,cAAUA,EAAU,SAAS,EACrD,gBAAkBA,MAAa,eAAWA,CAAQ,EAClD,MAAQA,MAAa,eAAWA,EAAU,OAAQF,EAAM,IAAIE,CAAQ,CAAC,EACrE,UAAW,EACX,aAAc,EACd,eAAa,iBAAa,CAAC,EAC3B,cAAe,OACf,kBAAmB,SACrB,CACF,CACF,CC7BA,SAASC,IAAiC,CACxC,MAAO,CACL,MAAO,CACL,SAAU,WACV,MAAO,MACP,OAAQ,MACR,QAAS,IACT,OAAQ,OACR,SAAU,SACV,KAAM,mBACN,WAAY,SACZ,OAAQ,GACV,CACF,CACF","names":["index_exports","__export","abbreviation","accordion","alert","avatar","badge","blockquote","breadcrumb","breadcrumbEllipsis","button","buttonGhost","buttonSwitch","card","code","combobox","command","commandItem","commandSearch","datePicker","descriptionList","details","dialog","divider","drawer","elevation","emphasis","empty","errorBoundary","fab","figure","focusRing","formGroup","grid","heading","horizontalRule","icon","image","inputCheckbox","inputColor","inputDateTime","inputFile","inputNumber","inputOTP","inputPassword","inputRadio","inputRange","inputSearch","inputSwitch","inputText","keyboard","label","link","linkButton","list","listItem","listItemButton","mark","menu","motion","orderedList","pagination","panelSection","paragraph","popover","popoverArrow","preformated","progress","rating","ringProgress","row","scrollArea","segmented","select","selectBox","selectItem","selectList","skeleton","small","spinner","splitter","splitterHandle","splitterPanel","stack","steps","strong","subscript","superscript","table","tabs","tag","textarea","timeline","timelineItem","toast","toggleGroup","toolbar","toolbarSpacer","tooltip","transitionGroup","unorderedList","visuallyHidden","__toCommonJS","import_core","import_theme","abbreviation","props","_a","_b","color","accentColor","node","listener","import_core","import_theme","import_theme","focusRing","listener","color","gap","ring","accordion","props","_a","_b","type","color","accentColor","node","el","handler","event","summary","item","detail","listener","focusRing","import_core","import_theme","alert","props","_a","color","listener","import_core","import_theme","avatar","props","_a","color","listener","import_core","import_theme","badge","props","_a","label","state","color","l","import_core","import_theme","blockquote","props","_a","color","node","listener","import_core","import_theme","breadcrumb","props","_a","separator","color","node","listener","import_core","import_theme","breadcrumbEllipsis","props","_a","color","node","listener","focusRing","import_core","import_theme","BUTTON_SIZE_FONT","import_core","import_theme","PADDING_STEPS","buttonGhost","props","_a","_b","_c","color","padding","fontSize","BUTTON_SIZE_FONT","node","listener","focusRing","PADDING_STEPS","button","props","_a","_b","_c","_d","variant","buttonGhost","color","isSolid","padding","fontSize","BUTTON_SIZE_FONT","__spreadProps","__spreadValues","node","listener","focusRing","import_core","import_theme","buttonSwitch","props","_a","_b","checked","check","color","accentColor","node","listener","focusRing","import_core","import_theme","SHADOWS","elevation","level","card","props","_a","color","listener","elevation","import_core","import_theme","code","props","_a","color","node","listener","import_core","import_theme","import_core","import_floating","import_core","isWritableState","source","subscribeOpen","onChange","emitCurrent","skipInitial","release","value","writeOpen","dismissOpen","onDismiss","asOpenState","open","floatingPanelId","kind","node","attachFloating","initialProps","_a","_b","_c","_d","openState","onDismiss","placement","content","keepOpenOnContentHover","behaviorKey","timer","cleanup","floating","floatingNode","mounted","reference","rootNode","panelId","floatingPartial","listener","event","hide","show","mountedNode","dataTheme","rNode","dialogHost","overlay","overlayEle","wireContent","target","ensureMounted","instance","instantShow","x","y","resolved","writeOpen","instantHide","dismissOpen","handleOutside","handleEscape","escapeTarget","onOpen","val","release","destroyed","updating","stampPanelBehavior","__spreadProps","__spreadValues","props","subscribeOpen","createFloating","asOpenState","anchorPartial","e","import_core","import_theme","xSvg","DEFAULT_DENSITY","TAG_HEIGHT","TAG_PAD_INLINE","TAG_PAD_END_REMOVABLE","TAG_REMOVE","TAG_REMOVE_RADIUS","tag","props","_a","removable","color","__spreadProps","__spreadValues","node","initial","removeHost","makeButton","e","event","listener","focusRing","findButton","item","sync","next","updateDom","existing","combobox","props","options","placement","color","open","multiple","state","openState","show","hide","anchorPartial","createFloating","popoverPartial","_e","node","listener","elevation","inputStyle","readQuery","_a","_b","findComboboxAnchor","from","current","inputAria","floatingPanelId","buildInput","custom","__spreadValues","event","buildWrap","inner","val","vals","items","opt","tag","_node","cur","filter","v","partial","__spreadProps","element","_inner","query","next","focusRing","import_core","import_theme","command","_node","element","commandSearch","props","color","accentColor","node","ctx","input","onInput","listener","focusRing","commandItem","_a","_b","el","text","applyFilter","q","release","import_core","import_theme","atMidnight","date","addDays","count","addMonths","sameDay","a","b","isoOf","startOfWeek","weekStart","localeWeekStart","locale","_a","_b","localeObject","info","attachDatePicker","_node","initialProps","current","releaseOnChange","subscribe","props","value","carryForward","next","prev","datePicker","_c","_d","mode","time","min","max","disabledDate","format","onChange","accentColor","placeState","selection","primaryDate","base","viewYear","viewMonth","focused","hovered","hour","minute","dateFormatter","__spreadValues","monthFormatter","weekdayFormatter","fullDateFormatter","formatOne","formatDisplay","start","end","weekdayNames","_unused","index","isDisabled","withTime","result","selectDate","node","hide","reapplyTime","inSelectedRange","listener","tail","low","high","day","isSelectedEnd","goToDate","shiftMonth","delta","shiftYear","focusActiveCell","root","calendar","buildCalendar","openState","show","anchorPartial","createFloating","triggerPartial","floatingPanelId","_e","openAndFocus","event","key","isSelectedPrimary","navButton","label","ariaLabel","onClick","navButtonStyle","header","weekdayHeader","name","gridRowStyle","grid","buildWeeks","onGridKey","children","buildTimeRow","buildFooter","elevation","first","month","weeks","week","cells","buildDayCell","disabled","selected","within","outside","isFocused","isToday","l","focusRing","numberSelect","state","timeSelectStyle","action","today","keyboard","import_core","import_theme","descriptionList","props","_a","color","node","listener","import_core","import_theme","details","props","_a","_b","duration","color","accentColor","node","listener","focusRing","import_core","import_theme","lockCount","lockScroll","unlockScroll","FOCUSABLE","attachDialog","node","initialProps","state","onDismiss","previousFocus","closing","scrollLocked","closeTimer","dlg","finalizeClose","unlockScroll","trapFocus","e","focusables","el","first","last","onCancel","dismissOpen","update","val","lockScroll","focusable","release","subscribeOpen","props","dialog","color","open","labelledBy","describedBy","asOpenState","__spreadProps","__spreadValues","_a","r","listener","elevation","import_core","import_theme","divider","props","_a","color","node","listener","import_core","import_theme","translateOut","marginMap","isVertical","p","resolvePhysical","placement","isRTL","attachDrawer","node","initialProps","state","onDismiss","size","dlg","onCancel","e","dismissOpen","resolve","nextPlacement","nextSize","physical","drawerSize","closing","scrollLocked","closeTimer","finishClose","unlockScroll","onTransitionEnd","update","val","lockScroll","release","subscribeOpen","props","drawer","color","open","asOpenState","physicalFallback","defaultSize","__spreadProps","__spreadValues","_a","r","listener","elevation","import_core","import_theme","emphasis","props","_a","color","node","listener","import_core","import_theme","empty","props","_a","color","listener","ORIGINAL_CHILDREN","restoreOriginalChildren","node","_a","original","errorBoundary","props","element","error","_b","reset","fallbackEl","import_core","import_theme","SIZE_MAP","fab","props","_a","_b","color","dim","node","listener","elevation","focusRing","import_core","import_theme","figure","props","_a","color","node","listener","import_core","import_theme","formGroup","props","_a","layout","color","isVertical","node","listener","import_theme","grid","props","columns","gap","align","__spreadValues","listener","import_core","import_theme","HeadingShift","heading","props","_a","color","size","node","listener","offset","import_core","import_theme","horizontalRule","props","_a","color","node","listener","import_core","import_theme","icon","props","_a","color","node","listener","import_core","import_theme","image","props","_a","color","node","listener","import_core","import_theme","inputCheckbox","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputColor","props","_a","color","node","listener","focusRing","import_core","import_theme","inputDateTime","props","_a","_b","mode","color","accentColor","node","listener","focusRing","import_core","import_theme","inputFile","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputNumber","props","_a","_b","color","accentColor","node","listener","focusRing","import_theme","inputOTP","node","container","getInputs","onInput","e","inputs","target","idx","onKeydown","onPaste","_a","_b","_c","text","found","startIdx","char","i","field","lastFilled","import_core","import_theme","EYE_SVG","EYE_OFF_SVG","HOST_FIELD_KEYS","bindReadable","value","listener","inputPassword","props","_a","_b","colorState","accentState","visibleState","hostFields","node","_node","element","host","key","_c","_d","_e","_f","_g","name","onInput","disabled","required","field","__spreadProps","__spreadValues","l","toggle","focusRing","import_core","import_theme","inputRadio","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputRange","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputSearch","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputSwitch","props","_a","accentColor","node","listener","focusRing","import_core","import_theme","inputText","props","_a","_b","type","color","accentColor","node","listener","focusRing","import_core","import_theme","keyboard","props","_a","color","node","listener","import_core","import_theme","label","props","_a","_b","color","accentColor","node","listener","import_core","import_theme","link","props","_a","_b","color","accentColor","node","event","el","listener","focusRing","import_core","import_theme","PADDING_STEPS","GHOST_PADDING","linkButton","props","_a","_b","_c","variant","color","size","fontSize","BUTTON_SIZE_FONT","padding","node","listener","focusRing","isSolid","__spreadProps","__spreadValues","import_core","import_theme","list","props","_a","color","listener","listItem","dense","listItemButton","_b","accentColor","focusRing","import_core","import_theme","mark","props","_a","accentColor","node","listener","import_core","import_theme","menu","props","_a","items","selectable","color","accentColor","activeKey","activeKeyIsCallerOwned","buildItems","node","inner","id","item","index","key","__spreadProps","__spreadValues","l","e","keys","it","i","idx","next","focusRing","attachMenu","_node","initial","current","element","elevation","import_core","isMotionState","value","toStyles","frame","out","transforms","key","toOptions","transition","_a","_b","_c","_d","prefersReducedMotion","e","attachMotion","node","initial","el","current","release","bindAnimate","animate","next","play","props","mode","target","frames","motion","__spreadProps","__spreadValues","done","inst","exit","import_core","import_theme","orderedList","props","_a","color","node","listener","import_core","import_theme","getPages","current","total","_","i","pages","start","end","persistValue","node","key","incoming","fallback","stored","persistTotal","pagination","props","color","accentColor","btnBase","listener","focusRing","activeStyle","__spreadProps","__spreadValues","state","totalState","content","page","pageCount","items","ellipsisIndex","p","isActive","snapshot","import_core","import_theme","panelSection","props","_a","padding","divider","color","__spreadValues","listener","import_core","import_theme","paragraph","props","_a","color","node","listener","import_core","import_theme","popover","props","_a","open","placement","openOn","openState","placeState","show","hide","anchorPartial","createFloating","popoverPartial","l","elevation","listener","floatingPanelId","_e","node","e","related","floatingEl","import_core","import_theme","popoverArrow","props","placement","color","sideOffset","bordered","place","flipMap","getFlipped","listener","_a","start","pos","end","x","y","import_core","import_theme","preformated","props","_a","color","node","listener","import_core","import_theme","progress","props","_a","_b","color","accentColor","node","listener","import_core","import_theme","STAR_FILLED","STAR_EMPTY","applyRatingProps","live","next","_a","_b","_c","insertStar","node","index","hoveredState","activeCount","listener","hovered","star","e","current","target","focusRing","syncStars","children","rating","props","_d","_e","_f","_g","__spreadProps","__spreadValues","initial","import_core","import_theme","ringProgress","props","_a","_b","_c","size","thickness","value","color","trackColor","holePercent","mask","l","node","import_theme","row","props","gap","align","justify","wrap","density","__spreadValues","listener","import_core","import_theme","scrollArea","props","_a","color","l","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","moveSegment","e","items","value","_a","k","keys","item","index","idx","next","group","buildSegmentButtons","color","accentColor","l","_b","current","elevation","focusRing","segmented","props","_c","live","__spreadProps","__spreadValues","element","snapshot","import_theme","select","props","color","accentColor","node","listener","l","svg","focusRing","import_core","import_theme","TYPEAHEAD_RESET_MS","resolveTypeahead","node","meta","matchesPrefix","label","needle","enabledPanelOptions","panel","el","selectBox","props","options","placement","color","open","multiple","state","openState","show","hide","anchorPartial","createFloating","popoverPartial","_e","listener","elevation","buildWrap","inner","val","vals","opt","tag","_node","cur","filter","v","attachInner","_inner","next","toggle","typeahead","key","_a","_b","_c","_d","repeated","root","floatingPanelId","matches","active","from","target","partial","__spreadProps","__spreadValues","element","e","kb","focusRing","import_theme","selectItem","props","accentColor","color","value","listener","_a","select","val","_e","node","state","v","focusRing","import_core","import_theme","selectList","props","_a","color","multiple","state","inputs","listener","val","v","node","import_core","import_theme","skeleton","props","_a","color","keyframes","animationName","listener","import_core","import_theme","small","props","_a","color","node","listener","import_core","import_theme","keyframes","animationName","spinner","props","_a","color","node","listener","import_core","import_theme","splitter","props","direction","defaultSize","min","max","_node","element","isFirstSplitterPanel","node","parent","item","splitterPanel","ctx","el","prop","apply","size","release","_a","splitterHandle","handle","isHorizontal","releaseAriaValue","onKeydown","e","step","next","cancelDrag","onMousedown","container","onMousemove","rect","raw","onMouseup","listener","focusRing","import_theme","stack","props","gap","align","justify","density","__spreadValues","listener","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","stepConnectorStyle","direction","color","accentColor","l","buildStepItems","items","current","vertical","connector","item","index","_a","cur","__spreadProps","__spreadValues","steps","props","live","element","snapshot","import_core","import_theme","strong","props","_a","color","node","listener","import_core","import_theme","subscript","props","_a","color","node","listener","import_core","import_theme","superscript","props","_a","color","node","listener","import_core","import_theme","table","props","_a","color","node","listener","l","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","buildTabsChildren","items","activeKey","accentColor","color","id","tablist","item","index","_a","l","e","k","keys","it","i","idx","next","list","focusRing","panels","tabs","props","__spreadValues","element","_b","snapshot","import_core","import_theme","textarea","props","_a","_b","color","accentColor","autoResize","__spreadProps","__spreadValues","node","initial","el","enabled","measuring","intersectionObserver","resizeObserver","resize","observe","entries","entry","unobserve","next","listener","focusRing","import_core","import_theme","timeline","timelineItem","props","_a","_b","_c","last","color","accentColor","activeState","__spreadValues","listener","import_core","import_theme","resolveOpenState","node","state","readOpen","listener","toast","props","position","color","isTop","isCenter","isRight","overlayEle","rootNode","overlay","elevation","done","_a","_b","finished","timer","overlayRemoved","overlayEl","removeOverlayIfEmpty","item","it","finish","onEnd","e","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","isPressed","val","moveToggle","e","items","value","multiple","_a","k","keys","item","index","idx","next","group","buildToggleButtons","color","accentColor","_b","_c","_d","_e","focusKey","arr","v","focusRing","toggleGroup","props","live","__spreadProps","__spreadValues","element","snapshot","l","toolbar","props","row","toolbarSpacer","import_core","import_theme","tooltip","props","open","placement","content","placeState","contentState","contentElement","listener","show","hide","anchorPartial","createFloating","tooltipPartial","elevation","popoverArrow","floatingPanelId","_e","node","e","import_core","getItemId","node","index","transitionGroup","props","duration","delay","previousRects","cancelMap","pendingTimers","pendingFrames","cancel","timer","frame","item","dom","_a","key","prev","next","deltaX","deltaY","cancelled","finish","onEnd","event","import_core","import_theme","unorderedList","props","_a","color","node","listener","visuallyHidden"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/patches/abbreviation.ts","../src/patches/accordion.ts","../src/utils/focusRing.ts","../src/patches/alert.ts","../src/patches/avatar.ts","../src/patches/badge.ts","../src/patches/blockquote.ts","../src/patches/breadcrumb.ts","../src/patches/breadcrumbEllipsis.ts","../src/patches/button.ts","../src/utils/buttonSize.ts","../src/patches/buttonGhost.ts","../src/patches/buttonSwitch.ts","../src/patches/card.ts","../src/utils/elevation.ts","../src/patches/code.ts","../src/patches/combobox.ts","../src/utils/floating.ts","../src/utils/openState.ts","../src/patches/tag.ts","../src/patches/command.ts","../src/patches/datePicker.ts","../src/patches/descriptionList.ts","../src/patches/details.ts","../src/patches/dialog.ts","../src/utils/scrollLock.ts","../src/patches/divider.ts","../src/patches/drawer.ts","../src/patches/emphasis.ts","../src/patches/empty.ts","../src/patches/errorBoundary.ts","../src/patches/fab.ts","../src/patches/figure.ts","../src/patches/formGroup.ts","../src/patches/grid.ts","../src/patches/heading.ts","../src/patches/horizontalRule.ts","../src/patches/icon.ts","../src/patches/image.ts","../src/patches/inputCheckbox.ts","../src/patches/inputColor.ts","../src/patches/inputDateTime.ts","../src/patches/inputFile.ts","../src/patches/inputNumber.ts","../src/patches/inputOTP.ts","../src/patches/inputPassword.ts","../src/patches/inputRadio.ts","../src/patches/inputRange.ts","../src/patches/inputSearch.ts","../src/patches/inputSwitch.ts","../src/patches/inputText.ts","../src/patches/keyboard.ts","../src/patches/label.ts","../src/patches/link.ts","../src/patches/linkButton.ts","../src/patches/list.ts","../src/patches/mark.ts","../src/patches/menu.ts","../src/patches/motion.ts","../src/patches/orderedList.ts","../src/patches/pagination.ts","../src/patches/panelSection.ts","../src/patches/paragraph.ts","../src/patches/popover.ts","../src/patches/popoverArrow.ts","../src/patches/preformated.ts","../src/patches/progress.ts","../src/patches/rating.ts","../src/patches/ringProgress.ts","../src/patches/row.ts","../src/patches/scrollArea.ts","../src/patches/segmented.ts","../src/patches/select.ts","../src/patches/selectBox.ts","../src/patches/selectItem.ts","../src/patches/selectList.ts","../src/patches/skeleton.ts","../src/patches/small.ts","../src/patches/spinner.ts","../src/patches/splitter.ts","../src/patches/stack.ts","../src/patches/steps.ts","../src/patches/strong.ts","../src/patches/subscript.ts","../src/patches/superscript.ts","../src/patches/table.ts","../src/patches/tabs.ts","../src/patches/textarea.ts","../src/patches/timeline.ts","../src/patches/toast.ts","../src/patches/toggleGroup.ts","../src/patches/toolbar.ts","../src/patches/tooltip.ts","../src/patches/transitionGroup.ts","../src/patches/unorderedList.ts","../src/patches/visuallyHidden.ts"],"sourcesContent":["export * from \"./classes.js\";\nexport * from \"./patches.js\";\nexport * from \"./types.js\";\nexport * from \"./utils.js\";\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles an abbreviation/acronym with a dotted underline and a \"help\" cursor,\n * shifting to the accent color on hover. Apply to an `<abbr>` element.\n *\n * @hostTag abbr\n * @param props.color - Base text/decoration color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @param props.accentColor - Hover color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @example { abbr: \"HTML\", title: \"HyperText Markup Language\", $: [abbreviation({ accentColor: \"primary\" })] }\n */\nfunction abbreviation(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"abbr\") {\n console.warn(`\"abbreviation\" primitive patch must use abbr tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n textDecorationLine: \"underline\",\n textDecorationStyle: \"dotted\",\n textDecorationColor: (listener) =>\n themeColor(listener, \"shift-7\", color.get(listener)),\n textUnderlineOffset: themeSpacing(0.72),\n cursor: \"help\",\n \"&:hover\": {\n color: (listener) =>\n themeColor(listener, \"shift-11\", accentColor.get(listener)),\n textDecorationColor: (listener) =>\n themeColor(listener, \"shift-9\", accentColor.get(listener)),\n },\n },\n };\n}\n\nexport { abbreviation };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Container patch that groups `<details>` elements into a bordered accordion.\n * In `type: \"single\"` mode (default), opening one item closes all siblings.\n *\n * @param props.type - `\"single\"` (default) or `\"multiple\"`. Single mode auto-closes siblings.\n * @param props.color - Theme color tone for borders and backgrounds. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color for focus rings on summary. Defaults to `\"primary\"`.\n * @example\n * { div: [\n * { details: [{ summary: \"Section A\" }, { p: \"Content A\" }], $: [details()] },\n * { details: [{ summary: \"Section B\" }, { p: \"Content B\" }], $: [details()] },\n * ], $: [accordion()] }\n */\nfunction accordion(\n props: {\n type?: \"single\" | \"multiple\";\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { type = \"single\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onMount: (node) => {\n if (type !== \"single\") return;\n\n const el = node.domElement;\n if (!el) return;\n const handler = (event: Event) => {\n const summary = (event.target as Element).closest(\"summary\");\n if (!summary) return;\n const item = summary.closest(\"details\") as HTMLDetailsElement | null;\n if (!item || item.parentElement !== el) return;\n if (!item.open) {\n Array.from(el.querySelectorAll(\":scope > details\")).forEach(\n (detail) => {\n if (detail !== item) (detail as HTMLDetailsElement).open = false;\n },\n );\n }\n };\n el.addEventListener(\"click\", handler);\n node.addHook(\"Remove\", () => el.removeEventListener(\"click\", handler));\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n outlineOffset: \"-1px\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n overflow: \"hidden\",\n \"& > details\": {\n borderBottom: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n },\n \"& > details:last-child\": {\n borderBottom: \"none\",\n },\n \"& > details > summary:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n },\n };\n}\n\nexport { accordion };\n","import type { Listener } from \"@domphy/core\";\nimport { type ThemeColor, themeColor } from \"@domphy/theme\";\n\n/**\n * Shared `:focus-visible` ring — ring-offset pattern used by Radix / shadcn /\n * Vercel / Linear:\n *\n * 1. 2px \"gap\" in the surface tone (reads as space between control + ring)\n * 2. 2px accent halo outside that gap\n *\n * Implemented as a layered `box-shadow` so it composes with a control's own\n * resting outline / elevation instead of replacing them. Prefer this over a\n * flush `0 0 0 2px` ring (looks like a thick pastel border glued to the edge)\n * and over the browser default outline.\n *\n * Accent at `shift-9` stays legible on both light and dark surfaces; the\n * washed `shift-6` flush ring is what made focus look broken in product UIs.\n */\nfunction focusRing(listener: Listener, color: ThemeColor = \"primary\"): string {\n const gap = themeColor(listener, \"surface\");\n const ring = themeColor(listener, \"shift-9\", color);\n return `0 0 0 2px ${gap}, 0 0 0 4px ${ring}`;\n}\n\nexport { focusRing };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A semantic alert surface block with a colored inset bar, padding, and\n * `role=\"alert\"`. Typically applied to a `<div>` (any block container).\n *\n * @param props.color - Surface/accent color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @example { div: \"Saved successfully\", $: [alert({ color: \"success\" })] }\n */\nfunction alert(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n\n return {\n role: \"alert\",\n // Alert is a semantic surface block, so it should shift the local surface context.\n dataTone: \"shift-2\",\n style: {\n display: \"flex\",\n alignItems: \"flex-start\",\n gap: themeSpacing(3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n boxShadow: (listener) =>\n `inset ${themeSpacing(1)} 0 0 0 ${themeColor(listener, \"shift-8\", color.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n },\n };\n}\n\nexport { alert };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A circular avatar container that centers initials/text and cover-fits any\n * child `<img>`. Typically applied to an inline-flex container such as a `<span>`.\n *\n * @param props.color - Background/foreground color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @example { span: \"JD\", $: [avatar({ color: \"primary\" })] }\n */\nfunction avatar(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n // Design-system initials weight (not app chrome) — consumers use avatar().\n _doctorDisable: \"inline-typography\",\n style: {\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n borderRadius: \"50%\",\n flexShrink: 0,\n width: themeSpacing(9),\n height: themeSpacing(9),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontWeight: \"600\",\n userSelect: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n // Hairline so the circle separates from same-tone surfaces.\n boxShadow: (listener) =>\n `0 0 0 1px ${themeColor(listener, \"border\", color.get(listener))}`,\n \"& img\": {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n },\n },\n };\n}\n\nexport { avatar };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Renders a small count/label bubble pinned to the top-right corner of its host\n * (via a `::after` pseudo-element). Typically applied to an inline container such\n * as a `<span>` wrapping an icon or element.\n *\n * @param props.color - Badge color tone. Optional `ValueOrState<ThemeColor>`, default \"danger\".\n * @param props.label - Text/number shown in the badge. Optional `ValueOrState<string | number>`, default 999.\n * @example { span: \"🔔\", $: [badge({ label: 3, color: \"danger\" })] }\n */\nfunction badge(\n props: {\n color?: ValueOrState<ThemeColor>;\n label?: ValueOrState<string | number>;\n } = {},\n): PartialElement {\n const { label = 999 } = props;\n const state = toState(label);\n const color = toState(props.color ?? \"danger\", \"color\");\n return {\n // Badge ::after uses a fixed size scale for the pill chrome.\n _doctorDisable: \"inline-typography\",\n style: {\n position: \"relative\",\n \"&::after\": {\n content: (l) => `\"${state.get(l)}\"`,\n position: \"absolute\",\n top: 0,\n right: 0,\n transform: \"translate(50%,-50%)\",\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n paddingInline: (l) => themeSpacing(themeDensity(l) * (1.5 / 1.5)),\n minWidth: themeSpacing(5),\n height: (l) => themeSpacing(themeDensity(l) * (5 / 1.5)),\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: (l) => themeSize(l, \"decrease-2\"),\n fontWeight: \"600\",\n lineHeight: 1,\n borderRadius: (l) => themeSpacing(themeDensity(l) * 999),\n backgroundColor: (l) => themeColor(l, \"shift-9\", color.get(l)),\n color: (l) => themeColor(l, \"shift-0\", color.get(l)),\n // Hairline ring so the pill pops on same-hue surfaces.\n boxShadow: (l) => `0 0 0 1px ${themeColor(l, \"shift-0\", color.get(l))}`,\n },\n },\n };\n}\n\nexport { badge };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a quotation block with a colored inset side bar, padded surface, and\n * shifted tone. Apply to a `<blockquote>` element.\n *\n * @hostTag blockquote\n * @param props.color - Surface/bar color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { blockquote: \"Design is how it works.\", $: [blockquote({ color: \"primary\" })] }\n */\nfunction blockquote(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"blockquote\") {\n console.warn(`\"blockquote\" primitive patch must use blockquote tag`);\n }\n },\n dataTone: \"shift-2\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n boxShadow: (listener) =>\n `inset ${themeSpacing(1)} 0 0 0 ${themeColor(listener, \"shift-4\", color.get(listener))}`,\n border: \"none\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n margin: 0,\n },\n };\n}\n\nexport { blockquote };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A horizontal breadcrumb navigation that lays out its children with a\n * separator between items and highlights the `[aria-current=page]` item.\n * Apply to a `<nav>` element.\n *\n * @hostTag nav\n * @param props.color - Color tone for links/separators. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @param props.separator - String inserted between items via `::after`. Optional `string`, default \"/\".\n * @example { nav: null, $: [breadcrumb({ separator: \"›\" })] }\n */\nfunction breadcrumb(\n props: { color?: ValueOrState<ThemeColor>; separator?: string } = {},\n): PartialElement {\n const { separator = \"/\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"nav\")\n console.warn('\"breadcrumb\" patch must use nav tag');\n },\n ariaLabel: \"breadcrumb\",\n style: {\n display: \"flex\",\n alignItems: \"center\",\n flexWrap: \"wrap\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n gap: themeSpacing(1),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n \"& > *\": {\n display: \"inline-flex\",\n alignItems: \"center\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n \"& > *:not(:last-child)::after\": {\n content: `\"${separator}\"`,\n color: (listener) =>\n themeColor(listener, \"shift-4\", color.get(listener)),\n paddingInlineStart: themeSpacing(1),\n },\n \"& > [aria-current=page]\": {\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { breadcrumb };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * An ellipsis trigger button for collapsed breadcrumb items, with hover and\n * focus-visible states. Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.color - Color tone for the trigger. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { button: \"…\", $: [breadcrumbEllipsis({ color: \"neutral\" })] }\n */\nfunction breadcrumbEllipsis(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn('\"breadcrumbEllipsis\" patch must use button tag');\n }\n },\n ariaLabel: \"More breadcrumb items\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n paddingInline: themeSpacing(1),\n border: \"none\",\n background: \"none\",\n cursor: \"pointer\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n borderRadius: themeSpacing(1),\n transition:\n \"color 140ms ease, background-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover\": {\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n },\n };\n}\n\nexport { breadcrumbEllipsis };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { BUTTON_SIZE_FONT, type ButtonSize } from \"../utils/buttonSize.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport { buttonGhost } from \"./buttonGhost.js\";\n\ntype ButtonVariant = \"solid\" | \"outline\" | \"ghost\";\n\nconst PADDING_STEPS: Record<ButtonSize, { block: number; inline: number }> = {\n small: { block: 0.5, inline: 2 },\n medium: { block: 1, inline: 3 },\n large: { block: 1.5, inline: 4 },\n};\n\n/**\n * A themed button control with density-aware padding/radius and hover, pressed\n * (`:active` ±2), focus-visible, `[disabled]`, and `[aria-busy=true]` states.\n * Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @param props.variant - Visual style: `\"outline\"` (tinted background + outline, default,\n * backward compatible), `\"solid\"` (filled background, readable contrast text), or `\"ghost\"`\n * (no background/border — delegates to `buttonGhost()` so the two stay visually identical).\n * @param props.size - Button size preset. Optional `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { button: \"Save\", $: [button({ color: \"primary\" })] }\n * @example { button: \"Delete\", $: [button({ color: \"error\", variant: \"solid\" })] }\n */\nfunction button(\n props: {\n color?: ValueOrState<ThemeColor>;\n variant?: ButtonVariant;\n size?: ButtonSize;\n } = {},\n): PartialElement {\n const variant = props.variant ?? \"outline\";\n if (variant === \"ghost\") {\n return buttonGhost({ color: props.color, size: props.size });\n }\n\n const color = toState(props.color ?? \"primary\", \"color\");\n const isSolid = variant === \"solid\";\n const padding = PADDING_STEPS[props.size ?? \"medium\"];\n const fontSize = BUTTON_SIZE_FONT[props.size ?? \"medium\"];\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn(`\"button\" primitive patch must use button tag`);\n }\n },\n // Solid: deep brand fill (shift-13) + light-end neutral text (shift-0).\n // Mid-ramp shift-8 failed WCAG (~2.2:1 white-on-medium). NOT dataTone-17\n // (that collapsed every color into a near-black pill). Outline text:\n // shift-13 for ≥4.5:1 on light surfaces (shift-9 failed at ~2.57).\n ...(isSolid\n ? {\n _doctorDisable: [\n \"low-contrast\",\n \"color-shift-minimum\",\n \"tone-background-inherit\",\n ] as const,\n }\n : {}),\n style: {\n appearance: \"none\",\n fontSize: (listener) => themeSize(listener, fontSize),\n // Single-line bounded control: block/radius = 1D, inline = 3D.\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding.block),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding.inline),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n width: \"fit-content\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outlineWidth: \"1px\",\n outline: isSolid\n ? \"none\"\n : (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-13\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-13\", color.get(listener))\n : themeColor(listener, \"inherit\", color.get(listener)),\n transition:\n \"background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-14\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-14\", color.get(listener))\n : themeColor(listener, \"hover\", color.get(listener)),\n },\n // Pressed: solid steps deeper on the brand ramp; outline uses +2 surface.\n \"&:active:not([disabled]):not([aria-busy=true])\": {\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-15\", color.get(listener))\n : themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n \"&[aria-busy=true]\": {\n opacity: 0.7,\n cursor: \"wait\",\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { button };\nexport type { ButtonVariant };\n","/**\n * The `fontSize` step for `button()`/`buttonGhost()`'s `size` prop. Padding stays\n * per-component (button and buttonGhost start from different base paddings) so\n * only the part that's genuinely identical — the font-size step — lives here.\n */\nconst BUTTON_SIZE_FONT = {\n small: \"decrease-1\",\n medium: \"inherit\",\n large: \"increase-1\",\n} as const;\n\ntype ButtonSize = keyof typeof BUTTON_SIZE_FONT;\n\nexport { BUTTON_SIZE_FONT };\nexport type { ButtonSize };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { BUTTON_SIZE_FONT, type ButtonSize } from \"../utils/buttonSize.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst PADDING_STEPS: Record<ButtonSize, number> = {\n small: 0.5,\n medium: 1,\n large: 1.5,\n};\n\n/**\n * A transparent button with no border or background — suitable for icon\n * actions, inline controls, and delete/close triggers. Apply to a `<button>`\n * element.\n *\n * @hostTag button\n * @param props.color - Text color tone. Optional `ValueOrState<ThemeColor>`, defaults to `\"neutral\"`.\n * @param props.size - Button size preset. Optional `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { button: \"×\", $: [buttonGhost()] }\n * @example { button: { span: null, $: [icon({ name: \"trash\" })] }, $: [buttonGhost({ color: \"error\" })] }\n */\nfunction buttonGhost(\n props: { color?: ValueOrState<ThemeColor>; size?: ButtonSize } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const padding = PADDING_STEPS[props.size ?? \"medium\"];\n const fontSize = BUTTON_SIZE_FONT[props.size ?? \"medium\"];\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn(`\"buttonGhost\" primitive patch must use button tag`);\n }\n },\n style: {\n appearance: \"none\",\n fontSize: (listener) => themeSize(listener, fontSize),\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n display: \"inline-flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n background: \"none\",\n outline: \"none\",\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n // Resting text uses the \"text\" alias (shift-9) — NOT the semantic-zone\n // shift-6 the patch previously used. A ghost button's label is essential\n // interactive content, and shift-6 on an edge surface measures ~2.4:1,\n // failing WCAG AA (axe color-contrast). shadcn's ghost variant likewise\n // rests at full foreground; hover/active keep the same text color and\n // differentiate via background only.\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:active:not([disabled]):not([aria-busy=true])\": {\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"border-strong\", \"neutral\"),\n },\n \"&[aria-busy=true]\": {\n opacity: 0.7,\n cursor: \"wait\",\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { buttonGhost };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * A pill-shaped toggle switch with `role=\"switch\"`; clicking flips the bound\n * `checked` state and slides the thumb. Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.checked - Toggle state. Optional `ValueOrState<boolean>`, default false.\n * @param props.accentColor - Color tone when checked (on). Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @param props.color - Color tone when unchecked (off track). Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { button: { span: null }, $: [buttonSwitch({ checked: true })] }\n */\nfunction buttonSwitch(\n props: {\n checked?: ValueOrState<boolean>;\n accentColor?: ValueOrState<ThemeColor>;\n color?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { checked = false } = props;\n\n const check = toState(checked);\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onSchedule: (node) => {\n if (node.tagName !== \"button\") {\n console.warn(`\"buttonSwitch\" primitive patch must use button tag`);\n }\n },\n role: \"switch\",\n ariaChecked: (listener) => check.get(listener),\n dataTone: \"shift-2\",\n onClick: () => check.set(!check.get()),\n style: {\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n fontSize: (listener) => themeSize(listener),\n border: \"none\",\n outlineWidth: \"1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color.get(listener))}`,\n minWidth: themeSpacing(12),\n minHeight: themeSpacing(6),\n borderRadius: themeSpacing(999),\n paddingLeft: themeSpacing(7),\n paddingRight: themeSpacing(2),\n cursor: \"pointer\",\n transition:\n \"padding-left 0.3s, padding-right 0.3s, background-color 140ms ease, box-shadow 140ms ease\",\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"& > :first-child\": {\n content: '\"\"',\n position: \"absolute\",\n display: \"inline-flex\",\n alignItems: \"center\",\n left: themeSpacing(0.5),\n top: \"50%\",\n transform: \"translateY(-50%)\",\n transition: \"left 0.3s\",\n width: themeSpacing(5),\n height: themeSpacing(5),\n borderRadius: themeSpacing(999),\n color: (listener) => themeColor(listener, \"text\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"decrease-2\", color.get(listener)),\n },\n \"&[aria-checked=true]\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-3\", accentColor.get(listener)),\n outline: \"none\",\n color: (listener) => themeColor(listener, \"decrease-2\"),\n paddingLeft: themeSpacing(2),\n paddingRight: themeSpacing(7),\n },\n \"&[aria-checked=true] > :first-child\": {\n left: `calc(100% - ${themeSpacing(5.5)})`,\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n };\n}\n\nexport { buttonSwitch };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\n\n/**\n * A grid-based card surface that auto-places known child elements into named\n * regions: `<img>` (image), headings (title), `<p>` (description), `<aside>`\n * (aside), `<div>` (content), and `<footer>` (footer). Typically applied to a\n * `<div>` (any block container).\n *\n * @param props.color - Surface/border color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { div: { h3: \"Title\", p: \"Body\" }, $: [card({ color: \"neutral\" })] }\n */\nfunction card(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n // Title weight is design-system chrome for the card region layout.\n _doctorDisable: \"inline-typography\",\n style: {\n display: \"grid\",\n gridTemplateColumns: \"1fr auto\",\n gridTemplateAreas:\n '\"image image\" \"title aside\" \"desc aside\" \"content content\" \"footer footer\"',\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n outlineOffset: \"-1px\",\n // Soft lift so cards separate from the page without looking like dialogs.\n boxShadow: elevation(\"low\"),\n overflow: \"hidden\",\n \"& > img\": {\n gridArea: \"image\",\n width: \"100%\",\n height: \"auto\",\n display: \"block\",\n },\n \"& > :is(h1,h2,h3,h4,h5,h6)\": {\n gridArea: \"title\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n fontWeight: \"600\",\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n margin: 0,\n },\n \"& > p\": {\n gridArea: \"desc\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n paddingBottom: (listener) => themeSpacing(themeDensity(listener) * 2),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n margin: 0,\n },\n \"& > aside\": {\n gridArea: \"aside\",\n alignSelf: \"center\",\n padding: (listener) => themeSpacing(themeDensity(listener) * 2),\n height: \"auto\",\n },\n \"& > div\": {\n gridArea: \"content\",\n padding: (listener) => themeSpacing(themeDensity(listener) * 4),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n \"& > footer\": {\n gridArea: \"footer\",\n display: \"flex\",\n gap: themeSpacing(2),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n borderTop: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color.get(listener))}`,\n },\n },\n };\n}\n\nexport { card };\n","/** Named elevation levels for floating/raised surfaces. */\ntype ElevationLevel = \"low\" | \"medium\" | \"high\";\n\n// Layered soft shadows (a tight contact shadow + a broad ambient one), black at\n// low alpha so the same value reads correctly on both light and dark surfaces\n// without a theme/context lookup.\nconst SHADOWS: Record<ElevationLevel, string> = {\n low: \"0 1px 2px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.10)\",\n medium: \"0 2px 4px rgba(0,0,0,0.10), 0 10px 24px rgba(0,0,0,0.14)\",\n high: \"0 6px 12px rgba(0,0,0,0.14), 0 24px 48px rgba(0,0,0,0.20)\",\n};\n\n/**\n * Shared box-shadow value for a named elevation level. Used by floating/raised\n * surface patches (popover, menu, dialog, drawer, toast, tooltip, combobox/\n * selectBox dropdown, datePicker popup, fab) so elevation reads consistently\n * across the library instead of each patch picking its own shadow.\n */\nfunction elevation(level: ElevationLevel): string {\n return SHADOWS[level];\n}\n\nexport { elevation };\nexport type { ElevationLevel };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles an inline code snippet with a subtle surface background, rounded corners,\n * and shifted tone. Apply to a `<code>` element.\n *\n * @hostTag code\n * @param props.color - Surface/text color tone. Optional `ValueOrState<ThemeColor>`, default \"neutral\".\n * @example { code: \"npm install\", $: [code({ color: \"neutral\" })] }\n */\nfunction code(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n _onInsert: (node) => {\n if (node.tagName !== \"code\") {\n console.warn(`\"code\" primitive patch must use code tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n whiteSpace: \"nowrap\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n height: (listener) => themeSpacing(themeDensity(listener) * (6 / 1.5)),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * (1.5 / 1.5)),\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * (1 / 1.5)),\n },\n };\n}\n\nexport { code };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n merge,\n type PartialElement,\n type State,\n type StyleObject,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport { tag } from \"./tag.js\";\n\n/**\n * A combobox/multi-select control: renders selected options as removable tags\n * plus an input, and shows a floating popover (`content`) anchored to the host.\n * Apply to a `<div>` element.\n *\n * @hostTag div\n * @param props.multiple - Allow selecting multiple values (popover stays open on click). Optional `boolean`, default false.\n * @param props.value - Selected value(s). Optional `ValueOrState<Array<number | string | null | undefined> | number | string | null | undefined>`, no default.\n * @param props.options - Available `{ label, value }` options used to render selected tags. Optional `Array<{ label: string; value: string }>`, default `[]`.\n * @param props.placement - Floating popover placement. Optional `ValueOrState<Placement>`, default \"bottom\".\n * @param props.content - The floating popover content element. Required `DomphyElement`.\n * @param props.color - Color tone for the control. Optional `ThemeColor`, default \"neutral\".\n * @param props.open - Whether the popover is open. Optional `ValueOrState<boolean>` (including `Computed`/`ReadableState`), default false. When the source is read-only, pass `onDismiss` so dismiss can close.\n * @param props.onDismiss - Called when the popover requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.input - Custom input element; when omitted a default `<input>` is created. Optional `DomphyElement`.\n * @example { div: null, $: [combobox({ options: [{ label: \"A\", value: \"a\" }], content: { div: null } })] }\n */\nfunction combobox(props: {\n multiple?: boolean;\n value?: ValueOrState<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n options?: Array<{ label: string; value: string }>;\n placement?: ValueOrState<Placement>;\n content: DomphyElement;\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n input?: DomphyElement;\n}): PartialElement {\n const {\n options = [],\n placement = \"bottom\",\n color = \"neutral\",\n open = false,\n multiple = false,\n } = props;\n\n const state = toState(props.value);\n const openState = toState(open);\n const { show, hide, anchorPartial } = createFloating({\n kind: \"combobox\",\n open: openState,\n onDismiss: props.onDismiss,\n placement: toState(placement),\n content: props.content,\n });\n\n const popoverPartial: PartialElement = {\n onClick: (_e, node) => !multiple && hide(node),\n dataTone: \"shift-0\",\n style: {\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n // Surface contract (dataTone-surface-contract): a tone-anchored panel\n // must declare BOTH background and text color. Page-matching shift-0\n // (same as menu/selectList/dialog), not the inverted tooltip surface.\n color: (listener) => themeColor(listener, \"text\"),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n\n merge(props.content, popoverPartial);\n\n const inputStyle: StyleObject = {\n border: \"none\",\n outline: \"none\",\n padding: 0,\n margin: 0,\n flex: 1,\n height: themeSpacing(6),\n marginInlineStart: themeSpacing(2),\n fontSize: (listener: any) => themeSize(listener, \"inherit\"),\n color: (listener: any) => themeColor(listener, \"text\", color),\n backgroundColor: (listener: any) => themeColor(listener, \"inherit\", color),\n };\n\n type InnerProps = {\n options: Array<{ label: string; value: string }>;\n multiple: boolean;\n color: ThemeColor;\n state: State<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n input?: DomphyElement;\n };\n\n type ComboboxInner = BehaviorInstance<InnerProps> & {\n query: State<string>;\n };\n\n const readQuery = (listener?: { elementNode?: ElementNode }) =>\n listener?.elementNode?.getBehavior<ComboboxInner>(\"comboboxInner\")?.query;\n\n const findComboboxAnchor = (from: ElementNode): ElementNode => {\n let current: ElementNode | null = from;\n while (current) {\n if (current._behaviorInstances.has(\"floating:combobox\")) return current;\n current = current.parent;\n }\n return from;\n };\n\n const inputAria: PartialElement = {\n role: \"combobox\",\n ariaHaspopup: \"listbox\",\n ariaExpanded: (listener) => openState.get(listener),\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"combobox\", findComboboxAnchor(listener.elementNode))\n : undefined,\n };\n\n const buildInput = (custom?: DomphyElement): DomphyElement => {\n if (custom) {\n merge(custom, {\n onFocus: (_e: Event, node: ElementNode) => show(node),\n style: inputStyle,\n _key: \"combobox-input\",\n ...inputAria,\n });\n return custom;\n }\n return {\n input: null,\n // Accessible name for the filter field (critical for axe label rule).\n ariaLabel: \"Filter options\",\n onFocus: (_e: Event, node: ElementNode) => show(node),\n value: (listener: { elementNode?: ElementNode }) =>\n readQuery(listener)?.get(listener as never) ?? \"\",\n onInput: (event: Event, node: ElementNode) => {\n node\n .getBehavior<ComboboxInner>(\"comboboxInner\")\n ?.query.set((event.target as HTMLInputElement).value);\n },\n style: inputStyle,\n _key: \"combobox-input\",\n ...inputAria,\n };\n };\n\n const buildWrap = (inner: InnerProps): DomphyElement<\"div\"> => ({\n div: (listener) => {\n openState.get(listener);\n const val = inner.state.get(listener);\n const vals = Array.isArray(val) ? val : [val];\n const opts = inner.options.filter((opt) => vals.includes(opt.value));\n const items: DomphyElement[] = opts.map((opt) => {\n return {\n span: opt.label,\n $: [tag({ color: inner.color, removable: true })],\n _key: opt.value,\n _onRemove: (_node: ElementNode) => {\n const cur = inner.state.get();\n const curVals = Array.isArray(cur) ? cur : [cur];\n const filter = curVals.filter((v) => v !== opt.value);\n inner.multiple\n ? inner.state.set(filter as any)\n : inner.state.set(filter[0] as any);\n },\n };\n });\n items.push(buildInput(inner.input));\n return items;\n },\n _key: \"comboboxWrap\",\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: themeSpacing(1),\n },\n });\n\n const attachInner = (\n node: ElementNode,\n _inner: InnerProps,\n ): ComboboxInner => {\n let query = node.getMetadata(\"comboboxQuery\") as State<string> | undefined;\n if (!query) {\n query = toState(\"\");\n node.setMetadata(\"comboboxQuery\", query);\n }\n return {\n query,\n update(next) {\n node.children.update([buildWrap(next)]);\n },\n };\n };\n\n const partial: PartialElement = {\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"combobox\" primitive patch must use div tag`);\n }\n },\n _onSchedule: (node, element) => {\n (element as Record<string, unknown>)[node.tagName] = [\n buildWrap({\n options,\n multiple,\n color,\n state,\n input: props.input,\n }),\n ];\n },\n ...behavior<InnerProps>(\"comboboxInner\", attachInner, {\n options,\n multiple,\n color,\n state,\n input: props.input,\n }),\n style: {\n minWidth: themeSpacing(32),\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n transition:\n \"background-color 140ms ease, outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-within\": {\n boxShadow: (listener) => focusRing(listener, color),\n },\n },\n };\n\n merge(anchorPartial, partial);\n return anchorPartial;\n}\n\nexport { combobox };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n merge,\n type PartialElement,\n type ReadableState,\n type State,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n autoUpdate,\n computePosition,\n flip,\n offset,\n type Placement,\n shift,\n} from \"@domphy/floating\";\nimport {\n asOpenState,\n dismissOpen,\n subscribeOpen,\n writeOpen,\n} from \"./openState.js\";\n\ntype FloatingProps = {\n kind: string;\n openState: ReadableState<boolean>;\n // Lives on the behavior instance so a reused node gets the latest callback\n // via update() — do not close over factory-generation onDismiss.\n onDismiss?: () => void;\n placement: State<Placement>;\n content: DomphyElement;\n // popover's openOn === \"hover\" case: hovering the floating PANEL itself\n // (not just the anchor) must keep it open, so the pointer can travel from\n // trigger to panel without the debounced hide() firing first.\n keepOpenOnContentHover: boolean;\n};\n\n// The panel id every floating component gets, derived deterministically from\n// the ANCHOR's nodeId (stable across generations — a reused node keeps its\n// nodeId — and across SSR/hydration, unlike Math.random()). The anchor's\n// trigger partial references the same id via _onSchedule (aria-controls /\n// aria-describedby), so trigger and panel agree without any factory-scope\n// mutable variable that a fresh generation would lose.\nfunction floatingPanelId(kind: string, node: ElementNode): string {\n return `domphy-${kind}-${node.nodeId}`;\n}\n\ntype FloatingInstance = BehaviorInstance<FloatingProps> & {\n show: () => void;\n hide: () => void;\n panelId: string;\n};\n\n// The per-anchor persistent state a floating component needs (position\n// cleanup, the inserted panel node, debounce timer) used to live in\n// createFloating()'s own closure — but that closure is recreated fresh every\n// time a reactive ancestor re-renders the anchor (popover()/tooltip() called\n// again on the SAME reused DOM element). Only the FIRST-ever generation's\n// _onMount ever fires (ElementNode hooks run once per node), so imperative,\n// document-level listeners (outside-click, Escape-inside-panel) that closed\n// over that generation's `openState`/`reference`/`floating` kept acting on an\n// orphaned copy forever, while live-rebound trigger events (onClick etc.)\n// moved on to whatever generation was actually current — the trigger opened\n// the panel, but nothing could ever close it again from outside.\n//\n// Fixed by moving all of this into ONE `behavior()` instance per (anchor,\n// kind): `attach` runs once, and every later generation's `show`/`hide`\n// calls and `_behaviors` re-declaration route into that SAME instance via\n// `getBehavior`/`update()` — so there is exactly one canonical `openState`/\n// `reference`/`floating` for the anchor's whole lifetime, not one per\n// generation.\nfunction attachFloating(\n node: ElementNode,\n initialProps: FloatingProps,\n): FloatingInstance {\n let { openState, onDismiss, placement, content, keepOpenOnContentHover } =\n initialProps;\n const { kind } = initialProps;\n const behaviorKey = `floating:${kind}`;\n\n let timer: ReturnType<typeof setTimeout> | null = null;\n let cleanup: (() => void) | null = null;\n let floating: HTMLElement | null = null;\n let floatingNode: ElementNode | null = null;\n let mounted = false;\n\n const reference = node.domElement as HTMLElement;\n const rootNode = node.getRoot();\n const panelId = floatingPanelId(kind, node);\n\n const floatingPartial: PartialElement = {\n style: {\n position: \"fixed\",\n pointerEvents: \"auto\",\n visibility: (listener) =>\n openState.get(listener) ? \"visible\" : \"hidden\",\n },\n // Escape must dismiss the panel from INSIDE it too: the content is\n // portaled as a DOM sibling of the anchor, so a keydown on a focused\n // element within the panel (menu item, calendar cell, footer button)\n // never bubbles to the anchor's own Escape handler.\n onKeyDown: (event) => {\n if ((event as KeyboardEvent).key === \"Escape\") hide();\n },\n onMouseEnter: () => keepOpenOnContentHover && show(),\n onMouseLeave: () => keepOpenOnContentHover && hide(),\n _onMount: (mountedNode) => {\n floating = mountedNode.domElement as HTMLElement;\n // Stamped as a plain DOM property (not node.attributes.set) so a later\n // floatingNode.patch(content) — which strips undeclared ATTRIBUTES from\n // its own bookkeeping — never removes it. A consumer-declared id on the\n // content element wins.\n if (!floating.id) floating.id = panelId;\n // Propagate data-theme from the trigger's ancestor so floating content\n // inherits CSS variable scope. Stamped on the PANEL, not the shared\n // overlay: the one overlay serves every floating component under the\n // root, so an overlay-level stamp would let whichever anchor opened\n // FIRST permanently impose its theme on later panels anchored under a\n // different [data-theme] scope. Skipped when the content declares its\n // own data-theme.\n if (reference && floating && !floating.hasAttribute(\"data-theme\")) {\n const dataTheme = reference\n .closest(\"[data-theme]\")\n ?.getAttribute(\"data-theme\");\n if (dataTheme) floating.setAttribute(\"data-theme\", dataTheme);\n }\n },\n _portal: (rNode) => {\n // showModal() puts the dialog in the top layer, above every z-index.\n // A panel portaled to the root overlay (z-index 20) would paint UNDER\n // an open dialog — drop it into the ancestor dialog instead so it\n // shares the top layer.\n const dialogHost = reference.closest(\"dialog\");\n if (dialogHost) {\n let overlay = dialogHost.querySelector(\":scope > #domphy-floating\");\n if (!overlay) {\n overlay = dialogHost.ownerDocument.createElement(\"div\");\n overlay.id = \"domphy-floating\";\n Object.assign((overlay as HTMLElement).style, {\n position: \"fixed\",\n inset: \"0\",\n zIndex: \"20\",\n pointerEvents: \"none\",\n });\n dialogHost.appendChild(overlay);\n }\n return overlay;\n }\n let overlay = rNode.domElement!.querySelector(`#domphy-floating`);\n if (!overlay) {\n const overlayEle: DomphyElement<\"div\"> = {\n div: [],\n id: `domphy-floating`,\n style: {\n position: \"fixed\",\n inset: 0,\n zIndex: 20,\n pointerEvents: \"none\",\n },\n };\n const overlayNode = rNode.children!.insert(overlayEle) as ElementNode;\n overlay = overlayNode.domElement!;\n }\n return overlay;\n },\n };\n\n // Later generations declare their OWN fresh `content` object (a new object\n // literal at the popover()/tooltip() call site) — wire it every time, not\n // just at attach, so the panel wiring (theming, portal, dismiss handlers)\n // is present regardless of which generation's content ends up mounted.\n const wireContent = (target: DomphyElement) => merge(target, floatingPartial);\n wireContent(content);\n\n const ensureMounted = () => {\n if (mounted) return;\n mounted = true;\n floatingNode = rootNode.children!.insert(content) as ElementNode;\n // Expose THIS instance on the panel node too: the panel is portaled as a\n // child of the ROOT (not of the anchor), so getBehavior's ancestor walk\n // from a panel descendant (a selectBox/combobox option, a datePicker day\n // cell) never reaches the anchor's registration. Registering the same\n // instance on the panel lets panel-originated events resolve it via\n // `node.getBehavior(behaviorKey)` — the documented walk-up pattern. No\n // teardown wiring here: the instance's lifetime is owned by the anchor\n // (destroy there), the registration simply dies with the panel node.\n floatingNode._behaviorInstances.set(behaviorKey, instance);\n };\n\n const instantShow = () => {\n // A re-render can detach the panel DOM without going through\n // instantHide (overlay reconcile, in-place patch). If we still think\n // we are mounted, skip insert and the panel never comes back.\n if (mounted && (!floating || !floating.isConnected)) {\n cleanup?.();\n cleanup = null;\n floatingNode = null;\n floating = null;\n mounted = false;\n }\n ensureMounted();\n if (reference && floating) {\n cleanup?.();\n cleanup = autoUpdate(reference, floating, () => {\n computePosition(reference as HTMLElement, floating as HTMLElement, {\n placement: placement.get() as Placement,\n // rootBoundary deliberately stays at the upstream default\n // ('viewport', i.e. the VISUAL viewport): with strategy \"fixed\" the\n // 1.8.0 'layoutViewport' option would stop clamping flip/shift to\n // the visible area, letting a panel land (partly) outside the\n // visible viewport during mobile pinch-zoom — a worse failure than\n // the jumpiness it fixes. Pinch-zoom/keyboard drift is already\n // handled by autoUpdate's post-1.8.0 observeMove re-anchoring.\n middleware: [offset(12), flip(), shift()],\n strategy: \"fixed\",\n }).then(({ x, y, placement: resolved }) => {\n // Teardown can run while computePosition's async work is in\n // flight (it nulls `floating` and removes the panel) — skip the\n // late positioning instead of dereferencing null.\n if (!floating) return;\n Object.assign(floating.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n placement.set(resolved);\n });\n });\n writeOpen(openState, true);\n }\n };\n // Fully unmounts (not just CSS-hides) the panel — mirrors show()'s own\n // insert-on-demand: a closed floating component holds no DOM/listeners.\n // ensureMounted() re-inserts a fresh panel node next time show() runs.\n // Visual unmount runs even when the source is read-only (Computed).\n const instantHide = () => {\n cleanup?.();\n cleanup = null;\n if (floatingNode) {\n floatingNode.remove();\n floatingNode = null;\n }\n floating = null;\n mounted = false;\n dismissOpen(openState, onDismiss);\n };\n const show = () => {\n timer && clearTimeout(timer);\n timer = setTimeout(instantShow, 100);\n };\n const hide = () => {\n timer && clearTimeout(timer);\n timer = setTimeout(instantHide, 100);\n };\n\n const handleOutside = (event: MouseEvent) => {\n if (!openState.get() || !reference || !floating) return;\n const target = event.target as Node;\n if (!reference.contains(target) && !floating.contains(target)) hide();\n };\n rootNode.domElement?.addEventListener(\"click\", handleOutside);\n\n // Escape must dismiss an open panel from ANYWHERE, not just from the\n // trigger or inside the panel (peer parity: Radix DismissableLayer closes\n // on a document-level Escape) — a hover-opened tooltip with focus sitting\n // on <body> otherwise ignores Escape entirely. Keyboard events target the\n // FOCUSED element and bubble UP, so unlike the outside-click listener this\n // one must live on the document (keydown is composed, so panels inside a\n // shadow root still reach it). Idempotent alongside the trigger/panel-level\n // Escape handlers: hide() is debounced and re-arming it on an\n // already-closed panel is a no-op.\n const handleEscape = (event: Event) => {\n if ((event as KeyboardEvent).key === \"Escape\" && openState.get()) hide();\n };\n const escapeTarget: EventTarget | null =\n rootNode.domElement?.ownerDocument ?? rootNode.domElement ?? null;\n escapeTarget?.addEventListener(\"keydown\", handleEscape);\n\n // Caller-driven open (open.set(true) / open:true) must insert the panel —\n // show()/hide() are only the trigger-event path. Guard with `mounted` so\n // instantShow/instantHide's own writeOpen/dismissOpen does not recurse\n // (writable State.set notifies listeners).\n const onOpen = (val: boolean) => {\n if (val) {\n if (!mounted) instantShow();\n } else if (mounted) {\n instantHide();\n }\n };\n let release = () => {};\n let destroyed = false;\n let updating = false;\n let instance: FloatingInstance;\n\n // Stamped after `instance` exists. The panel is patched in place on every\n // generation; patch() prunes _behaviorInstances keys absent from the new\n // descriptor and destroy()s them. The instance is SHARED with the anchor —\n // pruning it unmounts the live panel. Declaring the key on the content\n // keeps prune from treating it as leftover.\n const stampPanelBehavior = (target: DomphyElement) => {\n target._behaviors = {\n ...(target._behaviors ?? {}),\n [behaviorKey]: { attach: () => instance, props: {} },\n };\n };\n\n instance = {\n show,\n hide,\n panelId,\n update(props) {\n if (updating) return;\n onDismiss = props.onDismiss;\n if (props.openState !== openState) {\n release();\n openState = props.openState;\n // emitCurrent false: a fresh uncontrolled toState(false) on a reused\n // node is not a caller close.\n release = subscribeOpen(openState, onOpen, false);\n // Show if the new object is already true (open:true / caller-owned).\n if (openState.get()) instantShow();\n }\n placement = props.placement;\n content = props.content;\n keepOpenOnContentHover = props.keepOpenOnContentHover;\n wireContent(content);\n stampPanelBehavior(content);\n // Reflect the new generation's declared content into the already-\n // mounted panel in place (same DOM node, no flicker/teardown) — the\n // ordinary reused-node \"patch, don't recreate\" contract, applied to\n // the imperatively-inserted panel too.\n if (floatingNode) {\n updating = true;\n try {\n floatingNode.patch(content);\n } finally {\n updating = false;\n }\n }\n },\n destroy() {\n if (destroyed) return;\n destroyed = true;\n if (timer) clearTimeout(timer);\n timer = null;\n cleanup?.();\n cleanup = null;\n floatingNode?.remove();\n floatingNode = null;\n floating = null;\n mounted = false;\n release();\n release = () => {};\n rootNode.domElement?.removeEventListener(\"click\", handleOutside);\n escapeTarget?.removeEventListener(\"keydown\", handleEscape);\n },\n };\n stampPanelBehavior(content);\n // After `instance` exists: ensureMounted registers it on the panel node.\n // subscribeOpen notifies immediately (replaces onOpen(openState.get())).\n release = subscribeOpen(openState, onOpen);\n return instance;\n}\n\nfunction createFloating(props: {\n kind: string;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement: State<Placement>;\n content: DomphyElement;\n keepOpenOnContentHover?: boolean;\n}) {\n const { kind, placement, onDismiss } = props;\n const openState = asOpenState(props.open);\n const behaviorKey = `floating:${kind}`;\n\n // Trigger event handlers ARE live-rebound on every patch and already\n // receive the current ElementNode as their 2nd argument (unlike lifecycle\n // hooks) — so show(node)/hide(node) just forward to whatever instance is\n // attached there, regardless of which generation's closure is calling.\n const show = (node?: ElementNode) =>\n node?.getBehavior<FloatingInstance>(behaviorKey)?.show();\n const hide = (node?: ElementNode) =>\n node?.getBehavior<FloatingInstance>(behaviorKey)?.hide();\n\n // Plain spread, NOT merge(): merge() defensively deep-clones its `target`\n // argument, which would snapshot `props.content` right now — but the\n // caller (popover()/tooltip()) hasn't finished mutating it yet (it pushes\n // its OWN partial onto `content.$` right after this call returns). A\n // premature clone silently drops that later mutation, so the panel loses\n // its role/style/dismiss wiring. Spread keeps the `_behaviors` record's\n // `props.content` a live reference to the SAME object the caller mutates.\n const anchorPartial: PartialElement = {\n onKeyDown: (e: Event, node: ElementNode) =>\n (e as KeyboardEvent).key === \"Escape\" && hide(node),\n ...behavior<FloatingProps>(behaviorKey, attachFloating, {\n kind,\n openState,\n onDismiss,\n placement,\n content: props.content,\n keepOpenOnContentHover: !!props.keepOpenOnContentHover,\n }),\n };\n\n return { show, hide, anchorPartial };\n}\n\nexport { createFloating, floatingPanelId };\n","import {\n effect,\n type ReadableState,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\n\nexport function isWritableState<T>(\n source: ReadableState<T>,\n): source is State<T> {\n return typeof (source as State<T>).set === \"function\";\n}\n\n/**\n * Subscribe to overlay `open`. Writable State uses `addListener` (no\n * fabricated `.set()`, existing listenerCount-on-remove tests). Computed has\n * no `addListener` — `effect()` reads `get()`.\n *\n * `emitCurrent` (default true) delivers the value once on subscribe, matching\n * first-attach `update(state.get())`. Pass false when re-subscribing on a\n * reused node so a fresh uncontrolled `toState(false)` is not a caller close.\n */\nexport function subscribeOpen(\n source: ReadableState<boolean>,\n onChange: (open: boolean) => void,\n emitCurrent = true,\n): () => void {\n if (typeof (source as State<boolean>).addListener === \"function\") {\n if (emitCurrent) onChange(source.get());\n return (source as State<boolean>).addListener(onChange);\n }\n if (emitCurrent) {\n return effect(() => {\n onChange(source.get());\n });\n }\n let skipInitial = true;\n const release = effect(() => {\n const value = source.get();\n if (skipInitial) return;\n onChange(value);\n });\n skipInitial = false;\n return release;\n}\n\nexport function writeOpen(\n source: ReadableState<boolean>,\n value: boolean,\n): void {\n if (isWritableState(source)) source.set(value);\n}\n\nexport function dismissOpen(\n source: ReadableState<boolean>,\n onDismiss?: () => void,\n): void {\n onDismiss?.();\n writeOpen(source, false);\n}\n\nexport function asOpenState(\n open: ValueOrState<boolean> | undefined,\n): ReadableState<boolean> {\n return toState(open ?? false);\n}\n","import {\n behavior,\n type DomphyElement,\n ElementNode,\n type PartialElement,\n rawHtml,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst xSvg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M6.707 5.293l5.293 5.292l5.293 -5.292a1 1 0 0 1 1.414 1.414l-5.292 5.293l5.292 5.293a1 1 0 0 1 -1.414 1.414l-5.293 -5.292l-5.293 5.292a1 1 0 1 1 -1.414 -1.414l5.292 -5.293l-5.292 -5.293a1 1 0 0 1 1.414 -1.414\" /></svg>`;\n\n// Compact-chip chrome was bare `themeSpacing(U)` (catalog snapshots). Default\n// density is 1.5 (`light.densities[2]`, density.ts origin index 2). n = U / 1.5\n// keeps those pixels at default while dataDensity still scales. Height 6U must\n// stay below selectBox/combobox minHeight `(6 + 2d)U` or the chip fills the trigger.\nconst DEFAULT_DENSITY = 1.5;\nconst TAG_HEIGHT = 6 / DEFAULT_DENSITY;\nconst TAG_PAD_INLINE = 2.5 / DEFAULT_DENSITY;\nconst TAG_PAD_END_REMOVABLE = 1 / DEFAULT_DENSITY;\nconst TAG_REMOVE = 4 / DEFAULT_DENSITY;\nconst TAG_REMOVE_RADIUS = 1 / DEFAULT_DENSITY;\n\ntype TagRemoveProps = { removable: boolean };\n\n/**\n * Styles an inline chip/tag (rounded, bordered, optional remove button).\n * No host tag check; typically applied to a `<span>`. When `removable` is true,\n * a close button is inserted that removes the host node on click or Enter/Space.\n *\n * @hostTag span\n * @param props.color - Theme color for the chip background/border/text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @param props.removable - When true, renders a remove (x) button that removes the tag on click or Enter/Space. Optional. Defaults to `false`.\n * @example { span: \"Label\", $: [tag({ removable: true })] }\n */\nfunction tag(\n props: { color?: ValueOrState<ThemeColor>; removable?: boolean } = {},\n): PartialElement {\n const { removable = false } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n // _onInit would miss/orphan the button when a reused node is re-patched\n // with a flipped `removable`. behavior() attaches once and routes later\n // generations through update().\n ...behavior<TagRemoveProps>(\n \"tag-remove\",\n (node, initial) => {\n const removeHost = () => node.remove();\n const makeButton = (): DomphyElement<\"span\"> => ({\n span: rawHtml(xSvg),\n _key: \"tag-remove\",\n onClick: (e) => {\n (e as Event).stopPropagation();\n removeHost();\n },\n onKeyDown: (e) => {\n const event = e as KeyboardEvent;\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n event.stopPropagation();\n removeHost();\n },\n tabindex: 0,\n role: \"button\",\n ariaLabel: \"Remove\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n cursor: \"pointer\",\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_REMOVE_RADIUS),\n width: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_REMOVE),\n height: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_REMOVE),\n flexShrink: 0,\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-4\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n },\n });\n const findButton = () =>\n node.children.items.find(\n (item) => item instanceof ElementNode && item.key === \"tag-remove\",\n ) ?? null;\n // attach() runs from the host Mount hook, which fires BEFORE\n // render() walks children. Inserting with updateDom=true would\n // create a DOM node that render() then creates a second time.\n // First paint: list-only insert, let render() materialize it.\n // Later update(): the walk already finished, so mutate the live DOM.\n const sync = (next: TagRemoveProps, updateDom: boolean) => {\n const existing = findButton();\n if (next.removable && !existing) {\n node.children.insert(makeButton(), undefined, updateDom);\n } else if (!next.removable && existing) {\n node.children.remove(existing);\n }\n };\n sync(initial, false);\n return {\n update: (next) => sync(next, true),\n };\n },\n { removable },\n ),\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n whiteSpace: \"nowrap\",\n userSelect: \"none\",\n height: (listener) => themeSpacing(themeDensity(listener) * TAG_HEIGHT),\n paddingBlock: 0,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 999),\n paddingInlineStart: (listener) =>\n themeSpacing(themeDensity(listener) * TAG_PAD_INLINE),\n paddingInlineEnd: (listener) =>\n themeSpacing(\n themeDensity(listener) *\n (removable ? TAG_PAD_END_REMOVABLE : TAG_PAD_INLINE),\n ),\n gap: themeSpacing(1.5),\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n },\n };\n}\n\nexport { tag };\n","import { merge, type PartialElement, toState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Command-palette container patch. Sets up a vertical flex column and provides a\n * shared `command` context (a query State) consumed by `commandSearch` and\n * `commandItem` descendants to filter the list. Typically applied to a `<div>`.\n *\n * @example { div: [...], $: [command()] }\n */\nfunction command(): PartialElement {\n return {\n // Group (not listbox): search input + option buttons share one container;\n // listbox forbids non-option children (aria-required-children).\n role: \"group\",\n ariaLabel: \"Commands\",\n _onSchedule: (_node, element) => {\n merge(element, {\n _context: {\n command: {\n query: toState(\"\"),\n },\n },\n });\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n },\n };\n}\n\n/**\n * Search input for a command palette. Wires the input's value into the parent\n * `command` context's query State so descendant `commandItem`s filter live.\n * Apply to an `<input>` element used inside a `command()`.\n *\n * @hostTag input\n * @param props.color - Base theme color tone. Defaults to \"neutral\".\n * @param props.accentColor - Accent color used for the focus border. Defaults to \"primary\".\n * @example { input: \"\", $: [commandSearch({ accentColor: \"primary\" })] }\n */\nfunction commandSearch(\n props: { color?: ThemeColor; accentColor?: ThemeColor } = {},\n): PartialElement {\n const { color = \"neutral\", accentColor = \"primary\" } = props;\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"commandSearch\" patch must use input tag`);\n }\n },\n _onMount: (node) => {\n const ctx = node.getContext(\"command\");\n if (!ctx) {\n console.warn(`\"commandSearch\" patch must be used inside a \"command\"`);\n return;\n }\n const input = node.domElement as HTMLInputElement;\n const onInput = () => ctx.query.set(input.value);\n input.addEventListener(\"input\", onInput);\n node.addHook(\"Remove\", () => input.removeEventListener(\"input\", onInput));\n },\n style: {\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n border: \"none\",\n borderBottom: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color)}`,\n outline: \"none\",\n color: (listener) => themeColor(listener, \"shift-10\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n \"&::placeholder\": {\n color: (listener) => themeColor(listener, \"shift-7\"),\n },\n transition: \"border-bottom-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n borderBottomColor: (listener) =>\n themeColor(listener, \"shift-6\", accentColor),\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n },\n };\n}\n\n/**\n * Selectable item in a command palette. On mount, immediately hides itself if\n * the current query doesn't match its text content, and subscribes to future\n * query changes — so items added dynamically after a search is typed are\n * correctly filtered. Typically applied to a `<button>` (or any clickable\n * element) used inside a `command()`. Uses native button semantics (not\n * `role=option`) so the search input may sit as a sibling without a listbox\n * parent requirement.\n *\n * @param props.color - Base theme color tone. Defaults to \"neutral\".\n * @param props.accentColor - Accent color used for the focus ring. Defaults to \"primary\".\n * @example { button: \"Open file\", $: [commandItem({ color: \"neutral\" })] }\n */\nfunction commandItem(\n props: { color?: ThemeColor; accentColor?: ThemeColor } = {},\n): PartialElement {\n const { color = \"neutral\", accentColor = \"primary\" } = props;\n return {\n _onMount: (node) => {\n const ctx = node.getContext(\"command\");\n if (!ctx) {\n console.warn(`\"commandItem\" patch must be used inside a \"command\"`);\n return;\n }\n const el = node.domElement as HTMLElement;\n const text = el.textContent?.toLowerCase() ?? \"\";\n const applyFilter = (q: string) => {\n el.hidden = q.length > 0 && !text.includes(q.toLowerCase());\n };\n applyFilter(ctx.query.get());\n const release = ctx.query.addListener(applyFilter);\n node.addHook(\"Remove\", release);\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n width: \"100%\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n border: \"none\",\n outline: \"none\",\n // shift-13: menu-row labels need ≥4.5:1 on light surface (visual catalog).\n color: (listener) => themeColor(listener, \"shift-13\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled])\": {\n color: (listener) => themeColor(listener, \"shift-13\", color),\n backgroundColor: (listener) => themeColor(listener, \"hover\", color),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n },\n };\n}\n\nexport { command, commandSearch, commandItem };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n type Listener,\n merge,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** A single date selection, or a `[start, end]` tuple in range mode. */\nexport type DatePickerValue = Date | null | [Date | null, Date | null];\n\nexport interface DatePickerProps {\n /** Controlled value: a `Date` in single mode, a `[start, end]` tuple in range mode. */\n value?: ValueOrState<DatePickerValue>;\n /** Selection mode. */\n mode?: \"single\" | \"range\";\n /** Also pick hour + minute. The chosen time applies to the selected date(s). */\n time?: boolean;\n /** Earliest selectable day (inclusive). */\n min?: Date;\n /** Latest selectable day (inclusive). */\n max?: Date;\n /** Disable arbitrary days. */\n disabledDate?: (date: Date) => boolean;\n /** BCP-47 locale for month/weekday names, first-day-of-week, and formatting. */\n locale?: string;\n /** Override the first day of the week (0 = Sunday … 6 = Saturday). */\n weekStartsOn?: number;\n /** Override the input display string. */\n format?: (value: DatePickerValue) => string;\n /** Called whenever the selection changes. */\n onChange?: (value: DatePickerValue) => void;\n /** Accent color for the selected/active days. */\n accentColor?: ValueOrState<ThemeColor>;\n /** Popover placement relative to the input. */\n placement?: ValueOrState<Placement>;\n}\n\n// --- date helpers (no third-party library) -----------------------------------\n\nconst atMidnight = (date: Date): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate());\nconst addDays = (date: Date, count: number): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate() + count);\nconst addMonths = (date: Date, count: number): Date =>\n new Date(date.getFullYear(), date.getMonth() + count, date.getDate());\nconst sameDay = (a: Date | null, b: Date | null): boolean =>\n !!a &&\n !!b &&\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate();\nconst isoOf = (date: Date): string =>\n `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, \"0\")}-${String(\n date.getDate(),\n ).padStart(2, \"0\")}`;\nconst startOfWeek = (date: Date, weekStart: number): Date =>\n addDays(date, -((date.getDay() - weekStart + 7) % 7));\n\n/** Resolves the locale's first day of week, falling back to Sunday. */\nfunction localeWeekStart(locale: string): number {\n try {\n const localeObject = new Intl.Locale(locale) as Intl.Locale & {\n weekInfo?: { firstDay: number };\n getWeekInfo?: () => { firstDay: number };\n };\n const info = localeObject.getWeekInfo?.() ?? localeObject.weekInfo;\n if (info?.firstDay) return info.firstDay % 7; // Intl uses 1=Mon … 7=Sun\n } catch {\n // unsupported locale or engine — fall through to Sunday\n }\n return 0;\n}\n\n// --- per-node state preservation (reused-node lifecycle) -------------------\n\ntype DatePickerStates = {\n selection: State<DatePickerValue>;\n // When the caller passed `value`, each generation's toState(Date) is a\n // new object whose current value IS the caller's Date — copying the\n // previous internal selection onto it would overwrite that Date.\n selectionIsCallerOwned: boolean;\n viewYear: State<number>;\n viewMonth: State<number>;\n focused: State<Date>;\n hovered: State<Date | null>;\n hour: State<number>;\n minute: State<number>;\n open: State<boolean>;\n onChange?: (value: DatePickerValue) => void;\n};\n\n// Every ancestor re-render re-invokes datePicker() on the SAME reused input\n// node, allocating a fresh set of internal states with INITIAL values —\n// without carry-forward the user's uncontrolled selection, calendar view and\n// time silently reset on the next re-render, and the onChange subscription\n// (wired to the first generation's selection object) goes stale. ONE\n// behavior instance per node copies the live values into each new\n// generation's states (update() runs during patch(), before the fresh\n// input/calendar bindings evaluate) and keeps exactly one onChange\n// subscription on the CURRENT generation's selection.\nfunction attachDatePicker(\n _node: ElementNode,\n initialProps: DatePickerStates,\n): BehaviorInstance<DatePickerStates> {\n let current = initialProps;\n let releaseOnChange: (() => void) | null = null;\n const subscribe = (props: DatePickerStates) => {\n releaseOnChange?.();\n releaseOnChange = props.onChange\n ? props.selection.addListener((value) => props.onChange!(value))\n : null;\n };\n const carryForward = (next: State<any>, prev: State<any>) => {\n if (next !== prev) next.set(prev.get());\n };\n subscribe(current);\n return {\n update(next) {\n if (!next.selectionIsCallerOwned) {\n carryForward(next.selection, current.selection);\n }\n carryForward(next.viewYear, current.viewYear);\n carryForward(next.viewMonth, current.viewMonth);\n carryForward(next.focused, current.focused);\n carryForward(next.hovered, current.hovered);\n carryForward(next.hour, current.hour);\n carryForward(next.minute, current.minute);\n carryForward(next.open, current.open);\n if (\n next.selection !== current.selection ||\n next.onChange !== current.onChange\n ) {\n // Re-subscribe AFTER the carry-forward so it never fires onChange.\n subscribe(next);\n }\n current = next;\n },\n destroy() {\n releaseOnChange?.();\n releaseOnChange = null;\n },\n };\n}\n\n/**\n * A native, themeable date picker patch for an `<input>`. Opens a calendar\n * popover (rendered with Domphy elements, positioned via `@domphy/floating`)\n * supporting single/range selection, optional time, min/max + disabled days,\n * localized names, and keyboard navigation. The input is read-only and shows the\n * formatted selection; compose with `inputText()` for the input's look.\n *\n * @hostTag input\n * @param props.value - Controlled value (`ValueOrState<DatePickerValue>`): a `Date`/`null` in single mode, a `[start, end]` tuple in range mode.\n * @param props.mode - Selection mode, \"single\" | \"range\". Defaults to \"single\".\n * @param props.time - When true, also pick hour + minute (applied to the selected date(s)). Defaults to false.\n * @param props.min - Earliest selectable day (inclusive), a `Date`.\n * @param props.max - Latest selectable day (inclusive), a `Date`.\n * @param props.disabledDate - Predicate `(date: Date) => boolean` to disable arbitrary days.\n * @param props.locale - BCP-47 locale for names/first-day-of-week/formatting. Defaults to `navigator.language` (or \"en-US\" in non-browser).\n * @param props.weekStartsOn - Override first day of week (0 = Sunday … 6 = Saturday). Defaults to the locale's first day.\n * @param props.format - Override the input display string, `(value: DatePickerValue) => string`.\n * @param props.onChange - Called with the new value whenever the selection changes, `(value: DatePickerValue) => void`.\n * @param props.accentColor - Accent color (`ValueOrState<ThemeColor>`) for selected/active days. Defaults to \"primary\".\n * @param props.placement - Popover placement (`ValueOrState<Placement>`) relative to the input. Defaults to \"bottom-start\".\n * @example { input: \"\", $: [inputText(), datePicker({ mode: \"range\" })] }\n */\nfunction datePicker(props: DatePickerProps = {}): PartialElement {\n const {\n mode = \"single\",\n time = false,\n min,\n max,\n disabledDate,\n locale = typeof navigator !== \"undefined\" ? navigator.language : \"en-US\",\n format,\n onChange,\n } = props;\n\n const weekStart = props.weekStartsOn ?? localeWeekStart(locale);\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n const placeState = toState(props.placement ?? \"bottom-start\");\n\n const selection = toState<DatePickerValue>(\n props.value ?? (mode === \"range\" ? [null, null] : null),\n );\n\n const primaryDate = ((): Date => {\n const current = selection.get();\n const base =\n mode === \"range\" ? (current as [Date | null, Date | null])?.[0] : current;\n return base instanceof Date ? base : new Date();\n })();\n\n const viewYear = toState(primaryDate.getFullYear(), \"viewYear\");\n const viewMonth = toState(primaryDate.getMonth(), \"viewMonth\");\n const focused = toState<Date>(atMidnight(primaryDate), \"focused\");\n const hovered = toState<Date | null>(null, \"hovered\");\n const hour = toState(primaryDate.getHours(), \"hour\");\n const minute = toState(primaryDate.getMinutes(), \"minute\");\n\n // --- formatting -----------------------------------------------------------\n const dateFormatter = new Intl.DateTimeFormat(locale, {\n dateStyle: \"medium\",\n ...(time ? { timeStyle: \"short\" as const } : {}),\n });\n const monthFormatter = new Intl.DateTimeFormat(locale, {\n month: \"long\",\n year: \"numeric\",\n });\n const weekdayFormatter = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n });\n const fullDateFormatter = new Intl.DateTimeFormat(locale, {\n dateStyle: \"full\",\n });\n\n const formatOne = (date: Date | null): string =>\n date ? dateFormatter.format(date) : \"\";\n const formatDisplay = (value: DatePickerValue): string => {\n if (format) return format(value);\n if (mode === \"range\") {\n const [start, end] = (value as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n return start ? `${formatOne(start)} – ${formatOne(end)}` : \"\";\n }\n return formatOne(value as Date | null);\n };\n\n // 2023-01-01 is a Sunday, so index 0 maps to Sunday before the week-start shift.\n const weekdayNames = Array.from({ length: 7 }, (_unused, index) =>\n weekdayFormatter.format(new Date(2023, 0, 1 + ((index + weekStart) % 7))),\n );\n\n // --- selection logic ------------------------------------------------------\n const isDisabled = (date: Date): boolean =>\n (!!min && atMidnight(date) < atMidnight(min)) ||\n (!!max && atMidnight(date) > atMidnight(max)) ||\n (!!disabledDate && disabledDate(date));\n\n const withTime = (date: Date): Date => {\n if (!time) return atMidnight(date);\n const result = atMidnight(date);\n result.setHours(hour.get(), minute.get(), 0, 0);\n return result;\n };\n\n const selectDate = (date: Date, node?: ElementNode): void => {\n if (isDisabled(date)) return;\n if (mode === \"single\") {\n selection.set(withTime(date));\n // Close via the cell's node: the floating behavior instance is\n // registered on the panel node (floating.ts), so getBehavior's\n // ancestor walk from any panel descendant resolves it.\n if (!time) hide(node);\n return;\n }\n const [start, end] = (selection.get() as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n if (!start || (start && end)) {\n selection.set([withTime(date), null]);\n } else if (atMidnight(date) < atMidnight(start)) {\n selection.set([withTime(date), withTime(start)]);\n if (!time) hide(node);\n } else {\n selection.set([start, withTime(date)]);\n if (!time) hide(node);\n }\n };\n\n const reapplyTime = (): void => {\n if (!time) return;\n if (mode === \"single\") {\n const current = selection.get() as Date | null;\n if (current) selection.set(withTime(current));\n } else {\n const [start, end] = (selection.get() as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n selection.set([\n start ? withTime(start) : start,\n end ? withTime(end) : end,\n ]);\n }\n };\n\n const inSelectedRange = (date: Date, listener?: Listener): boolean => {\n if (mode !== \"range\") return false;\n const [start, end] = (selection.get(listener) as [\n Date | null,\n Date | null,\n ]) ?? [null, null];\n const tail = end ?? hovered.get(listener);\n if (!start || !tail) return false;\n const low = atMidnight(start) <= atMidnight(tail) ? start : tail;\n const high = atMidnight(start) <= atMidnight(tail) ? tail : start;\n const day = atMidnight(date);\n return day >= atMidnight(low) && day <= atMidnight(high);\n };\n\n const isSelectedEnd = (date: Date, listener?: Listener): boolean => {\n const current = selection.get(listener);\n if (mode === \"range\") {\n const [start, end] = (current as [Date | null, Date | null]) ?? [\n null,\n null,\n ];\n return sameDay(date, start) || sameDay(date, end);\n }\n return sameDay(date, current as Date | null);\n };\n\n // --- view navigation ------------------------------------------------------\n const goToDate = (date: Date): void => {\n viewYear.set(date.getFullYear());\n viewMonth.set(date.getMonth());\n };\n const shiftMonth = (delta: number): void => {\n const next = addMonths(new Date(viewYear.get(), viewMonth.get(), 1), delta);\n goToDate(next);\n };\n const shiftYear = (delta: number): void =>\n viewYear.set(viewYear.get() + delta);\n\n const focusActiveCell = (node?: ElementNode): void => {\n // Resolve the panel from the caller's live node (trigger or grid cell):\n // the old factory-scope `contentElement` was only ever assigned by the\n // first panel generation's _onMount, so later generations (reused node,\n // fresh closure) could never move focus into the grid.\n const root = node?.getRoot()?.domElement;\n setTimeout(() => {\n root\n ?.querySelector<HTMLElement>(`[data-date=\"${isoOf(focused.get())}\"]`)\n ?.focus();\n }, 0);\n };\n\n // --- floating popover ------------------------------------------------------\n const calendar = buildCalendar();\n const openState = toState(false);\n const { show, hide, anchorPartial } = createFloating({\n kind: \"datePicker\",\n open: openState,\n placement: placeState,\n content: calendar,\n });\n\n // Move focus into the grid when the popover opens.\n const triggerPartial: PartialElement = {\n type: \"text\",\n readonly: true,\n value: (listener) => formatDisplay(selection.get(listener)),\n role: \"combobox\",\n ariaHaspopup: \"dialog\",\n ariaExpanded: (listener) => openState.get(listener),\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"datePicker\", listener.elementNode)\n : undefined,\n ariaLabel: \"Choose date\",\n style: { cursor: \"pointer\" },\n onClick: (_e, node) => {\n openAndFocus(node);\n },\n onFocus: (_e, node) => {\n openAndFocus(node);\n },\n onKeyDown: (event, node) => {\n const key = (event as KeyboardEvent).key;\n if (key === \"ArrowDown\" || key === \"Enter\") {\n event.preventDefault();\n openAndFocus(node);\n }\n },\n ...behavior<DatePickerStates>(\"datePicker\", attachDatePicker, {\n selection,\n selectionIsCallerOwned: props.value !== undefined,\n viewYear,\n viewMonth,\n focused,\n hovered,\n hour,\n minute,\n open: openState,\n onChange,\n }),\n };\n function openAndFocus(node?: ElementNode): void {\n const current = isSelectedPrimary() ?? new Date();\n focused.set(atMidnight(current));\n goToDate(current);\n show(node);\n focusActiveCell(node);\n }\n function isSelectedPrimary(): Date | null {\n const current = selection.get();\n if (mode === \"range\")\n return (current as [Date | null, Date | null])?.[0] ?? null;\n return (current as Date | null) ?? null;\n }\n merge(anchorPartial, triggerPartial);\n return anchorPartial;\n\n // --- calendar builder -----------------------------------------------------\n function buildCalendar(): DomphyElement<\"div\"> {\n const navButton = (label: string, ariaLabel: string, onClick: () => void) =>\n ({\n button: label,\n type: \"button\",\n ariaLabel,\n onClick,\n style: navButtonStyle(),\n }) as DomphyElement;\n\n const header: DomphyElement<\"div\"> = {\n div: [\n navButton(\"«\", \"Previous year\", () => shiftYear(-1)),\n navButton(\"‹\", \"Previous month\", () => shiftMonth(-1)),\n {\n div: (listener) =>\n monthFormatter.format(\n new Date(viewYear.get(listener), viewMonth.get(listener), 1),\n ),\n ariaLive: \"polite\",\n // Calendar chrome (month/year header), not prose — weight is part\n // of the widget's visual design, not the theme's type scale.\n _doctorDisable: \"inline-typography\",\n style: {\n flex: \"1\",\n textAlign: \"center\",\n fontWeight: \"bold\",\n fontSize: (listener) => themeSize(listener),\n },\n },\n navButton(\"›\", \"Next month\", () => shiftMonth(1)),\n navButton(\"»\", \"Next year\", () => shiftYear(1)),\n ],\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(1),\n marginBottom: themeSpacing(2),\n },\n };\n\n const weekdayHeader: DomphyElement<\"div\"> = {\n div: weekdayNames.map((name, index) => ({\n div: name,\n // Calendar chrome (weekday column labels) — weight is widget design,\n // not theme typography.\n _doctorDisable: \"inline-typography\",\n style: {\n textAlign: \"center\",\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n fontWeight: \"bold\",\n color: (listener) => themeColor(listener, \"shift-7\"),\n paddingBlock: themeSpacing(1),\n },\n _key: index,\n })),\n role: \"row\",\n style: gridRowStyle(),\n };\n\n const grid: DomphyElement<\"div\"> = {\n div: (listener) => buildWeeks(listener),\n role: \"grid\",\n ariaLabel: \"Calendar\",\n onKeyDown: onGridKey,\n onMouseLeave: () => mode === \"range\" && hovered.set(null),\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: themeSpacing(0.5),\n },\n };\n\n const children: DomphyElement[] = [header, weekdayHeader, grid];\n if (time) children.push(buildTimeRow());\n children.push(buildFooter());\n\n return {\n div: children,\n role: \"dialog\",\n ariaModal: \"false\",\n // Surface contract (same as popover/combobox): page-matching shift-0\n // (menu/selectList/dialog), inherit background + \"text\" color. The\n // previous `themeColor(l, \"base\")` resolved to the ramp's MID anchor\n // (var(--neutral-8), gray) with text only 2 tone steps away — an\n // unreadable washed-out panel, invisible to doctor because the calendar\n // is mounted imperatively at runtime. shift-14 inverted the panel in\n // light theme (a dark calendar on a light page).\n dataTone: \"shift-0\",\n style: {\n minWidth: themeSpacing(70),\n padding: themeSpacing(3),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n }\n\n function buildWeeks(listener: Listener): DomphyElement[] {\n const first = new Date(viewYear.get(listener), viewMonth.get(listener), 1);\n const month = viewMonth.get(listener);\n const start = startOfWeek(first, weekStart);\n const weeks: DomphyElement[] = [];\n for (let week = 0; week < 6; week++) {\n const cells: DomphyElement[] = [];\n for (let day = 0; day < 7; day++) {\n const date = addDays(start, week * 7 + day);\n cells.push(buildDayCell(date, month, listener));\n }\n weeks.push({\n div: cells,\n role: \"row\",\n style: gridRowStyle(),\n _key: week,\n });\n }\n return weeks;\n }\n\n function buildDayCell(\n date: Date,\n month: number,\n listener: Listener,\n ): DomphyElement {\n const disabled = isDisabled(date);\n const selected = isSelectedEnd(date, listener);\n const within = inSelectedRange(date, listener);\n const outside = date.getMonth() !== month;\n const isFocused = sameDay(date, focused.get(listener));\n const isToday = sameDay(date, new Date());\n\n return {\n button: String(date.getDate()),\n type: \"button\",\n role: \"gridcell\",\n tabIndex: isFocused ? 0 : -1,\n ariaSelected: selected,\n ariaDisabled: disabled,\n disabled,\n ariaLabel: fullDateFormatter.format(date),\n dataDate: isoOf(date),\n onClick: (_e: Event, node: ElementNode) => selectDate(date, node),\n onMouseEnter: () => mode === \"range\" && hovered.set(date),\n style: {\n appearance: \"none\",\n border: \"none\",\n cursor: disabled ? \"not-allowed\" : \"pointer\",\n aspectRatio: \"1\",\n borderRadius: themeSpacing(1),\n fontSize: (l: Listener) => themeSize(l),\n fontFamily: \"inherit\",\n opacity: disabled ? 0.35 : outside ? 0.5 : 1,\n backgroundColor: (l: Listener) =>\n selected\n ? themeColor(l, \"shift-7\", accentColor.get(l))\n : within\n ? themeColor(l, \"hover\", accentColor.get(l))\n : \"transparent\",\n color: (l: Listener) =>\n selected\n ? themeColor(l, \"shift-0\", accentColor.get(l))\n : themeColor(l, \"text\"),\n outline: isToday\n ? (l: Listener) =>\n `1px solid ${themeColor(l, \"shift-6\", accentColor.get(l))}`\n : \"none\",\n outlineOffset: \"-2px\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (l: Listener) =>\n selected\n ? themeColor(l, \"shift-7\", accentColor.get(l))\n : themeColor(l, \"shift-3\", accentColor.get(l)),\n },\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor.get(l)),\n },\n },\n _key: isoOf(date),\n } as DomphyElement;\n }\n\n function buildTimeRow(): DomphyElement<\"div\"> {\n const numberSelect = (\n count: number,\n state: ReturnType<typeof toState<number>>,\n ariaLabel: string,\n ): DomphyElement => ({\n select: Array.from({ length: count }, (_unused, value) => ({\n option: String(value).padStart(2, \"0\"),\n value: String(value),\n selected: (listener) => state.get(listener) === value,\n _key: value,\n })) as DomphyElement[],\n ariaLabel,\n onChange: (event) => {\n state.set(Number((event.target as HTMLSelectElement).value));\n reapplyTime();\n },\n style: timeSelectStyle(),\n });\n\n return {\n div: [\n numberSelect(24, hour, \"Hour\"),\n // Time separator glyph — widget chrome, not prose.\n {\n span: \":\",\n _doctorDisable: \"inline-typography\",\n style: { fontWeight: \"bold\" },\n },\n numberSelect(60, minute, \"Minute\"),\n ],\n style: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: themeSpacing(1),\n marginTop: themeSpacing(3),\n },\n };\n }\n\n function buildFooter(): DomphyElement<\"div\"> {\n const action = (\n label: string,\n onClick: (node: ElementNode) => void,\n ): DomphyElement => ({\n button: label,\n type: \"button\",\n onClick: (_e: Event, node: ElementNode) => onClick(node),\n style: {\n appearance: \"none\",\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n fontSize: (l: Listener) => themeSize(l, \"decrease-1\"),\n color: (l: Listener) => themeColor(l, \"muted\", accentColor.get(l)),\n padding: themeSpacing(1),\n },\n });\n return {\n div: [\n action(\"Today\", (node) => {\n const today = new Date();\n focused.set(atMidnight(today));\n goToDate(today);\n focusActiveCell(node);\n }),\n action(\"Clear\", () => {\n selection.set(mode === \"range\" ? [null, null] : null);\n hovered.set(null);\n }),\n ],\n style: {\n display: \"flex\",\n justifyContent: \"space-between\",\n marginTop: themeSpacing(2),\n paddingTop: themeSpacing(2),\n borderTop: (l: Listener) => `1px solid ${themeColor(l, \"border\")}`,\n },\n };\n }\n\n function onGridKey(event: Event, node: ElementNode): void {\n const keyboard = event as KeyboardEvent;\n const current = focused.get();\n let next: Date | null = null;\n switch (keyboard.key) {\n case \"ArrowLeft\":\n next = addDays(current, -1);\n break;\n case \"ArrowRight\":\n next = addDays(current, 1);\n break;\n case \"ArrowUp\":\n next = addDays(current, -7);\n break;\n case \"ArrowDown\":\n next = addDays(current, 7);\n break;\n case \"Home\":\n next = startOfWeek(current, weekStart);\n break;\n case \"End\":\n next = addDays(startOfWeek(current, weekStart), 6);\n break;\n case \"PageUp\":\n next = addMonths(current, keyboard.shiftKey ? -12 : -1);\n break;\n case \"PageDown\":\n next = addMonths(current, keyboard.shiftKey ? 12 : 1);\n break;\n case \"Enter\":\n case \" \":\n keyboard.preventDefault();\n selectDate(current, node);\n return;\n default:\n return;\n }\n keyboard.preventDefault();\n focused.set(next);\n goToDate(next);\n focusActiveCell(node);\n }\n}\n\n// --- shared style fragments --------------------------------------------------\n\nfunction gridRowStyle() {\n return {\n display: \"grid\",\n gridTemplateColumns: \"repeat(7, 1fr)\",\n gap: themeSpacing(0.5),\n };\n}\n\nfunction navButtonStyle() {\n return {\n appearance: \"none\" as const,\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n fontSize: (l: Listener) => themeSize(l),\n color: (l: Listener) => themeColor(l, \"muted\"),\n width: themeSpacing(7),\n height: themeSpacing(7),\n borderRadius: themeSpacing(1),\n \"&:hover\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\"),\n },\n };\n}\n\nfunction timeSelectStyle() {\n return {\n fontFamily: \"inherit\",\n fontSize: (l: Listener) => themeSize(l),\n padding: themeSpacing(1),\n borderRadius: themeSpacing(1),\n // outline, not border — bounded control, keep the geometry formula exact.\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (l: Listener) => `1px solid ${themeColor(l, \"border-strong\")}`,\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n color: (l: Listener) => themeColor(l, \"text\"),\n };\n}\n\nexport { datePicker };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a description list as a two-column grid (terms in the first column,\n * descriptions in the second), theming the nested `<dt>`/`<dd>` elements.\n * Apply to a `<dl>` element.\n *\n * @hostTag dl\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the term/description text. Defaults to \"neutral\".\n * @example { dl: [{ dt: \"Name\" }, { dd: \"Domphy\" }], $: [descriptionList()] }\n */\nfunction descriptionList(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"dl\") {\n console.warn(`\"descriptionList\" primitive patch must use dl tag`);\n }\n },\n // Term weight is design-system chrome for description lists.\n _doctorDisable: \"inline-typography\",\n style: {\n display: \"grid\",\n gridTemplateColumns: `minmax(${themeSpacing(24)}, max-content) 1fr`,\n columnGap: themeSpacing(4),\n margin: 0,\n \"& dt\": {\n margin: 0,\n fontWeight: 600,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n \"& dd\": {\n margin: 0,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n },\n };\n}\n\nexport { descriptionList };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native disclosure widget: a themed `<summary>` header with an\n * animated rotating chevron and an expand/collapse transition on the body\n * content. Apply to a `<details>` element.\n *\n * @hostTag details\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the body/summary. Defaults to \"neutral\".\n * @param props.accentColor - Accent color (`ValueOrState<ThemeColor>`) for the summary's focus ring. Defaults to \"primary\".\n * @param props.duration - Open/close transition duration in milliseconds. Defaults to 240.\n * @example { details: [{ summary: \"More\" }, { div: \"Body\" }], $: [details()] }\n */\nfunction details(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n duration?: number;\n } = {},\n): PartialElement {\n const { duration = 240 } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"details\") {\n console.warn(`\"details\" primitive patch must use details tag`);\n }\n },\n // Summary weight is design-system chrome for disclosure headers.\n _doctorDisable: \"inline-typography\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n\n overflow: \"hidden\",\n \"& > summary\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", color.get(listener)),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n listStyle: \"none\",\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n cursor: \"pointer\",\n userSelect: \"none\",\n fontWeight: 500,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n height: themeSpacing(10),\n },\n \"& > summary::-webkit-details-marker\": {\n display: \"none\",\n },\n \"& > summary::marker\": {\n content: `\"\"`,\n },\n \"& > summary::after\": {\n content: `\"\"`,\n width: themeSpacing(2),\n height: themeSpacing(2),\n flexShrink: 0,\n marginTop: themeSpacing(-0.5),\n borderInlineEnd: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-9\", color.get(listener))}`,\n borderBottom: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-9\", color.get(listener))}`,\n transform: \"rotate(45deg)\",\n transition: `transform ${duration}ms ease`,\n },\n \"&[open] > summary::after\": {\n transform: \"rotate(-135deg)\",\n },\n \"& > summary:hover\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", color.get(listener)),\n },\n \"& > summary:focus-visible\": {\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"& > :not(summary)\": {\n maxHeight: 0,\n opacity: 0,\n overflow: \"hidden\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingTop: 0,\n paddingBottom: 0,\n transition: `max-height ${duration}ms ease, opacity ${duration}ms ease, padding ${duration}ms ease`,\n },\n \"&[open] > :not(summary)\": {\n // Non-clipping open state: a bounded max-height here (previously\n // themeSpacing(250) ≈ 1000px) silently CUT OFF body content taller\n // than the cap while fully open. CSS cannot transition max-height\n // to/from `none`, so the open transition is carried by opacity +\n // padding (both still animate over `duration`); max-height jumps\n // straight to none and tall content is never clipped.\n maxHeight: \"none\",\n opacity: 1,\n paddingTop: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingBottom: (listener) => themeSpacing(themeDensity(listener) * 3),\n },\n },\n };\n}\n\nexport { details };\n","import {\n type BehaviorInstance,\n behavior,\n type ElementNode,\n type PartialElement,\n type ReadableState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { asOpenState, dismissOpen, subscribeOpen } from \"../utils/openState.js\";\nimport { lockScroll, unlockScroll } from \"../utils/scrollLock.js\";\n\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), details, [tabindex]:not([tabindex=\"-1\"])';\n\ntype DialogProps = {\n state: ReadableState<boolean>;\n // Lives on the behavior instance so a reused node gets the latest callback\n // via update() — do not close over factory-generation onDismiss.\n onDismiss?: () => void;\n};\n\ntype DialogInstance = BehaviorInstance<DialogProps> & {\n // Close via the instance's CURRENT state — routing through the behavior\n // guarantees the state being set is the one the open/close subscription\n // listens to, even when a re-rendered generation's closure would otherwise\n // set its own fresh (unsubscribed) default state.\n requestClose: () => void;\n onTransitionEnd: (e: Event) => void;\n};\n\n// All close-finalization state (closing flag, previousFocus, scrollLocked,\n// the fallback timer) lives in ONE behavior instance per dialog node. It used\n// to be factory-scope variables captured by _onMount — but _onMount runs once\n// for the FIRST generation only, while onTransitionEnd (live-rebound every\n// patch) belongs to the LATEST generation: gen-1's update() set gen-1's\n// `closing = true` and the live gen-N handler read gen-N's `closing` (false)\n// and early-returned, so every close fell back to the 350ms timer and focus\n// restore scrolled through stale closures. behavior() attaches once and\n// routes every later generation's props into the same instance (floating.ts\n// pattern).\nfunction attachDialog(\n node: ElementNode,\n initialProps: DialogProps,\n): DialogInstance {\n let { state, onDismiss } = initialProps;\n let previousFocus: HTMLElement | null = null;\n let closing = false;\n let scrollLocked = false;\n let closeTimer: ReturnType<typeof setTimeout> | null = null;\n\n const dlg = node.domElement as HTMLDialogElement;\n dlg.setAttribute(\"aria-modal\", \"true\");\n\n const finalizeClose = () => {\n closing = false;\n // Guard for environments with HTMLDialogElement but no close()\n // implementation (e.g. jsdom in tests).\n if (typeof dlg.close === \"function\") dlg.close();\n // visibility/pointer-events/display (not just opacity) must reflect the\n // closed state: opacity alone leaves a closed dialog's content fully\n // reachable by Tab and exposed to the accessibility tree (opacity, unlike\n // visibility, never removes an element from either) — and a consumer\n // that sets its own `style: { display: ... }` on the dialog (a common\n // pattern for centering content) overrides the UA stylesheet's\n // `dialog:not([open]) { display: none }`, so `dlg.close()` alone doesn't\n // reliably hide it either. visibility+pointer-events still leave the\n // node in the layout and in the document for password-managers / autofocus.\n // Set INLINE so it always wins regardless of what the consumer's own\n // style object declares. Do not put `display: none` on the patch CSS\n // class — native `style.display` would lose to that class on reopen.\n dlg.style.visibility = \"hidden\";\n dlg.style.pointerEvents = \"none\";\n dlg.style.display = \"none\";\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n previousFocus?.focus();\n previousFocus = null;\n };\n\n const trapFocus = (e: KeyboardEvent) => {\n if (e.key !== \"Tab\") return;\n const focusables = Array.from(\n dlg.querySelectorAll<HTMLElement>(FOCUSABLE),\n ).filter(\n (el) => !el.closest(\"[aria-hidden='true']\") && el.offsetParent !== null,\n );\n if (!focusables.length) {\n e.preventDefault();\n return;\n }\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n if (e.shiftKey) {\n if (document.activeElement === first || document.activeElement === dlg) {\n e.preventDefault();\n last.focus();\n }\n } else {\n if (document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n }\n };\n\n const onCancel = (e: Event) => {\n e.preventDefault();\n dismissOpen(state, onDismiss);\n };\n dlg.addEventListener(\"cancel\", onCancel);\n\n const update = (val: boolean) => {\n if (val) {\n // Cancel any in-flight close: a pending fallback timer or a true\n // `closing` flag left over from the previous close (e.g. reopening\n // within the 350ms window, or the mount-time close of an\n // initially-closed dialog) would otherwise finalize-close the\n // just-opened dialog on the open fade's own transitionend.\n closing = false;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n previousFocus = document.activeElement as HTMLElement;\n dlg.style.visibility = \"visible\";\n dlg.style.pointerEvents = \"auto\";\n // Drop the closed-state inline display so the consumer's own\n // `style.display` (or the UA open-dialog rule) can apply.\n dlg.style.display = \"\";\n // Guard for environments with HTMLDialogElement but no showModal()\n // implementation (e.g. jsdom in tests). Also guard against re-entering\n // on an already-open dialog — showModal() throws InvalidStateError in\n // real browsers when the dialog is already open.\n if (typeof dlg.showModal === \"function\" && !dlg.open) dlg.showModal();\n if (!scrollLocked) {\n lockScroll();\n scrollLocked = true;\n }\n dlg.addEventListener(\"keydown\", trapFocus);\n requestAnimationFrame(() => {\n dlg.style.opacity = \"1\";\n const focusable = dlg.querySelector<HTMLElement>(FOCUSABLE);\n focusable?.focus();\n });\n } else {\n closing = true;\n dlg.style.opacity = \"0\";\n dlg.removeEventListener(\"keydown\", trapFocus);\n // Mounted already-closed (never opened): no fade to play — hide now\n // so a consumer `display: flex` cannot keep the closed node in layout\n // for the 350ms timer (or forever, if transitionend also never fires).\n if (!dlg.open) {\n finalizeClose();\n return;\n }\n // Fallback: if transitionend never fires (reduced-motion, display:none),\n // unblock close after the transition duration + buffer.\n closeTimer = setTimeout(() => {\n closeTimer = null;\n if (!closing) return;\n finalizeClose();\n }, 350);\n }\n };\n let release = subscribeOpen(state, update);\n\n return {\n requestClose: () => dismissOpen(state, onDismiss),\n onTransitionEnd: (e: Event) => {\n if (!closing) return;\n // Guard against bubbled transitionend from nested content (e.g. an\n // accordion/details transition inside the dialog) prematurely\n // triggering close-finalization.\n if (e.target !== dlg) return;\n if ((e as TransitionEvent).propertyName !== \"opacity\") return;\n finalizeClose();\n },\n update(props) {\n onDismiss = props.onDismiss;\n // Re-subscribe when a later generation brings a genuinely different\n // state object (e.g. the default `toState(false)` allocated per\n // factory call); a caller-owned state arrives as the SAME object and\n // keeps its existing subscription untouched.\n if (props.state !== state) {\n release();\n state = props.state;\n release = subscribeOpen(state, update, false);\n }\n },\n destroy() {\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n release();\n dlg.removeEventListener(\"cancel\", onCancel);\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n dlg.removeEventListener(\"keydown\", trapFocus);\n previousFocus?.focus();\n previousFocus = null;\n },\n };\n}\n\n/**\n * Modal dialog patch driven by an `open` State. Calls `showModal()`/`close()`,\n * fades via opacity, locks page scroll while open, traps Tab focus within the\n * dialog, restores focus to the previously focused element on close, sets\n * `aria-modal`, and closes on outside (backdrop) click. Apply to a `<dialog>`.\n * Closed state is inline `visibility`/`pointer-events`/`display:none` so a\n * consumer `style.display` cannot keep the node in layout.\n *\n * Accessible name/description: pass `labelledBy`/`describedBy` the `id` of a\n * heading/paragraph inside the dialog (Radix Title/Description parity). The\n * native `ariaLabelledby`/`ariaDescribedby` attributes on the host element\n * remain an equivalent escape hatch (the native element always wins).\n *\n * @hostTag dialog\n * @param props.color - Theme color tone for the dialog surface. Defaults to \"neutral\".\n * @param props.open - Open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so Escape/backdrop can close. Defaults to false.\n * @param props.onDismiss - Called when Escape/backdrop/`requestClose` request close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.labelledBy - `id` of the element labeling the dialog (wired to `aria-labelledby`). Optional.\n * @param props.describedBy - `id` of the element describing the dialog (wired to `aria-describedby`). Optional.\n * @example { dialog: [{ h2: \"Confirm\", id: \"dlg-title\" }], $: [dialog({ open, labelledBy: \"dlg-title\" })] }\n */\nfunction dialog(\n props: {\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n labelledBy?: string;\n describedBy?: string;\n } = {},\n): PartialElement {\n const {\n color = \"neutral\",\n open = false,\n labelledBy,\n describedBy,\n onDismiss,\n } = props;\n const state = asOpenState(open);\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"dialog\") {\n console.warn(`\"dialog\" primitive patch must use dialog tag`);\n }\n },\n ...behavior<DialogProps>(\"dialog\", attachDialog, { state, onDismiss }),\n ariaLabelledby: labelledBy,\n ariaDescribedby: describedBy,\n onClick: (e: MouseEvent, node) => {\n if (e.target !== node.domElement) return;\n const r = node.domElement!.getBoundingClientRect();\n const inside =\n e.clientX >= r.left &&\n e.clientX <= r.right &&\n e.clientY >= r.top &&\n e.clientY <= r.bottom;\n if (!inside) node.getBehavior<DialogInstance>(\"dialog\")?.requestClose();\n },\n onTransitionEnd: (e, node) =>\n node.getBehavior<DialogInstance>(\"dialog\")?.onTransitionEnd(e),\n style: {\n opacity: \"0\",\n // Matches finalizeClose's inline defaults — a dialog that mounts\n // already-closed (the common case: `open` defaults to false) must\n // start out of the tab order/accessibility tree from first paint, not\n // just after its first open->close cycle runs finalizeClose.\n visibility: \"hidden\",\n pointerEvents: \"none\",\n transition: \"opacity 200ms ease\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"shift-10\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n border: \"none\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n padding: (listener) => themeSpacing(themeDensity(listener) * 3),\n boxShadow: elevation(\"high\"),\n \"&::backdrop\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n opacity: 0.75,\n },\n },\n };\n}\n\nexport { dialog };\n","// Shared page-scroll lock for modal-like patches (dialog, drawer). A\n// module-level counter (not a plain boolean) is required because two\n// overlays can be open at once (e.g. a dialog opened from within a drawer);\n// without a counter, closing the inner one would clear `overflow` while the\n// outer one is still open.\nlet lockCount = 0;\n\nfunction lockScroll(): void {\n lockCount++;\n if (lockCount === 1) document.body.style.overflow = \"hidden\";\n}\n\nfunction unlockScroll(): void {\n lockCount = Math.max(0, lockCount - 1);\n if (lockCount === 0) document.body.style.overflow = \"\";\n}\n\n// Test-only: reset the module-level counter so a test that unmounts its tree\n// via `document.body.innerHTML = \"\"` (skipping the Remove hook / unlockScroll\n// call) doesn't leak a locked count into the next test.\nfunction _resetScrollLock(): void {\n lockCount = 0;\n}\n\nexport { lockScroll, unlockScroll, _resetScrollLock };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A horizontal separator (`role=\"separator\"`) with a line on each side of its\n * content, suitable for labelled dividers (\"or\"). Apply to a `<div>` element.\n *\n * @hostTag div\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the label text and rules. Defaults to \"neutral\".\n * @example { div: \"or\", $: [divider()] }\n */\nfunction divider(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n role: \"separator\",\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"divider\" patch should be used with <div>`);\n }\n },\n style: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"baseline\",\n gap: themeSpacing(2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n minHeight: \"1lh\",\n \"&::before\": {\n content: `\"\"`,\n flex: 1,\n borderColor: (listener) =>\n themeColor(listener, \"border-strong\", color.get(listener)),\n borderWidth: \"1px\",\n borderBottomStyle: \"solid\",\n },\n \"&::after\": {\n content: `\"\"`,\n flex: 1,\n borderColor: (listener) =>\n themeColor(listener, \"border-strong\", color.get(listener)),\n borderWidth: \"1px\",\n borderBottomStyle: \"solid\",\n },\n },\n };\n}\n\nexport { divider };\n","import {\n type BehaviorInstance,\n behavior,\n type ElementNode,\n type PartialElement,\n type ReadableState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { asOpenState, dismissOpen, subscribeOpen } from \"../utils/openState.js\";\nimport { lockScroll, unlockScroll } from \"../utils/scrollLock.js\";\n\ntype PhysicalPlacement = \"left\" | \"right\" | \"top\" | \"bottom\";\ntype Placement = PhysicalPlacement | \"start\" | \"end\";\n\nconst translateOut: Record<PhysicalPlacement, string> = {\n left: \"translateX(-100%)\",\n right: \"translateX(100%)\",\n top: \"translateY(-100%)\",\n bottom: \"translateY(100%)\",\n};\n\nconst marginMap: Record<PhysicalPlacement, string> = {\n left: \"0 auto 0 0\",\n right: \"0 0 0 auto\",\n top: \"0 0 auto 0\",\n bottom: \"auto 0 0 0\",\n};\n\nconst isVertical = (p: PhysicalPlacement) => p === \"left\" || p === \"right\";\n\nfunction resolvePhysical(\n placement: Placement,\n isRTL: boolean,\n): PhysicalPlacement {\n if (placement === \"start\") return isRTL ? \"right\" : \"left\";\n if (placement === \"end\") return isRTL ? \"left\" : \"right\";\n return placement;\n}\n\ntype DrawerProps = {\n state: ReadableState<boolean>;\n // Lives on the behavior instance so a reused node gets the latest callback\n // via update() — do not close over factory-generation onDismiss.\n onDismiss?: () => void;\n placement: Placement;\n size?: string;\n};\n\ntype DrawerInstance = BehaviorInstance<DrawerProps> & {\n requestClose: () => void;\n};\n\nfunction attachDrawer(\n node: ElementNode,\n initialProps: DrawerProps,\n): DrawerInstance {\n let { state, onDismiss, placement, size } = initialProps;\n\n const dlg = node.domElement as HTMLDialogElement;\n dlg.setAttribute(\"aria-modal\", \"true\");\n\n const onCancel = (e: Event) => {\n e.preventDefault();\n dismissOpen(state, onDismiss);\n };\n dlg.addEventListener(\"cancel\", onCancel);\n\n const resolve = (nextPlacement: Placement, nextSize?: string) => {\n const isLogical = nextPlacement === \"start\" || nextPlacement === \"end\";\n const isRTL =\n isLogical &&\n (dlg.ownerDocument.documentElement.dir === \"rtl\" ||\n dlg.ownerDocument.dir === \"rtl\");\n const physical = resolvePhysical(nextPlacement, isRTL);\n const drawerSize =\n nextSize ?? (isVertical(physical) ? themeSpacing(80) : themeSpacing(64));\n dlg.style.margin = marginMap[physical];\n dlg.style.width = isVertical(physical) ? drawerSize : \"100dvw\";\n dlg.style.height = isVertical(physical) ? \"100dvh\" : drawerSize;\n return physical;\n };\n\n let physical = resolve(placement, size);\n\n let closing = false;\n let scrollLocked = false;\n let closeTimer: ReturnType<typeof setTimeout> | null = null;\n\n const finishClose = () => {\n closeTimer = null;\n if (!closing) return;\n closing = false;\n // Guard for environments with HTMLDialogElement but no close()\n // implementation (e.g. jsdom in tests).\n if (typeof dlg.close === \"function\") dlg.close();\n // Same fix as dialog.ts: the closed state was only ever represented\n // by an off-screen `transform`, never visibility/pointer-events/display\n // — a closed drawer stayed fully reachable by Tab and exposed to the\n // accessibility tree (a CSS transform, like opacity, does neither),\n // and a consumer's own `style: { display: ... }` overrides the UA\n // stylesheet's `dialog:not([open])` rule anyway. Set INLINE so it\n // always wins. Do not put `display: none` on the patch CSS class —\n // native `style.display` would lose to that class on reopen.\n dlg.style.visibility = \"hidden\";\n dlg.style.pointerEvents = \"none\";\n dlg.style.display = \"none\";\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n };\n\n const onTransitionEnd = (e: Event) => {\n if (e.target !== dlg) return;\n if ((e as TransitionEvent).propertyName !== \"transform\") return;\n finishClose();\n };\n dlg.addEventListener(\"transitionend\", onTransitionEnd);\n\n const update = (val: boolean) => {\n if (val) {\n // Cancel any in-flight close: a pending fallback timer or a leftover\n // `closing` flag would otherwise finalize-close the just-opened drawer\n // when the open slide's own transitionend (or the 350ms timer) fires.\n closing = false;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n dlg.style.visibility = \"visible\";\n dlg.style.pointerEvents = \"auto\";\n dlg.style.display = \"\";\n // Guard for environments with HTMLDialogElement but no showModal()\n // implementation (e.g. jsdom in tests). Also guard against re-entering\n // on an already-open dialog — showModal() throws InvalidStateError in\n // real browsers when the dialog is already open.\n if (typeof dlg.showModal === \"function\" && !dlg.open) dlg.showModal();\n if (!scrollLocked) {\n lockScroll();\n scrollLocked = true;\n }\n requestAnimationFrame(() => {\n dlg.style.transform = \"translate(0, 0)\";\n });\n } else {\n closing = true;\n dlg.style.transform = translateOut[physical];\n if (!dlg.open) {\n finishClose();\n return;\n }\n closeTimer = setTimeout(finishClose, 350);\n }\n };\n let release = subscribeOpen(state, update);\n\n return {\n requestClose: () => dismissOpen(state, onDismiss),\n update(props) {\n onDismiss = props.onDismiss;\n if (props.state !== state) {\n release();\n state = props.state;\n release = subscribeOpen(state, update, false);\n }\n if (props.placement !== placement || props.size !== size) {\n placement = props.placement;\n size = props.size;\n physical = resolve(placement, size);\n if (!state.get()) dlg.style.transform = translateOut[physical];\n }\n },\n destroy() {\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n release();\n dlg.removeEventListener(\"cancel\", onCancel);\n dlg.removeEventListener(\"transitionend\", onTransitionEnd);\n if (scrollLocked) {\n unlockScroll();\n scrollLocked = false;\n }\n },\n };\n}\n\n/**\n * Edge-anchored modal drawer driven by an `open` State. Slides in/out from a\n * chosen edge via a 250 ms transform transition, calls `showModal()`/`close()`,\n * locks page scroll while open, and closes on backdrop click. A 350 ms fallback\n * ensures `close()` is always called even when `transitionend` doesn't fire\n * (reduced-motion, `display:none`, detached element). Apply to a `<dialog>`.\n *\n * Because the patch uses the native `<dialog>` `showModal()` API, the browser\n * traps focus inside the drawer while it is open and restores focus to the\n * previously focused element when `close()` is called. Sets `aria-modal=\"true\"`.\n * Escape key closes the drawer via the animated state path (not immediate close).\n *\n * `\"start\"` and `\"end\"` placements resolve to left/right based on the\n * document's `dir` attribute at mount time, enabling RTL-aware drawers:\n * `\"start\"` → left (LTR) / right (RTL); `\"end\"` → right (LTR) / left (RTL).\n *\n * @hostTag dialog\n * @param props.color - Theme color tone for the drawer surface. Defaults to \"neutral\".\n * @param props.open - Open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so Escape/backdrop can close. Defaults to false.\n * @param props.onDismiss - Called when Escape/backdrop/`requestClose` request close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.placement - Edge to anchor to. \"left\" | \"right\" | \"top\" | \"bottom\" | \"start\" | \"end\". Defaults to \"end\".\n * @param props.size - CSS length for the drawer's width (left/right/start/end) or height (top/bottom). Defaults to themeSpacing(80) for left/right, themeSpacing(64) for top/bottom.\n * @example { dialog: [...], $: [drawer({ open, placement: \"start\" })] }\n */\nfunction drawer(\n props: {\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement?: Placement;\n size?: string;\n } = {},\n): PartialElement {\n const {\n color = \"neutral\",\n open = false,\n onDismiss,\n placement = \"end\",\n size,\n } = props;\n const state = asOpenState(open);\n\n // For static rendering / SSR assume LTR as fallback; corrected at mount time.\n const physicalFallback = resolvePhysical(placement, false);\n const defaultSize = isVertical(physicalFallback)\n ? themeSpacing(80)\n : themeSpacing(64);\n const drawerSize = size ?? defaultSize;\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"dialog\") {\n console.warn(`\"drawer\" patch must use dialog tag`);\n }\n },\n ...behavior<DrawerProps>(\"drawer\", attachDrawer, {\n state,\n onDismiss,\n placement,\n size,\n }),\n onClick: (e: MouseEvent, node) => {\n if (e.target !== node.domElement) return;\n const r = node.domElement!.getBoundingClientRect();\n const inside =\n e.clientX >= r.left &&\n e.clientX <= r.right &&\n e.clientY >= r.top &&\n e.clientY <= r.bottom;\n if (!inside) node.getBehavior<DrawerInstance>(\"drawer\")?.requestClose();\n },\n style: {\n transform: translateOut[physicalFallback],\n // Matches finishClose's inline defaults — a drawer that mounts\n // already-closed (the common case) must start out of the tab\n // order/accessibility tree from first paint, not just after its first\n // open->close cycle runs finishClose.\n visibility: \"hidden\",\n pointerEvents: \"none\",\n transition: \"transform 0.25s ease\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"shift-10\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n border: \"none\",\n padding: (listener) => themeSpacing(themeDensity(listener) * 3),\n margin: marginMap[physicalFallback],\n width: isVertical(physicalFallback) ? drawerSize : \"100dvw\",\n height: isVertical(physicalFallback) ? \"100dvh\" : drawerSize,\n maxWidth: \"100dvw\",\n maxHeight: \"100dvh\",\n boxShadow: elevation(\"high\"),\n \"&::backdrop\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n opacity: 0.75,\n },\n },\n };\n}\n\nexport { drawer };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Italic emphasized inline text. Apply to an `<em>` element.\n *\n * @hostTag em\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the text. Defaults to \"neutral\".\n * @example { em: \"important\", $: [emphasis()] }\n */\nfunction emphasis(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"em\") {\n console.warn(`\"emphasis\" primitive patch must use em tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontStyle: \"italic\",\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n };\n}\n\nexport { emphasis };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Styles a container as an empty-state placeholder: centered flex column with\n * muted coloring and comfortable padding. Provide the icon, title, and\n * description as child elements.\n *\n * @param props.color - Theme color tone for the muted text/icon. Defaults to `\"neutral\"`.\n * @example\n * { div: [\n * { span: \"📭\" },\n * { p: \"No items yet\", $: [paragraph()] },\n * { span: \"Add your first item to get started\", $: [small()] },\n * ], $: [empty()] }\n */\nfunction empty(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: themeSpacing(3),\n paddingBlock: themeSpacing(12),\n paddingInline: themeSpacing(6),\n textAlign: \"center\",\n // Body / description text sits in the muted zone.\n color: (listener) => themeColor(listener, \"muted\", color.get(listener)),\n // Icon area: slightly softer so it recedes behind the title.\n \"& > :first-child\": {\n color: (listener) =>\n themeColor(listener, \"shift-5\", color.get(listener)),\n opacity: 0.9,\n },\n // Title (typically second child): stronger body text for hierarchy.\n \"& > :nth-child(2)\": {\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n },\n };\n}\n\nexport { empty };\n","import type { DomphyElement, ElementNode, PartialElement } from \"@domphy/core\";\n\nconst ORIGINAL_CHILDREN = \"errorBoundaryOriginal\";\n\nfunction restoreOriginalChildren(node: ElementNode): void {\n const original = node.getMetadata(ORIGINAL_CHILDREN);\n if (typeof original === \"function\") {\n node._childrenRelease?.();\n node._setupFunctionChildren(original);\n return;\n }\n if (original != null) {\n node.children.update(Array.isArray(original) ? original : [original]);\n return;\n }\n node.children.update([]);\n}\n\n/**\n * Catches errors thrown inside reactive child expressions and renders a\n * fallback element instead of crashing the whole tree. Apply to any container.\n *\n * Only errors in *reactive* children (functions returning element arrays) are\n * caught. Errors during static construction propagate normally — those are\n * programming errors, not runtime data errors.\n *\n * `reset()` restores the original children (including a reactive children\n * function) so the next evaluation runs again — it does not leave the host\n * empty.\n *\n * @hostTag any\n * @param props.fallback - Fallback element or factory `(error, reset) => element`. Defaults to a plain error message div.\n * @param props.onError - Optional callback for logging/telemetry.\n * @example { div: (l) => renderUserContent(l), $: [errorBoundary({ fallback: { p: \"Something went wrong.\" } })] }\n */\nfunction errorBoundary(\n props: {\n fallback?:\n | DomphyElement\n | ((error: unknown, reset: () => void) => DomphyElement);\n onError?: (error: unknown) => void;\n } = {},\n): PartialElement {\n return {\n _onSchedule: (node, element) => {\n if (node.getMetadata(ORIGINAL_CHILDREN) !== undefined) return;\n node.setMetadata(\n ORIGINAL_CHILDREN,\n (element as Record<string, unknown>)[node.tagName],\n );\n },\n _onError: (node, error) => {\n props.onError?.(error);\n const reset = () => restoreOriginalChildren(node);\n const fallbackEl =\n typeof props.fallback === \"function\"\n ? props.fallback(error, reset)\n : (props.fallback ??\n ({ div: \"An error occurred.\" } as DomphyElement));\n node.children.update([fallbackEl]);\n },\n };\n}\n\nexport { errorBoundary };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst SIZE_MAP = { small: 8, medium: 10, large: 14 } as const;\n\n/**\n * Floating Action Button — a circular elevated button typically used for the\n * primary action on a screen. Apply to a `<button>` element.\n *\n * @hostTag button\n * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, defaults to `\"primary\"`.\n * @param props.size - Button size preset. Optional `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { button: \"+\", $: [fab()] }\n * @example { button: \"+\", $: [fab({ size: \"small\", color: \"neutral\" })] }\n */\nfunction fab(\n props: {\n color?: ValueOrState<ThemeColor>;\n size?: \"small\" | \"medium\" | \"large\";\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n const dim = themeSpacing(SIZE_MAP[props.size ?? \"medium\"]);\n\n return {\n // Native `type` on the host still wins (mergePartial: native over patch).\n type: \"button\",\n _onInsert: (node) => {\n if (node.tagName !== \"button\") {\n console.warn('\"fab\" patch must use button tag');\n }\n },\n // Deep brand disc (shift-13) + light icon — mid-ramp shift-8 failed WCAG\n // (~2.2:1). tone-background-inherit wants inherit+dataTone; explicit fill\n // silences it the same way as button solid.\n _doctorDisable: [\n \"low-contrast\",\n \"color-shift-minimum\",\n \"tone-background-inherit\",\n ],\n style: {\n appearance: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n flexShrink: 0,\n width: dim,\n height: dim,\n borderRadius: \"50%\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-13\", color.get(listener)),\n color: (listener) => themeColor(listener, \"shift-0\", \"neutral\"),\n boxShadow: elevation(\"low\"),\n transition: \"background-color 200ms ease, box-shadow 200ms ease\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-14\", color.get(listener)),\n boxShadow: elevation(\"medium\"),\n },\n \"&:active:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-15\", color.get(listener)),\n boxShadow: elevation(\"low\"),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) =>\n `${elevation(\"medium\")}, ${focusRing(listener, color.get(listener))}`,\n },\n \"&[disabled]\": { opacity: 0.5, cursor: \"not-allowed\" },\n },\n };\n}\n\nexport { fab };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Lays out a figure as a column with block-level media (img/svg/video/canvas)\n * and a themed `<figcaption>`. Apply to a `<figure>` element.\n *\n * @hostTag figure\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the figure/caption text. Defaults to \"neutral\".\n * @example { figure: [{ img: \"\", src }, { figcaption: \"A caption\" }], $: [figure()] }\n */\nfunction figure(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"figure\") {\n console.warn(`\"figure\" primitive patch must use figure tag`);\n }\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: themeSpacing(2),\n marginInline: 0,\n marginTop: themeSpacing(3),\n marginBottom: themeSpacing(3),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"& img, & svg, & video, & canvas\": {\n display: \"block\",\n maxWidth: \"100%\",\n borderRadius: themeSpacing(2),\n },\n \"& figcaption\": {\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n color: (listener) => themeColor(listener, \"muted\", color.get(listener)),\n lineHeight: 1.45,\n },\n },\n };\n}\n\nexport { figure };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Layout patch for a group of form fields. Arranges a `<legend>`, `<label>`s,\n * controls, and helper `<p>`s in a grid — labels beside controls (horizontal)\n * or stacked above them (vertical). Apply to a `<fieldset>` element.\n *\n * @hostTag fieldset\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for legend/text/surface. Defaults to \"neutral\".\n * @param props.layout - Field arrangement, \"horizontal\" (label beside control) | \"vertical\" (label above). Defaults to \"horizontal\".\n * @example { fieldset: [{ legend: \"Profile\" }, { label: \"Name\" }, { input: \"\" }], $: [formGroup({ layout: \"vertical\" })] }\n */\nfunction formGroup(\n props: {\n color?: ValueOrState<ThemeColor>;\n layout?: \"horizontal\" | \"vertical\";\n } = {},\n): PartialElement {\n const { layout = \"horizontal\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n const isVertical = layout === \"vertical\";\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"fieldset\") {\n console.warn(`\"formGroup\" patch must use fieldset tag`);\n }\n },\n // Legend weight is design-system chrome for field groups.\n _doctorDisable: \"inline-typography\",\n style: {\n margin: 0,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 3),\n border: \"none\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n display: \"grid\",\n gridTemplateColumns: isVertical\n ? `minmax(0, 1fr)`\n : `max-content minmax(0, 1fr)`,\n columnGap: themeSpacing(4),\n rowGap: themeSpacing(3),\n alignItems: \"start\",\n \"& > legend\": {\n gridColumn: \"1 / -1\",\n margin: 0,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontWeight: 600,\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n },\n \"& > label\": {\n gridColumn: \"1\",\n alignSelf: \"start\",\n margin: 0,\n paddingBlock: (listener) =>\n isVertical ? 0 : themeSpacing(themeDensity(listener) * 1),\n },\n \"& > label:has(+ :not(legend, label, p) + p)\": {\n gridRow: isVertical ? \"auto\" : \"span 2\",\n },\n \"& > :not(legend, label, p)\": {\n gridColumn: isVertical ? \"1\" : \"2\",\n minWidth: 0,\n width: \"100%\",\n boxSizing: \"border-box\",\n },\n \"& > p\": {\n gridColumn: isVertical ? \"1\" : \"2\",\n minWidth: 0,\n margin: 0,\n marginBlockStart: `calc(${themeSpacing(2)} * -1)`,\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n },\n };\n}\n\nexport { formGroup };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeDensity, themeSpacing } from \"@domphy/theme\";\nimport type { FlexAlign } from \"./stack.js\";\n\n/**\n * A CSS grid with a column template and spacing between cells — the\n * general-purpose primitive for card/property/stat grids instead of\n * hand-rolling `display: \"grid\"; gridTemplateColumns: ...; gap: ...`.\n * Mirrors `row()`'s contract. Styles the host only; apply to any block\n * element.\n *\n * @param props.columns - Column count (expanded to `repeat(N, minmax(0, 1fr))`)\n * or a raw `grid-template-columns` value. Defaults to `1`.\n * @param props.gap - Spacing multiplier for gap between cells (default 4 = 1em at density 1).\n * @param props.align - Block-axis alignment of items (`alignItems`). Unset by default.\n * @example { div: [{ div: \"A\" }, { div: \"B\" }], $: [grid({ columns: 2 })] }\n * @example { div: [...], $: [grid({ columns: \"repeat(auto-fill, minmax(12em, 1fr))\", gap: 6 })] }\n */\nfunction grid(\n props: { columns?: number | string; gap?: number; align?: FlexAlign } = {},\n): PartialElement {\n const { columns = 1, gap = 4, align } = props;\n return {\n style: {\n display: \"grid\",\n gridTemplateColumns:\n typeof columns === \"number\"\n ? `repeat(${columns}, minmax(0, 1fr))`\n : columns,\n gap: (listener) => themeSpacing(themeDensity(listener) * gap),\n ...(align ? { alignItems: align } : {}),\n },\n };\n}\n\nexport { grid };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ElementSize,\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\nconst HeadingShift: Record<string, ElementSize> = {\n h6: \"decrease-1\",\n h5: \"inherit\",\n h4: \"increase-1\",\n h3: \"increase-2\",\n h2: \"increase-3\",\n h1: \"increase-4\",\n};\n\n/**\n * Styles a heading, scaling its font size by level (h1 largest … h6 smallest)\n * relative to the theme base size. Apply to a heading element `<h1>`–`<h6>`.\n *\n * @hostTag h1\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the heading text. Defaults to \"neutral\".\n * @param props.size - Optional `ElementSize` (`\"inherit\"` | `\"increase-N\"` | `\"decrease-N\"`, N ≤ 7). When set, font size is `themeSize(listener, size)` including `\"inherit\"` (no tag bump). When omitted, follows the host tag (`h1` increase-4 … `h6` decrease-1).\n * @example { h2: \"Section title\", $: [heading()] }\n * @example { h3: \"Panel title\", $: [heading({ size: \"inherit\" })] }\n */\nfunction heading(\n props: { color?: ValueOrState<ThemeColor>; size?: ElementSize } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const size = props.size;\n\n return {\n _onInsert: (node) => {\n if (![\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"].includes(node.tagName)) {\n console.warn(\n `\"heading\" primitive patch must use heading tags [h1...h6]`,\n );\n }\n },\n style: {\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n marginTop: 0,\n marginBottom: themeSpacing(2),\n fontSize: (listener) => {\n if (size !== undefined) {\n return themeSize(listener, size);\n }\n const offset = HeadingShift[listener.elementNode.tagName] || \"inherit\";\n return themeSize(listener, offset);\n },\n },\n };\n}\n\nexport { heading };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * A thematic break rendered as a thin 1px themed line with vertical margin.\n * Apply to an `<hr>` element.\n *\n * @hostTag hr\n * @param props.color - Theme color tone (`ValueOrState<ThemeColor>`) for the rule. Defaults to \"neutral\".\n * @example { hr: \"\", $: [horizontalRule()] }\n */\nfunction horizontalRule(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"hr\") {\n console.warn(`\"horizontalRule\" primitive patch must use hr tag`);\n }\n },\n // Soft rule surface — edge anchor (shift-3 = border) + inherit paint.\n dataTone: \"shift-3\",\n style: {\n border: 0,\n height: \"1px\",\n marginInline: 0,\n marginTop: themeSpacing(3),\n marginBottom: themeSpacing(3),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { horizontalRule };\n","import type { PartialElement } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles an inline icon container: square box that centers its content and\n * applies the themed icon color. Apply to a `<span>` element.\n *\n * @hostTag span\n * @param props.color - Optional theme color tone for the icon (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @example { span: null, $: [icon()] }\n */\nfunction icon(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"span\") {\n console.warn(`\"icon\" primitive patch should use span tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n alignSelf: \"center\",\n justifySelf: \"center\",\n verticalAlign: \"middle\",\n width: themeSpacing(4),\n height: themeSpacing(4),\n flexShrink: \"0\",\n fontSize: (listener) => themeSize(listener),\n backgroundColor: \"transparent\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { icon };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Styles a responsive image: full-width, cover-fit, rounded corners with a\n * themed placeholder background. Apply to an `<img>` element.\n *\n * @hostTag img\n * @param props.color - Optional theme color tone for the placeholder background (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @example { img: null, src: \"photo.jpg\", alt: \"Photo\", $: [image()] }\n */\nfunction image(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n _onInsert: (node) => {\n if (node.tagName !== \"img\") {\n console.warn(`\"image\" primitive patch must use img tag`);\n }\n },\n style: {\n display: \"block\",\n width: \"100%\",\n maxWidth: \"100%\",\n height: \"auto\",\n objectFit: \"cover\",\n borderRadius: themeSpacing(2),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { image };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a custom checkbox with themed box, check mark, indeterminate state,\n * hover, focus and disabled styling. Apply to an `<input>` element of\n * type `checkbox` (the patch sets `type: \"checkbox\"`).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for the box/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the checked/indeterminate fill and focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"checkbox\", $: [inputCheckbox()] }\n */\nfunction inputCheckbox(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n type: \"checkbox\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputCheckbox\" primitive patch must use input tag`);\n }\n },\n style: {\n appearance: \"none\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n display: \"inline-flex\",\n position: \"relative\",\n width: themeSpacing(6),\n height: themeSpacing(6),\n justifyContent: \"center\",\n alignItems: \"center\",\n transition: \"background-color 300ms, outline-color 300ms\",\n margin: 0,\n padding: 0,\n \"&::before\": {\n content: `\"\"`,\n display: \"block\",\n borderRadius: themeSpacing(1),\n lineHeight: 1,\n cursor: \"pointer\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n width: themeSpacing(4),\n height: themeSpacing(4),\n },\n \"&:hover::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:checked::before\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-6\", accentColor.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-8\", accentColor.get(listener)),\n },\n \"&:checked:hover:not([disabled])::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-7\", accentColor.get(listener)),\n },\n \"&:checked::after\": {\n content: `\"\"`,\n display: \"block\",\n position: \"absolute\",\n top: \"25%\",\n insetInlineStart: \"37%\",\n width: \"20%\",\n height: \"30%\",\n border: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"inherit\", accentColor.get(listener))}`,\n borderTop: 0,\n borderInlineStart: 0,\n transform: \"rotate(45deg)\",\n },\n \"&:indeterminate::before\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-6\", accentColor.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", accentColor.get(listener)),\n },\n \"&:indeterminate::after\": {\n content: `\"\"`,\n position: \"absolute\",\n inset: \"30%\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-8\", accentColor.get(listener)),\n },\n \"&:indeterminate:hover:not([disabled])::after\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-7\", accentColor.get(listener)),\n },\n \"&:focus-visible\": {\n borderRadius: themeSpacing(1.5),\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n cursor: \"not-allowed\",\n },\n \"&[disabled]::before, &[disabled]::after\": {\n outline: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-4\", \"neutral\"),\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { inputCheckbox };\n","import type { PartialElement, ValueOrState } from \"@domphy/core\";\nimport { toState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native color picker swatch with themed padding, rounded swatch and\n * disabled styling. Apply to an `<input>` element of type `color` (the patch\n * default is `type: \"color\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone used for the disabled state (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"color\", $: [inputColor()] }\n */\nfunction inputColor(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"color\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputColor\" primitive patch must use input tag`);\n }\n },\n style: {\n appearance: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 1),\n blockSize: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n inlineSize: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n backgroundColor: \"transparent\",\n transition: \"box-shadow 140ms ease\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&::-webkit-color-swatch-wrapper\": {\n margin: 0,\n padding: 0,\n },\n \"&::-webkit-color-swatch\": {\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n },\n },\n };\n}\n\nexport { inputColor };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\ntype InputDateTimeMode = \"date\" | \"time\" | \"week\" | \"month\" | \"datetime-local\";\n\n/**\n * Styles a native date/time input with themed border, padding, hover, focus,\n * invalid and disabled states. The `mode` selects the input `type`. Apply to\n * an `<input>` element (the patch default `type` is the chosen `mode`; a native `type` wins).\n *\n * @hostTag input\n * @param props.mode - Input mode selecting the host `type`: `\"date\" | \"time\" | \"week\" | \"month\" | \"datetime-local\"`. Defaults to `\"datetime-local\"`.\n * @param props.color - Optional theme color tone for text/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"datetime-local\", $: [inputDateTime()] }\n */\nfunction inputDateTime(\n props: {\n mode?: InputDateTimeMode;\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { mode = \"datetime-local\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: mode,\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputDateTime\" primitive patch must use input tag`);\n }\n },\n style: {\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::-webkit-calendar-picker-indicator\": {\n cursor: \"pointer\",\n opacity: 0.85,\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n },\n \"&:invalid\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"error\")}`,\n },\n },\n };\n}\n\nexport { inputDateTime };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native file input with a themed upload button, border, hover, focus\n * and disabled states. Apply to an `<input>` element of type `file` (the patch\n * default is `type: \"file\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for text/border and the upload button (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"file\", $: [inputFile()] }\n */\nfunction inputFile(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"file\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputFile\" primitive patch must use input tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 1),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::-webkit-file-upload-button\": {\n marginTop: (listener) => themeSpacing(themeDensity(listener)),\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n border: \"none\",\n borderRadius: themeSpacing(1),\n height: themeSpacing(6),\n paddingInline: themeSpacing(2),\n cursor: \"pointer\",\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"surface\", color.get(listener)),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.8,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"surface\", \"neutral\"),\n },\n \"&[disabled]::-webkit-file-upload-button\": {\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", \"neutral\"),\n },\n },\n };\n}\n\nexport { inputFile };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native number input with themed border, padding, visible spin\n * buttons, hover, focus and disabled states. Apply to an `<input>` element of\n * type `number` (the patch default is `type: \"number\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for text/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"number\", $: [inputNumber()] }\n */\nfunction inputNumber(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"number\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputNumber\" primitive patch must use input tag`);\n }\n },\n style: {\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n minWidth: themeSpacing(10),\n paddingInlineStart: (listener) =>\n themeSpacing(themeDensity(listener) * 3),\n paddingInlineEnd: (listener) =>\n themeSpacing(themeDensity(listener) * 1.5),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::-webkit-inner-spin-button, &::-webkit-outer-spin-button\": {\n opacity: 1,\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { inputNumber };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeSpacing } from \"@domphy/theme\";\n\n/**\n * Lays out a one-time-password container as a horizontal row of inputs and\n * wires keyboard navigation: auto-advance on input, backspace/arrow movement,\n * and paste distribution across the child inputs. Apply to a container element\n * (e.g. `<div>`) whose direct children are the OTP `<input>` boxes. Takes no\n * props.\n *\n * @example { div: null, $: [inputOTP()], children: [{ input: null }, { input: null }] }\n */\nfunction inputOTP(): PartialElement {\n return {\n // Group naming so aria-label on the host is valid (not a bare div).\n role: \"group\",\n ariaLabel: \"One-time password\",\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n \"& > *\": {\n minWidth: `${themeSpacing(9)}!important`,\n },\n },\n _onMount: (node) => {\n const container = node.domElement as HTMLElement;\n const getInputs = () =>\n Array.from(container.querySelectorAll(\"input\")) as HTMLInputElement[];\n\n const onInput = (e: Event) => {\n const inputs = getInputs();\n const target = e.target as HTMLInputElement;\n const idx = inputs.indexOf(target);\n if (target.value && idx < inputs.length - 1) {\n inputs[idx + 1].focus();\n }\n };\n\n const onKeydown = (e: KeyboardEvent) => {\n const inputs = getInputs();\n const target = e.target as HTMLInputElement;\n const idx = inputs.indexOf(target);\n if (e.key === \"Backspace\" && !target.value && idx > 0) {\n inputs[idx - 1].focus();\n }\n if (e.key === \"ArrowLeft\" && idx > 0) inputs[idx - 1].focus();\n if (e.key === \"ArrowRight\" && idx < inputs.length - 1)\n inputs[idx + 1].focus();\n };\n\n const onPaste = (e: ClipboardEvent) => {\n e.preventDefault();\n const text = e.clipboardData?.getData(\"text\") ?? \"\";\n const inputs = getInputs();\n const found = inputs.indexOf(e.target as HTMLInputElement);\n const startIdx = found === -1 ? 0 : found;\n [...text].forEach((char, i) => {\n const field = inputs[startIdx + i];\n if (!field) return;\n field.value = char;\n field.dispatchEvent(new Event(\"input\", { bubbles: true }));\n field.dispatchEvent(new Event(\"change\", { bubbles: true }));\n });\n const lastFilled = Math.min(\n startIdx + text.length - 1,\n inputs.length - 1,\n );\n inputs[lastFilled]?.focus();\n };\n\n container.addEventListener(\"input\", onInput);\n container.addEventListener(\"keydown\", onKeydown as EventListener);\n container.addEventListener(\"paste\", onPaste as EventListener);\n\n node.addHook(\"Remove\", () => {\n container.removeEventListener(\"input\", onInput);\n container.removeEventListener(\"keydown\", onKeydown as EventListener);\n container.removeEventListener(\"paste\", onPaste as EventListener);\n });\n },\n };\n}\n\nexport { inputOTP };\n","import type {\n DomphyElement,\n Listener,\n PartialElement,\n StyleObject,\n} from \"@domphy/core\";\nimport { isState, rawHtml, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n// Tabler Icons (MIT) — eye and eye-off outlines.\nconst EYE_SVG =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" ` +\n `stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" ` +\n `width=\"1em\" height=\"1em\">` +\n `<path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>` +\n `<path d=\"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0\"/>` +\n `<path d=\"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6\"/>` +\n `</svg>`;\n\nconst EYE_OFF_SVG =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" ` +\n `stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" ` +\n `width=\"1em\" height=\"1em\">` +\n `<path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>` +\n `<path d=\"M10.585 10.587a2 2 0 0 0 2.829 2.828\"/>` +\n `<path d=\"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6` +\n `c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18` +\n `c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87\"/>` +\n `<path d=\"M3 3l18 18\"/>` +\n `</svg>`;\n\nconst HOST_FIELD_KEYS = [\n \"name\",\n \"value\",\n \"onInput\",\n \"disabled\",\n \"required\",\n] as const;\n\ntype HostFieldKey = (typeof HOST_FIELD_KEYS)[number];\n\ntype HostFields = {\n name?: string;\n value?: unknown;\n onInput?: (event: Event) => void;\n disabled?: unknown;\n required?: boolean;\n};\n\nfunction bindReadable<T>(\n value: T | ValueOrState<T> | ((listener: Listener) => T) | undefined,\n): T | ((listener: Listener) => T) | undefined {\n if (value == null) return undefined;\n if (typeof value === \"function\") return value as (listener: Listener) => T;\n if (isState(value)) {\n return (listener) => (value as { get: (l?: Listener) => T }).get(listener);\n }\n return value as T;\n}\n\n/**\n * Password input wrapper: a styled `<div>` that inserts an `<input type=\"password\">`\n * and a show/hide toggle button. The outer div carries the focus-ring outline via\n * `:focus-within`. Apply to an empty `<div>`. Host `value`/`name`/`onInput`/\n * `disabled`/`required` are forwarded onto the real input so the field\n * participates in FormData.\n *\n * @hostTag div\n * @param props.color - Base color tone for border/background/text. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent outline color on focus-within. Defaults to `\"primary\"`.\n * @param props.value - Forwarded onto the inner input. Optional.\n * @param props.name - Forwarded onto the inner input (FormData key). Optional.\n * @param props.onInput - Forwarded onto the inner input. Optional.\n * @param props.disabled - Forwarded onto the inner input. Optional.\n * @param props.required - Forwarded onto the inner input. Optional.\n * @param props.autocomplete - Native autocomplete token. Defaults to `\"current-password\"`.\n * @param props.ariaLabel - Accessible name for the inner input. Defaults to `\"Password\"`.\n * @example { div: null, name: \"password\", $: [inputPassword()] }\n */\nfunction inputPassword(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n value?: ValueOrState<string>;\n name?: string;\n onInput?: (event: Event) => void;\n disabled?: ValueOrState<boolean>;\n required?: boolean;\n autocomplete?: string;\n ariaLabel?: string;\n } = {},\n): PartialElement {\n const colorState = toState(props.color ?? \"neutral\", \"color\");\n const accentState = toState(props.accentColor ?? \"primary\", \"accentColor\");\n const visibleState = toState(false);\n const hostFields: HostFields = {};\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn('\"inputPassword\" patch must use div tag');\n }\n },\n // Lift form fields off the host before merge so they land on the real\n // <input> (a div is not form-associated; FormData would omit them).\n _onSchedule: (_node, element) => {\n const host = element as PartialElement & HostFields;\n for (const key of HOST_FIELD_KEYS) {\n if (host[key] !== undefined) {\n hostFields[key] = host[key] as never;\n delete (host as Record<HostFieldKey, unknown>)[key];\n }\n }\n },\n // Build the input/toggle as real child elements (not imperative DOM\n // mutation in _onMount) so generateHTML()/SSR emits the actual markup.\n _onInit: (node) => {\n const name = props.name ?? hostFields.name;\n const value = bindReadable<string>(\n (props.value ?? hostFields.value) as ValueOrState<string> | undefined,\n );\n const onInput = props.onInput ?? hostFields.onInput;\n const disabled = bindReadable<boolean>(\n (props.disabled ?? hostFields.disabled) as\n | ValueOrState<boolean>\n | undefined,\n );\n const required = props.required ?? hostFields.required;\n\n const field: DomphyElement<\"input\"> = {\n input: null,\n type: (l) => (visibleState.get(l) ? \"text\" : \"password\"),\n ariaLabel: props.ariaLabel ?? \"Password\",\n autocomplete: props.autocomplete ?? \"current-password\",\n ...(name != null ? { name } : {}),\n ...(value != null ? { value } : {}),\n ...(onInput != null ? { onInput } : {}),\n ...(disabled != null ? { disabled } : {}),\n ...(required != null ? { required } : {}),\n style: {\n flex: 1,\n minWidth: 0,\n border: \"none\",\n outline: \"none\",\n backgroundColor: \"transparent\",\n padding: 0,\n margin: 0,\n font: \"inherit\",\n color: \"inherit\",\n },\n };\n\n const toggle: DomphyElement<\"button\"> = {\n button: (l) => rawHtml(visibleState.get(l) ? EYE_OFF_SVG : EYE_SVG),\n type: \"button\",\n ariaLabel: (l) =>\n visibleState.get(l) ? \"Hide password\" : \"Show password\",\n onClick: () => visibleState.set(!visibleState.get()),\n style: {\n background: \"none\",\n border: \"none\",\n padding: 0,\n margin: 0,\n cursor: \"pointer\",\n color: \"inherit\",\n display: \"flex\",\n alignItems: \"center\",\n flexShrink: 0,\n opacity: 0.6,\n },\n };\n\n node.children.insert(field);\n node.children.insert(toggle);\n },\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: (l) => themeSpacing(themeDensity(l) * 1),\n paddingBlock: (l) => themeSpacing(themeDensity(l) * 1),\n paddingInline: (l) => themeSpacing(themeDensity(l) * 3),\n borderRadius: (l) => themeSpacing(themeDensity(l) * 1.5),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (l) =>\n `1px solid ${themeColor(l, \"border-strong\", colorState.get(l))}`,\n color: (l) => themeColor(l, \"text\", colorState.get(l)),\n backgroundColor: (l) => themeColor(l, \"inherit\", colorState.get(l)),\n fontSize: (l) => themeSize(l, \"inherit\"),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not(:has([disabled])):not(:focus-within)\": {\n outline: (l) =>\n `1px solid ${themeColor(l, \"shift-5\", accentState.get(l))}`,\n },\n \"&:focus-within\": {\n boxShadow: (l) => focusRing(l, accentState.get(l)),\n },\n } as StyleObject,\n };\n}\n\nexport { inputPassword };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a custom radio button with a themed circular box, checked dot, hover,\n * focus and disabled states. Apply to an `<input>` element of type `radio`\n * (the patch sets `type: \"radio\"`).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for the box/border (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the checked dot and focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"radio\", $: [inputRadio()] }\n */\nfunction inputRadio(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n type: \"radio\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(\n `\"inputRadio\" primitive patch must use input tag and radio type`,\n );\n return;\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n appearance: \"none\",\n display: \"inline-flex\",\n position: \"relative\",\n width: themeSpacing(6),\n height: themeSpacing(6),\n justifyContent: \"center\",\n alignItems: \"center\",\n transition: \"background-color 300ms, outline-color 300ms\",\n margin: 0,\n padding: 0,\n \"&::before\": {\n content: `\"\"`,\n display: \"block\",\n borderRadius: \"50%\",\n lineHeight: 1,\n cursor: \"pointer\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n width: themeSpacing(4),\n height: themeSpacing(4),\n },\n \"&:hover::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:checked::before\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-6\", accentColor.get(listener))}`,\n },\n \"&:checked::after\": {\n content: `\"\"`,\n position: \"absolute\",\n inset: \"30%\",\n borderRadius: \"50%\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-8\", accentColor.get(listener)),\n },\n \"&:checked:hover:not([disabled])::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-7\", accentColor.get(listener)),\n },\n \"&:focus-visible\": {\n borderRadius: \"50%\",\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n cursor: \"not-allowed\",\n },\n \"&[disabled]::before, &[disabled]::after\": {\n outline: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-4\", \"neutral\"),\n pointerEvents: \"none\",\n },\n },\n };\n}\n\nexport { inputRadio };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a range slider with a themed track and thumb, hover, focus and\n * disabled states. Apply to an `<input>` element of type `range` (the patch\n * sets `type: \"range\"`).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for the slider track (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the thumb and focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"range\", $: [inputRange()] }\n */\nfunction inputRange(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n type: \"range\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputRange\" primitive patch must use input tag`);\n }\n },\n style: {\n appearance: \"none\",\n width: \"100%\",\n margin: 0,\n padding: 0,\n height: themeSpacing(4),\n background: \"transparent\",\n cursor: \"pointer\",\n \"&::-webkit-slider-runnable-track\": {\n height: themeSpacing(1.5),\n borderRadius: themeSpacing(999),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", color.get(listener)),\n },\n \"&::-webkit-slider-thumb\": {\n appearance: \"none\",\n width: themeSpacing(4),\n height: themeSpacing(4),\n borderRadius: themeSpacing(999),\n border: \"none\",\n marginTop: `calc((${themeSpacing(1.5)} - ${themeSpacing(4)}) / 2)`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-9\", accentColor.get(listener)),\n },\n \"&:hover:not([disabled])::-webkit-slider-thumb\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-10\", accentColor.get(listener)),\n },\n borderRadius: themeSpacing(2),\n transition: \"box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n };\n}\n\nexport { inputRange };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a search input with themed border, padding, placeholder color, native\n * search decorations, hover, focus and disabled states. Apply to an `<input>`\n * element of type `search` (the patch default is `type: \"search\"`; a native `type` wins).\n *\n * @hostTag input\n * @param props.color - Optional theme color tone for text/border/placeholder (`ValueOrState<ThemeColor>`). Defaults to `\"neutral\"`.\n * @param props.accentColor - Optional theme color tone for the hover/focus ring (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"search\", $: [inputSearch()] }\n */\nfunction inputSearch(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type: \"search\",\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputSearch\" primitive patch must use input tag`);\n }\n },\n style: {\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n minWidth: themeSpacing(32),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::placeholder\": {\n color: (listener) =>\n themeColor(listener, \"shift-7\", color.get(listener)),\n },\n \"&::-webkit-search-decoration\": {\n display: \"none\",\n },\n \"&::-webkit-search-cancel-button\": {\n cursor: \"pointer\",\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n },\n },\n };\n}\n\nexport { inputSearch };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a checkbox as a toggle switch: themed track and sliding knob that\n * animates and recolors on checked, plus a disabled state. Apply to an\n * `<input>` element of type `checkbox` (the patch sets `type: \"checkbox\"`).\n *\n * @hostTag input\n * @param props.accentColor - Optional theme color tone for the checked track (`ValueOrState<ThemeColor>`). Defaults to `\"primary\"`.\n * @example { input: null, type: \"checkbox\", $: [inputSwitch()] }\n */\nfunction inputSwitch(\n props: { accentColor?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n role: \"switch\",\n dataTone: \"shift-2\",\n type: \"checkbox\",\n _onSchedule: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(`\"inputSwitch\" primitive patch must use input tag`);\n return;\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n // Surface contract: dataTone is set; paint track via inherit + text color.\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n appearance: \"none\",\n position: \"relative\",\n display: \"inline-flex\",\n width: themeSpacing(9),\n height: themeSpacing(6),\n cursor: \"pointer\",\n margin: `0`,\n paddingBlock: themeSpacing(1),\n transition: \"box-shadow 140ms ease\",\n borderRadius: themeSpacing(999),\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&:checked\": {\n \"&::before\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-3\", accentColor.get(listener)),\n },\n \"&::after\": {\n left: `calc(100% - ${themeSpacing(3.5)})`,\n },\n },\n \"&::after\": {\n content: `\"\"`,\n aspectRatio: `1/1`,\n position: \"absolute\",\n width: themeSpacing(3),\n height: themeSpacing(3),\n borderRadius: themeSpacing(999),\n left: themeSpacing(0.5),\n top: \"50%\",\n transform: \"translateY(-50%)\",\n transition: \"left 0.3s\",\n backgroundColor: (listener) => themeColor(listener, \"decrease-3\"),\n },\n \"&::before\": {\n content: '\"\"',\n width: \"100%\",\n borderRadius: themeSpacing(999),\n display: \"inline-block\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: 1,\n backgroundColor: (listener) => themeColor(listener),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n };\n}\n\nexport { inputSwitch };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Themed single-line text input primitive. Sets `type` (default `\"text\"`) and\n * styles the field with themed border, focus ring, placeholder, disabled and\n * validation (`data-status`) states. Apply to an `<input>` element.\n *\n * @hostTag input\n * @param props - Optional configuration.\n * @param props.type - The input's `type` attribute (e.g. `\"email\"`, `\"url\"`, `\"tel\"`). Defaults to `\"text\"`.\n * @param props.color - Base color tone for text/border/background. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color tone for the hover/focus outline. Defaults to `\"primary\"`.\n * @example { input: \"\", type: \"text\", placeholder: \"Name\", $: [inputText()] }\n */\nfunction inputText(\n props: {\n type?: string;\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { type = \"text\" } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n // Declared like any other attribute — the native element still wins over\n // this patch default if the host declares its own `type`.\n type,\n _onInsert: (node) => {\n if (node.tagName !== \"input\") {\n console.warn(\n `\"inputText\" primitive patch must use input tag and text type`,\n );\n }\n },\n style: {\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n minWidth: themeSpacing(10),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::placeholder\": {\n color: (listener) => themeColor(listener, \"shift-7\"),\n },\n \"&:not(:placeholder-shown)\": {\n color: (listener) => themeColor(listener, \"shift-10\"),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n \"&:invalid:not(:placeholder-shown)\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"error\")}`,\n },\n \"&[data-status=error]\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"error\")}`,\n },\n \"&[data-status=warning]\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-6\", \"warning\")}`,\n },\n },\n };\n}\n\nexport { inputText };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Renders keyboard-key styling (themed background, border and padding) for a\n * keystroke hint. Apply to a `<kbd>` element.\n *\n * @hostTag kbd\n * @param props - Optional configuration.\n * @param props.color - Color tone for text/background/border. Defaults to `\"neutral\"`.\n * @example { kbd: \"Ctrl\", $: [keyboard()] }\n */\nfunction keyboard(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"kbd\") {\n console.warn(`\"keyboard\" primitive patch must use kbd tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * (0.5 / 1.5)),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * (1.5 / 1.5)),\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * (1 / 1.5)),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n },\n };\n}\n\nexport { keyboard };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Themed form-label primitive: inline-flex layout with gap, themed text color,\n * focus-within highlighting and a disabled (`aria-disabled`) state. Apply to a\n * `<label>` element.\n *\n * @hostTag label\n * @param props - Optional configuration.\n * @param props.color - Base color tone for the label text. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color tone applied on focus-within. Defaults to `\"primary\"`.\n * @example { label: \"Email\", htmlFor: \"email\", $: [label()] }\n */\nfunction label(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"label\") {\n console.warn(`\"label\" primitive patch must use label tag`);\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n cursor: \"pointer\",\n \"&:focus-within\": {\n color: (listener) =>\n themeColor(listener, \"shift-10\", accentColor.get(listener)),\n },\n \"&[aria-disabled=true]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { label };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Themed hyperlink primitive: styles text color, hover underline, visited,\n * focus ring and a disabled state. Apply to an `<a>` element.\n *\n * @hostTag a\n * @param props - Optional configuration.\n * @param props.color - Base color tone for the link text. Defaults to `\"primary\"`.\n * @param props.accentColor - Accent color tone for visited/focus states. Defaults to `\"secondary\"`.\n * @example { a: \"Home\", href: \"/\", $: [link()] }\n */\nfunction link(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"primary\", \"color\");\n const accentColor = toState(props.accentColor ?? \"secondary\", \"accentColor\");\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"a\") {\n console.warn(`\"link\" primitive patch must use a tag`);\n }\n },\n // `<a disabled>` is not a native navigation block — stop click/Enter.\n onClick: (event, node) => {\n const el = node.domElement;\n if (\n el?.hasAttribute(\"disabled\") ||\n el?.getAttribute(\"aria-disabled\") === \"true\"\n ) {\n event.preventDefault();\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n // shift-13 (not \"text\"/shift-9): brand hues need extra depth for ≥4.5:1\n // on a light surface (primary orange failed at 2.57 with shift-9).\n color: (listener) =>\n themeColor(listener, \"shift-13\", color.get(listener)),\n textDecoration: \"none\",\n \"&:visited\": {\n color: (listener) =>\n themeColor(listener, \"shift-13\", accentColor.get(listener)),\n },\n \"&:hover:not([disabled])\": {\n color: (listener) =>\n themeColor(listener, \"shift-14\", color.get(listener)),\n textDecoration: \"underline\",\n },\n borderRadius: themeSpacing(1),\n // Kill the browser default outline so only the shared focusRing shows.\n outline: \"none\",\n transition: \"color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n pointerEvents: \"none\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { link };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { BUTTON_SIZE_FONT, type ButtonSize } from \"../utils/buttonSize.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport type { ButtonVariant } from \"./button.js\";\n\nconst PADDING_STEPS: Record<ButtonSize, { block: number; inline: number }> = {\n small: { block: 0.5, inline: 2 },\n medium: { block: 1, inline: 3 },\n large: { block: 1.5, inline: 4 },\n};\n\nconst GHOST_PADDING: Record<ButtonSize, number> = {\n small: 0.5,\n medium: 1,\n large: 1.5,\n};\n\n/**\n * An `<a>` element styled to look like a button — same visual system as\n * `button()` (`variant` / `size` / color) while preserving link semantics\n * (href, middle-click, right-click). Apply to an `<a>` element.\n *\n * @hostTag a\n * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, default \"primary\".\n * @param props.variant - `\"outline\"` (default) | `\"solid\"` | `\"ghost\"` — matches `button()`.\n * @param props.size - `\"small\" | \"medium\" | \"large\"`, defaults to `\"medium\"`.\n * @example { a: \"Open app\", href: \"/app\", $: [linkButton({ color: \"primary\" })] }\n * @example { a: \"Get started\", href: \"/start\", $: [linkButton({ variant: \"solid\" })] }\n */\nfunction linkButton(\n props: {\n color?: ValueOrState<ThemeColor>;\n variant?: ButtonVariant;\n size?: ButtonSize;\n } = {},\n): PartialElement {\n const variant = props.variant ?? \"outline\";\n const color = toState(\n props.color ?? (variant === \"ghost\" ? \"neutral\" : \"primary\"),\n \"color\",\n );\n const size = props.size ?? \"medium\";\n const fontSize = BUTTON_SIZE_FONT[size];\n\n if (variant === \"ghost\") {\n const padding = GHOST_PADDING[size];\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"a\") {\n console.warn(`\"linkButton\" primitive patch must use a tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, fontSize),\n textDecoration: \"none\",\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n display: \"inline-flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n background: \"none\",\n outline: \"none\",\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n // Resting text uses the \"text\" alias (shift-9), matching buttonGhost:\n // a text-labeled ghost control fails WCAG AA at the previous shift-6\n // (~2.4:1 on an edge surface). Hover/active differentiate via\n // background only.\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&:hover:not([aria-disabled=true])\": {\n color: (listener) =>\n themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n textDecoration: \"none\",\n },\n \"&:active:not([aria-disabled=true])\": {\n color: (listener) =>\n themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[aria-disabled=true]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n pointerEvents: \"none\",\n color: (listener) => themeColor(listener, \"border-strong\", \"neutral\"),\n },\n },\n };\n }\n\n const isSolid = variant === \"solid\";\n const padding = PADDING_STEPS[size];\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"a\") {\n console.warn(`\"linkButton\" primitive patch must use a tag`);\n }\n },\n ...(isSolid\n ? {\n _doctorDisable: [\n \"low-contrast\",\n \"color-shift-minimum\",\n \"tone-background-inherit\",\n ] as const,\n }\n : {}),\n style: {\n fontSize: (listener) => themeSize(listener, fontSize),\n textDecoration: \"none\",\n paddingBlock: (listener) =>\n themeSpacing(themeDensity(listener) * padding.block),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * padding.inline),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n width: \"fit-content\",\n display: \"inline-flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 1),\n userSelect: \"none\",\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n border: \"none\",\n outlineOffset: \"-1px\",\n outlineWidth: \"1px\",\n outline: isSolid\n ? \"none\"\n : (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n // Solid: deep brand (shift-13) + light-end text (not mid-ramp ~2.2:1).\n // Outline: shift-13 for ≥4.5:1 on light bg.\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-13\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-13\", color.get(listener))\n : themeColor(listener, \"inherit\", color.get(listener)),\n transition:\n \"background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([aria-disabled=true])\": {\n textDecoration: \"none\",\n color: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-0\", \"neutral\")\n : themeColor(listener, \"shift-14\", color.get(listener)),\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-14\", color.get(listener))\n : themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:active:not([aria-disabled=true])\": {\n backgroundColor: (listener) =>\n isSolid\n ? themeColor(listener, \"shift-15\", color.get(listener))\n : themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color.get(listener)),\n },\n \"&[aria-disabled=true]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n pointerEvents: \"none\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n },\n },\n };\n}\n\nexport { linkButton };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a navigation/display list container. Sets `list-style: none` and\n * zero padding; pairs with `listItem` and `listItemButton`. Apply to `<ul>`.\n *\n * @hostTag ul\n * @param props.color - Surface color tone. Optional `ThemeColor`, defaults to `\"neutral\"`.\n * @example { ul: [...], $: [list()] }\n */\nfunction list(props: { color?: ThemeColor } = {}): PartialElement {\n const color = props.color ?? \"neutral\";\n return {\n style: {\n listStyle: \"none\",\n margin: 0,\n padding: 0,\n display: \"flex\",\n flexDirection: \"column\",\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n color: (listener) => themeColor(listener, \"text\", color),\n },\n };\n}\n\n/**\n * A non-interactive list row. Typically wraps an icon + text. Apply to `<li>`.\n *\n * @hostTag li\n * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.\n * @example { li: \"Item\", $: [listItem()] }\n */\nfunction listItem(props: { dense?: boolean } = {}): PartialElement {\n const { dense = false } = props;\n return {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBlock: (listener) =>\n themeSpacing(dense ? 1 : themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n },\n };\n}\n\n/**\n * An interactive (clickable) list row with hover/focus-visible states. Apply\n * to `<button>` or `<a>` inside an `<li>`.\n *\n * @param props.color - Color tone. Optional `ValueOrState<ThemeColor>`, defaults to `\"neutral\"`.\n * @param props.accentColor - Focus/active accent. Optional `ThemeColor`, defaults to `\"primary\"`.\n * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.\n * @example { button: \"Action\", $: [listItemButton()] }\n */\nfunction listItemButton(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ThemeColor;\n dense?: boolean;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = props.accentColor ?? \"primary\";\n const { dense = false } = props;\n\n return {\n style: {\n cursor: \"pointer\",\n appearance: \"none\",\n border: \"none\",\n background: \"transparent\",\n textDecoration: \"none\",\n textAlign: \"left\",\n display: \"flex\",\n alignItems: \"center\",\n width: \"100%\",\n gap: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBlock: (listener) =>\n themeSpacing(dense ? 1 : themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n transition: \"background-color 150ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"hover\", color.get(listener)),\n },\n \"&:active:not([disabled])\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"increase-2\", color.get(listener)),\n },\n \"&[aria-current=page], &[aria-selected=true]\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", accentColor),\n color: (listener) => themeColor(listener, \"shift-12\", accentColor),\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n \"&[disabled]\": { opacity: 0.5, cursor: \"not-allowed\" },\n },\n };\n}\n\nexport { list, listItem, listItemButton };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Themed highlight primitive: gives marked/highlighted inline text a tinted\n * background, rounded corners and padding. Apply to a `<mark>` element.\n *\n * @hostTag mark\n * @param props - Optional configuration.\n * @param props.accentColor - Accent color tone for the highlight fill and text. Defaults to `\"highlight\"`.\n * @example { mark: \"important\", $: [mark()] }\n */\nfunction mark(\n props: { accentColor?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const accentColor = toState(props.accentColor ?? \"highlight\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"mark\") {\n console.warn(`\"mark\" primitive patch must use mark tag`);\n }\n },\n dataTone: \"shift-2\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) =>\n themeColor(listener, \"text\", accentColor.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", accentColor.get(listener)),\n // Bare themeSpacing(U) at snapshot time; n = U / 1.5 (light.densities[2]).\n height: (listener) => themeSpacing(themeDensity(listener) * (6 / 1.5)),\n borderRadius: (listener) =>\n themeSpacing(themeDensity(listener) * (1 / 1.5)),\n paddingInline: (listener) =>\n themeSpacing(themeDensity(listener) * (1.5 / 1.5)),\n },\n };\n}\n\nexport { mark };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One item inside a menu. */\ntype MenuItem = {\n /** Button label — plain string (auto-wrapped) or any DomphyElement (e.g. icon + text). */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index. */\n key?: string | number;\n /** Called when the item is clicked. */\n onClick?: () => void;\n};\n\n/**\n * All-in-one vertical menu. Generates `<button>` `[role=menuitem]` elements\n * from the `items` array with keyboard navigation (Arrow/Home/End/Enter/Space).\n * Apply to any wrapper element (`div`, `ul`, …).\n *\n * @param props.items - Item definitions `{ label, key?, onClick? }`. Pass `[]`\n * to keep the wrapper's own children (escape hatch for fully custom rows —\n * only the menu container styling and `role=\"menu\"` semantics apply then).\n * @param props.activeKey - Currently selected key (value or State). Defaults to `null`.\n * @param props.selectable - Whether items track and update the active selection. Defaults to `true`.\n * @param props.color - Background color tone for the menu. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color for the active/focus item. Defaults to `\"primary\"`.\n * @example\n * { div: null, $: [menu({ items: [\n * { label: \"Profile\", key: \"profile\", onClick: () => navigate(\"/profile\") },\n * { label: \"Settings\", key: \"settings\", onClick: () => navigate(\"/settings\") },\n * ] })] }\n */\nfunction menu(\n props: {\n items: MenuItem[];\n activeKey?: ValueOrState<number | string | null>;\n selectable?: boolean;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const {\n items = [],\n selectable = true,\n color = \"neutral\",\n accentColor = \"primary\",\n } = props;\n const activeKey = toState(props.activeKey ?? null);\n const activeKeyIsCallerOwned = props.activeKey !== undefined;\n\n type MenuInner = {\n items: MenuItem[];\n activeKey: State<number | string | null>;\n activeKeyIsCallerOwned: boolean;\n selectable: boolean;\n color: ThemeColor;\n accentColor: ThemeColor;\n };\n\n const buildItems = (\n node: ElementNode,\n inner: MenuInner,\n ): DomphyElement<\"button\">[] => {\n const id = node.nodeId;\n return inner.items.map((item, index) => {\n const key = item.key ?? index;\n return {\n button:\n typeof item.label === \"string\"\n ? [{ span: item.label } as DomphyElement<\"span\">]\n : [item.label],\n _key: key,\n type: \"button\",\n id: `menuitem${id}${key}`,\n role: \"menuitem\",\n ...(inner.selectable\n ? {\n ariaCurrent: (l: Listener) =>\n inner.activeKey.get(l) === key || undefined,\n }\n : {}),\n onClick: () => {\n if (inner.selectable) inner.activeKey.set(key);\n item.onClick?.();\n },\n onKeyDown: (e: Event) => {\n const k = (e as KeyboardEvent).key;\n if (k === \"Enter\" || k === \" \") {\n e.preventDefault();\n (e.target as HTMLElement).click();\n return;\n }\n if (![\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = inner.items.map((it, i) => it.key ?? i);\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowDown\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowUp\")\n next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n (\n document.getElementById(`menuitem${id}${keys[next]}`) as HTMLElement\n )?.focus();\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(2),\n width: \"100%\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: (l: Listener) => themeSpacing(6 + themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 3),\n border: \"none\",\n outline: \"none\",\n // Menu panel is a light (shift-0) surface: \"text\" resolves to a\n // dark-on-light reading tone in both light and dark themes.\n color: (l: Listener) => themeColor(l, \"text\", inner.color),\n backgroundColor: (l: Listener) =>\n themeColor(l, \"inherit\", inner.color),\n transition:\n \"background-color 140ms ease, box-shadow 140ms ease, color 140ms ease\",\n \"&:hover:not([disabled]):not([aria-current=true])\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"hover\", inner.color),\n },\n \"&[aria-current=true]\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-3\", inner.accentColor),\n color: (l: Listener) =>\n themeColor(l, \"shift-13\", inner.accentColor),\n },\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, inner.accentColor),\n },\n },\n } as DomphyElement<\"button\">;\n });\n };\n\n const attachMenu = (\n _node: ElementNode,\n initial: MenuInner,\n ): BehaviorInstance<MenuInner> => {\n let current = initial;\n return {\n update(next) {\n if (\n next.activeKey !== current.activeKey &&\n !next.activeKeyIsCallerOwned\n ) {\n next.activeKey.set(current.activeKey.get());\n }\n current = next;\n // Empty items = the caller renders its own rows; leave children alone.\n if (current.items.length === 0) return;\n _node.children.update(buildItems(_node, current));\n },\n };\n };\n\n const inner: MenuInner = {\n items,\n activeKey,\n activeKeyIsCallerOwned,\n selectable,\n color,\n accentColor,\n };\n\n return {\n role: \"menu\",\n dataTone: \"shift-0\",\n _onSchedule: (node, element) => {\n // Empty items = the caller renders its own rows; leave children alone.\n if (items.length === 0) return;\n (element as Record<string, unknown>)[node.tagName] = buildItems(\n node,\n inner,\n );\n },\n ...behavior<MenuInner>(\"menu\", attachMenu, inner),\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n paddingBlock: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n color: (l: Listener) => themeColor(l, \"text\", color),\n borderRadius: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n outline: (l: Listener) =>\n `1px solid ${themeColor(l, \"border-strong\", color)}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n}\n\nexport { menu };\nexport type { MenuItem };\n","import {\n type BehaviorInstance,\n behavior,\n type PartialElement,\n type State,\n} from \"@domphy/core\";\n\n/**\n * One keyframe. Shorthands `x`/`y` (px), `scale`, `rotate` (deg) compose into a\n * single `transform`; any other key is a raw CSS property (e.g. `opacity`,\n * `backgroundColor`).\n */\nexport type MotionKeyframe = {\n x?: number | string;\n y?: number | string;\n scale?: number | string;\n rotate?: number | string;\n} & Record<string, string | number>;\n\nexport interface MotionProps {\n /** Starting keyframe applied before the enter animation. */\n initial?: MotionKeyframe;\n /** Target keyframe. Pass a `State` to re-animate whenever it changes. */\n animate?: MotionKeyframe | State<MotionKeyframe>;\n /** Keyframe animated to before the element is removed. */\n exit?: MotionKeyframe;\n transition?: {\n /** ms, default 300. */\n duration?: number;\n /** ms, default 0. */\n delay?: number;\n /** CSS easing, default \"ease\". */\n easing?: string;\n iterations?: number;\n };\n}\n\ntype MotionInstance = BehaviorInstance<MotionProps> & {\n play: (props: MotionProps, mode: \"enter\" | \"update\") => void;\n getExit: () => MotionKeyframe | undefined;\n getTransition: () => MotionProps[\"transition\"];\n};\n\nconst isMotionState = (value: unknown): value is State<MotionKeyframe> =>\n !!value &&\n typeof (value as State<MotionKeyframe>).get === \"function\" &&\n (value as { _isState?: boolean })._isState === true;\n\nconst toStyles = (frame: MotionKeyframe): Keyframe => {\n const out: Record<string, string | number> = {};\n const transforms: string[] = [];\n for (const key in frame) {\n const value = frame[key];\n if (key === \"x\") {\n transforms.push(\n `translateX(${typeof value === \"number\" ? `${value}px` : value})`,\n );\n } else if (key === \"y\") {\n transforms.push(\n `translateY(${typeof value === \"number\" ? `${value}px` : value})`,\n );\n } else if (key === \"scale\") {\n transforms.push(`scale(${value})`);\n } else if (key === \"rotate\") {\n transforms.push(\n `rotate(${typeof value === \"number\" ? `${value}deg` : value})`,\n );\n } else {\n out[key] = value;\n }\n }\n if (transforms.length) out.transform = transforms.join(\" \");\n return out as Keyframe;\n};\n\nfunction toOptions(\n transition: MotionProps[\"transition\"] = {},\n): KeyframeAnimationOptions {\n return {\n duration: transition.duration ?? 300,\n delay: transition.delay ?? 0,\n easing: transition.easing ?? \"ease\",\n iterations: transition.iterations ?? 1,\n fill: \"both\",\n };\n}\n\n/**\n * Animation primitive driven by the Web Animations API. Runs an enter\n * animation on mount (`initial` -> `animate`), re-animates whenever `animate`\n * is a `State` that changes, and plays the `exit` keyframe before removal.\n * Has no host-tag restriction; apply to any element you want to animate.\n *\n * Later generations route a fresh `animate`/`exit`/`transition` into the same\n * `behavior()` instance via `update()`, so a reused node is not stuck on\n * generation-1 keyframes.\n *\n * @param props - Optional configuration (see {@link MotionProps}).\n * @param props.initial - Starting keyframe applied before the enter animation.\n * @param props.animate - Target keyframe, or a `State` to re-animate on change.\n * @param props.exit - Keyframe animated to before the element is removed.\n * @param props.transition - Timing options.\n * @param props.transition.duration - Duration in ms. Defaults to `300`.\n * @param props.transition.delay - Delay in ms. Defaults to `0`.\n * @param props.transition.easing - CSS easing. Defaults to `\"ease\"`.\n * @param props.transition.iterations - Number of iterations. Defaults to `1`.\n * @example { div: \"Hello\", $: [motion({ initial: { opacity: 0 }, animate: { opacity: 1 } })] }\n */\nfunction prefersReducedMotion(): boolean {\n if (typeof matchMedia !== \"function\") return false;\n try {\n return matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n } catch {\n return false;\n }\n}\n\nfunction attachMotion(\n node: { domElement?: HTMLElement | null },\n initial: MotionProps,\n): MotionInstance {\n const el = node.domElement as HTMLElement | null;\n let current = initial;\n let release: (() => void) | undefined;\n\n const bindAnimate = (animate: MotionProps[\"animate\"]) => {\n release?.();\n release = undefined;\n if (!el || !isMotionState(animate)) return;\n release = animate.addListener((next: MotionKeyframe) => {\n if (prefersReducedMotion()) {\n Object.assign(el.style, toStyles(next));\n } else if (typeof el.animate === \"function\") {\n el.animate([toStyles(next)], toOptions(current.transition));\n }\n });\n };\n\n const play = (props: MotionProps, mode: \"enter\" | \"update\") => {\n if (!el) return;\n const target = isMotionState(props.animate)\n ? props.animate.get()\n : props.animate;\n if (prefersReducedMotion()) {\n if (target) Object.assign(el.style, toStyles(target));\n else if (mode === \"enter\" && props.initial) {\n Object.assign(el.style, toStyles(props.initial));\n }\n return;\n }\n if (typeof el.animate !== \"function\") return;\n if (target) {\n const frames =\n mode === \"enter\" && props.initial\n ? [toStyles(props.initial), toStyles(target)]\n : [toStyles(target)];\n el.animate(frames, toOptions(props.transition));\n } else if (mode === \"enter\" && props.initial) {\n Object.assign(el.style, toStyles(props.initial));\n }\n };\n\n play(initial, \"enter\");\n bindAnimate(initial.animate);\n\n return {\n play,\n getExit: () => current.exit,\n getTransition: () => current.transition,\n update(next) {\n current = next;\n play(next, \"update\");\n bindAnimate(next.animate);\n },\n destroy() {\n release?.();\n },\n };\n}\n\nfunction motion(props: MotionProps = {}): PartialElement {\n return {\n ...behavior<MotionProps>(\n \"motion\",\n (node, next) => attachMotion(node, next),\n props,\n ),\n _onBeforeRemove: (node, done) => {\n const el = node.domElement as HTMLElement | null;\n const inst = node.getBehavior<MotionInstance>(\"motion\");\n const exit = inst?.getExit() ?? props.exit;\n if (!el || !exit || typeof el.animate !== \"function\") return done();\n if (prefersReducedMotion()) {\n Object.assign(el.style, toStyles(exit));\n return done();\n }\n el.animate(\n [toStyles(exit)],\n toOptions(inst?.getTransition() ?? props.transition),\n ).finished.then(done, done);\n },\n };\n}\n\nexport { motion };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Themed ordered-list primitive: decimal markers positioned outside, reset\n * margins and themed text color. Apply to an `<ol>` element.\n *\n * @hostTag ol\n * @param props - Optional configuration.\n * @param props.color - Color tone for the list text. Defaults to `\"neutral\"`.\n * @example { ol: \"\", $: [orderedList()], children: [{ li: \"First\" }] }\n */\nfunction orderedList(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"ol\") {\n console.warn(`\"orderedList\" primitive patch must use ol tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n marginTop: 0,\n marginBottom: 0,\n paddingLeft: themeSpacing(3),\n listStyleType: \"decimal\",\n listStylePosition: \"outside\",\n },\n };\n}\n\nexport { orderedList };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nfunction getPages(current: number, total: number): (number | \"...\")[] {\n if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1);\n const pages: (number | \"...\")[] = [1];\n if (current > 3) pages.push(\"...\");\n const start = Math.max(2, current - 1);\n const end = Math.min(total - 1, current + 1);\n for (let i = start; i <= end; i++) pages.push(i);\n if (current < total - 2) pages.push(\"...\");\n pages.push(total);\n return pages;\n}\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction persistTotal(node: ElementNode, total: number): State<number> {\n let stored = node.getMetadata(\"paginationTotal\") as State<number> | undefined;\n if (!stored) {\n stored = toState(total);\n node.setMetadata(\"paginationTotal\", stored);\n }\n return stored;\n}\n\n/**\n * Themed pagination control. Renders previous/next buttons plus truncated page\n * numbers (with ellipses), tracks the current page in a `State`, and updates it\n * on click. Apply to a `<div>` element.\n *\n * @hostTag div\n * @param props - Configuration.\n * @param props.total - Required. Total number of pages.\n * @param props.value - Current page, accepts a value or `State`. Defaults to `1`.\n * @param props.color - Base color tone for the page buttons. Defaults to `\"neutral\"`.\n * @param props.accentColor - Accent color tone for the active page. Defaults to `\"primary\"`.\n * @example { div: \"\", $: [pagination({ total: 10, value: 1 })] }\n */\nfunction pagination(props: {\n value?: ValueOrState<number>;\n total: number;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n}): PartialElement {\n const { total, color = \"neutral\", accentColor = \"primary\" } = props;\n\n const btnBase = {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minWidth: (listener: any) => themeSpacing(6 + themeDensity(listener) * 2),\n height: (listener: any) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener: any) => themeSpacing(themeDensity(listener) * 2),\n borderRadius: (listener: any) => themeSpacing(themeDensity(listener) * 1.5),\n border: \"none\",\n cursor: \"pointer\",\n fontSize: (listener: any) => themeSize(listener, \"inherit\"),\n backgroundColor: \"transparent\",\n // Page numbers: shift-13 for readable inactive digits (catalog contrast).\n color: (listener: any) => themeColor(listener, \"shift-13\", color),\n transition:\n \"background-color 140ms ease, box-shadow 140ms ease, color 140ms ease\",\n \"&:hover:not([disabled])\": {\n color: (listener: any) => themeColor(listener, \"shift-13\", color),\n backgroundColor: (listener: any) => themeColor(listener, \"hover\", color),\n },\n \"&:focus-visible\": {\n boxShadow: (listener: any) => focusRing(listener, accentColor),\n },\n \"&[disabled]\": {\n opacity: 0.4,\n cursor: \"not-allowed\",\n },\n };\n\n const activeStyle = {\n ...btnBase,\n // Deep accent fill + light text (mid-ramp + mid text failed catalog).\n backgroundColor: (listener: any) =>\n themeColor(listener, \"shift-13\", accentColor),\n color: (listener: any) => themeColor(listener, \"shift-0\", \"neutral\"),\n fontWeight: \"bold\",\n cursor: \"default\",\n \"&:hover:not([disabled])\": {\n backgroundColor: (listener: any) =>\n themeColor(listener, \"shift-13\", accentColor),\n },\n };\n\n return {\n role: \"navigation\",\n ariaLabel: \"Pagination\",\n // Active page weight is design-system chrome for the control.\n _doctorDisable: \"inline-typography\",\n _onInsert: (node) => {\n if (node.tagName !== \"div\")\n console.warn('\"pagination\" patch must use div tag');\n },\n _onInit: (node) => {\n const state = persistValue(node, \"paginationPage\", props.value, 1);\n const totalState = persistTotal(node, total);\n const content: DomphyElement<\"div\"> = {\n div: (listener) => {\n const page = state.get(listener);\n const pageCount = totalState.get(listener);\n const items: DomphyElement[] = [];\n\n // Prev button\n items.push({\n button: \"‹\",\n _key: \"prev\",\n type: \"button\",\n ariaLabel: \"Previous page\",\n disabled: page <= 1,\n onClick: () => page > 1 && state.set(page - 1),\n style: btnBase,\n });\n\n // Page buttons. Keyed by page number (or a running ellipsis index —\n // there can be up to two \"...\" spans) so the list survives length\n // changes across pages without the unkeyed-reuse footgun.\n let ellipsisIndex = 0;\n for (const p of getPages(page, pageCount)) {\n if (p === \"...\") {\n items.push({\n span: \"…\",\n _key: `ellipsis-${ellipsisIndex++}`,\n ariaHidden: \"true\",\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n paddingInline: (listener: any) =>\n themeSpacing(themeDensity(listener) * 2),\n color: (listener: any) =>\n themeColor(listener, \"shift-7\", color),\n },\n });\n } else {\n const isActive = p === page;\n items.push({\n button: String(p),\n _key: `page-${p}`,\n type: \"button\",\n ariaLabel: `Page ${p}`,\n ariaCurrent: isActive ? \"page\" : undefined,\n disabled: isActive,\n onClick: () => state.set(p),\n style: isActive ? activeStyle : btnBase,\n });\n }\n }\n\n // Next button\n items.push({\n button: \"›\",\n _key: \"next\",\n type: \"button\",\n ariaLabel: \"Next page\",\n disabled: page >= pageCount,\n onClick: () => page < pageCount && state.set(page + 1),\n style: btnBase,\n });\n\n return items;\n },\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: themeSpacing(1),\n },\n };\n node.children.insert(content);\n },\n ...behavior<{ total: number }>(\n \"pagination-total\",\n (node) => ({\n update(snapshot) {\n persistTotal(node, snapshot.total).set(snapshot.total);\n },\n }),\n { total },\n ),\n style: {\n display: \"inline-flex\",\n },\n };\n}\n\nexport { pagination };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A padded section for side-panel/inspector UIs — density-aware padding on\n * all sides, with an optional bottom divider for sections stacked one after\n * another. A thin wrapper: it does not impose flex layout on its children —\n * pair it with `stack()` or `row()` for that. No host-tag check; apply to\n * any block element.\n *\n * @param props.padding - Spacing multiplier for padding on all sides (default 4 = 1em at density 1).\n * @param props.divider - Adds a bottom border, for sections stacked one after another. Defaults to `false`.\n * @param props.color - Theme color tone for the divider border. Defaults to `\"neutral\"`.\n * @example { div: [{ h3: \"Parameters\" }, { p: \"...\" }], $: [panelSection()] }\n * @example\n * { div: [\n * { div: \"Section A\", $: [panelSection({ divider: true })] },\n * { div: \"Section B\", $: [panelSection()] },\n * ], $: [stack({ gap: 0 })] }\n */\nfunction panelSection(\n props: {\n padding?: number;\n divider?: boolean;\n color?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const { padding = 4, divider = false } = props;\n const color = toState(props.color ?? \"neutral\", \"color\");\n return {\n style: {\n padding: (listener) => themeSpacing(themeDensity(listener) * padding),\n ...(divider\n ? {\n borderBottom: (listener) =>\n `1px solid ${themeColor(listener, \"border\", color.get(listener))}`,\n }\n : {}),\n },\n };\n}\n\nexport { panelSection };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Themed paragraph primitive: comfortable line-height, reset margins and themed\n * text color. Apply to a `<p>` element.\n *\n * @hostTag p\n * @param props - Optional configuration.\n * @param props.color - Color tone for the paragraph text. Defaults to `\"neutral\"`.\n * @example { p: \"Hello world\", $: [paragraph()] }\n */\nfunction paragraph(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"p\") {\n console.warn(`\"paragraph\" primitive patch must use p tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n lineHeight: 1.5,\n marginTop: 0,\n marginBottom: 0,\n },\n };\n}\n\nexport { paragraph };\n","import {\n type DomphyElement,\n type Listener,\n merge,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport { themeColor, themeDensity, themeSpacing } from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\n\nfunction contentOwnsSurface(content: DomphyElement): boolean {\n const record = content as DomphyElement & { dataTone?: string };\n if (typeof record.dataTone === \"string\") return true;\n const patches = content.$;\n if (!patches) return false;\n return patches.some(\n (patch) =>\n patch != null &&\n typeof (patch as { dataTone?: unknown }).dataTone === \"string\",\n );\n}\n\n/**\n * Floating popover primitive. Attaches to its host as the anchor/trigger and\n * shows a floating `content` element (with `role=\"dialog\"`) on click or hover,\n * positioned via `@domphy/floating`. Returns the anchor partial, which merges\n * trigger wiring (haspopup/expanded, focus/blur dismissal). Apply to the\n * trigger element you want the popover anchored to.\n *\n * @param props - Configuration.\n * @param props.openOn - Interaction that opens the popover: `\"click\"` or `\"hover\"`. Defaults to `\"click\"`.\n * @param props.open - Open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so Escape/outside click can close. Defaults to `false`.\n * @param props.onDismiss - Called when the panel requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.placement - Floating placement (e.g. `\"bottom\"`, `\"top-start\"`), value or `State`. Defaults to `\"bottom\"`.\n * @param props.content - The floating content element to display.\n * @example { button: \"Open\", $: [popover({ openOn: \"click\", content: { div: \"Hi\" } })] }\n */\nfunction popover(props: {\n openOn?: \"click\" | \"hover\";\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement?: ValueOrState<Placement>;\n content: DomphyElement;\n}): PartialElement {\n const { open = false, placement = \"bottom\", openOn = \"click\" } = props;\n\n const openState = toState(open);\n const placeState = toState(placement);\n\n const { show, hide, anchorPartial } = createFloating({\n kind: \"popover\",\n open: openState,\n onDismiss: props.onDismiss,\n placement: placeState,\n content: props.content,\n // Hovering the panel itself (not just the trigger) must keep it open —\n // handled generically inside floating.ts's behavior instance.\n keepOpenOnContentHover: openOn === \"hover\",\n });\n\n // Page-matching card (shift-0), same as menu/selectList/dialog — not the\n // inverted tooltip/toast surface (shift-17). A dark shift-14 panel wrapping\n // a light menu is the menubar recipe (`popover` + `menu`) rendered as two\n // stacked cards.\n const popoverPartial: PartialElement = {\n role: \"dialog\",\n dataTone: \"shift-0\",\n style: {\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n color: (l: Listener) => themeColor(l, \"text\"),\n borderRadius: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n outline: (l: Listener) => `1px solid ${themeColor(l, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n\n // Content that already owns a surface (`menu()`, `card()`, an authored\n // dataTone) must keep it: stamping this partial on top overwrites\n // `role=menu` with `role=dialog` and comma-joins a second box-shadow\n // (merge concatenates boxShadow).\n if (!contentOwnsSurface(props.content)) {\n props.content.$ ||= [];\n props.content.$.push(popoverPartial);\n }\n\n const triggerPartial: PartialElement = {\n ariaHaspopup: \"dialog\",\n ariaExpanded: (listener) => openState.get(listener),\n // Declared as a reactive attribute (listener.elementNode is the anchor) so\n // it is present from first render — before the panel's first show() — and\n // is re-declared on every patch: attributes set imperatively (the old\n // _onMount attributes.set) are stripped by patch() on ancestor re-render.\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"popover\", listener.elementNode)\n : undefined,\n onMouseEnter: (_e, node) => openOn === \"hover\" && show(node),\n onMouseLeave: (_e, node) => openOn === \"hover\" && hide(node),\n onClick: (_e, node) => {\n if (openOn === \"click\") {\n if (openState.get()) {\n hide(node);\n } else {\n show(node);\n }\n }\n },\n onKeyDown: (e, node) => {\n if ((e as KeyboardEvent).key === \"Escape\" && openState.get()) hide(node);\n },\n onFocus: (_e, node) => openOn === \"hover\" && show(node),\n onBlur: (e, node) => {\n // Docs: focus has no effect when openOn is click — only hover-mode\n // blur dismisses (and even then, not when focus moved INTO the panel).\n if (openOn !== \"hover\") return;\n const related = (e as FocusEvent).relatedTarget as Node | null;\n const root = node.getRoot().domElement as Element;\n // Tabbing from the trigger INTO the panel must not close the popover.\n // The id is deterministic and selector-safe ([a-z0-9-] only — nodeId is\n // a letter + hex hash), so this lookup works for every generation —\n // the old factory-scope `popoverId` was null in any generation whose\n // content _onInsert had never run, letting the guard fall through.\n const floatingEl = root.querySelector(\n `#${floatingPanelId(\"popover\", node)}`,\n );\n if (related && floatingEl?.contains(related)) return;\n hide(node);\n },\n };\n merge(anchorPartial, triggerPartial);\n\n return anchorPartial;\n}\n\nexport { popover };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Renders a small rotated arrow (via a `::after` pseudo-element) that points from a\n * popover/tooltip toward its anchor, positioned and oriented based on the floating placement.\n * The arrow direction is computed by flipping the given placement. No host-tag check is\n * performed; apply it to the popover container element.\n *\n * @param props.placement - Floating placement the popover sits at; the arrow is drawn on the\n * opposite (flipped) side. Accepts a value or reactive state. Defaults to `\"bottom-end\"`.\n * One of: `top` | `bottom` | `left` | `right` | `top-start` | `top-end` | `bottom-start` |\n * `bottom-end` | `left-start` | `left-end` | `right-start` | `right-end`.\n * @param props.sideOffset - CSS length used to offset the arrow toward the start/end edge.\n * Defaults to `themeSpacing(6)`.\n * @param props.color - Theme color tone for the arrow fill and border. Defaults to `\"neutral\"`.\n * @param props.bordered - Whether the arrow draws a 1px border (set to `0px` when false).\n * Defaults to `true`.\n * @example { div: [...], $: [popoverArrow({ placement: \"top\" })] }\n */\nfunction popoverArrow(\n props: {\n placement?: ValueOrState<Placement>;\n sideOffset?: string;\n color?: ThemeColor;\n bordered?: boolean;\n } = {},\n): PartialElement {\n const {\n placement = \"bottom-end\",\n color = \"neutral\",\n sideOffset = themeSpacing(6),\n bordered = true,\n } = props;\n\n const place = toState(placement);\n\n const flipMap: Record<Placement, Placement> = {\n top: \"bottom\",\n bottom: \"top\",\n left: \"right\",\n right: \"left\",\n \"top-start\": \"bottom-end\",\n \"top-end\": \"bottom-start\",\n \"bottom-start\": \"top-end\",\n \"bottom-end\": \"top-start\",\n \"left-start\": \"right-end\",\n \"left-end\": \"right-start\",\n \"right-start\": \"left-end\",\n \"right-end\": \"left-start\",\n };\n\n const getFlipped = (listener: any) =>\n flipMap[place.get(listener)] ?? flipMap[\"bottom-end\"];\n const start = (pos: string) =>\n pos.includes(\"start\") ? sideOffset : pos.includes(\"end\") ? \"auto\" : \"50%\";\n const end = (pos: string) =>\n pos.includes(\"end\") ? sideOffset : pos.includes(\"start\") ? \"auto\" : \"50%\";\n\n return {\n style: {\n fontSize: (listener) => themeSize(listener),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color),\n position: \"relative\",\n \"&::after\": {\n content: `\"\"`,\n position: \"absolute\",\n width: themeSpacing(1.5),\n height: themeSpacing(1.5),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n borderWidth: bordered ? \"1px\" : 0,\n borderColor: (listener) => themeColor(listener, \"border-strong\", color),\n borderTopStyle: (listener) => {\n const pos = getFlipped(listener);\n\n return pos.includes(\"top\") || pos.includes(\"right\")\n ? `solid`\n : \"none\";\n },\n borderBottomStyle: (listener) => {\n const pos = getFlipped(listener);\n\n return pos.includes(\"bottom\") || pos.includes(\"left\")\n ? `solid`\n : \"none\";\n },\n borderLeftStyle: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"top\") || pos.includes(\"left\") ? `solid` : \"none\";\n },\n borderRightStyle: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"bottom\") || pos.includes(\"right\")\n ? `solid`\n : \"none\";\n },\n top: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"top\")\n ? 0\n : pos.includes(\"bottom\")\n ? \"auto\"\n : start(pos);\n },\n right: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"right\")\n ? 0\n : pos.includes(\"left\")\n ? \"auto\"\n : end(pos);\n },\n bottom: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"bottom\")\n ? 0\n : pos.includes(\"top\")\n ? \"auto\"\n : end(pos);\n },\n left: (listener) => {\n const pos = getFlipped(listener);\n return pos.includes(\"left\")\n ? 0\n : pos.includes(\"right\")\n ? \"auto\"\n : start(pos);\n },\n transform: (listener) => {\n const pos = getFlipped(listener);\n const x =\n pos.includes(\"right\") ||\n (pos.includes(\"end\") && !pos.includes(\"left\"))\n ? \"50%\"\n : \"-50%\";\n const y =\n pos.includes(\"bottom\") ||\n (pos.includes(\"end\") && !pos.includes(\"top\"))\n ? \"50%\"\n : \"-50%\";\n return `translate(${x},${y}) rotate(45deg)`;\n },\n },\n },\n };\n}\n\nexport { popoverArrow };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a preformatted text block: inherited font size, themed foreground/background,\n * no border, density-scaled padding and rounded corners.\n *\n * @hostTag pre\n * @param props.color - Theme color tone for text and background. Accepts a value or reactive\n * state. Defaults to `\"neutral\"`.\n * @example { pre: \"const x = 1\", $: [preformated()] }\n */\nfunction preformated(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n dataTone: \"shift-2\",\n _onInsert: (node) => {\n if (node.tagName !== \"pre\") {\n console.warn(`\"preformated\" primitive patch must use pre tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n border: \"none\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n },\n };\n}\n\nexport { preformated };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Styles a native progress bar: full-width, pill-shaped track with a themed fill,\n * including the WebKit progress-bar/value pseudo-elements and a width transition.\n *\n * @hostTag progress\n * @param props.color - Theme color tone for the track/background. Accepts a value or reactive\n * state. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color tone for the filled value. Accepts a value or reactive\n * state. Defaults to `\"primary\"`.\n * @example { progress: null, value: 40, max: 100, $: [progress()] }\n */\nfunction progress(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"progress\") {\n console.warn(`\"progress\" primitive patch must use progress tag`);\n }\n },\n // Track surface — shift via dataTone, paint with inherit.\n dataTone: \"shift-3\",\n style: {\n appearance: \"none\",\n width: \"100%\",\n height: themeSpacing(2),\n border: 0,\n borderRadius: themeSpacing(999),\n overflow: \"hidden\",\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n \"&::-webkit-progress-bar\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n borderRadius: themeSpacing(999),\n },\n \"&::-webkit-progress-value\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-9\", accentColor.get(listener)),\n borderRadius: themeSpacing(999),\n transition: \"width 220ms ease\",\n },\n },\n };\n}\n\nexport { progress };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n rawHtml,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\nconst STAR_FILLED =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" width=\"1em\" height=\"1em\">` +\n `<path d=\"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z\"/>` +\n `</svg>`;\nconst STAR_EMPTY =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" width=\"1em\" height=\"1em\">` +\n `<path d=\"M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z\"/>` +\n `</svg>`;\n\ntype RatingProps = {\n value?: ValueOrState<number>;\n max?: number;\n onChange?: (value: number) => void;\n readOnly?: boolean;\n color?: ThemeColor;\n};\n\ntype RatingLive = {\n valueState: State<number>;\n onChange?: (value: number) => void;\n readOnly: boolean;\n max: number;\n color: ThemeColor;\n};\n\nfunction applyRatingProps(live: RatingLive, next: RatingProps): void {\n live.onChange = next.onChange;\n live.readOnly = next.readOnly ?? false;\n live.max = next.max ?? 5;\n live.color = next.color ?? \"warning\";\n if (isState(next.value)) {\n if (next.value !== live.valueState) {\n live.valueState.set(next.value.get());\n }\n } else if (next.value !== undefined) {\n // Plain number stays live. Omitted value leaves the internal state\n // alone so an uncontrolled click is not reset on a later factory call.\n live.valueState.set(next.value);\n }\n}\n\nfunction insertStar(\n node: ElementNode,\n index: number,\n live: RatingLive,\n hoveredState: State<number>,\n): void {\n const activeCount = (listener: Listener) => {\n const hovered = hoveredState.get(listener);\n return hovered > 0 ? hovered : live.valueState.get(listener);\n };\n\n const star: DomphyElement<\"button\"> = {\n button: (listener) =>\n rawHtml(index <= activeCount(listener) ? STAR_FILLED : STAR_EMPTY),\n _key: index,\n type: \"button\",\n ariaLabel: `${index} star${index > 1 ? \"s\" : \"\"}`,\n onClick: () => {\n if (live.readOnly) return;\n const next = index === live.valueState.get() ? 0 : index;\n live.valueState.set(next);\n live.onChange?.(next);\n hoveredState.set(0);\n },\n onMouseEnter: () => {\n if (live.readOnly) return;\n hoveredState.set(index);\n },\n onMouseLeave: () => hoveredState.set(0),\n onKeyDown: (e: KeyboardEvent) => {\n if (live.readOnly) return;\n const current = live.valueState.get();\n let next = current;\n if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") {\n next = Math.min(live.max, current + 1);\n e.preventDefault();\n } else if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") {\n next = Math.max(0, current - 1);\n e.preventDefault();\n } else {\n return;\n }\n live.valueState.set(next);\n live.onChange?.(next);\n const target = next > 0 ? next - 1 : 0;\n (node.domElement?.children[target] as HTMLElement)?.focus();\n },\n style: {\n background: \"none\",\n border: \"none\",\n outline: \"none\",\n borderRadius: themeSpacing(1),\n padding: 0,\n cursor: \"inherit\",\n color: \"inherit\",\n fontSize: \"inherit\",\n display: \"flex\",\n alignItems: \"center\",\n transition: \"box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, live.color),\n },\n },\n };\n node.children.insert(star);\n}\n\nfunction syncStars(\n node: ElementNode,\n live: RatingLive,\n hoveredState: State<number>,\n): void {\n const children = node.children.items;\n while (children.length > live.max) {\n node.children.remove(children[children.length - 1]);\n }\n for (let index = children.length + 1; index <= live.max; index++) {\n insertStar(node, index, live, hoveredState);\n }\n}\n\n/**\n * Interactive star rating applied to a container `<div>`. Manages its own star\n * children: click to set, Arrow keys to adjust, hover to preview. In `readOnly`\n * mode stars are non-interactive. Apply to a `<div>` element.\n *\n * Star insert runs in `_onInit` (SSR markup). `onChange`/`readOnly`/`max` and\n * a plain-number `value` stay live via `behavior()` `update()` so a reused\n * node picks up the latest factory props.\n *\n * @hostTag div\n * @param props.value - Current rating (0 – max). `ValueOrState<number>`, defaults to `0`.\n * @param props.max - Total number of stars. Optional `number`, defaults to `5`.\n * @param props.onChange - Called with the new value when the user picks a star.\n * @param props.readOnly - Disable interaction. Optional `boolean`, defaults to `false`.\n * @param props.color - Star color tone. Optional `ThemeColor`, defaults to `\"warning\"`.\n * @example { div: null, $: [rating({ value: ratingState, onChange: (v) => ratingState.set(v) })] }\n */\nfunction rating(props: RatingProps = {}): PartialElement {\n const live: RatingLive = {\n valueState: toState(props.value ?? 0),\n onChange: props.onChange,\n readOnly: props.readOnly ?? false,\n max: props.max ?? 5,\n color: props.color ?? \"warning\",\n };\n const hoveredState = toState(0);\n\n return {\n role: \"group\",\n ariaLabel: \"Rating\",\n style: {\n display: \"inline-flex\",\n gap: themeSpacing(0.5),\n // 1.5× inherited control size (theme-owned type scale, not a px/rem literal).\n fontSize: (listener) => themeSize(listener, \"increase-1\"),\n cursor: live.readOnly ? \"default\" : \"pointer\",\n color: (listener) => themeColor(listener, \"muted\", live.color),\n },\n ...behavior<RatingProps>(\n \"rating\",\n (node, initial) => {\n applyRatingProps(live, initial);\n syncStars(node, live, hoveredState);\n return {\n update(next) {\n applyRatingProps(live, next);\n syncStars(node, live, hoveredState);\n },\n };\n },\n {\n value: props.value,\n max: props.max ?? 5,\n onChange: props.onChange,\n readOnly: props.readOnly ?? false,\n color: props.color ?? \"warning\",\n },\n ),\n // Build stars as real child elements (not imperative DOM mutation in\n // _onMount) so generateHTML()/SSR emits the actual star markup.\n _onInit: (node) => {\n syncStars(node, live, hoveredState);\n },\n };\n}\n\nexport { rating };\n","import type { PartialElement, StyleObject } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Circular ring progress indicator rendered via CSS `conic-gradient` and a\n * circular `mask`. Progress starts at 12 o'clock and advances clockwise.\n * Exposes `role=\"progressbar\"` with `aria-valuenow/min/max`. Apply to a `<div>`.\n *\n * @hostTag div\n * @param props.value - Progress percentage 0–100. Accepts a value or reactive state. Defaults to `0`.\n * @param props.color - Theme color for the filled arc. Accepts a value or reactive state. Defaults to `\"primary\"`.\n * @param props.trackColor - Theme color for the background track. Accepts a value or reactive state. Defaults to `\"neutral\"`.\n * @param props.size - Diameter in `themeSpacing` units. Defaults to `16` (= `4em`).\n * @param props.thickness - Ring stroke as a fraction of the radius (0–0.5). Defaults to `0.25`.\n * @example { div: null, $: [ringProgress({ value: 65 })] }\n * @example { div: null, $: [ringProgress({ value: loadingState, color: \"success\", size: 20 })] }\n */\nfunction ringProgress(\n props: {\n value?: ValueOrState<number>;\n color?: ValueOrState<ThemeColor>;\n trackColor?: ValueOrState<ThemeColor>;\n size?: number;\n thickness?: number;\n } = {},\n): PartialElement {\n const { size = 16, thickness = 0.25 } = props;\n const value = toState(props.value ?? 0, \"value\");\n const color = toState(props.color ?? \"primary\", \"color\");\n const trackColor = toState(props.trackColor ?? \"neutral\", \"trackColor\");\n\n // Mask cuts the center to create a donut shape.\n // Uses `closest-side` so the gradient circle matches the visible element circle\n // exactly, making `holePercent` directly represent the fraction of outer radius.\n const holePercent = Math.round((1 - thickness) * 100);\n const mask = `radial-gradient(circle closest-side, transparent ${holePercent}%, black ${holePercent}%)`;\n\n return {\n role: \"progressbar\",\n ariaValuenow: (l) => String(Math.round(value.get(l))),\n ariaValuemin: \"0\",\n ariaValuemax: \"100\",\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn('\"ringProgress\" patch must use div tag');\n }\n },\n style: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: themeSpacing(size),\n height: themeSpacing(size),\n borderRadius: \"50%\",\n // Text color tracks the filled arc so any overlay label inherits it.\n color: (l) => themeColor(l, \"shift-9\", color.get(l)),\n // Fill arc from 12 o'clock clockwise; `from -90deg` rotates the start point.\n background: (l) =>\n `conic-gradient(from -90deg, ${themeColor(l, \"shift-9\", color.get(l))} ${value.get(l)}%, ${themeColor(l, \"shift-3\", trackColor.get(l))} 0%)`,\n WebkitMask: mask,\n mask,\n } as StyleObject,\n };\n}\n\nexport { ringProgress };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeDensity, themeSpacing } from \"@domphy/theme\";\nimport type { FlexAlign, FlexJustify } from \"./stack.js\";\n\n/**\n * A horizontal flex row with spacing between children, vertically centered by\n * default. The general-purpose primitive for icon+label rows, field rows,\n * and button groups — instead of hand-rolling `display: flex; alignItems:\n * center; gap: ...`. `toolbar()` is a semantic alias of this same shape for\n * headers/nav bars. Styles the host only; apply to any block element.\n *\n * @param props.gap - Spacing multiplier for gap between items (default 4).\n * Bounded-control mode (`density: true`, default): `themeSpacing(themeDensity(l) * gap)`\n * — at default density 1.5, gap 4 = 1.5em.\n * Structural/page-column mode (`density: false`): bare `themeSpacing(gap)` with no\n * density multiply — gap 4 = 1em, matching AGENTS.md \"bare themeSpacing(n)\".\n * @param props.align - Cross-axis alignment (`alignItems`). Defaults to `\"center\"`.\n * @param props.justify - Main-axis distribution (`justifyContent`). Unset by default (flex-start).\n * @param props.wrap - Allow items to wrap onto multiple lines. Defaults to `false`.\n * @param props.density - When true (default), gap is multiplied by theme density\n * (bounded controls). When false, gap is structural `themeSpacing(n)` — use this\n * for page/form columns.\n * @example { div: [{ span: \"Icon\" }, { span: \"Label\" }], $: [row()] }\n * @example { div: [...], $: [row({ justify: \"space-between\", wrap: true })] }\n * @example { div: [...], $: [row({ gap: 4, density: false })] }\n */\nfunction row(\n props: {\n gap?: number;\n align?: FlexAlign;\n justify?: FlexJustify;\n wrap?: boolean;\n density?: boolean;\n } = {},\n): PartialElement {\n const {\n gap = 4,\n align = \"center\",\n justify,\n wrap = false,\n density = true,\n } = props;\n return {\n style: {\n display: \"flex\",\n alignItems: align,\n gap: density\n ? (listener) => themeSpacing(themeDensity(listener) * gap)\n : () => themeSpacing(gap),\n ...(justify ? { justifyContent: justify } : {}),\n ...(wrap ? { flexWrap: \"wrap\" } : {}),\n },\n };\n}\n\nexport { row };\nexport type { FlexJustify };\n","import type { PartialElement, StyleObject } from \"@domphy/core\";\nimport { toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSpacing } from \"@domphy/theme\";\n\n/**\n * Applies thin, themed overlay scrollbars to any scrollable container.\n * Covers WebKit (Chrome/Safari/Edge) via `::-webkit-scrollbar` pseudo-elements\n * and Firefox via `scrollbar-width`/`scrollbar-color`. Sets `overflow: auto`.\n * No host-tag check; apply to any block element.\n *\n * @param props.color - Theme color for the scrollbar thumb. Accepts a value or\n * reactive state. Defaults to `\"neutral\"`.\n * @example { div: [...], style: { maxHeight: \"300px\" }, $: [scrollArea()] }\n */\nfunction scrollArea(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n style: {\n overflow: \"auto\",\n // Container text color so theme token usage also carries a reactive `color`.\n color: (l) => themeColor(l, \"text\", color.get(l)),\n \"&::-webkit-scrollbar\": {\n width: themeSpacing(2),\n height: themeSpacing(2),\n },\n \"&::-webkit-scrollbar-track\": {\n background: \"transparent\",\n },\n \"&::-webkit-scrollbar-thumb\": {\n backgroundColor: (l) => themeColor(l, \"shift-5\", color.get(l)),\n borderRadius: themeSpacing(999),\n // Transparent border creates visual padding around the thumb.\n border: `${themeSpacing(0.5)} solid transparent`,\n backgroundClip: \"content-box\",\n },\n \"&::-webkit-scrollbar-thumb:hover\": {\n backgroundColor: (l) => themeColor(l, \"shift-7\", color.get(l)),\n },\n // Firefox thin scrollbar with matching thumb/track colors.\n scrollbarWidth: \"thin\",\n scrollbarColor: (l) =>\n `${themeColor(l, \"shift-5\", color.get(l))} transparent`,\n } as StyleObject,\n };\n}\n\nexport { scrollArea };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One item inside a segmented control. */\ntype SegmentedItem = {\n /** Button label — plain string (auto-wrapped) or any DomphyElement. */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index. */\n key?: string;\n};\n\ntype SegmentedLive = {\n items: SegmentedItem[];\n color: ThemeColor;\n accentColor: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction moveSegment(\n e: Event,\n items: SegmentedItem[],\n key: string,\n value: State<string>,\n): void {\n const k = (e as KeyboardEvent).key;\n if (![\"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = items.map((item, index) => item.key ?? String(index));\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowRight\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowLeft\") next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n value.set(keys[next]);\n const group = (e.target as HTMLElement).closest(\"[role=radiogroup]\");\n group?.querySelectorAll<HTMLElement>(\"[role=radio]\")[next]?.focus();\n}\n\nfunction buildSegmentButtons(\n items: SegmentedItem[],\n value: State<string>,\n color: ThemeColor,\n accentColor: ThemeColor,\n): DomphyElement<\"button\">[] {\n return items.map((item, index) => {\n const key = item.key ?? String(index);\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n button: [labelEl],\n _key: key,\n type: \"button\",\n role: \"radio\",\n ariaChecked: (l: Listener) => value.get(l) === key,\n tabIndex: (l: Listener) => {\n const current = value.get(l);\n if (current === key) return 0;\n if (current === \"\" && key === (items[0]?.key ?? \"\")) return 0;\n return -1;\n },\n onClick: () => value.set(key),\n onKeyDown: (e: Event) => moveSegment(e, items, key, value),\n style: {\n cursor: \"pointer\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: themeSpacing(6),\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(3),\n border: \"none\",\n borderRadius: themeSpacing(10),\n color: (l: Listener) => themeColor(l, \"text\", color),\n backgroundColor: \"transparent\",\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled]):not([aria-checked=true])\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\", color),\n },\n \"&:active:not([disabled]):not([aria-checked=true])\": {\n backgroundColor: (l: Listener) => themeColor(l, \"increase-2\", color),\n },\n \"&[aria-checked=true]\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-0\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-10\", accentColor),\n // Selected segment sits slightly above the track.\n boxShadow: elevation(\"low\"),\n },\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor),\n },\n \"&[aria-checked=true]:focus-visible\": {\n boxShadow: (l: Listener) =>\n `${elevation(\"low\")}, ${focusRing(l, accentColor)}`,\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n } as DomphyElement<\"button\">;\n });\n}\n\n/**\n * All-in-one single-select segmented control. Generates `<button>` option\n * elements from the `items` array. Apply to any wrapper element.\n *\n * @param props.items - Item definitions `{ label, key? }`.\n * @param props.value - Initially selected key (value or State). Defaults to the first item's key.\n * @param props.color - Theme color for the control background. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for the selected item. Defaults to `\"primary\"`.\n * @example\n * { div: null, $: [segmented({ items: [\n * { label: \"Day\", key: \"day\" },\n * { label: \"Month\", key: \"month\" },\n * { label: \"Year\", key: \"year\" },\n * ] })] }\n */\nfunction segmented(\n props: {\n items: SegmentedItem[];\n value?: ValueOrState<string>;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const { items = [], color = \"neutral\", accentColor = \"primary\" } = props;\n const live: SegmentedLive = { items, color, accentColor };\n\n return {\n role: \"radiogroup\",\n // Publish value so descendants can read the selected segment.\n _context: {\n segmented: { value: toState(props.value ?? items[0]?.key ?? \"\") },\n },\n _onSchedule: (node, element) => {\n const value = persistValue(\n node,\n \"segmentedValue\",\n props.value,\n items[0]?.key ?? \"\",\n );\n (element as Record<string, unknown>)[node.tagName] = buildSegmentButtons(\n items,\n value,\n color,\n accentColor,\n );\n },\n ...behavior<SegmentedLive>(\n \"segmented-items\",\n (node) => ({\n update(snapshot) {\n const value = persistValue(\n node,\n \"segmentedValue\",\n props.value,\n snapshot.items[0]?.key ?? \"\",\n );\n node.children.update(\n buildSegmentButtons(\n snapshot.items,\n value,\n snapshot.color,\n snapshot.accentColor,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n // Track is a soft surface anchor — shift via dataTone, paint with inherit.\n dataTone: \"shift-2\",\n style: {\n display: \"inline-flex\",\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(1),\n gap: themeSpacing(0.5),\n borderRadius: themeSpacing(10),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n color: (l: Listener) => themeColor(l, \"text\", color),\n },\n };\n}\n\nexport { segmented };\nexport type { SegmentedItem };\n","import type { Listener, PartialElement } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeColorToken,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a native `<select>` control: removes the default appearance, applies themed\n * colors, outline, density-scaled padding/radius, a custom chevron background icon, and\n * hover/focus/disabled/optgroup/option states.\n *\n * @hostTag select\n * @param props.color - Theme color tone for text, background and outline. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color tone for hover/focus outlines. Defaults to `\"primary\"`.\n * @example { select: [{ option: \"A\" }], $: [select()] }\n */\nfunction select(\n props: { color?: ThemeColor; accentColor?: ThemeColor } = {},\n): PartialElement {\n const { color = \"neutral\", accentColor = \"primary\" } = props;\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"select\") {\n console.warn(`\"select\" primitive patch must use select tag`);\n }\n },\n style: {\n appearance: \"none\",\n fontFamily: \"inherit\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n lineHeight: \"inherit\",\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n border: \"none\",\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color)}`,\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingLeft: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingRight: (listener) => themeSpacing(themeDensity(listener) * 5),\n backgroundImage: (l: Listener) => {\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 10 6\"><path d=\"M1 1l4 4 4-4\" stroke=\"${themeColorToken(l, \"shift-7\")}\" stroke-width=\"1.5\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n return `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`;\n },\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: `right ${themeSpacing(2)} center`,\n backgroundSize: `${themeSpacing(2.5)} ${themeSpacing(1.5)}`,\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:not([multiple])\": {\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor)}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n \"& optgroup\": {\n color: (listener) => themeColor(listener, \"shift-11\", color),\n },\n \"& option[disabled]\": {\n color: (listener) => themeColor(listener, \"shift-7\", \"neutral\"),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n },\n },\n };\n}\n\nexport { select };\n","import {\n type BehaviorInstance,\n behavior,\n type DomphyElement,\n type ElementNode,\n merge,\n type PartialElement,\n type State,\n type StyleObject,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { focusRing } from \"../utils/focusRing.js\";\nimport { tag } from \"./tag.js\";\n\n// Typeahead (Radix Select character-search parity): printable characters\n// accumulate into a buffer that resets after 1s of idle; the buffer is a\n// case-insensitive prefix match against option labels. CLOSED trigger: the\n// match becomes the selection (native <select> behavior). OPEN panel: focus\n// moves to the matching [role=option] — focus is the keyboard highlight.\n// A buffer of one repeated character (\"aaa\") cycles through that char's\n// matches instead of pinning the first; disabled options are skipped.\nconst TYPEAHEAD_RESET_MS = 1000;\n\ntype TypeaheadMeta = {\n buffer: string;\n timer: ReturnType<typeof setTimeout> | null;\n};\n\n// The buffer lives on the NODE (not the factory closure): a selectBox inside\n// a reactive parent gets a fresh closure per ancestor re-render, and a\n// closure-local buffer would silently reset mid-typing on the reused node.\nfunction resolveTypeahead(node: ElementNode): TypeaheadMeta {\n let meta = node.getMetadata(\"selectBoxTypeahead\") as\n | TypeaheadMeta\n | undefined;\n if (!meta) {\n meta = { buffer: \"\", timer: null };\n node.setMetadata(\"selectBoxTypeahead\", meta);\n }\n return meta;\n}\n\nconst matchesPrefix = (label: string, needle: string) =>\n label.trim().toLowerCase().startsWith(needle);\n\nfunction enabledPanelOptions(panel: Element | null): HTMLElement[] {\n if (!panel) return [];\n return Array.from(\n panel.querySelectorAll<HTMLElement>(\"[role=option]\"),\n ).filter(\n (el) =>\n el.getAttribute(\"aria-disabled\") !== \"true\" &&\n !el.hasAttribute(\"disabled\"),\n );\n}\n\n/**\n * A clickable select trigger box that renders the currently selected option(s) as removable\n * tags and toggles a floating popover (the dropdown content) anchored to itself. Selected\n * labels are derived from `options` matching the bound `value`; removing a tag updates the value.\n * Keyboard: Enter/Space toggle, ArrowDown opens, Escape closes, and printable characters\n * typeahead-search options (closed: selects the match; open: focuses the matching\n * `[role=option]` in the panel; a repeated character cycles matches).\n *\n * @hostTag div\n * @param props.multiple - Whether multiple selection is allowed (renders removable tags and\n * keeps the popover open on click). Defaults to `false`.\n * @param props.value - Bound selection value(s). Accepts a value or reactive state of an array of\n * `number | string | null | undefined`, or a single `number | string | null | undefined`.\n * @param props.options - List of `{ label, value }` options used to resolve selected labels.\n * Defaults to `[]`.\n * @param props.placement - Floating placement of the dropdown popover. Accepts a value or\n * reactive state. Defaults to `\"bottom\"`.\n * @param props.content - Required. The popover/dropdown content element shown when open.\n * @param props.color - Theme color tone for the box text/background. Defaults to `\"neutral\"`.\n * @param props.open - Whether the popover is open. Accepts a value or reactive state (`ValueOrState<boolean>`, including `Computed`/`ReadableState`). Defaults to `false`. When the source is read-only, pass `onDismiss` so dismiss can close.\n * @param props.onDismiss - Called when the popover requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @example { div: null, $: [selectBox({ content: { div: [...] }, options: [{ label: \"A\", value: \"a\" }] })] }\n */\nfunction selectBox(props: {\n multiple?: boolean;\n value?: ValueOrState<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n options?: Array<{ label: string; value: string }>;\n placement?: ValueOrState<Placement>;\n content: DomphyElement;\n color?: ThemeColor;\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n}): PartialElement {\n const {\n options = [],\n placement = \"bottom\",\n color = \"neutral\",\n open = false,\n multiple = false,\n } = props;\n\n const state = toState(props.value);\n const openState = toState(open);\n const { show, hide, anchorPartial } = createFloating({\n kind: \"selectBox\",\n open: openState,\n onDismiss: props.onDismiss,\n placement: toState(placement),\n content: props.content,\n });\n\n const popoverPartial: PartialElement = {\n onClick: (_e, node) => !multiple && hide(node),\n dataTone: \"shift-0\",\n style: {\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n // Surface contract (dataTone-surface-contract): a tone-anchored panel\n // must declare BOTH background and text color. Page-matching shift-0\n // (same as menu/selectList/dialog), not the inverted tooltip surface.\n color: (listener) => themeColor(listener, \"text\"),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\")}`,\n outlineOffset: \"-1px\",\n boxShadow: elevation(\"medium\"),\n },\n };\n\n merge(props.content, popoverPartial);\n\n type InnerProps = {\n options: Array<{ label: string; value: string }>;\n multiple: boolean;\n color: ThemeColor;\n state: State<\n | Array<number | string | null | undefined>\n | number\n | string\n | null\n | undefined\n >;\n };\n\n const buildWrap = (inner: InnerProps): DomphyElement<\"div\"> => ({\n div: (listener) => {\n const val = inner.state.get(listener);\n const vals = Array.isArray(val) ? val : [val];\n const opts = inner.options.filter((opt) => vals.includes(opt.value));\n return opts.map((opt) => ({\n span: opt.label,\n $: [tag({ color: inner.color, removable: inner.multiple })],\n _key: opt.value,\n _onRemove: (_node: ElementNode) => {\n const cur = inner.state.get();\n const curVals = Array.isArray(cur) ? cur : [cur];\n const filter = curVals.filter((v) => v !== opt.value);\n inner.multiple\n ? inner.state.set(filter as any)\n : inner.state.set(filter[0] as any);\n },\n })) as DomphyElement<\"span\">[];\n },\n _key: \"selectBoxWrap\",\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: themeSpacing(1),\n flex: 1,\n } as StyleObject,\n });\n\n const attachInner = (\n node: ElementNode,\n _inner: InnerProps,\n ): BehaviorInstance<InnerProps> => {\n return {\n update(next) {\n node.children.update([buildWrap(next)]);\n },\n };\n };\n\n const toggle = (node?: ElementNode) =>\n openState.get() ? hide(node) : show(node);\n\n const typeahead = (key: string, node: ElementNode) => {\n const meta = resolveTypeahead(node);\n if (meta.timer) clearTimeout(meta.timer);\n meta.buffer += key.toLowerCase();\n meta.timer = setTimeout(() => {\n meta.buffer = \"\";\n }, TYPEAHEAD_RESET_MS);\n // \"aaa\" cycles through the a* matches rather than matching \"aaa\" literally.\n const repeated = meta.buffer.length > 1 && new Set(meta.buffer).size === 1;\n const needle = repeated ? meta.buffer[0]! : meta.buffer;\n\n if (openState.get()) {\n // Panel is portaled under the root (see floating.ts); its id is\n // deterministic, same lookup pattern as popover's onBlur guard.\n const root = node.getRoot().domElement as Element | null;\n const panel =\n root?.querySelector(`#${floatingPanelId(\"selectBox\", node)}`) ?? null;\n const matches = enabledPanelOptions(panel).filter((el) =>\n matchesPrefix(el.textContent ?? \"\", needle),\n );\n if (!matches.length) return;\n const active = node.domElement?.ownerDocument\n ?.activeElement as HTMLElement | null;\n const from = repeated && active ? matches.indexOf(active) : -1;\n const target = matches[(from + 1) % matches.length]!;\n target.focus();\n target.scrollIntoView?.({ block: \"nearest\" });\n return;\n }\n\n // Closed trigger: selection follows typeahead. Single-select only — a\n // multi-select tag set has no \"current option\" to move from.\n if (multiple) return;\n const matches = options.filter((opt) => matchesPrefix(opt.label, needle));\n if (!matches.length) return;\n const from = repeated\n ? matches.findIndex((opt) => opt.value === state.get())\n : -1;\n const next = matches[(from + 1) % matches.length]!;\n state.set(next.value as any);\n };\n\n const partial: PartialElement = {\n _onInsert: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"selectBox\" patch must use div tag`);\n }\n },\n _onSchedule: (node, element) => {\n (element as Record<string, unknown>)[node.tagName] = [\n buildWrap({ options, multiple, color, state }),\n ];\n },\n ...behavior<InnerProps>(\"selectBoxInner\", attachInner, {\n options,\n multiple,\n color,\n state,\n }),\n onClick: (_e, node) => toggle(node),\n // Focusable trigger: click + Enter/Space/ArrowDown open (APG button+listbox).\n // Escape dismiss composes with createFloating's hide path.\n tabindex: 0,\n role: \"button\",\n // Reactive boolean (same pattern as popover) — do NOT pin a static\n // ariaExpanded or patch re-apply will overwrite after keyboard open.\n ariaExpanded: (listener) => openState.get(listener),\n ariaHaspopup: \"listbox\",\n ariaControls: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"selectBox\", listener.elementNode)\n : undefined,\n onKeyDown: (e, node) => {\n const key = (e as KeyboardEvent).key;\n if (key === \"Escape\") {\n hide(node);\n return;\n }\n if (key === \"Enter\" || key === \" \") {\n e.preventDefault();\n toggle(node);\n return;\n }\n if (key === \"ArrowDown\" && !openState.get()) {\n e.preventDefault();\n show(node);\n return;\n }\n // Character typeahead (Radix Select parity) — modifier chords are\n // shortcuts, not search input.\n const kb = e as KeyboardEvent;\n if (key.length === 1 && !kb.ctrlKey && !kb.metaKey && !kb.altKey) {\n typeahead(key, node);\n }\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n minHeight: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n minWidth: themeSpacing(32),\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 2),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n transition:\n \"background-color 140ms ease, outline-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, color),\n },\n },\n };\n\n merge(anchorPartial, partial);\n return anchorPartial;\n}\n\nexport { selectBox };\n","import type { PartialElement } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * A single selectable option row (`role=\"option\"`) for use inside a `selectList`. Reads the\n * `select` context to reflect/toggle selection: it sets `aria-selected` from the bound value and\n * toggles the value (single or multiple) on click. Styles hover/selected/focus states.\n *\n * @hostTag div\n * @param props.accentColor - Theme color tone for the selected/focus state. Defaults to `\"primary\"`.\n * @param props.color - Theme color tone for text/background. Defaults to `\"neutral\"`.\n * @param props.value - The option value compared against and written to the select state.\n * Defaults to `null`.\n * @example { div: \"Option A\", $: [selectItem({ value: \"a\" })] }\n */\nfunction selectItem(\n props: {\n accentColor?: ThemeColor;\n color?: ThemeColor;\n value?: number | string;\n } = {},\n): PartialElement {\n const { accentColor = \"primary\", color = \"neutral\", value = null } = props;\n\n const partial: PartialElement = {\n role: \"option\",\n // Programmatically focusable (not tabbable): selectBox typeahead and\n // keyboard navigation move focus between options roving-style.\n tabindex: -1,\n // aria-selected and the click toggler must be DECLARED on the partial, not\n // wired imperatively in _onInit: hooks run once per real DOM node, but\n // patch() resets _events and strips undeclared attributes on every\n // ancestor re-render — so imperative wiring was lost on the first reuse\n // while the (once-run) hook never re-installed it. The reactive reader\n // resolves the `select` context lazily through listener.elementNode, so\n // every generation re-binds to whatever context is actually live.\n ariaSelected: (listener) => {\n const select = listener?.elementNode?.getContext(\"select\");\n if (!select) return undefined;\n const val = select.value.get(listener);\n return select.multiple ? val.includes(value) : val === value;\n },\n onClick: (_e, node) => {\n const select = node.getContext(\"select\");\n if (!select) return;\n const state = select.value;\n const val = state.get();\n if (select.multiple) {\n val.includes(value)\n ? state.set(val.filter((v: number | string) => v !== value))\n : state.set(val.concat([value]));\n } else {\n val !== value && state.set(value);\n }\n },\n _onInit: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"selectItem\" patch must use div tag`);\n }\n },\n style: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n height: (listener) => themeSpacing(6 + themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n border: \"none\",\n outline: \"none\",\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n \"&:hover:not([disabled]):not([aria-selected=true])\": {\n backgroundColor: (listener) => themeColor(listener, \"hover\", color),\n },\n \"&[aria-selected=true]\": {\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-6\", accentColor),\n color: (listener) => themeColor(listener, \"shift-11\"),\n },\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor),\n },\n },\n };\n return partial;\n}\n\nexport { selectItem };\n","import {\n type DomphyElement,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Container for a list of `selectItem`s that owns the selection state. It exposes a `select`\n * context (`{ value, multiple }`) consumed by child items, and injects hidden `<input>`(s)\n * carrying the selected value(s) under `name` for form submission.\n *\n * @hostTag div\n * @param props.multiple - Whether multiple selection is allowed; also sets the default empty\n * value (`[]` vs `null`). Defaults to `false`.\n * @param props.value - Bound selection value(s). Accepts a value or reactive state of an array of\n * `number | string | null`, or a single `number | string | null`. Defaults to `[]` when\n * `multiple`, otherwise `null`.\n * @param props.color - Theme color tone for the background. Defaults to `\"neutral\"`.\n * @param props.name - Name attribute for the hidden inputs (form field name).\n * @example { div: [{ div: \"A\", $: [selectItem({ value: \"a\" })] }], $: [selectList({ name: \"pick\" })] }\n */\nfunction selectList(\n props: {\n multiple?: boolean;\n value?: ValueOrState<\n Array<number | string | null> | number | string | null\n >;\n color?: ThemeColor;\n name?: string;\n } = {},\n): PartialElement {\n const { color = \"neutral\", multiple = false } = props;\n const state = toState(props.value ?? (multiple ? [] : null));\n\n // type=hidden form fields (not a visible input) — avoid axe label/listbox noise.\n const inputs: DomphyElement<\"div\"> = {\n div: (listener) => {\n const val = state.get(listener);\n const vals = Array.isArray(val) ? val : [val];\n return vals.map((v) => ({\n input: null,\n type: \"hidden\",\n name: props.name,\n // Preserve a legitimate numeric 0 (and other falsy-but-valid values);\n // `v || \"\"` would drop them.\n value: v == null ? \"\" : String(v),\n }));\n },\n // Keep out of the a11y tree; listbox children must be options.\n ariaHidden: \"true\",\n hidden: true,\n };\n\n const partial: PartialElement = {\n dataTone: \"shift-0\",\n // selectItem uses role=option; options require a listbox parent (WAI-ARIA).\n role: \"listbox\",\n ariaLabel: \"Options\",\n ariaMultiselectable: multiple ? \"true\" : undefined,\n _context: {\n select: {\n value: state,\n multiple,\n },\n },\n _onInit: (node) => {\n if (node.tagName !== \"div\") {\n console.warn(`\"selectList\" patch must use a div tag`);\n }\n node.children.insert(inputs);\n },\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n color: (listener) => themeColor(listener, \"text\", color),\n },\n };\n return partial;\n}\n\nexport { selectList };\n","import {\n hashString,\n type PartialElement,\n type StyleObject,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * A loading placeholder block with a left-to-right shimmer gradient. Marked\n * `aria-hidden`, themed background/foreground, fixed height, slight rounding.\n * No host-tag check; typically applied to a block-level element such as a\n * `div` or `span`.\n *\n * @param props.color - Theme color tone for the placeholder. Accepts a value or reactive state.\n * Defaults to `\"neutral\"`.\n * @example { div: null, $: [skeleton()] }\n */\nfunction skeleton(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n // Shimmer sweeps left→right over a near-white base (reads as loading, not\n // a flat opacity blink). Base + highlight are both theme tokens so the\n // effect adapts to light/dark surfaces. Highlight stays close to the base\n // (shift-2) — a deeper step reads as dirty banding on light themes.\n const keyframes = {\n \"0%\": { backgroundPosition: \"200% 0\" },\n \"100%\": { backgroundPosition: \"-200% 0\" },\n };\n const animationName = hashString(JSON.stringify(keyframes));\n return {\n ariaHidden: \"true\",\n dataTone: \"shift-1\",\n style: {\n fontSize: (listener) => themeSize(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n height: themeSpacing(6),\n display: \"block\",\n borderRadius: themeSpacing(1),\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n backgroundImage: (listener) =>\n `linear-gradient(90deg, ${themeColor(listener, \"inherit\", color.get(listener))} 0%, ${themeColor(listener, \"shift-2\", color.get(listener))} 50%, ${themeColor(listener, \"inherit\", color.get(listener))} 100%)`,\n backgroundSize: \"200% 100%\",\n animation: `${animationName} 1.6s ease-in-out infinite`,\n [`@keyframes ${animationName}`]: keyframes,\n } as StyleObject,\n };\n}\n\nexport { skeleton };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Styles small/secondary text: one step smaller font size (`data-size=\"decrease-1\"`) with a\n * themed foreground color.\n *\n * @hostTag small\n * @param props.color - Theme color tone for the text. Accepts a value or reactive state.\n * Defaults to `\"neutral\"`.\n * @example { small: \"fine print\", $: [small()] }\n */\nfunction small(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"small\") {\n console.warn('\"small\" patch must use small tag');\n }\n },\n dataSize: \"decrease-1\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n // shift-10 (not muted/shift-8) keeps WCAG AA ≥4.5:1 on light surfaces for small type.\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n },\n };\n}\n\nexport { small };\n","import type { PartialElement, StyleObject } from \"@domphy/core\";\nimport { hashString, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\nconst keyframes = { to: { transform: \"rotate(360deg)\" } };\nconst animationName = hashString(JSON.stringify(keyframes));\n\n/**\n * A circular loading spinner: a themed ring with a contrasting top border that rotates\n * continuously. Marked `role=\"status\"` with `aria-label=\"loading\"`.\n *\n * @hostTag span\n * @param props.color - Theme color tone for the ring/highlight. Accepts a value or reactive\n * state. Defaults to `\"neutral\"`.\n * @example { span: null, $: [spinner()] }\n */\nfunction spinner(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n role: \"status\",\n ariaLabel: \"loading\",\n _onInsert: (node) => {\n if (node.tagName !== \"span\") {\n console.warn(`\"spinner\" patch must use span tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n display: \"inline-block\",\n margin: 0,\n flexShrink: 0,\n width: themeSpacing(6),\n height: themeSpacing(6),\n borderRadius: \"50%\",\n border: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n borderTopColor: (listener) =>\n themeColor(listener, \"shift-9\", color.get(listener)),\n boxSizing: \"border-box\",\n padding: 0,\n animation: `${animationName} 0.7s linear infinite`,\n [`@keyframes ${animationName}`]: keyframes,\n } as StyleObject,\n };\n}\n\nexport { spinner };\n","import { ElementNode, merge, type PartialElement, toState } from \"@domphy/core\";\nimport { themeColor, themeSpacing } from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Root of a resizable split layout. Lays out children as a flex row (horizontal) or column\n * (vertical) and provides a `splitter` context (`{ direction, size, min, max }`) consumed by\n * `splitterPanel` and `splitterHandle`. `size` is a reactive state holding the first panel's\n * percentage. No host-tag check; typically applied to a `div`.\n *\n * @param props.direction - Split orientation, `\"horizontal\"` | `\"vertical\"`. Defaults to `\"horizontal\"`.\n * @param props.defaultSize - Initial size (percentage) of the resizable panel. Defaults to `50`.\n * @param props.min - Minimum panel size (percentage). Defaults to `10`.\n * @param props.max - Maximum panel size (percentage). Defaults to `90`.\n * @example { div: [...], $: [splitter({ direction: \"vertical\" })] }\n */\nfunction splitter(\n props: {\n direction?: \"horizontal\" | \"vertical\";\n defaultSize?: number;\n min?: number;\n max?: number;\n } = {},\n): PartialElement {\n const {\n direction = \"horizontal\",\n defaultSize = 50,\n min = 10,\n max = 90,\n } = props;\n return {\n _onSchedule: (_node, element) => {\n merge(element, {\n _context: {\n splitter: {\n direction,\n size: toState(defaultSize),\n min,\n max,\n // Legacy bookkeeping kept on the context object for compatibility.\n // First-vs-second assignment uses sibling order (see splitterPanel).\n panelCount: 0,\n },\n },\n });\n },\n style: {\n display: \"flex\",\n flexDirection: direction === \"horizontal\" ? \"row\" : \"column\",\n overflow: \"hidden\",\n },\n };\n}\n\n/**\n * The resizable panel inside a `splitter`. Reads the `splitter` context and binds its\n * width (horizontal) or height (vertical) to the context `size` state, updating reactively as\n * the handle is dragged. Intended for exactly two panels either side of one `splitterHandle`:\n * the first `splitterPanel` mounted takes `size`%, and the second takes the complementary\n * `100 - size`% — so the pair always sums to the full width/height instead of both tracking\n * the same number (which would make them grow and shrink together instead of trading space).\n * Warns if used outside a `splitter`. Takes no props.\n *\n * @example { div: [...], $: [splitterPanel()] }\n */\nfunction isFirstSplitterPanel(node: ElementNode): boolean {\n const parent = node.parent;\n if (!parent) return true;\n for (const item of parent.children.items) {\n if (item instanceof ElementNode && item.getMetadata(\"splitterPanel\")) {\n return item === node;\n }\n }\n return true;\n}\n\nfunction splitterPanel(): PartialElement {\n return {\n _metadata: { splitterPanel: true },\n _onMount: (node) => {\n const ctx = node.getContext(\"splitter\");\n if (!ctx) {\n console.warn(`\"splitterPanel\" patch must be used inside a \"splitter\"`);\n return;\n }\n const el = node.domElement as HTMLElement;\n const prop = ctx.direction === \"horizontal\" ? \"width\" : \"height\";\n\n const apply = (size: number) => {\n el.style[prop] = `${isFirstSplitterPanel(node) ? size : 100 - size}%`;\n };\n apply(ctx.size.get());\n el.style.flexShrink = \"0\";\n el.style.overflow = \"auto\";\n\n const release = ctx.size.addListener(apply);\n node.addHook(\"Remove\", () => {\n ctx.panelCount = Math.max(0, (ctx.panelCount ?? 1) - 1);\n release();\n });\n },\n };\n}\n\n/**\n * The draggable divider inside a `splitter`. Reads the `splitter` context, shows the\n * appropriate resize cursor, and updates the context `size` state (clamped to `min`/`max`)\n * via mouse drag or keyboard: Arrow keys move by 1%, Home/End jump to min/max, hold Shift\n * for 10× step. Sets `role=\"separator\"`, `tabindex=\"0\"`, and `aria-value*` attributes.\n * Warns if used outside a `splitter`. Takes no props.\n *\n * @example { div: null, $: [splitterHandle()] }\n */\nfunction splitterHandle(): PartialElement {\n return {\n role: \"separator\",\n tabindex: 0,\n _onMount: (node) => {\n const ctx = node.getContext(\"splitter\");\n if (!ctx) {\n console.warn(`\"splitterHandle\" patch must be used inside a \"splitter\"`);\n return;\n }\n const handle = node.domElement as HTMLElement;\n const isHorizontal = ctx.direction === \"horizontal\";\n\n handle.style.cursor = isHorizontal ? \"col-resize\" : \"row-resize\";\n handle.setAttribute(\n \"aria-orientation\",\n isHorizontal ? \"vertical\" : \"horizontal\",\n );\n handle.setAttribute(\"aria-valuemin\", String(ctx.min));\n handle.setAttribute(\"aria-valuemax\", String(ctx.max));\n handle.setAttribute(\"aria-valuenow\", String(Math.round(ctx.size.get())));\n\n const releaseAriaValue = ctx.size.addListener((size: number) => {\n handle.setAttribute(\"aria-valuenow\", String(Math.round(size)));\n });\n\n const onKeydown = (e: KeyboardEvent) => {\n const step = e.shiftKey ? 10 : 1;\n let next: number | null = null;\n if (isHorizontal) {\n if (e.key === \"ArrowRight\")\n next = Math.min(ctx.size.get() + step, ctx.max);\n else if (e.key === \"ArrowLeft\")\n next = Math.max(ctx.size.get() - step, ctx.min);\n } else {\n if (e.key === \"ArrowDown\")\n next = Math.min(ctx.size.get() + step, ctx.max);\n else if (e.key === \"ArrowUp\")\n next = Math.max(ctx.size.get() - step, ctx.min);\n }\n if (e.key === \"Home\") next = ctx.min;\n else if (e.key === \"End\") next = ctx.max;\n if (next !== null) {\n e.preventDefault();\n ctx.size.set(next);\n }\n };\n\n let cancelDrag: (() => void) | null = null;\n\n const onMousedown = (e: MouseEvent) => {\n e.preventDefault();\n const container = handle.parentElement!;\n\n const onMousemove = (e: MouseEvent) => {\n const rect = container.getBoundingClientRect();\n const raw = isHorizontal\n ? ((e.clientX - rect.left) / rect.width) * 100\n : ((e.clientY - rect.top) / rect.height) * 100;\n ctx.size.set(Math.min(Math.max(raw, ctx.min), ctx.max));\n };\n\n const onMouseup = () => {\n document.removeEventListener(\"mousemove\", onMousemove);\n document.removeEventListener(\"mouseup\", onMouseup);\n cancelDrag = null;\n };\n\n cancelDrag = () => {\n document.removeEventListener(\"mousemove\", onMousemove);\n document.removeEventListener(\"mouseup\", onMouseup);\n cancelDrag = null;\n };\n\n document.addEventListener(\"mousemove\", onMousemove);\n document.addEventListener(\"mouseup\", onMouseup);\n };\n\n handle.addEventListener(\"keydown\", onKeydown);\n handle.addEventListener(\"mousedown\", onMousedown);\n node.addHook(\"Remove\", () => {\n cancelDrag?.();\n releaseAriaValue();\n handle.removeEventListener(\"keydown\", onKeydown);\n handle.removeEventListener(\"mousedown\", onMousedown);\n });\n },\n // Soft divider surface — shift via dataTone, paint with inherit.\n dataTone: \"shift-2\",\n style: {\n flexShrink: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\"),\n \"&:hover\": {\n backgroundColor: (listener) => themeColor(listener, \"increase-1\"),\n },\n transition: \"background-color 140ms ease, box-shadow 140ms ease\",\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, \"primary\"),\n },\n \"&::after\": {\n content: '\"\"',\n // A small grip dot so the handle is visibly draggable. Without an\n // explicit size the pseudo-element collapses to 0x0 and is invisible.\n width: themeSpacing(1),\n height: themeSpacing(1),\n borderRadius: themeSpacing(999),\n backgroundColor: (listener) => themeColor(listener, \"shift-4\"),\n },\n },\n };\n}\n\nexport { splitter, splitterPanel, splitterHandle };\n","import type { PartialElement } from \"@domphy/core\";\nimport { themeDensity, themeSpacing } from \"@domphy/theme\";\n\ntype FlexAlign = \"flex-start\" | \"center\" | \"flex-end\" | \"stretch\" | \"baseline\";\n\ntype FlexJustify =\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n\n/**\n * A vertical flex column with spacing between children. The general-purpose\n * primitive for stacking blocks — form sections, panel content, card bodies —\n * instead of hand-rolling `display: flex; flexDirection: column; gap: ...`.\n * Styles the host only; apply to any block element.\n *\n * @param props.gap - Spacing multiplier for gap between children (default 3).\n * Bounded-control mode (`density: true`, default): `themeSpacing(themeDensity(l) * gap)`\n * — at default density 1.5, gap 3 = 1.125em.\n * Structural/page-column mode (`density: false`): bare `themeSpacing(gap)` with no\n * density multiply — gap 3 = 0.75em, matching AGENTS.md \"bare themeSpacing(n)\".\n * @param props.align - Cross-axis alignment (`alignItems`). Unset by default (flex default, stretch).\n * @param props.justify - Main-axis distribution (`justifyContent`). Unset by default (flex-start).\n * @param props.density - When true (default), gap is multiplied by theme density\n * (bounded controls). When false, gap is structural `themeSpacing(n)` — use this\n * for page/form columns.\n * @example { div: [{ h3: \"Title\" }, { p: \"Body\" }], $: [stack()] }\n * @example { div: [...], $: [stack({ gap: 2, align: \"center\" })] }\n * @example { div: [...], $: [stack({ gap: 3, density: false, justify: \"space-between\" })] }\n */\nfunction stack(\n props: {\n gap?: number;\n align?: FlexAlign;\n justify?: FlexJustify;\n density?: boolean;\n } = {},\n): PartialElement {\n const { gap = 3, align, justify, density = true } = props;\n return {\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: density\n ? (listener) => themeSpacing(themeDensity(listener) * gap)\n : () => themeSpacing(gap),\n ...(align ? { alignItems: align } : {}),\n ...(justify ? { justifyContent: justify } : {}),\n },\n };\n}\n\nexport { stack };\nexport type { FlexAlign, FlexJustify };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/** One step entry. */\ntype StepItem = {\n /** Step label — plain string (auto-wrapped) or any DomphyElement. */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index. */\n key?: string | number;\n};\n\ntype StepsLive = {\n items: StepItem[];\n direction: \"horizontal\" | \"vertical\";\n color: ThemeColor;\n accentColor: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction stepConnectorStyle(\n direction: \"horizontal\" | \"vertical\",\n color: ThemeColor,\n accentColor: ThemeColor,\n) {\n if (direction === \"vertical\") {\n // Outgoing track: from this badge's bottom through the host gap to the\n // next badge. Incoming-from-current-item cannot span the previous\n // item's variable label height.\n return {\n \"&:not(:last-child)::after\": {\n content: '\"\"',\n position: \"absolute\",\n left: themeSpacing(3),\n top: themeSpacing(6),\n bottom: `-${themeSpacing(2)}`,\n width: \"2px\",\n height: \"auto\",\n right: \"auto\",\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\", color),\n zIndex: \"0\",\n },\n \"&[data-status=done]:not(:last-child)::after\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n },\n };\n }\n return {\n \"&:not(:first-child)::after\": {\n content: '\"\"',\n position: \"absolute\",\n top: themeSpacing(3),\n right: `calc(50% + ${themeSpacing(3)})`,\n left: `calc(-50% + ${themeSpacing(3)})`,\n height: \"2px\",\n backgroundColor: (l: Listener) => themeColor(l, \"shift-3\", color),\n zIndex: \"0\",\n },\n \"&[data-status=done]:not(:first-child)::after\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n },\n \"&[data-status=active]:not(:first-child)::after\": {\n backgroundColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n },\n };\n}\n\nfunction buildStepItems(\n items: StepItem[],\n current: State<number>,\n direction: \"horizontal\" | \"vertical\",\n color: ThemeColor,\n accentColor: ThemeColor,\n): DomphyElement<\"li\">[] {\n const vertical = direction === \"vertical\";\n const connector = stepConnectorStyle(direction, color, accentColor);\n\n return items.map((item, index) => {\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n li: [labelEl],\n _key: item.key ?? index,\n dataStep: String(index + 1),\n dataStatus: (l: Listener) => {\n const cur = current.get(l);\n if (index < cur) return \"done\";\n if (index === cur) return \"active\";\n return \"pending\";\n },\n ariaCurrent: (l: Listener) =>\n current.get(l) === index ? \"step\" : undefined,\n style: {\n position: \"relative\",\n display: \"flex\",\n flexDirection: vertical ? \"row\" : \"column\",\n alignItems: vertical ? \"flex-start\" : \"center\",\n gap: themeSpacing(1),\n flex: vertical ? \"none\" : \"1\",\n fontSize: (l: Listener) => themeSize(l, \"decrease-1\"),\n textAlign: vertical ? \"left\" : \"center\",\n \"&::before\": {\n content: \"attr(data-step)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: themeSpacing(6),\n height: themeSpacing(6),\n borderRadius: themeSpacing(999),\n fontSize: (l: Listener) => themeSize(l, \"decrease-1\"),\n fontWeight: \"bold\",\n flexShrink: \"0\",\n border: (l: Listener) =>\n `2px solid ${themeColor(l, \"border-strong\", color)}`,\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n color: (l: Listener) => themeColor(l, \"muted\"),\n transition:\n \"background-color 200ms ease, color 200ms ease, border-color 200ms ease\",\n zIndex: \"1\",\n },\n ...connector,\n \"&[data-status=active]::before\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-9\", accentColor),\n borderColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-0\", accentColor),\n boxShadow: (l: Listener) =>\n `0 0 0 3px ${themeColor(l, \"shift-3\", accentColor)}`,\n },\n // Completed steps: filled accent + check, matching active track.\n \"&[data-status=done]::before\": {\n content: '\"✓\"',\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-9\", accentColor),\n borderColor: (l: Listener) => themeColor(l, \"shift-9\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-0\", accentColor),\n },\n \"&[data-status=pending]\": {\n color: (l: Listener) => themeColor(l, \"muted\"),\n },\n \"&[data-status=active]\": {\n color: (l: Listener) => themeColor(l, \"shift-11\", accentColor),\n fontWeight: \"bold\",\n },\n \"&[data-status=done]\": {\n color: (l: Listener) => themeColor(l, \"text\", color),\n },\n },\n } as DomphyElement<\"li\">;\n });\n}\n\n/**\n * All-in-one step-progress indicator. Generates `<li>` step elements from the\n * `items` array. Apply to an `<ol>` or `<ul>` element.\n *\n * @param props.items - Step definitions `{ label, key? }`.\n * @param props.current - Zero-based index of the active step (value or State). Defaults to `0`.\n * @param props.direction - `\"horizontal\"` (default) or `\"vertical\"` layout.\n * @param props.color - Theme color for pending/track elements. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for active/completed elements. Defaults to `\"primary\"`.\n * @example\n * { ol: null, $: [steps({ current: 1, items: [\n * { label: \"Cart\" },\n * { label: \"Shipping\" },\n * { label: \"Payment\" },\n * ] })] }\n */\nfunction steps(\n props: {\n items: StepItem[];\n current?: ValueOrState<number>;\n direction?: \"horizontal\" | \"vertical\";\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const {\n items = [],\n direction = \"horizontal\",\n color = \"neutral\",\n accentColor = \"primary\",\n } = props;\n const live: StepsLive = { items, direction, color, accentColor };\n\n return {\n // Step badge weight is design-system chrome for the progress control.\n _doctorDisable: \"inline-typography\",\n // Publish current/direction/colors so descendants can read the indicator.\n _context: {\n steps: {\n current: toState(props.current ?? 0),\n direction,\n color,\n accentColor,\n },\n },\n _onSchedule: (node, element) => {\n const current = persistValue(node, \"stepsCurrent\", props.current, 0);\n (element as Record<string, unknown>)[node.tagName] = buildStepItems(\n items,\n current,\n direction,\n color,\n accentColor,\n );\n },\n ...behavior<StepsLive>(\n \"steps-items\",\n (node) => ({\n update(snapshot) {\n const current = persistValue(node, \"stepsCurrent\", props.current, 0);\n node.children.update(\n buildStepItems(\n snapshot.items,\n current,\n snapshot.direction,\n snapshot.color,\n snapshot.accentColor,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n style: {\n display: \"flex\",\n flexDirection: direction === \"vertical\" ? \"column\" : \"row\",\n alignItems: direction === \"vertical\" ? \"flex-start\" : \"center\",\n gap: themeSpacing(2),\n listStyle: \"none\",\n margin: \"0\",\n padding: \"0\",\n },\n };\n}\n\nexport { steps };\nexport type { StepItem };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Styles strongly emphasized (bold) text: inherited font size, `font-weight: 700`, and a\n * themed foreground color.\n *\n * @hostTag strong\n * @param props.color - Theme color tone for the text. Accepts a value or reactive state.\n * Defaults to `\"neutral\"`.\n * @example { strong: \"important\", $: [strong()] }\n */\nfunction strong(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"strong\") {\n console.warn(`\"strong\" primitive patch must use strong tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n fontWeight: \"bold\",\n color: (listener) =>\n themeColor(listener, \"shift-11\", color.get(listener)),\n backgroundColor: (listener) => themeColor(listener),\n },\n };\n}\n\nexport { strong };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Renders subscript text (shrunk, baseline-lowered) for the host `<sub>` element.\n *\n * @hostTag sub\n * @param props.color - Theme color for the text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { sub: \"2\", $: [subscript()] }\n */\nfunction subscript(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"sub\") {\n console.warn(`\"subscript\" primitive patch must use sub tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n verticalAlign: \"sub\",\n lineHeight: 0,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { subscript };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport { type ThemeColor, themeColor, themeSize } from \"@domphy/theme\";\n\n/**\n * Renders superscript text (shrunk, baseline-raised) for the host `<sup>` element.\n *\n * @hostTag sup\n * @param props.color - Theme color for the text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { sup: \"2\", $: [superscript()] }\n */\nfunction superscript(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"sup\") {\n console.warn(`\"superscript\" primitive patch must use sup tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"decrease-1\"),\n verticalAlign: \"super\",\n lineHeight: 0,\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n },\n };\n}\n\nexport { superscript };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a data table (header/body/footer cells, caption, row hover, borders)\n * on the host `<table>` element.\n *\n * @hostTag table\n * @param props.color - Theme color applied across cells and text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { table: null, $: [table()] }\n */\nfunction table(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"table\") {\n console.warn(`\"table\" primitive patch must use table tag`);\n }\n },\n // Header/footer weights are design-system table chrome.\n _doctorDisable: \"inline-typography\",\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n width: \"100%\",\n borderCollapse: \"collapse\",\n \"& caption\": {\n captionSide: \"bottom\",\n },\n \"& th, & thead td\": {\n textAlign: \"left\",\n fontWeight: 500,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n color: (listener) =>\n themeColor(listener, \"shift-10\", color.get(listener)),\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n },\n \"& td\": {\n textAlign: \"left\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n boxShadow: (listener) =>\n `inset 0 1px 0 ${themeColor(listener, \"shift-3\", color.get(listener))}`,\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n },\n \"& tfoot th, & tfoot td\": {\n textAlign: \"left\",\n fontWeight: 500,\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n color: (l) => themeColor(l, \"shift-10\", color.get(l)),\n backgroundColor: (l) => themeColor(l, \"inherit\"),\n boxShadow: (l) =>\n `inset 0 -1px 0 ${themeColor(l, \"shift-4\", color.get(l))}`,\n },\n \"& tr\": {\n backgroundColor: (listener) => themeColor(listener, \"inherit\"),\n },\n\n // No !important needed: \".scope tbody tr:hover\" (two classes + two\n // elements) already out-specifies any row's own auto-scope class rule.\n \"& tbody tr:hover\": {\n backgroundColor: (listener) => themeColor(listener, \"hover\"),\n },\n },\n };\n}\n\nexport { table };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One tab entry: a trigger label and its panel content. */\ntype TabItem = {\n /** Tab button label — a plain string (auto-wrapped in span) or any DomphyElement. */\n label: string | DomphyElement;\n /** Panel content rendered when this tab is active. */\n content: DomphyElement;\n /** Stable identity key. Defaults to the item's zero-based index. */\n key?: string | number;\n};\n\ntype TabsLive = {\n items: TabItem[];\n accentColor: ThemeColor;\n color: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction buildTabsChildren(\n node: ElementNode,\n items: TabItem[],\n activeKey: State<string | number>,\n accentColor: ThemeColor,\n color: ThemeColor,\n): DomphyElement[] {\n const id = node.nodeId;\n\n const buttons: DomphyElement<\"button\">[] = items.map((item, index) => {\n const key = item.key ?? index;\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n button: [labelEl],\n _key: key,\n type: \"button\",\n role: \"tab\",\n id: `tab${id}${key}`,\n ariaControls: `panel${id}${key}`,\n ariaSelected: (l: Listener) => activeKey.get(l) === key,\n // Roving tabindex (APG tabs pattern): only the selected tab is in\n // the tab order; arrow keys move both selection and focus.\n tabIndex: (l: Listener) => (activeKey.get(l) === key ? 0 : -1),\n onClick: () => activeKey.set(key),\n onKeyDown: (e: Event) => {\n const k = (e as KeyboardEvent).key;\n if (![\"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = items.map((it, i) => it.key ?? i);\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowRight\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowLeft\")\n next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n activeKey.set(keys[next]);\n // Focus must follow selection: without this the next arrow key\n // fires on the OLD tab and re-navigates from its stale position,\n // making later tabs unreachable by keyboard. Resolved via the\n // event target's own tablist — shadow-root safe (unlike a\n // document.getElementById lookup).\n const list = (e.target as HTMLElement).closest(\"[role=tablist]\");\n list?.querySelectorAll<HTMLElement>(\"[role=tab]\")[next]?.focus();\n },\n style: {\n cursor: \"pointer\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: (l: Listener) => themeSpacing(6 + themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 4),\n border: \"none\",\n outline: \"none\",\n // Resting tabs: shift-13 for ≥4.5:1 on surface (catalog low-contrast).\n color: (l: Listener) => themeColor(l, \"shift-13\"),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\"),\n boxShadow: (l: Listener) =>\n `inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-1\", color)}`,\n transition: \"box-shadow 140ms ease, color 140ms ease\",\n \"&:hover:not([disabled]):not([aria-selected=true])\": {\n color: (l: Listener) => themeColor(l, \"shift-13\"),\n boxShadow: (l: Listener) =>\n `inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-2\", color)}`,\n },\n \"&[aria-selected=true]:not([disabled])\": {\n color: (l: Listener) => themeColor(l, \"shift-13\", accentColor),\n boxShadow: (l: Listener) =>\n `inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-8\", accentColor)}`,\n },\n // Focus ring must compose with the selected underline (both use\n // box-shadow) so keyboard focus doesn't erase the active indicator.\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor),\n },\n \"&[aria-selected=true]:focus-visible\": {\n boxShadow: (l: Listener) =>\n `${focusRing(l, accentColor)}, inset 0 ${themeSpacing(-0.5)} 0 0 ${themeColor(l, \"shift-6\", accentColor)}`,\n },\n },\n } as DomphyElement<\"button\">;\n });\n\n const tablist: DomphyElement<\"div\"> = {\n div: buttons,\n _key: \"tablist\",\n role: \"tablist\",\n ariaOrientation: \"horizontal\",\n style: { display: \"flex\" },\n } as DomphyElement<\"div\">;\n\n const panels: DomphyElement<\"div\">[] = items.map((item, index) => {\n const key = item.key ?? index;\n return {\n div: [item.content],\n _key: key,\n role: \"tabpanel\",\n id: `panel${id}${key}`,\n ariaLabelledby: `tab${id}${key}`,\n hidden: (l: Listener) => activeKey.get(l) !== key,\n style: {\n paddingBlock: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n paddingInline: (l: Listener) => themeSpacing(themeDensity(l) * 2),\n },\n } as DomphyElement<\"div\">;\n });\n\n return [tablist, ...panels];\n}\n\n/**\n * All-in-one tabs patch. Generates a `[role=tablist]` button row and\n * `[role=tabpanel]` panels from the `items` array. Apply to any wrapper\n * element (`div`, `section`, …). No companion `tab()` / `tabPanel()` needed.\n *\n * To control the active tab programmatically, pass an external `State` as\n * `activeKey` and call `.set()` on it from outside.\n *\n * @param props.items - Tab definitions `{ label, content, key? }`.\n * @param props.activeKey - Initially active key (value or State). Defaults to the first item's key.\n * @param props.accentColor - Theme color for the active underline indicator. Defaults to `\"primary\"`.\n * @param props.color - Theme color for the resting underline. Defaults to `\"neutral\"`.\n * @example\n * { div: null, $: [tabs({ items: [\n * { label: \"Overview\", content: { p: \"Overview content\" } },\n * { label: \"API\", content: { p: \"API content\" } },\n * ] })] }\n */\nfunction tabs(\n props: {\n items: TabItem[];\n activeKey?: ValueOrState<string | number>;\n accentColor?: ThemeColor;\n color?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const { items = [], accentColor = \"primary\", color = \"neutral\" } = props;\n const live: TabsLive = { items, accentColor, color };\n\n return {\n _onSchedule: (node, element) => {\n const activeKey = persistValue(\n node,\n \"tabsActiveKey\",\n props.activeKey,\n items[0]?.key ?? 0,\n );\n (element as Record<string, unknown>)[node.tagName] = buildTabsChildren(\n node,\n items,\n activeKey,\n accentColor,\n color,\n );\n },\n ...behavior<TabsLive>(\n \"tabs-items\",\n (node) => ({\n update(snapshot) {\n const activeKey = persistValue(\n node,\n \"tabsActiveKey\",\n props.activeKey,\n snapshot.items[0]?.key ?? 0,\n );\n node.children.update(\n buildTabsChildren(\n node,\n snapshot.items,\n activeKey,\n snapshot.accentColor,\n snapshot.color,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n };\n}\n\nexport { tabs };\nexport type { TabItem };\n","import {\n type BehaviorInstance,\n behavior,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/**\n * Styles a multi-line text input (border, focus/hover/invalid/disabled states)\n * on the host `<textarea>` element, with optional auto-resize to content.\n *\n * @hostTag textarea\n * @param props.color - Theme color for the border and text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for hover/focus outline. Optional, accepts a value or state. Defaults to `\"primary\"`.\n * @param props.autoResize - When true, grows the textarea height to fit its content on input and when `value` updates, and remeasures when the host becomes visible (IntersectionObserver) and when its box size changes (ResizeObserver). Optional. Defaults to `false`.\n * @example { textarea: null, $: [textarea({ autoResize: true })] }\n */\nfunction textarea(\n props: {\n color?: ValueOrState<ThemeColor>;\n accentColor?: ValueOrState<ThemeColor>;\n autoResize?: boolean;\n } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n const accentColor = toState(props.accentColor ?? \"primary\", \"accentColor\");\n const { autoResize = false } = props;\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"textarea\") {\n console.warn(`\"textarea\" primitive patch must use textarea tag`);\n }\n },\n // Resize on mount, on input, and when the host `value` attribute updates\n // (controlled writes skip the input event).\n ...behavior(\n \"textarea-auto-resize\",\n (node, initial) => {\n const el = node.domElement as HTMLTextAreaElement;\n let enabled = initial.autoResize;\n let measuring = false;\n let intersectionObserver: IntersectionObserver | undefined;\n let resizeObserver: ResizeObserver | undefined;\n const resize = () => {\n if (!enabled || measuring) return;\n measuring = true;\n // Unobserve during the height write so ResizeObserver cannot\n // re-enter from the measure itself (jsdom may deliver RO sync).\n resizeObserver?.unobserve(el);\n el.style.overflow = \"hidden\";\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight}px`;\n measuring = false;\n if (enabled) resizeObserver?.observe(el);\n };\n const observe = () => {\n if (typeof IntersectionObserver !== \"undefined\") {\n if (!intersectionObserver) {\n intersectionObserver = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) resize();\n });\n }\n intersectionObserver.observe(el);\n }\n if (typeof ResizeObserver !== \"undefined\") {\n if (!resizeObserver) {\n resizeObserver = new ResizeObserver(() => {\n if (measuring) return;\n resize();\n });\n }\n resizeObserver.observe(el);\n }\n };\n const unobserve = () => {\n intersectionObserver?.unobserve(el);\n resizeObserver?.unobserve(el);\n };\n el.addEventListener(\"input\", resize);\n node.attributes.addListener(\"value\", resize);\n if (enabled) {\n observe();\n resize();\n }\n return {\n resize,\n update(next) {\n enabled = next.autoResize;\n node.attributes.addListener(\"value\", resize);\n if (enabled) {\n observe();\n resize();\n } else {\n unobserve();\n }\n },\n destroy() {\n el.removeEventListener(\"input\", resize);\n intersectionObserver?.disconnect();\n resizeObserver?.disconnect();\n },\n };\n },\n { autoResize },\n ),\n _onUpdate: (node) => {\n node\n .getBehavior<\n BehaviorInstance<{ autoResize: boolean }> & { resize: () => void }\n >(\"textarea-auto-resize\")\n ?.resize();\n },\n style: {\n fontFamily: \"inherit\",\n lineHeight: \"inherit\",\n resize: \"vertical\",\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n border: \"none\",\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n outlineOffset: \"-1px\",\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", color.get(listener))}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"inherit\", color.get(listener)),\n transition: \"outline-color 140ms ease, box-shadow 140ms ease\",\n \"&::placeholder\": {\n color: (listener) => themeColor(listener, \"shift-7\"),\n },\n \"&:hover:not([disabled]):not([aria-busy=true])\": {\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"shift-5\", accentColor.get(listener))}`,\n },\n \"&:focus-visible\": {\n boxShadow: (listener) => focusRing(listener, accentColor.get(listener)),\n },\n \"&:invalid\": {\n outline: (listener) =>\n `${themeSpacing(0.5)} solid ${themeColor(listener, \"shift-5\", \"error\")}`,\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n color: (listener) => themeColor(listener, \"muted\", \"neutral\"),\n outline: (listener) =>\n `1px solid ${themeColor(listener, \"border-strong\", \"neutral\")}`,\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-2\", \"neutral\"),\n },\n },\n };\n}\n\nexport { textarea };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Container for a vertical timeline. Sets list reset styles. Apply to `<ol>` or `<ul>`.\n *\n * @example { ol: [...], $: [timeline()] }\n */\nfunction timeline(): PartialElement {\n return {\n style: {\n listStyle: \"none\",\n margin: 0,\n padding: 0,\n display: \"flex\",\n flexDirection: \"column\",\n },\n };\n}\n\n/**\n * A single event row in a `timeline`. Uses a 2-column grid: the left column holds\n * a dot (`::before`) and optional connector line (`::after`); the right column holds\n * the user's content. Apply to `<li>`.\n *\n * @param props.active - Full-opacity dot (accent color). `ValueOrState<boolean>`, defaults to `false`.\n * @param props.last - Suppress the vertical connector below this item. `boolean`, defaults to `false`.\n * @param props.color - Dot/connector color tone. `ThemeColor`, defaults to `\"neutral\"`.\n * @param props.accentColor - Active dot color tone. `ThemeColor`, defaults to `\"primary\"`.\n * @example { li: [{ b: \"2024\" }, { p: \"Event\" }], $: [timelineItem({ active: true })] }\n */\nfunction timelineItem(\n props: {\n active?: ValueOrState<boolean>;\n last?: boolean;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = {},\n): PartialElement {\n const { last = false } = props;\n const color = props.color ?? \"neutral\";\n const accentColor = props.accentColor ?? \"primary\";\n const activeState = toState(props.active ?? false);\n\n return {\n style: {\n display: \"grid\",\n gridTemplateColumns: \"2rem 1fr\",\n columnGap: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingBottom: (listener) =>\n last ? \"0\" : themeSpacing(themeDensity(listener) * 4),\n position: \"relative\",\n\n // Dot\n \"&::before\": {\n content: '\"\"',\n display: \"block\",\n width: \"0.75rem\",\n height: \"0.75rem\",\n borderRadius: \"50%\",\n justifySelf: \"center\",\n marginTop: themeSpacing(1),\n transition: \"background-color 200ms ease, opacity 200ms ease\",\n backgroundColor: (listener) =>\n themeColor(\n listener,\n \"shift-8\",\n activeState.get(listener) ? accentColor : color,\n ),\n opacity: (listener) => (activeState.get(listener) ? \"1\" : \"0.4\"),\n },\n\n // Vertical connector to the next item\n ...(last\n ? {}\n : {\n \"&::after\": {\n content: '\"\"',\n position: \"absolute\",\n left: \"calc(1rem - 1px)\",\n top: \"1.25rem\",\n bottom: (listener) => themeSpacing(themeDensity(listener) * -4),\n width: \"2px\",\n backgroundColor: (listener) =>\n themeColor(listener, \"shift-3\", color),\n },\n }),\n },\n };\n}\n\nexport { timeline, timelineItem };\n","import type {\n DomphyElement,\n ElementNode,\n PartialElement,\n State,\n} from \"@domphy/core\";\nimport { toState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\n\ntype ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\n// The open state must live on the NODE, not in the factory closure: a toast\n// inside a reactive parent gets a fresh toast() closure per ancestor\n// re-render (fresh `toState(false)`), while `_onMount` (which flips the state\n// to visible via rAF) runs ONCE for the first generation. The reused node's\n// re-patched style bindings would read the new generation's still-false\n// state and snap the visible toast back to opacity 0 / translated out.\n// Resolving through node metadata gives every generation the SAME state.\nfunction resolveOpenState(node: ElementNode): State<boolean> {\n let state = node.getMetadata(\"toastOpen\") as State<boolean> | undefined;\n if (!state) {\n state = toState(false);\n node.setMetadata(\"toastOpen\", state);\n }\n return state;\n}\n\nconst readOpen = (listener: any): boolean => {\n const node = listener?.elementNode as ElementNode | undefined;\n return node ? resolveOpenState(node).get(listener) : false;\n};\n\n/**\n * Renders a transient notification surface as a fixed-position overlay (portaled\n * into a corner stack), animating in on mount and out before removal. No host\n * tag check; typically applied to a `<div>`.\n *\n * @param props.position - Corner of the screen for the toast stack. Optional, one of `\"top-left\" | \"top-center\" | \"top-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\"`. Defaults to `\"top-center\"`.\n * @param props.color - Theme color for the toast surface. Optional. Defaults to `\"neutral\"`.\n * @example { div: \"Saved!\", $: [toast({ position: \"top-right\" })] }\n */\nfunction toast(\n props: { position?: ToastPosition; color?: ThemeColor } = {},\n): PartialElement {\n const { position = \"top-center\", color = \"neutral\" } = props;\n\n const isTop = position.startsWith(\"top\");\n const isCenter = position.endsWith(\"center\");\n const isRight = position.endsWith(\"right\");\n\n const overlayEle: DomphyElement<\"div\"> = {\n div: [],\n id: `domphy-toast-${position}`,\n style: {\n position: \"fixed\",\n display: \"flex\",\n flexDirection: isTop ? \"column\" : \"column-reverse\",\n alignItems: isCenter ? \"center\" : isRight ? \"end\" : \"start\",\n inset: 0,\n gap: themeSpacing(4),\n zIndex: 30,\n padding: themeSpacing(6),\n pointerEvents: \"none\",\n },\n };\n\n return {\n _portal: (rootNode) => {\n let overlay = rootNode.domElement!.querySelector(\n `#domphy-toast-${position}`,\n );\n if (!overlay) {\n const overlayNode = rootNode.children!.insert(\n overlayEle,\n ) as ElementNode;\n overlay = overlayNode.domElement!;\n }\n return overlay;\n },\n role: \"status\",\n ariaAtomic: \"true\",\n // Toast is rendered as an overlay surface, so it uses the inverted branch.\n dataTone: \"shift-17\",\n style: {\n minWidth: themeSpacing(32),\n pointerEvents: \"auto\",\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 2),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 4),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 2),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n color: (listener) => themeColor(listener, \"text\", color),\n backgroundColor: (listener) => themeColor(listener, \"inherit\", color),\n boxShadow: elevation(\"medium\"),\n opacity: (listener) => Number(readOpen(listener)),\n transform: (listener) =>\n readOpen(listener)\n ? \"translateY(0)\"\n : isTop\n ? \"translateY(-100%)\"\n : \"translateY(100%)\",\n transition: \"opacity 300ms ease, transform 300ms ease\",\n },\n _onMount: (node) =>\n requestAnimationFrame(() => resolveOpenState(node).set(true)),\n _onBeforeRemove: (node, done) => {\n let finished = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let overlayRemoved = false;\n const rootNode = node.getRoot();\n const overlayEl = node.domElement?.parentElement ?? null;\n // The #domphy-toast-{position} overlay is inserted into the root on\n // first use and shared by every toast at that position — remove it once\n // its LAST toast is gone instead of leaking one empty fixed container\n // per used position for the app's whole lifetime.\n const removeOverlayIfEmpty = () => {\n if (overlayRemoved) return;\n if (\n !overlayEl ||\n overlayEl.id !== `domphy-toast-${position}` ||\n overlayEl.childElementCount > 0\n ) {\n return;\n }\n overlayRemoved = true;\n const item = rootNode.children?.items.find(\n (it) => (it as ElementNode).domElement === overlayEl,\n );\n if (item) rootNode.children!.remove(item);\n else overlayEl.remove();\n };\n const finish = () => {\n if (finished) return;\n finished = true;\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n node.domElement!.removeEventListener(\"transitionend\", onEnd);\n done();\n removeOverlayIfEmpty();\n };\n const onEnd = (e: Event) => {\n if ((e as TransitionEvent).propertyName === \"transform\") finish();\n };\n node.domElement!.addEventListener(\"transitionend\", onEnd);\n // Fallback: if transitionend never fires (reduced-motion, display:none,\n // early detach), unblock removal after the transition duration + buffer.\n timer = setTimeout(finish, 350);\n // If the node is detached before the exit animation settles, clear the\n // pending fallback timer and the transitionend listener so they cannot\n // fire on a removed node.\n node.addHook(\"Remove\", () => {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n node.domElement?.removeEventListener(\"transitionend\", onEnd);\n removeOverlayIfEmpty();\n });\n resolveOpenState(node).set(false);\n },\n };\n}\n\nexport { toast };\n","import {\n behavior,\n type DomphyElement,\n type ElementNode,\n isState,\n type Listener,\n type PartialElement,\n type State,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { focusRing } from \"../utils/focusRing.js\";\n\n/** One item inside a toggle group. */\ntype ToggleItem = {\n /** Button label — plain string (auto-wrapped) or any DomphyElement. */\n label: string | DomphyElement;\n /** Stable key. Defaults to the item's zero-based index as a string. */\n key?: string;\n};\n\ntype ToggleLive = {\n items: ToggleItem[];\n multiple: boolean;\n color: ThemeColor;\n accentColor: ThemeColor;\n};\n\nfunction persistValue<T>(\n node: ElementNode,\n key: string,\n incoming: ValueOrState<T> | undefined,\n fallback: T,\n): State<T> {\n if (isState(incoming)) {\n node.setMetadata(key, incoming);\n return incoming as State<T>;\n }\n let stored = node.getMetadata(key) as State<T> | undefined;\n if (!stored) {\n stored = toState((incoming as T | undefined) ?? fallback);\n node.setMetadata(key, stored);\n }\n return stored;\n}\n\nfunction isPressed(val: string | string[], key: string): boolean {\n return Array.isArray(val) ? val.includes(key) : val === key;\n}\n\nfunction moveToggle(\n e: Event,\n items: ToggleItem[],\n key: string,\n value: State<string | string[]>,\n multiple: boolean,\n): void {\n const k = (e as KeyboardEvent).key;\n if (![\"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\"].includes(k)) return;\n e.preventDefault();\n const keys = items.map((item, index) => item.key ?? String(index));\n const idx = keys.indexOf(key);\n let next = idx;\n if (k === \"ArrowRight\") next = (idx + 1) % keys.length;\n else if (k === \"ArrowLeft\") next = (idx - 1 + keys.length) % keys.length;\n else if (k === \"Home\") next = 0;\n else if (k === \"End\") next = keys.length - 1;\n if (!multiple) value.set(keys[next]);\n const group = (e.target as HTMLElement).closest(\"[role=group]\");\n group?.querySelectorAll<HTMLElement>(\"button\")[next]?.focus();\n}\n\nfunction buildToggleButtons(\n items: ToggleItem[],\n value: State<string | string[]>,\n multiple: boolean,\n color: ThemeColor,\n accentColor: ThemeColor,\n): DomphyElement<\"button\">[] {\n return items.map((item, index) => {\n const key = item.key ?? String(index);\n const labelEl: DomphyElement =\n typeof item.label === \"string\"\n ? ({ span: item.label } as DomphyElement<\"span\">)\n : item.label;\n\n return {\n button: [labelEl],\n _key: key,\n type: \"button\",\n role: \"button\",\n ariaPressed: (l: Listener) => isPressed(value.get(l), key),\n tabIndex: (l: Listener) => {\n const val = value.get(l);\n if (multiple) {\n const arr = Array.isArray(val) ? val : [];\n const focusKey = arr[0] ?? items[0]?.key ?? \"0\";\n return key === focusKey ? 0 : -1;\n }\n if (val === key) return 0;\n if (val === \"\" && key === (items[0]?.key ?? \"0\")) return 0;\n return -1;\n },\n onClick: () => {\n const val = value.get();\n if (multiple) {\n const arr = Array.isArray(val) ? [...val] : [];\n value.set(\n arr.includes(key) ? arr.filter((v) => v !== key) : [...arr, key],\n );\n } else {\n value.set(val === key ? \"\" : key);\n }\n },\n onKeyDown: (e: Event) => moveToggle(e, items, key, value, multiple),\n style: {\n cursor: \"pointer\",\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n height: themeSpacing(6),\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(2),\n border: \"none\",\n borderRadius: themeSpacing(1.5),\n // Unpressed: shift-13 for readable resting labels (catalog contrast).\n color: (l: Listener) => themeColor(l, \"shift-13\", color),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n transition:\n \"background-color 140ms ease, color 140ms ease, box-shadow 140ms ease\",\n \"&:hover:not([disabled]):not([aria-pressed=true])\": {\n color: (l: Listener) => themeColor(l, \"shift-13\", color),\n backgroundColor: (l: Listener) => themeColor(l, \"hover\", color),\n },\n \"&:active:not([disabled])\": {\n backgroundColor: (l: Listener) => themeColor(l, \"increase-2\", color),\n },\n \"&[aria-pressed=true]\": {\n backgroundColor: (l: Listener) =>\n themeColor(l, \"shift-3\", accentColor),\n color: (l: Listener) => themeColor(l, \"shift-13\", accentColor),\n },\n \"&:focus-visible\": {\n boxShadow: (l: Listener) => focusRing(l, accentColor),\n },\n \"&[disabled]\": {\n opacity: 0.7,\n cursor: \"not-allowed\",\n },\n },\n } as DomphyElement<\"button\">;\n });\n}\n\n/**\n * All-in-one toggle group — single or multi-select button group. Generates\n * `<button>` toggle elements from the `items` array. Apply to any wrapper element.\n *\n * @param props.items - Item definitions `{ label, key? }`.\n * @param props.value - Selected key(s) (value or State). Defaults to `[]` (multiple) or `\"\"` (single).\n * @param props.multiple - Allow multiple items selected at once. Defaults to `false`.\n * @param props.color - Theme color for the group background/border. Defaults to `\"neutral\"`.\n * @param props.accentColor - Theme color for the pressed state. Defaults to `\"primary\"`.\n * @example\n * { div: null, $: [toggleGroup({ multiple: true, items: [\n * { label: \"Bold\", key: \"bold\" },\n * { label: \"Italic\", key: \"italic\" },\n * ] })] }\n */\nfunction toggleGroup(\n props: {\n items: ToggleItem[];\n value?: ValueOrState<string | string[]>;\n multiple?: boolean;\n color?: ThemeColor;\n accentColor?: ThemeColor;\n } = { items: [] },\n): PartialElement {\n const {\n items = [],\n multiple = false,\n color = \"neutral\",\n accentColor = \"primary\",\n } = props;\n const live: ToggleLive = { items, multiple, color, accentColor };\n\n return {\n role: \"group\",\n // Publish value + multiple so descendants can read the group selection.\n _context: {\n toggleGroup: {\n value: toState(props.value ?? (multiple ? [] : \"\")),\n multiple,\n },\n },\n _onSchedule: (node, element) => {\n const value = persistValue(\n node,\n \"toggleGroupValue\",\n props.value,\n multiple ? [] : \"\",\n );\n (element as Record<string, unknown>)[node.tagName] = buildToggleButtons(\n items,\n value,\n multiple,\n color,\n accentColor,\n );\n },\n ...behavior<ToggleLive>(\n \"toggle-items\",\n (node) => ({\n update(snapshot) {\n const value = persistValue(\n node,\n \"toggleGroupValue\",\n props.value,\n snapshot.multiple ? [] : \"\",\n );\n node.children.update(\n buildToggleButtons(\n snapshot.items,\n value,\n snapshot.multiple,\n snapshot.color,\n snapshot.accentColor,\n ),\n !!node.domElement,\n true,\n );\n },\n }),\n live,\n ),\n style: {\n display: \"flex\",\n paddingBlock: themeSpacing(1),\n paddingInline: themeSpacing(1),\n gap: themeSpacing(1),\n borderRadius: themeSpacing(2),\n fontSize: (l: Listener) => themeSize(l, \"inherit\"),\n backgroundColor: (l: Listener) => themeColor(l, \"inherit\", color),\n color: (l: Listener) => themeColor(l, \"text\", color),\n outline: (l: Listener) => `1px solid ${themeColor(l, \"border\", color)}`,\n outlineOffset: \"-1px\",\n },\n };\n}\n\nexport { toggleGroup };\nexport type { ToggleItem };\n","import type { DomphyElement, PartialElement } from \"@domphy/core\";\nimport { row } from \"./row.js\";\nimport type { FlexAlign, FlexJustify } from \"./stack.js\";\n\n/**\n * A horizontal flex row with vertically centered items. Useful for headers,\n * toolbars, navigation bars, and action strips. A semantic alias of `row()`;\n * wrap/justify/align/density are forwarded so callers do not drop down to\n * hand-rolled flex.\n *\n * @param props.gap - Spacing multiplier for gap between items (default 4).\n * Bounded-control mode (`density: true`, default): `themeSpacing(themeDensity(l) * gap)`.\n * Structural mode (`density: false`): bare `themeSpacing(gap)`.\n * @param props.wrap - Allow items to wrap onto multiple lines. Defaults to `false`.\n * @param props.justify - Main-axis distribution (`justifyContent`). Unset by default.\n * @param props.align - Cross-axis alignment (`alignItems`). Defaults to `\"center\"` (row default).\n * @param props.density - When true (default), gap is multiplied by theme density.\n * When false, gap is structural `themeSpacing(n)`.\n * @example { header: [...], $: [toolbar()] }\n * @example { nav: [...], $: [toolbar({ gap: 3 })] }\n * @example { header: [...], $: [toolbar({ wrap: true, justify: \"space-between\" })] }\n */\nfunction toolbar(\n props: {\n gap?: number;\n wrap?: boolean;\n justify?: FlexJustify;\n align?: FlexAlign;\n density?: boolean;\n } = {},\n): PartialElement {\n return row(props);\n}\n\n/**\n * A flex spacer that expands to fill available space in a toolbar, pushing\n * subsequent items to the far end.\n *\n * @example { header: [logo, toolbarSpacer(), nav, actions], $: [toolbar()] }\n */\nfunction toolbarSpacer(): DomphyElement {\n return { div: null, style: { flex: \"1 1 0\" } };\n}\n\nexport { toolbar, toolbarSpacer };\n","import {\n type DomphyElement,\n merge,\n type PartialElement,\n toState,\n type ValueOrState,\n} from \"@domphy/core\";\nimport type { Placement } from \"@domphy/floating\";\nimport {\n themeColor,\n themeDensity,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\nimport { elevation } from \"../utils/elevation.js\";\nimport { createFloating, floatingPanelId } from \"../utils/floating.js\";\nimport { popoverArrow } from \"./popoverArrow.js\";\n\n/**\n * Attaches a floating tooltip to the host element, shown on hover/focus and\n * hidden on leave/blur/Escape. Returns the anchor (trigger) partial; the tooltip\n * surface is positioned via the floating utility and linked with\n * `aria-describedby`. No host tag check; applied to the trigger element.\n *\n * @param props.open - Controlled open state (`ValueOrState<boolean>`), including `Computed`/`ReadableState`. When the source is read-only, pass `onDismiss` so leave/blur/Escape can close. Optional. Defaults to `false`.\n * @param props.onDismiss - Called when the tooltip requests close. Optional. Required to close when `open` is a read-only `Computed`/`ReadableState`.\n * @param props.placement - Floating placement relative to the trigger. Optional, accepts a value or state (`Placement`). Defaults to `\"top\"`.\n * @param props.content - Tooltip text content. Optional, accepts a value or state (string only). Defaults to `\"Tooltip Content\"`.\n * @example { button: \"Hover me\", $: [tooltip({ content: \"Help text\" })] }\n */\nfunction tooltip(\n props: {\n open?: ValueOrState<boolean>;\n onDismiss?: () => void;\n placement?: ValueOrState<Placement>;\n content?: ValueOrState<string>;\n } = {},\n): PartialElement {\n const {\n open = false,\n placement = \"top\",\n content = \"Tooltip Content\",\n } = props;\n\n const placeState = toState(placement);\n const contentState = toState(content);\n\n // The tooltip id is NOT pre-generated here: a factory-scope id (previously\n // Math.random()-based) churns per generation and mismatches SSR/hydration.\n // Instead the shared floating behavior stamps a deterministic id derived\n // from the anchor's nodeId when the panel mounts (see floating.ts), and the\n // trigger references the same id via _onSchedule below.\n const contentElement: DomphyElement<\"span\"> = {\n span: (listener) => contentState.get(listener),\n };\n\n const { show, hide, anchorPartial } = createFloating({\n kind: \"tooltip\",\n open,\n onDismiss: props.onDismiss,\n placement: placeState,\n content: contentElement,\n });\n\n const tooltipPartial: PartialElement = {\n role: \"tooltip\",\n dataSize: \"decrease-1\",\n dataTone: \"shift-17\",\n style: {\n paddingBlock: (listener) => themeSpacing(themeDensity(listener) * 1),\n paddingInline: (listener) => themeSpacing(themeDensity(listener) * 3),\n borderRadius: (listener) => themeSpacing(themeDensity(listener) * 1.5),\n color: (listener) => themeColor(listener, \"text\"),\n backgroundColor: (listener) => themeColor(listener),\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n boxShadow: elevation(\"low\"),\n },\n $: [popoverArrow({ placement: placeState, bordered: false })],\n };\n contentElement.$ ||= [];\n contentElement.$.push(tooltipPartial);\n\n const triggerPartial: PartialElement = {\n // Declared as a reactive attribute (listener.elementNode is the anchor) so\n // it is present from first render — before the tooltip's first show() —\n // and is re-declared on every patch (patch() strips attributes that are\n // no longer declared, so imperative wiring would not survive re-render).\n ariaDescribedby: (listener) =>\n listener?.elementNode\n ? floatingPanelId(\"tooltip\", listener.elementNode)\n : undefined,\n onMouseEnter: (_e, node) => show(node),\n onMouseLeave: (_e, node) => hide(node),\n onFocus: (_e, node) => show(node),\n onBlur: (_e, node) => hide(node),\n onKeyDown: (e, node) => (e as KeyboardEvent).key === \"Escape\" && hide(node),\n };\n\n merge(anchorPartial, triggerPartial);\n\n return anchorPartial;\n}\n\nexport { tooltip };\n","import { ElementNode, type PartialElement } from \"@domphy/core\";\n\ntype RectMap = Map<string, DOMRect>;\n\nfunction getItemId(node: ElementNode, index: number): string {\n if (node.key !== undefined && node.key !== null) {\n return String(node.key);\n }\n return `index-${index}`;\n}\n\n/**\n * Animates child reordering using the FLIP technique: records each child's\n * position before an update and smoothly transitions it from its old to new\n * position afterward. No host tag check; applied to the list container.\n *\n * @param props.duration - Transition duration in milliseconds. Optional. Defaults to `300`.\n * @param props.delay - Transition delay in milliseconds. Optional. Defaults to `0`.\n * @example { ul: null, $: [transitionGroup({ duration: 300 })] }\n */\nfunction transitionGroup(\n props: { duration?: number; delay?: number } = {},\n): PartialElement {\n const { duration = 300, delay = 0 } = props;\n\n let previousRects: RectMap = new Map();\n // Cancels any in-flight animation for a given DOM element before starting a new one.\n const cancelMap = new Map<HTMLElement, () => void>();\n // Pending fallback timers and queued rAF callbacks, tracked so a removal of\n // the container mid-animation can clear them instead of firing on a detached node.\n const pendingTimers = new Set<ReturnType<typeof setTimeout>>();\n const pendingFrames = new Set<number>();\n\n return {\n _onMount: (node) => {\n node.addHook(\"Remove\", () => {\n // Stop every in-flight animation: removes transitionend listeners.\n for (const cancel of Array.from(cancelMap.values())) cancel();\n cancelMap.clear();\n // Clear queued fallback timers.\n for (const timer of pendingTimers) clearTimeout(timer);\n pendingTimers.clear();\n // Cancel queued animation frames.\n for (const frame of pendingFrames) cancelAnimationFrame(frame);\n pendingFrames.clear();\n });\n },\n _onBeforeUpdate: (node) => {\n previousRects = new Map();\n node.children.items.forEach((item, index) => {\n if (!(item instanceof ElementNode)) return;\n const dom = item.domElement as HTMLElement | undefined;\n if (!dom) return;\n previousRects.set(getItemId(item, index), dom.getBoundingClientRect());\n });\n },\n _onUpdate: (node) => {\n node.children.items.forEach((item, index) => {\n if (!(item instanceof ElementNode)) return;\n const dom = item.domElement as HTMLElement | undefined;\n if (!dom) return;\n\n const key = getItemId(item, index);\n const prev = previousRects.get(key);\n if (!prev) return;\n\n const next = dom.getBoundingClientRect();\n const deltaX = prev.left - next.left;\n const deltaY = prev.top - next.top;\n if (Math.abs(deltaX) < 0.5 && Math.abs(deltaY) < 0.5) return;\n\n // Cancel any in-flight animation on this element before starting a new one.\n cancelMap.get(dom)?.();\n\n dom.style.transition = \"none\";\n dom.style.transform = `translate(${deltaX}px, ${deltaY}px)`;\n dom.getBoundingClientRect();\n\n const frame = requestAnimationFrame(() => {\n pendingFrames.delete(frame);\n dom.style.transition = `transform ${duration}ms ease ${delay}ms`;\n dom.style.transform = \"translate(0px, 0px)\";\n });\n pendingFrames.add(frame);\n\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n const finish = () => {\n if (cancelled) return;\n cancelled = true;\n if (timer) {\n pendingTimers.delete(timer);\n timer = null;\n }\n cancelMap.delete(dom);\n dom.removeEventListener(\"transitionend\", onEnd);\n dom.style.transition = \"\";\n dom.style.transform = \"\";\n };\n\n const onEnd = (event: Event) => {\n if ((event as TransitionEvent).propertyName === \"transform\") finish();\n };\n\n cancelMap.set(dom, () => {\n cancelled = true;\n if (timer) {\n clearTimeout(timer);\n pendingTimers.delete(timer);\n timer = null;\n }\n cancelMap.delete(dom);\n dom.removeEventListener(\"transitionend\", onEnd);\n });\n\n dom.addEventListener(\"transitionend\", onEnd);\n timer = setTimeout(finish, duration + delay + 34);\n pendingTimers.add(timer);\n });\n previousRects.clear();\n },\n };\n}\n\nexport { transitionGroup };\n","import { type PartialElement, toState, type ValueOrState } from \"@domphy/core\";\nimport {\n type ThemeColor,\n themeColor,\n themeSize,\n themeSpacing,\n} from \"@domphy/theme\";\n\n/**\n * Styles a bulleted list (disc markers, reset margins, themed text) on the host\n * `<ul>` element.\n *\n * @hostTag ul\n * @param props.color - Theme color for the list text. Optional, accepts a value or state. Defaults to `\"neutral\"`.\n * @example { ul: null, $: [unorderedList()] }\n */\nfunction unorderedList(\n props: { color?: ValueOrState<ThemeColor> } = {},\n): PartialElement {\n const color = toState(props.color ?? \"neutral\", \"color\");\n\n return {\n _onInsert: (node) => {\n if (node.tagName !== \"ul\") {\n console.warn(`\"unorderedList\" primitive patch must use ul tag`);\n }\n },\n style: {\n fontSize: (listener) => themeSize(listener, \"inherit\"),\n backgroundColor: (listener) => themeColor(listener),\n color: (listener) => themeColor(listener, \"text\", color.get(listener)),\n marginTop: 0,\n marginBottom: 0,\n paddingLeft: themeSpacing(3),\n listStyleType: \"disc\",\n listStylePosition: \"outside\",\n },\n };\n}\n\nexport { unorderedList };\n","import type { PartialElement } from \"@domphy/core\";\n\n/**\n * Visually hides an element while keeping it in the accessibility tree — the\n * classic \"sr-only\" recipe for screen-reader-only labels, live-region text,\n * and skip links (before focus). Styles the host only; apply to any element.\n *\n * @example { span: \"Opens in a new tab\", $: [visuallyHidden()] }\n */\nfunction visuallyHidden(): PartialElement {\n return {\n style: {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n margin: \"-1px\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n whiteSpace: \"nowrap\",\n border: \"0\",\n },\n };\n}\n\nexport { visuallyHidden };\n"],"mappings":"gyBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,kBAAAE,GAAA,cAAAC,GAAA,UAAAC,GAAA,WAAAC,GAAA,UAAAC,GAAA,eAAAC,GAAA,eAAAC,GAAA,uBAAAC,GAAA,WAAAC,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O,CACL,MAAO,CACL,SAAU,WACV,MAAO,MACP,OAAQ,MACR,QAAS,IACT,OAAQ,OACR,SAAU,SACV,KAAM,mBACN,WAAY,SACZ,OAAQ,GACV,CACF,CACF","names":["index_exports","__export","abbreviation","accordion","alert","avatar","badge","blockquote","breadcrumb","breadcrumbEllipsis","button","buttonGhost","buttonSwitch","card","code","combobox","command","commandItem","commandSearch","datePicker","descriptionList","details","dialog","divider","drawer","elevation","emphasis","empty","errorBoundary","fab","figure","focusRing","formGroup","grid","heading","horizontalRule","icon","image","inputCheckbox","inputColor","inputDateTime","inputFile","inputNumber","inputOTP","inputPassword","inputRadio","inputRange","inputSearch","inputSwitch","inputText","keyboard","label","link","linkButton","list","listItem","listItemButton","mark","menu","motion","orderedList","pagination","panelSection","paragraph","popover","popoverArrow","preformated","progress","rating","ringProgress","row","scrollArea","segmented","select","selectBox","selectItem","selectList","skeleton","small","spinner","splitter","splitterHandle","splitterPanel","stack","steps","strong","subscript","superscript","table","tabs","tag","textarea","timeline","timelineItem","toast","toggleGroup","toolbar","toolbarSpacer","tooltip","transitionGroup","unorderedList","visuallyHidden","__toCommonJS","import_core","import_theme","abbreviation","props","_a","_b","color","accentColor","node","listener","import_core","import_theme","import_theme","focusRing","listener","color","gap","ring","accordion","props","_a","_b","type","color","accentColor","node","el","handler","event","summary","item","detail","listener","focusRing","import_core","import_theme","alert","props","_a","color","listener","import_core","import_theme","avatar","props","_a","color","listener","import_core","import_theme","badge","props","_a","label","state","color","l","import_core","import_theme","blockquote","props","_a","color","node","listener","import_core","import_theme","breadcrumb","props","_a","separator","color","node","listener","import_core","import_theme","breadcrumbEllipsis","props","_a","color","node","listener","focusRing","import_core","import_theme","BUTTON_SIZE_FONT","import_core","import_theme","PADDING_STEPS","buttonGhost","props","_a","_b","_c","color","padding","fontSize","BUTTON_SIZE_FONT","node","listener","focusRing","PADDING_STEPS","button","props","_a","_b","_c","_d","variant","buttonGhost","color","isSolid","padding","fontSize","BUTTON_SIZE_FONT","__spreadProps","__spreadValues","node","listener","focusRing","import_core","import_theme","buttonSwitch","props","_a","_b","checked","check","color","accentColor","node","listener","focusRing","import_core","import_theme","SHADOWS","elevation","level","card","props","_a","color","listener","elevation","import_core","import_theme","code","props","_a","color","node","listener","import_core","import_theme","import_core","import_floating","import_core","isWritableState","source","subscribeOpen","onChange","emitCurrent","skipInitial","release","value","writeOpen","dismissOpen","onDismiss","asOpenState","open","floatingPanelId","kind","node","attachFloating","initialProps","_a","_b","_c","_d","openState","onDismiss","placement","content","keepOpenOnContentHover","behaviorKey","timer","cleanup","floating","floatingNode","mounted","reference","rootNode","panelId","floatingPartial","listener","event","hide","show","mountedNode","dataTheme","rNode","dialogHost","overlay","overlayEle","wireContent","target","ensureMounted","instance","instantShow","x","y","resolved","writeOpen","instantHide","dismissOpen","handleOutside","handleEscape","escapeTarget","onOpen","val","release","destroyed","updating","stampPanelBehavior","__spreadProps","__spreadValues","props","subscribeOpen","createFloating","asOpenState","anchorPartial","e","import_core","import_theme","xSvg","DEFAULT_DENSITY","TAG_HEIGHT","TAG_PAD_INLINE","TAG_PAD_END_REMOVABLE","TAG_REMOVE","TAG_REMOVE_RADIUS","tag","props","_a","removable","color","__spreadProps","__spreadValues","node","initial","removeHost","makeButton","e","event","listener","focusRing","findButton","item","sync","next","updateDom","existing","combobox","props","options","placement","color","open","multiple","state","openState","show","hide","anchorPartial","createFloating","popoverPartial","_e","node","listener","elevation","inputStyle","readQuery","_a","_b","findComboboxAnchor","from","current","inputAria","floatingPanelId","buildInput","custom","__spreadValues","event","buildWrap","inner","val","vals","items","opt","tag","_node","cur","filter","v","partial","__spreadProps","element","_inner","query","next","focusRing","import_core","import_theme","command","_node","element","commandSearch","props","color","accentColor","node","ctx","input","onInput","listener","focusRing","commandItem","_a","_b","el","text","applyFilter","q","release","import_core","import_theme","atMidnight","date","addDays","count","addMonths","sameDay","a","b","isoOf","startOfWeek","weekStart","localeWeekStart","locale","_a","_b","localeObject","info","attachDatePicker","_node","initialProps","current","releaseOnChange","subscribe","props","value","carryForward","next","prev","datePicker","_c","_d","mode","time","min","max","disabledDate","format","onChange","accentColor","placeState","selection","primaryDate","base","viewYear","viewMonth","focused","hovered","hour","minute","dateFormatter","__spreadValues","monthFormatter","weekdayFormatter","fullDateFormatter","formatOne","formatDisplay","start","end","weekdayNames","_unused","index","isDisabled","withTime","result","selectDate","node","hide","reapplyTime","inSelectedRange","listener","tail","low","high","day","isSelectedEnd","goToDate","shiftMonth","delta","shiftYear","focusActiveCell","root","calendar","buildCalendar","openState","show","anchorPartial","createFloating","triggerPartial","floatingPanelId","_e","openAndFocus","event","key","isSelectedPrimary","navButton","label","ariaLabel","onClick","navButtonStyle","header","weekdayHeader","name","gridRowStyle","grid","buildWeeks","onGridKey","children","buildTimeRow","buildFooter","elevation","first","month","weeks","week","cells","buildDayCell","disabled","selected","within","outside","isFocused","isToday","l","focusRing","numberSelect","state","timeSelectStyle","action","today","keyboard","import_core","import_theme","descriptionList","props","_a","color","node","listener","import_core","import_theme","details","props","_a","_b","duration","color","accentColor","node","listener","focusRing","import_core","import_theme","lockCount","lockScroll","unlockScroll","FOCUSABLE","attachDialog","node","initialProps","state","onDismiss","previousFocus","closing","scrollLocked","closeTimer","dlg","finalizeClose","unlockScroll","trapFocus","e","focusables","el","first","last","onCancel","dismissOpen","update","val","lockScroll","focusable","release","subscribeOpen","props","dialog","color","open","labelledBy","describedBy","asOpenState","__spreadProps","__spreadValues","_a","r","listener","elevation","import_core","import_theme","divider","props","_a","color","node","listener","import_core","import_theme","translateOut","marginMap","isVertical","p","resolvePhysical","placement","isRTL","attachDrawer","node","initialProps","state","onDismiss","size","dlg","onCancel","e","dismissOpen","resolve","nextPlacement","nextSize","physical","drawerSize","closing","scrollLocked","closeTimer","finishClose","unlockScroll","onTransitionEnd","update","val","lockScroll","release","subscribeOpen","props","drawer","color","open","asOpenState","physicalFallback","defaultSize","__spreadProps","__spreadValues","_a","r","listener","elevation","import_core","import_theme","emphasis","props","_a","color","node","listener","import_core","import_theme","empty","props","_a","color","listener","ORIGINAL_CHILDREN","restoreOriginalChildren","node","_a","original","errorBoundary","props","element","error","_b","reset","fallbackEl","import_core","import_theme","SIZE_MAP","fab","props","_a","_b","color","dim","node","listener","elevation","focusRing","import_core","import_theme","figure","props","_a","color","node","listener","import_core","import_theme","formGroup","props","_a","layout","color","isVertical","node","listener","import_theme","grid","props","columns","gap","align","__spreadValues","listener","import_core","import_theme","HeadingShift","heading","props","_a","color","size","node","listener","offset","import_core","import_theme","horizontalRule","props","_a","color","node","listener","import_core","import_theme","icon","props","_a","color","node","listener","import_core","import_theme","image","props","_a","color","node","listener","import_core","import_theme","inputCheckbox","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputColor","props","_a","color","node","listener","focusRing","import_core","import_theme","inputDateTime","props","_a","_b","mode","color","accentColor","node","listener","focusRing","import_core","import_theme","inputFile","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputNumber","props","_a","_b","color","accentColor","node","listener","focusRing","import_theme","inputOTP","node","container","getInputs","onInput","e","inputs","target","idx","onKeydown","onPaste","_a","_b","_c","text","found","startIdx","char","i","field","lastFilled","import_core","import_theme","EYE_SVG","EYE_OFF_SVG","HOST_FIELD_KEYS","bindReadable","value","listener","inputPassword","props","_a","_b","colorState","accentState","visibleState","hostFields","node","_node","element","host","key","_c","_d","_e","_f","_g","name","onInput","disabled","required","field","__spreadProps","__spreadValues","l","toggle","focusRing","import_core","import_theme","inputRadio","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputRange","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputSearch","props","_a","_b","color","accentColor","node","listener","focusRing","import_core","import_theme","inputSwitch","props","_a","accentColor","node","listener","focusRing","import_core","import_theme","inputText","props","_a","_b","type","color","accentColor","node","listener","focusRing","import_core","import_theme","keyboard","props","_a","color","node","listener","import_core","import_theme","label","props","_a","_b","color","accentColor","node","listener","import_core","import_theme","link","props","_a","_b","color","accentColor","node","event","el","listener","focusRing","import_core","import_theme","PADDING_STEPS","GHOST_PADDING","linkButton","props","_a","_b","_c","variant","color","size","fontSize","BUTTON_SIZE_FONT","padding","node","listener","focusRing","isSolid","__spreadProps","__spreadValues","import_core","import_theme","list","props","_a","color","listener","listItem","dense","listItemButton","_b","accentColor","focusRing","import_core","import_theme","mark","props","_a","accentColor","node","listener","import_core","import_theme","menu","props","_a","items","selectable","color","accentColor","activeKey","activeKeyIsCallerOwned","buildItems","node","inner","id","item","index","key","__spreadProps","__spreadValues","l","e","keys","it","i","idx","next","focusRing","attachMenu","_node","initial","current","element","elevation","import_core","isMotionState","value","toStyles","frame","out","transforms","key","toOptions","transition","_a","_b","_c","_d","prefersReducedMotion","e","attachMotion","node","initial","el","current","release","bindAnimate","animate","next","play","props","mode","target","frames","motion","__spreadProps","__spreadValues","done","inst","exit","import_core","import_theme","orderedList","props","_a","color","node","listener","import_core","import_theme","getPages","current","total","_","i","pages","start","end","persistValue","node","key","incoming","fallback","stored","persistTotal","pagination","props","color","accentColor","btnBase","listener","focusRing","activeStyle","__spreadProps","__spreadValues","state","totalState","content","page","pageCount","items","ellipsisIndex","p","isActive","snapshot","import_core","import_theme","panelSection","props","_a","padding","divider","color","__spreadValues","listener","import_core","import_theme","paragraph","props","_a","color","node","listener","import_core","import_theme","contentOwnsSurface","content","patches","patch","popover","props","_a","open","placement","openOn","openState","placeState","show","hide","anchorPartial","createFloating","popoverPartial","l","elevation","listener","floatingPanelId","_e","node","e","related","floatingEl","import_core","import_theme","popoverArrow","props","placement","color","sideOffset","bordered","place","flipMap","getFlipped","listener","_a","start","pos","end","x","y","import_core","import_theme","preformated","props","_a","color","node","listener","import_core","import_theme","progress","props","_a","_b","color","accentColor","node","listener","import_core","import_theme","STAR_FILLED","STAR_EMPTY","applyRatingProps","live","next","_a","_b","_c","insertStar","node","index","hoveredState","activeCount","listener","hovered","star","e","current","target","focusRing","syncStars","children","rating","props","_d","_e","_f","_g","__spreadProps","__spreadValues","initial","import_core","import_theme","ringProgress","props","_a","_b","_c","size","thickness","value","color","trackColor","holePercent","mask","l","node","import_theme","row","props","gap","align","justify","wrap","density","__spreadValues","listener","import_core","import_theme","scrollArea","props","_a","color","l","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","moveSegment","e","items","value","_a","k","keys","item","index","idx","next","group","buildSegmentButtons","color","accentColor","l","_b","current","elevation","focusRing","segmented","props","_c","live","__spreadProps","__spreadValues","element","snapshot","import_theme","select","props","color","accentColor","node","listener","l","svg","focusRing","import_core","import_theme","TYPEAHEAD_RESET_MS","resolveTypeahead","node","meta","matchesPrefix","label","needle","enabledPanelOptions","panel","el","selectBox","props","options","placement","color","open","multiple","state","openState","show","hide","anchorPartial","createFloating","popoverPartial","_e","listener","elevation","buildWrap","inner","val","vals","opt","tag","_node","cur","filter","v","attachInner","_inner","next","toggle","typeahead","key","_a","_b","_c","_d","repeated","root","floatingPanelId","matches","active","from","target","partial","__spreadProps","__spreadValues","element","e","kb","focusRing","import_theme","selectItem","props","accentColor","color","value","listener","_a","select","val","_e","node","state","v","focusRing","import_core","import_theme","selectList","props","_a","color","multiple","state","inputs","listener","val","v","node","import_core","import_theme","skeleton","props","_a","color","keyframes","animationName","listener","import_core","import_theme","small","props","_a","color","node","listener","import_core","import_theme","keyframes","animationName","spinner","props","_a","color","node","listener","import_core","import_theme","splitter","props","direction","defaultSize","min","max","_node","element","isFirstSplitterPanel","node","parent","item","splitterPanel","ctx","el","prop","apply","size","release","_a","splitterHandle","handle","isHorizontal","releaseAriaValue","onKeydown","e","step","next","cancelDrag","onMousedown","container","onMousemove","rect","raw","onMouseup","listener","focusRing","import_theme","stack","props","gap","align","justify","density","__spreadValues","listener","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","stepConnectorStyle","direction","color","accentColor","l","buildStepItems","items","current","vertical","connector","item","index","_a","cur","__spreadProps","__spreadValues","steps","props","live","element","snapshot","import_core","import_theme","strong","props","_a","color","node","listener","import_core","import_theme","subscript","props","_a","color","node","listener","import_core","import_theme","superscript","props","_a","color","node","listener","import_core","import_theme","table","props","_a","color","node","listener","l","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","buildTabsChildren","items","activeKey","accentColor","color","id","tablist","item","index","_a","l","e","k","keys","it","i","idx","next","list","focusRing","panels","tabs","props","__spreadValues","element","_b","snapshot","import_core","import_theme","textarea","props","_a","_b","color","accentColor","autoResize","__spreadProps","__spreadValues","node","initial","el","enabled","measuring","intersectionObserver","resizeObserver","resize","observe","entries","entry","unobserve","next","listener","focusRing","import_core","import_theme","timeline","timelineItem","props","_a","_b","_c","last","color","accentColor","activeState","__spreadValues","listener","import_core","import_theme","resolveOpenState","node","state","readOpen","listener","toast","props","position","color","isTop","isCenter","isRight","overlayEle","rootNode","overlay","elevation","done","_a","_b","finished","timer","overlayRemoved","overlayEl","removeOverlayIfEmpty","item","it","finish","onEnd","e","import_core","import_theme","persistValue","node","key","incoming","fallback","stored","isPressed","val","moveToggle","e","items","value","multiple","_a","k","keys","item","index","idx","next","group","buildToggleButtons","color","accentColor","_b","_c","_d","_e","focusKey","arr","v","focusRing","toggleGroup","props","live","__spreadProps","__spreadValues","element","snapshot","l","toolbar","props","row","toolbarSpacer","import_core","import_theme","tooltip","props","open","placement","content","placeState","contentState","contentElement","listener","show","hide","anchorPartial","createFloating","tooltipPartial","elevation","popoverArrow","floatingPanelId","_e","node","e","import_core","getItemId","node","index","transitionGroup","props","duration","delay","previousRects","cancelMap","pendingTimers","pendingFrames","cancel","timer","frame","item","dom","_a","key","prev","next","deltaX","deltaY","cancelled","finish","onEnd","event","import_core","import_theme","unorderedList","props","_a","color","node","listener","visuallyHidden"]}