@nswds/ui 9.2.0 → 9.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/breadcrumb.d.ts +1 -1
- package/dist/components/breadcrumb.js +5 -4
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button-group.js +3 -2
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/callout.d.ts +2 -2
- package/dist/components/callout.js +4 -3
- package/dist/components/callout.js.map +1 -1
- package/dist/components/description-list.js +7 -4
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/expandable-search.js +5 -4
- package/dist/components/expandable-search.js.map +1 -1
- package/dist/components/footer.d.ts +1 -1
- package/dist/components/footer.js +9 -5
- package/dist/components/footer.js.map +1 -1
- package/dist/components/header.d.ts +1 -1
- package/dist/components/header.js +9 -5
- package/dist/components/header.js.map +1 -1
- package/dist/components/hero.d.ts +2 -2
- package/dist/components/hero.js +22 -11
- package/dist/components/hero.js.map +1 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/link.d.ts +1 -1
- package/dist/components/main-nav.d.ts +1 -1
- package/dist/components/main-nav.js +9 -5
- package/dist/components/main-nav.js.map +1 -1
- package/dist/components/masthead.d.ts +1 -1
- package/dist/components/masthead.js +8 -4
- package/dist/components/masthead.js.map +1 -1
- package/dist/components/native-select.js +9 -6
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/page-header.d.ts +138 -0
- package/dist/components/page-header.js +181 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/select.js +6 -3
- package/dist/components/select.js.map +1 -1
- package/dist/components/skeleton.js +4 -3
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/tabs.js +7 -5
- package/dist/components/tabs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/resolve-variant.d.ts +23 -0
- package/dist/lib/resolve-variant.js +7 -0
- package/dist/lib/resolve-variant.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +5 -4
|
@@ -24,7 +24,7 @@ import * as React from 'react';
|
|
|
24
24
|
* look lands on the 4px grid (40px tall, 48px with the ellipsis).
|
|
25
25
|
*/
|
|
26
26
|
declare const breadcrumbVariants: (props?: ({
|
|
27
|
-
variant?: "default" | "
|
|
27
|
+
variant?: "default" | "band" | "soft" | "rail" | null | undefined;
|
|
28
28
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
29
29
|
/**
|
|
30
30
|
* The `sideOffset` to give a DropdownMenuContent opened from the ellipsis. The
|
|
@@ -7,6 +7,7 @@ import * as React from 'react';
|
|
|
7
7
|
import { IconChevronRight } from '../icons/chevron-right.js';
|
|
8
8
|
import { IconMoreHoriz } from '../icons/more-horiz.js';
|
|
9
9
|
import { overlayInk } from '../lib/overlay.js';
|
|
10
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
10
11
|
import { cn } from '../lib/utils.js';
|
|
11
12
|
import { TouchTarget } from './button.js';
|
|
12
13
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuLinkItem } from './dropdown-menu.js';
|
|
@@ -83,7 +84,7 @@ function Breadcrumb({
|
|
|
83
84
|
ref,
|
|
84
85
|
...props
|
|
85
86
|
}) {
|
|
86
|
-
const look = variant
|
|
87
|
+
const look = resolveVariant(variant, "default");
|
|
87
88
|
const collapses = collapse;
|
|
88
89
|
const navRef = React.useRef(null);
|
|
89
90
|
const [wraps, setWraps] = React.useState(null);
|
|
@@ -150,12 +151,12 @@ function Breadcrumb({
|
|
|
150
151
|
},
|
|
151
152
|
"aria-label": ariaLabel,
|
|
152
153
|
"data-slot": "breadcrumb",
|
|
153
|
-
"data-variant": look,
|
|
154
154
|
"data-collapse": collapses || void 0,
|
|
155
155
|
"data-measured": collapses && wraps !== null ? "" : void 0,
|
|
156
156
|
"data-collapsed": collapses && wraps ? "" : void 0,
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
...props,
|
|
158
|
+
"data-variant": look,
|
|
159
|
+
className: cn(breadcrumbVariants({ variant: look }), collapses && "w-full", className)
|
|
159
160
|
}
|
|
160
161
|
) });
|
|
161
162
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/breadcrumb.tsx"],"names":[],"mappings":";;;;;;;;;;;;AA4BA,MAAM,SAAA,GACJ,yGAAA;AASF,MAAM,WAAA,GACJ,kJAAA;AAsBF,MAAM,kBAAA,GAAqB,GAAA,CAAI,CAAC,8BAAA,EAAgC,UAAU,CAAA,EAAG;AAAA,EAC3E,QAAA,EAAU;AAAA,IACR,OAAA,EAAS;AAAA,MACP,OAAA,EAAS,SAAA;AAAA,MACT,IAAA,EAAM,CAAC,wDAAA,EAA0D,SAAS,CAAA;AAAA,MAC1E,IAAA,EAAM;AAAA,QACJ,kHAAA;AAAA,QACA,yIAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,iFAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA;AACF;AACF,GACF;AAAA,EACA,eAAA,EAAiB,EAAE,OAAA,EAAS,SAAA;AAC9B,CAAC;AAQD,MAAM,sBAAA,GAAyB;AAY/B,SAAS,WAAW,GAAA,EAA2B;AAC7C,EAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,SAAA,CAAU,IAAI,CAAA;AAChC,EAAA,KAAA,CAAM,gBAAgB,eAAe,CAAA;AACrC,EAAA,KAAA,CAAM,gBAAgB,gBAAgB,CAAA;AACtC,EAAA,KAAA,CAAM,gBAAgB,eAAe,CAAA;AACrC,EAAA,KAAA,MAAW,EAAA,IAAM,CAAC,KAAA,EAAO,GAAG,KAAA,CAAM,gBAAA,CAAiB,MAAM,CAAC,CAAA,EAAG,EAAA,CAAG,eAAA,CAAgB,IAAI,CAAA;AACpF,EAAA,KAAA,CAAM,YAAA,CAAa,eAAe,MAAM,CAAA;AACxC,EAAA,KAAA,CAAM,KAAA,GAAQ,I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AA;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ;AAWA,SAAS,kBAAA,CAAmB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAiC;AACjF,EAAA,uBACE,IAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,iEAAA,EAAmE,SAAS,CAAA;AAAA,MACzF,GAAG,KAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,WAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,aAAA,EAAA,EAAc,aAAA,EAAY,QAAO,CAAA,EACpC,CAAA;AAAA,wBACA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,QAAA,EAAA,YAAA,EAAU;AAAA;AAAA;AAAA,GACtC;AAEJ","file":"breadcrumb.js","sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { IconMoreHoriz } from '../icons/more-horiz.js'\nimport { overlayInk } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\nimport { TouchTarget } from './button.js'\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuLinkItem,\n DropdownMenuTrigger,\n} from './dropdown-menu.js'\n\n/**\n * The three variables every non-band look shares: the interactive ink (read\n * from `overlayInk`, so a retune of the ink is one edit — AGENTS.md §3), the\n * current page in the text colour and muted separators. Each variant sets all\n * three itself rather than overriding a base value, so the class string never\n * holds two declarations of one property — the exported `breadcrumbVariants`\n * stays correct without tailwind-merge, where the stylesheet's emission order\n * would otherwise pick the winner.\n */\nconst onSurface =\n '[--bc-current:var(--foreground)] [--bc-ink:var(--overlay-ink)] [--bc-separator:var(--muted-foreground)]'\n\n/**\n * The band and the tint are page chrome, so their content lines up with\n * Header's: the same 16 → 24 → 48px inset (`--header-padding-x`'s ladder,\n * written as disjoint ranges for cascade safety) and the same optional\n * `--header-max-width` column. BreadcrumbList applies both; `default` and\n * `rail` sit in page content and leave them unset. Retune with `--bc-inset`.\n */\nconst chromeInset =\n 'max-sm:[--bc-inset:--spacing(4)] sm:max-lg:[--bc-inset:--spacing(6)] lg:[--bc-inset:--spacing(12)] [--bc-max-width:var(--header-max-width,none)]'\n\n/**\n * The four looks, set on `Breadcrumb` and read by every part through\n * `group-data-*` (DESIGN.md, Breadcrumb):\n *\n * - `default`: no chrome; underlined ink links and chevrons. Use it unless the\n * page has a reason not to.\n * - `rail`: the masterbrand line system — hairlines above and below in the\n * text colour, slash separators. For a page whose top is already quiet.\n * - `band`: the solid brand band — Blue 01 with white links, deepening to\n * `primary-950` in dark exactly as Header's `dark` colour does, so a band\n * under that header stays flush in both modes (AGENTS.md §3 brand band). A\n * dark-only hairline in the ink at 15% keeps its edge on a dark page, where\n * 950 alone is ~1.06:1 against the canvas; under Header it is the band's\n * bottom edge, so it never seams. Labels are white in both modes for the\n * reason Button's solid labels are: `--text-inverse` flips.\n * - `soft`: a 10% ink tint with a 30% ink hairline under it.\n *\n * Every hairline is optical: the padding beside it is 1px shorter, so each\n * look lands on the 4px grid (40px tall, 48px with the ellipsis).\n */\nconst breadcrumbVariants = cva(['group/breadcrumb text-base/6', overlayInk], {\n variants: {\n variant: {\n default: onSurface,\n rail: ['border-y border-foreground py-[calc(--spacing(2)-1px)]', onSurface],\n band: [\n 'bg-primary-800 py-2 dark:border-b dark:border-(--bc-ink)/15 dark:bg-primary-950 dark:pb-[calc(--spacing(2)-1px)]',\n '[--bc-current:var(--color-white)] [--bc-ink:var(--color-white)] [--bc-separator:color-mix(in_oklch,var(--color-white)_72%,transparent)]',\n chromeInset,\n ],\n soft: [\n 'border-b border-(--bc-ink)/30 bg-(--bc-ink)/10 pt-2 pb-[calc(--spacing(2)-1px)]',\n onSurface,\n chromeInset,\n ],\n },\n },\n defaultVariants: { variant: 'default' },\n})\n\n/**\n * The `sideOffset` to give a DropdownMenuContent opened from the ellipsis. The\n * band, tint and rail add up to 8px of their own edge below the 24px trigger,\n * so the menu's default 4px would open it over that edge; 14px clears all\n * four looks.\n */\nconst BREADCRUMB_MENU_OFFSET = 14\n\n/**\n * Whether the full trail would wrap at the nav's current width. Measured on a\n * hidden clone placed beside the nav — same parent, so the same inherited\n * tokens and font — with the collapse state stripped, so a collapsed trail can\n * still ask how long it would be. The clone's list is laid out as one\n * unwrapped, unshrunk row, and the trail would wrap when that row overflows:\n * `scrollWidth` past `clientWidth`. Both are layout widths, so neither item\n * heights (an icon, a looser line height) nor transforms (a zooming dialog)\n * can sway the answer.\n */\nfunction trailWraps(nav: HTMLElement): boolean {\n const probe = nav.cloneNode(true) as HTMLElement\n probe.removeAttribute('data-collapse')\n probe.removeAttribute('data-collapsed')\n probe.removeAttribute('data-measured')\n for (const el of [probe, ...probe.querySelectorAll('[id]')]) el.removeAttribute('id')\n probe.setAttribute('aria-hidden', 'true')\n probe.inert = true\n Object.assign(probe.style, {\n position: 'absolute',\n insetBlockStart: '0',\n insetInlineStart: '0',\n width: `${nav.offsetWidth}px`,\n visibility: 'hidden',\n pointerEvents: 'none',\n })\n const list = probe.querySelector<HTMLElement>('[data-slot=breadcrumb-list]')\n if (!list) return false\n list.style.flexWrap = 'nowrap'\n list.style.whiteSpace = 'nowrap'\n for (const item of list.children) (item as HTMLElement).style.flexShrink = '0'\n nav.after(probe)\n const wraps = list.scrollWidth > list.clientWidth + 1\n probe.remove()\n return wraps\n}\n\n/** A step a collapsed trail hides, offered in its \"…\" menu instead. */\ntype BreadcrumbHiddenStep = { href: string; label: string }\n\nconst NO_HIDDEN_STEPS: BreadcrumbHiddenStep[] = []\n\n/**\n * The links a collapsed trail hides: every item between the first and the\n * parent that holds a link. A team's own ellipsis item has none, so it is\n * left out here and stays visible in the trail.\n */\nfunction hiddenSteps(nav: HTMLElement): BreadcrumbHiddenStep[] {\n const items = [\n ...nav.querySelectorAll<HTMLElement>(\n '[data-slot=breadcrumb-list] > [data-slot=breadcrumb-item]',\n ),\n ]\n return items.slice(1, -2).flatMap((item) => {\n const link = item.querySelector<HTMLAnchorElement>(\n ':scope > [data-slot=breadcrumb-content] > a[href]',\n )\n // `a[href]` matches an empty href too (a link to this page), and the\n // collapse rules treat it as a step, so the menu keeps it as well.\n const href = link?.getAttribute('href')\n return link && href != null ? [{ href, label: link.textContent?.trim() ?? '' }] : []\n })\n}\n\n/** The hidden steps of the enclosing collapsed trail, for the parent's \"…\" menu. */\nconst BreadcrumbHiddenContext = React.createContext<BreadcrumbHiddenStep[]>(NO_HIDDEN_STEPS)\n\n/**\n * The trail's landmark. `aria-label` defaults to \"Breadcrumb\" and can be\n * overridden (a page with two trails needs two names).\n *\n * `collapse` is on by default: when the full trail would wrap, it shortens to\n * its first step, a \"…\" menu of the steps it hides, and the current page's\n * parent — \"Home › … › Licences and permits\". The site root and the way up\n * stay visible and every hidden step is one tap away; the page heading names\n * the current page. The first step and the parent share one row, the parent\n * wrapping within it if its title is long. A team's own ellipsis stays in the\n * trail when it collapses. A trail that fits on one line stays whole at any\n * width, and a trail whose parent is its first step never collapses — there\n * would be nothing to hide but the current page. Pass `collapse={false}` to\n * keep the full trail, which then wraps.\n *\n * The menu's rows are plain links built from the hidden steps' `href`s, so\n * they navigate with a full page load. A team whose framework routes on the\n * client can put its own ellipsis menu in the trail instead.\n *\n * Wrapping is measured, so it needs JavaScript. Until the first measurement —\n * server-rendered HTML, or no script — an eligible trail is shown collapsed,\n * without the menu, at every width: one row that never clips, and the\n * measurement only ever expands it or adds the \"…\", so the page never changes\n * height when it lands. The nav takes `w-full`, which keeps its width\n * independent of its own collapse state; without it a shrink-to-fit parent (a\n * `flex items-center` header) would size it to the collapsed trail and it\n * could never measure wider. It is a plain class, so a consumer `w-*` still\n * wins.\n */\nfunction Breadcrumb({\n className,\n variant,\n collapse = true,\n 'aria-label': ariaLabel = 'Breadcrumb',\n ref,\n ...props\n}: React.ComponentProps<'nav'> &\n VariantProps<typeof breadcrumbVariants> & {\n collapse?: boolean\n }) {\n // VariantProps admits null, which cva reads as \"no variant\" and would leave\n // every --bc-* variable unset.\n const look = variant ?? 'default'\n const collapses = collapse\n const navRef = React.useRef<HTMLElement>(null)\n // null until measured: the CSS width fallback applies until then.\n const [wraps, setWraps] = React.useState<boolean | null>(null)\n const [hidden, setHidden] = React.useState<BreadcrumbHiddenStep[]>(NO_HIDDEN_STEPS)\n\n React.useLayoutEffect(() => {\n const nav = navRef.current\n if (!collapses || !nav) {\n setWraps(null)\n setHidden(NO_HIDDEN_STEPS)\n return\n }\n let frame = 0\n let measuredWidth = -1\n let dirty = true\n /** Re-measures whether the full trail wraps, and records the steps a collapse would hide. */\n const measure = () => {\n const width = nav.offsetWidth\n // Hidden (a display:none ancestor): nothing to learn until it shows,\n // which the ResizeObserver reports. Same width and same content: the\n // answer cannot have changed, so a height-only resize — including the\n // one collapsing causes — costs nothing.\n if (width === 0 || (!dirty && width === measuredWidth)) return\n measuredWidth = width\n dirty = false\n // No link at all: there is nothing to keep, so the trail never collapses.\n const next = nav.querySelector('[data-slot=breadcrumb-list] a[href]')\n ? trailWraps(nav)\n : false\n setWraps(next)\n const steps = next ? hiddenSteps(nav) : NO_HIDDEN_STEPS\n // Keep the same array when nothing changed, so the menu does not\n // re-render (and re-trigger the content observer) for no reason.\n setHidden((prev) => (JSON.stringify(prev) === JSON.stringify(steps) ? prev : steps))\n }\n /** Coalesces observer callbacks into one measurement on the next frame. */\n const schedule = () => {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(measure)\n }\n measure()\n // The observer's first callback reports the width just measured, so it\n // is skipped above. The probe is a sibling and the state lands as\n // attributes on the nav, so neither observer sees its own measurement.\n // Of attributes, `class` and `style` can change the trail's width without\n // changing the nav's, which a ResizeObserver cannot see, and `href`\n // changes no width but is copied into the \"…\" menu, so a changed\n // destination must rebuild it. Data and ARIA attributes, including the\n // menu trigger's, are left out.\n /** Marks the content changed and re-measures, whatever the width does. */\n const invalidate = () => {\n dirty = true\n schedule()\n }\n const resize = new ResizeObserver(schedule)\n resize.observe(nav)\n const content = new MutationObserver(invalidate)\n content.observe(nav, {\n childList: true,\n characterData: true,\n subtree: true,\n attributeFilter: ['class', 'href', 'style'],\n })\n // A web font that finishes loading changes the trail's width and nothing\n // the observers see (the nav's width holds), so the first measurement,\n // taken in the fallback font, would otherwise stand until the next\n // resize. Re-measure once the fonts in use are ready and on every later\n // load.\n const fonts = document.fonts as FontFaceSet | undefined\n let disposed = false\n fonts?.ready.then(() => {\n if (!disposed) invalidate()\n })\n fonts?.addEventListener('loadingdone', invalidate)\n return () => {\n disposed = true\n cancelAnimationFrame(frame)\n resize.disconnect()\n content.disconnect()\n fonts?.removeEventListener('loadingdone', invalidate)\n }\n }, [collapses])\n\n return (\n <BreadcrumbHiddenContext.Provider value={collapses && wraps ? hidden : NO_HIDDEN_STEPS}>\n <nav\n ref={(node) => {\n navRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n }}\n aria-label={ariaLabel}\n data-slot='breadcrumb'\n data-variant={look}\n data-collapse={collapses || undefined}\n data-measured={collapses && wraps !== null ? '' : undefined}\n data-collapsed={collapses && wraps ? '' : undefined}\n className={cn(breadcrumbVariants({ variant: look }), collapses && 'w-full', className)}\n {...props}\n />\n </BreadcrumbHiddenContext.Provider>\n )\n}\n\n/**\n * Default separators are drawn by the item after them (BreadcrumbItem's lead),\n * so a wrapped line starts with its separator and its target together instead\n * of stranding a chevron at the end of the line above. The separator `<li>`\n * stays in the tree — it is what the collapse rules count — but renders\n * nothing. A separator with custom children is drawn where it stands. Rows\n * sit 8px apart, 20px on a coarse pointer so the 44px touch targets of\n * neighbouring rows never overlap.\n *\n * The collapse rules key on the trail's shape rather than on markers the\n * consumer must add: the parent is the item two before the end, with a\n * separator between it and the current page. A collapsed trail keeps the\n * first item, any ellipsis item a team supplied, and that parent, and hides\n * the rest; the parent's \"…\" menu (BreadcrumbItem) offers what was hidden. The\n * rules apply only when the parent is a link and not the first item, so a\n * trail of one or two steps, or one whose parent slot is an ellipsis, stays\n * whole. A custom separator before the parent stays, so the kept steps are\n * still divided. The first item keeps its width and the parent takes the\n * rest of the row, wrapping within it if its title is long. (One `:has()` per\n * condition: `:has()` cannot nest.) The rules are written for the measured\n * state (`data-collapsed`) and again for the stand-in before measurement,\n * which collapses an eligible trail at every width.\n */\nfunction BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {\n return (\n <ol\n data-slot='breadcrumb-list'\n className={cn(\n 'mx-auto flex max-w-(--bc-max-width) flex-wrap items-center gap-x-2 px-(--bc-inset) wrap-break-word text-(--bc-separator) not-pointer-coarse:gap-y-2 group-data-[variant=rail]/breadcrumb:gap-x-3 pointer-coarse:gap-y-5',\n '[&>[data-slot=breadcrumb-separator]:not([data-custom])]:hidden',\n 'group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:not(:first-child):not(:nth-last-child(3)):not([data-custom]:nth-last-child(4)):not(:has(>[data-slot=breadcrumb-content]>button>[data-slot=breadcrumb-ellipsis]))]:hidden',\n 'group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:not(:first-child):not(:nth-last-child(3)):not([data-custom]:nth-last-child(4)):not(:has(>[data-slot=breadcrumb-content]>button>[data-slot=breadcrumb-ellipsis]))]:hidden',\n 'group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:shrink-0 group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:self-start group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:shrink-0 group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:self-start group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:nth-last-child(3)]:flex-1 group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:nth-last-child(3)]:flex-1',\n 'group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:nth-last-child(3)>[data-slot=breadcrumb-content]>[data-slot=breadcrumb-more]]:inline-flex',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * The \"…\" a collapsed trail adds before its parent: a menu of the steps it\n * hides, then the look's separator. It is rendered in every item while the\n * trail is collapsed and hidden steps exist, and BreadcrumbList shows it only\n * in the parent — inside that item, so the tab order matches what is seen:\n * Home, …, parent. The rows are underlined like the trail's links.\n */\nfunction BreadcrumbMore({ steps }: { steps: BreadcrumbHiddenStep[] }) {\n return (\n <span\n data-slot='breadcrumb-more'\n className='me-2 hidden items-center gap-2 align-top group-data-[variant=rail]/breadcrumb:me-3 group-data-[variant=rail]/breadcrumb:gap-3'\n >\n <DropdownMenu>\n <DropdownMenuTrigger\n aria-label={`Show ${steps.length} more ${steps.length === 1 ? 'page' : 'pages'}`}\n >\n <BreadcrumbEllipsis />\n </DropdownMenuTrigger>\n <DropdownMenuContent sideOffset={BREADCRUMB_MENU_OFFSET}>\n {steps.map((step) => (\n <DropdownMenuLinkItem\n key={`${step.href} ${step.label}`}\n href={step.href}\n className='underline underline-offset-4'\n >\n {step.label}\n </DropdownMenuLinkItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n <span aria-hidden='true' className='inline-flex shrink-0 [&>svg]:size-5'>\n <IconChevronRight className='group-data-[variant=rail]/breadcrumb:hidden rtl:rotate-180' />\n <span className='hidden text-xl/6 group-data-[variant=rail]/breadcrumb:inline'>/</span>\n </span>\n </span>\n )\n}\n\n/**\n * One step in the trail: the separator glyph it leads with, then its content.\n * The glyph — a chevron, or a slash on the rail — shows only when a default\n * BreadcrumbSeparator precedes the item, so the first item never carries one.\n * It aligns to the first line of a label that wraps, and to the centre of the\n * ellipsis trigger.\n *\n * The content sits in its own span so the link inside stays inline: a flex\n * item is blockified, and a block `<a>` would draw one rectangular halo and\n * focus ring round a wrapped label instead of one per line.\n *\n * A `<button>` whose direct child is a `BreadcrumbEllipsis` is styled as the\n * ellipsis trigger, which keeps the trail composable with `DropdownMenuTrigger`\n * (or any other trigger), and so is the \"…\" a collapsed trail adds. It is a\n * 24px control on the 4px radius — one line tall, so a row never changes\n * height with it — tinted from the ink at 10% on hover and 20% while\n * pressed or open, with the system's 2px offset focus ring and, in forced\n * colours (where tints are dropped), a 1px border. The selector sits inside\n * `:where()` so it carries no specificity: a `className` on the trigger itself\n * still wins.\n */\nfunction BreadcrumbItem({ className, children, ...props }: React.ComponentProps<'li'>) {\n const hidden = React.useContext(BreadcrumbHiddenContext)\n return (\n <li\n data-slot='breadcrumb-item'\n className={cn(\n 'inline-flex min-w-0 items-start gap-2 group-data-[variant=rail]/breadcrumb:gap-3 has-[>[data-slot=breadcrumb-content]>button]:items-center',\n '[[data-slot=breadcrumb-separator]:not([data-custom])+&>[data-slot=breadcrumb-lead]]:inline-flex',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:relative [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:inline-flex [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:size-6 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:cursor-pointer [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:items-center [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:justify-center [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:rounded-sm [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:bg-transparent [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:px-0 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:text-(--bc-ink) [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:motion-safe:transition-[color,background-color]',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:not-forced-colors:border-0 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:forced-colors:border',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:hover:bg-(--bc-ink)/10 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:active:bg-(--bc-ink)/20 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:aria-expanded:bg-(--bc-ink)/20',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-2 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-offset-2 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-(--bc-ink) [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-solid',\n className,\n )}\n {...props}\n >\n <span\n data-slot='breadcrumb-lead'\n aria-hidden='true'\n className='hidden h-6 shrink-0 items-center [&>svg]:size-5'\n >\n <IconChevronRight className='group-data-[variant=rail]/breadcrumb:hidden rtl:rotate-180' />\n <span className='hidden text-xl/6 group-data-[variant=rail]/breadcrumb:inline'>/</span>\n </span>\n <span data-slot='breadcrumb-content' className='min-w-0 has-[>button]:flex'>\n {hidden.length > 0 && <BreadcrumbMore steps={hidden} />}\n {children}\n </span>\n </li>\n )\n}\n\n/**\n * A link in the trail, in the system's link signature (DESIGN.md, Links):\n * medium weight, underlined in the ink at 4px offset, a 10% ink halo with a\n * 2px underline on hover and an 18% halo while pressed, and the 2px offset\n * focus ring in the ink, which appears in the ink at once: the transition\n * leaves `outline-color` out, so the ring never fades in from the base layer's\n * grey. The halo is Link's recipe, mixed in the same oklch\n * space; it is reproduced rather than reusing `linkVariants` because Link's\n * `primary` colour is fixed while a trail's ink changes with its look (white\n * on the band). There is deliberately no visited colour: a trail is\n * wayfinding, and a visited step is not information.\n *\n * A coarse-pointer TouchTarget rides inside the link's target, expanding the\n * hit area to 44px without growing the box (the Same-Floor Rule). It is only\n * added when the text comes through `children`; a link whose text lives\n * inside its `render` element keeps that text and goes without it.\n */\nfunction BreadcrumbLink({ className, render, children, ...props }: useRender.ComponentProps<'a'>) {\n return useRender({\n defaultTagName: 'a',\n props: mergeProps<'a'>(\n {\n className: cn(\n 'relative box-decoration-clone font-medium text-(--bc-ink) underline decoration-1 underline-offset-4 motion-safe:transition-[color,background-color,text-decoration-color,box-shadow]',\n '[--bc-halo-active:color-mix(in_oklch,var(--bc-ink)_18%,transparent)] [--bc-halo:color-mix(in_oklch,var(--bc-ink)_10%,transparent)]',\n 'hover:bg-(--bc-halo) hover:decoration-2 hover:shadow-[0_-2px_0_var(--bc-halo),0_4px_0_var(--bc-halo)]',\n 'active:bg-(--bc-halo-active) active:decoration-2 active:shadow-[0_-2px_0_var(--bc-halo-active),0_4px_0_var(--bc-halo-active)]',\n 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--bc-ink) focus-visible:outline-solid',\n className,\n ),\n ...(children !== undefined && {\n children: <TouchTarget>{children}</TouchTarget>,\n }),\n },\n props,\n ),\n render,\n state: {\n slot: 'breadcrumb-link',\n },\n })\n}\n\n/**\n * The current page's entry in the trail — plain text, not a link.\n *\n * Carries `aria-current='page'` and nothing else. The upstream shadcn version\n * adds `role='link' aria-disabled='true'` to a `<span>` that has no `href` and\n * no `tabIndex`, which makes AT announce \"link, dimmed, current page\" for\n * something that is neither a link nor operable, and puts a hand-rolled ARIA\n * role on an element that needs none. axe-core does not flag it, so it\n * survives an a11y gate set to `error`; it is removed deliberately here.\n *\n * Regular weight under the links' medium on every look: the step you are on is\n * the one you cannot follow, so it is never the heaviest word in the trail.\n */\nfunction BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-page'\n aria-current='page'\n className={cn('font-normal text-(--bc-current)', className)}\n {...props}\n />\n )\n}\n\n/**\n * Marks the step boundary. Decorative and hidden from assistive tech. Left\n * empty, it draws nothing itself: the item after it leads with the look's\n * glyph (BreadcrumbItem), so the glyph wraps with its target. Given children,\n * it draws them where it stands, as before.\n */\nfunction BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-separator'\n data-custom={children === undefined ? undefined : ''}\n role='presentation'\n aria-hidden='true'\n className={cn('inline-flex items-center [&>svg]:size-5', className)}\n {...props}\n >\n {children}\n </li>\n )\n}\n\n/**\n * The collapsed-steps glyph, with \"More pages\" for screen readers so a trigger\n * built around it is never unnamed. Put it as the only child of a trigger and\n * name the trigger by what it reveals, e.g.\n * `<DropdownMenuTrigger aria-label='Show 2 more pages'><BreadcrumbEllipsis /></DropdownMenuTrigger>`.\n * BreadcrumbItem styles that trigger, and the glyph carries a coarse-pointer\n * TouchTarget so the 24px control still takes a 44px tap. Open the menu with\n * `sideOffset={BREADCRUMB_MENU_OFFSET}`.\n */\nfunction BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-ellipsis'\n className={cn('relative flex size-6 items-center justify-center [&_svg]:size-6', className)}\n {...props}\n >\n <TouchTarget>\n <IconMoreHoriz aria-hidden='true' />\n </TouchTarget>\n <span className='sr-only'>More pages</span>\n </span>\n )\n}\n\nexport {\n Breadcrumb,\n BREADCRUMB_MENU_OFFSET,\n BreadcrumbEllipsis,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n breadcrumbVariants,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/breadcrumb.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AA6BA,MAAM,SAAA,GACJ,yGAAA;AASF,MAAM,WAAA,GACJ,kJAAA;AAsBF,MAAM,kBAAA,GAAqB,GAAA,CAAI,CAAC,8BAAA,EAAgC,UAAU,CAAA,EAAG;AAAA,EAC3E,QAAA,EAAU;AAAA,IACR,OAAA,EAAS;AAAA,MACP,OAAA,EAAS,SAAA;AAAA,MACT,IAAA,EAAM,CAAC,wDAAA,EAA0D,SAAS,CAAA;AAAA,MAC1E,IAAA,EAAM;AAAA,QACJ,kHAAA;AAAA,QACA,yIAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,iFAAA;AAAA,QACA,SAAA;AAAA,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from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { IconMoreHoriz } from '../icons/more-horiz.js'\nimport { overlayInk } from '../lib/overlay.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\nimport { TouchTarget } from './button.js'\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuLinkItem,\n DropdownMenuTrigger,\n} from './dropdown-menu.js'\n\n/**\n * The three variables every non-band look shares: the interactive ink (read\n * from `overlayInk`, so a retune of the ink is one edit — AGENTS.md §3), the\n * current page in the text colour and muted separators. Each variant sets all\n * three itself rather than overriding a base value, so the class string never\n * holds two declarations of one property — the exported `breadcrumbVariants`\n * stays correct without tailwind-merge, where the stylesheet's emission order\n * would otherwise pick the winner.\n */\nconst onSurface =\n '[--bc-current:var(--foreground)] [--bc-ink:var(--overlay-ink)] [--bc-separator:var(--muted-foreground)]'\n\n/**\n * The band and the tint are page chrome, so their content lines up with\n * Header's: the same 16 → 24 → 48px inset (`--header-padding-x`'s ladder,\n * written as disjoint ranges for cascade safety) and the same optional\n * `--header-max-width` column. BreadcrumbList applies both; `default` and\n * `rail` sit in page content and leave them unset. Retune with `--bc-inset`.\n */\nconst chromeInset =\n 'max-sm:[--bc-inset:--spacing(4)] sm:max-lg:[--bc-inset:--spacing(6)] lg:[--bc-inset:--spacing(12)] [--bc-max-width:var(--header-max-width,none)]'\n\n/**\n * The four looks, set on `Breadcrumb` and read by every part through\n * `group-data-*` (DESIGN.md, Breadcrumb):\n *\n * - `default`: no chrome; underlined ink links and chevrons. Use it unless the\n * page has a reason not to.\n * - `rail`: the masterbrand line system — hairlines above and below in the\n * text colour, slash separators. For a page whose top is already quiet.\n * - `band`: the solid brand band — Blue 01 with white links, deepening to\n * `primary-950` in dark exactly as Header's `dark` colour does, so a band\n * under that header stays flush in both modes (AGENTS.md §3 brand band). A\n * dark-only hairline in the ink at 15% keeps its edge on a dark page, where\n * 950 alone is ~1.06:1 against the canvas; under Header it is the band's\n * bottom edge, so it never seams. Labels are white in both modes for the\n * reason Button's solid labels are: `--text-inverse` flips.\n * - `soft`: a 10% ink tint with a 30% ink hairline under it.\n *\n * Every hairline is optical: the padding beside it is 1px shorter, so each\n * look lands on the 4px grid (40px tall, 48px with the ellipsis).\n */\nconst breadcrumbVariants = cva(['group/breadcrumb text-base/6', overlayInk], {\n variants: {\n variant: {\n default: onSurface,\n rail: ['border-y border-foreground py-[calc(--spacing(2)-1px)]', onSurface],\n band: [\n 'bg-primary-800 py-2 dark:border-b dark:border-(--bc-ink)/15 dark:bg-primary-950 dark:pb-[calc(--spacing(2)-1px)]',\n '[--bc-current:var(--color-white)] [--bc-ink:var(--color-white)] [--bc-separator:color-mix(in_oklch,var(--color-white)_72%,transparent)]',\n chromeInset,\n ],\n soft: [\n 'border-b border-(--bc-ink)/30 bg-(--bc-ink)/10 pt-2 pb-[calc(--spacing(2)-1px)]',\n onSurface,\n chromeInset,\n ],\n },\n },\n defaultVariants: { variant: 'default' },\n})\n\n/**\n * The `sideOffset` to give a DropdownMenuContent opened from the ellipsis. The\n * band, tint and rail add up to 8px of their own edge below the 24px trigger,\n * so the menu's default 4px would open it over that edge; 14px clears all\n * four looks.\n */\nconst BREADCRUMB_MENU_OFFSET = 14\n\n/**\n * Whether the full trail would wrap at the nav's current width. Measured on a\n * hidden clone placed beside the nav — same parent, so the same inherited\n * tokens and font — with the collapse state stripped, so a collapsed trail can\n * still ask how long it would be. The clone's list is laid out as one\n * unwrapped, unshrunk row, and the trail would wrap when that row overflows:\n * `scrollWidth` past `clientWidth`. Both are layout widths, so neither item\n * heights (an icon, a looser line height) nor transforms (a zooming dialog)\n * can sway the answer.\n */\nfunction trailWraps(nav: HTMLElement): boolean {\n const probe = nav.cloneNode(true) as HTMLElement\n probe.removeAttribute('data-collapse')\n probe.removeAttribute('data-collapsed')\n probe.removeAttribute('data-measured')\n for (const el of [probe, ...probe.querySelectorAll('[id]')]) el.removeAttribute('id')\n probe.setAttribute('aria-hidden', 'true')\n probe.inert = true\n Object.assign(probe.style, {\n position: 'absolute',\n insetBlockStart: '0',\n insetInlineStart: '0',\n width: `${nav.offsetWidth}px`,\n visibility: 'hidden',\n pointerEvents: 'none',\n })\n const list = probe.querySelector<HTMLElement>('[data-slot=breadcrumb-list]')\n if (!list) return false\n list.style.flexWrap = 'nowrap'\n list.style.whiteSpace = 'nowrap'\n for (const item of list.children) (item as HTMLElement).style.flexShrink = '0'\n nav.after(probe)\n const wraps = list.scrollWidth > list.clientWidth + 1\n probe.remove()\n return wraps\n}\n\n/** A step a collapsed trail hides, offered in its \"…\" menu instead. */\ntype BreadcrumbHiddenStep = { href: string; label: string }\n\nconst NO_HIDDEN_STEPS: BreadcrumbHiddenStep[] = []\n\n/**\n * The links a collapsed trail hides: every item between the first and the\n * parent that holds a link. A team's own ellipsis item has none, so it is\n * left out here and stays visible in the trail.\n */\nfunction hiddenSteps(nav: HTMLElement): BreadcrumbHiddenStep[] {\n const items = [\n ...nav.querySelectorAll<HTMLElement>(\n '[data-slot=breadcrumb-list] > [data-slot=breadcrumb-item]',\n ),\n ]\n return items.slice(1, -2).flatMap((item) => {\n const link = item.querySelector<HTMLAnchorElement>(\n ':scope > [data-slot=breadcrumb-content] > a[href]',\n )\n // `a[href]` matches an empty href too (a link to this page), and the\n // collapse rules treat it as a step, so the menu keeps it as well.\n const href = link?.getAttribute('href')\n return link && href != null ? [{ href, label: link.textContent?.trim() ?? '' }] : []\n })\n}\n\n/** The hidden steps of the enclosing collapsed trail, for the parent's \"…\" menu. */\nconst BreadcrumbHiddenContext = React.createContext<BreadcrumbHiddenStep[]>(NO_HIDDEN_STEPS)\n\n/**\n * The trail's landmark. `aria-label` defaults to \"Breadcrumb\" and can be\n * overridden (a page with two trails needs two names).\n *\n * `collapse` is on by default: when the full trail would wrap, it shortens to\n * its first step, a \"…\" menu of the steps it hides, and the current page's\n * parent — \"Home › … › Licences and permits\". The site root and the way up\n * stay visible and every hidden step is one tap away; the page heading names\n * the current page. The first step and the parent share one row, the parent\n * wrapping within it if its title is long. A team's own ellipsis stays in the\n * trail when it collapses. A trail that fits on one line stays whole at any\n * width, and a trail whose parent is its first step never collapses — there\n * would be nothing to hide but the current page. Pass `collapse={false}` to\n * keep the full trail, which then wraps.\n *\n * The menu's rows are plain links built from the hidden steps' `href`s, so\n * they navigate with a full page load. A team whose framework routes on the\n * client can put its own ellipsis menu in the trail instead.\n *\n * Wrapping is measured, so it needs JavaScript. Until the first measurement —\n * server-rendered HTML, or no script — an eligible trail is shown collapsed,\n * without the menu, at every width: one row that never clips, and the\n * measurement only ever expands it or adds the \"…\", so the page never changes\n * height when it lands. The nav takes `w-full`, which keeps its width\n * independent of its own collapse state; without it a shrink-to-fit parent (a\n * `flex items-center` header) would size it to the collapsed trail and it\n * could never measure wider. It is a plain class, so a consumer `w-*` still\n * wins.\n */\nfunction Breadcrumb({\n className,\n variant,\n collapse = true,\n 'aria-label': ariaLabel = 'Breadcrumb',\n ref,\n ...props\n}: React.ComponentProps<'nav'> &\n VariantProps<typeof breadcrumbVariants> & {\n collapse?: boolean\n }) {\n // Resolved once (see `resolveVariant`): VariantProps admits null, which cva\n // reads as \"no variant\" and would leave every --bc-* variable unset.\n const look = resolveVariant(variant, 'default')\n const collapses = collapse\n const navRef = React.useRef<HTMLElement>(null)\n // null until measured: the CSS width fallback applies until then.\n const [wraps, setWraps] = React.useState<boolean | null>(null)\n const [hidden, setHidden] = React.useState<BreadcrumbHiddenStep[]>(NO_HIDDEN_STEPS)\n\n React.useLayoutEffect(() => {\n const nav = navRef.current\n if (!collapses || !nav) {\n setWraps(null)\n setHidden(NO_HIDDEN_STEPS)\n return\n }\n let frame = 0\n let measuredWidth = -1\n let dirty = true\n /** Re-measures whether the full trail wraps, and records the steps a collapse would hide. */\n const measure = () => {\n const width = nav.offsetWidth\n // Hidden (a display:none ancestor): nothing to learn until it shows,\n // which the ResizeObserver reports. Same width and same content: the\n // answer cannot have changed, so a height-only resize — including the\n // one collapsing causes — costs nothing.\n if (width === 0 || (!dirty && width === measuredWidth)) return\n measuredWidth = width\n dirty = false\n // No link at all: there is nothing to keep, so the trail never collapses.\n const next = nav.querySelector('[data-slot=breadcrumb-list] a[href]')\n ? trailWraps(nav)\n : false\n setWraps(next)\n const steps = next ? hiddenSteps(nav) : NO_HIDDEN_STEPS\n // Keep the same array when nothing changed, so the menu does not\n // re-render (and re-trigger the content observer) for no reason.\n setHidden((prev) => (JSON.stringify(prev) === JSON.stringify(steps) ? prev : steps))\n }\n /** Coalesces observer callbacks into one measurement on the next frame. */\n const schedule = () => {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(measure)\n }\n measure()\n // The observer's first callback reports the width just measured, so it\n // is skipped above. The probe is a sibling and the state lands as\n // attributes on the nav, so neither observer sees its own measurement.\n // Of attributes, `class` and `style` can change the trail's width without\n // changing the nav's, which a ResizeObserver cannot see, and `href`\n // changes no width but is copied into the \"…\" menu, so a changed\n // destination must rebuild it. Data and ARIA attributes, including the\n // menu trigger's, are left out.\n /** Marks the content changed and re-measures, whatever the width does. */\n const invalidate = () => {\n dirty = true\n schedule()\n }\n const resize = new ResizeObserver(schedule)\n resize.observe(nav)\n const content = new MutationObserver(invalidate)\n content.observe(nav, {\n childList: true,\n characterData: true,\n subtree: true,\n attributeFilter: ['class', 'href', 'style'],\n })\n // A web font that finishes loading changes the trail's width and nothing\n // the observers see (the nav's width holds), so the first measurement,\n // taken in the fallback font, would otherwise stand until the next\n // resize. Re-measure once the fonts in use are ready and on every later\n // load.\n const fonts = document.fonts as FontFaceSet | undefined\n let disposed = false\n fonts?.ready.then(() => {\n if (!disposed) invalidate()\n })\n fonts?.addEventListener('loadingdone', invalidate)\n return () => {\n disposed = true\n cancelAnimationFrame(frame)\n resize.disconnect()\n content.disconnect()\n fonts?.removeEventListener('loadingdone', invalidate)\n }\n }, [collapses])\n\n return (\n <BreadcrumbHiddenContext.Provider value={collapses && wraps ? hidden : NO_HIDDEN_STEPS}>\n <nav\n ref={(node) => {\n navRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n }}\n aria-label={ariaLabel}\n data-slot='breadcrumb'\n data-collapse={collapses || undefined}\n data-measured={collapses && wraps !== null ? '' : undefined}\n data-collapsed={collapses && wraps ? '' : undefined}\n {...props}\n // After the spread, so a consumer's own `data-variant` cannot desync\n // the attribute from the classes both derive from the resolved value.\n data-variant={look}\n className={cn(breadcrumbVariants({ variant: look }), collapses && 'w-full', className)}\n />\n </BreadcrumbHiddenContext.Provider>\n )\n}\n\n/**\n * Default separators are drawn by the item after them (BreadcrumbItem's lead),\n * so a wrapped line starts with its separator and its target together instead\n * of stranding a chevron at the end of the line above. The separator `<li>`\n * stays in the tree — it is what the collapse rules count — but renders\n * nothing. A separator with custom children is drawn where it stands. Rows\n * sit 8px apart, 20px on a coarse pointer so the 44px touch targets of\n * neighbouring rows never overlap.\n *\n * The collapse rules key on the trail's shape rather than on markers the\n * consumer must add: the parent is the item two before the end, with a\n * separator between it and the current page. A collapsed trail keeps the\n * first item, any ellipsis item a team supplied, and that parent, and hides\n * the rest; the parent's \"…\" menu (BreadcrumbItem) offers what was hidden. The\n * rules apply only when the parent is a link and not the first item, so a\n * trail of one or two steps, or one whose parent slot is an ellipsis, stays\n * whole. A custom separator before the parent stays, so the kept steps are\n * still divided. The first item keeps its width and the parent takes the\n * rest of the row, wrapping within it if its title is long. (One `:has()` per\n * condition: `:has()` cannot nest.) The rules are written for the measured\n * state (`data-collapsed`) and again for the stand-in before measurement,\n * which collapses an eligible trail at every width.\n */\nfunction BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {\n return (\n <ol\n data-slot='breadcrumb-list'\n className={cn(\n 'mx-auto flex max-w-(--bc-max-width) flex-wrap items-center gap-x-2 px-(--bc-inset) wrap-break-word text-(--bc-separator) not-pointer-coarse:gap-y-2 group-data-[variant=rail]/breadcrumb:gap-x-3 pointer-coarse:gap-y-5',\n '[&>[data-slot=breadcrumb-separator]:not([data-custom])]:hidden',\n 'group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:not(:first-child):not(:nth-last-child(3)):not([data-custom]:nth-last-child(4)):not(:has(>[data-slot=breadcrumb-content]>button>[data-slot=breadcrumb-ellipsis]))]:hidden',\n 'group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:not(:first-child):not(:nth-last-child(3)):not([data-custom]:nth-last-child(4)):not(:has(>[data-slot=breadcrumb-content]>button>[data-slot=breadcrumb-ellipsis]))]:hidden',\n 'group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:shrink-0 group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:self-start group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:shrink-0 group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:first-child]:self-start group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:nth-last-child(3)]:flex-1 group-[[data-collapse]:not([data-measured])]/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:nth-last-child(3)]:flex-1',\n 'group-data-collapsed/breadcrumb:[&:has(>[data-slot=breadcrumb-item]:nth-last-child(3):not(:first-child)>[data-slot=breadcrumb-content]>a[href]):has(>[data-slot=breadcrumb-separator]:nth-last-child(2))>li:nth-last-child(3)>[data-slot=breadcrumb-content]>[data-slot=breadcrumb-more]]:inline-flex',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * The \"…\" a collapsed trail adds before its parent: a menu of the steps it\n * hides, then the look's separator. It is rendered in every item while the\n * trail is collapsed and hidden steps exist, and BreadcrumbList shows it only\n * in the parent — inside that item, so the tab order matches what is seen:\n * Home, …, parent. The rows are underlined like the trail's links.\n */\nfunction BreadcrumbMore({ steps }: { steps: BreadcrumbHiddenStep[] }) {\n return (\n <span\n data-slot='breadcrumb-more'\n className='me-2 hidden items-center gap-2 align-top group-data-[variant=rail]/breadcrumb:me-3 group-data-[variant=rail]/breadcrumb:gap-3'\n >\n <DropdownMenu>\n <DropdownMenuTrigger\n aria-label={`Show ${steps.length} more ${steps.length === 1 ? 'page' : 'pages'}`}\n >\n <BreadcrumbEllipsis />\n </DropdownMenuTrigger>\n <DropdownMenuContent sideOffset={BREADCRUMB_MENU_OFFSET}>\n {steps.map((step) => (\n <DropdownMenuLinkItem\n key={`${step.href} ${step.label}`}\n href={step.href}\n className='underline underline-offset-4'\n >\n {step.label}\n </DropdownMenuLinkItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n <span aria-hidden='true' className='inline-flex shrink-0 [&>svg]:size-5'>\n <IconChevronRight className='group-data-[variant=rail]/breadcrumb:hidden rtl:rotate-180' />\n <span className='hidden text-xl/6 group-data-[variant=rail]/breadcrumb:inline'>/</span>\n </span>\n </span>\n )\n}\n\n/**\n * One step in the trail: the separator glyph it leads with, then its content.\n * The glyph — a chevron, or a slash on the rail — shows only when a default\n * BreadcrumbSeparator precedes the item, so the first item never carries one.\n * It aligns to the first line of a label that wraps, and to the centre of the\n * ellipsis trigger.\n *\n * The content sits in its own span so the link inside stays inline: a flex\n * item is blockified, and a block `<a>` would draw one rectangular halo and\n * focus ring round a wrapped label instead of one per line.\n *\n * A `<button>` whose direct child is a `BreadcrumbEllipsis` is styled as the\n * ellipsis trigger, which keeps the trail composable with `DropdownMenuTrigger`\n * (or any other trigger), and so is the \"…\" a collapsed trail adds. It is a\n * 24px control on the 4px radius — one line tall, so a row never changes\n * height with it — tinted from the ink at 10% on hover and 20% while\n * pressed or open, with the system's 2px offset focus ring and, in forced\n * colours (where tints are dropped), a 1px border. The selector sits inside\n * `:where()` so it carries no specificity: a `className` on the trigger itself\n * still wins.\n */\nfunction BreadcrumbItem({ className, children, ...props }: React.ComponentProps<'li'>) {\n const hidden = React.useContext(BreadcrumbHiddenContext)\n return (\n <li\n data-slot='breadcrumb-item'\n className={cn(\n 'inline-flex min-w-0 items-start gap-2 group-data-[variant=rail]/breadcrumb:gap-3 has-[>[data-slot=breadcrumb-content]>button]:items-center',\n '[[data-slot=breadcrumb-separator]:not([data-custom])+&>[data-slot=breadcrumb-lead]]:inline-flex',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:relative [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:inline-flex [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:size-6 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:cursor-pointer [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:items-center [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:justify-center [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:rounded-sm [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:bg-transparent [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:px-0 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:text-(--bc-ink) [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:motion-safe:transition-[color,background-color]',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:not-forced-colors:border-0 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:forced-colors:border',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:hover:bg-(--bc-ink)/10 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:active:bg-(--bc-ink)/20 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:aria-expanded:bg-(--bc-ink)/20',\n '[:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-2 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-offset-2 [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-(--bc-ink) [:where(&>[data-slot=breadcrumb-content]_button:has(>[data-slot=breadcrumb-ellipsis]))]:focus-visible:outline-solid',\n className,\n )}\n {...props}\n >\n <span\n data-slot='breadcrumb-lead'\n aria-hidden='true'\n className='hidden h-6 shrink-0 items-center [&>svg]:size-5'\n >\n <IconChevronRight className='group-data-[variant=rail]/breadcrumb:hidden rtl:rotate-180' />\n <span className='hidden text-xl/6 group-data-[variant=rail]/breadcrumb:inline'>/</span>\n </span>\n <span data-slot='breadcrumb-content' className='min-w-0 has-[>button]:flex'>\n {hidden.length > 0 && <BreadcrumbMore steps={hidden} />}\n {children}\n </span>\n </li>\n )\n}\n\n/**\n * A link in the trail, in the system's link signature (DESIGN.md, Links):\n * medium weight, underlined in the ink at 4px offset, a 10% ink halo with a\n * 2px underline on hover and an 18% halo while pressed, and the 2px offset\n * focus ring in the ink, which appears in the ink at once: the transition\n * leaves `outline-color` out, so the ring never fades in from the base layer's\n * grey. The halo is Link's recipe, mixed in the same oklch\n * space; it is reproduced rather than reusing `linkVariants` because Link's\n * `primary` colour is fixed while a trail's ink changes with its look (white\n * on the band). There is deliberately no visited colour: a trail is\n * wayfinding, and a visited step is not information.\n *\n * A coarse-pointer TouchTarget rides inside the link's target, expanding the\n * hit area to 44px without growing the box (the Same-Floor Rule). It is only\n * added when the text comes through `children`; a link whose text lives\n * inside its `render` element keeps that text and goes without it.\n */\nfunction BreadcrumbLink({ className, render, children, ...props }: useRender.ComponentProps<'a'>) {\n return useRender({\n defaultTagName: 'a',\n props: mergeProps<'a'>(\n {\n className: cn(\n 'relative box-decoration-clone font-medium text-(--bc-ink) underline decoration-1 underline-offset-4 motion-safe:transition-[color,background-color,text-decoration-color,box-shadow]',\n '[--bc-halo-active:color-mix(in_oklch,var(--bc-ink)_18%,transparent)] [--bc-halo:color-mix(in_oklch,var(--bc-ink)_10%,transparent)]',\n 'hover:bg-(--bc-halo) hover:decoration-2 hover:shadow-[0_-2px_0_var(--bc-halo),0_4px_0_var(--bc-halo)]',\n 'active:bg-(--bc-halo-active) active:decoration-2 active:shadow-[0_-2px_0_var(--bc-halo-active),0_4px_0_var(--bc-halo-active)]',\n 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--bc-ink) focus-visible:outline-solid',\n className,\n ),\n ...(children !== undefined && {\n children: <TouchTarget>{children}</TouchTarget>,\n }),\n },\n props,\n ),\n render,\n state: {\n slot: 'breadcrumb-link',\n },\n })\n}\n\n/**\n * The current page's entry in the trail — plain text, not a link.\n *\n * Carries `aria-current='page'` and nothing else. The upstream shadcn version\n * adds `role='link' aria-disabled='true'` to a `<span>` that has no `href` and\n * no `tabIndex`, which makes AT announce \"link, dimmed, current page\" for\n * something that is neither a link nor operable, and puts a hand-rolled ARIA\n * role on an element that needs none. axe-core does not flag it, so it\n * survives an a11y gate set to `error`; it is removed deliberately here.\n *\n * Regular weight under the links' medium on every look: the step you are on is\n * the one you cannot follow, so it is never the heaviest word in the trail.\n */\nfunction BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-page'\n aria-current='page'\n className={cn('font-normal text-(--bc-current)', className)}\n {...props}\n />\n )\n}\n\n/**\n * Marks the step boundary. Decorative and hidden from assistive tech. Left\n * empty, it draws nothing itself: the item after it leads with the look's\n * glyph (BreadcrumbItem), so the glyph wraps with its target. Given children,\n * it draws them where it stands, as before.\n */\nfunction BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-separator'\n data-custom={children === undefined ? undefined : ''}\n role='presentation'\n aria-hidden='true'\n className={cn('inline-flex items-center [&>svg]:size-5', className)}\n {...props}\n >\n {children}\n </li>\n )\n}\n\n/**\n * The collapsed-steps glyph, with \"More pages\" for screen readers so a trigger\n * built around it is never unnamed. Put it as the only child of a trigger and\n * name the trigger by what it reveals, e.g.\n * `<DropdownMenuTrigger aria-label='Show 2 more pages'><BreadcrumbEllipsis /></DropdownMenuTrigger>`.\n * BreadcrumbItem styles that trigger, and the glyph carries a coarse-pointer\n * TouchTarget so the 24px control still takes a 44px tap. Open the menu with\n * `sideOffset={BREADCRUMB_MENU_OFFSET}`.\n */\nfunction BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-ellipsis'\n className={cn('relative flex size-6 items-center justify-center [&_svg]:size-6', className)}\n {...props}\n >\n <TouchTarget>\n <IconMoreHoriz aria-hidden='true' />\n </TouchTarget>\n <span className='sr-only'>More pages</span>\n </span>\n )\n}\n\nexport {\n Breadcrumb,\n BREADCRUMB_MENU_OFFSET,\n BreadcrumbEllipsis,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n breadcrumbVariants,\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { cva } from 'class-variance-authority';
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { ButtonGroupContext } from '../lib/button-group-context.js';
|
|
8
8
|
export { ButtonGroupBoundary } from '../lib/button-group-context.js';
|
|
9
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
9
10
|
import { cn } from '../lib/utils.js';
|
|
10
11
|
import { buttonColorVariants } from './button.js';
|
|
11
12
|
import { Separator } from './separator.js';
|
|
@@ -152,8 +153,8 @@ function ButtonGroup({
|
|
|
152
153
|
children,
|
|
153
154
|
...props
|
|
154
155
|
}) {
|
|
155
|
-
const resolvedVariant = variant
|
|
156
|
-
const resolvedOrientation = orientation
|
|
156
|
+
const resolvedVariant = resolveVariant(variant, DEFAULT_GROUP_VARIANT);
|
|
157
|
+
const resolvedOrientation = resolveVariant(orientation, DEFAULT_GROUP_ORIENTATION);
|
|
157
158
|
const resolvedColor = color ?? void 0;
|
|
158
159
|
const resolvedSize = size ?? void 0;
|
|
159
160
|
const context = React.useMemo(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/button-group.tsx"],"names":[],"mappings":";;;;;;;;;;;AAgBA,MAAM,qBAAA,GAAwB,SAAA;AAC9B,MAAM,yBAAA,GAA4B,YAAA;AAqClC,MAAM,mBAAA,GAAsB,GAAA;AAAA,EAC1B;AAAA,IACE,oEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA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IAChB,KAAA,EAAO,UAAA;AAAA,MACL;AAAA,QACE,SAAA,EAAW,EAAA;AAAA;AAAA,UAET,wIAAA;AAAA;AAAA,UAEA,kEAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA,MACA;AAAA,KACF;AAAA,IACA,MAAA;AAAA,IACA,KAAA,EAAO;AAAA,MACL,IAAA,EAAM;AAAA;AACR,GACD,CAAA;AACH;AAQA,SAAS,oBAAA,CAAqB;AAAA,EAC5B,SAAA;AAAA,EACA,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA2C;AACzC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,UAAA,CAAW,kBAAkB,CAAA;AACjD,EAAA,MAAM,mBAAA,GACJ,WAAA,KAAgB,KAAA,EAAO,WAAA,KAAgB,aAAa,YAAA,GAAe,UAAA,CAAA;AAErE,EAAA,uBACE,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,WAAA,EAAa,mBAAA;AAAA,MACb,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA,QAIT,+FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"button-group.js","sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport {\n ButtonGroupBoundary,\n ButtonGroupContext,\n type ButtonGroupContextValue,\n} from '../lib/button-group-context.js'\nimport { cn } from '../lib/utils.js'\nimport { buttonColorVariants, type ButtonProps } from './button.js'\nimport { Separator } from './separator.js'\n\nconst DEFAULT_GROUP_VARIANT = 'outline' as const\nconst DEFAULT_GROUP_ORIENTATION = 'horizontal' as const\n\n/**\n * The group owns the boundary. It draws the frame or the band, the hairline\n * between segments and the 4px corners, and it clips its children to that\n * radius — so a segment never computes a corner of its own. The segments are\n * ordinary Buttons: they read `ButtonGroupContext` and give up the chrome the\n * group now draws (see `styles.segment` in button.tsx).\n *\n * This replaces a wrapper that collapsed borders through `[data-slot]` child\n * selectors copied from shadcn. Button never emitted `data-slot`, so none of\n * those rules matched: every Button kept its own 2px outline and 4px corners,\n * and neighbours met with a 4px doubled border.\n *\n * Every colour is Button's own `--btn-fill` / `--btn-bg` / `--btn-text` pair,\n * applied to the group by `buttonColorVariants`, so a group's `color` means\n * what a Button's does: the ink flips for dark mode the same way, and on a\n * soft or surface band it steps to the darker ink those tints need the same\n * way (`styles.tintInk` in button.tsx). The segments learn they sit on that\n * tint from the `band` the context carries, and step their own colour's ink,\n * so a segment naming another colour keeps it. Hairlines take the text\n * colour, per the masterbrand's line system. These classes therefore only\n * paint on an element that also carries `buttonColorVariants` —\n * `ring-(--btn-bg)` is invalid without it — so a consumer extending the\n * group's styling applies the two together, as `ButtonGroup` does.\n *\n * Two kinds of rule reach a segment. What depends on the segment's\n * NEIGHBOURS — dividers, seams, the text cell — lives here and uses the CHILD\n * combinator (`&>`) and sibling combinators, so it needs the segments to be\n * direct children. What depends only on the BAND — the re-ink on a solid\n * band, the frame-revealing `bg-clip-padding` — lives on the segment itself,\n * keyed on the `data-band` the group tells it through context, so it holds\n * for a segment rendered through a trigger's `render` prop or wrapped in a\n * span. Never a descendant rule: a group is not meant to nest, but if one\n * ever does, a descendant rule from the outer band would re-ink the inner\n * group's segments.\n */\nconst buttonGroupVariants = cva(\n [\n 'isolate inline-flex w-fit items-stretch overflow-hidden rounded-sm',\n // `items-stretch` above is what makes every segment the same size across\n // the group's cross axis — except an icon-only one, which `styles.iconOnly`\n // squares with `size-(--btn-h)`. A definite cross size is precisely the\n // case flexbox does NOT stretch (CSS Flexbox §9.4: stretch applies only\n // when the cross-size property computes to `auto`), so the square holds its\n // 52px whatever the segments beside it do. In a column that is every mixed\n // group: a 52px square in a 135px band, with a void beside it and the\n // hairline above it stopping a third of the way across. In a row it needs a\n // label to wrap first, which `min-h-(--btn-h)` on the button explicitly\n // allows — a floor, not a fixed height — and then the square sits at the\n // top of a 136px row.\n //\n // So the group releases the cross dimension and lets `items-stretch` do its\n // work, keeping the main one: the square stays a square whenever its\n // neighbours are one line tall, and grows with them when they are not.\n // Keyed on the group's own orientation, so neither rule is a bare utility\n // the other has to override, and reached through the child combinator, so\n // a nested icon button (inside a popup opened from a segment, say) is not\n // touched. (0,3,0) against `size-(--btn-h)`'s (0,1,0).\n 'data-[orientation=horizontal]:[&>[data-slot][data-icon-only]]:h-auto',\n 'data-[orientation=vertical]:[&>[data-slot][data-icon-only]]:w-auto',\n // The band's label colour, resolved HERE from the group's own colour\n // token and inherited by every segment as a computed value. A segment on\n // a solid band re-points its ink to this (see `styles.segment` in\n // button.tsx); publishing it from the group is what stops a segment that\n // names its own `color` from reading its own `--btn-text` instead.\n '[--group-label:var(--btn-text)]',\n // Dividers. A Button or ButtonGroupText carries `data-slot` and a 1px\n // transparent border, so the divider is that border recoloured on the\n // shared edge: no extra pixel, and the group's outer box stays exactly\n // one button tall. (ButtonGroupSeparator carries `data-slot` too but no\n // border and no size, so the hairline beside it is drawn by the segment\n // after it.) Keyed on orientation both ways so neither rule is a bare\n // utility the other overrides, and written as `[data-slot]~[data-slot]`\n // for specificity: Button's `dark:border-white/5` is a border-color\n // SHORTHAND at (0,2,0), and this longhand only beats it by specificity,\n // never by emission order (AGENTS.md §4, the two-build cascade).\n //\n // `loading` reaches these rules as well as `disabled`: Button derives\n // `disabled` from either, so a busy segment is a disabled one here. The\n // boundary therefore moves by a pixel when a request starts, which is the\n // contract holding rather than breaking — the alternative is a\n // half-strength hairline beside an enabled control for as long as the\n // request runs. `Segment Props` pins it.\n //\n // A disabled segment fades itself with `opacity-50`, and a divider drawn\n // on its own leading edge would fade with it — leaving one weak hairline\n // in an otherwise full-strength row, right where the eye reads the join.\n // So the boundary before a disabled segment is drawn on the trailing edge\n // of the segment BEFORE it instead, and the disabled segment's own\n // leading edge stays transparent. A separator between the two has no edge\n // to paint, so the rule also looks through one.\n //\n // The one hairline this does NOT lift out of the fade is the one BETWEEN\n // two adjacent disabled segments: its only available edge belongs to a\n // disabled element either way, so it renders at 50% like the pair it\n // divides. That is the coherent reading — the whole run is unavailable,\n // and a full-strength line inside it would draw more attention than the\n // controls do — and lifting it would mean moving dividers off the\n // segments entirely, onto a layer the group owns. `Disabled` renders the\n // case and pins where each edge lands.\n 'data-[orientation=horizontal]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-s-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-t-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-b-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-b-(--divider)',\n // Two solid segments side by side (a split button): the ink divider would\n // vanish on the fill, so the seam is a reversed hairline in the label\n // colour. Above the general divider on specificity, with the same\n // disabled handling, and again looking through a separator.\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n ],\n {\n variants: {\n variant: {\n // A 1px hairline frame in the ink, drawn as an inset ring so it adds\n // no height: the group is exactly as tall as a lone Button beside it.\n // No fill of its own, like Button's outline: the surface shows\n // through, so a `white` outline group on a dark panel stays a frame.\n // Forced-colours mode discards box shadows, so the frame is restated\n // there as an outline, which that mode keeps and recolours. The text\n // cell stops its background at the padding box so the frame shows\n // through its transparent border.\n outline: [\n 'ring-1 ring-(--btn-bg) [--divider:var(--btn-bg)] ring-inset',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-clip-padding',\n ],\n // The band. Segments re-ink themselves on it (see `styles.segment` in\n // button.tsx); the text cell sits on the band in its label colour, at\n // the label weight so it reads as a label rather than as another\n // button.\n solid: [\n 'bg-(--btn-fill) [--divider:color-mix(in_oklab,var(--btn-text)_30%,transparent)]',\n '[&>[data-slot=button-group-text]]:bg-transparent [&>[data-slot=button-group-text]]:font-medium [&>[data-slot=button-group-text]]:text-(--btn-text)',\n ],\n // Button's soft pair — ink at 10%, 20% in dark — as a band. The text\n // cell sits on the band.\n soft: 'bg-(--btn-bg)/10 [--divider:color-mix(in_oklab,var(--btn-bg)_30%,transparent)] dark:bg-(--btn-bg)/20 [&>[data-slot=button-group-text]]:bg-transparent',\n // Button's surface pair: ink at 5% inside an ink/50 hairline, restated\n // as an outline for forced colours like the outline frame.\n surface: [\n 'bg-(--btn-bg)/5 ring-1 ring-(--btn-bg)/50 [--divider:color-mix(in_oklab,var(--btn-bg)_50%,transparent)] ring-inset dark:bg-(--btn-bg)/30',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-transparent',\n ],\n // No frame, no fill: only the hairlines between segments remain.\n ghost: '[--divider:var(--btn-bg)]',\n },\n orientation: {\n horizontal: 'flex-row',\n vertical: 'flex-col',\n },\n },\n defaultVariants: {\n variant: DEFAULT_GROUP_VARIANT,\n orientation: DEFAULT_GROUP_ORIENTATION,\n },\n },\n)\n\n/** The group variants a ButtonGroup can paint. `link` has no group form. */\ntype ButtonGroupVariant = NonNullable<VariantProps<typeof buttonGroupVariants>['variant']>\n\ntype ButtonGroupProps = Omit<React.ComponentProps<'div'>, 'color'> &\n VariantProps<typeof buttonGroupVariants> & {\n /**\n * Colour token, with Button's meaning: `primary` by default. Sets the\n * ink the frame, band and dividers are drawn in, and the default colour\n * of every segment.\n */\n color?: ButtonProps['color']\n /**\n * Scale step, with Button's meaning. The default size of every segment.\n * `icon` is not offered: it is a 40px chrome square, and the group clips\n * to its own box, so the 44px touch expansion Button adds on a coarse\n * pointer would be cut off. A segment that asks for `icon` anyway renders\n * as `iconOnly` at the group's own step, so it lines up with the segments\n * beside it.\n */\n size?: Exclude<ButtonProps['size'], 'icon'>\n }\n\n/**\n * Joins a row (or column) of Buttons into one control. Takes Button's variant\n * family — `outline` (the default), `solid`, `soft`, `surface`, `ghost` — and\n * its colour tokens and size steps, and hands them to its segments as\n * defaults. A segment may name its own emphasis: a `solid` Save inside an\n * outline group is the primary action of that row.\n *\n * Children are Buttons (or ButtonLinks), `ButtonGroupText` for an inline\n * label, and `ButtonGroupSeparator` for a semantic boundary, as DIRECT\n * children: the hairlines between segments are drawn on the segments' shared\n * edges, so a segment wrapped in another element (a span holding a tooltip\n * on a disabled segment, say) keeps its label and its band treatment but\n * loses the hairlines it shares with its neighbours — the one before it, and\n * the one after it too when the wrapped segment is the first child. It is a group of buttons, not a general\n * control frame — an input or select with an attached action is InputGroup's\n * job — and groups do not nest.\n *\n * A popup opened from a segment (a split button's menu) renders through a\n * portal, which React context follows. Every popup in this package resets the\n * group context at its portal, so the Buttons inside render normally; wrap\n * the contents of an overlay from another library in `ButtonGroupBoundary`\n * to get the same. Without that reset a Button inside the popup renders as a\n * segment of the group it was opened from, and on a solid band that means its\n * label takes the band's colour — white on the popup's own surface.\n */\nfunction ButtonGroup({\n className,\n variant,\n orientation,\n color,\n size,\n children,\n ...props\n}: ButtonGroupProps) {\n const resolvedVariant = variant ?? DEFAULT_GROUP_VARIANT\n const resolvedOrientation = orientation ?? DEFAULT_GROUP_ORIENTATION\n // `null` is admitted by both prop types (they borrow Button's, which allow\n // it) and is the idiomatic way to thread an optional prop through a\n // wrapper. cva reads it as \"no variant\" rather than \"unspecified\", so an\n // unnormalised `null` would emit no size or colour classes AT ALL — and\n // because a segment resolves `color ?? group.color`, one `null` on the\n // group would turn every child's own `undefined` into an explicit `null`\n // and un-style the whole row: no padding, no height, and a frame still\n // pointing at a `--btn-bg` nothing defines. Normalising here means the\n // group and its segments both fall back to the same cva defaults a lone\n // Button gets.\n const resolvedColor = color ?? undefined\n const resolvedSize = size ?? undefined\n const context = React.useMemo<ButtonGroupContextValue>(\n () => ({\n band: resolvedVariant,\n color: resolvedColor,\n size: resolvedSize,\n orientation: resolvedOrientation,\n }),\n [resolvedVariant, resolvedColor, resolvedSize, resolvedOrientation],\n )\n\n return (\n <div\n role='group'\n data-slot='button-group'\n className={cn(\n buttonColorVariants({ color: resolvedColor, variant: resolvedVariant }),\n buttonGroupVariants({ variant: resolvedVariant, orientation: resolvedOrientation }),\n className,\n )}\n {...props}\n // AFTER the spread, so that no prop can override these two — unlike\n // `data-slot` above, and unlike Button, which puts its own stamps first\n // so InputGroupButton can relabel them. `data-orientation` is what every\n // divider rule keys on, while the flex direction comes from the cva\n // variant and the separator's axis from the context — neither of which\n // a prop can reach. If a prop could override it, a row handed\n // `data-orientation='vertical'` would paint column dividers across\n // itself. Nothing in the package keys on `data-variant` (the band\n // treatment reaches the segments through `data-band` instead), but it is\n // the group's public description of itself, and stamped last it cannot\n // be made to contradict the variant the group actually paints. The\n // Segment Props play pins both. `data-slot` stays first because\n // relabelling a group is the same escape hatch Button offers.\n data-variant={resolvedVariant}\n data-orientation={resolvedOrientation}\n >\n <ButtonGroupContext.Provider value={context}>{children}</ButtonGroupContext.Provider>\n </div>\n )\n}\n\n/**\n * An inline label between segments — a unit, a count, a mode. Sits at the\n * body size (16px), never smaller: it shares a line with 16px button labels,\n * so anything below that reads as fine print. Semibold, the weight the\n * InputGroup addon uses for the same job. On a framed or ghost group it sits\n * on the sunken surface so it reads as chrome rather than as a button; on a\n * band it sits on the band, and a solid band gives it the band's label colour\n * at the label weight (see `buttonGroupVariants`).\n */\nfunction ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>) {\n return useRender({\n defaultTagName: 'div',\n props: mergeProps<'div'>(\n {\n className: cn(\n // The transparent border is what the group's divider recolours.\n 'flex items-center gap-2 border border-transparent bg-(--surface-sunken) px-4 text-base font-semibold text-muted-foreground select-none',\n // A glyph beside the text matches Button's 24px label glyph.\n \"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6\",\n className,\n ),\n },\n props,\n ),\n render,\n state: {\n slot: 'button-group-text',\n },\n })\n}\n\n/**\n * A semantic boundary between segments. Every segment is already divided by\n * a hairline, so the separator draws nothing of its own — it exists for\n * assistive technology, which hears it as a region boundary, and it follows\n * the group's orientation unless told otherwise.\n */\nfunction ButtonGroupSeparator({\n className,\n orientation,\n ...props\n}: React.ComponentProps<typeof Separator>) {\n const group = React.useContext(ButtonGroupContext)\n const resolvedOrientation =\n orientation ?? (group?.orientation === 'vertical' ? 'horizontal' : 'vertical')\n\n return (\n <Separator\n data-slot='button-group-separator'\n orientation={resolvedOrientation}\n className={cn(\n // Zero-size on its own axis and transparent: the hairline beside it\n // is the group's divider, not this element. Same variant keys as the\n // primitive's own sizing so tailwind-merge resolves them here.\n 'self-stretch bg-transparent data-[orientation=horizontal]:h-0 data-[orientation=vertical]:w-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n ButtonGroup,\n ButtonGroupBoundary,\n ButtonGroupSeparator,\n ButtonGroupText,\n buttonGroupVariants,\n}\nexport type { ButtonGroupProps, ButtonGroupVariant }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/button-group.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAiBA,MAAM,qBAAA,GAAwB,SAAA;AAC9B,MAAM,yBAAA,GAA4B,YAAA;AAqClC,MAAM,mBAAA,GAAsB,GAAA;AAAA,EAC1B;AAAA,IACE,oEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAoBA,sEAAA;AAAA,IACA,oEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,iCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmCA,qGAAA;AAAA,IACA,qGAAA;AAAA,IACA,wIAAA;AAAA,IACA,mGAAA;AAAA,IACA,mGAAA;AAAA,IACA,sIAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,iJAAA;AAAA,IACA,oLAAA;AAAA,IACA,iJAAA;AAAA,IACA,oLAAA;AAAA,IACA,+IAAA;AAAA,IACA,kLAAA;AAAA,IACA,+IAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASP,OAAA,EAAS;AAAA,UACP,6DA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AAAA;AAAA;AAAA;AAAA,QAIT,+FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"button-group.js","sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport {\n ButtonGroupBoundary,\n ButtonGroupContext,\n type ButtonGroupContextValue,\n} from '../lib/button-group-context.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\nimport { buttonColorVariants, type ButtonProps } from './button.js'\nimport { Separator } from './separator.js'\n\nconst DEFAULT_GROUP_VARIANT = 'outline' as const\nconst DEFAULT_GROUP_ORIENTATION = 'horizontal' as const\n\n/**\n * The group owns the boundary. It draws the frame or the band, the hairline\n * between segments and the 4px corners, and it clips its children to that\n * radius — so a segment never computes a corner of its own. The segments are\n * ordinary Buttons: they read `ButtonGroupContext` and give up the chrome the\n * group now draws (see `styles.segment` in button.tsx).\n *\n * This replaces a wrapper that collapsed borders through `[data-slot]` child\n * selectors copied from shadcn. Button never emitted `data-slot`, so none of\n * those rules matched: every Button kept its own 2px outline and 4px corners,\n * and neighbours met with a 4px doubled border.\n *\n * Every colour is Button's own `--btn-fill` / `--btn-bg` / `--btn-text` pair,\n * applied to the group by `buttonColorVariants`, so a group's `color` means\n * what a Button's does: the ink flips for dark mode the same way, and on a\n * soft or surface band it steps to the darker ink those tints need the same\n * way (`styles.tintInk` in button.tsx). The segments learn they sit on that\n * tint from the `band` the context carries, and step their own colour's ink,\n * so a segment naming another colour keeps it. Hairlines take the text\n * colour, per the masterbrand's line system. These classes therefore only\n * paint on an element that also carries `buttonColorVariants` —\n * `ring-(--btn-bg)` is invalid without it — so a consumer extending the\n * group's styling applies the two together, as `ButtonGroup` does.\n *\n * Two kinds of rule reach a segment. What depends on the segment's\n * NEIGHBOURS — dividers, seams, the text cell — lives here and uses the CHILD\n * combinator (`&>`) and sibling combinators, so it needs the segments to be\n * direct children. What depends only on the BAND — the re-ink on a solid\n * band, the frame-revealing `bg-clip-padding` — lives on the segment itself,\n * keyed on the `data-band` the group tells it through context, so it holds\n * for a segment rendered through a trigger's `render` prop or wrapped in a\n * span. Never a descendant rule: a group is not meant to nest, but if one\n * ever does, a descendant rule from the outer band would re-ink the inner\n * group's segments.\n */\nconst buttonGroupVariants = cva(\n [\n 'isolate inline-flex w-fit items-stretch overflow-hidden rounded-sm',\n // `items-stretch` above is what makes every segment the same size across\n // the group's cross axis — except an icon-only one, which `styles.iconOnly`\n // squares with `size-(--btn-h)`. A definite cross size is precisely the\n // case flexbox does NOT stretch (CSS Flexbox §9.4: stretch applies only\n // when the cross-size property computes to `auto`), so the square holds its\n // 52px whatever the segments beside it do. In a column that is every mixed\n // group: a 52px square in a 135px band, with a void beside it and the\n // hairline above it stopping a third of the way across. In a row it needs a\n // label to wrap first, which `min-h-(--btn-h)` on the button explicitly\n // allows — a floor, not a fixed height — and then the square sits at the\n // top of a 136px row.\n //\n // So the group releases the cross dimension and lets `items-stretch` do its\n // work, keeping the main one: the square stays a square whenever its\n // neighbours are one line tall, and grows with them when they are not.\n // Keyed on the group's own orientation, so neither rule is a bare utility\n // the other has to override, and reached through the child combinator, so\n // a nested icon button (inside a popup opened from a segment, say) is not\n // touched. (0,3,0) against `size-(--btn-h)`'s (0,1,0).\n 'data-[orientation=horizontal]:[&>[data-slot][data-icon-only]]:h-auto',\n 'data-[orientation=vertical]:[&>[data-slot][data-icon-only]]:w-auto',\n // The band's label colour, resolved HERE from the group's own colour\n // token and inherited by every segment as a computed value. A segment on\n // a solid band re-points its ink to this (see `styles.segment` in\n // button.tsx); publishing it from the group is what stops a segment that\n // names its own `color` from reading its own `--btn-text` instead.\n '[--group-label:var(--btn-text)]',\n // Dividers. A Button or ButtonGroupText carries `data-slot` and a 1px\n // transparent border, so the divider is that border recoloured on the\n // shared edge: no extra pixel, and the group's outer box stays exactly\n // one button tall. (ButtonGroupSeparator carries `data-slot` too but no\n // border and no size, so the hairline beside it is drawn by the segment\n // after it.) Keyed on orientation both ways so neither rule is a bare\n // utility the other overrides, and written as `[data-slot]~[data-slot]`\n // for specificity: Button's `dark:border-white/5` is a border-color\n // SHORTHAND at (0,2,0), and this longhand only beats it by specificity,\n // never by emission order (AGENTS.md §4, the two-build cascade).\n //\n // `loading` reaches these rules as well as `disabled`: Button derives\n // `disabled` from either, so a busy segment is a disabled one here. The\n // boundary therefore moves by a pixel when a request starts, which is the\n // contract holding rather than breaking — the alternative is a\n // half-strength hairline beside an enabled control for as long as the\n // request runs. `Segment Props` pins it.\n //\n // A disabled segment fades itself with `opacity-50`, and a divider drawn\n // on its own leading edge would fade with it — leaving one weak hairline\n // in an otherwise full-strength row, right where the eye reads the join.\n // So the boundary before a disabled segment is drawn on the trailing edge\n // of the segment BEFORE it instead, and the disabled segment's own\n // leading edge stays transparent. A separator between the two has no edge\n // to paint, so the rule also looks through one.\n //\n // The one hairline this does NOT lift out of the fade is the one BETWEEN\n // two adjacent disabled segments: its only available edge belongs to a\n // disabled element either way, so it renders at 50% like the pair it\n // divides. That is the coherent reading — the whole run is unavailable,\n // and a full-strength line inside it would draw more attention than the\n // controls do — and lifting it would mean moving dividers off the\n // segments entirely, onto a layer the group owns. `Disabled` renders the\n // case and pins where each edge lands.\n 'data-[orientation=horizontal]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-s-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-t-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-b-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-b-(--divider)',\n // Two solid segments side by side (a split button): the ink divider would\n // vanish on the fill, so the seam is a reversed hairline in the label\n // colour. Above the general divider on specificity, with the same\n // disabled handling, and again looking through a separator.\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n ],\n {\n variants: {\n variant: {\n // A 1px hairline frame in the ink, drawn as an inset ring so it adds\n // no height: the group is exactly as tall as a lone Button beside it.\n // No fill of its own, like Button's outline: the surface shows\n // through, so a `white` outline group on a dark panel stays a frame.\n // Forced-colours mode discards box shadows, so the frame is restated\n // there as an outline, which that mode keeps and recolours. The text\n // cell stops its background at the padding box so the frame shows\n // through its transparent border.\n outline: [\n 'ring-1 ring-(--btn-bg) [--divider:var(--btn-bg)] ring-inset',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-clip-padding',\n ],\n // The band. Segments re-ink themselves on it (see `styles.segment` in\n // button.tsx); the text cell sits on the band in its label colour, at\n // the label weight so it reads as a label rather than as another\n // button.\n solid: [\n 'bg-(--btn-fill) [--divider:color-mix(in_oklab,var(--btn-text)_30%,transparent)]',\n '[&>[data-slot=button-group-text]]:bg-transparent [&>[data-slot=button-group-text]]:font-medium [&>[data-slot=button-group-text]]:text-(--btn-text)',\n ],\n // Button's soft pair — ink at 10%, 20% in dark — as a band. The text\n // cell sits on the band.\n soft: 'bg-(--btn-bg)/10 [--divider:color-mix(in_oklab,var(--btn-bg)_30%,transparent)] dark:bg-(--btn-bg)/20 [&>[data-slot=button-group-text]]:bg-transparent',\n // Button's surface pair: ink at 5% inside an ink/50 hairline, restated\n // as an outline for forced colours like the outline frame.\n surface: [\n 'bg-(--btn-bg)/5 ring-1 ring-(--btn-bg)/50 [--divider:color-mix(in_oklab,var(--btn-bg)_50%,transparent)] ring-inset dark:bg-(--btn-bg)/30',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-transparent',\n ],\n // No frame, no fill: only the hairlines between segments remain.\n ghost: '[--divider:var(--btn-bg)]',\n },\n orientation: {\n horizontal: 'flex-row',\n vertical: 'flex-col',\n },\n },\n defaultVariants: {\n variant: DEFAULT_GROUP_VARIANT,\n orientation: DEFAULT_GROUP_ORIENTATION,\n },\n },\n)\n\n/** The group variants a ButtonGroup can paint. `link` has no group form. */\ntype ButtonGroupVariant = NonNullable<VariantProps<typeof buttonGroupVariants>['variant']>\n\ntype ButtonGroupProps = Omit<React.ComponentProps<'div'>, 'color'> &\n VariantProps<typeof buttonGroupVariants> & {\n /**\n * Colour token, with Button's meaning: `primary` by default. Sets the\n * ink the frame, band and dividers are drawn in, and the default colour\n * of every segment.\n */\n color?: ButtonProps['color']\n /**\n * Scale step, with Button's meaning. The default size of every segment.\n * `icon` is not offered: it is a 40px chrome square, and the group clips\n * to its own box, so the 44px touch expansion Button adds on a coarse\n * pointer would be cut off. A segment that asks for `icon` anyway renders\n * as `iconOnly` at the group's own step, so it lines up with the segments\n * beside it.\n */\n size?: Exclude<ButtonProps['size'], 'icon'>\n }\n\n/**\n * Joins a row (or column) of Buttons into one control. Takes Button's variant\n * family — `outline` (the default), `solid`, `soft`, `surface`, `ghost` — and\n * its colour tokens and size steps, and hands them to its segments as\n * defaults. A segment may name its own emphasis: a `solid` Save inside an\n * outline group is the primary action of that row.\n *\n * Children are Buttons (or ButtonLinks), `ButtonGroupText` for an inline\n * label, and `ButtonGroupSeparator` for a semantic boundary, as DIRECT\n * children: the hairlines between segments are drawn on the segments' shared\n * edges, so a segment wrapped in another element (a span holding a tooltip\n * on a disabled segment, say) keeps its label and its band treatment but\n * loses the hairlines it shares with its neighbours — the one before it, and\n * the one after it too when the wrapped segment is the first child. It is a group of buttons, not a general\n * control frame — an input or select with an attached action is InputGroup's\n * job — and groups do not nest.\n *\n * A popup opened from a segment (a split button's menu) renders through a\n * portal, which React context follows. Every popup in this package resets the\n * group context at its portal, so the Buttons inside render normally; wrap\n * the contents of an overlay from another library in `ButtonGroupBoundary`\n * to get the same. Without that reset a Button inside the popup renders as a\n * segment of the group it was opened from, and on a solid band that means its\n * label takes the band's colour — white on the popup's own surface.\n */\nfunction ButtonGroup({\n className,\n variant,\n orientation,\n color,\n size,\n children,\n ...props\n}: ButtonGroupProps) {\n const resolvedVariant = resolveVariant(variant, DEFAULT_GROUP_VARIANT)\n const resolvedOrientation = resolveVariant(orientation, DEFAULT_GROUP_ORIENTATION)\n // `null` is admitted by both prop types (they borrow Button's, which allow\n // it) and is the idiomatic way to thread an optional prop through a\n // wrapper. cva reads it as \"no variant\" rather than \"unspecified\", so an\n // unnormalised `null` would emit no size or colour classes AT ALL — and\n // because a segment resolves `color ?? group.color`, one `null` on the\n // group would turn every child's own `undefined` into an explicit `null`\n // and un-style the whole row: no padding, no height, and a frame still\n // pointing at a `--btn-bg` nothing defines. Normalising here means the\n // group and its segments both fall back to the same cva defaults a lone\n // Button gets.\n const resolvedColor = color ?? undefined\n const resolvedSize = size ?? undefined\n const context = React.useMemo<ButtonGroupContextValue>(\n () => ({\n band: resolvedVariant,\n color: resolvedColor,\n size: resolvedSize,\n orientation: resolvedOrientation,\n }),\n [resolvedVariant, resolvedColor, resolvedSize, resolvedOrientation],\n )\n\n return (\n <div\n role='group'\n data-slot='button-group'\n className={cn(\n buttonColorVariants({ color: resolvedColor, variant: resolvedVariant }),\n buttonGroupVariants({ variant: resolvedVariant, orientation: resolvedOrientation }),\n className,\n )}\n {...props}\n // AFTER the spread, so that no prop can override these two — unlike\n // `data-slot` above, and unlike Button, which puts its own stamps first\n // so InputGroupButton can relabel them. `data-orientation` is what every\n // divider rule keys on, while the flex direction comes from the cva\n // variant and the separator's axis from the context — neither of which\n // a prop can reach. If a prop could override it, a row handed\n // `data-orientation='vertical'` would paint column dividers across\n // itself. Nothing in the package keys on `data-variant` (the band\n // treatment reaches the segments through `data-band` instead), but it is\n // the group's public description of itself, and stamped last it cannot\n // be made to contradict the variant the group actually paints. The\n // Segment Props play pins both. `data-slot` stays first because\n // relabelling a group is the same escape hatch Button offers.\n data-variant={resolvedVariant}\n data-orientation={resolvedOrientation}\n >\n <ButtonGroupContext.Provider value={context}>{children}</ButtonGroupContext.Provider>\n </div>\n )\n}\n\n/**\n * An inline label between segments — a unit, a count, a mode. Sits at the\n * body size (16px), never smaller: it shares a line with 16px button labels,\n * so anything below that reads as fine print. Semibold, the weight the\n * InputGroup addon uses for the same job. On a framed or ghost group it sits\n * on the sunken surface so it reads as chrome rather than as a button; on a\n * band it sits on the band, and a solid band gives it the band's label colour\n * at the label weight (see `buttonGroupVariants`).\n */\nfunction ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>) {\n return useRender({\n defaultTagName: 'div',\n props: mergeProps<'div'>(\n {\n className: cn(\n // The transparent border is what the group's divider recolours.\n 'flex items-center gap-2 border border-transparent bg-(--surface-sunken) px-4 text-base font-semibold text-muted-foreground select-none',\n // A glyph beside the text matches Button's 24px label glyph.\n \"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6\",\n className,\n ),\n },\n props,\n ),\n render,\n state: {\n slot: 'button-group-text',\n },\n })\n}\n\n/**\n * A semantic boundary between segments. Every segment is already divided by\n * a hairline, so the separator draws nothing of its own — it exists for\n * assistive technology, which hears it as a region boundary, and it follows\n * the group's orientation unless told otherwise.\n */\nfunction ButtonGroupSeparator({\n className,\n orientation,\n ...props\n}: React.ComponentProps<typeof Separator>) {\n const group = React.useContext(ButtonGroupContext)\n const resolvedOrientation =\n orientation ?? (group?.orientation === 'vertical' ? 'horizontal' : 'vertical')\n\n return (\n <Separator\n data-slot='button-group-separator'\n orientation={resolvedOrientation}\n className={cn(\n // Zero-size on its own axis and transparent: the hairline beside it\n // is the group's divider, not this element. Same variant keys as the\n // primitive's own sizing so tailwind-merge resolves them here.\n 'self-stretch bg-transparent data-[orientation=horizontal]:h-0 data-[orientation=vertical]:w-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n ButtonGroup,\n ButtonGroupBoundary,\n ButtonGroupSeparator,\n ButtonGroupText,\n buttonGroupVariants,\n}\nexport type { ButtonGroupProps, ButtonGroupVariant }\n"]}
|
|
@@ -6,7 +6,7 @@ import { Link } from './link.js';
|
|
|
6
6
|
|
|
7
7
|
declare const buttonCva: (props?: ({
|
|
8
8
|
variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
|
|
9
|
-
color?: "
|
|
9
|
+
color?: "danger" | "tertiary" | "accent" | "success" | "warning" | "white" | "grey" | "primary" | "secondary" | null | undefined;
|
|
10
10
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
11
11
|
iconOnly?: boolean | null | undefined;
|
|
12
12
|
onTint?: boolean | null | undefined;
|
|
@@ -27,7 +27,7 @@ type ButtonVariantProps = NonNullable<Parameters<typeof buttonCva>[0]>;
|
|
|
27
27
|
*/
|
|
28
28
|
declare function buttonVariants({ onTint, ...props }?: ButtonVariantProps): string;
|
|
29
29
|
declare const buttonColorCva: (props?: ({
|
|
30
|
-
color?: "
|
|
30
|
+
color?: "danger" | "tertiary" | "accent" | "success" | "warning" | "white" | "grey" | "primary" | "secondary" | null | undefined;
|
|
31
31
|
onTint?: boolean | null | undefined;
|
|
32
32
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
33
33
|
/**
|
|
@@ -25,7 +25,7 @@ type CalloutStatus = 'info' | 'success' | 'warning' | 'danger';
|
|
|
25
25
|
* drift out of step with the token library.
|
|
26
26
|
*/
|
|
27
27
|
declare const calloutVariants: (props?: ({
|
|
28
|
-
status?: "
|
|
28
|
+
status?: "danger" | "success" | "warning" | "info" | null | undefined;
|
|
29
29
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
30
30
|
type CalloutProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> & VariantProps<typeof calloutVariants> & {
|
|
31
31
|
/** Optional bold lead line above the body copy. */
|
|
@@ -66,7 +66,7 @@ declare function Callout({ className, status, title, icon, children, ref, ...pro
|
|
|
66
66
|
*/
|
|
67
67
|
declare const Alert: typeof Callout;
|
|
68
68
|
declare const alertVariants: (props?: ({
|
|
69
|
-
status?: "
|
|
69
|
+
status?: "danger" | "success" | "warning" | "info" | null | undefined;
|
|
70
70
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
71
71
|
type AlertProps = CalloutProps;
|
|
72
72
|
type AlertStatus = CalloutStatus;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
3
4
|
import { cn } from '../lib/utils.js';
|
|
4
5
|
import { IconCheckCircle } from '../icons/check-circle.js';
|
|
5
6
|
import { IconError } from '../icons/error.js';
|
|
@@ -32,16 +33,16 @@ const calloutVariants = cva(
|
|
|
32
33
|
}
|
|
33
34
|
);
|
|
34
35
|
function Callout({ className, status, title, icon, children, ref, ...props }) {
|
|
35
|
-
const resolvedStatus = status
|
|
36
|
+
const resolvedStatus = resolveVariant(status, "info");
|
|
36
37
|
const Icon = icon === void 0 ? CALLOUT_ICONS[resolvedStatus] : icon;
|
|
37
38
|
return /* @__PURE__ */ jsxs(
|
|
38
39
|
"div",
|
|
39
40
|
{
|
|
40
41
|
ref,
|
|
41
42
|
"data-slot": "callout",
|
|
42
|
-
"data-status": resolvedStatus,
|
|
43
|
-
className: cn(calloutVariants({ status, className })),
|
|
44
43
|
...props,
|
|
44
|
+
"data-status": resolvedStatus,
|
|
45
|
+
className: cn(calloutVariants({ status: resolvedStatus, className })),
|
|
45
46
|
children: [
|
|
46
47
|
Icon ? /* @__PURE__ */ jsx(
|
|
47
48
|
Icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/callout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/callout.tsx"],"names":[],"mappings":";;;;;;;;;AAwBA,MAAM,aAAA,GAA0D;AAAA,EAC9D,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,eAAA;AAAA,EACT,OAAA,EAAS,WAAA;AAAA,EACT,MAAA,EAAQ;AACV,CAAA;AAsBA,MAAM,eAAA,GAAkB,GAAA;AAAA,EACtB;AAAA,IACE,kCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,MAAA,EAAQ;AAAA,QACN,IAAA,EAAM,mJAAA;AAAA,QACN,OAAA,EACE,+JAAA;AAAA,QACF,OAAA,EACE,+JAAA;AAAA,QACF,MAAA,EACE;AAAA;AACJ,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,MAAA,EAAQ;AAAA;AACV;AAEJ;AAgCA,SAAS,OAAA,CAAQ,EAAE,SAAA,EAAW,MAAA,EAAQ,KAAA,EAAO,MAAM,QAAA,EAAU,GAAA,EAAK,GAAG,KAAA,EAAM,EAAiB;AAG1F,EAAA,MAAM,cAAA,GAAiB,cAAA,CAAe,MAAA,EAAQ,MAAM,CAAA;AAIpD,EAAA,MAAM,IAAA,GAAO,IAAA,KAAS,MAAA,GAAY,aAAA,CAAc,cAAc,CAAA,GAAI,IAAA;AAElE,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,SAAA;AAAA,MACT,GAAG,KAAA;AAAA,MAGJ,aAAA,EAAa,cAAA;AAAA,MACb,SAAA,EAAW,GAAG,eAAA,CAAgB,EAAE,QAAQ,cAAA,EAAgB,SAAA,EAAW,CAAC,CAAA;AAAA,MAEnE,QAAA,EAAA;AAAA,QAAA,IAAA,mBACC,GAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,aAAA,EAAY,MAAA;AAAA,YACZ,WAAA,EAAU,cAAA;AAAA,YAIV,SAAA,EAAU;AAAA;AAAA,SACZ,GACE,IAAA;AAAA,wBACJ,IAAA,CAAC,KAAA,EAAA,EAAI,WAAA,EAAU,iBAAA,EAAkB,WAAU,gBAAA,EACxC,QAAA,EAAA;AAAA,UAAA,KAAA,uBACE,GAAA,EAAA,EAAE,WAAA,EAAU,iBAAgB,SAAA,EAAU,eAAA,EACpC,iBACH,CAAA,GACE,IAAA;AAAA,UACH;AAAA,SAAA,EACH;AAAA;AAAA;AAAA,GACF;AAEJ;AAUA,MAAM,KAAA,GAAQ;AACd,MAAM,aAAA,GAAgB","file":"callout.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nimport { IconCheckCircle } from '../icons/check-circle.js'\nimport { IconError } from '../icons/error.js'\nimport { IconInfo } from '../icons/info.js'\nimport { IconWarning } from '../icons/warning.js'\n\n/** The four message statuses, matching `Toaster`'s vocabulary. */\ntype CalloutStatus = 'info' | 'success' | 'warning' | 'danger'\n\n/**\n * Status → glyph, deliberately identical to the mapping `sonner.tsx` gives its\n * toasts. A success confirmation should carry the same mark whether it arrives\n * as a toast or sits on the page, and a reader who has learnt one has learnt\n * the other.\n *\n * `danger` maps to `IconError` — the status name follows `Button`'s vocabulary\n * (`danger`, not `error`), while the icon name follows Material Symbols'.\n */\nconst CALLOUT_ICONS: Record<CalloutStatus, React.ElementType> = {\n info: IconInfo,\n success: IconCheckCircle,\n warning: IconWarning,\n danger: IconError,\n}\n\n/**\n * Every colour funnels through a single `--callout-ink` per status, declared on\n * the root so the icon and the border both resolve from one declaration — the\n * same ink-token pattern as `footer.tsx`, `link.tsx` and `step-indicator.tsx`.\n *\n * Values are the RAW `@nswds/tokens` semantic ROLE tokens (`--info-surface`,\n * `--info-text`, …), not the `--color-*` Tailwind bridge aliases. Two reasons,\n * both load-bearing:\n *\n * 1. Tailwind v4 tree-shakes unreferenced `@theme` keys, and an\n * arbitrary-property reference is not a usage signal — the same trap\n * documented on `button.tsx`'s semantic colours and `step-indicator.tsx`'s\n * status inks. The raw tokens are plain `:root` declarations that always\n * resolve.\n * 2. The role tokens already carry their own dark values, scoped\n * `[data-theme=dark], .dark` by `@nswds/tokens`' `semantic/oklch.dark.css`\n * (imported by theme.css). So every status flips with the theme on its own\n * and this component needs no `dark:` variant at all — nothing here can\n * drift out of step with the token library.\n */\nconst calloutVariants = cva(\n [\n 'flex gap-4 rounded-md border p-6',\n 'border-(--callout-border) bg-(--callout-surface) text-(--callout-text)',\n ],\n {\n variants: {\n status: {\n info: '[--callout-border:var(--info-border)] [--callout-ink:var(--info-solid)] [--callout-surface:var(--info-surface)] [--callout-text:var(--info-text)]',\n success:\n '[--callout-border:var(--success-border)] [--callout-ink:var(--success-solid)] [--callout-surface:var(--success-surface)] [--callout-text:var(--success-text)]',\n warning:\n '[--callout-border:var(--warning-border)] [--callout-ink:var(--warning-solid)] [--callout-surface:var(--warning-surface)] [--callout-text:var(--warning-text)]',\n danger:\n '[--callout-border:var(--danger-border)] [--callout-ink:var(--danger-solid)] [--callout-surface:var(--danger-surface)] [--callout-text:var(--danger-text)]',\n },\n },\n defaultVariants: {\n status: 'info',\n },\n },\n)\n\ntype CalloutProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> &\n VariantProps<typeof calloutVariants> & {\n /** Optional bold lead line above the body copy. */\n title?: React.ReactNode\n /**\n * Replaces the status glyph. Pass `null` to drop it entirely — the status\n * is still carried by the border and surface, and by `title` where one is\n * supplied.\n */\n icon?: React.ElementType | null\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * A bordered notice that marks a passage of page content as informational,\n * confirming, cautionary or dangerous.\n *\n * **This is for STATIC content, and carries no live-region semantics.** No\n * `role=\"alert\"`, no `aria-live`: those announce on mount, so a callout that is\n * simply part of the page would interrupt a screen-reader user every time they\n * arrived. Use `Toaster` for a message that appears in response to something\n * the user just did, or `FieldError` for inline validation — both already\n * handle announcement. If you render a `Callout` dynamically and it genuinely\n * needs announcing, own that at the call site with your own live region.\n *\n * **Status is never carried by colour alone** (WCAG 2.2, 1.4.1). The glyph\n * distinguishes the four statuses visually; where the distinction also matters\n * to a screen-reader user, say so in the `title` or the body copy rather than\n * relying on the icon, which is decorative here by design.\n */\nfunction Callout({ className, status, title, icon, children, ref, ...props }: CalloutProps) {\n // Resolved once (see `resolveVariant`), so cva, `data-status` and the icon\n // lookup agree for `null` and `''` as well as the default spelling.\n const resolvedStatus = resolveVariant(status, 'info')\n // `icon` is optional-with-a-default AND nullable-to-disable, so an explicit\n // `null` has to survive: `icon ?? CALLOUT_ICONS[…]` would resurrect the\n // default for exactly the consumer trying to turn it off.\n const Icon = icon === undefined ? CALLOUT_ICONS[resolvedStatus] : icon\n\n return (\n <div\n ref={ref}\n data-slot='callout'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-status={resolvedStatus}\n className={cn(calloutVariants({ status: resolvedStatus, className }))}\n >\n {Icon ? (\n <Icon\n aria-hidden='true'\n data-slot='callout-icon'\n // The icon modules paint `fill=\"currentColor\"`, so setting the text\n // colour here is what tints the glyph — and it keeps working for a\n // consumer-supplied `icon` drawn with strokes rather than fills.\n className='mt-0.5 size-6 shrink-0 text-(--callout-ink)'\n />\n ) : null}\n <div data-slot='callout-content' className='min-w-0 flex-1'>\n {title ? (\n <p data-slot='callout-title' className='font-semibold'>\n {title}\n </p>\n ) : null}\n {children}\n </div>\n </div>\n )\n}\n\n/**\n * `Callout` under shadcn's name, so code and habits carried over from shadcn's\n * `<Alert>` find it. It is the same component with the same props, which\n * differ from shadcn's in three ways: the tone is `status` (`info`, `success`,\n * `warning`, `danger`) rather than `variant`; the title is the `title` prop and\n * the body is `children`, so there is no `AlertTitle` / `AlertDescription`;\n * and it carries no `role=\"alert\"`, for the reason given on `Callout`.\n */\nconst Alert = Callout\nconst alertVariants = calloutVariants\ntype AlertProps = CalloutProps\ntype AlertStatus = CalloutStatus\n\nexport { Alert, alertVariants, Callout, calloutVariants }\nexport type { AlertProps, AlertStatus, CalloutProps, CalloutStatus }\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
3
4
|
import { cn } from '../lib/utils.js';
|
|
4
5
|
|
|
6
|
+
const DEFAULT_DESCRIPTION_LIST_LAYOUT = "stacked";
|
|
5
7
|
const descriptionListVariants = cva("", {
|
|
6
8
|
variants: {
|
|
7
9
|
layout: {
|
|
@@ -24,18 +26,19 @@ const descriptionListVariants = cva("", {
|
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
defaultVariants: {
|
|
27
|
-
layout:
|
|
29
|
+
layout: DEFAULT_DESCRIPTION_LIST_LAYOUT
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
function DescriptionList({ className, layout, ref, ...props }) {
|
|
33
|
+
const layoutway = resolveVariant(layout, DEFAULT_DESCRIPTION_LIST_LAYOUT);
|
|
31
34
|
return /* @__PURE__ */ jsx(
|
|
32
35
|
"dl",
|
|
33
36
|
{
|
|
34
37
|
ref,
|
|
35
38
|
"data-slot": "description-list",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
...props,
|
|
40
|
+
"data-layout": layoutway,
|
|
41
|
+
className: cn(descriptionListVariants({ layout: layoutway, className }))
|
|
39
42
|
}
|
|
40
43
|
);
|
|
41
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/description-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/description-list.tsx"],"names":[],"mappings":";;;;;AASA,MAAM,+BAAA,GAAkC,SAAA;AAwBxC,MAAM,uBAAA,GAA0B,IAAI,EAAA,EAAI;AAAA,EACtC,QAAA,EAAU;AAAA,IACR,MAAA,EAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,MAKN,OAAA,EAAS,qBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,OAAA,EACE,8FAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAKF,MAAA,EAAQ;AAAA;AACV,GACF;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,MAAA,EAAQ;AAAA;AAEZ,CAAC;AA4BD,SAAS,gBAAgB,EAAE,SAAA,EAAW,QAAQ,GAAA,EAAK,GAAG,OAAM,EAAyB;AAGnF,EAAA,MAAM,SAAA,GAAY,cAAA,CAAe,MAAA,EAAQ,+BAA+B,CAAA;AACxE,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,kBAAA;AAAA,MACT,GAAG,KAAA;AAAA,MAGJ,aAAA,EAAa,SAAA;AAAA,MACb,SAAA,EAAW,GAAG,uBAAA,CAAwB,EAAE,QAAQ,SAAA,EAAW,SAAA,EAAW,CAAC;AAAA;AAAA,GACzE;AAEJ;AAOA,SAAS,gBAAgB,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAyB;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,yCAAA,EAA2C,SAAS,CAAA;AAAA,MACjE,GAAG;AAAA;AAAA,GACN;AAEJ;AAaA,SAAS,mBAAmB,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAA4B;AACjF,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,qBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,wCAAA,EAA0C,SAAS,CAAA;AAAA,MAChE,GAAG;AAAA;AAAA,GACN;AAEJ","file":"description-list.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\n// Shared by cva's defaultVariants, the data-layout attribute and the\n// `resolveVariant` call in `DescriptionList`, so they can't drift apart.\nconst DEFAULT_DESCRIPTION_LIST_LAYOUT = 'stacked'\n\n/**\n * Term/detail pairs — metadata strips, summary rows, key–value facts.\n *\n * **This name shipped once before and was removed.** `DescriptionList` was\n * dropped from the public API as a BREAKING CHANGE in v3 (commit 09d6db3),\n * incidentally, inside a commit whose subject was adding ten unrelated\n * components; its registry item then outlived it by three releases until\n * `check:registry-resolves` caught the orphan. Consumers were told to migrate\n * off it, so this is a deliberate re-introduction rather than a revert, and it\n * is not source-compatible with the old one:\n *\n * - The old markup was a single hardcoded grid\n * (`sm:grid-cols-[min(50%,--spacing(80))_auto]`) with no way to opt out.\n * Layout is now a variant.\n * - The old classes were cascade-unsafe in exactly the way `check:cascade`\n * now fails a build for — `text-base/6 sm:text-sm/6` and\n * `border-t … sm:border-t` are bare utilities paired with responsive\n * overrides of the same property, so an npm consumer's own Tailwind build\n * could outrank them. Every responsive step here is a mutually exclusive\n * range instead.\n * - The old type ramp dropped to 14px from `sm` up. Body copy holds at 16px.\n */\nconst descriptionListVariants = cva('', {\n variants: {\n layout: {\n /**\n * Terms above details, stacked in one column at every width. The safe\n * default: it never truncates a long term and needs no width assumptions.\n */\n stacked: 'flex flex-col gap-4',\n /**\n * Two columns from `sm` up — term in the first, detail in the second —\n * collapsing to `stacked` below it. The classic definition-list\n * treatment for short terms.\n */\n columns:\n 'grid gap-x-8 gap-y-4 max-sm:grid-cols-1 sm:grid-cols-[minmax(0,--spacing(60))_minmax(0,1fr)]',\n /**\n * Facts side by side, wrapping as they run out of room — the strip\n * under a page banner. Terms sit above their details within each cell.\n */\n inline: 'grid gap-x-8 gap-y-6 max-sm:grid-cols-2 sm:grid-cols-4',\n },\n },\n defaultVariants: {\n layout: DEFAULT_DESCRIPTION_LIST_LAYOUT,\n },\n})\n\ntype DescriptionListProps = React.ComponentPropsWithoutRef<'dl'> &\n VariantProps<typeof descriptionListVariants> & {\n ref?: React.Ref<HTMLDListElement>\n }\n\n/**\n * A `<dl>` of term/detail pairs.\n *\n * **`columns` and `inline` place their own children, so each pair must be\n * wrapped in a single element.** A `<dl>` may contain `<div>` wrappers around\n * `<dt>`/`<dd>` groups — that is valid HTML and preserves the list semantics —\n * and it is what keeps a term with its detail when the grid wraps. Without the\n * wrapper the grid places every `<dt>` and `<dd>` independently and pairs come\n * apart at the wrap point:\n *\n * ```tsx\n * <DescriptionList layout='inline'>\n * <div>\n * <DescriptionTerm>Version</DescriptionTerm>\n * <DescriptionDetails>2.001</DescriptionDetails>\n * </div>\n * </DescriptionList>\n * ```\n *\n * `stacked` has no such requirement — wrap or don't, it reads the same.\n */\nfunction DescriptionList({ className, layout, ref, ...props }: DescriptionListProps) {\n // Resolved once (see `resolveVariant`), so cva and `data-layout` agree for\n // `null` and `''` as well as the default spelling.\n const layoutway = resolveVariant(layout, DEFAULT_DESCRIPTION_LIST_LAYOUT)\n return (\n <dl\n ref={ref}\n data-slot='description-list'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-layout={layoutway}\n className={cn(descriptionListVariants({ layout: layoutway, className }))}\n />\n )\n}\n\ntype DescriptionTermProps = React.ComponentPropsWithoutRef<'dt'> & {\n ref?: React.Ref<HTMLElement>\n}\n\n/** The term half of a pair — the label. */\nfunction DescriptionTerm({ className, ref, ...props }: DescriptionTermProps) {\n return (\n <dt\n ref={ref}\n data-slot='description-term'\n className={cn('text-base/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\ntype DescriptionDetailsProps = React.ComponentPropsWithoutRef<'dd'> & {\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * The detail half of a pair — the value.\n *\n * `ms-0` is deliberate: browsers give `<dd>` a 40px `margin-inline-start` by\n * default, which the grid layouts would otherwise indent every value by. It is\n * an unconditional reset, so it does not fight the responsive ramp.\n */\nfunction DescriptionDetails({ className, ref, ...props }: DescriptionDetailsProps) {\n return (\n <dd\n ref={ref}\n data-slot='description-details'\n className={cn('ms-0 text-base/relaxed text-foreground', className)}\n {...props}\n />\n )\n}\n\nexport { DescriptionDetails, DescriptionList, descriptionListVariants, DescriptionTerm }\nexport type { DescriptionDetailsProps, DescriptionListProps, DescriptionTermProps }\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
5
6
|
import { cn } from '../lib/utils.js';
|
|
6
7
|
import { IconSearch } from '../icons/search.js';
|
|
7
8
|
|
|
@@ -97,13 +98,13 @@ function ExpandableSearch({
|
|
|
97
98
|
onSubmit,
|
|
98
99
|
onFocusCapture,
|
|
99
100
|
onBlurCapture,
|
|
100
|
-
variant
|
|
101
|
+
variant,
|
|
101
102
|
ref,
|
|
102
103
|
...props
|
|
103
104
|
}) {
|
|
104
105
|
const [value, setValue] = React.useState(defaultValue);
|
|
105
106
|
const [formHasFocusWithin, setFormHasFocusWithin] = React.useState(false);
|
|
106
|
-
const resolvedVariant = variant
|
|
107
|
+
const resolvedVariant = resolveVariant(variant, "default");
|
|
107
108
|
const isActive = value.length > 0 || formHasFocusWithin;
|
|
108
109
|
const contextValue = React.useMemo(
|
|
109
110
|
() => ({ value, setValue, formHasFocusWithin, variant: resolvedVariant }),
|
|
@@ -132,10 +133,10 @@ function ExpandableSearch({
|
|
|
132
133
|
"form",
|
|
133
134
|
{
|
|
134
135
|
"data-slot": "expandable-search",
|
|
135
|
-
"data-variant": resolvedVariant,
|
|
136
136
|
"data-expanded": isActive || void 0,
|
|
137
137
|
...props,
|
|
138
|
-
|
|
138
|
+
"data-variant": resolvedVariant,
|
|
139
|
+
className: cn(expandableSearchVariants({ variant: resolvedVariant }), className),
|
|
139
140
|
onBlurCapture: handleBlurCapture,
|
|
140
141
|
onFocusCapture: handleFocusCapture,
|
|
141
142
|
onSubmit: handleSubmit,
|