@stackone/malachite 2.110.0 → 2.111.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/COMPONENTS.md CHANGED
@@ -122,7 +122,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
122
122
  - **`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`.
123
123
  - **`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`).
124
124
  - **`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. `titleCode` sets code after the title in the mono face as one phrase with it, such as `n8n called` then `Salesforce | Delete contact`. 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. `icon` keeps the ring and draws a 12-14px glyph inside it in place of the dot, painted by `tone`, such as the call’s source type (MCP, API key, webhook); `skipped` beats `marker`, which beats `icon`. `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`, `titleCode`, `time`, `tone` (`TimelineTone`: `neutral` | `info` | `success` | `warning` | `error`), `marker` (fills the 24px circle in place of the ringed dot), `icon` (a glyph inside the ring, painted by `tone`), `skipped`, `stopped`, `stoppedLabel`, `meta` (`TimelineMetaEntry[]`: `label`, `value`).
125
- - **`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).
125
+ - **`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), `rowDensity` (`default`; `compact`, about 30px rows; `snug`, 38px rows with 12px side padding and a tighter header), `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).
126
126
  - **`Statistic`** — Displays a statistic value with a label; primary/secondary sizes. _Key props:_ `StatisticValueSize`.
127
127
  - **`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"`.
128
128
  - **`ZoomableImage`** — An image shown inline as a button that enlarges it, for a screenshot too detailed to read at its inline size. The thumbnail is shown at its own width up to the width of its container, never stretched, and stops at 240px tall, cropping a tall image to its top. The enlarged image sits on the scrim with no card, as large as the window allows at its own aspect ratio, up to its natural size, and a click anywhere or ESC closes it. The thumbnail is named `Enlarge image: <alt>` and the dialog is named by `title`, or by `alt` when `title` is missing or empty, so `alt` must be non-empty. `onError` reports a thumbnail that failed to load, so the caller can leave it out rather than show a broken image. The thumbnail loads lazily, so for one below the fold that report comes once it nears the viewport, not on render. _Key props:_ `src`, `alt`, `title`, `onError`.
@@ -1,44 +1,44 @@
1
1
  import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
- import { useState as L, useId as v, useMemo as E } from "react";
3
- import M from "./CopyOverlayButton.js";
4
- import j from "./CustomIcons/CaretDownIcon.js";
2
+ import { useState as M, useId as N, useMemo as E } from "react";
3
+ import j from "./CopyOverlayButton.js";
4
+ import B from "./CustomIcons/CaretDownIcon.js";
5
5
  import i from "./Typography/Text.js";
6
- import { rowsWrapperStyle as U } from "./codeBlockStyles.js";
7
- import { FOCUS_RING_INSET as I, FOCUS_RING as W } from "./focusRing.js";
8
- import { isRenderableNode as B } from "./renderableNode.js";
6
+ import { rowsWrapperStyle as L } from "./codeBlockStyles.js";
7
+ import { FOCUS_RING_INSET as I, FOCUS_RING as U } from "./focusRing.js";
8
+ import { isRenderableNode as W } from "./renderableNode.js";
9
9
  import { canCopyToClipboard as G } from "./useClipboardCopy.js";
10
- const w = 5, C = 2e3, H = 360, S = "var(--malachite-card-border,rgb(232,232,232))", $ = "var(--malachite-card-subtle-divider,rgb(241,241,241))", P = (e) => e === "" ? [] : e.replace(/\r?\n$/, "").split(/\r\n|\r|\n/), _ = (e, l) => !Number.isNaN(e) && e >= 1 ? Math.floor(e) : l, V = (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", X = (e, l, c) => {
10
+ const w = 5, C = 2e3, H = 360, P = (e) => e ? 11 : 6, S = "var(--malachite-card-border,rgb(232,232,232))", $ = "var(--malachite-card-subtle-divider,rgb(241,241,241))", V = (e) => e === "" ? [] : e.replace(/\r?\n$/, "").split(/\r\n|\r|\n/), k = (e, l) => !Number.isNaN(e) && e >= 1 ? Math.floor(e) : l, X = (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", Y = (e, l, c) => {
11
11
  if (e)
12
12
  return "Show Less";
13
- const s = c > 0 ? ` · ${c} flagged` : "";
14
- return `Show All ${l} Lines${s}`;
15
- }, te = ({
13
+ const n = c > 0 ? ` · ${c} flagged` : "";
14
+ return `Show All ${l} Lines${n}`;
15
+ }, oe = ({
16
16
  title: e,
17
17
  meta: l,
18
18
  titleHidden: c = !1,
19
- code: s,
20
- previewLines: k = w,
21
- highlightLines: f = [],
22
- showLineNumbers: d = !0,
23
- copyable: z = !1,
24
- maxRenderedLines: D = C,
25
- className: R = ""
19
+ code: n,
20
+ previewLines: R = w,
21
+ highlightLines: y = [],
22
+ showLineNumbers: s = !0,
23
+ copyable: _ = !1,
24
+ maxRenderedLines: z = C,
25
+ className: D = ""
26
26
  }) => {
27
- const [p, O] = L(!1), y = z && G(), m = v(), u = v(), a = E(() => P(s), [s]), b = E(
27
+ const [p, O] = M(!1), x = _ && G(), m = N(), u = N(), a = E(() => V(n), [n]), b = E(
28
28
  () => new Set(
29
- f.filter(
29
+ y.filter(
30
30
  (t) => Number.isInteger(t) && t >= 1 && t <= a.length
31
31
  )
32
32
  ),
33
- [f, a.length]
34
- ), x = _(k, w), N = a.length > x, h = p || !N, g = Math.min(
35
- h ? a.length : x,
36
- _(D, C)
37
- ), T = a.slice(0, g), A = [...b].filter((t) => t > x).length, F = `max(40px, calc(${String(a.length).length}ch + 14px))`;
33
+ [y, a.length]
34
+ ), g = k(R, w), v = a.length > g, h = p || !v, f = Math.min(
35
+ h ? a.length : g,
36
+ k(z, C)
37
+ ), T = a.slice(0, f), A = [...b].filter((t) => t > g).length, F = `max(40px, calc(${String(a.length).length}ch + 14px))`;
38
38
  return /* @__PURE__ */ o(
39
39
  "div",
40
40
  {
41
- className: `overflow-hidden rounded-[var(--malachite-radius-10,10px)] border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] ${R}`,
41
+ className: `overflow-hidden rounded-[var(--malachite-radius-10,10px)] border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] ${D}`,
42
42
  style: { borderColor: S },
43
43
  children: [
44
44
  c ? /* @__PURE__ */ r("span", { id: m, className: "sr-only", children: e }) : /* @__PURE__ */ o(
@@ -48,7 +48,7 @@ const w = 5, C = 2e3, H = 360, S = "var(--malachite-card-border,rgb(232,232,232)
48
48
  style: { borderColor: $ },
49
49
  children: [
50
50
  /* @__PURE__ */ r("span", { id: m, className: "flex min-w-0", children: /* @__PURE__ */ r(i, { size: "xsmall", color: "secondary", fontWeight: "semi-bold", children: e }) }),
51
- B(l) && /* @__PURE__ */ r(
51
+ W(l) && /* @__PURE__ */ r(
52
52
  i,
53
53
  {
54
54
  size: "xsmall",
@@ -70,61 +70,62 @@ const w = 5, C = 2e3, H = 360, S = "var(--malachite-card-border,rgb(232,232,232)
70
70
  role: "region",
71
71
  "aria-labelledby": m,
72
72
  tabIndex: 0,
73
- className: `m-0 overflow-auto font-mono text-[length:var(--malachite-font-size-xsmall,11px)] ${d ? "py-[6px] leading-[14px]" : "py-[10px] leading-[1.65]"} text-[var(--malachite-text-primary,rgb(10,10,10))] ${I}`,
73
+ className: `m-0 overflow-auto font-mono text-[length:var(--malachite-font-size-xsmall,11px)] ${s ? "leading-[14px]" : "py-[10px] leading-[1.65]"} text-[var(--malachite-text-primary,rgb(10,10,10))] ${I}`,
74
74
  style: {
75
75
  maxHeight: H,
76
- paddingInlineEnd: y ? 40 : void 0
76
+ paddingInlineEnd: x ? 40 : void 0,
77
+ paddingBlock: s ? P(x) : void 0
77
78
  },
78
- children: /* @__PURE__ */ o("span", { className: "block", style: U(!1), children: [
79
- T.map((t, n) => (
79
+ children: /* @__PURE__ */ o("span", { className: "block", style: L(!1), children: [
80
+ T.map((t, d) => (
80
81
  // A line's position is its identity: its text can repeat.
81
82
  /* @__PURE__ */ o(
82
83
  "span",
83
84
  {
84
- "data-flagged": b.has(n + 1) || void 0,
85
- className: V(b.has(n + 1)),
85
+ "data-flagged": b.has(d + 1) || void 0,
86
+ className: X(b.has(d + 1)),
86
87
  children: [
87
- d && /* @__PURE__ */ r(
88
+ s && /* @__PURE__ */ r(
88
89
  "span",
89
90
  {
90
91
  "aria-hidden": "true",
91
92
  className: "flex-none select-none pe-[10px] text-end text-[var(--malachite-text-dimmed,rgb(161,161,161))]",
92
93
  style: { width: F },
93
- children: n + 1
94
+ children: d + 1
94
95
  }
95
96
  ),
96
97
  /* @__PURE__ */ o(
97
98
  "span",
98
99
  {
99
- className: `min-w-0 whitespace-pre ${d ? "" : "px-[11px]"}`,
100
+ className: `min-w-0 whitespace-pre ${s ? "" : "px-[11px]"}`,
100
101
  children: [
101
- b.has(n + 1) && /* @__PURE__ */ r("span", { className: "sr-only select-none", children: "Flagged: " }),
102
+ b.has(d + 1) && /* @__PURE__ */ r("span", { className: "sr-only select-none", children: "Flagged: " }),
102
103
  t || " "
103
104
  ]
104
105
  }
105
106
  )
106
107
  ]
107
108
  },
108
- n
109
+ d
109
110
  )
110
111
  )),
111
- !h && !d && /* @__PURE__ */ r("span", { "aria-hidden": "true", className: "block select-none px-[14px]", children: "…" })
112
+ !h && !s && /* @__PURE__ */ r("span", { "aria-hidden": "true", className: "block select-none px-[14px]", children: "…" })
112
113
  ] })
113
114
  }
114
115
  ),
115
- y && /* @__PURE__ */ r(
116
- M,
116
+ x && /* @__PURE__ */ r(
117
+ j,
117
118
  {
118
- text: s,
119
+ text: n,
119
120
  "aria-label": `Copy ${e}`,
120
121
  iconSize: 12,
121
- className: `absolute end-[6px] top-[6px] z-[1] flex cursor-pointer items-center justify-center rounded-md border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] p-[5px] text-[var(--malachite-text-secondary,rgb(115,115,115))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${W}`,
122
+ className: `absolute end-[6px] top-[6px] z-[1] flex cursor-pointer items-center justify-center rounded-md border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] p-[5px] text-[var(--malachite-text-secondary,rgb(115,115,115))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${U}`,
122
123
  style: { borderColor: S }
123
124
  }
124
125
  )
125
126
  ] }),
126
- h && g < a.length && /* @__PURE__ */ r(i, { as: "p", size: "xsmall", color: "secondary", className: "m-0 px-[12px] pb-[8px]", children: `Showing the first ${g.toLocaleString()} of ${a.length.toLocaleString()} lines.` }),
127
- N && /* @__PURE__ */ o(
127
+ h && f < a.length && /* @__PURE__ */ r(i, { as: "p", size: "xsmall", color: "secondary", className: "m-0 px-[12px] pb-[8px]", children: `Showing the first ${f.toLocaleString()} of ${a.length.toLocaleString()} lines.` }),
128
+ v && /* @__PURE__ */ o(
128
129
  "button",
129
130
  {
130
131
  type: "button",
@@ -135,9 +136,9 @@ const w = 5, C = 2e3, H = 360, S = "var(--malachite-card-border,rgb(232,232,232)
135
136
  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))] ${I}`,
136
137
  style: { borderColor: $ },
137
138
  children: [
138
- /* @__PURE__ */ r(i, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", children: X(p, a.length, A) }),
139
+ /* @__PURE__ */ r(i, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", children: Y(p, a.length, A) }),
139
140
  /* @__PURE__ */ r("span", { "aria-hidden": "true", className: "flex", children: /* @__PURE__ */ r(
140
- j,
141
+ B,
141
142
  {
142
143
  size: 12,
143
144
  className: "transition-transform",
@@ -152,7 +153,7 @@ const w = 5, C = 2e3, H = 360, S = "var(--malachite-card-border,rgb(232,232,232)
152
153
  );
153
154
  };
154
155
  export {
155
- te as CodePreview,
156
- te as default
156
+ oe as CodePreview,
157
+ oe as default
157
158
  };
158
159
  //# sourceMappingURL=CodePreview.js.map
@@ -1 +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 CopyOverlayButton from './CopyOverlayButton';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport Text from './Typography/Text';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { canCopyToClipboard } from './useClipboardCopy';\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 /** Drops the header, `meta` with it, for a payload whose surroundings already name it. The\n * title still names it for assistive tech. */\n titleHidden?: boolean;\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 /** A button over the body copies the whole payload, folded lines too. */\n copyable?: 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 titleHidden = false,\n code,\n previewLines = DEFAULT_PREVIEW_LINES,\n highlightLines = [],\n showLineNumbers = true,\n copyable = false,\n maxRenderedLines = DEFAULT_MAX_RENDERED_LINES,\n className = '',\n}) => {\n const [expanded, setExpanded] = useState(false);\n const showsCopy = copyable && canCopyToClipboard();\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 {titleHidden ? (\n <span id={titleId} className=\"sr-only\">\n {title}\n </span>\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 )}\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 <div className=\"relative\">\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={{\n maxHeight: MAX_BODY_HEIGHT,\n paddingInlineEnd: showsCopy ? 40 : undefined,\n }}\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 {showsCopy && (\n <CopyOverlayButton\n text={code}\n aria-label={`Copy ${title}`}\n iconSize={12}\n className={`absolute end-[6px] top-[6px] z-[1] flex cursor-pointer items-center justify-center rounded-md border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] p-[5px] text-[var(--malachite-text-secondary,rgb(115,115,115))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING}`}\n style={{ borderColor: BORDER }}\n />\n )}\n </div>\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","titleHidden","previewLines","highlightLines","showLineNumbers","copyable","maxRenderedLines","className","setExpanded","useState","showsCopy","canCopyToClipboard","titleId","useId","bodyId","lines","useMemo","line","limit","foldable","open","rendered","shown","gutter","jsxs","jsx","Text","isRenderableNode","FOCUS_RING_INSET","rowsWrapperStyle","index","CopyOverlayButton","FOCUS_RING","isOpen","CaretDownIcon"],"mappings":";;;;;;;;;AA+BA,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,KAA0C,CAAC;AAAA,EAC7C,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAAd;AAAA,EACA,cAAAe,IAAerB;AAAA,EACf,gBAAAsB,IAAiB,CAAA;AAAA,EACjB,iBA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cAAA,gBAAAwC,EAACC,GAAA,EAAK,MAAK,UAAS,YAAW,aAAY,OAAM,WAC5C,UAAAjC,EAAYC,GAAUqB,EAAM,QAAQnB,CAAW,GACpD;AAAA,cACA,gBAAA6B,EAAC,QAAA,EAAK,eAAY,QAAO,WAAU,QAC/B,UAAA,gBAAAA;AAAA,gBAACS;AAAA,gBAAA;AAAA,kBACG,MAAM;AAAA,kBACN,WAAU;AAAA,kBACV,OAAO,EAAE,WAAWxC,IAAW,mBAAmB,OAAA;AAAA,gBAAU;AAAA,cAAA,EAChE,CACJ;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACJ;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
1
+ {"version":3,"file":"CodePreview.js","sources":["../../src/components/CodePreview.tsx"],"sourcesContent":["import type React from 'react';\nimport { useId, useMemo, useState } from 'react';\nimport CopyOverlayButton from './CopyOverlayButton';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport Text from './Typography/Text';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { canCopyToClipboard } from './useClipboardCopy';\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 /** Drops the header, `meta` with it, for a payload whose surroundings already name it. The\n * title still names it for assistive tech. */\n titleHidden?: boolean;\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 /** A button over the body copies the whole payload, folded lines too. */\n copyable?: 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;\nconst numberedRowsPadding = (showsCopy: boolean) => (showsCopy ? 11 : 6);\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 titleHidden = false,\n code,\n previewLines = DEFAULT_PREVIEW_LINES,\n highlightLines = [],\n showLineNumbers = true,\n copyable = false,\n maxRenderedLines = DEFAULT_MAX_RENDERED_LINES,\n className = '',\n}) => {\n const [expanded, setExpanded] = useState(false);\n const showsCopy = copyable && canCopyToClipboard();\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 {titleHidden ? (\n <span id={titleId} className=\"sr-only\">\n {title}\n </span>\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 )}\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 <div className=\"relative\">\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, with room for the copy button beside one line; a bare payload keeps code spacing.\n className={`m-0 overflow-auto font-mono text-[length:var(--malachite-font-size-xsmall,11px)] ${showLineNumbers ? 'leading-[14px]' : 'py-[10px] leading-[1.65]'} text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING_INSET}`}\n style={{\n maxHeight: MAX_BODY_HEIGHT,\n paddingInlineEnd: showsCopy ? 40 : undefined,\n paddingBlock: showLineNumbers\n ? numberedRowsPadding(showsCopy)\n : undefined,\n }}\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 {showsCopy && (\n <CopyOverlayButton\n text={code}\n aria-label={`Copy ${title}`}\n iconSize={12}\n className={`absolute end-[6px] top-[6px] z-[1] flex cursor-pointer items-center justify-center rounded-md border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] p-[5px] text-[var(--malachite-text-secondary,rgb(115,115,115))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING}`}\n style={{ borderColor: BORDER }}\n />\n )}\n </div>\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","numberedRowsPadding","showsCopy","BORDER","DIVIDER","linesOf","code","countOf","value","fallback","lineClasses","flagged","toggleLabel","expanded","total","hiddenFlags","flags","CodePreview","title","meta","titleHidden","previewLines","highlightLines","showLineNumbers","copyable","maxRenderedLines","className","setExpanded","useState","canCopyToClipboard","titleId","useId","bodyId","lines","useMemo","line","limit","foldable","open","rendered","shown","gutter","jsxs","jsx","Text","isRenderableNode","FOCUS_RING_INSET","rowsWrapperStyle","index","CopyOverlayButton","FOCUS_RING","isOpen","CaretDownIcon"],"mappings":";;;;;;;;;AA+BA,MAAMA,IAAwB,GACxBC,IAA6B,KAG7BC,IAAkB,KAClBC,IAAsB,CAACC,MAAwBA,IAAY,KAAK,GAEhEC,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,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