@platned/ui 0.9.5 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +31 -0
- package/README.md +8 -0
- package/dist/{chunk-OGQIGGVB.js → chunk-O2Y4XUXQ.js} +2 -1
- package/dist/data-table.js +1 -1
- package/dist/index.cjs +1350 -661
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +288 -3
- package/dist/index.js +1159 -463
- package/dist/index.js.map +1 -1
- package/dist/sidebar.cjs +20 -1158
- package/dist/sidebar.cjs.map +1 -1
- package/dist/sidebar.d.cts +175 -105
- package/dist/sidebar.d.ts +175 -105
- package/dist/sidebar.js +18 -1170
- package/dist/sidebar.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- /package/dist/{chunk-OGQIGGVB.js.map → chunk-O2Y4XUXQ.js.map} +0 -0
package/dist/sidebar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sidebar/index.tsx","../src/lib/cn.ts","../src/lib/focus-ring.ts","../src/lib/slot.tsx","../src/components/forms/control-size.tsx","../src/components/forms/icon-button.tsx","../src/components/avatar/avatar.tsx","../src/lib/use-controllable-state.ts","../src/components/overlays/menu-styles.ts","../src/lib/scrollbar.ts","../src/components/overlays/portal.tsx","../src/lib/compose-event-handlers.ts","../src/components/overlays/tooltip.tsx","../src/components/overlays/menu-core.tsx","../src/components/cards/scroll-area.tsx","../src/components/overlays/dropdown-menu.tsx","../src/components/chrome/nav-item.tsx","../src/sidebar/nav-tabs.tsx"],"sourcesContent":["import { createContext, useContext, useMemo, type HTMLAttributes, type ReactNode } from 'react';\nimport { Link, useLocation } from 'react-router-dom';\nimport { ChevronLeftIcon, ChevronRightIcon, EllipsisVerticalIcon, LogOutIcon } from 'lucide-react';\n\nimport {\n Avatar,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n NavItem,\n ScrollArea,\n Tooltip,\n cn,\n} from '../index';\nimport type { NavItemSize, NavItemVariant } from '../index';\n\nexport interface SidebarNavItem {\n /**\n * The destination. May carry a hash (`/docs/floating#tooltip`) to link to a section of a\n * page: that row is current only when the hash matches too, and the page's own plain row\n * steps aside while it is. New in 0.7.0.\n */\n to: string;\n label: string;\n /** Optional — a collapsed row without one falls back to a monogram of its label. */\n icon?: ReactNode;\n /** Red dot on the row — something new behind this destination. */\n indicator?: boolean;\n /** Match the path exactly rather than as a prefix. Needed for an index route. */\n end?: boolean;\n /**\n * A destination that exists but cannot be opened right now (no permission, coming soon).\n * The row is dimmed, announced with `aria-disabled`, out of the tab order, and refuses the\n * press. New in 0.7.0.\n */\n disabled?: boolean;\n}\n\nexport interface SidebarNavGroup {\n /**\n * Uppercase heading above the group. Omit for an ungrouped run of rows.\n *\n * Kept in the accessibility tree when the rail is collapsed rather than dropped: it is the\n * only thing saying what the run of icons below it has in common.\n */\n title?: string;\n items: SidebarNavItem[];\n}\n\nexport interface AppSidebarProps {\n /** The scrolling nav. One untitled group is a flat list. */\n groups: SidebarNavGroup[];\n /** Rows pinned below the scrolling nav — settings, help, a sign-out link. */\n footerNav?: SidebarNavItem[];\n /**\n * Brand lockup. Given a function it receives `collapsed`, so the caller can swap a full\n * lockup for a mark alone rather than having one squeezed into an 80px rail.\n */\n brand?: ReactNode | ((state: { collapsed: boolean }) => ReactNode);\n /** Bottom slot, below a divider — a user card, a version pill, nothing. */\n footer?: ReactNode;\n /**\n * Whether the rail can collapse at all.\n *\n * `false` locks it open: no toggle button, and `collapsed` is ignored rather than half\n * honoured. A collapsed rail is 80px of icons, so it only earns its place in a nav short\n * enough and iconographic enough to survive the loss of its labels — a long text nav\n * (the docs site's own, for one) is better off never offering it.\n */\n collapsible?: boolean;\n collapsed?: boolean;\n /** Omit and the collapse toggle is not rendered, though `collapsed` still applies. */\n onToggle?: () => void;\n size?: NavItemSize;\n variant?: NavItemVariant;\n /** Expanded width, as a Tailwind class. */\n width?: string;\n collapsedWidth?: string;\n className?: string;\n}\n\n/**\n * The application nav rail: brand, a grouped list of destinations, and a footer.\n *\n * Lives on its own entry point (`@platned/ui/sidebar`) because it uses `NavLink`, and\n * `react-router-dom` is an optional peer dependency.\n *\n * Through 0.4.0 this was not a library component at all. It hardcoded ten product routes,\n * their labels and their icons, an `SCIC` wordmark, and an `isAdmin` flag gating two of the\n * rows — so the only app it could render was the one it was extracted from, and the docs\n * site kept a second, unrelated sidebar of its own rather than use it. Everything\n * app-specific is now a prop or a slot, and the docs site runs on this component.\n *\n * Width is an explicit prop rather than something `className` overrides: the width is\n * conditional on `collapsed`, so a `className=\"w-64\"` would tailwind-merge away the\n * collapsed width too and break the collapse. Everything else about the shell is fair game\n * for `className` — `rounded-none` to flatten it for a full-bleed layout, for instance.\n */\nexport function AppSidebar({\n groups,\n footerNav,\n brand,\n footer,\n collapsible = true,\n collapsed: collapsedProp = false,\n onToggle,\n size = 'md',\n variant = 'card',\n width = 'w-80',\n collapsedWidth = 'w-20',\n className,\n}: AppSidebarProps) {\n // One switch turns the whole behaviour off, rather than leaving a caller to remember that\n // `collapsible={false}` also means never passing `collapsed`.\n const collapsed = collapsible && collapsedProp;\n const hashTargets = useMemo(\n () =>\n new Set(\n [...groups.flatMap((group) => group.items), ...(footerNav ?? [])]\n .map((item) => item.to)\n .filter((to) => to.includes('#')),\n ),\n [groups, footerNav],\n );\n\n return (\n <HashTargets.Provider value={hashTargets}>\n <aside\n className={cn(\n 'relative flex h-full shrink-0 flex-col py-2 transition-all duration-200 motion-reduce:transition-none',\n 'rounded-xl border-r border-default bg-default-secondary',\n collapsed ? collapsedWidth : width,\n className,\n )}\n >\n {collapsible && onToggle && (\n <button\n type=\"button\"\n aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n aria-expanded={!collapsed}\n onClick={onToggle}\n className={cn(\n 'absolute -right-3 top-5 z-raised flex size-6 items-center justify-center rounded-full',\n 'border border-default bg-default text-default-secondary',\n // Not `hover:bg-default-hover` — that is #F5F5F5, exactly the rail colour, and\n // this button straddles the rail edge, so half of it dissolved into the rail on\n // hover. Same hover vocabulary as the rows instead.\n 'shadow-100 transition-colors hover:bg-brand-tertiary-hover hover:text-brand',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default',\n )}\n >\n {collapsed ? (\n <ChevronRightIcon className=\"size-3\" strokeWidth={2.5} aria-hidden />\n ) : (\n <ChevronLeftIcon className=\"size-3\" strokeWidth={2.5} aria-hidden />\n )}\n </button>\n )}\n\n {brand && (\n <div\n className={cn(\n 'flex shrink-0 items-center overflow-hidden p-4',\n collapsed ? 'justify-center' : 'gap-2.5',\n )}\n >\n {typeof brand === 'function' ? brand({ collapsed }) : brand}\n </div>\n )}\n\n <ScrollArea axis=\"vertical\" label=\"Sidebar navigation\" className=\"min-h-0 flex-1\">\n <nav className=\"flex flex-col gap-4 px-4 pb-3 pt-2\">\n {groups.map((group, groupIndex) => (\n <SidebarGroup\n key={group.title ?? `group-${groupIndex}`}\n group={group}\n // A rule above every group but the first, expanded or collapsed. In the rail\n // it is also standing in for the heading, which has no room at 80px and goes\n // screen-reader-only — so the grouping survives for both kinds of reader.\n showSeparator={groupIndex > 0}\n collapsed={collapsed}\n size={size}\n variant={variant}\n />\n ))}\n </nav>\n </ScrollArea>\n\n {(footerNav?.length || footer) && (\n <div className=\"flex shrink-0 flex-col\">\n {footerNav && footerNav.length > 0 && (\n <nav className=\"flex flex-col gap-3 px-4 pt-2\">\n {footerNav.map((item) => (\n <SidebarLink\n key={item.to}\n item={item}\n collapsed={collapsed}\n size={size}\n variant={variant}\n />\n ))}\n </nav>\n )}\n {/* No rule above the footer — the design separates it by whitespace alone. */}\n {footer}\n </div>\n )}\n </aside>\n </HashTargets.Provider>\n );\n}\n\nfunction SidebarGroup({\n group,\n showSeparator,\n collapsed,\n size,\n variant,\n}: {\n group: SidebarNavGroup;\n showSeparator: boolean;\n collapsed: boolean;\n size: NavItemSize;\n variant: NavItemVariant;\n}) {\n return (\n // 12px between rows, per the design — the rows read as separate pills rather than a\n // stack. Through 0.5.0 this was `gap-1`, which packed them into a near-continuous block.\n // The same gap spaces the separator and the heading, so neither needs a margin of its own.\n <div className=\"flex flex-col gap-3\">\n {showSeparator && <SidebarSeparator />}\n {group.title && (\n <p\n className={cn(\n 'text-body-tiny font-semibold uppercase tracking-wider text-neutral-tertiary',\n // Flush with the rows rather than inset a further 12px — the heading lines up\n // with the left edge of the pills below it, not with their labels.\n // `sr-only` is out of flow, so a collapsed group's heading costs no gap.\n collapsed ? 'sr-only' : 'px-0',\n )}\n >\n {group.title}\n </p>\n )}\n {group.items.map((item) => (\n <SidebarLink\n key={item.to}\n item={item}\n collapsed={collapsed}\n size={size}\n variant={variant}\n />\n ))}\n </div>\n );\n}\n\n/** Every `to` in the sidebar that carries a hash, so a page's plain row can step aside for one. */\nconst HashTargets = createContext<Set<string>>(new Set());\n\n/**\n * Whether a row is the current one. `NavLink` cannot decide this once rows link to sections:\n * it ignores the hash, so every row pointing into one page lit up together, and each carried\n * `aria-current=\"page\"`.\n */\nfunction useRowActive(item: SidebarNavItem): boolean {\n const location = useLocation();\n const hashTargets = useContext(HashTargets);\n const [path, hash] = item.to.split('#');\n const pathMatches = item.end\n ? location.pathname === path\n : location.pathname === path || location.pathname.startsWith(`${path.replace(/\\/$/, '')}/`);\n if (!pathMatches) return false;\n if (hash !== undefined) return location.hash === `#${hash}`;\n // A plain row is current unless a sibling row names the exact section being shown.\n return !hashTargets.has(`${location.pathname}${location.hash}`);\n}\n\nfunction SidebarLink({\n item,\n collapsed,\n size,\n variant,\n}: {\n item: SidebarNavItem;\n collapsed: boolean;\n size: NavItemSize;\n variant: NavItemVariant;\n}) {\n const active = useRowActive(item);\n const link = (\n <Link\n to={item.to}\n aria-current={active ? 'page' : undefined}\n aria-disabled={item.disabled || undefined}\n tabIndex={item.disabled ? -1 : undefined}\n // Link skips navigation when the click is prevented.\n onClick={item.disabled ? (event) => event.preventDefault() : undefined}\n // A collapsed row is a 44px square but the link still fills the 48px track, so it\n // needs to centre its child — otherwise the square sits 2px left of centre in the rail.\n className={cn('block w-full no-underline', collapsed && 'flex justify-center')}\n >\n <NavItem\n icon={item.icon}\n label={item.label}\n isActive={active}\n indicator={item.indicator}\n disabled={item.disabled}\n collapsed={collapsed}\n size={size}\n variant={variant}\n />\n </Link>\n );\n\n // Only when collapsed. Expanded, the label is already on screen and a tooltip repeating it\n // is noise — and mounting one per row would cost the expanded rail a portal it never shows.\n //\n // It wraps the `NavLink`, not the `NavItem`: `NavItem` renders a non-focusable `<span>`, so\n // anchoring to it would give a tooltip that opens on hover and is unreachable by keyboard —\n // the exact failure `Tooltip` documents itself as existing to prevent. The default\n // `describedby` association is right here; `labelledby` would replace the row's existing\n // `sr-only` name with a duplicate of itself and keep every row's portal permanently mounted.\n if (!collapsed) return link;\n\n return (\n <Tooltip title={item.label} side=\"right\">\n {link}\n </Tooltip>\n );\n}\n\n// ── SidebarSeparator ───────────────────────────────────────────────────────────\n\nexport type SidebarSeparatorProps = HTMLAttributes<HTMLDivElement>;\n\n/**\n * The rule between nav groups. `AppSidebar` draws one above every group after the first;\n * this is exported so the same line can be used in the `footer` slot or in a hand-composed\n * rail without anyone re-deriving `h-px bg-divider` and inevitably picking a different inset.\n *\n * Decorative by default. The grouping it marks is already carried semantically by each\n * group's heading — which stays in the accessibility tree even when the rail is collapsed and\n * the heading is visually hidden — so announcing the rule as well is redundant. Pass\n * `role=\"separator\"` through if you are using it somewhere that has no heading to lean on.\n */\nexport function SidebarSeparator({ className, ...rest }: SidebarSeparatorProps) {\n return <div aria-hidden className={cn('mx-1 h-px shrink-0 bg-divider', className)} {...rest} />;\n}\n\n// ── SidebarUserCard ────────────────────────────────────────────────────────────\n\nexport interface SidebarUserCardProps {\n name: string;\n role: string;\n onLogout: () => void;\n collapsed?: boolean;\n /** Extra menu entries above Sign out. */\n menu?: ReactNode;\n className?: string;\n}\n\n/**\n * The signed-in user block, for `AppSidebar`'s `footer` slot.\n *\n * Was private, and its props were on `AppSidebar` itself — which meant every consumer of the\n * sidebar had to have a user, a role and a logout handler whether it had a concept of any\n * of them or not. The docs site has none, and passes no footer.\n *\n * Its menu is `DropdownMenu` rather than the hand-rolled click-outside popover it was: that\n * one had no keyboard contract and, being absolutely positioned, was clipped by the\n * collapsed rail. `DropdownMenu` portals.\n */\nexport function SidebarUserCard({\n name,\n role,\n onLogout,\n collapsed = false,\n menu,\n className,\n}: SidebarUserCardProps) {\n const initial = name.trim().charAt(0);\n\n const items = (\n <>\n {menu}\n <DropdownMenuItem\n icon={<LogOutIcon className=\"size-3.5\" aria-hidden />}\n onSelect={onLogout}\n >\n Sign out\n </DropdownMenuItem>\n </>\n );\n\n if (collapsed) {\n return (\n <div className={cn('flex shrink-0 items-center justify-center p-4', className)}>\n <DropdownMenu>\n <DropdownMenuTrigger asChild label=\"User options\">\n <button type=\"button\" aria-label={`${name} — user options`} className=\"rounded-full\">\n <Avatar initial={initial} size=\"lg\" shape=\"circle\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent side=\"right\" align=\"end\">\n {items}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n );\n }\n\n return (\n <div className={cn('flex shrink-0 items-center gap-2.5 p-4', className)}>\n <Avatar initial={initial} size=\"lg\" shape=\"circle\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span className=\"truncate text-body-sm font-semibold leading-snug text-default\">\n {name}\n </span>\n <span className=\"truncate text-body-tiny font-regular leading-none text-default-secondary\">\n {role}\n </span>\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger asChild label=\"User options\">\n <button\n type=\"button\"\n aria-label={`${name} — user options`}\n // `hover:bg-default-hover` here was #F5F5F5 on a #F5F5F5 rail — no hover at all.\n className=\"flex size-6 shrink-0 items-center justify-center rounded-md text-default-secondary transition-colors hover:bg-brand-tertiary-hover hover:text-brand\"\n >\n <EllipsisVerticalIcon className=\"size-5\" aria-hidden />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent side=\"top\" align=\"end\">\n {items}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n );\n}\n\n// ── Route-driven navigation ────────────────────────────────────────────────────\n// Lives on this entry point (not the main one) because it needs react-router-dom.\n\nexport { NavTabs } from './nav-tabs';\nexport type { NavTabsProps, NavTabItem } from './nav-tabs';\n","import { type ClassValue, clsx } from 'clsx';\nimport { extendTailwindMerge } from 'tailwind-merge';\n\n/**\n * Every `fontSize` key in `tailwind-preset.cjs`, in the same order.\n *\n * `tailwind-merge` decides whether a `text-*` class is a **font size** or a **text colour**\n * by pattern: it recognises t-shirt sizes (`text-sm`, `text-2xl`) and bare lengths, and files\n * everything else under colour. Every size in this design system is a word — `text-body-sm`,\n * `text-heading`, `text-scale-07` — so without this list twMerge calls them colours, and then\n * drops them when a real colour follows in the same string:\n *\n * cn('text-body-micro text-neutral-tertiary') // → 'text-neutral-tertiary'\n *\n * The size vanishes and the element inherits its parent's. That is not hypothetical: it is\n * why the sidebar's group headings rendered at the 16px body default for two releases while\n * the source said `text-body-tiny`, and why chasing the number in the source never moved it.\n *\n * Keep in sync with the preset — `cn.test.ts` fails if they drift.\n */\nconst FONT_SIZES = [\n 'body-micro',\n 'body-tiny',\n 'body-xs',\n 'body-sm',\n 'body',\n 'body-lg',\n 'heading-sm',\n 'heading',\n 'heading-lg',\n 'subheading-sm',\n 'subheading',\n 'subheading-lg',\n 'subtitle-sm',\n 'subtitle',\n 'subtitle-lg',\n 'title-sm',\n 'title',\n 'title-lg',\n 'title-hero',\n 'scale-01',\n 'scale-02',\n 'scale-03',\n 'scale-04',\n 'scale-05',\n 'scale-06',\n 'scale-07',\n 'scale-08',\n 'scale-09',\n 'scale-10',\n 'scale-12',\n] as const;\n\nconst twMerge = extendTailwindMerge({\n extend: {\n classGroups: {\n 'font-size': [{ text: [...FONT_SIZES] }],\n },\n },\n});\n\n/**\n * `clsx` + `tailwind-merge`, taught this system's type scale.\n *\n * Use this instead of bare `clsx` in any component whose `className` prop is meant to\n * *override* a base utility — the composable `Card*` and `Modal*` parts, and anything\n * else built to be reshaped by its caller.\n *\n * Why it is necessary: `clsx` only concatenates. When two conflicting Tailwind\n * utilities both end up in the attribute, the winner is decided by *stylesheet order*,\n * not attribute order. Tailwind emits `flex-row` before `flex-col` and `gap-3` before\n * `gap-4`, so under plain `clsx`:\n *\n * <CardBody className=\"flex-row gap-3\" /> // base is 'flex flex-col gap-4 p-4'\n *\n * silently stays a column with a 4-unit gap. `twMerge` drops the losing class instead,\n * so the caller's intent wins.\n *\n * Everywhere else in the library `className` is purely additive, and plain `clsx`\n * remains correct — and cheaper. Do not sweep it out of those files.\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","/**\n * The keyboard focus ring, as one string, so every control draws the same one.\n *\n * Before 0.7.0 this exact class list was written out by hand in 18 places, with six\n * near-misses beside it (a missing offset colour, `ring-offset-2`). Use it in new and migrated\n * components rather than re-typing it.\n *\n * `FOCUS_RING` sits outside the element and needs room around it. Inside a scrolling or\n * `overflow-hidden` panel, such as a menu, a listbox or a table cell, the offset ring is clipped,\n * so items there use `FOCUS_RING_INSET`, which draws inside the element's own box.\n *\n * Highlight is not focus: menu and option items also tint their background when highlighted\n * (by pointer or by keyboard), but the tint alone does not meet WCAG 2.4.7 next to a hovered\n * sibling with the same tint. The ring is what marks the keyboard position.\n */\nexport const FOCUS_RING =\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default';\n\nexport const FOCUS_RING_INSET =\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand';\n","import {\n cloneElement,\n forwardRef,\n isValidElement,\n type CSSProperties,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport clsx from 'clsx';\n\n/**\n * `Slot` renders its own props onto its single child element instead of emitting a\n * wrapper of its own. It is what makes `asChild` work.\n *\n * Why the library needs it: before 0.4.0 there was no way to render a `Button` as a\n * router `<Link>`, or to use any component as a tooltip/popover anchor, because every\n * component hardcoded its host element. The usual workaround — a `component`/`as` prop —\n * multiplies generics across the whole surface and still cannot forward a ref through\n * two levels. Delegating to the child instead keeps the type surface flat.\n *\n * <Button asChild><Link to=\"/x\">Go</Link></Button>\n *\n * Merge rules, in order of who wins:\n * - `className` — concatenated, slot first, so the child's classes come last\n * - `style` — shallow-merged, child wins on conflicting keys\n * - `on*` — both run, slot's handler first; the child's runs even if the slot's\n * called `preventDefault`, matching normal DOM listener behaviour\n * - everything else — child wins, so a child's explicit `type` or `role` is never\n * clobbered by a default the slot happens to carry\n */\nexport interface SlotProps extends HTMLAttributes<HTMLElement> {\n /** The single element to merge into. */\n children?: ReactNode;\n /**\n * Rebuilds the child's children, so a component that decorates its content can keep\n * doing so through `asChild`.\n *\n * `Button` renders `leadingIcon`, a padded label span and `trailingIcon` around whatever\n * it is given. Without this, `<Button asChild><Link>Go</Link></Button>` would either drop\n * the icons (cloning the Link untouched) or drop \"Go\" (replacing the Link's children\n * outright). It receives the child's own children — \"Go\" — and returns the decorated\n * tree to place inside the child.\n */\n wrapChildren?: (childChildren: ReactNode) => ReactNode;\n}\n\nexport const Slot = forwardRef<HTMLElement, SlotProps>(function Slot(\n { children, wrapChildren, ...slotProps },\n forwardedRef,\n) {\n // A bare string, an array, or nothing at all — there is no element to merge into.\n // Rendering the children plain would silently drop every prop the slot carries\n // (including the ref and the ARIA wiring a trigger depends on), so this renders\n // nothing rather than something subtly broken.\n if (!isValidElement(children)) return null;\n\n const child = children as ReactElement<{ children?: ReactNode }>;\n\n const merged = {\n ...mergeProps(slotProps, child.props as Record<string, unknown>),\n ref: composeRefs(forwardedRef, getElementRef(child)),\n } as Record<string, unknown>;\n\n return wrapChildren\n ? cloneElement(child, merged, wrapChildren(child.props.children))\n : cloneElement(child, merged);\n});\n\nfunction mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps };\n\n for (const key in childProps) {\n const slotValue = slotProps[key];\n const childValue = childProps[key];\n\n if (/^on[A-Z]/.test(key)) {\n // Both handlers run. The slot's fires first so a component can set up state\n // before the consumer's own handler observes it.\n if (typeof slotValue === 'function' && typeof childValue === 'function') {\n merged[key] = (...args: unknown[]) => {\n (slotValue as (...a: unknown[]) => void)(...args);\n (childValue as (...a: unknown[]) => void)(...args);\n };\n } else {\n merged[key] = childValue ?? slotValue;\n }\n } else if (key === 'className') {\n merged[key] = clsx(slotValue as string, childValue as string);\n } else if (key === 'style') {\n merged[key] = { ...(slotValue as CSSProperties), ...(childValue as CSSProperties) };\n } else {\n merged[key] = childValue;\n }\n }\n\n return merged;\n}\n\n/**\n * React 19 exposes a `ref` on `props`; React 18 keeps it on the element. The peer range\n * is `>=18`, so both have to be read.\n */\nfunction getElementRef(element: ReactElement): Ref<unknown> | undefined {\n const asRecord = element as unknown as {\n ref?: Ref<unknown>;\n props?: { ref?: Ref<unknown> };\n };\n return asRecord.props?.ref ?? asRecord.ref;\n}\n\n/** Fan one node out to several refs, callback or object. */\nexport function composeRefs<T>(...refs: (Ref<T> | undefined)[]) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (!ref) continue;\n if (typeof ref === 'function') {\n ref(node);\n } else {\n (ref as { current: T | null }).current = node;\n }\n }\n };\n}\n","import { createContext, useContext, type ReactNode } from 'react';\nimport type { InputSize } from './input';\n\n/**\n * A default `size` for the form controls inside a container.\n *\n * `FilterBar size=\"sm\"` used to set only the gap between its children, so its own \"Sizes\"\n * example put a 24px Input beside a 36px Select and nothing in the API said the caller had\n * to size each control by hand. A container that has a size prop should mean it.\n *\n * Deliberately narrow: the context carries an `InputSize` and nothing else. It is not a\n * general \"component config\" channel — that is where implicit inheritance stops being\n * predictable. And an explicit `size` prop always wins, so the escape hatch is one prop on\n * the one control that needs to differ.\n *\n * `cloneElement` would have been the alternative and cannot work here: it never reaches a\n * control wrapped for layout (`<div className=\"w-56\"><Input /></div>`) or one nested inside\n * a consumer's own composite, and it would inject `size` into whatever element happens to\n * be the child — including a `<span>`, which React then warns about. Context is also how\n * the library already solves this shape, in `FieldContext`, `RadioGroupContext` and\n * `ToggleGroupContext`.\n */\nconst ControlSizeContext = createContext<InputSize | null>(null);\n\nexport interface ControlSizeProviderProps {\n size: InputSize;\n children: ReactNode;\n}\n\nexport function ControlSizeProvider({ size, children }: ControlSizeProviderProps) {\n return <ControlSizeContext.Provider value={size}>{children}</ControlSizeContext.Provider>;\n}\n\n/**\n * Resolve a control's size: an explicit prop, else the enclosing container's default,\n * else `md`.\n *\n * Call it unconditionally at the top of the component — it is a hook.\n */\nexport function useControlSize(explicit?: InputSize): InputSize {\n const inherited = useContext(ControlSizeContext);\n return explicit ?? inherited ?? 'md';\n}\n","import { forwardRef, type ButtonHTMLAttributes, type MouseEvent, type ReactNode } from 'react';\nimport clsx from 'clsx';\nimport { cn } from '../../lib/cn';\nimport { FOCUS_RING } from '../../lib/focus-ring';\nimport { Slot } from '../../lib/slot';\nimport { type ButtonSize } from './button';\nimport { useControlSize } from './control-size';\n\nexport type IconButtonVariant = 'primary' | 'neutral' | 'subtle';\n\nexport interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: IconButtonVariant;\n size?: ButtonSize;\n /** Required for accessibility — no visible text label */\n 'aria-label': string;\n /** Render the single child element instead of a `<button>` — e.g. a router `Link`. */\n asChild?: boolean;\n children?: ReactNode;\n}\n\nconst variantStyles: Record<IconButtonVariant, string> = {\n primary: clsx(\n 'bg-brand border border-brand text-brand-on-brand',\n 'hover:bg-brand-hover',\n 'disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled',\n 'aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled',\n ),\n // Neutral uses secondary background (light gray) for visual weight without a text label\n neutral: clsx(\n 'bg-default-secondary border border-default text-default',\n // icon turns brand blue on hover (Figma spec)\n 'hover:bg-default-secondary-hover hover:text-brand',\n 'disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled',\n 'aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled',\n ),\n subtle: clsx(\n 'bg-transparent text-neutral',\n // hover uses background-default-default-hover (#f5f5f5), icon turns brand blue (Figma spec)\n 'hover:bg-default-hover hover:text-brand',\n // disabled needs explicit border since there is no base border\n 'disabled:bg-disabled disabled:border disabled:border-disabled disabled:text-disabled-on-disabled',\n 'aria-disabled:bg-disabled aria-disabled:border aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled',\n ),\n};\n\nconst sizeStyles: Record<ButtonSize, string> = {\n lg: 'size-12 rounded-2xl [&_svg]:size-5',\n md: 'size-9 rounded-lg [&_svg]:size-5',\n sm: 'size-6 rounded-full [&_svg]:size-4',\n};\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n {\n variant = 'primary',\n size: sizeProp,\n asChild = false,\n type,\n disabled,\n onClick,\n children,\n className,\n ...props\n },\n ref,\n) {\n const size = useControlSize(sizeProp);\n // A disabled `asChild` element (say a router `<Link>`) has no `disabled` attribute, so it\n // has to refuse the press itself, as `Button` does.\n const softDisabled = asChild && Boolean(disabled);\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n if (softDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n onClick?.(event);\n };\n\n const rootProps = {\n // `cn`, so a caller's `className` beats the size's radius and the variant's colours.\n className: cn(\n 'inline-flex shrink-0 items-center justify-center transition-colors',\n FOCUS_RING,\n 'disabled:cursor-not-allowed aria-disabled:cursor-not-allowed',\n variantStyles[variant],\n sizeStyles[size],\n className,\n ),\n 'data-variant': variant,\n 'data-size': size,\n 'aria-disabled': softDisabled || undefined,\n onClick: handleClick,\n ...props,\n };\n\n // No `wrapChildren` here: an icon button has no label span or icon slots to rebuild, so\n // the child's own content is already the whole thing.\n if (asChild) {\n return (\n <Slot ref={ref} tabIndex={disabled ? -1 : undefined} {...rootProps}>\n {children}\n </Slot>\n );\n }\n\n return (\n <button\n ref={ref}\n // Without an explicit type, a button inside a <form> defaults to `submit` and an\n // icon button meant to reveal a password or open a menu submits the form instead.\n type={type ?? 'button'}\n disabled={disabled}\n {...rootProps}\n >\n {children}\n </button>\n );\n});\n","import clsx from 'clsx';\n\nexport type AvatarSize = 'sm' | 'md' | 'lg';\nexport type AvatarShape = 'circle' | 'square';\n\nexport interface AvatarInitialProps {\n type?: 'initial';\n /** Single character — Figma spec: one letter only to avoid overflow */\n initial: string;\n size?: AvatarSize;\n shape?: AvatarShape;\n className?: string;\n}\n\nexport interface AvatarImageProps {\n type: 'image';\n src: string;\n alt?: string;\n size?: AvatarSize;\n shape?: AvatarShape;\n className?: string;\n}\n\nexport type AvatarProps = AvatarInitialProps | AvatarImageProps;\n\n// Figma sizes: lg=40px, md=32px, sm=24px\nconst sizeStyles: Record<AvatarSize, string> = {\n lg: 'size-10',\n md: 'size-8',\n sm: 'size-6',\n};\n\n// Figma text sizes for initials: body-medium at lg, scales down proportionally\nconst initialTextStyles: Record<AvatarSize, string> = {\n lg: 'text-body font-semibold',\n md: 'text-body-xs font-semibold',\n sm: 'text-body-tiny font-semibold',\n};\n\n// Figma shape radii: circle=full, square: lg/md=8px (rounded-lg), sm=4px (rounded)\nfunction getShapeClass(shape: AvatarShape, size: AvatarSize): string {\n if (shape === 'circle') return 'rounded-full';\n return size === 'sm' ? 'rounded' : 'rounded-lg';\n}\n\nexport function Avatar(props: AvatarProps) {\n const { size = 'lg', shape = 'circle', className } = props;\n\n const base = clsx(\n 'shrink-0 overflow-hidden',\n sizeStyles[size],\n getShapeClass(shape, size),\n className,\n );\n\n if (props.type === 'image') {\n return (\n <div className={base}>\n <img\n src={props.src}\n alt={props.alt ?? ''}\n className=\"size-full object-cover\"\n />\n </div>\n );\n }\n\n return (\n <div\n className={clsx(base, 'flex items-center justify-center')}\n style={{\n background:\n 'linear-gradient(135deg, var(--color-graphic-blue) 30%, var(--color-graphic-red) 100%)',\n }}\n >\n <span\n className={clsx(\n 'select-none leading-none text-brand-on-brand',\n initialTextStyles[size],\n )}\n >\n {props.initial.charAt(0).toUpperCase()}\n </span>\n </div>\n );\n}\n","import { useCallback, useRef, useState } from 'react';\n\nexport interface UseControllableStateOptions<T> {\n /** The controlled value. Passing anything other than `undefined` takes control. */\n value?: T;\n /** Initial value when uncontrolled. */\n defaultValue: T;\n /** Fired on every change, controlled or not. */\n onChange?: (value: T) => void;\n}\n\n/**\n * One state value that works controlled or uncontrolled, the way every Radix and\n * shadcn/ui control does.\n *\n * Before 0.4.0 nothing in this library supported an uncontrolled mode — `Checkbox`,\n * `Toggle`, `Tabs`, `SegmentedControl`, `ButtonGroup` and `MultiSelectCard` all *required*\n * a value plus a change handler, so the simplest possible use site still needed a\n * `useState` in the consumer. `DropdownMenu` had the opposite problem: its open state was\n * entirely internal, so a caller could neither open it programmatically nor observe it.\n *\n * Control is decided per render by whether `value` is `undefined`. A component that\n * starts controlled and later passes `undefined` will fall back to its internal value —\n * the same caveat React itself has with inputs, and for the same reason.\n */\nexport function useControllableState<T>({\n value,\n defaultValue,\n onChange,\n}: UseControllableStateOptions<T>): [T, (next: T | ((prev: T) => T)) => void] {\n const [internal, setInternal] = useState<T>(defaultValue);\n\n const isControlled = value !== undefined;\n const current = isControlled ? value : internal;\n\n // Kept in a ref so `setValue` stays referentially stable across renders. Without this\n // every consumer that puts it in a dependency array re-subscribes on each render.\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const currentRef = useRef(current);\n currentRef.current = current;\n\n const isControlledRef = useRef(isControlled);\n isControlledRef.current = isControlled;\n\n const setValue = useCallback((next: T | ((prev: T) => T)) => {\n const resolved =\n typeof next === 'function' ? (next as (prev: T) => T)(currentRef.current) : next;\n\n if (resolved === currentRef.current) return;\n\n // A controlled component must not move its own value — the parent owns it and will\n // pass the new one back down. Only the notification goes out.\n if (!isControlledRef.current) setInternal(resolved);\n onChangeRef.current?.(resolved);\n }, []);\n\n return [current, setValue];\n}\n","import clsx from 'clsx';\nimport { SCROLLBAR_CLASSES } from '../../lib/scrollbar';\nimport type { InputSize } from '../forms/input';\n\n/**\n * The one option-list look, shared by every component that pops a panel of choices:\n * `DropdownMenu`, `ContextMenu`, `Menubar`, `Combobox`, `Command` and `Select`.\n *\n * Before this existed the four implementations had drifted: menus used `py-1` panels with\n * full-bleed square `px-3` items, while `Combobox` and `Command` used `p-1` panels with\n * inset `rounded-md px-2.5` ones. Menus moved, not the other two — a rounded highlight\n * needs the panel's own inset padding or its corners collide with the panel border on the\n * first and last item, and the inset form was already 2 of the 3 sites and the 2 newest.\n *\n * Strings, not components, and deliberately in its own module: `forms/` consumes these,\n * and importing `menu-core` from there would pull the whole menu component tree into the\n * bundle graph — tsup runs with no code splitting.\n */\n\n// ── Panel ──────────────────────────────────────────────────────────────────────\n\nexport const OVERLAY_PANEL = 'rounded-lg border border-default bg-default p-1 shadow-300';\n\n/** Menus need a floor width; anchored lists take their width from the trigger. */\nexport const OVERLAY_PANEL_MENU = clsx(OVERLAY_PANEL, 'min-w-[168px]');\n\n/**\n * Scroll cap for an anchored list. Prefers the collision-aware height `useFloatingPanel`\n * writes to `--panel-available-height` when `matchAnchorWidth` is set, falling back to\n * 16rem so the class is safe on a panel that never measured.\n */\nexport const OVERLAY_PANEL_SCROLL = clsx(\n 'max-h-[min(16rem,var(--panel-available-height,16rem))] overflow-y-auto',\n // A floating panel is already its own scroll container and keeps focus on the input or a\n // roving option, so it needs the scrollbar styling but not `ScrollArea`'s tab stop.\n SCROLLBAR_CLASSES,\n);\n\n// ── Item ───────────────────────────────────────────────────────────────────────\n\n/**\n * Carries no padding and no text size — those live in `OVERLAY_ITEM_SIZE`.\n *\n * `clsx` only concatenates, so a base carrying `px-3` beside a size carrying `px-2.5`\n * would resolve by stylesheet order rather than attribute order. Keeping each utility in\n * exactly one of the two strings makes the composition order-independent.\n */\nexport const OVERLAY_ITEM_BASE =\n 'flex w-full cursor-pointer select-none items-start gap-2 rounded-md text-left outline-none transition-colors';\n\nexport const OVERLAY_ITEM_SIZE: Record<InputSize, string> = {\n lg: 'px-3 py-2.5 text-body',\n md: 'px-2.5 py-2 text-body-sm',\n sm: 'px-2 py-1.5 text-body-tiny',\n};\n\nexport type OverlayItemTone = 'default' | 'danger';\n\n/** Hover and keyboard focus share one background — there is no separate active token. */\nexport function overlayItemTone(tone: OverlayItemTone, disabled: boolean) {\n if (disabled) return 'cursor-not-allowed text-disabled';\n return tone === 'danger'\n ? 'text-danger hover:bg-danger-tertiary focus:bg-danger-tertiary'\n : 'text-default hover:bg-default-secondary focus:bg-default-secondary';\n}\n\n/** Highlight driven by state rather than `:hover` — for lists using aria-activedescendant. */\nexport const OVERLAY_ITEM_ACTIVE = 'bg-default-secondary';\n\n// ── Group heading and separator ────────────────────────────────────────────────\n\nexport const OVERLAY_HEADING =\n 'px-2.5 py-1.5 text-body-tiny font-semibold uppercase tracking-wide text-default-tertiary';\n\n/** `-mx-1` cancels the panel's `p-1` so the rule still spans edge to edge. */\nexport const OVERLAY_SEPARATOR = '-mx-1 my-1 h-px bg-divider';\n","import clsx from 'clsx';\n\n/**\n * Styled native scrollbars, for the components that must own their own overflow and so\n * cannot delegate to `ScrollArea`.\n *\n * Two kinds qualify. A table wrapper, a tab strip or a stepper, where inserting another\n * element would break the layout or the `<table>` element relationship; and a floating panel\n * that is already its own scroll container. Both hold focusable children, so a keyboard user\n * can already reach and scroll them — which is the one thing `ScrollArea` adds beyond these\n * classes, and the one thing they do not need.\n *\n * Prefer `ScrollArea` for a scrolling *region* of content. Reach for this only when a wrapper\n * element is not an option, and say why at the call site.\n *\n * A plain string module rather than an export from `scroll-area.tsx`: `menu-styles.ts` needs\n * it, and importing a component module from a style module would pull the component into the\n * bundle graph for the sake of a class list.\n */\nexport const SCROLLBAR_CLASSES = clsx(\n // Firefox and the standard property.\n '[scrollbar-color:var(--color-background-default-tertiary)_transparent] [scrollbar-width:thin]',\n // WebKit/Blink.\n '[&::-webkit-scrollbar]:size-2',\n '[&::-webkit-scrollbar-track]:bg-transparent',\n '[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-default-tertiary',\n '[&::-webkit-scrollbar-thumb:hover]:bg-neutral-secondary',\n '[&::-webkit-scrollbar-corner]:bg-transparent',\n);\n","import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\n\nexport interface PortalProps {\n children: ReactNode;\n /**\n * Where to mount. Defaults to the nearest `PortalContainerProvider`, else `document.body`.\n *\n * Pass a container when the app renders inside a shadow root or a scoped theme\n * wrapper — the portal must stay inside whatever element the design tokens are\n * declared on, or every `var(--color-*)` resolves to nothing.\n */\n container?: HTMLElement | null;\n}\n\n/**\n * The default mount point for every `Portal` beneath it.\n *\n * A Radix modal (`Modal`, `Drawer`) traps focus inside its content, hides everything else\n * from assistive tech and treats a press anywhere else as \"outside\". A floating panel that\n * is not itself built on Radix, such as `Combobox`'s listbox or a `DatePicker` calendar,\n * would portal to `document.body` and land in exactly that \"everything else\": focus would be\n * pulled back out of it, and choosing an option would close the dialog. So each Radix modal\n * provides its own content node here, and those panels portal inside the dialog instead.\n * They position with `strategy: 'fixed'`, so the dialog's scroll container does not clip them.\n */\nconst PortalContainerContext = createContext<HTMLElement | null>(null);\n\nexport function PortalContainerProvider({\n container,\n children,\n}: {\n container: HTMLElement | null;\n children: ReactNode;\n}) {\n return (\n <PortalContainerContext.Provider value={container}>{children}</PortalContainerContext.Provider>\n );\n}\n\n/** The container a `Portal` here would mount into, for Radix parts that take `container`. */\nexport function usePortalContainer(): HTMLElement | null {\n return useContext(PortalContainerContext);\n}\n\n/**\n * Renders `children` outside the parent DOM hierarchy.\n *\n * Until 0.4.0 this library never called `createPortal` — `Modal`, `Drawer`,\n * `DropdownMenu`, `RoleComboBox` and the sidebar menu all rendered inline. Two concrete\n * failures came out of that:\n *\n * - `DropdownMenu` was positioned `absolute` inside a `relative` wrapper, so it was\n * clipped by `Card`'s `overflow-hidden` and by `DataTable`'s `overflow-x-auto` — the\n * two places its own doc comment said it was for.\n * - `position: fixed` resolves against the nearest ancestor with `transform`, `filter`,\n * `backdrop-filter`, `perspective`, `will-change` or `contain`, so a `Modal` opened\n * from inside any transformed ancestor was positioned against that ancestor rather\n * than the viewport, and `z-50` was scoped to a stacking context it did not control.\n *\n * Mounting is deferred to an effect so the server render and the first client render\n * agree — reaching for `document` during render breaks SSR and hydration.\n */\nexport function Portal({ children, container }: PortalProps) {\n const [mounted, setMounted] = useState(false);\n const contextContainer = useContext(PortalContainerContext);\n\n useEffect(() => setMounted(true), []);\n\n if (!mounted) return null;\n\n const target =\n container ?? contextContainer ?? (typeof document === 'undefined' ? null : document.body);\n if (!target) return null;\n\n return createPortal(children, target);\n}\n","/**\n * Runs a consumer's event handler, then the component's own, unless the consumer called\n * `preventDefault()`. The same contract Radix uses, so behaviour is uniform across the\n * library.\n *\n * Use it wherever a component has its own handler for an event that consumers may also pass.\n * The bug it exists for appeared in five 0.6 components: the built-in handler was written as\n * a JSX attribute and `{...rest}` was spread after it, so a consumer's `onClick` or `onKeyDown`\n * silently replaced the toggle, the arrow keys or the roving focus.\n */\nexport function composeEventHandlers<E extends { defaultPrevented: boolean }>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n): (event: E) => void {\n return (event) => {\n theirs?.(event);\n if (!event.defaultPrevented) ours(event);\n };\n}\n","import { useId, type ReactElement, type ReactNode } from 'react';\nimport { Tooltip as TooltipPrimitive } from 'radix-ui';\nimport { cn } from '../../lib/cn';\nimport type { FloatingAlign, FloatingSide } from './floating';\nimport { usePortalContainer } from './portal';\n\nexport interface TooltipProps {\n /**\n * The trigger. Must be a single focusable element — a tooltip that can only be reached\n * with a pointer is invisible to keyboard and touch users, so this deliberately does not\n * wrap its child in a span to make it hoverable.\n */\n children: ReactElement;\n /** Bold first line. Matches Figma's `Title` property. */\n title?: ReactNode;\n /** Supporting line. Matches Figma's `Body` / `Has Body`. */\n body?: ReactNode;\n side?: FloatingSide;\n align?: FloatingAlign;\n /** Delay before opening on hover, in ms. Default `150`. Keyboard focus opens at once. */\n openDelay?: number;\n /**\n * @deprecated Ignored from 0.7.0. The tooltip now stays open while the pointer travels\n * from the trigger onto it and while it is hovered, as WCAG 1.4.13 requires, which is what\n * a close delay used to approximate. Remove it from call sites; it will be dropped in 0.8.\n */\n closeDelay?: number;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * `describedby` — the trigger keeps its own name and the tooltip adds detail. This is\n * almost always what you want. `labelledby` makes the tooltip *be* the trigger's name,\n * for an icon-only button with no other text. Default `describedby`.\n *\n * Deliberately not called `as`: everywhere else in this library `as` chooses the rendered\n * element, and reusing it for something else here would be a trap (it also makes\n * `jsx-a11y`'s polymorphic-component checking treat the value as a tag name).\n */\n association?: 'describedby' | 'labelledby';\n className?: string;\n}\n\n/**\n * Tooltip. Matches Figma's `Tooltip` set — `Placement: Top | Left | Right | Bottom`, with\n * a title and an optional body.\n *\n * Built on Radix Tooltip from 0.7.0, which gets right what a naive tooltip does not:\n *\n * - **Keyboard and touch reachable.** Opens on keyboard focus as well as hover, and closes\n * on Escape. A hover-only tooltip is inaccessible to half the people using it.\n * - **Hoverable (WCAG 1.4.13).** It stays open while the pointer moves onto it, so a\n * magnifier user can read it. 0.6 closed it the moment the pointer left the trigger.\n * - **Escape closes only the tooltip.** It goes through the same layer stack as `Modal`, so\n * dismissing a tooltip inside a dialog no longer closes the dialog too.\n * - **Referenced, not floating text.** The trigger is `aria-describedby` the tooltip (or\n * `aria-labelledby` it), so it is announced *with* the control.\n * - **`role=\"tooltip\"` and no interactive content.** Use `Popover` for anything a user acts on.\n *\n * Each tooltip carries its own Radix provider, so there is nothing to mount at the app root.\n */\nexport function Tooltip({\n children,\n title,\n body,\n side = 'top',\n align = 'center',\n openDelay = 150,\n open,\n defaultOpen,\n onOpenChange,\n association = 'describedby',\n className,\n}: TooltipProps) {\n const container = usePortalContainer();\n const labelId = useId();\n const labelled = association === 'labelledby';\n\n const content = (\n <>\n {title && <p className=\"font-semibold\">{title}</p>}\n {body && <p className={cn(title && 'mt-0.5 opacity-80')}>{body}</p>}\n </>\n );\n\n return (\n <TooltipPrimitive.Provider delayDuration={openDelay}>\n <TooltipPrimitive.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <TooltipPrimitive.Trigger\n asChild\n // As the trigger's *name*, the tooltip text has to exist while closed too, or the\n // control is unnamed; so it is rendered hidden, permanently, and Radix's own\n // description of it is switched off to avoid reading the name twice.\n {...(labelled ? { 'aria-labelledby': labelId, 'aria-describedby': undefined } : {})}\n >\n {children}\n </TooltipPrimitive.Trigger>\n {labelled && (\n <span id={labelId} hidden>\n {title}\n {body ? ' ' : null}\n {body}\n </span>\n )}\n <TooltipPrimitive.Portal container={container ?? undefined}>\n <TooltipPrimitive.Content\n side={side}\n align={align}\n sideOffset={6}\n collisionPadding={8}\n className={cn(\n 'z-tooltip max-w-[260px] rounded-lg bg-neutral px-3 py-2 shadow-300',\n 'text-body-xs text-neutral-on-neutral',\n className,\n )}\n >\n {content}\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n </TooltipPrimitive.Provider>\n );\n}\n","import {\n Fragment,\n forwardRef,\n useId,\n type ComponentType,\n type ForwardRefExoticComponent,\n type HTMLAttributes,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type RefAttributes,\n} from 'react';\nimport clsx from 'clsx';\nimport { CheckIcon, ChevronRightIcon } from 'lucide-react';\nimport { cn } from '../../lib/cn';\nimport { FOCUS_RING_INSET } from '../../lib/focus-ring';\nimport {\n OVERLAY_HEADING,\n OVERLAY_ITEM_BASE,\n OVERLAY_ITEM_SIZE,\n OVERLAY_PANEL_MENU,\n OVERLAY_SEPARATOR,\n type OverlayItemTone,\n} from './menu-styles';\nimport { usePortalContainer } from './portal';\n\n/**\n * The shared item set behind `DropdownMenu`, `ContextMenu` and `Menubar`.\n *\n * All three are the same WAI-ARIA menu: identical items, keyboard contract and ARIA. Only how\n * they *open* differs: a trigger button, a right-click at the pointer, or a bar of triggers.\n * From 0.7.0 that contract is Radix's (roving focus, typeahead, Home/End, submenus with a\n * safe pointer path, Escape through the shared layer stack), and this module only supplies\n * the look and our props.\n *\n * Radix scopes each item to its own root (`DropdownMenu.Item` will not work inside a\n * `ContextMenu`), so `createMenuParts` builds one identically styled set per primitive. That\n * keeps it one implementation, not three copies.\n */\n\n/** Panel chrome, shared so the three menus cannot drift apart visually. */\nexport const MENU_PANEL_CLASSES = cn('z-popover', OVERLAY_PANEL_MENU, 'focus:outline-none');\n\nconst ITEM_BASE = clsx(\n OVERLAY_ITEM_BASE,\n OVERLAY_ITEM_SIZE.md,\n // Highlight follows Radix's `data-highlighted`, which tracks pointer and keyboard alike.\n // The ring marks the keyboard position on top of it: the tint alone, shared with hover,\n // cannot tell a keyboard user which of two tinted items has focus.\n FOCUS_RING_INSET,\n 'data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled',\n);\n\nexport type MenuItemTone = OverlayItemTone;\n\n/** Tone as a state attribute, styled here, so call sites never pass colour classes. */\nconst ITEM_TONE: Record<MenuItemTone, string> = {\n default: 'text-default data-[highlighted]:bg-default-secondary',\n danger: 'text-danger data-[highlighted]:bg-danger-tertiary',\n};\n\n/** Keeps a press inside a portalled menu from reaching a clickable ancestor, e.g. a table row. */\nexport function stopToAncestors(event: ReactMouseEvent | ReactKeyboardEvent) {\n event.stopPropagation();\n}\n\n/**\n * Lands on an item when a menu opens, whatever opened it.\n *\n * Radix focuses the panel on open and moves on to the first item only after a keyboard\n * open. The APG menu button (and 0.6) put focus on an item either way, and on the *last* one\n * after ArrowUp. Wire it to the content's `onFocus`. It is deferred a microtask so it runs\n * after Radix's own entry focus rather than being undone by it.\n */\nexport function focusMenuEdge(\n event: { target: EventTarget; currentTarget: HTMLElement },\n edge: 'start' | 'end',\n) {\n if (event.target !== event.currentTarget) return;\n const panel = event.currentTarget;\n queueMicrotask(() => {\n const items = panel.querySelectorAll<HTMLElement>('[role^=\"menuitem\"]:not([data-disabled])');\n if (edge === 'end') items[items.length - 1]?.focus();\n else if (document.activeElement === panel) items[0]?.focus();\n });\n}\n\n// ── Prop types (one set, shared by all three menus) ───────────────────────────\n\nexport interface MenuItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n children: ReactNode;\n /** Called on activation. Call `event.preventDefault()` to keep the menu open. */\n onSelect?: (event: Event) => void;\n tone?: MenuItemTone;\n disabled?: boolean;\n /** Leading glyph. Marked decorative automatically. Matches Figma's `Icon` / `Has Icon`. */\n icon?: ReactNode;\n /** Second line. Matches Figma's `Description` / `Has Description`. */\n description?: ReactNode;\n /** Trailing shortcut hint. Matches Figma's `Shortcut` / `Has Shortcut`. */\n shortcut?: ReactNode;\n /** Typeahead match text, when `children` is not a plain string. */\n textValue?: string;\n}\n\nexport interface MenuCheckboxItemProps extends Omit<MenuItemProps, 'onSelect' | 'icon'> {\n checked: boolean;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nexport interface MenuRadioGroupProps {\n children: ReactNode;\n value?: string;\n onValueChange?: (value: string) => void;\n}\n\nexport interface MenuRadioItemProps extends Omit<MenuItemProps, 'onSelect' | 'icon'> {\n value: string;\n}\n\nexport interface MenuGroupProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n /** Names the group. Rendered as a heading when set. */\n label?: string;\n}\n\nexport interface MenuLabelProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n}\n\nexport interface MenuSeparatorProps extends HTMLAttributes<HTMLDivElement> {}\n\nexport interface MenuShortcutProps extends HTMLAttributes<HTMLSpanElement> {\n children: ReactNode;\n}\n\nexport interface MenuSubProps {\n children: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\nexport interface MenuSubTriggerProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n textValue?: string;\n}\n\nexport interface MenuSubContentProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n}\n\n// ── Items as data (0.8.0) ──────────────────────────────────────────────────────\n\ninterface MenuItemDefBase {\n /** Stable key. */\n id: string;\n /** Leave the entry out, e.g. `hidden: !can('delete')`. Separators left dangling are dropped. */\n hidden?: boolean;\n}\n\n/**\n * One menu entry as data: the same shape for `DropdownMenu`, `ContextMenu` and `Menubar`.\n * Each `type` renders through the matching part, so the keyboard contract and styling are the\n * parts' own. Omit `type` for a plain action.\n */\nexport type MenuItemDef =\n | (MenuItemDefBase & {\n type?: 'item';\n label: ReactNode;\n onSelect?: (event: Event) => void;\n tone?: MenuItemTone;\n disabled?: boolean;\n icon?: ReactNode;\n description?: ReactNode;\n shortcut?: ReactNode;\n textValue?: string;\n })\n | (MenuItemDefBase & {\n type: 'checkbox';\n label: ReactNode;\n checked: boolean;\n onCheckedChange?: (checked: boolean) => void;\n disabled?: boolean;\n shortcut?: ReactNode;\n textValue?: string;\n })\n | (MenuItemDefBase & {\n type: 'radio';\n value?: string;\n onValueChange?: (value: string) => void;\n options: { value: string; label: ReactNode; disabled?: boolean }[];\n })\n | (MenuItemDefBase & { type: 'group'; label?: string; items: MenuItemDef[] })\n | (MenuItemDefBase & {\n type: 'submenu';\n label: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n items: MenuItemDef[];\n })\n | (MenuItemDefBase & { type: 'label'; label: ReactNode })\n | (MenuItemDefBase & { type: 'separator' })\n /** Escape hatch: render a part yourself, e.g. an item with `asChild` around a router link. */\n | (MenuItemDefBase & { type: 'custom'; render: () => ReactNode });\n\n/**\n * Drops hidden entries, groups and submenus left empty, and separators that no longer sit\n * between two entries, so a permission-filtered menu never starts, ends or doubles up on a line.\n */\nexport function visibleMenuItems(items: readonly MenuItemDef[]): MenuItemDef[] {\n const kept = items.filter((item) => {\n if (item.hidden) return false;\n if (item.type === 'group' || item.type === 'submenu') return visibleMenuItems(item.items).length > 0;\n return true;\n });\n return kept.filter((item, i) => {\n if (item.type !== 'separator') return true;\n const prev = kept[i - 1];\n return i > 0 && i < kept.length - 1 && prev.type !== 'separator';\n });\n}\n\n// ── The primitive shape all three Radix menus share ────────────────────────────\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Part = ForwardRefExoticComponent<any & RefAttributes<HTMLDivElement>>;\n\nexport interface RadixMenuPrimitive {\n Item: Part;\n CheckboxItem: Part;\n RadioGroup: Part;\n RadioItem: Part;\n ItemIndicator: Part;\n Group: Part;\n Label: Part;\n Separator: Part;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Sub: ComponentType<any>;\n SubTrigger: Part;\n SubContent: Part;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Portal: ComponentType<any>;\n}\n\nexport function createMenuParts(P: RadixMenuPrimitive) {\n const Item = forwardRef<HTMLDivElement, MenuItemProps>(function MenuItem(\n { children, onSelect, tone = 'default', disabled = false, icon, description, shortcut, textValue, className, ...rest },\n ref,\n ) {\n const descriptionId = useId();\n return (\n <P.Item\n ref={ref}\n disabled={disabled}\n textValue={textValue}\n onSelect={onSelect}\n data-tone={tone}\n aria-describedby={description ? descriptionId : undefined}\n className={cn(ITEM_BASE, ITEM_TONE[tone], className)}\n {...rest}\n >\n {icon && (\n <span aria-hidden className=\"mt-0.5 flex size-4 shrink-0 items-center justify-center\">\n {icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate\">{children}</span>\n {description && (\n <span id={descriptionId} className=\"mt-0.5 block text-body-tiny text-default-secondary\">\n {description}\n </span>\n )}\n </span>\n {shortcut && (\n <span className=\"ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary\">{shortcut}</span>\n )}\n </P.Item>\n );\n });\n\n const CheckboxItem = forwardRef<HTMLDivElement, MenuCheckboxItemProps>(function MenuCheckboxItem(\n { children, checked, onCheckedChange, disabled = false, tone = 'default', shortcut, textValue, className, ...rest },\n ref,\n ) {\n return (\n <P.CheckboxItem\n ref={ref}\n checked={checked}\n onCheckedChange={(next: boolean | 'indeterminate') => onCheckedChange?.(next === true)}\n // Stays open: a checkbox item is for multi-select, and closing after each toggle\n // would make selecting three things take three round trips. Radix closes by default.\n onSelect={(event: Event) => event.preventDefault()}\n disabled={disabled}\n textValue={textValue}\n data-tone={tone}\n className={cn(ITEM_BASE, 'items-center', ITEM_TONE[tone], className)}\n {...rest}\n >\n <span aria-hidden className=\"flex size-4 shrink-0 items-center justify-center\">\n <P.ItemIndicator>\n <CheckIcon className=\"size-3.5\" strokeWidth={3} />\n </P.ItemIndicator>\n </span>\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n {shortcut && (\n <span className=\"ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary\">{shortcut}</span>\n )}\n </P.CheckboxItem>\n );\n });\n\n function RadioGroup({ children, value, onValueChange }: MenuRadioGroupProps) {\n return (\n <P.RadioGroup value={value} onValueChange={onValueChange}>\n {children}\n </P.RadioGroup>\n );\n }\n\n const RadioItem = forwardRef<HTMLDivElement, MenuRadioItemProps>(function MenuRadioItem(\n { children, value, disabled = false, tone = 'default', textValue, className, ...rest },\n ref,\n ) {\n return (\n <P.RadioItem\n ref={ref}\n value={value}\n disabled={disabled}\n textValue={textValue}\n data-tone={tone}\n className={cn(ITEM_BASE, 'items-center', ITEM_TONE[tone], className)}\n {...rest}\n >\n <span aria-hidden className=\"flex size-4 shrink-0 items-center justify-center\">\n <P.ItemIndicator>\n <span className=\"block size-1.5 rounded-full bg-current\" />\n </P.ItemIndicator>\n </span>\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n </P.RadioItem>\n );\n });\n\n const Group = forwardRef<HTMLDivElement, MenuGroupProps>(function MenuGroup(\n { children, label, className, ...rest },\n ref,\n ) {\n const labelId = useId();\n return (\n <P.Group ref={ref} aria-labelledby={label ? labelId : undefined} className={className} {...rest}>\n {label && (\n <div id={labelId} className={OVERLAY_HEADING}>\n {label}\n </div>\n )}\n {children}\n </P.Group>\n );\n });\n\n /** A non-interactive heading inside the menu. Matches Figma's `Menu Heading`. */\n const Label = forwardRef<HTMLDivElement, MenuLabelProps>(function MenuLabel(\n { className, ...rest },\n ref,\n ) {\n return <P.Label ref={ref} className={cn(OVERLAY_HEADING, className)} {...rest} />;\n });\n\n /** Matches Figma's `Menu Separator`. */\n const Separator = forwardRef<HTMLDivElement, MenuSeparatorProps>(function MenuSeparator(\n { className, ...rest },\n ref,\n ) {\n return <P.Separator ref={ref} className={cn(OVERLAY_SEPARATOR, className)} {...rest} />;\n });\n\n /** Trailing keyboard hint, for use outside an item's `shortcut` prop. */\n const Shortcut = forwardRef<HTMLSpanElement, MenuShortcutProps>(function MenuShortcut(\n { className, ...rest },\n ref,\n ) {\n return (\n <span ref={ref} className={cn('ml-auto pl-4 text-body-tiny text-default-tertiary', className)} {...rest} />\n );\n });\n\n /** A nested menu. New in 0.7.0: Radix supplies the hover intent and safe pointer path. */\n function Sub({ children, open, defaultOpen, onOpenChange }: MenuSubProps) {\n return (\n <P.Sub open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n {children}\n </P.Sub>\n );\n }\n\n /** The item that opens a `*Sub`. ArrowRight opens it, ArrowLeft closes it. */\n const SubTrigger = forwardRef<HTMLDivElement, MenuSubTriggerProps>(function MenuSubTrigger(\n { children, icon, disabled = false, textValue, className, ...rest },\n ref,\n ) {\n return (\n <P.SubTrigger\n ref={ref}\n disabled={disabled}\n textValue={textValue}\n className={cn(\n ITEM_BASE,\n 'items-center',\n ITEM_TONE.default,\n 'data-[state=open]:bg-default-secondary',\n className,\n )}\n {...rest}\n >\n {icon && (\n <span aria-hidden className=\"flex size-4 shrink-0 items-center justify-center\">\n {icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n <ChevronRightIcon aria-hidden className=\"ml-auto size-4 shrink-0 text-default-tertiary\" />\n </P.SubTrigger>\n );\n });\n\n const SubContent = forwardRef<HTMLDivElement, MenuSubContentProps>(function MenuSubContent(\n { className, onClick, onKeyDown, ...rest },\n ref,\n ) {\n const container = usePortalContainer();\n return (\n <P.Portal container={container ?? undefined}>\n <P.SubContent\n ref={ref}\n sideOffset={4}\n collisionPadding={8}\n className={cn(MENU_PANEL_CLASSES, className)}\n onClick={(event: ReactMouseEvent<HTMLDivElement>) => {\n onClick?.(event);\n stopToAncestors(event);\n }}\n onKeyDown={(event: ReactKeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n stopToAncestors(event);\n }}\n {...rest}\n />\n </P.Portal>\n );\n });\n\n /**\n * Renders `MenuItemDef[]` through the parts above. New in 0.8.0. The menus' `items` prop uses\n * it, and it is exported per menu (`DropdownMenuItems`…) for a custom trigger or content.\n */\n function Items({ items }: { items: readonly MenuItemDef[] }) {\n return <>{visibleMenuItems(items).map(renderItem)}</>;\n }\n\n function renderItem(item: MenuItemDef): ReactNode {\n switch (item.type) {\n case 'checkbox':\n return (\n <CheckboxItem\n key={item.id}\n checked={item.checked}\n onCheckedChange={item.onCheckedChange}\n disabled={item.disabled}\n shortcut={item.shortcut}\n textValue={item.textValue}\n >\n {item.label}\n </CheckboxItem>\n );\n case 'radio':\n return (\n <RadioGroup key={item.id} value={item.value} onValueChange={item.onValueChange}>\n {item.options.map((option) => (\n <RadioItem key={option.value} value={option.value} disabled={option.disabled}>\n {option.label}\n </RadioItem>\n ))}\n </RadioGroup>\n );\n case 'group':\n return (\n <Group key={item.id} label={item.label}>\n <Items items={item.items} />\n </Group>\n );\n case 'submenu':\n return (\n <Sub key={item.id}>\n <SubTrigger icon={item.icon} disabled={item.disabled}>\n {item.label}\n </SubTrigger>\n <SubContent>\n <Items items={item.items} />\n </SubContent>\n </Sub>\n );\n case 'label':\n return <Label key={item.id}>{item.label}</Label>;\n case 'separator':\n return <Separator key={item.id} />;\n case 'custom':\n return <Fragment key={item.id}>{item.render()}</Fragment>;\n default:\n return (\n <Item\n key={item.id}\n onSelect={item.onSelect}\n tone={item.tone}\n disabled={item.disabled}\n icon={item.icon}\n description={item.description}\n shortcut={item.shortcut}\n textValue={item.textValue}\n >\n {item.label}\n </Item>\n );\n }\n }\n\n return {\n Items,\n Item,\n CheckboxItem,\n RadioGroup,\n RadioItem,\n Group,\n Label,\n Separator,\n Shortcut,\n Sub,\n SubTrigger,\n SubContent,\n };\n}\n","import { forwardRef, useEffect, useRef, useState, type HTMLAttributes, type ReactNode } from 'react';\nimport clsx from 'clsx';\nimport { SCROLLBAR_CLASSES } from '../../lib/scrollbar';\nimport { composeRefs } from '../../lib/slot';\n\nexport type ScrollAreaAxis = 'vertical' | 'horizontal' | 'both';\n\nexport interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n axis?: ScrollAreaAxis;\n /**\n * Accessible name for the scrollable region. Strongly recommended — a scroll container\n * that becomes focusable (see below) needs to announce what it is.\n */\n label?: string;\n}\n\nconst OVERFLOW: Record<ScrollAreaAxis, string> = {\n vertical: 'overflow-y-auto overflow-x-hidden',\n horizontal: 'overflow-x-auto overflow-y-hidden',\n both: 'overflow-auto',\n};\n\nexport { SCROLLBAR_CLASSES } from '../../lib/scrollbar';\n\n/**\n * A scrollable region with styled scrollbars.\n *\n * **Native scrolling, deliberately.** shadcn/Radix replaces the scrollbar with a rendered\n * one, which looks tidier and costs real accessibility: an overlay scrollbar has to\n * reimplement keyboard scrolling, momentum, trackpad and pen behaviour, and the OS\n * \"click the track to page\" convention — and it drops out entirely if the JS fails. Styling\n * `::-webkit-scrollbar` plus `scrollbar-width`/`scrollbar-color` gets most of the look with\n * none of that risk, and degrades to a normal scrollbar where unsupported.\n *\n * The one thing this *does* add is the piece browsers get wrong: a scroll container is not\n * keyboard focusable by default in Chrome or Safari, so a keyboard-only user cannot scroll\n * an overflowing `<div>` at all unless something inside it is focusable. This measures its\n * own content and sets `tabIndex={0}` only while it actually overflows, so the region is\n * scrollable with the arrow keys without adding a pointless tab stop when it does not.\n */\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea(\n { children, axis = 'vertical', label, className, ...rest },\n ref,\n) {\n const localRef = useRef<HTMLDivElement>(null);\n const [overflows, setOverflows] = useState(false);\n\n useEffect(() => {\n const node = localRef.current;\n if (!node) return;\n\n const measure = () => {\n const vertical = node.scrollHeight > node.clientHeight + 1;\n const horizontal = node.scrollWidth > node.clientWidth + 1;\n setOverflows(\n axis === 'vertical' ? vertical : axis === 'horizontal' ? horizontal : vertical || horizontal,\n );\n };\n\n measure();\n\n // Feature-detected: `ResizeObserver` is absent in jsdom, in Safari before 13.1, and\n // during any server render, and an unguarded `new ResizeObserver` throws outright. The\n // measurement above has already run, so without the observer the tab stop is simply\n // decided once at mount rather than tracked — degraded, not broken.\n if (typeof ResizeObserver === 'undefined') return;\n\n // Content and box size both matter, so both are observed. On the element it catches the\n // box; on the first child it catches content growth.\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n if (node.firstElementChild) observer.observe(node.firstElementChild);\n return () => observer.disconnect();\n }, [axis, children]);\n\n return (\n <div\n ref={composeRefs<HTMLDivElement>(localRef, ref)}\n // `role=\"region\"` only once it is focusable and named, so an ordinary non-overflowing\n // wrapper does not add a landmark to the page for nothing.\n role={overflows && label ? 'region' : undefined}\n aria-label={overflows ? label : undefined}\n tabIndex={overflows ? 0 : undefined}\n data-slot=\"scroll-area\"\n className={clsx(\n OVERFLOW[axis],\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default',\n SCROLLBAR_CLASSES,\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n});\n","import {\n createContext,\n forwardRef,\n useContext,\n useMemo,\n useRef,\n type HTMLAttributes,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n} from 'react';\nimport { DropdownMenu as DropdownMenuPrimitive } from 'radix-ui';\nimport { EllipsisIcon } from 'lucide-react';\n\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/compose-event-handlers';\nimport { useControllableState } from '../../lib/use-controllable-state';\nimport { IconButton } from '../forms/icon-button';\nimport type { FloatingAlign, FloatingSide } from './floating';\nimport {\n MENU_PANEL_CLASSES,\n createMenuParts,\n focusMenuEdge,\n stopToAncestors,\n type MenuItemDef,\n} from './menu-core';\nimport { usePortalContainer } from './portal';\n\n/**\n * Overflow / row-actions menu.\n *\n * 0.4.0 rebuilt it to the WAI-ARIA menu contract after a version that declared the roles\n * and implemented none of the keys. 0.7.0 moves that contract onto Radix DropdownMenu, which\n * also brings submenus (`DropdownMenuSub`), the one thing 0.4.0 deliberately left out because\n * a half-built safe-travel path is worse than none.\n *\n * Kept from ours, on top of Radix:\n * - **ArrowUp on the trigger opens on the last item**, as the APG describes.\n * - **Tab closes the menu** so focus moves on through the page; Radix keeps Tab inside.\n * - **It works inside a clickable table row.** Presses on the trigger and in the panel stop\n * short of the row, the behaviour 0.2.0's `RowMenu` existed for.\n * - **Non-modal by default.** The page behind stays readable and interactive.\n */\n\nexport interface DropdownMenuProps {\n /** The parts: `DropdownMenuTrigger` and `DropdownMenuContent`. Omit when passing `items`. */\n children?: ReactNode;\n /**\n * The menu as data, rendered through the parts. New in 0.8.0. Use it or `children`, not both.\n * The same `MenuItemDef` shape as `ContextMenu` and `Menubar`.\n */\n items?: readonly MenuItemDef[];\n /** With `items`: the element that opens the menu. Default the `⋯` icon button. */\n trigger?: ReactNode;\n /** With `items` and the default trigger: its accessible name. Default \"Open menu\". */\n label?: string;\n /** With `items`: where the panel opens. Defaults as `DropdownMenuContent`. */\n side?: FloatingSide;\n align?: FloatingAlign;\n /** Controlled open state. Omit for uncontrolled. */\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * Block the page while open (Radix's default). Default `false`, matching 0.6: a menu is\n * not a dialog, and the page behind it stays usable.\n */\n modal?: boolean;\n}\n\ninterface DropdownMenuState {\n setOpen: (open: boolean) => void;\n /** Which end to land on when the menu opens; ArrowUp on the trigger means \"last item\". */\n pendingEdge: { current: 'start' | 'end' };\n}\n\nconst DropdownMenuStateContext = createContext<DropdownMenuState | null>(null);\n\nfunction useDropdownMenuState(part: string): DropdownMenuState {\n const value = useContext(DropdownMenuStateContext);\n if (!value) throw new Error(`<${part}> must be used inside <DropdownMenu>`);\n return value;\n}\n\nexport function DropdownMenu({\n children,\n items,\n trigger,\n label,\n side,\n align,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n modal = false,\n}: DropdownMenuProps) {\n const [open, setOpen] = useControllableState({\n value: openProp,\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n });\n const pendingEdge = useRef<'start' | 'end'>('start');\n const state = useMemo(() => ({ setOpen, pendingEdge }), [setOpen]);\n\n return (\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} modal={modal}>\n <DropdownMenuStateContext.Provider value={state}>\n {items ? (\n <>\n <DropdownMenuTrigger asChild={trigger != null} label={label}>\n {trigger}\n </DropdownMenuTrigger>\n <DropdownMenuContent side={side} align={align}>\n <DropdownMenuItems items={items} />\n </DropdownMenuContent>\n </>\n ) : (\n children\n )}\n </DropdownMenuStateContext.Provider>\n </DropdownMenuPrimitive.Root>\n );\n}\n\n// ── Trigger ────────────────────────────────────────────────────────────────────\n\nexport interface DropdownMenuTriggerProps extends HTMLAttributes<HTMLButtonElement> {\n children?: ReactNode;\n /** Render the child element instead of the default overflow button. */\n asChild?: boolean;\n /** Accessible name for the default `⋯` button. Ignored when `asChild` is set. */\n label?: string;\n}\n\nexport const DropdownMenuTrigger = forwardRef<HTMLButtonElement, DropdownMenuTriggerProps>(\n function DropdownMenuTrigger(\n { children, asChild = false, label = 'Open menu', onClick, onPointerDown, onMouseDown, onKeyDown, ...rest },\n ref,\n ) {\n const state = useDropdownMenuState('DropdownMenuTrigger');\n\n // Radix runs these first and then its own handler, so stopping propagation here keeps a\n // surrounding row from reacting without stopping the menu from opening.\n const handlers = {\n onClick: (event: ReactMouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n stopToAncestors(event);\n },\n onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => {\n onPointerDown?.(event);\n event.stopPropagation();\n },\n onMouseDown: (event: ReactMouseEvent<HTMLButtonElement>) => {\n onMouseDown?.(event);\n stopToAncestors(event);\n },\n onKeyDown: (event: ReactKeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === 'ArrowUp') {\n // Radix opens on ArrowDown only.\n event.preventDefault();\n state.pendingEdge.current = 'end';\n state.setOpen(true);\n }\n // Enter on the trigger must not also activate the row it sits in.\n if (event.key === 'Enter' || event.key === ' ') stopToAncestors(event);\n },\n };\n\n if (asChild) {\n return (\n <DropdownMenuPrimitive.Trigger ref={ref} asChild {...rest} {...handlers}>\n {children}\n </DropdownMenuPrimitive.Trigger>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Trigger ref={ref} asChild {...rest} {...handlers}>\n <IconButton variant=\"neutral\" size=\"sm\" aria-label={label}>\n {children ?? <EllipsisIcon className=\"size-4\" aria-hidden />}\n </IconButton>\n </DropdownMenuPrimitive.Trigger>\n );\n },\n);\n\n// ── Content ────────────────────────────────────────────────────────────────────\n\nexport interface DropdownMenuContentProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n side?: FloatingSide;\n align?: FloatingAlign;\n sideOffset?: number;\n /** Where to portal the menu. Defaults to the enclosing dialog, else `document.body`. */\n container?: HTMLElement | null;\n /** Called when focus returns on close. Call `preventDefault()` to stop it moving to the trigger. */\n onCloseAutoFocus?: (event: Event) => void;\n}\n\nexport const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuContentProps>(\n function DropdownMenuContent(\n {\n children,\n side = 'bottom',\n align = 'end',\n sideOffset = 6,\n container,\n className,\n onClick,\n onKeyDown,\n onFocus,\n onCloseAutoFocus,\n ...rest\n },\n ref,\n ) {\n const state = useDropdownMenuState('DropdownMenuContent');\n const inherited = usePortalContainer();\n\n return (\n <DropdownMenuPrimitive.Portal container={container ?? inherited ?? undefined}>\n <DropdownMenuPrimitive.Content\n ref={ref}\n side={side}\n align={align}\n sideOffset={sideOffset}\n collisionPadding={8}\n // Arrow keys wrap from the last item to the first and back, as they did in 0.6.\n loop\n className={cn(MENU_PANEL_CLASSES, className)}\n onCloseAutoFocus={composeEventHandlers(onCloseAutoFocus, () => {\n state.pendingEdge.current = 'start';\n })}\n onFocus={composeEventHandlers(onFocus, (event) => {\n const edge = state.pendingEdge.current;\n state.pendingEdge.current = 'start';\n focusMenuEdge(event, edge);\n })}\n onClick={(event) => {\n onClick?.(event);\n stopToAncestors(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n stopToAncestors(event);\n // Tab leaves the menu rather than walking it: close, and Radix hands focus back\n // to the trigger, from where the browser carries on.\n if (event.key === 'Tab') state.setOpen(false);\n }}\n {...rest}\n >\n {children}\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\n\n// ── Items ──────────────────────────────────────────────────────────────────────\n\nconst parts = createMenuParts(DropdownMenuPrimitive);\n\n/** Renders `MenuItemDef[]` inside your own `DropdownMenuContent`. New in 0.8.0. */\nexport const DropdownMenuItems = parts.Items;\nexport const DropdownMenuItem = parts.Item;\nexport const DropdownMenuCheckboxItem = parts.CheckboxItem;\nexport const DropdownMenuRadioGroup = parts.RadioGroup;\nexport const DropdownMenuRadioItem = parts.RadioItem;\nexport const DropdownMenuGroup = parts.Group;\nexport const DropdownMenuLabel = parts.Label;\nexport const DropdownMenuSeparator = parts.Separator;\nexport const DropdownMenuShortcut = parts.Shortcut;\nexport const DropdownMenuSub = parts.Sub;\nexport const DropdownMenuSubTrigger = parts.SubTrigger;\nexport const DropdownMenuSubContent = parts.SubContent;\n\nexport type {\n MenuItemDef,\n MenuItemProps as DropdownMenuItemProps,\n MenuItemTone as DropdownMenuItemTone,\n MenuCheckboxItemProps as DropdownMenuCheckboxItemProps,\n MenuRadioGroupProps as DropdownMenuRadioGroupProps,\n MenuRadioItemProps as DropdownMenuRadioItemProps,\n MenuGroupProps as DropdownMenuGroupProps,\n MenuLabelProps as DropdownMenuLabelProps,\n MenuSeparatorProps as DropdownMenuSeparatorProps,\n MenuShortcutProps as DropdownMenuShortcutProps,\n MenuSubProps as DropdownMenuSubProps,\n MenuSubTriggerProps as DropdownMenuSubTriggerProps,\n MenuSubContentProps as DropdownMenuSubContentProps,\n} from './menu-core';\n","import { type HTMLAttributes, type ReactNode } from 'react';\nimport clsx from 'clsx';\nimport { Slot } from '../../lib/slot';\n\nexport type NavItemSize = 'sm' | 'md';\nexport type NavItemVariant = 'card' | 'plain';\n\nexport interface NavItemProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * Leading glyph. Optional, but when `collapsed` it is the only thing left to look at, so\n * a row without one falls back to a monogram taken from the label.\n */\n icon?: ReactNode;\n label: string;\n /**\n * A destination that exists but cannot be opened right now (no permission, coming soon).\n * Dimmed, out of the tab order and inert under `asChild`, with `aria-disabled` so it is\n * still announced. New in 0.7.0; replaces `pointer-events-none opacity-40` at the call site.\n */\n disabled?: boolean;\n /**\n * The row you are on — the current route. Paints the brand fill and, under `asChild`, sets\n * `aria-current=\"page\"`; it also reflects to `data-state=\"active\"`.\n *\n * Not the same thing as focus, though Figma's `MenuButton` names this variant\n * `state=focussed`. That is a misnomer to fix on the design side: keyboard focus is the\n * ring below, it is transient and can land on any row, and if it painted the brand fill\n * too there would be no way to see which row is the current one while tabbing past it.\n */\n isActive?: boolean;\n /** Red indicator dot at top-right corner (e.g. unread count) */\n indicator?: boolean;\n /** Collapsed mode — label is visually hidden but stays in the accessibility tree. */\n collapsed?: boolean;\n /** Row height. `sm` suits a dense secondary nav or a nested group. */\n size?: NavItemSize;\n /**\n * Row weight.\n *\n * `card` gives every inactive row its own border and surface — right for a short primary\n * rail of eight or ten destinations, where each row is a target in its own right.\n * `plain` drops both, so an inactive row is just text: right for a long grouped nav,\n * where thirty bordered pills read as thirty cards rather than a list.\n *\n * A variant decides what a row looks like **at rest, and nothing else**. Hover and the\n * current-row fill are one vocabulary shared by both — see `STATE`. Through 0.5.0 each\n * variant defined its own, and `plain`'s was invisible against the rail it was written for.\n */\n variant?: NavItemVariant;\n /**\n * Render the single child element as the row, so the row itself is the link or button.\n *\n * `NavItem` is presentational by default — a `<span>` with hover styling. That is fine\n * inside a router `NavLink`, which is how `src/sidebar/` uses it, but on its own it is a\n * nav row that looks interactive and cannot be focused or activated. `asChild` is the\n * fix for anyone using it outside that wrapper:\n *\n * <NavItem asChild icon={<HouseIcon />} label=\"Home\">\n * <NavLink to=\"/\" />\n * </NavItem>\n */\n asChild?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\n/**\n * `md` is Figma's `MenuButton` in every dimension: 44px tall, 12px radius, 12px gap, 14px\n * padding-x. `square` is the collapsed footprint — the design does not stretch a collapsed row\n * to the rail width, it centres a 44×44 button, which is exactly `px-3.5` either side of a\n * 16px icon.\n *\n * The label is the one deliberate departure. Figma specifies Body Base (16px); this is\n * `text-body-sm` (14px), because 16px rows read as oversized against everything else in a\n * product shell. The design file is the authority on the box and the colours, not on this.\n *\n * `sm` has no counterpart in the design file; it is a code-only density for long navs.\n */\nconst SIZE: Record<NavItemSize, { box: string; label: string; square: string }> = {\n sm: { box: 'h-9 gap-2 rounded-lg px-3 py-1.5', label: 'text-body-xs', square: 'w-9' },\n md: { box: 'h-11 gap-3 rounded-xl px-3.5 py-2.5', label: 'text-body-sm', square: 'w-11' },\n};\n\n/**\n * Up to two characters standing in for a missing icon in the collapsed rail.\n *\n * Two rather than one because any nav long enough to be worth collapsing collides on first\n * letters — the docs' own sidebar has Button beside Badges and Input beside Icons. Multiple\n * words give one initial each (\"Color Tokens\" → \"CT\"); a single word gives its first two\n * (\"Button\" → \"Bu\"), which stays readable rather than shouting. Words that open with\n * punctuation are skipped, so \"Cards & Containers\" is \"CC\" and not \"C&\".\n */\nfunction monogram(label: string): string {\n const words = label.split(/\\s+/).filter((word) => /^[\\p{L}\\p{N}]/u.test(word));\n const [first, second] = words;\n // A label of nothing but symbols has no initials to take; show its first character.\n if (!first) return Array.from(label.trim())[0]?.toUpperCase() ?? '';\n if (second) return (Array.from(first)[0] + Array.from(second)[0]).toUpperCase();\n const [a, b] = Array.from(first);\n return a.toUpperCase() + (b ?? '').toLowerCase();\n}\n\n/**\n * What a row looks like when you are on it, and when you hover one you are not — shared by\n * both variants and declared nowhere else. Selection means one thing in this library.\n *\n * Through 0.5.0 each variant carried its own pair, and `plain`'s hover was\n * `hover:bg-default-hover` — a generic app-surface token resolving to `--prim-gray-100`,\n * which is the same #F5F5F5 as the `bg-default-secondary` rail a sidebar row sits on. Plain\n * rows therefore had **no visible hover at all** in light mode, and `plain`'s active\n * `bg-brand-tertiary` (#F1F7FD) was a 1.02:1 step against that same rail. The bug survived\n * because the docs demo every variant on `bg-default` — white — where the collision does\n * not occur.\n */\nconst STATE = {\n // Figma MenuButton `state=hover`. No border change: Figma holds it at #D9D9D9 through\n // hover and moves only the fill and the text.\n hover: 'hover:bg-brand-tertiary-hover hover:text-brand',\n // Figma MenuButton `state=focussed`, which is that file's name for selected — see the\n // `isActive` doc comment. Hovering the current row darkens it rather than reverting it to\n // the pale hover tint, which would read as the row losing its selection under the cursor.\n active: 'bg-brand text-brand-on-brand hover:bg-brand-hover',\n} as const;\n\n/** The resting appearance — the whole of the difference between the two variants. */\nconst VARIANT: Record<NavItemVariant, { active: string; inactive: string }> = {\n card: {\n // `border-transparent` holds the 1px so the icon and label do not shift outward when a\n // row becomes the current one — the same trick, for the same reason, as `button.tsx`.\n // `bg-brand` still paints edge to edge, since backgrounds clip to the border box.\n active: clsx('border border-transparent', STATE.active),\n inactive: clsx('border border-default bg-default text-default-secondary', STATE.hover),\n },\n plain: {\n active: STATE.active,\n inactive: clsx('text-default-secondary', STATE.hover),\n },\n};\n\nexport function NavItem({\n icon,\n label,\n isActive = false,\n indicator = false,\n collapsed = false,\n size = 'md',\n variant = 'card',\n asChild = false,\n disabled = false,\n children,\n className,\n onClick,\n ...rest\n}: NavItemProps) {\n const s = SIZE[size];\n const v = VARIANT[variant];\n\n const rootProps = {\n // Only meaningful when `asChild` renders a real link — a decorative span with\n // aria-current would be a lie.\n 'aria-current': asChild && isActive ? ('page' as const) : undefined,\n // Same attribute the disclosure components and `TableRow` use, so the state is\n // addressable from a consumer's CSS. `active` rather than `selected`: a nav row is where\n // you *are* (`aria-current=\"page\"`), which is a different thing from a row you have\n // *picked* (`aria-selected`) — `TableRow` is the latter and says `selected`.\n 'data-state': isActive ? ('active' as const) : undefined,\n 'data-disabled': disabled || undefined,\n 'aria-disabled': disabled || undefined,\n className: clsx(\n 'relative flex items-center transition-colors',\n // Unconditional: a row can also become focusable by the caller putting it inside a\n // link, which is how `src/sidebar/` uses it. A ring that only appears under `asChild`\n // leaves that case with no visible focus at all.\n // The offset is `default-secondary`, not `default`: a nav row's home is the sidebar\n // rail, and `ring-offset-default` is #FFFFFF, so a focused `plain` row drew a 1px white\n // halo on the #F5F5F5 rail. The offset itself is load-bearing — in dark mode\n // `ring-brand` and `bg-brand` are both #F1F7FD, so without it a focused *active* row\n // would have no visible ring at its inner edge.\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default-secondary',\n s.box,\n // Expanded rows fill the nav; a collapsed one is a centred square, not a stretched row.\n collapsed ? clsx('justify-center', s.square) : 'w-full',\n isActive ? v.active : v.inactive,\n 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40 data-[disabled]:hover:bg-transparent data-[disabled]:hover:text-default-secondary',\n className,\n ),\n ...rest,\n // After the spread: a disabled row refuses the press (a router Link skips navigation when\n // the event is prevented) and leaves the tab order, as a disabled control does.\n ...(disabled ? { tabIndex: -1 } : {}),\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n },\n };\n\n const content = (\n <>\n {icon != null ? (\n <span aria-hidden className=\"shrink-0 [&_svg]:size-4\">\n {icon}\n </span>\n ) : (\n // Icons are optional, but the collapsed rail hides the label — so a row with neither\n // renders as an empty box. Through 0.5.0 that is exactly what a nav without icons\n // collapsed to, the docs site's own 36-row sidebar included. The monogram is\n // decorative in the same way the icon is: the `sr-only` label below still names the\n // row.\n collapsed && (\n <span\n aria-hidden\n // `min-w-4` rather than `size-4`: the box matches the 16px an icon would take,\n // but a wide pair like \"MW\" is allowed to outgrow it rather than be clipped.\n className=\"flex h-4 min-w-4 shrink-0 items-center justify-center text-body-tiny font-semibold leading-none tracking-tight\"\n >\n {monogram(label)}\n </span>\n )\n )}\n {/* `collapsed` hides the label visually but keeps it in the accessibility tree.\n Through 0.3.0 the span was not rendered at all and no `aria-label` replaced it,\n so a collapsed sidebar was nine unlabelled icon links — the icon itself carries\n no name, being decorative. */}\n <span\n className={clsx(\n 'min-w-0 truncate font-regular leading-snug',\n s.label,\n collapsed ? 'sr-only' : 'flex-1',\n )}\n >\n {label}\n </span>\n {indicator && (\n <span\n // The dot is the only carrier of \"there is something new here\", so it needs a\n // name of its own rather than being purely decorative.\n role=\"status\"\n aria-label=\"Unread\"\n className=\"absolute -right-px -top-px size-2 rounded-full bg-danger\"\n />\n )}\n </>\n );\n\n if (asChild) {\n // The child element becomes the row itself, so the icon/label/indicator go inside it\n // and its own children (usually nothing, since the label comes from `label`) are\n // discarded in favour of the composed content.\n return (\n <Slot wrapChildren={() => content} {...rootProps}>\n {children}\n </Slot>\n );\n }\n\n return <span {...rootProps}>{content}</span>;\n}\n","import { NavLink } from 'react-router-dom';\nimport clsx from 'clsx';\n\nimport { SCROLLBAR_CLASSES } from '../lib/scrollbar';\n\nexport interface NavTabItem {\n to: string;\n label: string;\n /** Match this route exactly — needed for an index route like `/account`. */\n end?: boolean;\n}\n\nexport interface NavTabsProps {\n items: NavTabItem[];\n className?: string;\n}\n\n/** Route-driven tab strip, backed by react-router's `NavLink`.\n *\n * Use this when each tab is its own route. For state-driven tabs that do not change\n * the URL, use `Tabs` from the main entry point instead — it has no router dependency.\n *\n * The active underline and label use `brand-emphasis` (#0C2D58), the brand fill colour\n * Figma specifies for a tab rule, rather than the lighter `brand` border token. */\nexport function NavTabs({ items, className }: NavTabsProps) {\n return (\n // The links inside are the tab stops.\n <div\n className={clsx(\n 'flex gap-6 overflow-x-auto border-b border-default',\n SCROLLBAR_CLASSES,\n className,\n )}\n >\n {items.map((tab) => (\n <NavLink\n key={tab.to}\n to={tab.to}\n end={tab.end}\n className={({ isActive }) =>\n clsx(\n 'shrink-0 whitespace-nowrap border-b-2 pb-3 text-body-sm transition-colors',\n isActive\n ? 'border-brand-emphasis font-semibold text-brand-emphasis'\n : 'border-transparent font-medium text-default-secondary hover:text-default',\n )\n }\n >\n {tab.label}\n </NavLink>\n ))}\n </div>\n );\n}\n"],"mappings":";AAAA,SAAS,iBAAAA,gBAAe,cAAAC,aAAY,WAAAC,gBAAoD;AACxF,SAAS,MAAM,mBAAmB;AAClC,SAAS,iBAAiB,oBAAAC,mBAAkB,sBAAsB,kBAAkB;;;ACFpF,SAA0B,YAAY;AACtC,SAAS,2BAA2B;AAmBpC,IAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,UAAU,oBAAoB;AAAA,EAClC,QAAQ;AAAA,IACN,aAAa;AAAA,MACX,aAAa,CAAC,EAAE,MAAM,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E,0BAAAC,MAAC,gBACC;AAAA,sBAAAD,MAAC,uBAAoB,SAAO,MAAC,OAAM,gBACjC,0BAAAA,MAAC,YAAO,MAAK,UAAS,cAAY,GAAG,IAAI,wBAAmB,WAAU,gBACpE,0BAAAA,MAAC,UAAO,SAAkB,MAAK,MAAK,OAAM,UAAS,GACrD,GACF;AAAA,MACA,gBAAAA,MAAC,uBAAoB,MAAK,SAAQ,OAAM,OACrC,iBACH;AAAA,OACF,GACF;AAAA,EAEJ;AAEA,SACE,gBAAAC,MAAC,SAAI,WAAW,GAAG,0CAA0C,SAAS,GACpE;AAAA,oBAAAD,MAAC,UAAO,SAAkB,MAAK,MAAK,OAAM,UAAS;AAAA,IACnD,gBAAAC,MAAC,SAAI,WAAU,wCACb;AAAA,sBAAAD,MAAC,UAAK,WAAU,iEACb,gBACH;AAAA,MACA,gBAAAA,MAAC,UAAK,WAAU,4EACb,gBACH;AAAA,OACF;AAAA,IACA,gBAAAC,MAAC,gBACC;AAAA,sBAAAD,MAAC,uBAAoB,SAAO,MAAC,OAAM,gBACjC,0BAAAA;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,cAAY,GAAG,IAAI;AAAA,UAEnB,WAAU;AAAA,UAEV,0BAAAA,MAAC,wBAAqB,WAAU,UAAS,eAAW,MAAC;AAAA;AAAA,MACvD,GACF;AAAA,MACA,gBAAAA,MAAC,uBAAoB,MAAK,OAAM,OAAM,OACnC,iBACH;AAAA,OACF;AAAA,KACF;AAEJ;","names":["createContext","useContext","useMemo","ChevronRightIcon","clsx","Slot","forwardRef","clsx","jsx","clsx","forwardRef","IconButton","clsx","jsx","sizeStyles","clsx","clsx","clsx","createContext","useContext","useState","jsx","useContext","jsx","Fragment","forwardRef","useId","clsx","Fragment","jsx","jsxs","clsx","forwardRef","useId","forwardRef","useEffect","useRef","useState","clsx","jsx","forwardRef","ScrollArea","useRef","useState","useEffect","clsx","createContext","forwardRef","useContext","useRef","Fragment","jsx","jsxs","createContext","useContext","useRef","forwardRef","DropdownMenuTrigger","DropdownMenuContent","clsx","Fragment","jsx","jsxs","clsx","clsx","jsx","clsx","Fragment","jsx","jsxs","useMemo","ChevronRightIcon","createContext","useContext"]}
|
|
1
|
+
{"version":3,"sources":["../src/sidebar/index.tsx","../src/sidebar/nav-tabs.tsx","../src/lib/scrollbar.ts"],"sourcesContent":["import { forwardRef } from 'react';\nimport { Link, useLocation } from 'react-router-dom';\n\nimport { Sidebar } from '../index';\nimport type { SidebarLinkProps, SidebarProps } from '../index';\n\nexport type AppSidebarProps = Omit<SidebarProps, 'currentPath' | 'currentHash' | 'linkComponent'>;\n\n/** `Sidebar`'s link slot, filled with react-router's `Link`. */\nconst RouterLink = forwardRef<HTMLAnchorElement, SidebarLinkProps>(function RouterLink({ href, ...rest }, ref) {\n return <Link ref={ref} to={href} {...rest} />;\n});\n\n/**\n * The application nav rail, wired to react-router: the current row comes from `useLocation`\n * and rows link with `Link`.\n *\n * Lives on its own entry point (`@platned/ui/sidebar`) because `react-router-dom` is an\n * optional peer dependency. From 0.9.6 it is a thin wrapper over `Sidebar` on the main entry,\n * which takes the location and the link component as props — use that directly in an app on\n * another router (Next.js).\n *\n * Through 0.4.0 this was not a library component at all. It hardcoded ten product routes,\n * their labels and their icons, an `SCIC` wordmark, and an `isAdmin` flag gating two of the\n * rows — so the only app it could render was the one it was extracted from. Everything\n * app-specific is now a prop or a slot.\n *\n * Width is an explicit prop rather than something `className` overrides: the width is\n * conditional on `collapsed`, so a `className=\"w-64\"` would tailwind-merge away the\n * collapsed width too and break the collapse. Everything else about the shell is fair game\n * for `className` — `rounded-none` to flatten it for a full-bleed layout, for instance.\n */\nexport function AppSidebar(props: AppSidebarProps) {\n const location = useLocation();\n return (\n <Sidebar {...props} currentPath={location.pathname} currentHash={location.hash} linkComponent={RouterLink} />\n );\n}\n\n// Kept on this entry so imports from before 0.9.6 keep working; they live on the main one now.\nexport { SidebarSeparator, SidebarUserCard } from '../index';\nexport type {\n SidebarNavItem,\n SidebarNavGroup,\n SidebarSeparatorProps,\n SidebarUserCardProps,\n} from '../index';\n\n// ── Route-driven navigation ────────────────────────────────────────────────────\n// Lives on this entry point (not the main one) because it needs react-router-dom.\n\nexport { NavTabs } from './nav-tabs';\nexport type { NavTabsProps, NavTabItem } from './nav-tabs';\n","import { NavLink } from 'react-router-dom';\nimport clsx from 'clsx';\n\nimport { SCROLLBAR_CLASSES } from '../lib/scrollbar';\n\nexport interface NavTabItem {\n to: string;\n label: string;\n /** Match this route exactly — needed for an index route like `/account`. */\n end?: boolean;\n}\n\nexport interface NavTabsProps {\n items: NavTabItem[];\n className?: string;\n}\n\n/** Route-driven tab strip, backed by react-router's `NavLink`.\n *\n * Use this when each tab is its own route. For state-driven tabs that do not change\n * the URL, use `Tabs` from the main entry point instead — it has no router dependency.\n *\n * The active underline and label use `brand-emphasis` (#0C2D58), the brand fill colour\n * Figma specifies for a tab rule, rather than the lighter `brand` border token. */\nexport function NavTabs({ items, className }: NavTabsProps) {\n return (\n // The links inside are the tab stops.\n <div\n className={clsx(\n 'flex gap-6 overflow-x-auto border-b border-default',\n SCROLLBAR_CLASSES,\n className,\n )}\n >\n {items.map((tab) => (\n <NavLink\n key={tab.to}\n to={tab.to}\n end={tab.end}\n className={({ isActive }) =>\n clsx(\n 'shrink-0 whitespace-nowrap border-b-2 pb-3 text-body-sm transition-colors',\n isActive\n ? 'border-brand-emphasis font-semibold text-brand-emphasis'\n : 'border-transparent font-medium text-default-secondary hover:text-default',\n )\n }\n >\n {tab.label}\n </NavLink>\n ))}\n </div>\n );\n}\n","import clsx from 'clsx';\n\n/**\n * Styled native scrollbars, for the components that must own their own overflow and so\n * cannot delegate to `ScrollArea`.\n *\n * Two kinds qualify. A table wrapper, a tab strip or a stepper, where inserting another\n * element would break the layout or the `<table>` element relationship; and a floating panel\n * that is already its own scroll container. Both hold focusable children, so a keyboard user\n * can already reach and scroll them — which is the one thing `ScrollArea` adds beyond these\n * classes, and the one thing they do not need.\n *\n * Prefer `ScrollArea` for a scrolling *region* of content. Reach for this only when a wrapper\n * element is not an option, and say why at the call site.\n *\n * A plain string module rather than an export from `scroll-area.tsx`: `menu-styles.ts` needs\n * it, and importing a component module from a style module would pull the component into the\n * bundle graph for the sake of a class list.\n */\nexport const SCROLLBAR_CLASSES = clsx(\n // Firefox and the standard property.\n '[scrollbar-color:var(--color-background-default-tertiary)_transparent] [scrollbar-width:thin]',\n // WebKit/Blink.\n '[&::-webkit-scrollbar]:size-2',\n '[&::-webkit-scrollbar-track]:bg-transparent',\n '[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-default-tertiary',\n '[&::-webkit-scrollbar-thumb:hover]:bg-neutral-secondary',\n '[&::-webkit-scrollbar-corner]:bg-transparent',\n);\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,MAAM,mBAAmB;AAElC,SAAS,eAAe;AAqCxB,SAAS,kBAAkB,uBAAuB;;;ACxClD,SAAS,eAAe;AACxB,OAAOA,WAAU;;;ACDjB,OAAO,UAAU;AAmBV,IAAM,oBAAoB;AAAA;AAAA,EAE/B;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ADOQ;AAXD,SAAS,QAAQ,EAAE,OAAO,UAAU,GAAiB;AAC1D;AAAA;AAAA,IAEE;AAAA,MAAC;AAAA;AAAA,QACC,WAAWC;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAEC,gBAAM,IAAI,CAAC,QACV;AAAA,UAAC;AAAA;AAAA,YAEC,IAAI,IAAI;AAAA,YACR,KAAK,IAAI;AAAA,YACT,WAAW,CAAC,EAAE,SAAS,MACrBA;AAAA,cACE;AAAA,cACA,WACI,4DACA;AAAA,YACN;AAAA,YAGD,cAAI;AAAA;AAAA,UAZA,IAAI;AAAA,QAaX,CACD;AAAA;AAAA,IACH;AAAA;AAEJ;;;AD3CS,gBAAAC,YAAA;AADT,IAAM,aAAa,WAAgD,SAASC,YAAW,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK;AAC7G,SAAO,gBAAAD,KAAC,QAAK,KAAU,IAAI,MAAO,GAAG,MAAM;AAC7C,CAAC;AAqBM,SAAS,WAAW,OAAwB;AACjD,QAAM,WAAW,YAAY;AAC7B,SACE,gBAAAA,KAAC,WAAS,GAAG,OAAO,aAAa,SAAS,UAAU,aAAa,SAAS,MAAM,eAAe,YAAY;AAE/G;","names":["clsx","clsx","jsx","RouterLink"]}
|