@stackone/malachite 2.99.2 → 2.100.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 +3 -1
- package/dist/components/CodePreview.js +142 -0
- package/dist/components/CodePreview.js.map +1 -0
- package/dist/components/LinkCard.js +83 -0
- package/dist/components/LinkCard.js.map +1 -0
- package/dist/components/Timeline.js +65 -31
- package/dist/components/Timeline.js.map +1 -1
- package/dist/index.d.ts +53 -0
- package/dist/index.js +480 -476
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/dist/theme.js +1 -1
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
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. `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. `dimmed`, `border`, `size`, `glassFooter` and `headerConfig` do not apply to a framed card. _Key props:_ `variant` (`CardVariant`: `default` | `framed`), `title`, `subtitle`, `extra`, `padding`, `footer`.
|
|
15
|
+
- **`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`.
|
|
15
16
|
- **`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.
|
|
16
17
|
- **`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`.
|
|
17
18
|
- **`CardStrip`** — Horizontally scrolling radio group of cards, with edge arrows that appear only when the content overflows, an edge fade, scroll-snap and arrow-key navigation matching `SegmentedControl`. Owns interaction only: it finds its options by looking for `role="radio"` descendants carrying `data-value`, so any such child works (`SelectableCard` emits both). Pass a non-selectable terminal tile as `CardStrip.AddTile` — it sits inside the group but outside the radio set, and must be a direct child or it scrolls with the cards. Use `leading` to pin a card that should not scroll away; the strip tells the cards which slot they are in, so a pinned `SelectableCard` drops the left rule the scrolling ones draw. A strip too narrow to show a card beside `leading` scrolls it with the cards rather than squeezing them, so the selected card always has its full width. Set `bleed` when the strip sits in a `PageLayout`: the strip stretches past the horizontal padding of the layout so its bottom rule runs the full width of the page card, while the cards stay aligned to the gutter. With no cards at all the strip degenerates to its pinned slots alone — no trough, no scroller and no arrows — with the add tile standing beside `leading` and taking `primary` emphasis automatically, since adding the first card is the only thing on offer. _Key props:_ `value`, `tone` (`profile` | `library` | `editing` — read off the selected card unless set), `onChange`, `children`, `leading`, `arrows`, `fadeEdges`, `snap`, `bleed`, `scrollSelectedIntoView`, `aria-label`, `aria-labelledby`, `className`, `style`. `CardStrip.AddTile`: `label`, `icon`, `onClick`, `disabled`, `emphasis` (`primary` | `secondary` — left to the strip unless set: `primary` while there are no cards, `secondary` once there are), `className`.
|
|
@@ -117,7 +118,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
117
118
|
- **`LevelMeter`** — Rising bars, shortest first, that picture how much of a scale is on — an access level in a level menu or on a level chip. Each step is `on` (a solid accent-green bar), `partial` (a green outline over a faint tint, for a step only some of whose actions are on) or `off` (an empty grey outline); every step keeps 3:1 against the surface, and colours come from the theme. Styled inline so it still draws inside an `ActionMenu`, which portals outside the shadow root and its stylesheet. Beside text that already names the level it is decorative and hidden from assistive tech; give it a `label` only when it stands alone and it reads as an image of that name. As an `ActionMenu` item `icon` or a `Button` `icon`, leave `label` off: the icon joins the item name, and the text already says the level. _Key props:_ `steps` (`LevelMeterStep[]`: `on` | `partial` | `off`), `label`, `className`.
|
|
118
119
|
- **`TimeBarChart`** — Counts per time bucket as stacked bars on a UTC axis, the request-volume chart above a log list. Every bucket in `range` takes a slot whether or not it has data, so gaps read as gaps; a zone-less time string is read as UTC. Hover or arrow-key through buckets for a tooltip listing every series and the total; `highlightTime` shades the bucket holding a time from elsewhere on the page, such as the hovered log row. With `onRangeSelect`, dragging across bars reports the whole buckets covered, `end` exclusive so it goes straight back in as `range`, and whether the selection takes in the last bucket. `loading` dims bars already drawn rather than replacing them, and shows a spinner only when there is nothing to dim. Series colours follow the theme’s status tokens by `tone`, and failures always stack above successes whatever order `series` comes in, so position separates them where colour alone might not; a legend names them unless `legend={false}`. A visually hidden table carries the same numbers for screen readers. _Key props:_ `series` (`{ key, label, tone }[]`, stacked by tone with `error` on top; `TimeBarChartTone`: `success` | `error` | `neutral`), `buckets` (`{ start, values }[]`), `interval` (`{ unit, step }`; `TimeBarChartUnit`: `minute` | `hour` | `day` | `week` | `month`), `range` (`end` exclusive, as a selection reports it; at most 2,000 buckets, the newest kept), `TimeBarChartSize` (`small` | `medium` | `large`), `loading`, `error`, `errorTitle`, `errorSubTitle`, `valueLabel`, `legend`, `highlightTime`, `onRangeSelect`, `aria-label`, `aria-labelledby`, `className`, `style`.
|
|
119
120
|
- **`TimeBarChartSwatch`** — The mark a `TimeBarChart` draws a series in, by its `tone`, for naming the series somewhere other than the chart's legend, such as a count beside the chart standing in for it. It matches the legend and the tooltip, and the bars draw the same colour at 40%; it follows the theme with them. Decorative: the label beside it does the naming. _Key props:_ `tone` (`TimeBarChartTone`).
|
|
120
|
-
- **`Timeline`** — A vertical sequence of steps as an ordered list (`Timeline.Item`): a dot on a connecting line, a title, its timing at the right and a free-form body below, such as what happened to one API call. The dot is painted by `tone` from the theme’s text tokens (`neutral` is secondary text, the rest their status colours), or replaced by a decorative `marker` such as the caller’s logo. `stopped` puts an error badge (`stoppedLabel`, default "Stopped here") after the title of the step a flow ended on and paints its dot `error` unless a `tone` is set; the line ends at the last item. For steps a person works through (complete, open, locked) use `StepList`. _Key props:_ `aria-label`, `aria-labelledby`; on `Timeline.Item`: `title`, `time`, `tone` (`TimelineTone`: `neutral` | `info` | `success` | `warning` | `error`), `marker` (fills the 24px circle in place of the ringed dot), `stopped`, `stoppedLabel
|
|
121
|
+
- **`Timeline`** — A vertical sequence of steps as an ordered list (`Timeline.Item`): a dot on a connecting line, a title, its timing at the right and a free-form body below, such as what happened to one API call. The dot is painted by `tone` from the theme’s text tokens (`neutral` is secondary text, the rest their status colours), or replaced by a decorative `marker` such as the caller’s logo. `stopped` puts an error badge (`stoppedLabel`, default "Stopped here") after the title of the step a flow ended on and paints its dot `error` unless a `tone` is set; the line ends at the last item. `meta` puts facts about a step in one wrapping row under its title, such as `calls` 2 and `status` 200, each label secondary and its value in the mono face, 18px apart, as a `dl`. `skipped` marks a step that never ran with a grey chevron in place of the dot; the title has to say so. For steps a person works through (complete, open, locked) use `StepList`. _Key props:_ `aria-label`, `aria-labelledby`; on `Timeline.Item`: `title`, `time`, `tone` (`TimelineTone`: `neutral` | `info` | `success` | `warning` | `error`), `marker` (fills the 24px circle in place of the ringed dot), `skipped`, `stopped`, `stoppedLabel`, `meta` (`TimelineMetaEntry[]`: `label`, `value`).
|
|
121
122
|
- **`Table`** — Data table with columns, sizing, pagination and row selection. `column.align` places a column's header as well as its cells. What lands on the aligned edge is the last thing in the header row rather than the title: the sort caret on a sortable column, the info icon on one carrying `info` without a sorter. `headerVariant` picks the header layout, and only `inline` lines header and body up exactly, because both are cells of one `<table>`. `detached` builds them from flex rows, where a sortable header cell is 32px narrower than a non-sortable one — its padding sits on the inner button rather than on the flex item — so its header cells sit 15–17px off their column at any alignment; reach for `inline` where exact alignment matters. Sorting is internal, so the array passed as `data` is not the order rendered once a column is sorted: `onVisibleOrderChange` reports the rows in render order — the whole of `data`, compared by `rowKey` so an equal order never re-fires — for a consumer stepping a master-detail view the way the user sees it. On the detached header, `title`, `subtitle` and `extra` add a title row on the frame above the column headers, the row a `framed` `Card` draws, and it docks with them under `stickyHeaderTop` (with `showHeader={false}` nothing docks and it scrolls with the rows). The inline header has no frame, so it draws none of the three and warns in development. _Key props:_ `TableColumns` (incl. `align`), `TableSize`, `TableType`, `TableRowSelection`, `TablePaginationPosition` (`pagination.position`, in antd naming: a pager on each edge named, aligned as named, 16px from the rows; bottom right by default), `headerVariant`, `title`, `subtitle`, `extra`, `onVisibleOrderChange`, `scrollHeight` (a height, or `"fill"` for the room left in its scroller once the content above and below it fits, so the page itself never scrolls).
|
|
122
123
|
- **`Statistic`** — Displays a statistic value with a label; primary/secondary sizes. _Key props:_ `StatisticValueSize`.
|
|
123
124
|
- **`Avatar`** — Logo/initial avatar. Renders the image when available, otherwise a coloured tile with the first letter of `name`, or with `fallback="placeholder"` the generic "no logo available" tile. Encapsulates the fallback colour. _Key props:_ `src`, `name`, `size`, `shape="square" | "circle"`, `fallback="initial" | "placeholder"`.
|
|
@@ -127,6 +128,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
127
128
|
- **`AppLogo`** — A connector's mark, optionally with its name and version tag. Builds on `Avatar`, so a missing or broken logo falls back to the generic "no logo available" placeholder, a neutral grey tile with a darker square, the same mark stackone-logos.com serves. The gap tightens below 18px so the mark and label still read as one unit. _Key props:_ `src`, `name`, `showName`, `size`, `nameSize`, `nameWeight`, `version`, `truncate`, `className`.
|
|
128
129
|
- **`ConnectionHeader`** — Two tilted logo tiles (from → to) showing a connection between apps. _Key props:_ `from`, `to` (`ConnectionEndpoint`: `icon`, `label`, `background`).
|
|
129
130
|
- **`CodeBlock`** — Syntax-styled code block, a JSON tree, or a diff. A `json` tree folds by depth with `collapsed`; `collapseLargerThan` also starts any nested array or object with more entries than the limit collapsed at any depth, so a large payload mounts a row per node rather than per item; a node over the limit gets a keyboard toggle named by its path and size, and a folded one says how many entries it holds. _Key props:_ `code`, `json`, `language` (`yaml` | `cedar`), `collapsed`, `collapseLargerThan`, `diff`, `showLineNumbers`, `wrapLines`, `enableCopy`, `height`, `aria-label`, `aria-labelledby`.
|
|
131
|
+
- **`CodePreview`** — A framed payload, such as the raw request or response under a step of a trace: a header naming it with mono `meta` at the right, its first `previewLines` lines (5 by default) with line numbers, and a full-width “Show All N Lines” toggle for the rest that becomes “Show Less”; the toggle carries `aria-expanded`, is described by the title, says how many flagged lines the fold hides, and only appears when there is more to show. The body is a focusable region named by the title, so a keyboard can scroll it. An empty `code` says so. The body scrolls past 360px, folded or open; past `maxRenderedLines` (2,000 by default) the expanded body stops mounting lines and says how many it left out. `highlightLines` flags 1-based lines with the error tint, a rule down their start edge and a visually hidden “Flagged:” for assistive tech; say why nearby. Plain text, no syntax colouring or JSON tree: for those use `CodeBlock`. _Key props:_ `title`, `meta`, `code`, `previewLines`, `highlightLines`, `showLineNumbers` (default `true`), `maxRenderedLines`, `className`.
|
|
130
132
|
- **`Stepper`** — Progress dots/segments for a multi-step flow; optionally clickable. `groups` takes a long flow in labelled sections: the active step’s group opens into one bar per step across the full width and every other group folds to a short bar. Folded bars keep a fixed width and the open group shares what is left, so allow about 20px per other group and 12px per step in the open group. With `onChange` each folded bar is a button named after its group. _Key props:_ `steps` or `groups` (`{ label, steps }[]`), `active`, `onChange`.
|
|
131
133
|
- **`Swatch`** — Colour swatch preview.
|
|
132
134
|
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsxs as l, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as A, useId as N, useMemo as v } from "react";
|
|
3
|
+
import L from "./CustomIcons/CaretDownIcon.js";
|
|
4
|
+
import c from "./Typography/Text.js";
|
|
5
|
+
import { rowsWrapperStyle as M } from "./codeBlockStyles.js";
|
|
6
|
+
import { FOCUS_RING_INSET as E } from "./focusRing.js";
|
|
7
|
+
import { isRenderableNode as O } from "./renderableNode.js";
|
|
8
|
+
const w = 5, I = 2e3, T = 360, F = "var(--malachite-card-border,rgb(232,232,232))", S = "var(--malachite-card-subtle-divider,rgb(241,241,241))", W = (e) => e === "" ? [] : e.replace(/\r?\n$/, "").split(/\r\n|\r|\n/), $ = (e, o) => !Number.isNaN(e) && e >= 1 ? Math.floor(e) : o, j = (e) => e ? "flex border-0 border-s-[3px] border-solid border-[var(--malachite-error-background,rgb(197,63,63))] bg-[var(--malachite-alert-error-background,rgba(197,63,63,0.08))]" : "flex border-0 border-s-[3px] border-solid border-transparent", H = (e, o, s) => {
|
|
9
|
+
if (e)
|
|
10
|
+
return "Show Less";
|
|
11
|
+
const m = s > 0 ? ` · ${s} flagged` : "";
|
|
12
|
+
return `Show All ${o} Lines${m}`;
|
|
13
|
+
}, q = ({
|
|
14
|
+
title: e,
|
|
15
|
+
meta: o,
|
|
16
|
+
code: s,
|
|
17
|
+
previewLines: m = w,
|
|
18
|
+
highlightLines: f = [],
|
|
19
|
+
showLineNumbers: i = !0,
|
|
20
|
+
maxRenderedLines: D = I,
|
|
21
|
+
className: _ = ""
|
|
22
|
+
}) => {
|
|
23
|
+
const [d, k] = A(!1), h = N(), u = N(), a = v(() => W(s), [s]), p = v(
|
|
24
|
+
() => new Set(
|
|
25
|
+
f.filter(
|
|
26
|
+
(t) => Number.isInteger(t) && t >= 1 && t <= a.length
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
[f, a.length]
|
|
30
|
+
), x = $(m, w), y = a.length > x, b = d || !y, g = Math.min(
|
|
31
|
+
b ? a.length : x,
|
|
32
|
+
$(D, I)
|
|
33
|
+
), C = a.slice(0, g), R = [...p].filter((t) => t > x).length, z = `max(40px, calc(${String(a.length).length}ch + 14px))`;
|
|
34
|
+
return /* @__PURE__ */ l(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
className: `overflow-hidden rounded-[var(--malachite-radius-10,10px)] border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] ${_}`,
|
|
38
|
+
style: { borderColor: F },
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ l(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
className: "flex items-center justify-between gap-[12px] border-0 border-b border-solid bg-[var(--malachite-card-sunken-background,rgb(250,250,250))] px-[12px] py-[7px] leading-[14px]",
|
|
44
|
+
style: { borderColor: S },
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ r("span", { id: h, className: "flex min-w-0", children: /* @__PURE__ */ r(c, { size: "xsmall", color: "secondary", fontWeight: "semi-bold", children: e }) }),
|
|
47
|
+
O(o) && /* @__PURE__ */ r(
|
|
48
|
+
c,
|
|
49
|
+
{
|
|
50
|
+
size: "xsmall",
|
|
51
|
+
color: "secondary",
|
|
52
|
+
font: "mono",
|
|
53
|
+
wrap: !1,
|
|
54
|
+
className: "truncate",
|
|
55
|
+
children: o
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
a.length === 0 ? /* @__PURE__ */ r(c, { as: "p", size: "xsmall", color: "secondary", className: "m-0 px-[12px] py-[8px]", children: "Empty" }) : (
|
|
62
|
+
// Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.
|
|
63
|
+
/* @__PURE__ */ r(
|
|
64
|
+
"pre",
|
|
65
|
+
{
|
|
66
|
+
id: u,
|
|
67
|
+
role: "region",
|
|
68
|
+
"aria-labelledby": h,
|
|
69
|
+
tabIndex: 0,
|
|
70
|
+
className: `m-0 overflow-auto font-mono text-[length:var(--malachite-font-size-xsmall,11px)] ${i ? "py-[6px] leading-[14px]" : "py-[10px] leading-[1.65]"} text-[var(--malachite-text-primary,rgb(10,10,10))] ${E}`,
|
|
71
|
+
style: { maxHeight: T },
|
|
72
|
+
children: /* @__PURE__ */ l("span", { className: "block", style: M(!1), children: [
|
|
73
|
+
C.map((t, n) => (
|
|
74
|
+
// A line's position is its identity: its text can repeat.
|
|
75
|
+
/* @__PURE__ */ l(
|
|
76
|
+
"span",
|
|
77
|
+
{
|
|
78
|
+
"data-flagged": p.has(n + 1) || void 0,
|
|
79
|
+
className: j(p.has(n + 1)),
|
|
80
|
+
children: [
|
|
81
|
+
i && /* @__PURE__ */ r(
|
|
82
|
+
"span",
|
|
83
|
+
{
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
className: "flex-none select-none pe-[10px] text-end text-[var(--malachite-text-dimmed,rgb(161,161,161))]",
|
|
86
|
+
style: { width: z },
|
|
87
|
+
children: n + 1
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ l(
|
|
91
|
+
"span",
|
|
92
|
+
{
|
|
93
|
+
className: `min-w-0 whitespace-pre ${i ? "" : "px-[11px]"}`,
|
|
94
|
+
children: [
|
|
95
|
+
p.has(n + 1) && /* @__PURE__ */ r("span", { className: "sr-only select-none", children: "Flagged: " }),
|
|
96
|
+
t || " "
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
n
|
|
103
|
+
)
|
|
104
|
+
)),
|
|
105
|
+
!b && !i && /* @__PURE__ */ r("span", { "aria-hidden": "true", className: "block select-none px-[14px]", children: "…" })
|
|
106
|
+
] })
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
),
|
|
110
|
+
b && g < a.length && /* @__PURE__ */ r(c, { as: "p", size: "xsmall", color: "secondary", className: "m-0 px-[12px] pb-[8px]", children: `Showing the first ${g.toLocaleString()} of ${a.length.toLocaleString()} lines.` }),
|
|
111
|
+
y && /* @__PURE__ */ l(
|
|
112
|
+
"button",
|
|
113
|
+
{
|
|
114
|
+
type: "button",
|
|
115
|
+
"aria-expanded": d,
|
|
116
|
+
"aria-controls": u,
|
|
117
|
+
"aria-describedby": h,
|
|
118
|
+
onClick: () => k((t) => !t),
|
|
119
|
+
className: `m-0 flex w-full cursor-pointer appearance-none items-center gap-[5px] border-0 border-t border-solid bg-transparent px-[12px] py-[7px] text-start font-[inherit] text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${E}`,
|
|
120
|
+
style: { borderColor: S },
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ r(c, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", children: H(d, a.length, R) }),
|
|
123
|
+
/* @__PURE__ */ r("span", { "aria-hidden": "true", className: "flex", children: /* @__PURE__ */ r(
|
|
124
|
+
L,
|
|
125
|
+
{
|
|
126
|
+
size: 12,
|
|
127
|
+
className: "transition-transform",
|
|
128
|
+
style: { transform: d ? "rotate(180deg)" : void 0 }
|
|
129
|
+
}
|
|
130
|
+
) })
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
q as CodePreview,
|
|
140
|
+
q as default
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=CodePreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodePreview.js","sources":["../../src/components/CodePreview.tsx"],"sourcesContent":["import type React from 'react';\nimport { useId, useMemo, useState } from 'react';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport Text from './Typography/Text';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { FOCUS_RING_INSET } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\n\nexport interface CodePreviewProps {\n /** Names the payload in the header and its body and toggle for assistive tech, e.g. `Request`. */\n title: string;\n /** At the right of the header in the mono face, e.g. `POST · acc_8f2…`. */\n meta?: React.ReactNode;\n code: string;\n /** How many lines show until the reader asks for all of them. `Infinity` shows them all. */\n previewLines?: number;\n /** 1-based line numbers to flag, such as the fields a scanner caught. Colour alone, so say why nearby. */\n highlightLines?: readonly number[];\n showLineNumbers?: boolean;\n /** The most lines the expanded body mounts; past it a note says how many are not shown. */\n maxRenderedLines?: number;\n className?: string;\n}\n\nconst DEFAULT_PREVIEW_LINES = 5;\nconst DEFAULT_MAX_RENDERED_LINES = 2000;\n\n// Past this the body scrolls, folded or open, so a long preview never crowds out what is around it.\nconst MAX_BODY_HEIGHT = 360;\n\nconst BORDER = 'var(--malachite-card-border,rgb(232,232,232))';\nconst DIVIDER = 'var(--malachite-card-subtle-divider,rgb(241,241,241))';\n\n// Any line ending, and no empty last line for a trailing newline.\nconst linesOf = (code: string): string[] =>\n code === '' ? [] : code.replace(/\\r?\\n$/, '').split(/\\r\\n|\\r|\\n/);\n\nconst countOf = (value: number, fallback: number): number =>\n !Number.isNaN(value) && value >= 1 ? Math.floor(value) : fallback;\n\nconst lineClasses = (flagged: boolean): string =>\n flagged\n ? 'flex border-0 border-s-[3px] border-solid border-[var(--malachite-error-background,rgb(197,63,63))] bg-[var(--malachite-alert-error-background,rgba(197,63,63,0.08))]'\n : 'flex border-0 border-s-[3px] border-solid border-transparent';\n\nconst toggleLabel = (expanded: boolean, total: number, hiddenFlags: number): string => {\n if (expanded) {\n return 'Show Less';\n }\n const flags = hiddenFlags > 0 ? ` · ${hiddenFlags} flagged` : '';\n return `Show All ${total} Lines${flags}`;\n};\n\n/**\n * A framed payload: a header naming it, its first lines, and a toggle for the rest. For the raw\n * request or response under a step of a trace, where the whole body would crowd out the steps.\n */\nconst CodePreview: React.FC<CodePreviewProps> = ({\n title,\n meta,\n code,\n previewLines = DEFAULT_PREVIEW_LINES,\n highlightLines = [],\n showLineNumbers = true,\n maxRenderedLines = DEFAULT_MAX_RENDERED_LINES,\n className = '',\n}) => {\n const [expanded, setExpanded] = useState(false);\n const titleId = useId();\n const bodyId = useId();\n const lines = useMemo(() => linesOf(code), [code]);\n const flagged = useMemo(\n () =>\n new Set(\n highlightLines.filter(\n (line) => Number.isInteger(line) && line >= 1 && line <= lines.length,\n ),\n ),\n [highlightLines, lines.length],\n );\n const limit = countOf(previewLines, DEFAULT_PREVIEW_LINES);\n const foldable = lines.length > limit;\n const open = expanded || !foldable;\n const rendered = Math.min(\n open ? lines.length : limit,\n countOf(maxRenderedLines, DEFAULT_MAX_RENDERED_LINES),\n );\n const shown = lines.slice(0, rendered);\n const hiddenFlags = [...flagged].filter((line) => line > limit).length;\n // 40px as designed, wider only when the last line's number would crowd the code.\n const gutter = `max(40px, calc(${String(lines.length).length}ch + 14px))`;\n return (\n <div\n className={`overflow-hidden rounded-[var(--malachite-radius-10,10px)] border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] ${className}`}\n style={{ borderColor: BORDER }}\n >\n <div\n className=\"flex items-center justify-between gap-[12px] border-0 border-b border-solid bg-[var(--malachite-card-sunken-background,rgb(250,250,250))] px-[12px] py-[7px] leading-[14px]\"\n style={{ borderColor: DIVIDER }}\n >\n <span id={titleId} className=\"flex min-w-0\">\n <Text size=\"xsmall\" color=\"secondary\" fontWeight=\"semi-bold\">\n {title}\n </Text>\n </span>\n {isRenderableNode(meta) && (\n <Text\n size=\"xsmall\"\n color=\"secondary\"\n font=\"mono\"\n wrap={false}\n className=\"truncate\"\n >\n {meta}\n </Text>\n )}\n </div>\n {lines.length === 0 ? (\n <Text as=\"p\" size=\"xsmall\" color=\"secondary\" className=\"m-0 px-[12px] py-[8px]\">\n Empty\n </Text>\n ) : (\n // Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.\n <pre\n id={bodyId}\n role=\"region\"\n aria-labelledby={titleId}\n tabIndex={0}\n // Numbered rows sit tight like an editor's; a bare payload keeps code spacing, as designed.\n className={`m-0 overflow-auto font-mono text-[length:var(--malachite-font-size-xsmall,11px)] ${showLineNumbers ? 'py-[6px] leading-[14px]' : 'py-[10px] leading-[1.65]'} text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING_INSET}`}\n style={{ maxHeight: MAX_BODY_HEIGHT }}\n >\n <span className=\"block\" style={rowsWrapperStyle(false)}>\n {shown.map((line, index) => (\n // A line's position is its identity: its text can repeat.\n <span\n key={index}\n data-flagged={flagged.has(index + 1) || undefined}\n className={lineClasses(flagged.has(index + 1))}\n >\n {showLineNumbers && (\n <span\n aria-hidden=\"true\"\n className=\"flex-none select-none pe-[10px] text-end text-[var(--malachite-text-dimmed,rgb(161,161,161))]\"\n style={{ width: gutter }}\n >\n {index + 1}\n </span>\n )}\n <span\n className={`min-w-0 whitespace-pre ${showLineNumbers ? '' : 'px-[11px]'}`}\n >\n {flagged.has(index + 1) && (\n <span className=\"sr-only select-none\">Flagged: </span>\n )}\n {line || ' '}\n </span>\n </span>\n ))}\n {!open && !showLineNumbers && (\n <span aria-hidden=\"true\" className=\"block select-none px-[14px]\">\n …\n </span>\n )}\n </span>\n </pre>\n )}\n {open && rendered < lines.length && (\n <Text as=\"p\" size=\"xsmall\" color=\"secondary\" className=\"m-0 px-[12px] pb-[8px]\">\n {`Showing the first ${rendered.toLocaleString()} of ${lines.length.toLocaleString()} lines.`}\n </Text>\n )}\n {foldable && (\n <button\n type=\"button\"\n aria-expanded={expanded}\n aria-controls={bodyId}\n aria-describedby={titleId}\n onClick={() => setExpanded((isOpen) => !isOpen)}\n className={`m-0 flex w-full cursor-pointer appearance-none items-center gap-[5px] border-0 border-t border-solid bg-transparent px-[12px] py-[7px] text-start font-[inherit] text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${FOCUS_RING_INSET}`}\n style={{ borderColor: DIVIDER }}\n >\n <Text size=\"xsmall\" fontWeight=\"semi-bold\" color=\"inherit\">\n {toggleLabel(expanded, lines.length, hiddenFlags)}\n </Text>\n <span aria-hidden=\"true\" className=\"flex\">\n <CaretDownIcon\n size={12}\n className=\"transition-transform\"\n style={{ transform: expanded ? 'rotate(180deg)' : undefined }}\n />\n </span>\n </button>\n )}\n </div>\n );\n};\n\nexport default CodePreview;\nexport { CodePreview };\n"],"names":["DEFAULT_PREVIEW_LINES","DEFAULT_MAX_RENDERED_LINES","MAX_BODY_HEIGHT","BORDER","DIVIDER","linesOf","code","countOf","value","fallback","lineClasses","flagged","toggleLabel","expanded","total","hiddenFlags","flags","CodePreview","title","meta","previewLines","highlightLines","showLineNumbers","maxRenderedLines","className","setExpanded","useState","titleId","useId","bodyId","lines","useMemo","line","limit","foldable","open","rendered","shown","gutter","jsxs","jsx","Text","isRenderableNode","FOCUS_RING_INSET","rowsWrapperStyle","index","isOpen","CaretDownIcon"],"mappings":";;;;;;;AAwBA,MAAMA,IAAwB,GACxBC,IAA6B,KAG7BC,IAAkB,KAElBC,IAAS,iDACTC,IAAU,yDAGVC,IAAU,CAACC,MACbA,MAAS,KAAK,CAAA,IAAKA,EAAK,QAAQ,UAAU,EAAE,EAAE,MAAM,YAAY,GAE9DC,IAAU,CAACC,GAAeC,MAC5B,CAAC,OAAO,MAAMD,CAAK,KAAKA,KAAS,IAAI,KAAK,MAAMA,CAAK,IAAIC,GAEvDC,IAAc,CAACC,MACjBA,IACM,0KACA,gEAEJC,IAAc,CAACC,GAAmBC,GAAeC,MAAgC;AACnF,MAAIF;AACA,WAAO;AAEX,QAAMG,IAAQD,IAAc,IAAI,MAAMA,CAAW,aAAa;AAC9D,SAAO,YAAYD,CAAK,SAASE,CAAK;AAC1C,GAMMC,IAA0C,CAAC;AAAA,EAC7C,OAAAC;AAAA,E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AAA,gBAAU;AAAA,cAAA,EAChE,CACJ;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACJ;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsxs as l, Fragment as g, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import v from "./CustomIcons/ForwardArrowIcon.js";
|
|
3
|
+
import $ from "./Typography/EllipsisText.js";
|
|
4
|
+
import m from "./Typography/Text.js";
|
|
5
|
+
import { devWarning as N } from "./devWarning.js";
|
|
6
|
+
import { FOCUS_RING as y } from "./focusRing.js";
|
|
7
|
+
import { isRenderableNode as p } from "./renderableNode.js";
|
|
8
|
+
import { safeHref as C } from "./safeHref.js";
|
|
9
|
+
const L = {
|
|
10
|
+
neutral: "primary",
|
|
11
|
+
success: "success",
|
|
12
|
+
warning: "warning",
|
|
13
|
+
error: "error"
|
|
14
|
+
}, s = "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", h = `cursor-pointer transition-colors hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] hover:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))] ${y}`, O = ({
|
|
15
|
+
title: f,
|
|
16
|
+
description: t,
|
|
17
|
+
tone: x = "neutral",
|
|
18
|
+
icon: c,
|
|
19
|
+
trailing: d,
|
|
20
|
+
actionLabel: u = "Open",
|
|
21
|
+
onClick: r,
|
|
22
|
+
href: a,
|
|
23
|
+
className: o = ""
|
|
24
|
+
}) => {
|
|
25
|
+
const n = C(a);
|
|
26
|
+
a && !n && N(
|
|
27
|
+
`LinkCard.href:${a}`,
|
|
28
|
+
`LinkCard dropped the unsafe href "${a}"; without an onClick it is a static card.`
|
|
29
|
+
);
|
|
30
|
+
const b = !!(n || r), i = /* @__PURE__ */ l(g, { children: [
|
|
31
|
+
p(c) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: c }),
|
|
32
|
+
/* @__PURE__ */ l("span", { className: "flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]", children: [
|
|
33
|
+
/* @__PURE__ */ e(
|
|
34
|
+
m,
|
|
35
|
+
{
|
|
36
|
+
size: "small",
|
|
37
|
+
fontWeight: "bold",
|
|
38
|
+
color: L[x],
|
|
39
|
+
className: "leading-[17px]",
|
|
40
|
+
children: f
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
t && /* @__PURE__ */ e(
|
|
44
|
+
$,
|
|
45
|
+
{
|
|
46
|
+
size: "xsmall",
|
|
47
|
+
color: "secondary",
|
|
48
|
+
tooltip: t,
|
|
49
|
+
tooltipWhenTruncated: !0,
|
|
50
|
+
inline: !0,
|
|
51
|
+
children: t
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
] }),
|
|
55
|
+
p(d) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: d }),
|
|
56
|
+
b && /* @__PURE__ */ l("span", { className: "flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]", children: [
|
|
57
|
+
/* @__PURE__ */ e(m, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", wrap: !1, children: u }),
|
|
58
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex", children: /* @__PURE__ */ e(v, { size: 12 }) })
|
|
59
|
+
] })
|
|
60
|
+
] });
|
|
61
|
+
return n ? /* @__PURE__ */ e(
|
|
62
|
+
"a",
|
|
63
|
+
{
|
|
64
|
+
href: n,
|
|
65
|
+
onClick: r,
|
|
66
|
+
className: `${s} ${h} ${o}`,
|
|
67
|
+
children: i
|
|
68
|
+
}
|
|
69
|
+
) : r ? /* @__PURE__ */ e(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
type: "button",
|
|
73
|
+
onClick: r,
|
|
74
|
+
className: `m-0 appearance-none font-[inherit] ${s} ${h} ${o}`,
|
|
75
|
+
children: i
|
|
76
|
+
}
|
|
77
|
+
) : /* @__PURE__ */ e("div", { className: `${s} ${o}`, children: i });
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
O as LinkCard,
|
|
81
|
+
O as default
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=LinkCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkCard.js","sources":["../../src/components/LinkCard.tsx"],"sourcesContent":["import type React from 'react';\nimport ForwardArrowIcon from './CustomIcons/ForwardArrowIcon';\nimport EllipsisText from './Typography/EllipsisText';\nimport Text from './Typography/Text';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING } 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; truncated text shows in full on hover. */\n description?: string;\n /** Colours the title. */\n tone?: LinkCardTone;\n /** Decorative, before the title. Coloured paths need `data-malachite-shape`. */\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 transition-colors hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] hover:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))] ${FOCUS_RING}`;\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 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 <Text\n size=\"small\"\n fontWeight=\"bold\"\n color={TITLE_COLOR[tone]}\n className=\"leading-[17px]\"\n >\n {title}\n </Text>\n {description && (\n <EllipsisText\n size=\"xsmall\"\n color=\"secondary\"\n tooltip={description}\n tooltipWhenTruncated\n inline\n >\n {description}\n </EllipsisText>\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 <Text size=\"xsmall\" fontWeight=\"semi-bold\" color=\"inherit\" wrap={false}>\n {actionLabel}\n </Text>\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 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 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","FOCUS_RING","LinkCard","title","description","tone","icon","trailing","actionLabel","onClick","rawHref","className","href","safeHref","devWarning","interactive","body","jsxs","Fragment","isRenderableNode","jsx","Text","EllipsisText","ForwardArrowIcon"],"mappings":";;;;;;;;AA4BA,MAAMA,IAAc;AAAA,EAChB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAEMC,IACF,kTAEEC,IAAsB,qLAAqLC,CAAU,IAGrNC,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,IACI,iBAAiBJ,CAAO;AAAA,IACxB,qCAAqCA,CAAO;AAAA,EAAA;AAGpD,QAAMK,IAAc,GAAQH,KAAQH,IAC9BO,IACF,gBAAAC,EAAAC,GAAA,EACK,UAAA;AAAA,IAAAC,EAAiBb,CAAI,KAClB,gBAAAc,EAAC,QAAA,EAAK,eAAY,QAAO,WAAU,+BAC9B,UAAAd,EAAA,CACL;AAAA,IAEJ,gBAAAW,EAAC,QAAA,EAAK,WAAU,yDACZ,UAAA;AAAA,MAAA,gBAAAG;AAAA,QAACC;AAAA,QAAA;AAAA,UACG,MAAK;AAAA,UACL,YAAW;AAAA,UACX,OAAOvB,EAAYO,CAAI;AAAA,UACvB,WAAU;AAAA,UAET,UAAAF;AAAA,QAAA;AAAA,MAAA;AAAA,MAEJC,KACG,gBAAAgB;AAAA,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
|
3
|
+
import r from "./Typography/Text.js";
|
|
4
|
+
const w = {
|
|
5
5
|
neutral: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
6
6
|
info: "var(--malachite-text-info, rgb(12, 88, 174))",
|
|
7
7
|
success: "var(--malachite-text-success, rgb(2, 122, 66))",
|
|
8
8
|
warning: "var(--malachite-text-warning, rgb(150, 88, 10))",
|
|
9
9
|
error: "var(--malachite-text-error, rgb(237, 53, 54))"
|
|
10
|
-
},
|
|
11
|
-
|
|
10
|
+
}, u = /* @__PURE__ */ e(
|
|
11
|
+
"svg",
|
|
12
|
+
{
|
|
13
|
+
"data-timeline-skipped": "",
|
|
14
|
+
width: "14",
|
|
15
|
+
height: "14",
|
|
16
|
+
viewBox: "0 0 24 24",
|
|
17
|
+
className: "block text-[var(--malachite-text-placeholder,rgb(187,187,187))]",
|
|
18
|
+
children: /* @__PURE__ */ e(
|
|
19
|
+
"path",
|
|
20
|
+
{
|
|
21
|
+
"data-malachite-shape": "",
|
|
22
|
+
d: "M6 9l6 6 6-6",
|
|
23
|
+
fill: "none",
|
|
24
|
+
stroke: "currentColor",
|
|
25
|
+
strokeWidth: "2.4",
|
|
26
|
+
strokeLinecap: "round",
|
|
27
|
+
strokeLinejoin: "round"
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
), v = ({
|
|
32
|
+
title: i,
|
|
12
33
|
time: a,
|
|
13
34
|
tone: n,
|
|
14
|
-
marker:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
marker: s,
|
|
36
|
+
skipped: p = !1,
|
|
37
|
+
stopped: t = !1,
|
|
38
|
+
stoppedLabel: o,
|
|
39
|
+
meta: d = [],
|
|
40
|
+
children: h,
|
|
41
|
+
className: f = ""
|
|
19
42
|
}) => {
|
|
20
|
-
const
|
|
43
|
+
const m = n ?? (t ? "error" : "neutral"), x = p ? u : s;
|
|
21
44
|
return /* @__PURE__ */ l(
|
|
22
45
|
"li",
|
|
23
46
|
{
|
|
24
|
-
className: `relative m-0 flex gap-[14px] pb-[40px] last:pb-0 [&:last-child>[data-timeline-line]]:hidden ${
|
|
47
|
+
className: `relative m-0 flex gap-[14px] pb-[40px] last:pb-0 [&:last-child>[data-timeline-line]]:hidden ${f}`,
|
|
25
48
|
children: [
|
|
26
49
|
/* @__PURE__ */ e(
|
|
27
50
|
"span",
|
|
@@ -35,13 +58,13 @@ const p = {
|
|
|
35
58
|
"span",
|
|
36
59
|
{
|
|
37
60
|
"aria-hidden": "true",
|
|
38
|
-
className: `flex h-[24px] w-[24px] flex-none items-center justify-center overflow-hidden rounded-full ${
|
|
39
|
-
children:
|
|
61
|
+
className: `flex h-[24px] w-[24px] flex-none items-center justify-center overflow-hidden rounded-full ${x ? "" : "border border-solid border-[var(--malachite-card-border,rgb(232,232,232))]"}`,
|
|
62
|
+
children: x || /* @__PURE__ */ e(
|
|
40
63
|
"span",
|
|
41
64
|
{
|
|
42
|
-
"data-timeline-dot":
|
|
65
|
+
"data-timeline-dot": m,
|
|
43
66
|
className: "h-[8px] w-[8px] rounded-full",
|
|
44
|
-
style: { backgroundColor:
|
|
67
|
+
style: { backgroundColor: w[m] }
|
|
45
68
|
}
|
|
46
69
|
)
|
|
47
70
|
}
|
|
@@ -49,12 +72,12 @@ const p = {
|
|
|
49
72
|
/* @__PURE__ */ l("div", { className: "flex min-w-0 flex-1 flex-col gap-[8px] pt-[2px]", children: [
|
|
50
73
|
/* @__PURE__ */ l("div", { className: "flex items-start justify-between gap-[12px]", children: [
|
|
51
74
|
/* @__PURE__ */ l("div", { className: "flex min-w-0 flex-wrap items-center gap-x-[8px] gap-y-[4px] [overflow-wrap:anywhere]", children: [
|
|
52
|
-
/* @__PURE__ */ e(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
/* @__PURE__ */ e(r, { size: "small", fontWeight: "bold", className: "min-w-0 leading-[18px]", children: i }),
|
|
76
|
+
t && /* @__PURE__ */ e("span", { className: "sr-only", children: ", " }),
|
|
77
|
+
t && /* @__PURE__ */ e(
|
|
78
|
+
b,
|
|
56
79
|
{
|
|
57
|
-
value: (
|
|
80
|
+
value: (o == null ? void 0 : o.trim()) || "Stopped here",
|
|
58
81
|
type: "error",
|
|
59
82
|
fontSize: "xsmall",
|
|
60
83
|
textTransform: "none",
|
|
@@ -64,7 +87,7 @@ const p = {
|
|
|
64
87
|
] }),
|
|
65
88
|
(a || a === 0) && /* @__PURE__ */ e("span", { className: "sr-only", children: ", " }),
|
|
66
89
|
(a || a === 0) && /* @__PURE__ */ e(
|
|
67
|
-
|
|
90
|
+
r,
|
|
68
91
|
{
|
|
69
92
|
size: "xsmall",
|
|
70
93
|
color: "secondary",
|
|
@@ -75,29 +98,40 @@ const p = {
|
|
|
75
98
|
}
|
|
76
99
|
)
|
|
77
100
|
] }),
|
|
78
|
-
m
|
|
101
|
+
d.length > 0 && /* @__PURE__ */ e("dl", { className: "m-0 flex flex-wrap gap-x-[18px] gap-y-[6px] leading-[16px]", children: d.map((c, g) => /* @__PURE__ */ l(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
className: "flex min-w-0 items-baseline gap-[3px]",
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ e("dt", { className: "flex", children: /* @__PURE__ */ e(r, { size: "xsmall", color: "secondary", children: c.label }) }),
|
|
107
|
+
/* @__PURE__ */ e("dd", { className: "m-0 flex min-w-0 [overflow-wrap:anywhere]", children: /* @__PURE__ */ e(r, { size: "xsmall", font: "mono", children: c.value }) })
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
`${c.label}-${g}`
|
|
111
|
+
)) }),
|
|
112
|
+
h
|
|
79
113
|
] })
|
|
80
114
|
]
|
|
81
115
|
}
|
|
82
116
|
);
|
|
83
|
-
},
|
|
84
|
-
children:
|
|
117
|
+
}, N = ({
|
|
118
|
+
children: i,
|
|
85
119
|
className: a = "",
|
|
86
120
|
"aria-label": n,
|
|
87
|
-
"aria-labelledby":
|
|
121
|
+
"aria-labelledby": s
|
|
88
122
|
}) => /* @__PURE__ */ e(
|
|
89
123
|
"ol",
|
|
90
124
|
{
|
|
91
125
|
role: "list",
|
|
92
126
|
"aria-label": n,
|
|
93
|
-
"aria-labelledby":
|
|
127
|
+
"aria-labelledby": s,
|
|
94
128
|
className: `m-0 list-none p-0 ${a}`,
|
|
95
|
-
children:
|
|
129
|
+
children: i
|
|
96
130
|
}
|
|
97
131
|
);
|
|
98
|
-
|
|
132
|
+
N.Item = v;
|
|
99
133
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
134
|
+
N as Timeline,
|
|
135
|
+
N as default
|
|
102
136
|
};
|
|
103
137
|
//# sourceMappingURL=Timeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timeline.js","sources":["../../src/components/Timeline.tsx"],"sourcesContent":["import React from 'react';\nimport Tag from './Tag';\nimport Text from './Typography/Text';\n\nexport type TimelineTone = 'neutral' | 'info' | 'success' | 'warning' | 'error';\n\nexport interface TimelineProps {\n children: React.ReactNode;\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n}\n\nexport interface TimelineItemProps {\n title: React.ReactNode;\n /** When the step happened, shown at the right of the title, e.g. `+6 ms`. */\n time?: React.ReactNode;\n /**\n * Paints the dot: `error` on a `stopped` step, else `neutral`, unless set. Colour alone, so the\n * title has to say what happened. Ignored when `marker` is set.\n */\n tone?: TimelineTone;\n /** Replaces the ringed dot with a 24px circle of its own, e.g. the caller's logo at size 24. Decorative: hidden from assistive tech. */\n marker?: React.ReactNode;\n /** Marks the step the flow ended on, with a badge after the title. */\n stopped?: boolean;\n /** The badge's text when `stopped`. Empty falls back to \"Stopped here\". */\n stoppedLabel?: string;\n /**\n * The step's detail, below the title: tags, copy, payloads. Each child is a row of its own, 8px\n * apart, and unstyled, so wrap copy in `Typography.Text`.\n */\n children?: React.ReactNode;\n className?: string;\n}\n\n// The light theme's values as fallbacks: the dot paints before the theme reaches `:host`.\nconst DOT_COLOR: Record<TimelineTone, string> = {\n neutral: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n info: 'var(--malachite-text-info, rgb(12, 88, 174))',\n success: 'var(--malachite-text-success, rgb(2, 122, 66))',\n warning: 'var(--malachite-text-warning, rgb(150, 88, 10))',\n error: 'var(--malachite-text-error, rgb(237, 53, 54))',\n};\n\nconst Item: React.FC<TimelineItemProps> = ({\n title,\n time,\n tone,\n marker,\n stopped = false,\n stoppedLabel,\n children,\n className = '',\n}) => {\n const dotTone = tone ?? (stopped ? 'error' : 'neutral');\n return (\n <li\n className={`relative m-0 flex gap-[14px] pb-[40px] last:pb-0 [&:last-child>[data-timeline-line]]:hidden ${className}`}\n >\n <span\n data-timeline-line=\"\"\n aria-hidden=\"true\"\n className=\"absolute start-[11px] top-[26px] bottom-[2px] w-[2px] bg-[var(--malachite-card-border,rgb(232,232,232))]\"\n />\n <span\n aria-hidden=\"true\"\n // The ring's border would cut into a marker, so a marker gets the full 24px circle instead.\n className={`flex h-[24px] w-[24px] flex-none items-center justify-center overflow-hidden rounded-full ${marker ? '' : 'border border-solid border-[var(--malachite-card-border,rgb(232,232,232))]'}`}\n >\n {marker || (\n <span\n data-timeline-dot={dotTone}\n className=\"h-[8px] w-[8px] rounded-full\"\n style={{ backgroundColor: DOT_COLOR[dotTone] }}\n />\n )}\n </span>\n <div className=\"flex min-w-0 flex-1 flex-col gap-[8px] pt-[2px]\">\n <div className=\"flex items-start justify-between gap-[12px]\">\n <div className=\"flex min-w-0 flex-wrap items-center gap-x-[8px] gap-y-[4px] [overflow-wrap:anywhere]\">\n <Text size=\"small\" fontWeight=\"semi-bold\" className=\"min-w-0\">\n {title}\n </Text>\n {stopped && <span className=\"sr-only\">, </span>}\n {stopped && (\n <Tag\n value={stoppedLabel?.trim() || 'Stopped here'}\n type=\"error\"\n fontSize=\"xsmall\"\n textTransform=\"none\"\n paddingSize=\"compact\"\n />\n )}\n </div>\n {(time || time === 0) && <span className=\"sr-only\">, </span>}\n {(time || time === 0) && (\n <Text\n size=\"xsmall\"\n color=\"secondary\"\n font=\"mono\"\n wrap={false}\n className=\"pt-[2px]\"\n >\n {time}\n </Text>\n )}\n </div>\n {children}\n </div>\n </li>\n );\n};\n\n/** A vertical sequence of steps, each with a dot on a connecting line, a title, its timing and a body. */\nconst Timeline: React.FC<TimelineProps> & { Item: typeof Item } = ({\n children,\n className = '',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => (\n <ol\n // list-style: none strips list semantics in WebKit, so VoiceOver would not announce the steps.\n role=\"list\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={`m-0 list-none p-0 ${className}`}\n >\n {children}\n </ol>\n);\n\nTimeline.Item = Item;\n\nexport default Timeline;\nexport { Timeline };\n"],"names":["DOT_COLOR","Item","title","time","tone","marker","stopped","stoppedLabel","children","className","dotTone","jsxs","jsx","Text","Tag","Timeline","ariaLabel","ariaLabelledBy"],"mappings":";;;AAqCA,MAAMA,IAA0C;AAAA,EAC5C,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAEMC,IAAoC,CAAC;AAAA,EACvC,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AAChB,MAAM;AACF,QAAMC,IAAUN,MAASE,IAAU,UAAU;AAC7C,SACI,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,+FAA+FF,CAAS;AAAA,MAEnH,UAAA;AAAA,QAAA,gBAAAG;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,sBAAmB;AAAA,YACnB,eAAY;AAAA,YACZ,WAAU;AAAA,UAAA;AAAA,QAAA;AAAA,QAEd,gBAAAA;AAAA,UAAC;AAAA,UAAA;A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;AAAA,EACZ,cAAcO;AAAA,EACd,mBAAmBC;AACvB,MACI,gBAAAL;AAAA,EAAC;AAAA,EAAA;AAAA,IAEG,MAAK;AAAA,IACL,cAAYI;AAAA,IACZ,mBAAiBC;AAAA,IACjB,WAAW,qBAAqBR,CAAS;AAAA,IAExC,UAAAD;AAAA,EAAA;AACL;AAGJO,EAAS,OAAOd;"}
|
|
1
|
+
{"version":3,"file":"Timeline.js","sources":["../../src/components/Timeline.tsx"],"sourcesContent":["import React from 'react';\nimport Tag from './Tag';\nimport Text from './Typography/Text';\n\nexport type TimelineTone = 'neutral' | 'info' | 'success' | 'warning' | 'error';\n\nexport interface TimelineProps {\n children: React.ReactNode;\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n}\n\nexport interface TimelineMetaEntry {\n label: string;\n value: React.ReactNode;\n}\n\nexport interface TimelineItemProps {\n title: React.ReactNode;\n /** When the step happened, shown at the right of the title, e.g. `+6 ms`. */\n time?: React.ReactNode;\n /**\n * Paints the dot: `error` on a `stopped` step, else `neutral`, unless set. Colour alone, so the\n * title has to say what happened. Ignored when `marker` is set.\n */\n tone?: TimelineTone;\n /** Replaces the ringed dot with a 24px circle of its own, e.g. the caller's logo at size 24. Decorative: hidden from assistive tech. */\n marker?: React.ReactNode;\n /** A step that never ran: a grey chevron replaces the dot, `tone` and `marker`. */\n skipped?: boolean;\n /** Marks the step the flow ended on, with a badge after the title. */\n stopped?: boolean;\n /** The badge's text when `stopped`. Empty falls back to \"Stopped here\". */\n stoppedLabel?: string;\n /** Label and value pairs in a wrapping row under the title. */\n meta?: readonly TimelineMetaEntry[];\n /**\n * The step's detail, below the title: tags, copy, payloads. Each child is a row of its own, 8px\n * apart, and unstyled, so wrap copy in `Typography.Text`.\n */\n children?: React.ReactNode;\n className?: string;\n}\n\n// The light theme's values as fallbacks: the dot paints before the theme reaches `:host`.\nconst DOT_COLOR: Record<TimelineTone, string> = {\n neutral: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n info: 'var(--malachite-text-info, rgb(12, 88, 174))',\n success: 'var(--malachite-text-success, rgb(2, 122, 66))',\n warning: 'var(--malachite-text-warning, rgb(150, 88, 10))',\n error: 'var(--malachite-text-error, rgb(237, 53, 54))',\n};\n\n// Stroked, so it opts out of the global path fill reset.\nconst SKIPPED_MARK = (\n <svg\n data-timeline-skipped=\"\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n className=\"block text-[var(--malachite-text-placeholder,rgb(187,187,187))]\"\n >\n <path\n data-malachite-shape=\"\"\n d=\"M6 9l6 6 6-6\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.4\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n);\n\nconst Item: React.FC<TimelineItemProps> = ({\n title,\n time,\n tone,\n marker,\n skipped = false,\n stopped = false,\n stoppedLabel,\n meta = [],\n children,\n className = '',\n}) => {\n const dotTone = tone ?? (stopped ? 'error' : 'neutral');\n const shownMarker = skipped ? SKIPPED_MARK : marker;\n return (\n <li\n className={`relative m-0 flex gap-[14px] pb-[40px] last:pb-0 [&:last-child>[data-timeline-line]]:hidden ${className}`}\n >\n <span\n data-timeline-line=\"\"\n aria-hidden=\"true\"\n className=\"absolute start-[11px] top-[26px] bottom-[2px] w-[2px] bg-[var(--malachite-card-border,rgb(232,232,232))]\"\n />\n <span\n aria-hidden=\"true\"\n // The ring's border would cut into a marker, so a marker gets the full 24px circle instead.\n className={`flex h-[24px] w-[24px] flex-none items-center justify-center overflow-hidden rounded-full ${shownMarker ? '' : 'border border-solid border-[var(--malachite-card-border,rgb(232,232,232))]'}`}\n >\n {shownMarker || (\n <span\n data-timeline-dot={dotTone}\n className=\"h-[8px] w-[8px] rounded-full\"\n style={{ backgroundColor: DOT_COLOR[dotTone] }}\n />\n )}\n </span>\n <div className=\"flex min-w-0 flex-1 flex-col gap-[8px] pt-[2px]\">\n <div className=\"flex items-start justify-between gap-[12px]\">\n <div className=\"flex min-w-0 flex-wrap items-center gap-x-[8px] gap-y-[4px] [overflow-wrap:anywhere]\">\n <Text size=\"small\" fontWeight=\"bold\" className=\"min-w-0 leading-[18px]\">\n {title}\n </Text>\n {stopped && <span className=\"sr-only\">, </span>}\n {stopped && (\n <Tag\n value={stoppedLabel?.trim() || 'Stopped here'}\n type=\"error\"\n fontSize=\"xsmall\"\n textTransform=\"none\"\n paddingSize=\"compact\"\n />\n )}\n </div>\n {(time || time === 0) && <span className=\"sr-only\">, </span>}\n {(time || time === 0) && (\n <Text\n size=\"xsmall\"\n color=\"secondary\"\n font=\"mono\"\n wrap={false}\n className=\"pt-[2px]\"\n >\n {time}\n </Text>\n )}\n </div>\n {meta.length > 0 && (\n <dl className=\"m-0 flex flex-wrap gap-x-[18px] gap-y-[6px] leading-[16px]\">\n {meta.map((entry, index) => (\n <div\n key={`${entry.label}-${index}`}\n className=\"flex min-w-0 items-baseline gap-[3px]\"\n >\n <dt className=\"flex\">\n <Text size=\"xsmall\" color=\"secondary\">\n {entry.label}\n </Text>\n </dt>\n <dd className=\"m-0 flex min-w-0 [overflow-wrap:anywhere]\">\n <Text size=\"xsmall\" font=\"mono\">\n {entry.value}\n </Text>\n </dd>\n </div>\n ))}\n </dl>\n )}\n {children}\n </div>\n </li>\n );\n};\n\n/** A vertical sequence of steps, each with a dot on a connecting line, a title, its timing and a body. */\nconst Timeline: React.FC<TimelineProps> & { Item: typeof Item } = ({\n children,\n className = '',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => (\n <ol\n // list-style: none strips list semantics in WebKit, so VoiceOver would not announce the steps.\n role=\"list\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={`m-0 list-none p-0 ${className}`}\n >\n {children}\n </ol>\n);\n\nTimeline.Item = Item;\n\nexport default Timeline;\nexport { Timeline };\n"],"names":["DOT_COLOR","SKIPPED_MARK","jsx","Item","title","time","tone","marker","skipped","stopped","stoppedLabel","meta","children","className","dotTone","shownMarker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AAM,aACrB,UAAAE,EAAM,MAAA,CACX,GACJ;AAAA,gBACA,gBAAAjB,EAAC,MAAA,EAAG,WAAU,6CACV,UAAA,gBAAAA,EAACe,GAAA,EAAK,MAAK,UAAS,MAAK,QACpB,UAAAE,EAAM,MAAA,CACX,EAAA,CACJ;AAAA,cAAA;AAAA,YAAA;AAAA,YAZK,GAAGA,EAAM,KAAK,IAAIC,CAAK;AAAA,UAAA,CAcnC,GACL;AAAA,UAEHR;AAAA,QAAA,EAAA,CACL;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGZ,GAGMS,IAA4D,CAAC;AAAA,EAC/D,UAAAT;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,cAAcS;AAAA,EACd,mBAAmBC;AACvB,MACI,gBAAArB;AAAA,EAAC;AAAA,EAAA;AAAA,IAEG,MAAK;AAAA,IACL,cAAYoB;AAAA,IACZ,mBAAiBC;AAAA,IACjB,WAAW,qBAAqBV,CAAS;AAAA,IAExC,UAAAD;AAAA,EAAA;AACL;AAGJS,EAAS,OAAOlB;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1238,6 +1238,28 @@ declare interface CodeBlockProps {
|
|
|
1238
1238
|
|
|
1239
1239
|
export declare const CodeIcon: React.FC<IconProps_31>;
|
|
1240
1240
|
|
|
1241
|
+
/**
|
|
1242
|
+
* A framed payload: a header naming it, its first lines, and a toggle for the rest. For the raw
|
|
1243
|
+
* request or response under a step of a trace, where the whole body would crowd out the steps.
|
|
1244
|
+
*/
|
|
1245
|
+
export declare const CodePreview: default_2.FC<CodePreviewProps>;
|
|
1246
|
+
|
|
1247
|
+
export declare interface CodePreviewProps {
|
|
1248
|
+
/** Names the payload in the header and its body and toggle for assistive tech, e.g. `Request`. */
|
|
1249
|
+
title: string;
|
|
1250
|
+
/** At the right of the header in the mono face, e.g. `POST · acc_8f2…`. */
|
|
1251
|
+
meta?: default_2.ReactNode;
|
|
1252
|
+
code: string;
|
|
1253
|
+
/** How many lines show until the reader asks for all of them. `Infinity` shows them all. */
|
|
1254
|
+
previewLines?: number;
|
|
1255
|
+
/** 1-based line numbers to flag, such as the fields a scanner caught. Colour alone, so say why nearby. */
|
|
1256
|
+
highlightLines?: readonly number[];
|
|
1257
|
+
showLineNumbers?: boolean;
|
|
1258
|
+
/** The most lines the expanded body mounts; past it a note says how many are not shown. */
|
|
1259
|
+
maxRenderedLines?: number;
|
|
1260
|
+
className?: string;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1241
1263
|
export declare interface CodeTextProps {
|
|
1242
1264
|
bold?: boolean;
|
|
1243
1265
|
size?: FontSize;
|
|
@@ -3299,6 +3321,28 @@ export declare const LibraryIcon: React.FC<IconProps_68>;
|
|
|
3299
3321
|
|
|
3300
3322
|
export declare const Link: default_2.FC<LinkProps>;
|
|
3301
3323
|
|
|
3324
|
+
/** A compact card that opens more detail elsewhere, such as another tab of a panel. */
|
|
3325
|
+
export declare const LinkCard: default_2.FC<LinkCardProps>;
|
|
3326
|
+
|
|
3327
|
+
export declare interface LinkCardProps {
|
|
3328
|
+
title: string;
|
|
3329
|
+
/** One line under the title; truncated text shows in full on hover. */
|
|
3330
|
+
description?: string;
|
|
3331
|
+
/** Colours the title. */
|
|
3332
|
+
tone?: LinkCardTone;
|
|
3333
|
+
/** Decorative, before the title. Coloured paths need `data-malachite-shape`. */
|
|
3334
|
+
icon?: default_2.ReactNode;
|
|
3335
|
+
/** Decorative content before the action, e.g. a level scale. Must not be interactive. */
|
|
3336
|
+
trailing?: default_2.ReactNode;
|
|
3337
|
+
actionLabel?: string;
|
|
3338
|
+
onClick?: (event: default_2.MouseEvent<HTMLElement>) => void;
|
|
3339
|
+
/** Renders a link instead of a button; unsafe schemes are dropped. */
|
|
3340
|
+
href?: string;
|
|
3341
|
+
className?: string;
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
|
+
export declare type LinkCardTone = 'neutral' | 'success' | 'warning' | 'error';
|
|
3345
|
+
|
|
3302
3346
|
export declare const LinkIcon: React.FC<IconProps_69>;
|
|
3303
3347
|
|
|
3304
3348
|
export declare interface LinkProps {
|
|
@@ -6057,10 +6101,14 @@ export declare interface TimelineItemProps {
|
|
|
6057
6101
|
tone?: TimelineTone;
|
|
6058
6102
|
/** Replaces the ringed dot with a 24px circle of its own, e.g. the caller's logo at size 24. Decorative: hidden from assistive tech. */
|
|
6059
6103
|
marker?: default_2.ReactNode;
|
|
6104
|
+
/** A step that never ran: a grey chevron replaces the dot, `tone` and `marker`. */
|
|
6105
|
+
skipped?: boolean;
|
|
6060
6106
|
/** Marks the step the flow ended on, with a badge after the title. */
|
|
6061
6107
|
stopped?: boolean;
|
|
6062
6108
|
/** The badge's text when `stopped`. Empty falls back to "Stopped here". */
|
|
6063
6109
|
stoppedLabel?: string;
|
|
6110
|
+
/** Label and value pairs in a wrapping row under the title. */
|
|
6111
|
+
meta?: readonly TimelineMetaEntry[];
|
|
6064
6112
|
/**
|
|
6065
6113
|
* The step's detail, below the title: tags, copy, payloads. Each child is a row of its own, 8px
|
|
6066
6114
|
* apart, and unstyled, so wrap copy in `Typography.Text`.
|
|
@@ -6069,6 +6117,11 @@ export declare interface TimelineItemProps {
|
|
|
6069
6117
|
className?: string;
|
|
6070
6118
|
}
|
|
6071
6119
|
|
|
6120
|
+
export declare interface TimelineMetaEntry {
|
|
6121
|
+
label: string;
|
|
6122
|
+
value: default_2.ReactNode;
|
|
6123
|
+
}
|
|
6124
|
+
|
|
6072
6125
|
export declare interface TimelineProps {
|
|
6073
6126
|
children: default_2.ReactNode;
|
|
6074
6127
|
className?: string;
|