@rtkelly-labs/design-system 0.18.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +1 -1
  3. package/dist/components/BracketText.js +3 -2
  4. package/dist/components/BracketText.js.map +1 -1
  5. package/dist/components/Button.js.map +1 -1
  6. package/dist/components/Card.js +2 -1
  7. package/dist/components/Card.js.map +1 -1
  8. package/dist/components/DataTable.js +135 -52
  9. package/dist/components/DataTable.js.map +1 -1
  10. package/dist/components/Divider.js +21 -14
  11. package/dist/components/Divider.js.map +1 -1
  12. package/dist/components/InlineAction.js +58 -0
  13. package/dist/components/InlineAction.js.map +1 -0
  14. package/dist/components/PageTitle.js +5 -1
  15. package/dist/components/PageTitle.js.map +1 -1
  16. package/dist/components/ResourceState.js +55 -0
  17. package/dist/components/ResourceState.js.map +1 -0
  18. package/dist/components/SocialIcon.js.map +1 -1
  19. package/dist/components/StatCard.js +2 -2
  20. package/dist/components/StatCard.js.map +1 -1
  21. package/dist/components/StatusPage.js.map +1 -1
  22. package/dist/components/docs/figures/ActivityGrid.js.map +1 -1
  23. package/dist/components/docs/figures/ChangeSummary.js +68 -25
  24. package/dist/components/docs/figures/ChangeSummary.js.map +1 -1
  25. package/dist/components/docs/figures/DrawingSheet.js +4 -1
  26. package/dist/components/docs/figures/DrawingSheet.js.map +1 -1
  27. package/dist/components/docs/figures/FigureFrame.js.map +1 -1
  28. package/dist/components/docs/figures/FigureSurfaceContext.js +9 -0
  29. package/dist/components/docs/figures/FigureSurfaceContext.js.map +1 -0
  30. package/dist/components/docs/figures/IndexedSection.js +8 -2
  31. package/dist/components/docs/figures/IndexedSection.js.map +1 -1
  32. package/dist/components/docs/figures/index.js.map +1 -1
  33. package/dist/components/experiments/ExperimentsView.js.map +1 -1
  34. package/dist/components/marketing/FeatureGrid.js.map +1 -1
  35. package/dist/components/marketing/Hero.js +2 -2
  36. package/dist/components/marketing/Hero.js.map +1 -1
  37. package/dist/components/marketing/PricingGrid.js.map +1 -1
  38. package/dist/components/review/ChangeBar.js +29 -0
  39. package/dist/components/review/ChangeBar.js.map +1 -0
  40. package/dist/components/review/ChangeCount.js +27 -0
  41. package/dist/components/review/ChangeCount.js.map +1 -0
  42. package/dist/components/review/ChangeIndex.js +50 -0
  43. package/dist/components/review/ChangeIndex.js.map +1 -0
  44. package/dist/components/review/DeltaValue.js +87 -0
  45. package/dist/components/review/DeltaValue.js.map +1 -0
  46. package/dist/components/review/DiffView.js +115 -0
  47. package/dist/components/review/DiffView.js.map +1 -0
  48. package/dist/components/review/KeyedDiff.js +43 -0
  49. package/dist/components/review/KeyedDiff.js.map +1 -0
  50. package/dist/components/review/ProvenanceStrip.js +17 -0
  51. package/dist/components/review/ProvenanceStrip.js.map +1 -0
  52. package/dist/components/review/PullRequestPage.js +223 -0
  53. package/dist/components/review/PullRequestPage.js.map +1 -0
  54. package/dist/components/review/ReviewReportPage.js +111 -0
  55. package/dist/components/review/ReviewReportPage.js.map +1 -0
  56. package/dist/components/review/StatusMark.js +32 -0
  57. package/dist/components/review/StatusMark.js.map +1 -0
  58. package/dist/components/review/VerdictBand.js +45 -0
  59. package/dist/components/review/VerdictBand.js.map +1 -0
  60. package/dist/components/review/diff.js +53 -0
  61. package/dist/components/review/diff.js.map +1 -0
  62. package/dist/components/review/index.js +16 -0
  63. package/dist/components/review/index.js.map +1 -0
  64. package/dist/components/review/samples.js +235 -0
  65. package/dist/components/review/samples.js.map +1 -0
  66. package/dist/components/review/vocabulary.js +51 -0
  67. package/dist/components/review/vocabulary.js.map +1 -0
  68. package/dist/components/saas/SaasLandingPage.js +10 -2
  69. package/dist/components/saas/SaasLandingPage.js.map +1 -1
  70. package/dist/hooks/usePolledResource.js +98 -0
  71. package/dist/hooks/usePolledResource.js.map +1 -0
  72. package/dist/index.d.ts +908 -26
  73. package/dist/index.js +6 -1
  74. package/dist/index.js.map +1 -1
  75. package/dist/lib/units.js +25 -0
  76. package/dist/lib/units.js.map +1 -0
  77. package/package.json +9 -3
package/CHANGELOG.md CHANGED
@@ -9,6 +9,56 @@ 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
+
43
+ ## 0.19.0
44
+
45
+ Pieces for operational apps, upstreamed from the rig hub (rtkelly13/rig#274). Nothing to change.
46
+
47
+ - `usePolledResource(load, { key, intervalMs, enabled })` loads, then polls while the page is
48
+ visible, keeps the last good answer when a later load fails, and returns `updatedAt` for
49
+ `FreshnessIndicator`. A new `key` clears the old answer rather than showing it as current
50
+ (#440).
51
+ - `ResourceState` renders a resource's loading, failed, stale and ready states around a
52
+ render-prop body (#440).
53
+ - `DataTable` takes `selectedKeys`, `onSelectionChange`, `isRowSelectable` and
54
+ `selectionLabel` for controlled row selection. Paginated, the header checkbox selects the
55
+ current page; a refused row's reason is its checkbox's description (#439).
56
+ - `InlineAction` is a link-styled action for table cells and prose: a `button`, or an `a`
57
+ through `LinkProvider` when given `href` (#437).
58
+ - `formatBytes` writes a byte count in its largest unit, binary and labelled `KiB` by
59
+ default, SI with `{ base: 1000 }` (#436).
60
+ - `DrawingSheet` and `IndexedSection` take `surface`, and `FigureSurface` is exported (#420).
61
+
12
62
  ## 0.18.0
13
63
 
14
64
  A `delta` role group — `added`, `removed`, `moved`, and `deltaGround` `added`, `removed`,
package/README.md CHANGED
@@ -84,7 +84,7 @@ operating instructions are in [`docs/visual-regression.md`](./docs/visual-regres
84
84
 
85
85
  - **What is asserted**: three tables in `tests/visual.spec.ts`: `CASES` (desktop), `MOBILE_CASES`
86
86
  (narrow viewport) and `INTERACTIONS` (hover, focus and open states). They run against a static
87
- Storybook build served on `http://localhost:6006`. `pnpm check:visual-coverage` requires every component to
87
+ Storybook build served on `http://localhost:8103`. `pnpm check:visual-coverage` requires every component to
88
88
  have an asserted story or a stated reason.
89
89
  - **Two projects**: `chromium` (desktop) and `mobile`. Baselines live in `tests/__snapshots__/`,
90
90
  named by file rather than story id, so retitling a story does not orphan one.
@@ -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 [\n </span>{' '}\n {children}{' '}\n <span aria-hidden=\"true\">\n ]\n </span>\n </span>\n );\n}\n"],"mappings":";AAEA,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAyB5B,SACE,KADF;AAVG,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAAqB;AAEnB,QAAM,cAAc,SAAS,gBAAgB,MAAM,IAAI;AAEvD,SACE,qBAAC,UAAK,aAAU,gBAAe,WAAW,GAAG,aAAa,SAAS,GAAI,GAAG,OACxE;AAAA,wBAAC,UAAK,eAAY,QAAO,eAEzB;AAAA,IAAQ;AAAA,IACP;AAAA,IAAU;AAAA,IACX,oBAAC,UAAK,eAAY,QAAO,eAEzB;AAAA,KACF;AAEJ;","names":[]}
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,EACp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ACH;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"]}
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;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,EACpB,SAASA,QAAO,OAAO,KAAK;AAC5B,UAAM;AAAA,MACJ;AAAA,MACA,UAAU;AAAA,MACV,OAAO;A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AIP,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"]}
@@ -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 &rarr; ]\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,IA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;AAAA,YACd,KAAK;AAAA,YACL,OAAO,EAAE,WAAW,SAAS,gBAAgB,UAAU,OAAO,QAAQ,WAAW,QAAQ;AAAA;AAAA,QAC3F,GAEJ;AAAA,QAGF,qBAAC,SAAI,OAAO,EAAE,SAAS,SAAS,GAC7B;AAAA,mBACC;AAAA,YAAC;AAAA;AAAA,cACC,OAAO;AAAA,gBACL,cAAc;AAAA,gBACd,UAAU;AAAA,gBACV,YAAY,eAAe,KAAK;AAAA,gBAChC,YAAY;AAAA,gBACZ,YAAY;AAAA,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 &rarr; ]\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,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,SAAS;AAAA,EACT;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,WAAW,UAAU,aAAa,eAAe,OAAO,OAAO,KAAK,aAAa,eAAe,OAAO,MAAM;AAAA,IACrH,YAAY;AAAA,IACZ,GAAI,cAAc,EAAE,iBAAiB,OAAO,iBAAiB,YAAY,IAAI,CAAC;AAAA,IAC9E,GAAG;AAAA,EACL;AAGA,MAAI,SAAS,SAAS;AACpB,WACE;AAAA,MAAC;AAAA;AAAA,QAAI,aAAU;AAAA,QACb;AAAA,QACA,WAAW,GAAG,SAAS;AAAA,QACvB,OAAO,EAAE,GAAG,eAAe,SAAS,SAAS;AAAA,QAC5C,GAAG;AAAA,QAEH;AAAA,mBACC;AAAA,YAAC;AAAA;AAAA,cACC,OAAO;AAAA,gBACL,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT,UAAU;AAAA,gBACV,YA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AK,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"]}
@@ -18,6 +18,7 @@ import {
18
18
  useState
19
19
  } from "react";
20
20
  import { cn } from "../lib/recipe.js";
21
+ import { Checkbox } from "./Checkbox.js";
21
22
  import { NerdIcon } from "./NerdIcon.js";
22
23
  import { Pagination } from "./Pagination.js";
23
24
  import {
@@ -29,8 +30,10 @@ import {
29
30
  TableHeader,
30
31
  TableRow
31
32
  } from "./Table.js";
33
+ import { Tooltip } from "./Tooltip.js";
32
34
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
33
35
  var SORT_HINT = { asc: "Sort ascending", desc: "Sort descending" };
36
+ var EMPTY_KEYS = /* @__PURE__ */ new Set();
34
37
  var SPACER_STYLE_BASE = { padding: 0, border: 0 };
35
38
  function spacerStyle(height) {
36
39
  return { height, ...SPACER_STYLE_BASE };
@@ -50,6 +53,10 @@ function DataTable({
50
53
  className = "",
51
54
  containerClassName = "",
52
55
  virtualize,
56
+ selectedKeys = EMPTY_KEYS,
57
+ onSelectionChange,
58
+ isRowSelectable,
59
+ selectionLabel,
53
60
  ...rest
54
61
  }) {
55
62
  const [sorting, setSorting] = useState([]);
@@ -159,23 +166,72 @@ function DataTable({
159
166
  getScrollElement: () => scrollElementRef?.current ?? scrollRef.current,
160
167
  scrollMargin
161
168
  });
169
+ const keyOf = (row) => String(keyExtractor ? keyExtractor(row.original, row.index) : row.id);
170
+ const selectable = Boolean(onSelectionChange);
171
+ const rowSelectability = (row) => {
172
+ const verdict = isRowSelectable ? isRowSelectable(row.original) : true;
173
+ return verdict === true ? { ok: true, reason: void 0 } : { ok: false, reason: typeof verdict === "string" && verdict ? verdict : void 0 };
174
+ };
175
+ const report = (next) => {
176
+ if (!onSelectionChange) return;
177
+ const valid = new Set(
178
+ activeTable.getCoreRowModel().flatRows.filter((row) => rowSelectability(row).ok).map(keyOf)
179
+ );
180
+ onSelectionChange(new Set([...next].filter((key) => valid.has(key))));
181
+ };
182
+ const rowHeaderColumn = activeTable.getAllLeafColumns().find((column) => column.columnDef.meta?.rowHeader);
183
+ const labelOf = (row, key) => {
184
+ if (selectionLabel) return selectionLabel(row.original);
185
+ const name = rowHeaderColumn ? row.getValue(rowHeaderColumn.id) : void 0;
186
+ return `Select ${typeof name === "string" || typeof name === "number" ? name : key}`;
187
+ };
188
+ const pageKeys = selectable ? rows.filter((row) => rowSelectability(row).ok).map(keyOf) : [];
189
+ const pageSelected = pageKeys.filter((key) => selectedKeys.has(key)).length;
190
+ const allLabel = rows.length < totalRows && !virtualization ? "Select all rows on this page" : "Select all rows";
191
+ const renderSelectCell = (row, rowKey, isSelected) => {
192
+ const verdict = rowSelectability(row);
193
+ const reasonId = `${uid}-why-${rowKey}`;
194
+ const box = /* @__PURE__ */ jsx(
195
+ Checkbox,
196
+ {
197
+ "aria-label": labelOf(row, rowKey),
198
+ "aria-describedby": verdict.reason ? reasonId : void 0,
199
+ checked: isSelected,
200
+ disabled: !verdict.ok,
201
+ onCheckedChange: (checked) => {
202
+ const next = new Set(selectedKeys);
203
+ if (checked) next.add(rowKey);
204
+ else next.delete(rowKey);
205
+ report(next);
206
+ }
207
+ }
208
+ );
209
+ return /* @__PURE__ */ jsx(TableCell, { "data-slot": "datatable-select", className: "w-0", children: verdict.reason ? /* @__PURE__ */ jsxs(Fragment, { children: [
210
+ /* @__PURE__ */ jsx(Tooltip, { content: verdict.reason, children: box }),
211
+ /* @__PURE__ */ jsx("span", { id: reasonId, hidden: true, children: verdict.reason })
212
+ ] }) : box });
213
+ };
162
214
  const renderRow = (row, position) => {
163
- const rowKey = keyExtractor ? keyExtractor(row.original, row.index) : row.id;
164
- return /* @__PURE__ */ jsx(
215
+ const rowKey = keyOf(row);
216
+ const isSelected = selectable ? selectedKeys.has(rowKey) : row.getIsSelected();
217
+ return /* @__PURE__ */ jsxs(
165
218
  TableRow,
166
219
  {
167
220
  "aria-rowindex": windowed ? headerGroups.length + pageOffset + position + 1 : void 0,
168
- "data-state": row.getIsSelected() && "selected",
169
- children: row.getVisibleCells().map((cell) => {
170
- const meta = cell.column.columnDef.meta;
171
- const content = flexRender(cell.column.columnDef.cell, cell.getContext());
172
- return meta?.rowHeader ? /* @__PURE__ */ jsx(TableHead, { scope: "row", className: meta.className, children: content }, cell.id) : /* @__PURE__ */ jsx(TableCell, { className: meta?.className, children: content }, cell.id);
173
- })
221
+ "data-state": isSelected ? "selected" : void 0,
222
+ children: [
223
+ selectable && renderSelectCell(row, rowKey, isSelected),
224
+ row.getVisibleCells().map((cell) => {
225
+ const meta = cell.column.columnDef.meta;
226
+ const content = flexRender(cell.column.columnDef.cell, cell.getContext());
227
+ return meta?.rowHeader ? /* @__PURE__ */ jsx(TableHead, { scope: "row", className: meta.className, children: content }, cell.id) : /* @__PURE__ */ jsx(TableCell, { className: meta?.className, children: content }, cell.id);
228
+ })
229
+ ]
174
230
  },
175
231
  rowKey
176
232
  );
177
233
  };
178
- const colSpan = activeTable.getAllLeafColumns().length || 1;
234
+ const colSpan = activeTable.getAllLeafColumns().length + (selectable ? 1 : 0) || 1;
179
235
  const virtualItems = virtualization ? virtualizer.getVirtualItems() : [];
180
236
  const firstItem = virtualItems[0];
181
237
  const lastItem = virtualItems[virtualItems.length - 1];
@@ -193,53 +249,80 @@ function DataTable({
193
249
  containerClassName: virtualization && !scrollElementRef ? cn(containerClassName, "border-0 overflow-x-visible") : containerClassName,
194
250
  children: [
195
251
  caption != null && /* @__PURE__ */ jsx(TableCaption, { children: caption }),
196
- /* @__PURE__ */ jsx(TableHeader, { children: headerGroups.map((headerGroup, groupIdx) => /* @__PURE__ */ jsx(TableRow, { "aria-rowindex": windowed ? groupIdx + 1 : void 0, children: headerGroup.headers.map((header, headerIdx) => {
197
- const canSort = !header.isPlaceholder && header.column.getCanSort();
198
- const isSorted = !header.isPlaceholder && header.column.getIsSorted();
199
- const meta = header.column.columnDef.meta;
200
- const ariaSort = isSorted && header.column.getSortIndex() === 0 ? isSorted === "asc" ? "ascending" : "descending" : void 0;
201
- const next = canSort ? header.column.getNextSortingOrder() : false;
202
- const hintId = `${uid}-sort-${groupIdx}-${headerIdx}`;
203
- const label = header.isPlaceholder ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
204
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "[" }),
205
- /* @__PURE__ */ jsx("span", { children: flexRender(header.column.columnDef.header, header.getContext()) }),
206
- canSort && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-flex items-center", children: /* @__PURE__ */ jsx(
207
- NerdIcon,
208
- {
209
- name: isSorted === "asc" ? "sort-asc" : isSorted === "desc" ? "sort-desc" : "sort",
210
- size: "sm",
211
- accent: isSorted ? "primary" : "muted"
212
- }
213
- ) }),
214
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "]" })
215
- ] });
216
- return /* @__PURE__ */ jsx(
252
+ /* @__PURE__ */ jsx(TableHeader, { children: headerGroups.map((headerGroup, groupIdx) => /* @__PURE__ */ jsxs(TableRow, { "aria-rowindex": windowed ? groupIdx + 1 : void 0, children: [
253
+ selectable && groupIdx === 0 && /* @__PURE__ */ jsx(
217
254
  TableHead,
218
255
  {
219
- colSpan: header.colSpan > 1 ? header.colSpan : void 0,
220
- scope: header.colSpan > 1 && !header.isPlaceholder ? "colgroup" : void 0,
221
- "aria-sort": ariaSort,
222
- className: cn(
223
- canSort && "relative cursor-pointer select-none hover:bg-surface-base transition-colors",
224
- meta?.className
225
- ),
226
- children: canSort ? /* @__PURE__ */ jsxs(
227
- "button",
256
+ "data-slot": "datatable-select-all",
257
+ rowSpan: headerGroups.length > 1 ? headerGroups.length : void 0,
258
+ className: "w-0",
259
+ children: /* @__PURE__ */ jsx(
260
+ Checkbox,
228
261
  {
229
- type: "button",
230
- "aria-describedby": hintId,
231
- onClick: header.column.getToggleSortingHandler(),
232
- className: "inline-flex cursor-pointer items-center gap-1.5 uppercase after:absolute after:inset-0",
233
- children: [
234
- label,
235
- /* @__PURE__ */ jsx("span", { id: hintId, hidden: true, children: next ? SORT_HINT[next] : "Remove sort" })
236
- ]
262
+ "aria-label": allLabel,
263
+ checked: pageKeys.length > 0 && pageSelected === pageKeys.length,
264
+ indeterminate: pageSelected > 0 && pageSelected < pageKeys.length,
265
+ disabled: pageKeys.length === 0,
266
+ onCheckedChange: (checked) => {
267
+ const next = new Set(selectedKeys);
268
+ for (const key of pageKeys) {
269
+ if (checked) next.add(key);
270
+ else next.delete(key);
271
+ }
272
+ report(next);
273
+ }
237
274
  }
238
- ) : label && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center gap-1.5", children: label })
239
- },
240
- header.id
241
- );
242
- }) }, headerGroup.id)) }),
275
+ )
276
+ }
277
+ ),
278
+ headerGroup.headers.map((header, headerIdx) => {
279
+ const canSort = !header.isPlaceholder && header.column.getCanSort();
280
+ const isSorted = !header.isPlaceholder && header.column.getIsSorted();
281
+ const meta = header.column.columnDef.meta;
282
+ const ariaSort = isSorted && header.column.getSortIndex() === 0 ? isSorted === "asc" ? "ascending" : "descending" : void 0;
283
+ const next = canSort ? header.column.getNextSortingOrder() : false;
284
+ const hintId = `${uid}-sort-${groupIdx}-${headerIdx}`;
285
+ const label = header.isPlaceholder ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
286
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "[" }),
287
+ /* @__PURE__ */ jsx("span", { children: flexRender(header.column.columnDef.header, header.getContext()) }),
288
+ canSort && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-flex items-center", children: /* @__PURE__ */ jsx(
289
+ NerdIcon,
290
+ {
291
+ name: isSorted === "asc" ? "sort-asc" : isSorted === "desc" ? "sort-desc" : "sort",
292
+ size: "sm",
293
+ accent: isSorted ? "primary" : "muted"
294
+ }
295
+ ) }),
296
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "]" })
297
+ ] });
298
+ return /* @__PURE__ */ jsx(
299
+ TableHead,
300
+ {
301
+ colSpan: header.colSpan > 1 ? header.colSpan : void 0,
302
+ scope: header.colSpan > 1 && !header.isPlaceholder ? "colgroup" : void 0,
303
+ "aria-sort": ariaSort,
304
+ className: cn(
305
+ canSort && "relative cursor-pointer select-none hover:bg-surface-base transition-colors",
306
+ meta?.className
307
+ ),
308
+ children: canSort ? /* @__PURE__ */ jsxs(
309
+ "button",
310
+ {
311
+ type: "button",
312
+ "aria-describedby": hintId,
313
+ onClick: header.column.getToggleSortingHandler(),
314
+ className: "inline-flex cursor-pointer items-center gap-1.5 uppercase after:absolute after:inset-0",
315
+ children: [
316
+ label,
317
+ /* @__PURE__ */ jsx("span", { id: hintId, hidden: true, children: next ? SORT_HINT[next] : "Remove sort" })
318
+ ]
319
+ }
320
+ ) : label && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center gap-1.5", children: label })
321
+ },
322
+ header.id
323
+ );
324
+ })
325
+ ] }, headerGroup.id)) }),
243
326
  /* @__PURE__ */ jsx(TableBody, { children: rows.length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsxs(
244
327
  TableCell,
245
328
  {