@stackone/malachite 2.138.0 → 2.141.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/COMPONENTS.md CHANGED
@@ -12,6 +12,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
12
12
  - **`SurfaceExpandableRow`** — A row that opens to reveal a body (used as `Surface.ExpandableRow`), for a line that carries its own controls. Not `Accordion`, which puts its header inside the toggle button, so a header holding a dropdown or a second button would be invalid: here the row surface takes the click and a cell opts out by wrapping its controls in `ExpandableRow.Controls`, while the arrow stays a real button so the keyboard reaches it. That opt-out is explicit rather than sniffing the event target for an interactive ancestor, because a control rendering into a shadow root retargets the event to its host. `sticky` pins the row while its body scrolls, offset by `stickyTopOffset` for whatever is already pinned above it; it only pins while open, since a closed row has nothing to scroll past. _Key props:_ `header`, `children`, `expanded`, `onToggle`, `sticky`, `stickyTopOffset`, `divider`, `tone`, `aria-label`, `className`, `style`.
13
13
  - **`DisclosureArrow`** — The expand/collapse triangle disclosure UI shares (`Accordion`, `Surface.ExpandableRow`). Owns its colour states so they never drift between usages: `text-primary` when expanded, `text-placeholder` otherwise, and dark on hover inside a `group` ancestor — put `group` on the clickable header or row so that hover state activates. _Key props:_ `expanded`, `size`, `className`.
14
14
  - **`Card`** — Generic content card. `title` heads it, with dimmed `subtitle` text beside it and `extra` actions at the right of the title row. By default the title and subtitle shrink to whatever `extra` leaves them, and on a framed card are cut short with the full text in a tooltip; `wrapExtra` instead moves `extra` onto a line of its own under them, still at the right, when the title and subtitle together do not fit on one line beside it, and the header grows by that line. On a framed card `wrapExtra` also adds 6px above and below the title row, so an `extra` taller than 32px makes the header taller than 44px even when nothing wraps; use a small or medium control there. Keep text that changes width, such as a live save status, out of a wrapping `extra`, or the header jumps between one line and two as it changes. `variant="framed"` draws the detached `Table`’s frame instead: the title row sits on a grey frame and the children in a bordered section inside it, so a card above a table, such as a chart over a log list, reads as part of the same set. `tone` (`CardTone`, the same `neutral` | `warning` | `error` | `success` as `Modal`’s tray) paints a framed card’s frame in that tray colour, for a verdict card; `neutral` keeps the default grey frame. Tone is colour alone, so the title has to say the outcome. It is a type error on a default card. `dimmed`, `border`, `size`, `glassFooter` and `headerConfig` do not apply to a framed card. A framed card given no children is its title row alone, such as a question with its answer buttons in `extra`. _Key props:_ `variant` (`CardVariant`: `default` | `framed`), `tone` (`CardTone`, framed only), `title`, `subtitle`, `extra`, `wrapExtra`, `padding`, `footer`.
15
+ - **`TileGrid`** — Tiles side by side, as many to a row as fit at 140px each, wrapping below that: a short set of things to pick from, such as AI clients. Each `TileGrid.Tile` is a decorative `icon` such as a logo, then its `title`, then a `description` that wraps rather than being cut, with no action label: the whole tile is one button, or an anchor with `href` (an unsafe scheme is dropped), named by its title and described by its description. `variant="more"` is a dashed tile on the sunken ground for a "See all" that leads past the grid. Name it with `aria-label` or `aria-labelledby` to make it a group. For one card that opens more detail beside its text use `LinkCard`; to choose one option use `ChoiceGroup`. _Key props:_ `aria-label`, `aria-labelledby`, `className`. `TileGrid.Tile`: `title`, `description`, `icon`, `variant` (`TileVariant`: `default` | `more`), `onClick`, `href`, `className`.
15
16
  - **`LinkCard`** — A compact card that opens more about one thing elsewhere on the screen, such as another tab of a side panel: an optional icon, a title coloured by `tone`, a one-line description cut with an ellipsis, optional `trailing` content such as a level scale, and an accent “Open →”. The whole card is one button, or an anchor with `href` (an unsafe scheme such as `javascript:` is dropped); with neither `onClick` nor a safe `href` it is a static card without the action. Tone is colour alone, so the title has to say the outcome. For a resource in a new tab use `ResourceCard`; for a row in a list use `Surface.Row`. _Key props:_ `title`, `description`, `tone` (`LinkCardTone`: `neutral` | `success` | `warning` | `error`), `icon`, `trailing` (both decorative; `trailing` sits inside the control, so never interactive), `actionLabel` (default `Open`), `onClick`, `href`, `className`.
16
17
  - **`ResourceCard`** — A card pointing at a resource elsewhere, such as an SDK’s documentation: a muted icon tile, a title, a description clamped to two lines and a link that opens in a new tab. `ResourceCard.Header` is the icon, title and description on their own, all phrasing content, so a section that opens on them, such as an `Accordion` header, can use it inside its button. _Key props:_ `icon`, `title`, `description`, `href`, `linkLabel` (default `Documentation`), `titleAs` (`h3` | `h4`), `className`. `ResourceCard.Header`: `icon`, `title`, `description`; phrasing content only, so its title is never a heading.
17
18
  - **`SelectableCard`** — A card that is one option in a radio group — eyebrow, optional status tag, title, description, a count label and a top-right action slot. Use inside a `CardStrip`. Selection is controlled by the consumer: pass `selected`, which drives both the visual treatment and `aria-checked`. A selected card meets the sheet below the way a browser tab meets its toolbar — its bottom corners flare outward onto the strip’s rule — so its outline is one SVG path rather than borders, which would split into two lines at the tangent. `variant` picks the palette: `profile` (green), `library` (neutral) or `editing` (amber, for a profile with unsaved changes). `actions` stands in the card’s top-right corner, on the eyebrow row, and renders outside the control so a menu or icon button inside it stays clickable and keeps its own tab stop. Nothing else marks that corner: the flared outline, the tint and the green eyebrow already say which card is selected, so a radio there would only repeat them. `onDismiss` adds an x after `actions`, tinted like the eyebrow so it reads as part of the card — for discarding a draft card; `dismissDisabledReason` disables it and explains why in its tooltip. `isDefault` marks the card as the account default with a pin beside the title, named for assistive tech and tooltipped for everyone else — it belongs with the name it qualifies rather than among the actions, which read as things to press. `address` puts a one-line chip above the count for a copyable address such as a server URL: its `label` is cut short with an ellipsis, and its full `value` shows in a tooltip and is copied on click, without selecting the card. It takes the place of `description`, since the card has room for one or the other. For a row-shaped selectable use `Surface.Row` instead. _Key props:_ `value`, `title`, `titleIcon`, `isDefault`, `variant` (`profile` | `library` | `editing`), `eyebrow`, `status` (`label`, `type`, `tooltip`), `description`, `address` (`label`, `value`), `countLabel`, `actions`, `onDismiss` (`dismissLabel`, `dismissDisabledReason`), `selected`, `loading` (`loadingLabel`, `loadingHint`), `disabled`, `dimmed`, `onSelect`, `tabIndex`, `aria-label`, `className`, `style`.
@@ -82,7 +83,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
82
83
  - **`DateRangePicker`** — `DatePicker`'s range form, with the same props and a `{ start, end }` value. The second click completes a day range; a click before the start restarts it. The end always covers the whole of its last unit (`23:59:59.999` for a picked day, the last millisecond of the picked minute or second), so a filter on the range keeps its final minutes. In a `formControl` field a cleared range writes `null`. With a time precision a Start/End switch picks which end the time columns edit, end times before the start are not offered, and Apply waits for both ends. `presets` list beside the calendar and apply at once; pass a function (`value: () => ({ start, end })`) for a relative preset such as "Past 1 hour", so it is measured when clicked rather than when the page loaded. A preset with `disabled: true` stays visible and focusable but cannot resolve or commit a value, for plan-locked ranges; `disabledReason` explains why in a tooltip and as its accessible description. _Key props:_ `value` / `defaultValue` (`{ start, end }`), `onChange`, `presets` (`DateRangePreset[]`), plus every `DatePicker` prop.
83
84
  - **`MultiSelect`** — Multi-select dropdown. `width` fixes the trigger, as `Dropdown` and `Search` take it, so a toolbar can put its controls on one width — and, as with those two, a container narrower than the value still wins; the menu fills the trigger and left-aligns under it, so that one prop sizes both; `minWidth` raises the 160px floor a narrow trigger falls back to. An option label too long for the menu ellipsises, and hovering it shows the full label — above the description in `hover` mode — as `Dropdown` does for its options. `requiredIndicator` follows the same three-way convention the single-select controls do, so a form choosing asterisks does not get "(Optional)" on one of its fields. _Key props:_ `MultiSelectOption[]`, `MultiSelectSize`, `width`, `minWidth`, `label`, `searchable`, `inlineSearch`, `chips`, `chipsRemovable`, `required`, `requiredIndicator`, `aria-label`, `aria-labelledby`, `id`.
84
85
  - **`FilterSearch`** — One search field that filters across several categories. Clicking lists the filters, each with its description and an example; picking one lists its values behind a `Filters > Name` breadcrumb, and typing before picking searches the values of every filter at once, tagging each match with the filter it belongs to. Select All / Deselect All act on whatever the query matches. Each filter becomes a segmented chip, its name then its values (`Connector | Notion, Attio +2`), that reopens its values when clicked; an item `icon` is drawn in its menu row and in the chip, and `chipLabel: false` on a filter drops its name from the chip (`Configured only`); Backspace in an empty field removes the last one. `onQueryChange` reports the text in the field, for analytics or a server-side search. With `textFilter` (`{ value, label }`, under a `value` no filter uses) the typed text is itself the first row while searching (`Search "acme"`); committing it adds a `Search: acme` chip whose selection is `{ filter: textFilter.value, items: [text] }`, replacing any earlier text, so a free-text search can sit in the URL beside the filters, and clicking that chip puts the text back in the field. Controlled: `onChange` gets the next selection and the `changes` that produced it, an empty `items` meaning the filter was removed, so a URL-backed selection writes back only what moved. Chips keep the order filters were added in even when `value` comes back reordered, and keep their labels while `filters` reloads. `filtersButton` puts a Filters button, with the applied count, at the right end of the bar that opens a Filters panel beneath it: every filter at once, each drawn by its `control` (`list`, the default, a checkbox per value with an optional `count` badge and a search box past 8 values; `toggle`, a switch for the filter's one value; `segmented`, All plus one segment per value), applied as they change and mirrored as chips in the bar, with Clear all leaving the typed text alone. The button and the filter chips are then the only way to filters: the field is a plain search box (`role="searchbox"`) that never opens a menu, reports what is typed through `onQueryChange`, keeps it on blur and while the panel is open, and pins it as the `textFilter` chip on Enter. _Key props:_ `filters` (`control`, item `count`), `value`, `onChange`, `onClear`, `onActiveFilterChange`, `onQueryChange`, `textFilter`, `filtersButton`, `placeholder`, `size`, `width`, `loading`, `disabled`, `clearable`, `maxVisibleChips`, `aria-label`, `aria-labelledby`, `id`.
85
- - **`QueryInput`** — A textbox with inline syntax colouring and a suggestion menu anchored to the caret. It carries no grammar of its own: the consumer parses the value, hands back `tokens` to colour and `suggestions` to offer, so the vocabulary lives in the consuming app rather than here. _Key props:_ `value`, `onChange`, `tokens`, `suggestions`, `activeRange`, `onAccept`, `onQueryContextChange`, `onSubmit`, `placeholder`, `size`, `disabled`, `loading`, `emptyMessage`, `className`, `style`, `aria-label`, `aria-labelledby`.
86
+ - **`QueryInput`** — A textbox with inline syntax colouring and a suggestion menu anchored to the caret. It carries no grammar of its own: the consumer parses the value, hands back `tokens` to colour and `suggestions` to offer, so the vocabulary lives in the consuming app rather than here. Committed clauses can sit in the bar as removable chips before the text (a logs filter bar), with a leading search icon and a Clear All; the bar wraps and grows to hold them. _Key props:_ `value`, `onChange`, `tokens`, `suggestions` (`{id, label, description?, detail?, insertText?}`), `activeRange`, `onAccept`, `onQueryContextChange`, `onSubmit`, `chips` (`{id, label, operator, value, tone?: include | exclude | invalid, tooltip?}`), `onChipRemove` (also Backspace in an empty field), `onClear`, `searchIcon`, `menuTitle`, `menuHints` (`{keys, label}[]`), `placeholder`, `size`, `disabled`, `loading`, `emptyMessage`, `className`, `style`, `aria-label`, `aria-labelledby`.
86
87
  - **`DividerToggle`** — A line divider with a toggle pill in the middle to expand/collapse an optional section below it. _Key props:_ `label`, `expandedLabel`, `expanded`, `onToggle`, `aria-controls`, `className`.
87
88
  - **`FormSteps`** — A vertical list of steps. Renders each step as a list item with its title, optional action, and children below. Offers `form` (lettered markers, descriptions) and `review` (numbered steps, compact lists) variants. _Key props:_ `items` (`key`, `title`, `description`, `action`, `children`), `variant` (`review` | `form`), `marker`, `className`, `aria-label`, `aria-labelledby`.
88
89
  - **`SettingRow`** — One setting: a labelled row with its control on the trailing edge, and the sentence that explains it underneath. `control` may be a render prop receiving the label’s id, so a control that no `<label htmlFor>` can reach — `Toggle` renders a `<button role="switch">` — still names itself via `aria-labelledby`. _Key props:_ `label`, `badge`, `description`, `control`, `className`.
@@ -1,65 +1,59 @@
1
- import { jsxs as c, Fragment as C, jsx as e } from "react/jsx-runtime";
2
- import { useId as R, useState as E } from "react";
1
+ import { jsxs as i, Fragment as R, jsx as e } from "react/jsx-runtime";
2
+ import { useId as E, useState as C } from "react";
3
3
  import L from "./CustomIcons/ForwardArrowIcon.js";
4
4
  import O from "./TruncatedTooltip.js";
5
- import b from "./Typography/Text.js";
5
+ import u from "./Typography/Text.js";
6
6
  import { getFontSize as A, getTextColor as F } from "./Typography/textStyles.js";
7
- import { ROW_HOVER as _ } from "./chromeStyles.js";
8
- import { devWarning as z } from "./devWarning.js";
9
- import { FOCUS_RING as W, isFocusVisible as D } from "./focusRing.js";
10
- import { isRenderableNode as g } from "./renderableNode.js";
11
- import { safeHref as V } from "./safeHref.js";
12
- const j = {
7
+ import { cardHref as _ } from "./cardHref.js";
8
+ import { ROW_HOVER as z } from "./chromeStyles.js";
9
+ import { FOCUS_RING as D, isFocusVisible as V } from "./focusRing.js";
10
+ import { isRenderableNode as b } from "./renderableNode.js";
11
+ const W = {
13
12
  neutral: "primary",
14
13
  success: "success",
15
14
  warning: "warning",
16
15
  error: "error"
17
- }, d = "flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline", v = `cursor-pointer ${_} hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] ${W}`, k = {
16
+ }, c = "flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline", g = `cursor-pointer ${z} hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] ${D}`, j = {
18
17
  color: F("secondary"),
19
18
  fontSize: A("xsmall")
20
- }, Z = ({
21
- title: $,
19
+ }, M = ({
20
+ title: w,
22
21
  description: r,
23
- tone: w = "neutral",
24
- icon: m,
25
- trailing: f,
26
- actionLabel: N = "Open",
22
+ tone: v = "neutral",
23
+ icon: d,
24
+ trailing: m,
25
+ actionLabel: $ = "Open",
27
26
  onClick: a,
28
- href: n,
29
- className: o = ""
27
+ href: N,
28
+ className: n = ""
30
29
  }) => {
31
- const t = V(n);
32
- n && !t && z(
33
- `LinkCard.href:${n}`,
34
- `LinkCard dropped the unsafe href "${n}"; without an onClick it is a static card.`
35
- );
36
- const y = !!(t || a), i = R(), p = `${i}-title`, h = `${i}-description`, x = `${i}-action`, [S, s] = E(!1), T = {
37
- onFocus: (I) => s(D(I.currentTarget, !1)),
38
- onPointerDown: () => s(!1),
39
- onBlur: () => s(!1)
40
- }, u = {
41
- "aria-labelledby": `${p} ${x}`,
42
- "aria-describedby": r ? h : void 0,
30
+ const t = _("LinkCard", "card", N), y = !!(t || a), o = E(), f = `${o}-title`, p = `${o}-description`, x = `${o}-action`, [S, l] = C(!1), T = {
31
+ onFocus: (I) => l(V(I.currentTarget, !1)),
32
+ onPointerDown: () => l(!1),
33
+ onBlur: () => l(!1)
34
+ }, h = {
35
+ "aria-labelledby": `${f} ${x}`,
36
+ "aria-describedby": r ? p : void 0,
43
37
  ...T
44
- }, l = /* @__PURE__ */ c(C, { children: [
45
- g(m) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: m }),
46
- /* @__PURE__ */ c("span", { className: "flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]", children: [
47
- /* @__PURE__ */ e("span", { id: p, className: "flex min-w-0 [overflow-wrap:anywhere]", children: /* @__PURE__ */ e(
48
- b,
38
+ }, s = /* @__PURE__ */ i(R, { children: [
39
+ b(d) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: d }),
40
+ /* @__PURE__ */ i("span", { className: "flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]", children: [
41
+ /* @__PURE__ */ e("span", { id: f, className: "flex min-w-0 [overflow-wrap:anywhere]", children: /* @__PURE__ */ e(
42
+ u,
49
43
  {
50
44
  size: "small",
51
45
  fontWeight: "bold",
52
- color: j[w],
46
+ color: W[v],
53
47
  className: "min-w-0 leading-[17px]",
54
- children: $
48
+ children: w
55
49
  }
56
50
  ) }),
57
51
  r && /* @__PURE__ */ e(
58
52
  "span",
59
53
  {
60
- id: h,
54
+ id: p,
61
55
  className: "flex min-w-0 [overflow-wrap:anywhere]",
62
- style: k,
56
+ style: j,
63
57
  children: S ? r : /* @__PURE__ */ e(
64
58
  O,
65
59
  {
@@ -73,9 +67,9 @@ const j = {
73
67
  }
74
68
  )
75
69
  ] }),
76
- g(f) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: f }),
77
- y && /* @__PURE__ */ c("span", { className: "flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]", children: [
78
- /* @__PURE__ */ e("span", { id: x, className: "flex", children: /* @__PURE__ */ e(b, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", wrap: !1, children: N }) }),
70
+ b(m) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: m }),
71
+ y && /* @__PURE__ */ i("span", { className: "flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]", children: [
72
+ /* @__PURE__ */ e("span", { id: x, className: "flex", children: /* @__PURE__ */ e(u, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", wrap: !1, children: $ }) }),
79
73
  /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex", children: /* @__PURE__ */ e(L, { size: 12 }) })
80
74
  ] })
81
75
  ] });
@@ -84,23 +78,23 @@ const j = {
84
78
  {
85
79
  href: t,
86
80
  onClick: a,
87
- ...u,
88
- className: `${d} ${v} ${o}`,
89
- children: l
81
+ ...h,
82
+ className: `${c} ${g} ${n}`,
83
+ children: s
90
84
  }
91
85
  ) : a ? /* @__PURE__ */ e(
92
86
  "button",
93
87
  {
94
88
  type: "button",
95
89
  onClick: a,
96
- ...u,
97
- className: `m-0 appearance-none font-[inherit] ${d} ${v} ${o}`,
98
- children: l
90
+ ...h,
91
+ className: `m-0 appearance-none font-[inherit] ${c} ${g} ${n}`,
92
+ children: s
99
93
  }
100
- ) : /* @__PURE__ */ e("div", { className: `${d} ${o}`, children: l });
94
+ ) : /* @__PURE__ */ e("div", { className: `${c} ${n}`, children: s });
101
95
  };
102
96
  export {
103
- Z as LinkCard,
104
- Z as default
97
+ M as LinkCard,
98
+ M as default
105
99
  };
106
100
  //# sourceMappingURL=LinkCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LinkCard.js","sources":["../../src/components/LinkCard.tsx"],"sourcesContent":["import type React from 'react';\nimport { useId, useState } from 'react';\nimport ForwardArrowIcon from './CustomIcons/ForwardArrowIcon';\nimport TruncatedTooltip from './TruncatedTooltip';\nimport Text from './Typography/Text';\nimport { getFontSize, getTextColor } from './Typography/textStyles';\nimport { ROW_HOVER } from './chromeStyles';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING, isFocusVisible } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { safeHref } from './safeHref';\n\nexport type LinkCardTone = 'neutral' | 'success' | 'warning' | 'error';\n\nexport interface LinkCardProps {\n title: string;\n /** One line under the title; shown in full on hover, or when a clickable card takes keyboard focus. */\n description?: string;\n /** Colours the title. */\n tone?: LinkCardTone;\n /**\n * Decorative, before the title. Paths are filled with `currentColor`, so colour one through\n * `color`, as `Hexagon` does; a path keeping its own `fill` needs `data-malachite-shape`.\n */\n icon?: React.ReactNode;\n /** Decorative content before the action, e.g. a level scale. Must not be interactive. */\n trailing?: React.ReactNode;\n actionLabel?: string;\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Renders a link instead of a button; unsafe schemes are dropped. */\n href?: string;\n className?: string;\n}\n\nconst TITLE_COLOR = {\n neutral: 'primary',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\n\nconst CARD_CLASSES =\n 'flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline';\n\nconst INTERACTIVE_CLASSES = `cursor-pointer ${ROW_HOVER} hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] ${FOCUS_RING}`;\n\nconst DESCRIPTION_STYLE: React.CSSProperties = {\n color: getTextColor('secondary'),\n fontSize: getFontSize('xsmall'),\n};\n\n/** A compact card that opens more detail elsewhere, such as another tab of a panel. */\nconst LinkCard: React.FC<LinkCardProps> = ({\n title,\n description,\n tone = 'neutral',\n icon,\n trailing,\n actionLabel = 'Open',\n onClick,\n href: rawHref,\n className = '',\n}) => {\n const href = safeHref(rawHref);\n if (rawHref && !href) {\n devWarning(\n `LinkCard.href:${rawHref}`,\n `LinkCard dropped the unsafe href \"${rawHref}\"; without an onClick it is a static card.`,\n );\n }\n const interactive = Boolean(href || onClick);\n const id = useId();\n const titleId = `${id}-title`;\n const descriptionId = `${id}-description`;\n const actionId = `${id}-action`;\n const [revealed, setRevealed] = useState(false);\n const reveal = {\n onFocus: (event: React.FocusEvent<HTMLElement>) =>\n setRevealed(isFocusVisible(event.currentTarget, false)),\n onPointerDown: () => setRevealed(false),\n onBlur: () => setRevealed(false),\n };\n const labelling = {\n 'aria-labelledby': `${titleId} ${actionId}`,\n 'aria-describedby': description ? descriptionId : undefined,\n ...reveal,\n };\n const body = (\n <>\n {isRenderableNode(icon) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {icon}\n </span>\n )}\n <span className=\"flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]\">\n <span id={titleId} className=\"flex min-w-0 [overflow-wrap:anywhere]\">\n <Text\n size=\"small\"\n fontWeight=\"bold\"\n color={TITLE_COLOR[tone]}\n className=\"min-w-0 leading-[17px]\"\n >\n {title}\n </Text>\n </span>\n {description && (\n <span\n id={descriptionId}\n className=\"flex min-w-0 [overflow-wrap:anywhere]\"\n style={DESCRIPTION_STYLE}\n >\n {revealed ? (\n description\n ) : (\n <TruncatedTooltip\n text={description}\n delay={1}\n triggerAs=\"span\"\n describesTrigger={false}\n >\n {description}\n </TruncatedTooltip>\n )}\n </span>\n )}\n </span>\n {isRenderableNode(trailing) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {trailing}\n </span>\n )}\n {interactive && (\n <span className=\"flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]\">\n <span id={actionId} className=\"flex\">\n <Text size=\"xsmall\" fontWeight=\"semi-bold\" color=\"inherit\" wrap={false}>\n {actionLabel}\n </Text>\n </span>\n <span aria-hidden=\"true\" className=\"flex\">\n <ForwardArrowIcon size={12} />\n </span>\n </span>\n )}\n </>\n );\n if (href) {\n return (\n <a\n href={href}\n onClick={onClick}\n {...labelling}\n className={`${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </a>\n );\n }\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n {...labelling}\n className={`m-0 appearance-none font-[inherit] ${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </button>\n );\n }\n return <div className={`${CARD_CLASSES} ${className}`}>{body}</div>;\n};\n\nexport default LinkCard;\nexport { LinkCard };\n"],"names":["TITLE_COLOR","CARD_CLASSES","INTERACTIVE_CLASSES","ROW_HOVER","FOCUS_RING","DESCRIPTION_STYLE","getTextColor","getFontSize","LinkCard","title","description","tone","icon","trailing","actionLabel","onClick","rawHref","className","href","safeHref","devWarning","interactive","id","useId","titleId","descriptionId","actionId","revealed","setRevealed","useState","reveal","event","isFocusVisible","labelling","body","jsxs","Fragment","isRenderableNode","jsx","Text","TruncatedTooltip","ForwardArrowIcon"],"mappings":";;;;;;;;;;;AAkCA,MAAMA,IAAc;AAAA,EAChB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAEMC,IACF,kTAEEC,IAAsB,kBAAkBC,CAAS,4EAA4EC,CAAU,IAEvIC,IAAyC;AAAA,EAC3C,OAAOC,EAAa,WAAW;AAAA,EAC/B,UAAUC,EAAY,QAAQ;AAClC,GAGMC,IAAoC,CAAC;AAAA,EACvC,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,SAAAC;AAAA,EACA,MAAMC;AAAA,EACN,WAAAC,IAAY;AAChB,MAAM;AACF,QAAMC,IAAOC,EAASH,CAAO;AAC7B,EAAIA,KAAW,CAACE,KACZE;AAAA,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EjB,UAAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACL;AAAA,MAAA;AAAA,IAER,GAER;AAAA,IACC2B,EAAiBxB,CAAQ,KACtB,gBAAAyB,EAAC,UAAK,eAAY,QAAO,WAAU,+BAC9B,UAAAzB,EAAA,CACL;AAAA,IAEHQ,KACG,gBAAAc,EAAC,QAAA,EAAK,WAAU,iGACZ,UAAA;AAAA,MAAA,gBAAAG,EAAC,UAAK,IAAIZ,GAAU,WAAU,QAC1B,4BAACa,GAAA,EAAK,MAAK,UAAS,YAAW,aAAY,OAAM,WAAU,MAAM,IAC5D,aACL,GACJ;AAAA,MACA,gBAAAD,EAAC,QAAA,EAAK,eAAY,QAAO,WAAU,QAC/B,UAAA,gBAAAA,EAACG,GAAA,EAAiB,MAAM,GAAA,CAAI,EAAA,CAChC;AAAA,IAAA,EAAA,CACJ;AAAA,EAAA,GAER;AAEJ,SAAIvB,IAEI,gBAAAoB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAApB;AAAA,MACA,SAAAH;AAAA,MACC,GAAGkB;AAAA,MACJ,WAAW,GAAGhC,CAAY,IAAIC,CAAmB,IAAIe,CAAS;AAAA,MAE7D,UAAAiB;AAAA,IAAA;AAAA,EAAA,IAITnB,IAEI,gBAAAuB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,SAAAvB;AAAA,MACC,GAAGkB;AAAA,MACJ,WAAW,sCAAsChC,CAAY,IAAIC,CAAmB,IAAIe,CAAS;AAAA,MAEhG,UAAAiB;AAAA,IAAA;AAAA,EAAA,IAIN,gBAAAI,EAAC,SAAI,WAAW,GAAGrC,CAAY,IAAIgB,CAAS,IAAK,UAAAiB,EAAA,CAAK;AACjE;"}
1
+ {"version":3,"file":"LinkCard.js","sources":["../../src/components/LinkCard.tsx"],"sourcesContent":["import type React from 'react';\nimport { useId, useState } from 'react';\nimport ForwardArrowIcon from './CustomIcons/ForwardArrowIcon';\nimport TruncatedTooltip from './TruncatedTooltip';\nimport Text from './Typography/Text';\nimport { getFontSize, getTextColor } from './Typography/textStyles';\nimport { cardHref } from './cardHref';\nimport { ROW_HOVER } from './chromeStyles';\nimport { FOCUS_RING, isFocusVisible } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\n\nexport type LinkCardTone = 'neutral' | 'success' | 'warning' | 'error';\n\nexport interface LinkCardProps {\n title: string;\n /** One line under the title; shown in full on hover, or when a clickable card takes keyboard focus. */\n description?: string;\n /** Colours the title. */\n tone?: LinkCardTone;\n /**\n * Decorative, before the title. Paths are filled with `currentColor`, so colour one through\n * `color`, as `Hexagon` does; a path keeping its own `fill` needs `data-malachite-shape`.\n */\n icon?: React.ReactNode;\n /** Decorative content before the action, e.g. a level scale. Must not be interactive. */\n trailing?: React.ReactNode;\n actionLabel?: string;\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Renders a link instead of a button; unsafe schemes are dropped. */\n href?: string;\n className?: string;\n}\n\nconst TITLE_COLOR = {\n neutral: 'primary',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\n\nconst CARD_CLASSES =\n 'flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline';\n\nconst INTERACTIVE_CLASSES = `cursor-pointer ${ROW_HOVER} hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] ${FOCUS_RING}`;\n\nconst DESCRIPTION_STYLE: React.CSSProperties = {\n color: getTextColor('secondary'),\n fontSize: getFontSize('xsmall'),\n};\n\n/** A compact card that opens more detail elsewhere, such as another tab of a panel. */\nconst LinkCard: React.FC<LinkCardProps> = ({\n title,\n description,\n tone = 'neutral',\n icon,\n trailing,\n actionLabel = 'Open',\n onClick,\n href: rawHref,\n className = '',\n}) => {\n const href = cardHref('LinkCard', 'card', rawHref);\n const interactive = Boolean(href || onClick);\n const id = useId();\n const titleId = `${id}-title`;\n const descriptionId = `${id}-description`;\n const actionId = `${id}-action`;\n const [revealed, setRevealed] = useState(false);\n const reveal = {\n onFocus: (event: React.FocusEvent<HTMLElement>) =>\n setRevealed(isFocusVisible(event.currentTarget, false)),\n onPointerDown: () => setRevealed(false),\n onBlur: () => setRevealed(false),\n };\n const labelling = {\n 'aria-labelledby': `${titleId} ${actionId}`,\n 'aria-describedby': description ? descriptionId : undefined,\n ...reveal,\n };\n const body = (\n <>\n {isRenderableNode(icon) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {icon}\n </span>\n )}\n <span className=\"flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]\">\n <span id={titleId} className=\"flex min-w-0 [overflow-wrap:anywhere]\">\n <Text\n size=\"small\"\n fontWeight=\"bold\"\n color={TITLE_COLOR[tone]}\n className=\"min-w-0 leading-[17px]\"\n >\n {title}\n </Text>\n </span>\n {description && (\n <span\n id={descriptionId}\n className=\"flex min-w-0 [overflow-wrap:anywhere]\"\n style={DESCRIPTION_STYLE}\n >\n {revealed ? (\n description\n ) : (\n <TruncatedTooltip\n text={description}\n delay={1}\n triggerAs=\"span\"\n describesTrigger={false}\n >\n {description}\n </TruncatedTooltip>\n )}\n </span>\n )}\n </span>\n {isRenderableNode(trailing) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {trailing}\n </span>\n )}\n {interactive && (\n <span className=\"flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]\">\n <span id={actionId} className=\"flex\">\n <Text size=\"xsmall\" fontWeight=\"semi-bold\" color=\"inherit\" wrap={false}>\n {actionLabel}\n </Text>\n </span>\n <span aria-hidden=\"true\" className=\"flex\">\n <ForwardArrowIcon size={12} />\n </span>\n </span>\n )}\n </>\n );\n if (href) {\n return (\n <a\n href={href}\n onClick={onClick}\n {...labelling}\n className={`${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </a>\n );\n }\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n {...labelling}\n className={`m-0 appearance-none font-[inherit] ${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </button>\n );\n }\n return <div className={`${CARD_CLASSES} ${className}`}>{body}</div>;\n};\n\nexport default LinkCard;\nexport { LinkCard };\n"],"names":["TITLE_COLOR","CARD_CLASSES","INTERACTIVE_CLASSES","ROW_HOVER","FOCUS_RING","DESCRIPTION_STYLE","getTextColor","getFontSize","LinkCard","title","description","tone","icon","trailing","actionLabel","onClick","rawHref","className","href","cardHref","interactive","id","useId","titleId","descriptionId","actionId","revealed","setRevealed","useState","reveal","event","isFocusVisible","labelling","body","jsxs","Fragment","isRenderableNode","jsx","Text","TruncatedTooltip","ForwardArrowIcon"],"mappings":";;;;;;;;;;AAiCA,MAAMA,IAAc;AAAA,EAChB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAEMC,IACF,kTAEEC,IAAsB,kBAAkBC,CAAS,4EAA4EC,CAAU,IAEvIC,IAAyC;AAAA,EAC3C,OAAOC,EAAa,WAAW;AAAA,EAC/B,UAAUC,EAAY,QAAQ;AAClC,GAGMC,IAAoC,CAAC;AAAA,EACvC,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,SAAAC;AAAA,EACA,MAAMC;AAAA,EACN,WAAAC,IAAY;AAChB,MAAM;AACF,QAAMC,IAAOC,EAAS,YAAY,QAAQH,CAAO,GAC3CI,IAAc,GAAQF,KAAQH,IAC9BM,IAAKC,EAAA,GACLC,IAAU,GAAGF,CAAE,UACfG,IAAgB,GAAGH,CAAE,gBACrBI,IAAW,GAAGJ,CAAE,WAChB,CAACK,GAAUC,CAAW,IAAIC,EAAS,EAAK,GACxCC,IAAS;AAAA,IACX,SA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