@rtkelly-labs/design-system 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/components/BracketText.js +3 -2
- package/dist/components/BracketText.js.map +1 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.js +2 -1
- package/dist/components/Card.js.map +1 -1
- package/dist/components/DataTable.js.map +1 -1
- package/dist/components/Divider.js +21 -14
- package/dist/components/Divider.js.map +1 -1
- package/dist/components/InlineAction.js.map +1 -1
- package/dist/components/PageTitle.js +5 -1
- package/dist/components/PageTitle.js.map +1 -1
- package/dist/components/ResourceState.js.map +1 -1
- package/dist/components/SocialIcon.js.map +1 -1
- package/dist/components/StatCard.js +2 -2
- package/dist/components/StatCard.js.map +1 -1
- package/dist/components/StatusPage.js.map +1 -1
- package/dist/components/docs/figures/ActivityGrid.js.map +1 -1
- package/dist/components/docs/figures/ChangeSummary.js +68 -25
- package/dist/components/docs/figures/ChangeSummary.js.map +1 -1
- package/dist/components/docs/figures/FigureFrame.js.map +1 -1
- package/dist/components/docs/figures/index.js.map +1 -1
- package/dist/components/experiments/ExperimentsView.js.map +1 -1
- package/dist/components/marketing/FeatureGrid.js.map +1 -1
- package/dist/components/marketing/Hero.js +2 -2
- package/dist/components/marketing/Hero.js.map +1 -1
- package/dist/components/marketing/PricingGrid.js.map +1 -1
- package/dist/components/review/ChangeBar.js +29 -0
- package/dist/components/review/ChangeBar.js.map +1 -0
- package/dist/components/review/ChangeCount.js +27 -0
- package/dist/components/review/ChangeCount.js.map +1 -0
- package/dist/components/review/ChangeIndex.js +50 -0
- package/dist/components/review/ChangeIndex.js.map +1 -0
- package/dist/components/review/DeltaValue.js +87 -0
- package/dist/components/review/DeltaValue.js.map +1 -0
- package/dist/components/review/DiffView.js +115 -0
- package/dist/components/review/DiffView.js.map +1 -0
- package/dist/components/review/KeyedDiff.js +43 -0
- package/dist/components/review/KeyedDiff.js.map +1 -0
- package/dist/components/review/ProvenanceStrip.js +17 -0
- package/dist/components/review/ProvenanceStrip.js.map +1 -0
- package/dist/components/review/PullRequestPage.js +223 -0
- package/dist/components/review/PullRequestPage.js.map +1 -0
- package/dist/components/review/ReviewReportPage.js +111 -0
- package/dist/components/review/ReviewReportPage.js.map +1 -0
- package/dist/components/review/StatusMark.js +32 -0
- package/dist/components/review/StatusMark.js.map +1 -0
- package/dist/components/review/VerdictBand.js +45 -0
- package/dist/components/review/VerdictBand.js.map +1 -0
- package/dist/components/review/diff.js +53 -0
- package/dist/components/review/diff.js.map +1 -0
- package/dist/components/review/index.js +16 -0
- package/dist/components/review/index.js.map +1 -0
- package/dist/components/review/samples.js +235 -0
- package/dist/components/review/samples.js.map +1 -0
- package/dist/components/review/vocabulary.js +51 -0
- package/dist/components/review/vocabulary.js.map +1 -0
- package/dist/components/saas/SaasLandingPage.js +10 -2
- package/dist/components/saas/SaasLandingPage.js.map +1 -1
- package/dist/index.d.ts +640 -24
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,37 @@ Proper release notes start at 1.0. Until then this file records only what a
|
|
|
9
9
|
consumer has to *do*, newest first. The reasoning lives in the pull requests and
|
|
10
10
|
in [`docs/adr/`](./docs/adr/).
|
|
11
11
|
|
|
12
|
+
## 0.20.0
|
|
13
|
+
|
|
14
|
+
Review surfaces and lighter page weight. Re-baseline snapshots of anything showing a page title,
|
|
15
|
+
a bracketed title, a divider, `SaasLandingPage`, or the pages that now use quiet cards.
|
|
16
|
+
|
|
17
|
+
The review family: `VerdictBand`, `StatusMark`, `ProvenanceStrip`, `DeltaValue`,
|
|
18
|
+
`ChangeCount`, `ChangeBar`, `ChangeIndex`, `DiffView`, `KeyedDiff`, with
|
|
19
|
+
`parseUnifiedDiff`, `countDiff` and `diffAnchor`. `DiffView` lines take review `comments`.
|
|
20
|
+
Only the verdict carries a strong border and shadow; the rest of the family is ruled or
|
|
21
|
+
hairline-framed.
|
|
22
|
+
|
|
23
|
+
`ReviewReportPage` and `PullRequestPage` compose the family into whole pages: the report a
|
|
24
|
+
comparison tool such as Diffra emits, and a pull request under review. Both ship with sample
|
|
25
|
+
data (`DEFAULT_REVIEW_REPORT`, `DEFAULT_PULL_REQUEST`) and appear on the site's examples.
|
|
26
|
+
|
|
27
|
+
`StatCard` takes `appearance="quiet"` and `Card` takes `weight="quiet"` (passed through by
|
|
28
|
+
`Feature` and `PricingTier`), for figures in a row and panels beside a heavier object. Defaults
|
|
29
|
+
are unchanged. `SaasLandingPage` now draws its features and non-recommended plans quiet:
|
|
30
|
+
re-baseline its snapshots.
|
|
31
|
+
|
|
32
|
+
`PageTitle` and `Hero` take `framed` (default `true`); `SaasLandingPage` passes `false`, so its
|
|
33
|
+
deploy terminal leads. `BracketText` joins each bracket to its neighbouring word with a no-break
|
|
34
|
+
space, so a wrapping title no longer strands a `]` on its own line, and `PageTitle` balances its
|
|
35
|
+
lines. `Divider` now runs the full width of its container: a start cap, a fill sized to whole
|
|
36
|
+
characters with CSS `round()`, and an end cap. An explicit `pattern` is drawn as before.
|
|
37
|
+
Re-baseline anything showing a page title, a bracketed title or a divider.
|
|
38
|
+
|
|
39
|
+
Every type the public API names is now exported (#452). Model-based, type-surface and on-demand
|
|
40
|
+
mutation tests (#450, #451), the Stitch sync pipeline (#442) and the `design.md` /
|
|
41
|
+
`machine.design.md` split (#443) are internal. Nothing to change.
|
|
42
|
+
|
|
12
43
|
## 0.19.0
|
|
13
44
|
|
|
14
45
|
Pieces for operational apps, upstreamed from the rig hub (rtkelly13/rig#274). Nothing to change.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { cn } from "../lib/recipe.js";
|
|
3
3
|
import { accentTextClass } from "../lib/accentClasses.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var NBSP = "\xA0";
|
|
5
6
|
function BracketText({
|
|
6
7
|
children,
|
|
7
8
|
accent,
|
|
@@ -11,9 +12,9 @@ function BracketText({
|
|
|
11
12
|
const accentClass = accent ? accentTextClass(accent) : "";
|
|
12
13
|
return /* @__PURE__ */ jsxs("span", { "data-slot": "bracket-text", className: cn(accentClass, className), ...props, children: [
|
|
13
14
|
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "[" }),
|
|
14
|
-
|
|
15
|
+
NBSP,
|
|
15
16
|
children,
|
|
16
|
-
|
|
17
|
+
NBSP,
|
|
17
18
|
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "]" })
|
|
18
19
|
] });
|
|
19
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/BracketText.tsx"],"sourcesContent":["import type { ReactNode, HTMLAttributes } from 'react';\nimport type { AccentToken } from '../lib/theme';\nimport { cn } from '../lib/recipe';\nimport { accentTextClass } from '../lib/accentClasses';\n\nexport interface BracketTextProps extends HTMLAttributes<HTMLSpanElement> {\n children: ReactNode;\n /**\n * Semantic emphasis. Roles only — `'white'` was still accepted here after\n * #138 removed the hue vocabulary from the component API, because the union\n * named it explicitly and the class map was typed `Record<string, string>`.\n * An appearance name in a component API is the defect ADR 0001 exists to\n * prevent; omit `accent` for the default ink.\n */\n accent?: AccentToken;\n className?: string;\n}\n\nexport function BracketText({\n children,\n accent,\n className = '',\n ...props\n}: BracketTextProps) {\n // No per-render object: the map lives in `lib/accentClasses`, written once.\n const accentClass = accent ? accentTextClass(accent) : '';\n\n return (\n <span data-slot=\"bracket-text\" className={cn(accentClass, className)} {...props}>\n <span aria-hidden=\"true\">\n
|
|
1
|
+
{"version":3,"sources":["../../src/components/BracketText.tsx"],"sourcesContent":["import type { ReactNode, HTMLAttributes } from 'react';\nimport type { AccentToken } from '../lib/theme';\nimport { cn } from '../lib/recipe';\nimport { accentTextClass } from '../lib/accentClasses';\n\nconst NBSP = '\\u00a0';\n\nexport interface BracketTextProps extends HTMLAttributes<HTMLSpanElement> {\n children: ReactNode;\n /**\n * Semantic emphasis. Roles only — `'white'` was still accepted here after\n * #138 removed the hue vocabulary from the component API, because the union\n * named it explicitly and the class map was typed `Record<string, string>`.\n * An appearance name in a component API is the defect ADR 0001 exists to\n * prevent; omit `accent` for the default ink.\n */\n accent?: AccentToken;\n className?: string;\n}\n\nexport function BracketText({\n children,\n accent,\n className = '',\n ...props\n}: BracketTextProps) {\n // No per-render object: the map lives in `lib/accentClasses`, written once.\n const accentClass = accent ? accentTextClass(accent) : '';\n\n // A no-break space, not a space, between each bracket and the text: a wrapping title must\n // never strand a `]` alone on the last line, or open a line with `[` and nothing after it.\n return (\n <span data-slot=\"bracket-text\" className={cn(accentClass, className)} {...props}>\n <span aria-hidden=\"true\">[</span>\n {NBSP}\n {children}\n {NBSP}\n <span aria-hidden=\"true\">]</span>\n </span>\n );\n}\n"],"mappings":";AAEA,SAAS,UAAU;AACnB,SAAS,uBAAuB;AA6B5B,SACE,KADF;AA3BJ,IAAM,OAAO;AAeN,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAAqB;AAEnB,QAAM,cAAc,SAAS,gBAAgB,MAAM,IAAI;AAIvD,SACE,qBAAC,UAAK,aAAU,gBAAe,WAAW,GAAG,aAAa,SAAS,GAAI,GAAG,OACxE;AAAA,wBAAC,UAAK,eAAY,QAAO,eAAC;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACD,oBAAC,UAAK,eAAY,QAAO,eAAC;AAAA,KAC5B;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Button.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef } from 'react';\nimport type { Ref } from 'react';\nimport type {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport { recipe } from '../lib/recipe';\nimport { Spinner } from './Spinner';\n\ninterface ButtonOwnProps {\n /**\n * The label. Written in caps at the call site rather than upper-cased in\n * CSS, so a screen reader is given the words rather than the shouting, and\n * so an acronym that is already caps does not read as emphasis.\n */\n children: ReactNode;\n /**\n * `primary`, `secondary` and `tertiary` use the corresponding accent role,\n * which changes with the theme level. `inverse` uses the primary content\n * role as its background for maximum contrast. `default` is identical to\n * `primary`. Omitted, the variant is `tertiary`.\n */\n variant?: ButtonVariant;\n /**\n * Padding and type scale, not a semantic weight. `md` is the default and the\n * one to reach for; `sm` is for dense rows such as a table's row actions,\n * and `lg` for a page's single primary action. Hit area is the constraint\n * that decides — `sm` is still 44px tall at the `web` Medium.\n */\n size?: 'sm' | 'md' | 'lg';\n /**\n * Wraps the label in `[ ]`. The brutalist cue for \"this one does something\"\n * — worth it for a form's submit or a destructive confirm, noise on every\n * button in a toolbar. It is punctuation in the label, not a border.\n */\n bracketed?: boolean;\n /**\n * Merged into the recipe's own classes. Reach for it to place the button —\n * `w-full`, a grid slot — rather than to restyle it; a colour set here is\n * what `pnpm check:tokens` exists to find.\n */\n className?: string;\n}\n\n/**\n * The accents a filled Button may take.\n *\n * Narrower than `AccentToken` on purpose: `quiet` is missing because\n * `check:contrast` gates `text.inverse` against `accent.primary`, `secondary`\n * and `tertiary` only. A quiet fill with inverse text on it is not measured, so\n * it is not offered.\n */\nexport type ButtonVariant =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'inverse'\n | 'default';\n\n/**\n * The `<button>` form. `href?: never` is what makes the union below\n * discriminate: without it TypeScript would accept `href` here and silently\n * drop it onto an element that ignores it.\n */\nexport type ButtonElementProps = ButtonOwnProps &\n DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> & {\n href?: never;\n /**\n * The request this button started is in flight. Reach for it instead of\n * `disabled` while a submit is being sent.\n *\n * `disabled` removes a focused button from the tab order and drops focus\n * to `<body>`, so a keyboard user is thrown back to the top of the page\n * at the moment they need to hear what happened. A pending button keeps\n * focus and its tab stop, reports `aria-disabled=\"true\"` instead of the\n * `disabled` attribute, and ignores activation: a click, Enter, Space,\n * or Enter in one of its form's fields does not run `onClick` and does\n * not submit the form again.\n *\n * It shows a spinner in place of the label, over the label's own box, so\n * the button keeps its width; the label stays in the accessibility tree,\n * so the accessible name does not change while it has focus. The fill is\n * kept and the button sits sunk into its press — the same offset and no\n * shadow as `:active` — which is distinct from the sunken, muted\n * `disabled` treatment.\n *\n * Pass it from the first render — `pending={saving}`, not\n * `pending={saving || undefined}` — so the live region that announces\n * `pendingLabel` is in the page before it has anything to say. `disabled`\n * wins over `pending` when both are set.\n */\n pending?: boolean;\n /**\n * What is being waited for, as a screen reader hears it when `pending`\n * turns on — \"Signing in\", not \"Loading\". It is written into a visually\n * hidden `role=\"status\"` region beside the button, which exists whenever\n * `pending` is passed at all and is empty until it is `true`.\n */\n pendingLabel?: string;\n };\n\n/** The `<a>` form. Passing `href` selects it; there is no `as` prop to remember. */\nexport type ButtonLinkProps = ButtonOwnProps &\n DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> & {\n /**\n * Where it navigates — and the discriminant. Supplying it renders an `<a>`\n * wearing the button's styling, which is what a keyboard user, a screen\n * reader and a middle click all need from something that navigates. Omit\n * it for anything that acts on the current page.\n */\n href: string;\n /**\n * Not offered on the anchor form. A link's work is the browser's\n * navigation, which the page cannot hold open, and `aria-disabled` on a\n * link is a link that still navigates. A control that starts a request\n * is a `<button>`.\n */\n pending?: never;\n /** Not offered on the anchor form; see `pending`. */\n pendingLabel?: never;\n };\n\nexport type ButtonProps = ButtonElementProps | ButtonLinkProps;\n\n/**\n * The press affordance — offset shadow that collapses as the control moves into\n * it. Shared rather than repeated so the four accents cannot drift apart.\n *\n * Hover and press are gated on `not-disabled:` so a disabled button does not\n * lift under the pointer or sink when clicked: it would be promising an action\n * it will not take. `not-disabled` rather than `enabled`, because `:enabled`\n * matches form elements only and the anchor form would lose its hover.\n *\n * `not-aria-disabled:` is the same gate for a pending button, which is\n * `aria-disabled` rather than `:disabled` so that it keeps focus. Spelled out\n * in full rather than built from a constant: Tailwind reads the source text,\n * and a template literal emits no CSS.\n */\nconst PRESS =\n 'shadow-hard-md not-disabled:not-aria-disabled:hover:shadow-hard-lg ' +\n 'not-disabled:not-aria-disabled:active:translate-x-1 ' +\n 'not-disabled:not-aria-disabled:active:translate-y-1 ' +\n 'not-disabled:not-aria-disabled:active:shadow-none';\n\n/**\n * The disabled treatment, the one `Select`'s trigger and the text fields wear:\n * a sunken ground, the subtle edge, muted ink and no shadow. Before #252 a\n * disabled button rendered exactly like an enabled one — it looked pressable\n * and did nothing. A request in flight is `pending`, not this. `disabled:`\n * matches the `<button>` form only, which is right: an anchor cannot be\n * disabled.\n */\nconst DISABLED =\n 'disabled:cursor-not-allowed disabled:border-edge-subtle disabled:bg-surface-sunken ' +\n 'disabled:text-content-muted disabled:shadow-none';\n\n/**\n * One constant per rendered form, aliased by every name that resolves to it.\n *\n * `default` and `primary` share the same constant and render identically.\n */\nconst PRIMARY = `bg-accent-primary text-content-inverse border-edge-strong ${PRESS}`;\nconst SECONDARY = `bg-accent-secondary text-content-inverse border-edge-strong ${PRESS}`;\nconst TERTIARY = `bg-accent-tertiary text-content-inverse border-edge-strong ${PRESS}`;\nconst INVERSE = `bg-content-primary text-content-inverse border-content-primary ${PRESS}`;\n\nconst button = recipe({\n base: `font-mono font-bold uppercase border-2 transition-all duration-200 ${DISABLED}`,\n variants: {\n size: {\n sm: 'px-4 py-2 text-sm',\n md: 'px-6 py-3 text-base',\n lg: 'px-8 py-4 text-lg',\n },\n variant: {\n primary: PRIMARY,\n secondary: SECONDARY,\n tertiary: TERTIARY,\n inverse: INVERSE,\n default: PRIMARY,\n },\n /**\n * An anchor is not `inline-flex` by default and carries an underline, so the\n * two forms would otherwise lay out and read differently from identical\n * props. A variant rather than a prepended string so a caller's own\n * `className` still resolves against it.\n */\n asLink: {\n true: 'inline-flex items-center justify-center no-underline',\n },\n /**\n * Held in its press: the `:active` offset with the shadow gone, over the\n * variant's own fill. Enabled is raised, disabled is sunken and muted, and\n * pending is the one in between — this button was pressed and has not let\n * go. `relative` is the box the spinner is centred in.\n */\n pending: {\n true: 'relative cursor-progress translate-x-1 translate-y-1 shadow-none',\n },\n },\n defaultVariants: {\n variant: 'tertiary',\n size: 'md',\n },\n});\n\n/**\n * A button, or a link that looks like one.\n *\n * The distinction is not cosmetic and is not the caller's styling preference:\n * a control that *navigates* must be an `<a>`, or it loses middle-click,\n * open-in-new-tab, the status-bar URL preview, and its announcement as a link\n * to a screen reader. Marketing CTAs are overwhelmingly navigation — \"Get\n * started\" goes somewhere — so a button-only component pushes every landing\n * page into either nesting an anchor inside a button (invalid HTML) or\n * re-styling the whole thing by hand.\n *\n * Passing `href` selects the anchor form, and TypeScript then offers anchor\n * attributes (`target`, `rel`, `download`) and withdraws button-only ones\n * (`disabled`, `type`) — the latter being the point, since `disabled` does\n * nothing whatsoever on an anchor.\n *\n * ```tsx\n * <Button onClick={save}>SAVE</Button>\n * <Button href=\"/pricing\" variant=\"tertiary\" bracketed size=\"lg\">SEE PRICING</Button>\n * ```\n */\n/**\n * Forwards its ref to whichever element it renders.\n *\n * `ButtonProps` is a union, so the ref's type is the union of both targets —\n * `HTMLButtonElement | HTMLAnchorElement`. A caller who knows which form they\n * asked for can narrow it; one who does not is told the truth, which is that it\n * depends on `href`.\n *\n * This is what `<Tooltip.Trigger render={<Button />} />` needs: Base UI's\n * composition merges props *and a ref* onto the element it is given, and a\n * component that drops the ref silently breaks positioning, focus return and\n * outside-click detection in every primitive that wraps it.\n */\nexport const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n function Button(props, ref) {\n const {\n children,\n variant = 'tertiary',\n size = 'md',\n bracketed = false,\n className,\n ...rest\n } = props;\n\n const label = bracketed ? (\n <span className=\"inline-flex items-center justify-center gap-2\">\n <span className=\"select-none\" aria-hidden=\"true\">\n [\n </span>\n <span className=\"inline-flex items-center gap-2\">{children}</span>\n <span className=\"select-none\" aria-hidden=\"true\">\n ]\n </span>\n </span>\n ) : (\n <span className=\"inline-flex items-center justify-center gap-2\">{children}</span>\n );\n\n if (typeof props.href === 'string') {\n // `pending` is `never` here; taken out so a stray `undefined` is not spread.\n const {\n pending: _pending,\n pendingLabel: _pendingLabel,\n ...anchorProps\n } = rest as Omit<ButtonLinkProps, keyof ButtonOwnProps>;\n return (\n <a data-slot=\"button\"\n ref={ref as Ref<HTMLAnchorElement>}\n {...anchorProps}\n // A `target=\"_blank\"` document can reach back through `window.opener`\n // unless told otherwise. Modern browsers imply `noopener`, but not\n // every renderer this package ships into is a modern browser, and an\n // explicit `rel` costs nothing. An explicit `rel` from the caller wins.\n rel={\n anchorProps.rel ??\n (anchorProps.target === '_blank' ? 'noopener noreferrer' : undefined)\n }\n className={button({ variant, size, asLink: true, class: className })}\n >\n {label}\n </a>\n );\n }\n\n const {\n pending,\n pendingLabel = 'Working',\n ...buttonProps\n } = rest as Omit<ButtonElementProps, keyof ButtonOwnProps>;\n const isPending = pending === true && !buttonProps.disabled;\n\n const element = (\n <button data-slot=\"button\"\n ref={ref as Ref<HTMLButtonElement>}\n {...buttonProps}\n // The `disabled` attribute is what drops focus, so a pending button says\n // it is unavailable through ARIA and refuses activation here instead.\n // Enter and Space on a focused button, and Enter in a text field of its\n // form (implicit submission), all reach a button as a `click`; cancelling\n // it cancels the submit it would have sent. Base UI's Button does the\n // same under `focusableWhenDisabled`.\n aria-disabled={isPending ? true : buttonProps['aria-disabled']}\n onClick={isPending ? preventActivation : buttonProps.onClick}\n data-pending={isPending ? '' : undefined}\n className={button({ variant, size, pending: isPending, class: className })}\n >\n {isPending ? (\n <>\n {/* Transparent, not removed: it holds the width and the name. */}\n <span className=\"inline-flex opacity-0\">{label}</span>\n <Spinner\n // Sized to the label's line box: `sm` in a small button, `md` —\n // about a capital's height and a half — in the others.\n size={size === 'sm' ? 'sm' : 'md'}\n accent=\"current\"\n // The status region beside the button announces the wait. This is\n // the drawing only; a second live region inside a button, whose\n // children are presentational, would be read unreliably or twice.\n role={undefined}\n aria-hidden=\"true\"\n className=\"absolute inset-0\"\n />\n </>\n ) : (\n label\n )}\n </button>\n );\n\n if (pending === undefined) return element;\n\n return (\n <>\n {element}\n {/*\n * Outside the button because a button's children are presentational: a\n * live region inside one is flattened into its name. Present from the\n * first render and filled only while pending, which is what makes the\n * insertion an announcement rather than a region appearing already full.\n */}\n <span role=\"status\" className=\"sr-only\" data-slot=\"button-status\">\n {isPending ? pendingLabel : ''}\n </span>\n </>\n );\n});\n\n/** A pending button's click: cancelled, so neither `onClick` nor a submit runs. */\nfunction preventActivation(event: MouseEvent<HTMLButtonElement>) {\n event.preventDefault();\n}\n"],"mappings":";;;AAEA,SAAS,kBAAkB;AAS3B,SAAS,cAAc;AACvB,SAAS,eAAe;AAqPpB,SA8DI,UA7DF,KADF;AAlHJ,IAAM,QACJ;AAaF,IAAM,WACJ;AAQF,IAAM,UAAU,6DAA6D,KAAK;AAClF,IAAM,YAAY,+DAA+D,KAAK;AACtF,IAAM,WAAW,8DAA8D,KAAK;AACpF,IAAM,UAAU,kEAAkE,KAAK;AAEvF,IAAM,SAAS,OAAO;AAAA,EACpB,MAAM,sEAAsE,QAAQ;AAAA,EACpF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,UAAU;AAAA,MACV,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,QAAQ;AAAA,MACN,MAAM;AAAA,IACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,SAAS;AAAA,MACP,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;AAoCM,IAAM,SAAS;AAAA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AA,UAC/C;AAAA,YAAC;AAAA;AAAA,cAGC,MAAM,SAAS,OAAO,OAAO;AAAA,cAC7B,QAAO;AAAA,cAIP,MAAM;AAAA,cACN,eAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,WACF,IAEA;AAAA;AAAA,IAEJ;AAGF,QAAI,YAAY,OAAW,QAAO;AAElC,WACE,iCACG;AAAA;AAAA,MAOD,oBAAC,UAAK,MAAK,UAAS,WAAU,WAAU,aAAU,iBAC/C,sBAAY,eAAe,IAC9B;AAAA,OACF;AAAA,EAEJ;AAAC;AAGD,SAAS,kBAAkB,OAAsC;AAC/D,QAAM,eAAe;AACvB;","names":["Button"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Button.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef } from 'react';\nimport type { Ref } from 'react';\nimport type {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport { recipe } from '../lib/recipe';\nimport { Spinner } from './Spinner';\n\nexport interface ButtonOwnProps {\n /**\n * The label. Written in caps at the call site rather than upper-cased in\n * CSS, so a screen reader is given the words rather than the shouting, and\n * so an acronym that is already caps does not read as emphasis.\n */\n children: ReactNode;\n /**\n * `primary`, `secondary` and `tertiary` use the corresponding accent role,\n * which changes with the theme level. `inverse` uses the primary content\n * role as its background for maximum contrast. `default` is identical to\n * `primary`. Omitted, the variant is `tertiary`.\n */\n variant?: ButtonVariant;\n /**\n * Padding and type scale, not a semantic weight. `md` is the default and the\n * one to reach for; `sm` is for dense rows such as a table's row actions,\n * and `lg` for a page's single primary action. Hit area is the constraint\n * that decides — `sm` is still 44px tall at the `web` Medium.\n */\n size?: 'sm' | 'md' | 'lg';\n /**\n * Wraps the label in `[ ]`. The brutalist cue for \"this one does something\"\n * — worth it for a form's submit or a destructive confirm, noise on every\n * button in a toolbar. It is punctuation in the label, not a border.\n */\n bracketed?: boolean;\n /**\n * Merged into the recipe's own classes. Reach for it to place the button —\n * `w-full`, a grid slot — rather than to restyle it; a colour set here is\n * what `pnpm check:tokens` exists to find.\n */\n className?: string;\n}\n\n/**\n * The accents a filled Button may take.\n *\n * Narrower than `AccentToken` on purpose: `quiet` is missing because\n * `check:contrast` gates `text.inverse` against `accent.primary`, `secondary`\n * and `tertiary` only. A quiet fill with inverse text on it is not measured, so\n * it is not offered.\n */\nexport type ButtonVariant =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'inverse'\n | 'default';\n\n/**\n * The `<button>` form. `href?: never` is what makes the union below\n * discriminate: without it TypeScript would accept `href` here and silently\n * drop it onto an element that ignores it.\n */\nexport type ButtonElementProps = ButtonOwnProps &\n DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> & {\n href?: never;\n /**\n * The request this button started is in flight. Reach for it instead of\n * `disabled` while a submit is being sent.\n *\n * `disabled` removes a focused button from the tab order and drops focus\n * to `<body>`, so a keyboard user is thrown back to the top of the page\n * at the moment they need to hear what happened. A pending button keeps\n * focus and its tab stop, reports `aria-disabled=\"true\"` instead of the\n * `disabled` attribute, and ignores activation: a click, Enter, Space,\n * or Enter in one of its form's fields does not run `onClick` and does\n * not submit the form again.\n *\n * It shows a spinner in place of the label, over the label's own box, so\n * the button keeps its width; the label stays in the accessibility tree,\n * so the accessible name does not change while it has focus. The fill is\n * kept and the button sits sunk into its press — the same offset and no\n * shadow as `:active` — which is distinct from the sunken, muted\n * `disabled` treatment.\n *\n * Pass it from the first render — `pending={saving}`, not\n * `pending={saving || undefined}` — so the live region that announces\n * `pendingLabel` is in the page before it has anything to say. `disabled`\n * wins over `pending` when both are set.\n */\n pending?: boolean;\n /**\n * What is being waited for, as a screen reader hears it when `pending`\n * turns on — \"Signing in\", not \"Loading\". It is written into a visually\n * hidden `role=\"status\"` region beside the button, which exists whenever\n * `pending` is passed at all and is empty until it is `true`.\n */\n pendingLabel?: string;\n };\n\n/** The `<a>` form. Passing `href` selects it; there is no `as` prop to remember. */\nexport type ButtonLinkProps = ButtonOwnProps &\n DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> & {\n /**\n * Where it navigates — and the discriminant. Supplying it renders an `<a>`\n * wearing the button's styling, which is what a keyboard user, a screen\n * reader and a middle click all need from something that navigates. Omit\n * it for anything that acts on the current page.\n */\n href: string;\n /**\n * Not offered on the anchor form. A link's work is the browser's\n * navigation, which the page cannot hold open, and `aria-disabled` on a\n * link is a link that still navigates. A control that starts a request\n * is a `<button>`.\n */\n pending?: never;\n /** Not offered on the anchor form; see `pending`. */\n pendingLabel?: never;\n };\n\nexport type ButtonProps = ButtonElementProps | ButtonLinkProps;\n\n/**\n * The press affordance — offset shadow that collapses as the control moves into\n * it. Shared rather than repeated so the four accents cannot drift apart.\n *\n * Hover and press are gated on `not-disabled:` so a disabled button does not\n * lift under the pointer or sink when clicked: it would be promising an action\n * it will not take. `not-disabled` rather than `enabled`, because `:enabled`\n * matches form elements only and the anchor form would lose its hover.\n *\n * `not-aria-disabled:` is the same gate for a pending button, which is\n * `aria-disabled` rather than `:disabled` so that it keeps focus. Spelled out\n * in full rather than built from a constant: Tailwind reads the source text,\n * and a template literal emits no CSS.\n */\nconst PRESS =\n 'shadow-hard-md not-disabled:not-aria-disabled:hover:shadow-hard-lg ' +\n 'not-disabled:not-aria-disabled:active:translate-x-1 ' +\n 'not-disabled:not-aria-disabled:active:translate-y-1 ' +\n 'not-disabled:not-aria-disabled:active:shadow-none';\n\n/**\n * The disabled treatment, the one `Select`'s trigger and the text fields wear:\n * a sunken ground, the subtle edge, muted ink and no shadow. Before #252 a\n * disabled button rendered exactly like an enabled one — it looked pressable\n * and did nothing. A request in flight is `pending`, not this. `disabled:`\n * matches the `<button>` form only, which is right: an anchor cannot be\n * disabled.\n */\nconst DISABLED =\n 'disabled:cursor-not-allowed disabled:border-edge-subtle disabled:bg-surface-sunken ' +\n 'disabled:text-content-muted disabled:shadow-none';\n\n/**\n * One constant per rendered form, aliased by every name that resolves to it.\n *\n * `default` and `primary` share the same constant and render identically.\n */\nconst PRIMARY = `bg-accent-primary text-content-inverse border-edge-strong ${PRESS}`;\nconst SECONDARY = `bg-accent-secondary text-content-inverse border-edge-strong ${PRESS}`;\nconst TERTIARY = `bg-accent-tertiary text-content-inverse border-edge-strong ${PRESS}`;\nconst INVERSE = `bg-content-primary text-content-inverse border-content-primary ${PRESS}`;\n\nconst button = recipe({\n base: `font-mono font-bold uppercase border-2 transition-all duration-200 ${DISABLED}`,\n variants: {\n size: {\n sm: 'px-4 py-2 text-sm',\n md: 'px-6 py-3 text-base',\n lg: 'px-8 py-4 text-lg',\n },\n variant: {\n primary: PRIMARY,\n secondary: SECONDARY,\n tertiary: TERTIARY,\n inverse: INVERSE,\n default: PRIMARY,\n },\n /**\n * An anchor is not `inline-flex` by default and carries an underline, so the\n * two forms would otherwise lay out and read differently from identical\n * props. A variant rather than a prepended string so a caller's own\n * `className` still resolves against it.\n */\n asLink: {\n true: 'inline-flex items-center justify-center no-underline',\n },\n /**\n * Held in its press: the `:active` offset with the shadow gone, over the\n * variant's own fill. Enabled is raised, disabled is sunken and muted, and\n * pending is the one in between — this button was pressed and has not let\n * go. `relative` is the box the spinner is centred in.\n */\n pending: {\n true: 'relative cursor-progress translate-x-1 translate-y-1 shadow-none',\n },\n },\n defaultVariants: {\n variant: 'tertiary',\n size: 'md',\n },\n});\n\n/**\n * A button, or a link that looks like one.\n *\n * The distinction is not cosmetic and is not the caller's styling preference:\n * a control that *navigates* must be an `<a>`, or it loses middle-click,\n * open-in-new-tab, the status-bar URL preview, and its announcement as a link\n * to a screen reader. Marketing CTAs are overwhelmingly navigation — \"Get\n * started\" goes somewhere — so a button-only component pushes every landing\n * page into either nesting an anchor inside a button (invalid HTML) or\n * re-styling the whole thing by hand.\n *\n * Passing `href` selects the anchor form, and TypeScript then offers anchor\n * attributes (`target`, `rel`, `download`) and withdraws button-only ones\n * (`disabled`, `type`) — the latter being the point, since `disabled` does\n * nothing whatsoever on an anchor.\n *\n * ```tsx\n * <Button onClick={save}>SAVE</Button>\n * <Button href=\"/pricing\" variant=\"tertiary\" bracketed size=\"lg\">SEE PRICING</Button>\n * ```\n */\n/**\n * Forwards its ref to whichever element it renders.\n *\n * `ButtonProps` is a union, so the ref's type is the union of both targets —\n * `HTMLButtonElement | HTMLAnchorElement`. A caller who knows which form they\n * asked for can narrow it; one who does not is told the truth, which is that it\n * depends on `href`.\n *\n * This is what `<Tooltip.Trigger render={<Button />} />` needs: Base UI's\n * composition merges props *and a ref* onto the element it is given, and a\n * component that drops the ref silently breaks positioning, focus return and\n * outside-click detection in every primitive that wraps it.\n */\nexport const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n function Button(props, ref) {\n const {\n children,\n variant = 'tertiary',\n size = 'md',\n bracketed = false,\n className,\n ...rest\n } = props;\n\n const label = bracketed ? (\n <span className=\"inline-flex items-center justify-center gap-2\">\n <span className=\"select-none\" aria-hidden=\"true\">\n [\n </span>\n <span className=\"inline-flex items-center gap-2\">{children}</span>\n <span className=\"select-none\" aria-hidden=\"true\">\n ]\n </span>\n </span>\n ) : (\n <span className=\"inline-flex items-center justify-center gap-2\">{children}</span>\n );\n\n if (typeof props.href === 'string') {\n // `pending` is `never` here; taken out so a stray `undefined` is not spread.\n const {\n pending: _pending,\n pendingLabel: _pendingLabel,\n ...anchorProps\n } = rest as Omit<ButtonLinkProps, keyof ButtonOwnProps>;\n return (\n <a data-slot=\"button\"\n ref={ref as Ref<HTMLAnchorElement>}\n {...anchorProps}\n // A `target=\"_blank\"` document can reach back through `window.opener`\n // unless told otherwise. Modern browsers imply `noopener`, but not\n // every renderer this package ships into is a modern browser, and an\n // explicit `rel` costs nothing. An explicit `rel` from the caller wins.\n rel={\n anchorProps.rel ??\n (anchorProps.target === '_blank' ? 'noopener noreferrer' : undefined)\n }\n className={button({ variant, size, asLink: true, class: className })}\n >\n {label}\n </a>\n );\n }\n\n const {\n pending,\n pendingLabel = 'Working',\n ...buttonProps\n } = rest as Omit<ButtonElementProps, keyof ButtonOwnProps>;\n const isPending = pending === true && !buttonProps.disabled;\n\n const element = (\n <button data-slot=\"button\"\n ref={ref as Ref<HTMLButtonElement>}\n {...buttonProps}\n // The `disabled` attribute is what drops focus, so a pending button says\n // it is unavailable through ARIA and refuses activation here instead.\n // Enter and Space on a focused button, and Enter in a text field of its\n // form (implicit submission), all reach a button as a `click`; cancelling\n // it cancels the submit it would have sent. Base UI's Button does the\n // same under `focusableWhenDisabled`.\n aria-disabled={isPending ? true : buttonProps['aria-disabled']}\n onClick={isPending ? preventActivation : buttonProps.onClick}\n data-pending={isPending ? '' : undefined}\n className={button({ variant, size, pending: isPending, class: className })}\n >\n {isPending ? (\n <>\n {/* Transparent, not removed: it holds the width and the name. */}\n <span className=\"inline-flex opacity-0\">{label}</span>\n <Spinner\n // Sized to the label's line box: `sm` in a small button, `md` —\n // about a capital's height and a half — in the others.\n size={size === 'sm' ? 'sm' : 'md'}\n accent=\"current\"\n // The status region beside the button announces the wait. This is\n // the drawing only; a second live region inside a button, whose\n // children are presentational, would be read unreliably or twice.\n role={undefined}\n aria-hidden=\"true\"\n className=\"absolute inset-0\"\n />\n </>\n ) : (\n label\n )}\n </button>\n );\n\n if (pending === undefined) return element;\n\n return (\n <>\n {element}\n {/*\n * Outside the button because a button's children are presentational: a\n * live region inside one is flattened into its name. Present from the\n * first render and filled only while pending, which is what makes the\n * insertion an announcement rather than a region appearing already full.\n */}\n <span role=\"status\" className=\"sr-only\" data-slot=\"button-status\">\n {isPending ? pendingLabel : ''}\n </span>\n </>\n );\n});\n\n/** A pending button's click: cancelled, so neither `onClick` nor a submit runs. */\nfunction preventActivation(event: MouseEvent<HTMLButtonElement>) {\n event.preventDefault();\n}\n"],"mappings":";;;AAEA,SAAS,kBAAkB;AAS3B,SAAS,cAAc;AACvB,SAAS,eAAe;AAqPpB,SA8DI,UA7DF,KADF;AAlHJ,IAAM,QACJ;AAaF,IAAM,WACJ;AAQ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UAAE,aAAU;AAAA,UACX;AAAA,UACC,GAAG;AAAA,UAKJ,KACE,YAAY,QACX,YAAY,WAAW,WAAW,wBAAwB;AAAA,UAE7D,WAAW,OAAO,EAAE,SAAS,MAAM,QAAQ,MAAM,OAAO,UAAU,CAAC;AAAA,UAElE;AAAA;AAAA,MACH;AAAA,IAEJ;AAEA,UAAM;AAAA,MACJ;AAAA,MACA,eAAe;AAAA,MACf,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,YAAY,YAAY,QAAQ,CAAC,YAAY;AAEnD,UAAM,UACJ;AAAA,MAAC;AAAA;AAAA,QAAO,aAAU;AAAA,QAChB;AAAA,QACC,GAAG;AAAA,QAOJ,iBAAe,YAAY,OAAO,YAAY,eAAe;AAAA,QAC7D,SAAS,YAAY,oBAAoB,YAAY;AAAA,QACrD,gBAAc,YAAY,KAAK;AAAA,QAC/B,WAAW,OAAO,EAAE,SAAS,MAAM,SAAS,WAAW,OAAO,UAAU,CAAC;AAAA,QAExE,sBACC,iCAEE;AAAA,8BAAC,UAAK,WAAU,yBAAyB,iBAAM;AAAA,UAC/C;AAAA,YAAC;AAAA;AAAA,cAGC,MAAM,SAAS,OAAO,OAAO;AAAA,cAC7B,QAAO;AAAA,cAIP,MAAM;AAAA,cACN,eAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,WACF,IAEA;AAAA;AAAA,IAEJ;AAGF,QAAI,YAAY,OAAW,QAAO;AAElC,WACE,iCACG;AAAA;AAAA,MAOD,oBAAC,UAAK,MAAK,UAAS,WAAU,WAAU,aAAU,iBAC/C,sBAAY,eAAe,IAC9B;AAAA,OACF;AAAA,EAEJ;AAAC;AAGD,SAAS,kBAAkB,OAAsC;AAC/D,QAAM,eAAe;AACvB;","names":["Button"]}
|
package/dist/components/Card.js
CHANGED
|
@@ -16,6 +16,7 @@ var Card = forwardRef(function Card2({
|
|
|
16
16
|
badge,
|
|
17
17
|
panel = false,
|
|
18
18
|
variant,
|
|
19
|
+
weight = "strong",
|
|
19
20
|
style,
|
|
20
21
|
...props
|
|
21
22
|
}, ref) {
|
|
@@ -24,7 +25,7 @@ var Card = forwardRef(function Card2({
|
|
|
24
25
|
const baseCardStyle = {
|
|
25
26
|
backgroundColor: semanticTokens.surface.base,
|
|
26
27
|
color: semanticTokens.text.primary,
|
|
27
|
-
border: `2px solid ${semanticTokens.border.strong}`,
|
|
28
|
+
border: weight === "quiet" ? `1px solid ${semanticTokens.border.default}` : `2px solid ${semanticTokens.border.strong}`,
|
|
28
29
|
transition: "transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease",
|
|
29
30
|
...accentColor ? { borderLeftWidth: "4px", borderLeftColor: accentColor } : {},
|
|
30
31
|
...style
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Card.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport type { ReactNode, HTMLAttributes, CSSProperties } from 'react';\nimport { cn } from '../lib/recipe';\nimport { accentVar, semanticTokens } from '../lib/theme';\nimport type { AccentToken } from '../lib/theme';\n\n\n/**\n * The two shapes a `Card` renders.\n *\n * `panel` is the general container — border, padding, optional accent stripe.\n * `card` is the blog/project card: a filename bar, an optional cover image and\n * a `[ Learn More → ]` footer, carrying its own width and float classes.\n */\nexport type CardVariant = 'panel' | 'card';\n\nexport interface CardProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Card heading. With no `variant` set, its presence is also what selects the\n * full card form over the panel form — see the note on `variant`.\n */\n title?: string;\n /**\n * The standfirst under the title — one or two sentences saying what the card\n * is about. Longer body copy belongs in `children`, which is not constrained\n * to a paragraph.\n */\n description?: string;\n /**\n * A cover image above the card's text. Mutually exclusive with `asciiArt` in\n * practice rather than in types: both occupy the same slot, and a card given\n * both shows the image.\n */\n imgSrc?: string;\n /**\n * Turns the card into a link to here, rendered as a trailing affordance\n * rather than by wrapping the whole card — so the title stays selectable and\n * nested controls keep their own click targets.\n */\n href?: string;\n /**\n * Monospace art rendered in place of an image. The reason the mono face is\n * latin-only by deliberate choice: box-drawing characters must land on the\n * same advance width or the art shears.\n */\n asciiArt?: string;\n /**\n * Shown in the card's header strip as a file name would be in an editor\n * tab. A label for the card's provenance, not a download.\n */\n filename?: string;\n /**\n * The card's body. Whatever `title` and `description` cannot say — a list, a\n * chart, controls. With no `title` and no `variant`, supplying this is what\n * selects the panel form; see the note on `variant`.\n */\n children?: ReactNode;\n /**\n * Merged into the recipe's classes. For placement and span — a grid cell, a\n * width — rather than for restyling the surface.\n */\n className?: string;\n /** Semantic accent for the left border highlight. */\n accent?: AccentToken;\n /** Badge text shown in the card header */\n badge?: string;\n /**\n * Render the plain panel.\n *\n * @deprecated Use `variant=\"panel\"`. This is kept because it is what existing\n * call sites pass, and `variant` takes precedence over it.\n */\n panel?: boolean;\n /**\n * Which of the component's two forms to render.\n *\n * Setting it is the whole point: with `variant` omitted the form is\n * *inferred* — panel when there is no `title`, full card otherwise — so a\n * panel that later gains a title silently becomes a floated blog card with a\n * filename bar. Nothing in the diff that adds the title says so.\n *\n * Omitting it keeps that inference exactly as it was, for the call sites that\n * already rely on it. New code should say which form it wants.\n */\n variant?: CardVariant;\n}\n\n/**\n * A bordered container, in two forms.\n *\n * **`variant=\"panel\"`** is the general one: border, 1.5rem of padding, an\n * optional accent stripe down the left edge, and whatever you put in it. Reach\n * for this unless you specifically want the other.\n *\n * **`variant=\"card\"`** is the blog/project card — a filename bar across the top\n * reading `some_title.md`, an optional cover image, then title, description and\n * a `[ Learn More → ]` link. It is opinionated on purpose and carries its own\n * width and float classes, so it belongs in a card grid rather than as a\n * general-purpose box.\n *\n * **Say which one you want.** With `variant` omitted the form is inferred from\n * whether a `title` is present, which means adding a title to a panel silently\n * turns it into a floated blog card. The inference is kept for the call sites\n * that predate `variant`; new code should not rely on it.\n *\n * The accent is a *stripe*, not a fill: `accent` thickens the left border to\n * 4px and colours it. That is the whole colour budget of the component, which\n * is why a card conveys category rather than status.\n *\n * ```tsx\n * <Card variant=\"panel\" accent=\"info\" badge=\"DRAFT\">\n * <p>Anything.</p>\n * </Card>\n *\n * <Card variant=\"card\" title=\"Where a theme stops applying\" href=\"/posts/theme\" />\n * ```\n */\nexport const Card = forwardRef<HTMLDivElement, CardProps>(function Card({\n title,\n description,\n imgSrc,\n href,\n asciiArt,\n filename,\n children,\n className = '',\n accent,\n badge,\n panel = false,\n variant,\n style,\n ...props\n}, ref) {\n const accentColor = accent ? accentVar(accent) : undefined;\n\n /**\n * An explicit `variant` decides; otherwise fall back to the historical\n * inference, unchanged, so nothing that renders today renders differently.\n *\n * Written as one resolved value rather than left inline in the branch below,\n * because the inference is the part worth being able to point at — and worth\n * being able to delete in one place when it goes in a major.\n */\n const form: CardVariant = variant ?? (panel || (!title && children) ? 'panel' : 'card');\n\n const baseCardStyle: CSSProperties = {\n backgroundColor: semanticTokens.surface.base,\n color: semanticTokens.text.primary,\n border: `2px solid ${semanticTokens.border.strong}`,\n transition: 'transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease',\n ...(accentColor ? { borderLeftWidth: '4px', borderLeftColor: accentColor } : {}),\n ...style,\n };\n\n // Simple panel mode: no filename header, no width constraints\n if (form === 'panel') {\n return (\n <div data-slot=\"card\"\n ref={ref}\n className={cn(className)}\n style={{ ...baseCardStyle, padding: '1.5rem' }}\n {...props}\n >\n {badge && (\n <span\n style={{\n display: 'inline-block',\n padding: '0.15rem 0.5rem',\n fontSize: '0.65rem',\n fontFamily: semanticTokens.font.mono,\n fontWeight: 700,\n textTransform: 'uppercase',\n color: 'var(--ds-text-inverse)',\n backgroundColor: accentColor ?? semanticTokens.accent.tertiary,\n marginBottom: '0.75rem',\n }}\n >\n {badge}\n </span>\n )}\n {title && (\n <h3\n style={{\n fontFamily: semanticTokens.font.display,\n fontSize: '1.1rem',\n fontWeight: 800,\n textTransform: 'uppercase',\n color: accentColor || semanticTokens.text.primary,\n marginBottom: '0.75rem',\n letterSpacing: '0.025em',\n }}\n >\n {title}\n </h3>\n )}\n {description && (\n <p style={{ fontFamily: semanticTokens.font.mono, fontSize: '0.85rem', color: semanticTokens.text.primary, opacity: 0.9, lineHeight: 1.6 }}>\n {description}\n </p>\n )}\n {children}\n </div>\n );\n }\n\n // Full card mode with filename header bar (blog/project card style)\n const computedFilename = filename || (title ? `${title.toLowerCase().replace(/\\s+/g, '_')}.md` : 'card.md');\n\n return (\n <div data-slot=\"card\" ref={ref} className={cn('p-4 md:w-1/2', className)} style={{ maxWidth: '544px' }} {...props}>\n <div\n style={{\n height: '100%',\n ...baseCardStyle,\n }}\n >\n <div\n style={{\n borderBottom: `2px solid ${semanticTokens.border.strong}`,\n padding: '0.5rem 1rem',\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n backgroundColor: semanticTokens.surface.base,\n }}\n >\n <span\n style={{\n fontFamily: semanticTokens.font.mono,\n fontSize: '0.85rem',\n color: semanticTokens.accent.secondary,\n fontWeight: 700,\n textTransform: 'uppercase',\n // A file name is one unbreakable token: in a narrow card it must wrap inside the\n // header strip, not run out past the card border.\n minWidth: 0,\n overflowWrap: 'anywhere',\n }}\n >\n {computedFilename}\n </span>\n {asciiArt && (\n <pre style={{ fontSize: '0.7rem', color: semanticTokens.accent.primary, lineHeight: 1 }}>\n {asciiArt}\n </pre>\n )}\n </div>\n\n {imgSrc && (\n <div style={{ borderBottom: `2px solid ${semanticTokens.border.strong}` }}>\n {href ? (\n <a href={href} aria-label={`Link to ${title || 'card'}`}>\n <img\n alt={title || 'Card Image'}\n src={imgSrc}\n style={{ objectFit: 'cover', objectPosition: 'center', width: '100%', maxHeight: '192px' }}\n />\n </a>\n ) : (\n <img\n alt={title || 'Card Image'}\n src={imgSrc}\n style={{ objectFit: 'cover', objectPosition: 'center', width: '100%', maxHeight: '192px' }}\n />\n )}\n </div>\n )}\n\n <div style={{ padding: '1.5rem' }}>\n {title && (\n <h2\n style={{\n marginBottom: '0.75rem',\n fontSize: '1.5rem',\n fontFamily: semanticTokens.font.display,\n fontWeight: 700,\n lineHeight: 1.3,\n letterSpacing: '-0.01em',\n textTransform: 'uppercase',\n color: semanticTokens.text.primary,\n }}\n >\n {href ? (\n <a href={href} aria-label={`Link to ${title}`} style={{ color: 'inherit', textDecoration: 'none' }}>\n {title}\n </a>\n ) : (\n title\n )}\n </h2>\n )}\n {description && (\n <p style={{ marginBottom: '0.75rem', fontFamily: semanticTokens.font.body, fontSize: '0.9rem', color: semanticTokens.text.primary, opacity: 0.7, lineHeight: 1.6 }}>\n {description}\n </p>\n )}\n {children}\n {href && (\n <a\n href={href}\n style={{\n fontFamily: semanticTokens.font.mono,\n fontWeight: 700,\n color: semanticTokens.accent.primary,\n textDecoration: 'none',\n textTransform: 'uppercase',\n display: 'inline-block',\n transition: 'transform 0.15s ease',\n }}\n aria-label={`Link to ${title || 'details'}`}\n >\n [ Learn More → ]\n </a>\n )}\n </div>\n </div>\n </div>\n );\n});\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,UAAU;AACnB,SAAS,WAAW,sBAAsB;AA0JpC,SAOI,KAPJ;AAxCC,IAAM,OAAO,WAAsC,SAASA,MAAK;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,cAAc,SAAS,UAAU,MAAM,IAAI;AAUjD,QAAM,OAAoB,YAAY,SAAU,CAAC,SAAS,WAAY,UAAU;AAEhF,QAAM,gBAA+B;AAAA,IACnC,iBAAiB,eAAe,QAAQ;AAAA,IACxC,OAAO,eAAe,KAAK;AAAA,IAC3B,QAAQ,aAAa,eAAe,OAAO,MAAM;AAAA,IACjD,YAAY;AAAA,IACZ,GAAI,cAAc,EAAE,iBAAiB,OAAO,iBAAiB,YAAY,IAAI,CAAC;AAAA,IAC9E,GAAG;AAAA,EACL;AAGA,MAAI,SAAS,SAA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AA,gBACZ,eAAe;AAAA,gBACf,eAAe;AAAA,gBACf,OAAO,eAAe,KAAK;AAAA,cAC7B;AAAA,cAEC,iBACC,oBAAC,OAAE,MAAY,cAAY,WAAW,KAAK,IAAI,OAAO,EAAE,OAAO,WAAW,gBAAgB,OAAO,GAC9F,iBACH,IAEA;AAAA;AAAA,UAEJ;AAAA,UAED,eACC,oBAAC,OAAE,OAAO,EAAE,cAAc,WAAW,YAAY,eAAe,KAAK,MAAM,UAAU,UAAU,OAAO,eAAe,KAAK,SAAS,SAAS,KAAK,YAAY,IAAI,GAC9J,uBACH;AAAA,UAED;AAAA,UACA,QACC;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,OAAO;AAAA,gBACL,YAAY,eAAe,KAAK;AAAA,gBAChC,YAAY;AAAA,gBACZ,OAAO,eAAe,OAAO;AAAA,gBAC7B,gBAAgB;AAAA,gBAChB,eAAe;AAAA,gBACf,SAAS;AAAA,gBACT,YAAY;AAAA,cACd;AAAA,cACA,cAAY,WAAW,SAAS,SAAS;AAAA,cAC1C;AAAA;AAAA,UAED;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;","names":["Card"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Card.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport type { ReactNode, HTMLAttributes, CSSProperties } from 'react';\nimport { cn } from '../lib/recipe';\nimport { accentVar, semanticTokens } from '../lib/theme';\nimport type { AccentToken } from '../lib/theme';\n\n\n/**\n * The two shapes a `Card` renders.\n *\n * `panel` is the general container — border, padding, optional accent stripe.\n * `card` is the blog/project card: a filename bar, an optional cover image and\n * a `[ Learn More → ]` footer, carrying its own width and float classes.\n */\nexport type CardVariant = 'panel' | 'card';\n\n/**\n * How heavily the card is drawn. `strong` is the brand's 2px `border.strong` box. `quiet` is a\n * 1px `border.default` frame, for a card that sits beside or inside other boxes and should not\n * compete with the one that matters — see `docs/edge-hierarchy.md`. The accent stripe is kept.\n */\nexport type CardWeight = 'strong' | 'quiet';\n\nexport interface CardProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Card heading. With no `variant` set, its presence is also what selects the\n * full card form over the panel form — see the note on `variant`.\n */\n title?: string;\n /**\n * The standfirst under the title — one or two sentences saying what the card\n * is about. Longer body copy belongs in `children`, which is not constrained\n * to a paragraph.\n */\n description?: string;\n /**\n * A cover image above the card's text. Mutually exclusive with `asciiArt` in\n * practice rather than in types: both occupy the same slot, and a card given\n * both shows the image.\n */\n imgSrc?: string;\n /**\n * Turns the card into a link to here, rendered as a trailing affordance\n * rather than by wrapping the whole card — so the title stays selectable and\n * nested controls keep their own click targets.\n */\n href?: string;\n /**\n * Monospace art rendered in place of an image. The reason the mono face is\n * latin-only by deliberate choice: box-drawing characters must land on the\n * same advance width or the art shears.\n */\n asciiArt?: string;\n /**\n * Shown in the card's header strip as a file name would be in an editor\n * tab. A label for the card's provenance, not a download.\n */\n filename?: string;\n /**\n * The card's body. Whatever `title` and `description` cannot say — a list, a\n * chart, controls. With no `title` and no `variant`, supplying this is what\n * selects the panel form; see the note on `variant`.\n */\n children?: ReactNode;\n /**\n * Merged into the recipe's classes. For placement and span — a grid cell, a\n * width — rather than for restyling the surface.\n */\n className?: string;\n /** Semantic accent for the left border highlight. */\n accent?: AccentToken;\n /** Badge text shown in the card header */\n badge?: string;\n /**\n * Render the plain panel.\n *\n * @deprecated Use `variant=\"panel\"`. This is kept because it is what existing\n * call sites pass, and `variant` takes precedence over it.\n */\n panel?: boolean;\n /**\n * Which of the component's two forms to render.\n *\n * Setting it is the whole point: with `variant` omitted the form is\n * *inferred* — panel when there is no `title`, full card otherwise — so a\n * panel that later gains a title silently becomes a floated blog card with a\n * filename bar. Nothing in the diff that adds the title says so.\n *\n * Omitting it keeps that inference exactly as it was, for the call sites that\n * already rely on it. New code should say which form it wants.\n */\n variant?: CardVariant;\n /** `strong` by default. `quiet` draws a 1px `border.default` frame and keeps the accent stripe. */\n weight?: CardWeight;\n}\n\n/**\n * A bordered container, in two forms.\n *\n * **`variant=\"panel\"`** is the general one: border, 1.5rem of padding, an\n * optional accent stripe down the left edge, and whatever you put in it. Reach\n * for this unless you specifically want the other.\n *\n * **`variant=\"card\"`** is the blog/project card — a filename bar across the top\n * reading `some_title.md`, an optional cover image, then title, description and\n * a `[ Learn More → ]` link. It is opinionated on purpose and carries its own\n * width and float classes, so it belongs in a card grid rather than as a\n * general-purpose box.\n *\n * **Say which one you want.** With `variant` omitted the form is inferred from\n * whether a `title` is present, which means adding a title to a panel silently\n * turns it into a floated blog card. The inference is kept for the call sites\n * that predate `variant`; new code should not rely on it.\n *\n * The accent is a *stripe*, not a fill: `accent` thickens the left border to\n * 4px and colours it. That is the whole colour budget of the component, which\n * is why a card conveys category rather than status.\n *\n * ```tsx\n * <Card variant=\"panel\" accent=\"info\" badge=\"DRAFT\">\n * <p>Anything.</p>\n * </Card>\n *\n * <Card variant=\"card\" title=\"Where a theme stops applying\" href=\"/posts/theme\" />\n * ```\n */\nexport const Card = forwardRef<HTMLDivElement, CardProps>(function Card({\n title,\n description,\n imgSrc,\n href,\n asciiArt,\n filename,\n children,\n className = '',\n accent,\n badge,\n panel = false,\n variant,\n weight = 'strong',\n style,\n ...props\n}, ref) {\n const accentColor = accent ? accentVar(accent) : undefined;\n\n /**\n * An explicit `variant` decides; otherwise fall back to the historical\n * inference, unchanged, so nothing that renders today renders differently.\n *\n * Written as one resolved value rather than left inline in the branch below,\n * because the inference is the part worth being able to point at — and worth\n * being able to delete in one place when it goes in a major.\n */\n const form: CardVariant = variant ?? (panel || (!title && children) ? 'panel' : 'card');\n\n const baseCardStyle: CSSProperties = {\n backgroundColor: semanticTokens.surface.base,\n color: semanticTokens.text.primary,\n border: weight === 'quiet' ? `1px solid ${semanticTokens.border.default}` : `2px solid ${semanticTokens.border.strong}`,\n transition: 'transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease',\n ...(accentColor ? { borderLeftWidth: '4px', borderLeftColor: accentColor } : {}),\n ...style,\n };\n\n // Simple panel mode: no filename header, no width constraints\n if (form === 'panel') {\n return (\n <div data-slot=\"card\"\n ref={ref}\n className={cn(className)}\n style={{ ...baseCardStyle, padding: '1.5rem' }}\n {...props}\n >\n {badge && (\n <span\n style={{\n display: 'inline-block',\n padding: '0.15rem 0.5rem',\n fontSize: '0.65rem',\n fontFamily: semanticTokens.font.mono,\n fontWeight: 700,\n textTransform: 'uppercase',\n color: 'var(--ds-text-inverse)',\n backgroundColor: accentColor ?? semanticTokens.accent.tertiary,\n marginBottom: '0.75rem',\n }}\n >\n {badge}\n </span>\n )}\n {title && (\n <h3\n style={{\n fontFamily: semanticTokens.font.display,\n fontSize: '1.1rem',\n fontWeight: 800,\n textTransform: 'uppercase',\n color: accentColor || semanticTokens.text.primary,\n marginBottom: '0.75rem',\n letterSpacing: '0.025em',\n }}\n >\n {title}\n </h3>\n )}\n {description && (\n <p style={{ fontFamily: semanticTokens.font.mono, fontSize: '0.85rem', color: semanticTokens.text.primary, opacity: 0.9, lineHeight: 1.6 }}>\n {description}\n </p>\n )}\n {children}\n </div>\n );\n }\n\n // Full card mode with filename header bar (blog/project card style)\n const computedFilename = filename || (title ? `${title.toLowerCase().replace(/\\s+/g, '_')}.md` : 'card.md');\n\n return (\n <div data-slot=\"card\" ref={ref} className={cn('p-4 md:w-1/2', className)} style={{ maxWidth: '544px' }} {...props}>\n <div\n style={{\n height: '100%',\n ...baseCardStyle,\n }}\n >\n <div\n style={{\n borderBottom: `2px solid ${semanticTokens.border.strong}`,\n padding: '0.5rem 1rem',\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n backgroundColor: semanticTokens.surface.base,\n }}\n >\n <span\n style={{\n fontFamily: semanticTokens.font.mono,\n fontSize: '0.85rem',\n color: semanticTokens.accent.secondary,\n fontWeight: 700,\n textTransform: 'uppercase',\n // A file name is one unbreakable token: in a narrow card it must wrap inside the\n // header strip, not run out past the card border.\n minWidth: 0,\n overflowWrap: 'anywhere',\n }}\n >\n {computedFilename}\n </span>\n {asciiArt && (\n <pre style={{ fontSize: '0.7rem', color: semanticTokens.accent.primary, lineHeight: 1 }}>\n {asciiArt}\n </pre>\n )}\n </div>\n\n {imgSrc && (\n <div style={{ borderBottom: `2px solid ${semanticTokens.border.strong}` }}>\n {href ? (\n <a href={href} aria-label={`Link to ${title || 'card'}`}>\n <img\n alt={title || 'Card Image'}\n src={imgSrc}\n style={{ objectFit: 'cover', objectPosition: 'center', width: '100%', maxHeight: '192px' }}\n />\n </a>\n ) : (\n <img\n alt={title || 'Card Image'}\n src={imgSrc}\n style={{ objectFit: 'cover', objectPosition: 'center', width: '100%', maxHeight: '192px' }}\n />\n )}\n </div>\n )}\n\n <div style={{ padding: '1.5rem' }}>\n {title && (\n <h2\n style={{\n marginBottom: '0.75rem',\n fontSize: '1.5rem',\n fontFamily: semanticTokens.font.display,\n fontWeight: 700,\n lineHeight: 1.3,\n letterSpacing: '-0.01em',\n textTransform: 'uppercase',\n color: semanticTokens.text.primary,\n }}\n >\n {href ? (\n <a href={href} aria-label={`Link to ${title}`} style={{ color: 'inherit', textDecoration: 'none' }}>\n {title}\n </a>\n ) : (\n title\n )}\n </h2>\n )}\n {description && (\n <p style={{ marginBottom: '0.75rem', fontFamily: semanticTokens.font.body, fontSize: '0.9rem', color: semanticTokens.text.primary, opacity: 0.7, lineHeight: 1.6 }}>\n {description}\n </p>\n )}\n {children}\n {href && (\n <a\n href={href}\n style={{\n fontFamily: semanticTokens.font.mono,\n fontWeight: 700,\n color: semanticTokens.accent.primary,\n textDecoration: 'none',\n textTransform: 'uppercase',\n display: 'inline-block',\n transition: 'transform 0.15s ease',\n }}\n aria-label={`Link to ${title || 'details'}`}\n >\n [ Learn More → ]\n </a>\n )}\n </div>\n </div>\n </div>\n );\n});\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,UAAU;AACnB,SAAS,WAAW,sBAAsB;AAoKpC,SAOI,KAPJ;AAzCC,IAAM,OAAO,WAAsC,SAASA,MAA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A,cACA,cAAY,WAAW,SAAS,SAAS;AAAA,cAC1C;AAAA;AAAA,UAED;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;","names":["Card"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/DataTable.tsx"],"sourcesContent":["'use client';\n\nimport {\n flexRender,\n getCoreRowModel,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n type ColumnDef,\n type SortingState,\n type Table as TanStackTable,\n} from '@tanstack/react-table';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport {\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { cn } from '../lib/recipe';\nimport { Checkbox } from './Checkbox';\nimport { NerdIcon } from './NerdIcon';\nimport { Pagination } from './Pagination';\nimport {\n Table,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n type TableAppearance,\n type TableDensity,\n} from './Table';\nimport { Tooltip } from './Tooltip';\n\n// Legacy column interface for backwards-compatibility\nexport interface Column<T> {\n header: string;\n accessor: keyof T | ((row: T) => ReactNode);\n className?: string;\n enableSorting?: boolean;\n sortValue?: (row: T) => any;\n /**\n * The column that names each row — a hostname, a branch. Its body cells\n * render as `<th scope=\"row\">`, so a screen reader announces the row by it\n * while moving across. On a TanStack `ColumnDef`, set `meta.rowHeader`.\n */\n rowHeader?: boolean;\n}\n\ninterface DataTableColumnMeta {\n className?: string;\n rowHeader?: boolean;\n}\n\n// What a press on a sort button does, keyed by the column's next order so the\n// description cannot disagree with the click.\nconst SORT_HINT = { asc: 'Sort ascending', desc: 'Sort descending' } as const;\n\n// A stable default, so an unselected table does not build a new Set per render.\nconst EMPTY_KEYS: ReadonlySet<string> = new Set();\n\n/** Virtualization geometry is runtime arithmetic; hoisted objects (the\n * `ATTACHED_STYLE` convention from CodeBlock) keep it off the inline-style\n * sites the contract counts. */\nconst SPACER_STYLE_BASE = { padding: 0, border: 0 } as const;\nfunction spacerStyle(height: number) {\n return { height, ...SPACER_STYLE_BASE };\n}\nfunction scrollBoxStyle(height: number) {\n return { height };\n}\n\n/**\n * Row virtualization is planned against a fixed row height rather than measured\n * rows: deterministic rendering is a contract here (docs/deterministic-rendering.md),\n * and a measured engine would make the snapshot of a 10k-row table depend on font\n * loading. Multi-line cell content is therefore clipped to `rowHeight`.\n */\nexport interface DataTableVirtualization {\n /**\n * Viewport height, in px, of the scroll box the table builds for itself.\n * Ignored when `scrollElementRef` is provided. Defaults to 480.\n */\n height?: number;\n /** Fixed row height, in px, the virtualizer plans against. Defaults to 44. */\n rowHeight?: number;\n /** Rows rendered beyond each edge of the viewport. Defaults to 8. */\n overscan?: number;\n /**\n * Scroll inside an existing scrollable element instead of building one. When\n * provided, no wrapper is rendered and this element owns both axes — and it\n * must be keyboard-reachable itself (`tabIndex={0}`), or the window cannot be\n * scrolled without a mouse.\n */\n scrollElementRef?: RefObject<HTMLElement | null>;\n}\n\ntype DataTableSharedProps<T> = {\n /**\n * `grid` keeps the framed default, `quiet` removes the full cell grid, and\n * `index` adds a keyline to row headers for catalog-style scanning.\n */\n appearance?: TableAppearance;\n /**\n * `comfortable` preserves the existing cell spacing. `compact` reduces it\n * for reference tables with many rows.\n */\n density?: TableDensity;\n /**\n * `index` is the row's position in `data`, not on screen, so a key built\n * from it follows its row through a sort rather than staying with the slot.\n */\n keyExtractor?: (row: T, index: number) => string | number;\n /**\n * What the table is a table of. Rendered as the `<caption>`, which is the\n * table's accessible name; a string caption also names the scroll regions.\n */\n caption?: ReactNode;\n emptyText?: string;\n className?: string;\n containerClassName?: string;\n /**\n * Window the body to the visible rows so a dataset of thousands renders as\n * many rows as fit, not as many as exist. `true` uses the defaults;\n * mutually exclusive with `pageSize`, which wins nothing — pagination is\n * simply not attached while virtualizing. The table still reports the whole\n * dataset to assistive tech, through `aria-rowcount` and `aria-rowindex`.\n */\n virtualize?: boolean | DataTableVirtualization;\n /**\n * The keys of the selected rows, as `keyExtractor` produces them (numbers\n * are compared as strings). Controlled: the table never changes it, it\n * reports the next set through `onSelectionChange`. Because selection is\n * keyed rather than positional it survives a sort, a page change and a\n * windowed scroll. Without a `keyExtractor` the key is TanStack's row id,\n * which is the row's index in `data` and does not follow a row when\n * `data` changes — pass one.\n */\n selectedKeys?: ReadonlySet<string>;\n /**\n * Turns selection on: a leading column of checkboxes, one per row, and one\n * in the header. Called with the whole next selection on every toggle.\n * The set it reports holds only keys of rows that are still in the data\n * and still selectable, so a key whose row has gone, or has become\n * unselectable, drops out on the next change rather than lingering.\n */\n onSelectionChange?: (keys: Set<string>) => void;\n /**\n * Whether a row may be selected. `false` disables its checkbox; a string\n * disables it *and* says why, as the checkbox's accessible description and\n * as a tooltip on hover. Every row is selectable when omitted.\n */\n isRowSelectable?: (row: T) => boolean | string;\n /**\n * The accessible name of a row's checkbox. Defaults to \"Select\" followed by\n * the row-header column's value (`rowHeader` / `meta.rowHeader`), or by\n * the row's key when there is no row header — so mark a row header, or\n * pass this, or every checkbox is named by an id.\n */\n selectionLabel?: (row: T) => string;\n};\n\nexport type DataTableProps<T> = DataTableSharedProps<T> &\n (\n | {\n /** Pre-configured TanStack table instance */\n table: TanStackTable<T>;\n columns?: never;\n data?: never;\n }\n | {\n table?: never;\n /** Column definitions (either simple Column<T>[] or TanStack ColumnDef<T>[]) */\n columns: Column<T>[] | ColumnDef<T, any>[];\n data: T[];\n /** `false` turns sorting off for every column. Defaults to `true`. */\n enableSorting?: boolean;\n pageSize?: number;\n }\n );\n\n/**\n * A data table on `@tanstack/react-table`, with the semantics TanStack does not\n * supply written here: `scope` on every header, `aria-sort` on the sorted\n * column, a real sort button per sortable header, an optional `caption`, and a\n * true row count when the body is windowed.\n */\nexport function DataTable<T>({\n table: providedTable,\n columns,\n data,\n keyExtractor,\n caption,\n appearance = 'grid',\n density = 'comfortable',\n emptyText = 'No items found.',\n className = '',\n containerClassName = '',\n virtualize,\n selectedKeys = EMPTY_KEYS,\n onSelectionChange,\n isRowSelectable,\n selectionLabel,\n ...rest\n}: DataTableProps<T>) {\n const [sorting, setSorting] = useState<SortingState>([]);\n const uid = useId();\n // Memoized (the exhaustive-deps rule's own suggestion): a caller passing a\n // fresh `virtualize={{ ... }}` literal must not churn the measure effect.\n const virtualization = useMemo(\n () => (virtualize ? (typeof virtualize === 'object' ? virtualize : {}) : undefined),\n [virtualize],\n );\n const {\n height = 480,\n rowHeight = density === 'compact' ? 36 : 44,\n overscan = 8,\n scrollElementRef,\n } = virtualization ?? {};\n const [globalFilter, setGlobalFilter] = useState('');\n\n // Normalize columns if legacy format is provided\n const tanstackColumns = useMemo<ColumnDef<T, any>[]>(() => {\n if (!columns) return [];\n\n return columns.map((col: any) => {\n // Check if it's already a TanStack ColumnDef\n if ('accessorKey' in col || 'accessorFn' in col || 'id' in col) {\n return col as ColumnDef<T, any>;\n }\n\n // Convert legacy Column<T> to ColumnDef<T>\n const legacy = col as Column<T>;\n return {\n id: typeof legacy.accessor === 'string' ? legacy.accessor : legacy.header,\n header: legacy.header,\n enableSorting: legacy.enableSorting ?? true,\n accessorFn: (row: T) => {\n if (legacy.sortValue) {\n return legacy.sortValue(row);\n }\n if (typeof legacy.accessor === 'function') {\n const res = legacy.accessor(row);\n if (res && typeof res === 'object' && 'props' in (res as any)) {\n const children = (res as any).props?.children;\n if (typeof children === 'string' || typeof children === 'number') {\n return children;\n }\n }\n return typeof res === 'string' || typeof res === 'number' ? res : '';\n }\n return row[legacy.accessor];\n },\n cell: (info: any) => {\n if (typeof legacy.accessor === 'function') {\n return legacy.accessor(info.row.original);\n }\n return info.getValue() as ReactNode;\n },\n meta: {\n className: legacy.className,\n rowHeader: legacy.rowHeader,\n },\n } as ColumnDef<T, any>;\n });\n }, [columns]);\n\n // `pageSize` used to switch the pagination model on and nothing else, so\n // TanStack's default of 10 applied whatever was asked for (#276). It is read\n // from the prop on every render, not handed to `initialState` once, so a\n // later change is honoured; only the page index is state. A new size starts\n // again at page one rather than stranding the reader past the last page.\n const paginated = !virtualization && 'pageSize' in rest && Boolean(rest.pageSize);\n const requestedPageSize = paginated ? (rest as { pageSize: number }).pageSize : 10;\n const [pageIndexState, setPageIndexState] = useState(0);\n const [pageSizeSeen, setPageSizeSeen] = useState(requestedPageSize);\n if (pageSizeSeen !== requestedPageSize) {\n setPageSizeSeen(requestedPageSize);\n setPageIndexState(0);\n }\n const pagination = { pageIndex: pageIndexState, pageSize: requestedPageSize };\n const defaultTable = useReactTable<T>({\n data: data || [],\n columns: tanstackColumns,\n state: {\n sorting,\n globalFilter,\n ...(paginated ? { pagination } : {}),\n },\n onPaginationChange: (updater) => {\n const next = typeof updater === 'function' ? updater(pagination) : updater;\n setPageIndexState(next.pageIndex);\n },\n enableSorting: 'enableSorting' in rest ? rest.enableSorting !== false : true,\n onSortingChange: setSorting,\n onGlobalFilterChange: setGlobalFilter,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getPaginationRowModel: paginated ? getPaginationRowModel() : undefined,\n });\n\n const activeTable = providedTable || defaultTable;\n const rows = activeTable.getRowModel().rows;\n const headerGroups = activeTable.getHeaderGroups();\n\n // A windowed body — virtualized, or one page of a paginated model — holds\n // fewer rows than the data, and a screen reader counts what it is given. So\n // the table states the real count and each row its real position, all from\n // one total. aria-rowcount counts every row, header rows included.\n const totalRows = activeTable.getRowCount();\n const windowed = Boolean(virtualization) || rows.length < totalRows;\n const { pageIndex, pageSize } = activeTable.getState().pagination;\n const pageOffset = virtualization\n ? 0\n : Math.min(pageIndex * pageSize, Math.max(0, totalRows - rows.length));\n\n const scrollRef = useRef<HTMLDivElement>(null);\n // The virtualizer measures from the top of the scroll element, which on a\n // table is the header's top-left — but rows begin below it. Measuring the\n // body's offset once (the header's height is static by recipe) removes the\n // scrollMargin error that would otherwise offset every window by ~46px.\n const [scrollMargin, setScrollMargin] = useState(0);\n useLayoutEffect(() => {\n if (!virtualization) return;\n const scrollEl = scrollElementRef?.current ?? scrollRef.current;\n const body = scrollEl?.querySelector('[data-slot=\"table-body\"]');\n if (!scrollEl || !body) return;\n setScrollMargin(\n body.getBoundingClientRect().top -\n scrollEl.getBoundingClientRect().top +\n scrollEl.scrollTop,\n );\n }, [virtualization, scrollElementRef, rows.length]);\n\n const virtualizer = useVirtualizer({\n count: virtualization ? rows.length : 0,\n estimateSize: () => rowHeight,\n overscan,\n getScrollElement: () => scrollElementRef?.current ?? scrollRef.current,\n scrollMargin,\n });\n\n // `row.index`, not the on-screen position: a key built from the position\n // would stay with the slot while the rows move through it on a sort.\n const keyOf = (row: (typeof rows)[number]) =>\n String(keyExtractor ? keyExtractor(row.original, row.index) : row.id);\n\n // Selection is drawn outside TanStack's column model, so a caller's columns,\n // header groups and `table` instance are untouched by it.\n const selectable = Boolean(onSelectionChange);\n const rowSelectability = (row: (typeof rows)[number]) => {\n const verdict = isRowSelectable ? isRowSelectable(row.original) : true;\n return verdict === true\n ? { ok: true as const, reason: undefined }\n : { ok: false as const, reason: typeof verdict === 'string' && verdict ? verdict : undefined };\n };\n // Every report is pruned against the data as it is now — the core model,\n // so a row hidden by a filter keeps its selection, and its flat rows, so a\n // sub-row from `getSubRows` is as selectable as its parent.\n const report = (next: Set<string>) => {\n if (!onSelectionChange) return;\n const valid = new Set(\n activeTable\n .getCoreRowModel()\n .flatRows.filter((row) => rowSelectability(row).ok)\n .map(keyOf),\n );\n onSelectionChange(new Set([...next].filter((key) => valid.has(key))));\n };\n const rowHeaderColumn = activeTable\n .getAllLeafColumns()\n .find((column) => (column.columnDef.meta as DataTableColumnMeta | undefined)?.rowHeader);\n const labelOf = (row: (typeof rows)[number], key: string) => {\n if (selectionLabel) return selectionLabel(row.original);\n const name = rowHeaderColumn ? row.getValue(rowHeaderColumn.id) : undefined;\n return `Select ${typeof name === 'string' || typeof name === 'number' ? name : key}`;\n };\n\n // The header box acts on the rows the body holds: one page when paginated,\n // every row otherwise (a virtualized body holds all of them, windowed).\n // Selecting rows on pages the reader cannot see is how a bulk delete takes\n // more than was meant, so it is never done implicitly.\n const pageKeys = selectable ? rows.filter((row) => rowSelectability(row).ok).map(keyOf) : [];\n const pageSelected = pageKeys.filter((key) => selectedKeys.has(key)).length;\n const allLabel = rows.length < totalRows && !virtualization ? 'Select all rows on this page' : 'Select all rows';\n\n // A refused row's checkbox is disabled, and a disabled control takes no\n // focus — so the reason cannot live only in the tooltip. It is also the\n // checkbox's description, read wherever the checkbox is.\n const renderSelectCell = (row: (typeof rows)[number], rowKey: string, isSelected: boolean) => {\n const verdict = rowSelectability(row);\n const reasonId = `${uid}-why-${rowKey}`;\n const box = (\n <Checkbox\n aria-label={labelOf(row, rowKey)}\n aria-describedby={verdict.reason ? reasonId : undefined}\n checked={isSelected}\n disabled={!verdict.ok}\n onCheckedChange={(checked) => {\n const next = new Set(selectedKeys);\n if (checked) next.add(rowKey);\n else next.delete(rowKey);\n report(next);\n }}\n />\n );\n return (\n <TableCell data-slot=\"datatable-select\" className=\"w-0\">\n {verdict.reason ? (\n <>\n <Tooltip content={verdict.reason}>{box}</Tooltip>\n <span id={reasonId} hidden>\n {verdict.reason}\n </span>\n </>\n ) : (\n box\n )}\n </TableCell>\n );\n };\n\n const renderRow = (row: (typeof rows)[number], position: number) => {\n const rowKey = keyOf(row);\n const isSelected = selectable ? selectedKeys.has(rowKey) : row.getIsSelected();\n\n return (\n <TableRow\n key={rowKey}\n aria-rowindex={windowed ? headerGroups.length + pageOffset + position + 1 : undefined}\n data-state={isSelected ? 'selected' : undefined}\n >\n {selectable && renderSelectCell(row, rowKey, isSelected)}\n {row.getVisibleCells().map((cell) => {\n const meta = cell.column.columnDef.meta as DataTableColumnMeta | undefined;\n const content = flexRender(cell.column.columnDef.cell, cell.getContext());\n return meta?.rowHeader ? (\n <TableHead key={cell.id} scope=\"row\" className={meta.className}>\n {content}\n </TableHead>\n ) : (\n <TableCell key={cell.id} className={meta?.className}>\n {content}\n </TableCell>\n );\n })}\n </TableRow>\n );\n };\n\n const colSpan = activeTable.getAllLeafColumns().length + (selectable ? 1 : 0) || 1;\n\n const virtualItems = virtualization ? virtualizer.getVirtualItems() : [];\n // `getVirtualItems` positions are relative to the scroll element and already\n // include `scrollMargin`; the gaps are what remains of the total column\n // above the first rendered row and below the last.\n const firstItem = virtualItems[0];\n const lastItem = virtualItems[virtualItems.length - 1];\n const topGap = virtualization && firstItem ? firstItem.start - scrollMargin : 0;\n const bottomGap =\n virtualization && lastItem\n ? virtualizer.getTotalSize() - lastItem.end\n : 0;\n\n const regionLabel = typeof caption === 'string' ? caption : undefined;\n\n const table = (\n <Table\n className={className}\n label={regionLabel}\n appearance={appearance}\n density={density}\n aria-rowcount={windowed ? headerGroups.length + totalRows : undefined}\n containerClassName={\n virtualization && !scrollElementRef\n ? cn(containerClassName, 'border-0 overflow-x-visible')\n : containerClassName\n }\n >\n {caption != null && <TableCaption>{caption}</TableCaption>}\n <TableHeader>\n {headerGroups.map((headerGroup, groupIdx) => (\n <TableRow key={headerGroup.id} aria-rowindex={windowed ? groupIdx + 1 : undefined}>\n {selectable && groupIdx === 0 && (\n <TableHead\n data-slot=\"datatable-select-all\"\n rowSpan={headerGroups.length > 1 ? headerGroups.length : undefined}\n className=\"w-0\"\n >\n <Checkbox\n aria-label={allLabel}\n checked={pageKeys.length > 0 && pageSelected === pageKeys.length}\n indeterminate={pageSelected > 0 && pageSelected < pageKeys.length}\n disabled={pageKeys.length === 0}\n onCheckedChange={(checked) => {\n const next = new Set(selectedKeys);\n for (const key of pageKeys) {\n if (checked) next.add(key);\n else next.delete(key);\n }\n report(next);\n }}\n />\n </TableHead>\n )}\n {headerGroup.headers.map((header, headerIdx) => {\n const canSort = !header.isPlaceholder && header.column.getCanSort();\n const isSorted = !header.isPlaceholder && header.column.getIsSorted();\n const meta = header.column.columnDef.meta as DataTableColumnMeta | undefined;\n // One header carries aria-sort at a time (ARIA 1.2); under a\n // multi-column sort it is the primary key's.\n const ariaSort =\n isSorted && header.column.getSortIndex() === 0\n ? isSorted === 'asc'\n ? 'ascending'\n : 'descending'\n : undefined;\n const next = canSort ? header.column.getNextSortingOrder() : false;\n const hintId = `${uid}-sort-${groupIdx}-${headerIdx}`;\n // The icon is decorative: the state it draws is aria-sort's.\n const label = header.isPlaceholder ? null : (\n <>\n <span aria-hidden=\"true\">[</span>\n <span>{flexRender(header.column.columnDef.header, header.getContext())}</span>\n {canSort && (\n <span aria-hidden=\"true\" className=\"inline-flex items-center\">\n <NerdIcon\n name={isSorted === 'asc' ? 'sort-asc' : isSorted === 'desc' ? 'sort-desc' : 'sort'}\n size=\"sm\"\n accent={isSorted ? 'primary' : 'muted'}\n />\n </span>\n )}\n <span aria-hidden=\"true\">]</span>\n </>\n );\n\n // A sortable header holds a native button, so sorting is\n // reachable by Tab and fired by Enter or Space. Its name is the\n // column's; what a press does is its description, which keeps\n // \"sort ascending\" out of the header name read before every\n // cell. `::after` stretches the hit area over the cell, as the\n // old whole-cell click had it.\n return (\n <TableHead\n key={header.id}\n colSpan={header.colSpan > 1 ? header.colSpan : undefined}\n // A group heading spanning several columns heads all of them;\n // `col`, the default, would tie it to the first one only.\n scope={header.colSpan > 1 && !header.isPlaceholder ? 'colgroup' : undefined}\n aria-sort={ariaSort}\n className={cn(\n canSort && 'relative cursor-pointer select-none hover:bg-surface-base transition-colors',\n meta?.className,\n )}\n >\n {canSort ? (\n <button\n type=\"button\"\n aria-describedby={hintId}\n onClick={header.column.getToggleSortingHandler()}\n className=\"inline-flex cursor-pointer items-center gap-1.5 uppercase after:absolute after:inset-0\"\n >\n {label}\n <span id={hintId} hidden>\n {next ? SORT_HINT[next] : 'Remove sort'}\n </span>\n </button>\n ) : (\n label && <span className=\"inline-flex items-center gap-1.5\">{label}</span>\n )}\n </TableHead>\n );\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {rows.length === 0 ? (\n <TableRow>\n <TableCell\n colSpan={colSpan}\n className={cn(\n density === 'compact' ? 'px-3 py-4' : 'px-4 py-8',\n 'text-center text-content-muted font-mono',\n )}\n >\n > {emptyText}\n </TableCell>\n </TableRow>\n ) : virtualization ? (\n <>\n {topGap > 0 && <SpacerRow height={topGap} colSpan={colSpan} />}\n {virtualItems.map((item) => renderRow(rows[item.index], item.index))}\n {bottomGap > 0 && <SpacerRow height={bottomGap} colSpan={colSpan} />}\n </>\n ) : (\n rows.map((row, position) => renderRow(row, position))\n )}\n </TableBody>\n </Table>\n );\n\n // A paginated body needs a way to the other pages, or every row past the\n // first page is unreachable. It is the system's own `Pagination`, in its\n // callback mode, rather than a second pager written here. Only for the\n // table this component builds: a caller passing `table` owns its state.\n const pageCount = activeTable.getPageCount();\n if (paginated && !providedTable && pageCount > 1) {\n return (\n <div data-slot=\"datatable-paginated\" className=\"flex flex-col gap-4\">\n {table}\n <Pagination\n totalPages={pageCount}\n currentPage={pageIndex + 1}\n onPageChange={(page) => activeTable.setPageIndex(page - 1)}\n />\n </div>\n );\n }\n\n if (!virtualization || scrollElementRef) return table;\n\n return (\n <div\n ref={scrollRef}\n data-slot=\"table-virtual-scroll\"\n tabIndex={0}\n role=\"region\"\n aria-label={regionLabel ?? 'Table contents'}\n className=\"relative w-full overflow-y-auto\"\n style={scrollBoxStyle(height)}\n >\n {table}\n </div>\n );\n}\n\n/**\n * Splits the difference between a windowed tbody and the table's own grid:\n * the row contributes height, contributes nothing to column sizing, and is\n * hidden from assistive tech because the rows it stands in for are absent.\n */\nfunction SpacerRow({ height, colSpan }: { height: number; colSpan: number }) {\n return (\n <tr aria-hidden=\"true\">\n <td aria-hidden=\"true\" colSpan={colSpan} style={spacerStyle(height)} />\n </tr>\n );\n}\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,UAAU;AACnB,SAAS,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AU,uBAC5C;AAAA;AAAA,MACD;AAAA,QAAC;AAAA;AAAA,UACC,YAAY;AAAA,UACZ,aAAa,YAAY;AAAA,UACzB,cAAc,CAAC,SAAS,YAAY,aAAa,OAAO,CAAC;AAAA;AAAA,MAC3D;AAAA,OACF;AAAA,EAEJ;AAEA,MAAI,CAAC,kBAAkB,iBAAkB,QAAO;AAEhD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,aAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAK;AAAA,MACL,cAAY,eAAe;AAAA,MAC3B,WAAU;AAAA,MACV,OAAO,eAAe,MAAM;AAAA,MAE3B;AAAA;AAAA,EACH;AAEJ;AAOA,SAAS,UAAU,EAAE,QAAQ,QAAQ,GAAwC;AAC3E,SACE,oBAAC,QAAG,eAAY,QACd,8BAAC,QAAG,eAAY,QAAO,SAAkB,OAAO,YAAY,MAAM,GAAG,GACvE;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/DataTable.tsx"],"sourcesContent":["'use client';\n\nimport {\n flexRender,\n getCoreRowModel,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n type ColumnDef,\n type SortingState,\n type Table as TanStackTable,\n} from '@tanstack/react-table';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport {\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { cn } from '../lib/recipe';\nimport { Checkbox } from './Checkbox';\nimport { NerdIcon } from './NerdIcon';\nimport { Pagination } from './Pagination';\nimport {\n Table,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n type TableAppearance,\n type TableDensity,\n} from './Table';\nimport { Tooltip } from './Tooltip';\n\n// Legacy column interface for backwards-compatibility\nexport interface Column<T> {\n header: string;\n accessor: keyof T | ((row: T) => ReactNode);\n className?: string;\n enableSorting?: boolean;\n sortValue?: (row: T) => any;\n /**\n * The column that names each row — a hostname, a branch. Its body cells\n * render as `<th scope=\"row\">`, so a screen reader announces the row by it\n * while moving across. On a TanStack `ColumnDef`, set `meta.rowHeader`.\n */\n rowHeader?: boolean;\n}\n\ninterface DataTableColumnMeta {\n className?: string;\n rowHeader?: boolean;\n}\n\n// What a press on a sort button does, keyed by the column's next order so the\n// description cannot disagree with the click.\nconst SORT_HINT = { asc: 'Sort ascending', desc: 'Sort descending' } as const;\n\n// A stable default, so an unselected table does not build a new Set per render.\nconst EMPTY_KEYS: ReadonlySet<string> = new Set();\n\n/** Virtualization geometry is runtime arithmetic; hoisted objects (the\n * `ATTACHED_STYLE` convention from CodeBlock) keep it off the inline-style\n * sites the contract counts. */\nconst SPACER_STYLE_BASE = { padding: 0, border: 0 } as const;\nfunction spacerStyle(height: number) {\n return { height, ...SPACER_STYLE_BASE };\n}\nfunction scrollBoxStyle(height: number) {\n return { height };\n}\n\n/**\n * Row virtualization is planned against a fixed row height rather than measured\n * rows: deterministic rendering is a contract here (docs/deterministic-rendering.md),\n * and a measured engine would make the snapshot of a 10k-row table depend on font\n * loading. Multi-line cell content is therefore clipped to `rowHeight`.\n */\nexport interface DataTableVirtualization {\n /**\n * Viewport height, in px, of the scroll box the table builds for itself.\n * Ignored when `scrollElementRef` is provided. Defaults to 480.\n */\n height?: number;\n /** Fixed row height, in px, the virtualizer plans against. Defaults to 44. */\n rowHeight?: number;\n /** Rows rendered beyond each edge of the viewport. Defaults to 8. */\n overscan?: number;\n /**\n * Scroll inside an existing scrollable element instead of building one. When\n * provided, no wrapper is rendered and this element owns both axes — and it\n * must be keyboard-reachable itself (`tabIndex={0}`), or the window cannot be\n * scrolled without a mouse.\n */\n scrollElementRef?: RefObject<HTMLElement | null>;\n}\n\nexport type DataTableSharedProps<T> = {\n /**\n * `grid` keeps the framed default, `quiet` removes the full cell grid, and\n * `index` adds a keyline to row headers for catalog-style scanning.\n */\n appearance?: TableAppearance;\n /**\n * `comfortable` preserves the existing cell spacing. `compact` reduces it\n * for reference tables with many rows.\n */\n density?: TableDensity;\n /**\n * `index` is the row's position in `data`, not on screen, so a key built\n * from it follows its row through a sort rather than staying with the slot.\n */\n keyExtractor?: (row: T, index: number) => string | number;\n /**\n * What the table is a table of. Rendered as the `<caption>`, which is the\n * table's accessible name; a string caption also names the scroll regions.\n */\n caption?: ReactNode;\n emptyText?: string;\n className?: string;\n containerClassName?: string;\n /**\n * Window the body to the visible rows so a dataset of thousands renders as\n * many rows as fit, not as many as exist. `true` uses the defaults;\n * mutually exclusive with `pageSize`, which wins nothing — pagination is\n * simply not attached while virtualizing. The table still reports the whole\n * dataset to assistive tech, through `aria-rowcount` and `aria-rowindex`.\n */\n virtualize?: boolean | DataTableVirtualization;\n /**\n * The keys of the selected rows, as `keyExtractor` produces them (numbers\n * are compared as strings). Controlled: the table never changes it, it\n * reports the next set through `onSelectionChange`. Because selection is\n * keyed rather than positional it survives a sort, a page change and a\n * windowed scroll. Without a `keyExtractor` the key is TanStack's row id,\n * which is the row's index in `data` and does not follow a row when\n * `data` changes — pass one.\n */\n selectedKeys?: ReadonlySet<string>;\n /**\n * Turns selection on: a leading column of checkboxes, one per row, and one\n * in the header. Called with the whole next selection on every toggle.\n * The set it reports holds only keys of rows that are still in the data\n * and still selectable, so a key whose row has gone, or has become\n * unselectable, drops out on the next change rather than lingering.\n */\n onSelectionChange?: (keys: Set<string>) => void;\n /**\n * Whether a row may be selected. `false` disables its checkbox; a string\n * disables it *and* says why, as the checkbox's accessible description and\n * as a tooltip on hover. Every row is selectable when omitted.\n */\n isRowSelectable?: (row: T) => boolean | string;\n /**\n * The accessible name of a row's checkbox. Defaults to \"Select\" followed by\n * the row-header column's value (`rowHeader` / `meta.rowHeader`), or by\n * the row's key when there is no row header — so mark a row header, or\n * pass this, or every checkbox is named by an id.\n */\n selectionLabel?: (row: T) => string;\n};\n\nexport type DataTableProps<T> = DataTableSharedProps<T> &\n (\n | {\n /** Pre-configured TanStack table instance */\n table: TanStackTable<T>;\n columns?: never;\n data?: never;\n }\n | {\n table?: never;\n /** Column definitions (either simple Column<T>[] or TanStack ColumnDef<T>[]) */\n columns: Column<T>[] | ColumnDef<T, any>[];\n data: T[];\n /** `false` turns sorting off for every column. Defaults to `true`. */\n enableSorting?: boolean;\n pageSize?: number;\n }\n );\n\n/**\n * A data table on `@tanstack/react-table`, with the semantics TanStack does not\n * supply written here: `scope` on every header, `aria-sort` on the sorted\n * column, a real sort button per sortable header, an optional `caption`, and a\n * true row count when the body is windowed.\n */\nexport function DataTable<T>({\n table: providedTable,\n columns,\n data,\n keyExtractor,\n caption,\n appearance = 'grid',\n density = 'comfortable',\n emptyText = 'No items found.',\n className = '',\n containerClassName = '',\n virtualize,\n selectedKeys = EMPTY_KEYS,\n onSelectionChange,\n isRowSelectable,\n selectionLabel,\n ...rest\n}: DataTableProps<T>) {\n const [sorting, setSorting] = useState<SortingState>([]);\n const uid = useId();\n // Memoized (the exhaustive-deps rule's own suggestion): a caller passing a\n // fresh `virtualize={{ ... }}` literal must not churn the measure effect.\n const virtualization = useMemo(\n () => (virtualize ? (typeof virtualize === 'object' ? virtualize : {}) : undefined),\n [virtualize],\n );\n const {\n height = 480,\n rowHeight = density === 'compact' ? 36 : 44,\n overscan = 8,\n scrollElementRef,\n } = virtualization ?? {};\n const [globalFilter, setGlobalFilter] = useState('');\n\n // Normalize columns if legacy format is provided\n const tanstackColumns = useMemo<ColumnDef<T, any>[]>(() => {\n if (!columns) return [];\n\n return columns.map((col: any) => {\n // Check if it's already a TanStack ColumnDef\n if ('accessorKey' in col || 'accessorFn' in col || 'id' in col) {\n return col as ColumnDef<T, any>;\n }\n\n // Convert legacy Column<T> to ColumnDef<T>\n const legacy = col as Column<T>;\n return {\n id: typeof legacy.accessor === 'string' ? legacy.accessor : legacy.header,\n header: legacy.header,\n enableSorting: legacy.enableSorting ?? true,\n accessorFn: (row: T) => {\n if (legacy.sortValue) {\n return legacy.sortValue(row);\n }\n if (typeof legacy.accessor === 'function') {\n const res = legacy.accessor(row);\n if (res && typeof res === 'object' && 'props' in (res as any)) {\n const children = (res as any).props?.children;\n if (typeof children === 'string' || typeof children === 'number') {\n return children;\n }\n }\n return typeof res === 'string' || typeof res === 'number' ? res : '';\n }\n return row[legacy.accessor];\n },\n cell: (info: any) => {\n if (typeof legacy.accessor === 'function') {\n return legacy.accessor(info.row.original);\n }\n return info.getValue() as ReactNode;\n },\n meta: {\n className: legacy.className,\n rowHeader: legacy.rowHeader,\n },\n } as ColumnDef<T, any>;\n });\n }, [columns]);\n\n // `pageSize` used to switch the pagination model on and nothing else, so\n // TanStack's default of 10 applied whatever was asked for (#276). It is read\n // from the prop on every render, not handed to `initialState` once, so a\n // later change is honoured; only the page index is state. A new size starts\n // again at page one rather than stranding the reader past the last page.\n const paginated = !virtualization && 'pageSize' in rest && Boolean(rest.pageSize);\n const requestedPageSize = paginated ? (rest as { pageSize: number }).pageSize : 10;\n const [pageIndexState, setPageIndexState] = useState(0);\n const [pageSizeSeen, setPageSizeSeen] = useState(requestedPageSize);\n if (pageSizeSeen !== requestedPageSize) {\n setPageSizeSeen(requestedPageSize);\n setPageIndexState(0);\n }\n const pagination = { pageIndex: pageIndexState, pageSize: requestedPageSize };\n const defaultTable = useReactTable<T>({\n data: data || [],\n columns: tanstackColumns,\n state: {\n sorting,\n globalFilter,\n ...(paginated ? { pagination } : {}),\n },\n onPaginationChange: (updater) => {\n const next = typeof updater === 'function' ? updater(pagination) : updater;\n setPageIndexState(next.pageIndex);\n },\n enableSorting: 'enableSorting' in rest ? rest.enableSorting !== false : true,\n onSortingChange: setSorting,\n onGlobalFilterChange: setGlobalFilter,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getPaginationRowModel: paginated ? getPaginationRowModel() : undefined,\n });\n\n const activeTable = providedTable || defaultTable;\n const rows = activeTable.getRowModel().rows;\n const headerGroups = activeTable.getHeaderGroups();\n\n // A windowed body — virtualized, or one page of a paginated model — holds\n // fewer rows than the data, and a screen reader counts what it is given. So\n // the table states the real count and each row its real position, all from\n // one total. aria-rowcount counts every row, header rows included.\n const totalRows = activeTable.getRowCount();\n const windowed = Boolean(virtualization) || rows.length < totalRows;\n const { pageIndex, pageSize } = activeTable.getState().pagination;\n const pageOffset = virtualization\n ? 0\n : Math.min(pageIndex * pageSize, Math.max(0, totalRows - rows.length));\n\n const scrollRef = useRef<HTMLDivElement>(null);\n // The virtualizer measures from the top of the scroll element, which on a\n // table is the header's top-left — but rows begin below it. Measuring the\n // body's offset once (the header's height is static by recipe) removes the\n // scrollMargin error that would otherwise offset every window by ~46px.\n const [scrollMargin, setScrollMargin] = useState(0);\n useLayoutEffect(() => {\n if (!virtualization) return;\n const scrollEl = scrollElementRef?.current ?? scrollRef.current;\n const body = scrollEl?.querySelector('[data-slot=\"table-body\"]');\n if (!scrollEl || !body) return;\n setScrollMargin(\n body.getBoundingClientRect().top -\n scrollEl.getBoundingClientRect().top +\n scrollEl.scrollTop,\n );\n }, [virtualization, scrollElementRef, rows.length]);\n\n const virtualizer = useVirtualizer({\n count: virtualization ? rows.length : 0,\n estimateSize: () => rowHeight,\n overscan,\n getScrollElement: () => scrollElementRef?.current ?? scrollRef.current,\n scrollMargin,\n });\n\n // `row.index`, not the on-screen position: a key built from the position\n // would stay with the slot while the rows move through it on a sort.\n const keyOf = (row: (typeof rows)[number]) =>\n String(keyExtractor ? keyExtractor(row.original, row.index) : row.id);\n\n // Selection is drawn outside TanStack's column model, so a caller's columns,\n // header groups and `table` instance are untouched by it.\n const selectable = Boolean(onSelectionChange);\n const rowSelectability = (row: (typeof rows)[number]) => {\n const verdict = isRowSelectable ? isRowSelectable(row.original) : true;\n return verdict === true\n ? { ok: true as const, reason: undefined }\n : { ok: false as const, reason: typeof verdict === 'string' && verdict ? verdict : undefined };\n };\n // Every report is pruned against the data as it is now — the core model,\n // so a row hidden by a filter keeps its selection, and its flat rows, so a\n // sub-row from `getSubRows` is as selectable as its parent.\n const report = (next: Set<string>) => {\n if (!onSelectionChange) return;\n const valid = new Set(\n activeTable\n .getCoreRowModel()\n .flatRows.filter((row) => rowSelectability(row).ok)\n .map(keyOf),\n );\n onSelectionChange(new Set([...next].filter((key) => valid.has(key))));\n };\n const rowHeaderColumn = activeTable\n .getAllLeafColumns()\n .find((column) => (column.columnDef.meta as DataTableColumnMeta | undefined)?.rowHeader);\n const labelOf = (row: (typeof rows)[number], key: string) => {\n if (selectionLabel) return selectionLabel(row.original);\n const name = rowHeaderColumn ? row.getValue(rowHeaderColumn.id) : undefined;\n return `Select ${typeof name === 'string' || typeof name === 'number' ? name : key}`;\n };\n\n // The header box acts on the rows the body holds: one page when paginated,\n // every row otherwise (a virtualized body holds all of them, windowed).\n // Selecting rows on pages the reader cannot see is how a bulk delete takes\n // more than was meant, so it is never done implicitly.\n const pageKeys = selectable ? rows.filter((row) => rowSelectability(row).ok).map(keyOf) : [];\n const pageSelected = pageKeys.filter((key) => selectedKeys.has(key)).length;\n const allLabel = rows.length < totalRows && !virtualization ? 'Select all rows on this page' : 'Select all rows';\n\n // A refused row's checkbox is disabled, and a disabled control takes no\n // focus — so the reason cannot live only in the tooltip. It is also the\n // checkbox's description, read wherever the checkbox is.\n const renderSelectCell = (row: (typeof rows)[number], rowKey: string, isSelected: boolean) => {\n const verdict = rowSelectability(row);\n const reasonId = `${uid}-why-${rowKey}`;\n const box = (\n <Checkbox\n aria-label={labelOf(row, rowKey)}\n aria-describedby={verdict.reason ? reasonId : undefined}\n checked={isSelected}\n disabled={!verdict.ok}\n onCheckedChange={(checked) => {\n const next = new Set(selectedKeys);\n if (checked) next.add(rowKey);\n else next.delete(rowKey);\n report(next);\n }}\n />\n );\n return (\n <TableCell data-slot=\"datatable-select\" className=\"w-0\">\n {verdict.reason ? (\n <>\n <Tooltip content={verdict.reason}>{box}</Tooltip>\n <span id={reasonId} hidden>\n {verdict.reason}\n </span>\n </>\n ) : (\n box\n )}\n </TableCell>\n );\n };\n\n const renderRow = (row: (typeof rows)[number], position: number) => {\n const rowKey = keyOf(row);\n const isSelected = selectable ? selectedKeys.has(rowKey) : row.getIsSelected();\n\n return (\n <TableRow\n key={rowKey}\n aria-rowindex={windowed ? headerGroups.length + pageOffset + position + 1 : undefined}\n data-state={isSelected ? 'selected' : undefined}\n >\n {selectable && renderSelectCell(row, rowKey, isSelected)}\n {row.getVisibleCells().map((cell) => {\n const meta = cell.column.columnDef.meta as DataTableColumnMeta | undefined;\n const content = flexRender(cell.column.columnDef.cell, cell.getContext());\n return meta?.rowHeader ? (\n <TableHead key={cell.id} scope=\"row\" className={meta.className}>\n {content}\n </TableHead>\n ) : (\n <TableCell key={cell.id} className={meta?.className}>\n {content}\n </TableCell>\n );\n })}\n </TableRow>\n );\n };\n\n const colSpan = activeTable.getAllLeafColumns().length + (selectable ? 1 : 0) || 1;\n\n const virtualItems = virtualization ? virtualizer.getVirtualItems() : [];\n // `getVirtualItems` positions are relative to the scroll element and already\n // include `scrollMargin`; the gaps are what remains of the total column\n // above the first rendered row and below the last.\n const firstItem = virtualItems[0];\n const lastItem = virtualItems[virtualItems.length - 1];\n const topGap = virtualization && firstItem ? firstItem.start - scrollMargin : 0;\n const bottomGap =\n virtualization && lastItem\n ? virtualizer.getTotalSize() - lastItem.end\n : 0;\n\n const regionLabel = typeof caption === 'string' ? caption : undefined;\n\n const table = (\n <Table\n className={className}\n label={regionLabel}\n appearance={appearance}\n density={density}\n aria-rowcount={windowed ? headerGroups.length + totalRows : undefined}\n containerClassName={\n virtualization && !scrollElementRef\n ? cn(containerClassName, 'border-0 overflow-x-visible')\n : containerClassName\n }\n >\n {caption != null && <TableCaption>{caption}</TableCaption>}\n <TableHeader>\n {headerGroups.map((headerGroup, groupIdx) => (\n <TableRow key={headerGroup.id} aria-rowindex={windowed ? groupIdx + 1 : undefined}>\n {selectable && groupIdx === 0 && (\n <TableHead\n data-slot=\"datatable-select-all\"\n rowSpan={headerGroups.length > 1 ? headerGroups.length : undefined}\n className=\"w-0\"\n >\n <Checkbox\n aria-label={allLabel}\n checked={pageKeys.length > 0 && pageSelected === pageKeys.length}\n indeterminate={pageSelected > 0 && pageSelected < pageKeys.length}\n disabled={pageKeys.length === 0}\n onCheckedChange={(checked) => {\n const next = new Set(selectedKeys);\n for (const key of pageKeys) {\n if (checked) next.add(key);\n else next.delete(key);\n }\n report(next);\n }}\n />\n </TableHead>\n )}\n {headerGroup.headers.map((header, headerIdx) => {\n const canSort = !header.isPlaceholder && header.column.getCanSort();\n const isSorted = !header.isPlaceholder && header.column.getIsSorted();\n const meta = header.column.columnDef.meta as DataTableColumnMeta | undefined;\n // One header carries aria-sort at a time (ARIA 1.2); under a\n // multi-column sort it is the primary key's.\n const ariaSort =\n isSorted && header.column.getSortIndex() === 0\n ? isSorted === 'asc'\n ? 'ascending'\n : 'descending'\n : undefined;\n const next = canSort ? header.column.getNextSortingOrder() : false;\n const hintId = `${uid}-sort-${groupIdx}-${headerIdx}`;\n // The icon is decorative: the state it draws is aria-sort's.\n const label = header.isPlaceholder ? null : (\n <>\n <span aria-hidden=\"true\">[</span>\n <span>{flexRender(header.column.columnDef.header, header.getContext())}</span>\n {canSort && (\n <span aria-hidden=\"true\" className=\"inline-flex items-center\">\n <NerdIcon\n name={isSorted === 'asc' ? 'sort-asc' : isSorted === 'desc' ? 'sort-desc' : 'sort'}\n size=\"sm\"\n accent={isSorted ? 'primary' : 'muted'}\n />\n </span>\n )}\n <span aria-hidden=\"true\">]</span>\n </>\n );\n\n // A sortable header holds a native button, so sorting is\n // reachable by Tab and fired by Enter or Space. Its name is the\n // column's; what a press does is its description, which keeps\n // \"sort ascending\" out of the header name read before every\n // cell. `::after` stretches the hit area over the cell, as the\n // old whole-cell click had it.\n return (\n <TableHead\n key={header.id}\n colSpan={header.colSpan > 1 ? header.colSpan : undefined}\n // A group heading spanning several columns heads all of them;\n // `col`, the default, would tie it to the first one only.\n scope={header.colSpan > 1 && !header.isPlaceholder ? 'colgroup' : undefined}\n aria-sort={ariaSort}\n className={cn(\n canSort && 'relative cursor-pointer select-none hover:bg-surface-base transition-colors',\n meta?.className,\n )}\n >\n {canSort ? (\n <button\n type=\"button\"\n aria-describedby={hintId}\n onClick={header.column.getToggleSortingHandler()}\n className=\"inline-flex cursor-pointer items-center gap-1.5 uppercase after:absolute after:inset-0\"\n >\n {label}\n <span id={hintId} hidden>\n {next ? SORT_HINT[next] : 'Remove sort'}\n </span>\n </button>\n ) : (\n label && <span className=\"inline-flex items-center gap-1.5\">{label}</span>\n )}\n </TableHead>\n );\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {rows.length === 0 ? (\n <TableRow>\n <TableCell\n colSpan={colSpan}\n className={cn(\n density === 'compact' ? 'px-3 py-4' : 'px-4 py-8',\n 'text-center text-content-muted font-mono',\n )}\n >\n > {emptyText}\n </TableCell>\n </TableRow>\n ) : virtualization ? (\n <>\n {topGap > 0 && <SpacerRow height={topGap} colSpan={colSpan} />}\n {virtualItems.map((item) => renderRow(rows[item.index], item.index))}\n {bottomGap > 0 && <SpacerRow height={bottomGap} colSpan={colSpan} />}\n </>\n ) : (\n rows.map((row, position) => renderRow(row, position))\n )}\n </TableBody>\n </Table>\n );\n\n // A paginated body needs a way to the other pages, or every row past the\n // first page is unreachable. It is the system's own `Pagination`, in its\n // callback mode, rather than a second pager written here. Only for the\n // table this component builds: a caller passing `table` owns its state.\n const pageCount = activeTable.getPageCount();\n if (paginated && !providedTable && pageCount > 1) {\n return (\n <div data-slot=\"datatable-paginated\" className=\"flex flex-col gap-4\">\n {table}\n <Pagination\n totalPages={pageCount}\n currentPage={pageIndex + 1}\n onPageChange={(page) => activeTable.setPageIndex(page - 1)}\n />\n </div>\n );\n }\n\n if (!virtualization || scrollElementRef) return table;\n\n return (\n <div\n ref={scrollRef}\n data-slot=\"table-virtual-scroll\"\n tabIndex={0}\n role=\"region\"\n aria-label={regionLabel ?? 'Table contents'}\n className=\"relative w-full overflow-y-auto\"\n style={scrollBoxStyle(height)}\n >\n {table}\n </div>\n );\n}\n\n/**\n * Splits the difference between a windowed tbody and the table's own grid:\n * the row contributes height, contributes nothing to column sizing, and is\n * hidden from assistive tech because the rows it stands in for are absent.\n */\nfunction SpacerRow({ height, colSpan }: { height: number; colSpan: number }) {\n return (\n <tr aria-hidden=\"true\">\n <td aria-hidden=\"true\" colSpan={colSpan} style={spacerStyle(height)} />\n </tr>\n );\n}\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,eAAe;AA0WlB,SAgBI,UAhBJ,KAgBI,YAhBJ;AAlVN,IAAM,YAAY,EAAE,KAAK,kBAAkB,MAAM,kBAAkB;AAGnE,IAAM,aAAkC,oBAAI,IAAI;AAKhD,IAAM,oBAAoB,EAAE,SAAS,GAAG,QAAQ,EAAE;AAClD,SAAS,YAAY,QAAgB;AACnC,SAAO,EAAE,QAAQ,GAAG,kBAAkB;AACxC;AACA,SAAS,eAAe,QAAgB;AACtC,SAAO,EAAE,OAAO;AAClB;AAqHO,SAAS,UAAa;AAAA,EAC3B,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,CAAC,SAAS,UAAU,IAAI,SAAuB,CAAC,CAAC;AACvD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,QACR,GACF,IACE,iBACF,iCACG;AAAA,mBAAS,KAAK,oBAAC,aAAU,QAAQ,QAAQ,SAAkB;AAAA,UAC3D,aAAa,IAAI,CAAC,SAAS,UAAU,KAAK,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;AAAA,UAClE,YAAY,KAAK,oBAAC,aAAU,QAAQ,WAAW,SAAkB;AAAA,WACpE,IAEA,KAAK,IAAI,CAAC,KAAK,aAAa,UAAU,KAAK,QAAQ,CAAC,GAExD;AAAA;AAAA;AAAA,EACF;AAOF,QAAM,YAAY,YAAY,aAAa;AAC3C,MAAI,aAAa,CAAC,iBAAiB,YAAY,GAAG;AAChD,WACE,qBAAC,SAAI,aAAU,uBAAsB,WAAU,uBAC5C;AAAA;AAAA,MACD;AAAA,QAAC;AAAA;AAAA,UACC,YAAY;AAAA,UACZ,aAAa,YAAY;AAAA,UACzB,cAAc,CAAC,SAAS,YAAY,aAAa,OAAO,CAAC;AAAA;AAAA,MAC3D;AAAA,OACF;AAAA,EAEJ;AAEA,MAAI,CAAC,kBAAkB,iBAAkB,QAAO;AAEhD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,aAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAK;AAAA,MACL,cAAY,eAAe;AAAA,MAC3B,WAAU;AAAA,MACV,OAAO,eAAe,MAAM;AAAA,MAE3B;AAAA;AAAA,EACH;AAEJ;AAOA,SAAS,UAAU,EAAE,QAAQ,QAAQ,GAAwC;AAC3E,SACE,oBAAC,QAAG,eAAY,QACd,8BAAC,QAAG,eAAY,QAAO,SAAkB,OAAO,YAAY,MAAM,GAAG,GACvE;AAEJ;","names":[]}
|
|
@@ -4,11 +4,20 @@
|
|
|
4
4
|
import { LEVELS, DEFAULT_LEVEL } from "../theme/levels.js";
|
|
5
5
|
import { useOptionalTheme } from "./ThemeProvider.js";
|
|
6
6
|
import { cn } from "../lib/recipe.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
var DIVIDER_PATTERNS = {
|
|
9
9
|
dark: "//====================================================//",
|
|
10
10
|
light: "\xB7 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \u2500 \xB7"
|
|
11
11
|
};
|
|
12
|
+
var DIVIDER_MARKS = {
|
|
13
|
+
dark: { start: "//", fill: "=", end: "//" },
|
|
14
|
+
light: { start: "\xB7", fill: " \u2500", end: " \xB7" }
|
|
15
|
+
};
|
|
16
|
+
var FILL_WIDTH = {
|
|
17
|
+
dark: "[width:round(down,calc(100%_-_4*(1ch_+_0.2em)),calc(1ch_+_0.2em))]",
|
|
18
|
+
light: "[width:round(down,calc(100%_-_3*(1ch_+_0.2em)),calc(2*(1ch_+_0.2em)))]"
|
|
19
|
+
};
|
|
20
|
+
var FILL_REPEAT = 400;
|
|
12
21
|
var VARIANT_POLARITY = {
|
|
13
22
|
terminal: "dark",
|
|
14
23
|
pencil: "light"
|
|
@@ -21,21 +30,19 @@ var Divider = ({
|
|
|
21
30
|
}) => {
|
|
22
31
|
const theme = useOptionalTheme();
|
|
23
32
|
const polarity = variant === "auto" ? theme?.polarity ?? LEVELS[DEFAULT_LEVEL].polarity : VARIANT_POLARITY[variant];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
children: pattern ?? DIVIDER_PATTERNS[polarity]
|
|
35
|
-
}
|
|
36
|
-
);
|
|
33
|
+
const base = "font-mono text-accent-primary tracking-[0.2em] select-none my-6 overflow-hidden whitespace-nowrap";
|
|
34
|
+
if (pattern != null) {
|
|
35
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "divider", className: cn(base, className), "aria-hidden": "true", ...props, children: pattern });
|
|
36
|
+
}
|
|
37
|
+
const mark = DIVIDER_MARKS[polarity];
|
|
38
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "divider", className: cn(base, "flex", className), "aria-hidden": "true", ...props, children: [
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0", children: mark.start }),
|
|
40
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "divider-fill", className: cn("min-w-0 overflow-hidden", FILL_WIDTH[polarity]), children: mark.fill.repeat(FILL_REPEAT) }),
|
|
41
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0", children: mark.end })
|
|
42
|
+
] });
|
|
37
43
|
};
|
|
38
44
|
export {
|
|
45
|
+
DIVIDER_MARKS,
|
|
39
46
|
DIVIDER_PATTERNS,
|
|
40
47
|
Divider
|
|
41
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Divider.tsx"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { LEVELS, DEFAULT_LEVEL } from '../theme/levels';\nimport type { Polarity } from '../theme/levels';\nimport { useOptionalTheme } from './ThemeProvider';\nimport { cn } from '../lib/recipe';\n\n/**\n * A rule drawn in characters rather than pixels.\n *\n * The glyph is part of the design, and it is not the same glyph on every level.\n * The dark end of the ladder leans on terminal devices — scanlines, `>`\n * prompts, `//====//` rules. The light end is paper, where the equivalent\n * device is a hand-ruled pencil dash. Same component, same role, different\n * mark.\n *\n * ## Why this exists as its own component\n *\n * That behaviour used to live in the *consumer's* stylesheet, as\n * `.sketch .ascii-divider::after { content: \"· ─ ─ ·\" }` in the blog, overriding\n * a `::after` in the design system. Three things were wrong with that:\n *\n * - The design intent — \"this rule is drawn differently on paper\" — was\n * stated in a downstream repo, so the system did not actually own its own\n * divider.\n * - It keyed off `.sketch`, a level name that no longer exists. Anything\n * built that way silently stops matching when the ladder changes, because\n * a selector that matches nothing fails quietly.\n * - It forced the design system to keep a bare `.ascii-divider` class as a\n * styling hook purely so a pseudo-element had something to attach to,\n * which was the last hole in the styling-lives-in-TSX rule.\n *\n * Encoding it here closes all three: the mapping is a `Record<Polarity, …>`, so\n * it is exhaustive by type, and the glyph is real text rather than generated\n * content — which means it is selectable, searchable, and readable by a screen\n * reader if it ever needed to be (it is `aria-hidden`, being decoration).\n */\n\n/** Which mark to draw. `auto` follows the current level's polarity. */\nexport type DividerVariant = 'auto' | 'terminal' | 'pencil';\n\n/**\n * The mark each polarity draws.\n *\n * A `Record<Polarity, …>` rather than a conditional, for the same reason the\n * rest of the ladder is: a third polarity would be a compile error here rather\n * than a silent fallthrough.\n */\nexport const DIVIDER_PATTERNS: Readonly<Record<Polarity, string>> = {\n dark: '//====================================================//',\n light: '· ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ·',\n};\n\nconst VARIANT_POLARITY: Readonly<Record<Exclude<DividerVariant, 'auto'>, Polarity>> = {\n terminal: 'dark',\n pencil: 'light',\n};\n\nexport interface DividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Which mark to draw. Defaults to `auto`, which follows the level's declared\n * polarity — terminal on `midnight`/`dim`, pencil on `bright`/`white`.\n */\n variant?: DividerVariant;\n /** An explicit mark, overriding both the variant and the level. */\n pattern?: string;\n}\n\nexport const Divider: React.FC<DividerProps> = ({\n variant = 'auto',\n pattern,\n className = '',\n ...props\n}) => {\n // Optional on purpose: a divider must still draw something sensible in a\n // story with no decorator, or under a consumer that sets `data-theme` on the\n // document and never mounts a provider.\n const theme = useOptionalTheme();\n const polarity =\n variant === 'auto'\n ? (theme?.polarity ?? LEVELS[DEFAULT_LEVEL].polarity)\n : VARIANT_POLARITY[variant];\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/components/Divider.tsx"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { LEVELS, DEFAULT_LEVEL } from '../theme/levels';\nimport type { Polarity } from '../theme/levels';\nimport { useOptionalTheme } from './ThemeProvider';\nimport { cn } from '../lib/recipe';\n\n/**\n * A rule drawn in characters rather than pixels.\n *\n * The glyph is part of the design, and it is not the same glyph on every level.\n * The dark end of the ladder leans on terminal devices — scanlines, `>`\n * prompts, `//====//` rules. The light end is paper, where the equivalent\n * device is a hand-ruled pencil dash. Same component, same role, different\n * mark.\n *\n * ## Why this exists as its own component\n *\n * That behaviour used to live in the *consumer's* stylesheet, as\n * `.sketch .ascii-divider::after { content: \"· ─ ─ ·\" }` in the blog, overriding\n * a `::after` in the design system. Three things were wrong with that:\n *\n * - The design intent — \"this rule is drawn differently on paper\" — was\n * stated in a downstream repo, so the system did not actually own its own\n * divider.\n * - It keyed off `.sketch`, a level name that no longer exists. Anything\n * built that way silently stops matching when the ladder changes, because\n * a selector that matches nothing fails quietly.\n * - It forced the design system to keep a bare `.ascii-divider` class as a\n * styling hook purely so a pseudo-element had something to attach to,\n * which was the last hole in the styling-lives-in-TSX rule.\n *\n * Encoding it here closes all three: the mapping is a `Record<Polarity, …>`, so\n * it is exhaustive by type, and the glyph is real text rather than generated\n * content — which means it is selectable, searchable, and readable by a screen\n * reader if it ever needed to be (it is `aria-hidden`, being decoration).\n */\n\n/** Which mark to draw. `auto` follows the current level's polarity. */\nexport type DividerVariant = 'auto' | 'terminal' | 'pencil';\n\n/**\n * The mark each polarity draws.\n *\n * A `Record<Polarity, …>` rather than a conditional, for the same reason the\n * rest of the ladder is: a third polarity would be a compile error here rather\n * than a silent fallthrough.\n */\nexport const DIVIDER_PATTERNS: Readonly<Record<Polarity, string>> = {\n dark: '//====================================================//',\n light: '· ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ·',\n};\n\n/**\n * The same marks, as a start cap, a repeating fill and an end cap, so a rule can run the full\n * width of its container instead of stopping where a fixed string happens to end.\n *\n * `step` is the fill unit's length in characters and `caps` the two caps' total; both feed the\n * width calculation below, so a mark changed here must change its numbers with it.\n */\nexport const DIVIDER_MARKS: Readonly<Record<Polarity, { start: string; fill: string; end: string }>> = {\n dark: { start: '//', fill: '=', end: '//' },\n light: { start: '·', fill: ' ─', end: ' ·' },\n};\n\n/**\n * The fill's width: the container less the caps, rounded **down to a whole fill unit**, so the\n * last glyph is never cut in half and the end cap sits flush against the fill. One character's\n * advance is `1ch` plus the `0.2em` tracking. CSS `round()` does the arithmetic with no script, so\n * the rule also fills a static `ds-report` page; a browser without `round()` drops the width and\n * the fill is simply clipped, which is how every divider behaved before.\n *\n * Written out per polarity, not built from the numbers: Tailwind reads class names from source\n * text, and a template literal emits no CSS.\n */\nconst FILL_WIDTH: Readonly<Record<Polarity, string>> = {\n dark: '[width:round(down,calc(100%_-_4*(1ch_+_0.2em)),calc(1ch_+_0.2em))]',\n light: '[width:round(down,calc(100%_-_3*(1ch_+_0.2em)),calc(2*(1ch_+_0.2em)))]',\n};\n\n/** Enough fill for a 4K-wide container; the width above trims it to the container. */\nconst FILL_REPEAT = 400;\n\nconst VARIANT_POLARITY: Readonly<Record<Exclude<DividerVariant, 'auto'>, Polarity>> = {\n terminal: 'dark',\n pencil: 'light',\n};\n\nexport interface DividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Which mark to draw. Defaults to `auto`, which follows the level's declared\n * polarity — terminal on `midnight`/`dim`, pencil on `bright`/`white`.\n */\n variant?: DividerVariant;\n /** An explicit mark, overriding both the variant and the level. */\n pattern?: string;\n}\n\nexport const Divider: React.FC<DividerProps> = ({\n variant = 'auto',\n pattern,\n className = '',\n ...props\n}) => {\n // Optional on purpose: a divider must still draw something sensible in a\n // story with no decorator, or under a consumer that sets `data-theme` on the\n // document and never mounts a provider.\n const theme = useOptionalTheme();\n const polarity =\n variant === 'auto'\n ? (theme?.polarity ?? LEVELS[DEFAULT_LEVEL].polarity)\n : VARIANT_POLARITY[variant];\n\n const base = 'font-mono text-accent-primary tracking-[0.2em] select-none my-6 overflow-hidden whitespace-nowrap';\n\n // An explicit pattern is drawn as given and clipped, as it always was.\n if (pattern != null) {\n return (\n <div data-slot=\"divider\" className={cn(base, className)} aria-hidden=\"true\" {...props}>\n {pattern}\n </div>\n );\n }\n\n // Clipped, not truncated: an ellipsis on a rule reads as a broken string. The mark is\n // decoration, so `aria-hidden` keeps it out of the accessibility tree.\n const mark = DIVIDER_MARKS[polarity];\n return (\n <div data-slot=\"divider\" className={cn(base, 'flex', className)} aria-hidden=\"true\" {...props}>\n <span className=\"shrink-0\">{mark.start}</span>\n <span data-slot=\"divider-fill\" className={cn('min-w-0 overflow-hidden', FILL_WIDTH[polarity])}>\n {mark.fill.repeat(FILL_REPEAT)}\n </span>\n <span className=\"shrink-0\">{mark.end}</span>\n </div>\n );\n};\n"],"mappings":";;;AAGA,SAAS,QAAQ,qBAAqB;AAEtC,SAAS,wBAAwB;AACjC,SAAS,UAAU;AAiHb,cAUF,YAVE;AAtEC,IAAM,mBAAuD;AAAA,EAClE,MAAM;AAAA,EACN,OAAO;AACT;AASO,IAAM,gBAA0F;AAAA,EACrG,MAAM,EAAE,OAAO,MAAM,MAAM,KAAK,KAAK,KAAK;AAAA,EAC1C,OAAO,EAAE,OAAO,QAAK,MAAM,WAAM,KAAK,QAAK;AAC7C;AAYA,IAAM,aAAiD;AAAA,EACrD,MAAM;AAAA,EACN,OAAO;AACT;AAGA,IAAM,cAAc;AAEpB,IAAM,mBAAgF;AAAA,EACpF,UAAU;AAAA,EACV,QAAQ;AACV;AAYO,IAAM,UAAkC,CAAC;AAAA,EAC9C,UAAU;AAAA,EACV;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,MAAM;AAIJ,QAAM,QAAQ,iBAAiB;AAC/B,QAAM,WACJ,YAAY,SACP,OAAO,YAAY,OAAO,aAAa,EAAE,WAC1C,iBAAiB,OAAO;AAE9B,QAAM,OAAO;AAGb,MAAI,WAAW,MAAM;AACnB,WACE,oBAAC,SAAI,aAAU,WAAU,WAAW,GAAG,MAAM,SAAS,GAAG,eAAY,QAAQ,GAAG,OAC7E,mBACH;AAAA,EAEJ;AAIA,QAAM,OAAO,cAAc,QAAQ;AACnC,SACE,qBAAC,SAAI,aAAU,WAAU,WAAW,GAAG,MAAM,QAAQ,SAAS,GAAG,eAAY,QAAQ,GAAG,OACtF;AAAA,wBAAC,UAAK,WAAU,YAAY,eAAK,OAAM;AAAA,IACvC,oBAAC,UAAK,aAAU,gBAAe,WAAW,GAAG,2BAA2B,WAAW,QAAQ,CAAC,GACzF,eAAK,KAAK,OAAO,WAAW,GAC/B;AAAA,IACA,oBAAC,UAAK,WAAU,YAAY,eAAK,KAAI;AAAA,KACvC;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/InlineAction.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport type {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n ReactNode,\n Ref,\n} from 'react';\nimport { recipe } from '../lib/recipe';\nimport { SiteLink } from './LinkProvider';\n\
|
|
1
|
+
{"version":3,"sources":["../../src/components/InlineAction.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport type {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n ReactNode,\n Ref,\n} from 'react';\nimport { recipe } from '../lib/recipe';\nimport { SiteLink } from './LinkProvider';\n\nexport interface InlineActionOwnProps {\n /**\n * The words, in the case the surrounding text is written in. Unlike\n * `Button`'s label this is read as part of a sentence or a cell, so it is\n * not written in caps — `view output`, `retry`, `all alerts →`.\n */\n children: ReactNode;\n /**\n * How loudly it reads against the text around it. `accent` is the primary\n * accent ink with a solid underline — the one to reach for, and what a link\n * in a row of data looks like. `quiet` is secondary ink with a dotted\n * underline, for a housekeeping action beside the content it acts on —\n * `clear`, `reset`, `show all` — that should not compete with it.\n * Omitted, the tone is `accent`.\n */\n tone?: InlineActionTone;\n /**\n * Merged into the recipe's own classes. Reach for it to set the typeface or\n * size where the surrounding text does not — `font-mono` in a table of ids —\n * rather than to recolour it.\n */\n className?: string;\n}\n\n/** The inks an `InlineAction` may take. Named for emphasis, not for a hue. */\nexport type InlineActionTone = 'accent' | 'quiet';\n\n/**\n * The `<button>` form: an action on the current page. `href?: never` is what\n * lets the union below discriminate, exactly as it does on `Button`.\n */\nexport type InlineActionButtonProps = InlineActionOwnProps &\n Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, 'children'> & {\n href?: never;\n };\n\n/**\n * The `<a>` form: the same ink on something that navigates. Rendered through\n * `LinkProvider`, so an app's router handles an internal href.\n */\nexport type InlineActionLinkProps = InlineActionOwnProps &\n Omit<DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, 'children'> & {\n /**\n * Where it navigates — and the discriminant. Supplying it renders a link\n * through the `LinkProvider`'s component; omit it for anything that acts\n * on the current page.\n */\n href: string;\n /**\n * Not offered on the anchor form. `disabled` does nothing on an `<a>`, and\n * a link that cannot be followed is text, not a link.\n */\n disabled?: never;\n };\n\nexport type InlineActionProps = InlineActionButtonProps | InlineActionLinkProps;\n\n/**\n * No box, no padding, no case or weight of its own: the type is the\n * surrounding text's, so it sits in a sentence or a table cell without\n * changing the line. Preflight already gives a `<button>` the inherited font\n * and a transparent ground; this adds the underline that says it can be used.\n *\n * Hover is gated on `not-disabled:` so a disabled action does not respond to\n * the pointer; `not-disabled` rather than `enabled`, because `:enabled` matches\n * form elements only and the anchor form would lose its hover. The change is\n * instant, not animated: a colour change this small does not need easing, and\n * every animated property is one more thing `docs/deterministic-rendering.md`\n * has to switch off.\n *\n * Focus is the global `:focus-visible` outline, untouched — see\n * `src/focus-ring.test.ts`.\n */\nconst inlineAction = recipe({\n base:\n 'cursor-pointer text-left underline underline-offset-2 ' +\n 'disabled:cursor-not-allowed disabled:text-content-muted disabled:no-underline',\n variants: {\n tone: {\n accent: 'text-accent-primary decoration-1 not-disabled:hover:decoration-2',\n quiet:\n 'text-content-secondary decoration-dotted not-disabled:hover:text-content-primary ' +\n 'not-disabled:hover:decoration-solid',\n },\n },\n defaultVariants: {\n tone: 'accent',\n },\n});\n\n/**\n * An action that reads as a link: underlined text inside a sentence or a table\n * cell, with no box, padding or press of its own.\n *\n * `Button` is the control a screen is built around — bordered, filled, caps,\n * a 44px hit area. In a table row that is too much: one per row is a column of\n * buttons, and the row's data is lost behind them. This is the same decision\n * in the weight of the text around it, and like `Button` the element follows\n * the job rather than the look: without `href` it is a `<button type=\"button\">`\n * that runs `onClick`; with `href` it is a link, through `LinkProvider`.\n *\n * It takes the surrounding font and size, so it is mono in a mono cell and\n * prose in a paragraph; there is no `size`. An inline target is exempt from\n * the WCAG 2.5.8 target-size minimum because its size is set by the line it\n * sits in — which is also why it belongs inline, not standing on its own as a\n * page's action.\n *\n * ```tsx\n * <InlineAction onClick={() => openRun(run.id)}>view output</InlineAction>\n * <InlineAction href={`/runs/${run.id}`}>open run</InlineAction>\n * <InlineAction tone=\"quiet\" onClick={clear}>clear</InlineAction>\n * ```\n */\nexport const InlineAction = forwardRef<HTMLButtonElement | HTMLAnchorElement, InlineActionProps>(\n function InlineAction(props, ref) {\n const { children, tone = 'accent', className, ...rest } = props;\n const classes = inlineAction({ tone, class: className });\n\n if (typeof props.href === 'string') {\n const {\n href,\n disabled: _disabled,\n ...anchorProps\n } = rest as Omit<InlineActionLinkProps, keyof InlineActionOwnProps>;\n return (\n <SiteLink\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n data-slot=\"inline-action\"\n {...anchorProps}\n className={classes}\n >\n {children}\n </SiteLink>\n );\n }\n\n const buttonProps = rest as Omit<InlineActionButtonProps, keyof InlineActionOwnProps>;\n return (\n <button\n // A bare `<button>` inside a form is a submit button. This one acts on\n // its row, so it says so unless the caller asks for a submit.\n type=\"button\"\n data-slot=\"inline-action\"\n ref={ref as Ref<HTMLButtonElement>}\n {...buttonProps}\n className={classes}\n >\n {children}\n </button>\n );\n },\n);\n\nInlineAction.displayName = 'InlineAction';\n"],"mappings":";AAAA,SAAS,kBAAkB;AAQ3B,SAAS,cAAc;AACvB,SAAS,gBAAgB;AA+HjB;AApDR,IAAM,eAAe,OAAO;AAAA,EAC1B,MACE;AAAA,EAEF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,OACE;AAAA,IAEJ;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAyBM,IAAM,eAAe;AAAA,EAC1B,SAASA,cAAa,OAAO,KAAK;AAChC,UAAM,EAAE,UAAU,OAAO,UAAU,WAAW,GAAG,KAAK,IAAI;AAC1D,UAAM,UAAU,aAAa,EAAE,MAAM,OAAO,UAAU,CAAC;AAEvD,QAAI,OAAO,MAAM,SAAS,UAAU;AAClC,YAAM;AAAA,QACJ;AAAA,QACA,UAAU;AAAA,QACV,GAAG;AAAA,MACL,IAAI;AACJ,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,aAAU;AAAA,UACT,GAAG;AAAA,UACJ,WAAW;AAAA,UAEV;AAAA;AAAA,MACH;AAAA,IAEJ;AAEA,UAAM,cAAc;AACpB,WACE;AAAA,MAAC;AAAA;AAAA,QAGC,MAAK;AAAA,QACL,aAAU;AAAA,QACV;AAAA,QACC,GAAG;AAAA,QACJ,WAAW;AAAA,QAEV;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,aAAa,cAAc;","names":["InlineAction"]}
|
|
@@ -6,10 +6,14 @@ function PageTitle({
|
|
|
6
6
|
children,
|
|
7
7
|
subtitle,
|
|
8
8
|
bracketed = true,
|
|
9
|
+
framed = true,
|
|
9
10
|
className = "",
|
|
10
11
|
...props
|
|
11
12
|
}) {
|
|
12
|
-
const baseClasses =
|
|
13
|
+
const baseClasses = cn(
|
|
14
|
+
"text-3xl font-display font-bold leading-tight tracking-tight text-[var(--ds-text-primary)] uppercase text-balance sm:text-4xl md:text-5xl inline-block",
|
|
15
|
+
framed ? "border-4 border-double border-[var(--ds-border-strong)] px-6 py-4" : "py-2"
|
|
16
|
+
);
|
|
13
17
|
return /* @__PURE__ */ jsxs("div", { "data-slot": "page-title", className: "mb-8", children: [
|
|
14
18
|
/* @__PURE__ */ jsx("h1", { className: cn(baseClasses, className), ...props, children: bracketed ? /* @__PURE__ */ jsx(BracketText, { children }) : children }),
|
|
15
19
|
subtitle && /* @__PURE__ */ jsx("p", { className: "mt-2 font-mono text-sm text-accent-primary", children: subtitle })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/PageTitle.tsx"],"sourcesContent":["import type { ReactNode, HTMLAttributes } from 'react';\nimport { BracketText } from './BracketText';\nimport { cn } from '../lib/recipe';\n\nexport interface PageTitleProps extends HTMLAttributes<HTMLHeadingElement> {\n children: ReactNode;\n subtitle?: string;\n bracketed?: boolean;\n className?: string;\n}\n\nexport function PageTitle({\n children,\n subtitle,\n bracketed = true,\n className = '',\n ...props\n}: PageTitleProps) {\n const baseClasses
|
|
1
|
+
{"version":3,"sources":["../../src/components/PageTitle.tsx"],"sourcesContent":["import type { ReactNode, HTMLAttributes } from 'react';\nimport { BracketText } from './BracketText';\nimport { cn } from '../lib/recipe';\n\nexport interface PageTitleProps extends HTMLAttributes<HTMLHeadingElement> {\n children: ReactNode;\n subtitle?: string;\n bracketed?: boolean;\n /**\n * Draw the title in its double-ruled box. `true` by default. Set `false` where something else\n * on the page is the heavy object — a hero whose demo leads, for instance — so the title does\n * not compete with it. See `docs/edge-hierarchy.md`.\n */\n framed?: boolean;\n className?: string;\n}\n\nexport function PageTitle({\n children,\n subtitle,\n bracketed = true,\n framed = true,\n className = '',\n ...props\n}: PageTitleProps) {\n const baseClasses = cn(\n 'text-3xl font-display font-bold leading-tight tracking-tight text-[var(--ds-text-primary)] uppercase text-balance sm:text-4xl md:text-5xl inline-block',\n framed ? 'border-4 border-double border-[var(--ds-border-strong)] px-6 py-4' : 'py-2',\n );\n\n return (\n <div data-slot=\"page-title\" className=\"mb-8\">\n <h1 className={cn(baseClasses, className)} {...props}>\n {bracketed ? <BracketText>{children}</BracketText> : children}\n </h1>\n {subtitle && (\n <p className=\"mt-2 font-mono text-sm text-accent-primary\">\n {subtitle}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";AACA,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AA6Bf,SAEiB,KAFjB;AAdG,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,GAAG;AACL,GAAmB;AACjB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,SAAS,sEAAsE;AAAA,EACjF;AAEA,SACE,qBAAC,SAAI,aAAU,cAAa,WAAU,QACpC;AAAA,wBAAC,QAAG,WAAW,GAAG,aAAa,SAAS,GAAI,GAAG,OAC5C,sBAAY,oBAAC,eAAa,UAAS,IAAiB,UACvD;AAAA,IACC,YACC,oBAAC,OAAE,WAAU,8CACV,oBACH;AAAA,KAEJ;AAEJ;","names":[]}
|