@stackone/malachite 2.134.0 → 2.134.2
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/dist/components/ChangeReview/ChangeReviewItem.js +19 -19
- package/dist/components/ChangeReview/ChangeReviewItem.js.map +1 -1
- package/dist/components/CodePreview.js +41 -41
- package/dist/components/CodePreview.js.map +1 -1
- package/dist/components/Input/Input.js +126 -112
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/PageLayout/constants.js +17 -11
- package/dist/components/PageLayout/constants.js.map +1 -1
- package/dist/components/PageLayout/pageColumn.js +18 -24
- package/dist/components/PageLayout/pageColumn.js.map +1 -1
- package/dist/components/PageLayout/pageColumns.js +9 -10
- package/dist/components/PageLayout/pageColumns.js.map +1 -1
- package/dist/components/PageLayout/regularLayout.js +5 -5
- package/dist/components/PageLayout/regularLayout.js.map +1 -1
- package/dist/fontFace.js +20 -0
- package/dist/fontFace.js.map +1 -0
- package/dist/fontInjection.js.map +1 -1
- package/dist/geist-font.inline.js +7 -0
- package/dist/geist-font.inline.js.map +1 -0
- package/dist/geist-font.js +13 -14
- package/dist/geist-font.js.map +1 -1
- package/dist/inter-font.inline.js +22 -0
- package/dist/inter-font.inline.js.map +1 -0
- package/dist/inter-font.js +25 -26
- package/dist/inter-font.js.map +1 -1
- package/dist/stack-sans-font.inline.js +6 -0
- package/dist/stack-sans-font.inline.js.map +1 -0
- package/dist/stack-sans-font.js +9 -8
- package/dist/stack-sans-font.js.map +1 -1
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-400-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-400-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-400-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-400-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-400-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-500-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-500-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-500-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-500-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/geist-sans/files/geist-sans-latin-500-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-400-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-400-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-400-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-400-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-400-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-500-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-500-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-500-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-500-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-500-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-600-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-600-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-600-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-600-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-600-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-700-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-700-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-700-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-700-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-700-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-400-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-400-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-400-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-400-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-400-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-500-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-500-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-500-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-500-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-500-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-600-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-600-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-600-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-600-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-600-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-700-normal.woff2 +0 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-700-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-700-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-700-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource/inter/files/inter-latin-ext-700-normal.woff2.js.map +1 -1
- package/dist/vendor/@fontsource-variable/stack-sans-text/files/stack-sans-text-latin-wght-normal.woff2 +0 -0
- package/dist/vendor/@fontsource-variable/stack-sans-text/files/stack-sans-text-latin-wght-normal.woff2.inline.js +5 -0
- package/dist/vendor/@fontsource-variable/stack-sans-text/files/stack-sans-text-latin-wght-normal.woff2.inline.js.map +1 -0
- package/dist/vendor/@fontsource-variable/stack-sans-text/files/stack-sans-text-latin-wght-normal.woff2.js +2 -2
- package/dist/vendor/@fontsource-variable/stack-sans-text/files/stack-sans-text-latin-wght-normal.woff2.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as r, jsx as t, Fragment as
|
|
1
|
+
import { jsxs as r, jsx as t, Fragment as z } from "react/jsx-runtime";
|
|
2
2
|
import { useState as S } from "react";
|
|
3
|
-
import { Button as
|
|
3
|
+
import { Button as k } from "../Button.js";
|
|
4
4
|
import C from "../CustomIcons/SparkleIcon.js";
|
|
5
5
|
import I from "../Tooltip.js";
|
|
6
6
|
import { Typography as l } from "../Typography/index.js";
|
|
@@ -8,7 +8,7 @@ const w = {
|
|
|
8
8
|
changed: "Changed",
|
|
9
9
|
added: "Added",
|
|
10
10
|
removed: "To be removed"
|
|
11
|
-
}, R = (e, s) => e === "removed" ? `Marked for removal by ${s}. Accept to remove it, or revert to keep it.` : `${w[e]} by ${s}. Accept to keep it, or revert to restore the previous value.`, j = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : !1,
|
|
11
|
+
}, N = { fontSize: 11, lineHeight: 1 }, R = (e, s) => e === "removed" ? `Marked for removal by ${s}. Accept to remove it, or revert to keep it.` : `${w[e]} by ${s}. Accept to keep it, or revert to restore the previous value.`, j = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : !1, W = ({
|
|
12
12
|
label: e,
|
|
13
13
|
fieldName: s,
|
|
14
14
|
before: o,
|
|
@@ -17,20 +17,20 @@ const w = {
|
|
|
17
17
|
origin: d = "assistant",
|
|
18
18
|
children: m,
|
|
19
19
|
onApprove: A,
|
|
20
|
-
onDeny:
|
|
20
|
+
onDeny: T,
|
|
21
21
|
headerActions: p,
|
|
22
22
|
onPreviewRevert: i,
|
|
23
23
|
disabled: f = !1,
|
|
24
24
|
className: h = ""
|
|
25
25
|
}) => {
|
|
26
|
-
const [
|
|
26
|
+
const [$, g] = S(!1), n = s ?? (typeof e == "string" ? e : void 0), u = () => {
|
|
27
27
|
i !== void 0 && (g(!0), i(!0));
|
|
28
28
|
}, v = () => {
|
|
29
29
|
i !== void 0 && (g(!1), i(!1));
|
|
30
30
|
}, x = /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
31
31
|
typeof e == "string" ? /* @__PURE__ */ t(l.Text, { size: "small", fontWeight: "semi-bold", children: e }) : e,
|
|
32
32
|
/* @__PURE__ */ t("span", { className: "sr-only", children: `${w[c]} by ${d}` })
|
|
33
|
-
] }), y =
|
|
33
|
+
] }), y = /* @__PURE__ */ r(
|
|
34
34
|
"div",
|
|
35
35
|
{
|
|
36
36
|
className: "flex flex-shrink-0 items-center gap-1 rounded-md px-1",
|
|
@@ -46,14 +46,14 @@ const w = {
|
|
|
46
46
|
}
|
|
47
47
|
) }),
|
|
48
48
|
/* @__PURE__ */ t(
|
|
49
|
-
|
|
49
|
+
k,
|
|
50
50
|
{
|
|
51
51
|
variant: "destructive",
|
|
52
52
|
size: "xsmall",
|
|
53
53
|
iconOnly: !0,
|
|
54
54
|
"aria-label": n === void 0 ? "Revert change" : `Revert ${n}`,
|
|
55
55
|
disabled: f,
|
|
56
|
-
onClick:
|
|
56
|
+
onClick: T,
|
|
57
57
|
onMouseEnter: u,
|
|
58
58
|
onMouseLeave: v,
|
|
59
59
|
onFocus: u,
|
|
@@ -61,12 +61,12 @@ const w = {
|
|
|
61
61
|
icon: (
|
|
62
62
|
/* Reload rather than a cross: reverting restores the previous value rather
|
|
63
63
|
than dismissing the field. */
|
|
64
|
-
/* @__PURE__ */ t("span", { "aria-hidden": "true", style:
|
|
64
|
+
/* @__PURE__ */ t("span", { "aria-hidden": "true", style: N, children: "↺" })
|
|
65
65
|
)
|
|
66
66
|
}
|
|
67
67
|
),
|
|
68
68
|
/* @__PURE__ */ t(
|
|
69
|
-
|
|
69
|
+
k,
|
|
70
70
|
{
|
|
71
71
|
variant: "success",
|
|
72
72
|
size: "xsmall",
|
|
@@ -74,12 +74,12 @@ const w = {
|
|
|
74
74
|
"aria-label": n === void 0 ? "Accept change" : `Accept ${n}`,
|
|
75
75
|
disabled: f,
|
|
76
76
|
onClick: A,
|
|
77
|
-
icon: /* @__PURE__ */ t("span", { "aria-hidden": "true", style:
|
|
77
|
+
icon: /* @__PURE__ */ t("span", { "aria-hidden": "true", style: N, children: "✓" })
|
|
78
78
|
}
|
|
79
79
|
)
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
|
-
),
|
|
82
|
+
), b = /* @__PURE__ */ r(z, { children: [
|
|
83
83
|
(o !== void 0 || a !== void 0) && /* @__PURE__ */ r("div", { className: "flex flex-wrap items-baseline gap-1", children: [
|
|
84
84
|
/* @__PURE__ */ r(l.SecondaryText, { size: "small", children: [
|
|
85
85
|
"Was ",
|
|
@@ -95,7 +95,7 @@ const w = {
|
|
|
95
95
|
}
|
|
96
96
|
)
|
|
97
97
|
] }),
|
|
98
|
-
|
|
98
|
+
$ && /* @__PURE__ */ t(l.SecondaryText, { size: "small", children: "Previewing the revert — release to keep the AI value" })
|
|
99
99
|
] });
|
|
100
100
|
return m !== void 0 ? /* @__PURE__ */ r(
|
|
101
101
|
"div",
|
|
@@ -107,11 +107,11 @@ const w = {
|
|
|
107
107
|
x,
|
|
108
108
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
109
109
|
p,
|
|
110
|
-
|
|
110
|
+
y
|
|
111
111
|
] })
|
|
112
112
|
] }),
|
|
113
113
|
m,
|
|
114
|
-
/* @__PURE__ */ t("div", { className: "flex flex-col gap-1", children:
|
|
114
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-1", children: b })
|
|
115
115
|
]
|
|
116
116
|
}
|
|
117
117
|
) : /* @__PURE__ */ r(
|
|
@@ -122,16 +122,16 @@ const w = {
|
|
|
122
122
|
children: [
|
|
123
123
|
/* @__PURE__ */ r("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
124
124
|
x,
|
|
125
|
-
|
|
125
|
+
b
|
|
126
126
|
] }),
|
|
127
127
|
p,
|
|
128
|
-
|
|
128
|
+
y
|
|
129
129
|
]
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
132
|
};
|
|
133
133
|
export {
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
W as ChangeReviewItem,
|
|
135
|
+
W as default
|
|
136
136
|
};
|
|
137
137
|
//# sourceMappingURL=ChangeReviewItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeReviewItem.js","sources":["../../../src/components/ChangeReview/ChangeReviewItem.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport Button from '../Button';\nimport SparkleIcon from '../CustomIcons/SparkleIcon';\nimport Tooltip from '../Tooltip';\nimport { Typography } from '../Typography';\n\nexport type ChangeKind = 'changed' | 'added' | 'removed';\n\nexport interface ChangeReviewItemProps {\n /**\n * What changed — a field name, or the name of a group of them. Omit it when the field this\n * item annotates already carries its own visible heading elsewhere on the page (so the name\n * doesn't render twice) — pass `fieldName` instead, so the badge and actions still know what\n * they belong to.\n *\n * A node rather than a string, because a field's heading is not always only its name: one\n * with an explainer behind an info icon has to hand the whole heading over, or it loses the\n * icon for as long as it is marked. A node carries no accessible name, so `fieldName` is\n * required alongside anything that is not a plain string.\n */\n label?: React.ReactNode;\n /**\n * Names the field the badge and actions act on, for assistive tech. Defaults to `label`, so\n * passing only `label` keeps working as before. Set it explicitly when `label` is omitted —\n * otherwise \"Accept\"/\"Revert\" would have nothing telling a screen reader which field they act\n * on.\n */\n fieldName?: string;\n /** How it read before. A node, so a caller can show chips or code rather than a string. */\n before?: React.ReactNode;\n /** How it reads now. Usually omitted: the field itself is showing it. */\n after?: React.ReactNode;\n kind?: ChangeKind;\n /** What made the change. Names the assistant by default. */\n origin?: string;\n /**\n * The field the change is annotating. When given, the tag/label/actions form a header band\n * above it and the before/after line moves below it, so \"Was …\" reads next to the value it\n * describes instead of stacked with the header. Omit it for the standalone card.\n */\n children?: React.ReactNode;\n /**\n * The caller's own controls for this field, in the header band beside accept and revert.\n * A capability's Remove belongs to the field rather than to the review, but while the field\n * is marked the header is the only row its heading has, so without a slot here the button\n * has nowhere to sit that is not on top of something.\n */\n headerActions?: React.ReactNode;\n onApprove: () => void;\n onDeny: () => void;\n /**\n * Fires while the revert control is hovered or focused, and again when it stops being\n * either. A callback rather than internal state because the thing being previewed — the\n * field this change came from — lives elsewhere on the page, outside what `Item` renders;\n * only the caller can swap what that field shows.\n */\n onPreviewRevert?: (previewing: boolean) => void;\n disabled?: boolean;\n className?: string;\n}\n\nconst KIND_WORDS: Record<ChangeKind, string> = {\n changed: 'Changed',\n added: 'Added',\n removed: 'To be removed',\n};\n\n/**\n * What the \"AI\" pill means, for its tooltip. The badge is two letters, which says who wrote\n * the value but not that the reader is expected to do something about it — and the accept and\n * revert controls it refers to are hidden until the row is hovered or focused.\n */\nconst badgeTooltip = (kind: ChangeKind, origin: string): string =>\n kind === 'removed'\n ? `Marked for removal by ${origin}. Accept to remove it, or revert to keep it.`\n : `${KIND_WORDS[kind]} by ${origin}. Accept to keep it, or revert to restore the previous value.`;\n\n// A multi-select with nothing chosen reaches this as `[]`, not `undefined` — that, a blank or\n// whitespace-only string, and an absent value all read as \"nothing was there\" rather than\n// printing nothing (or, worse, the literal word \"undefined\").\nconst isEmptyDisplacedValue = (value: React.ReactNode): boolean => {\n if (value === undefined || value === null) {\n return true;\n }\n if (typeof value === 'string') {\n return value.trim() === '';\n }\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n return false;\n};\n\n/**\n * Says that something on screen was changed by a machine, shows what it displaced, and offers\n * the two ways out.\n *\n * Accept is deliberately the heavier control (filled, dark) against Revert's quiet outline —\n * the design leans toward accepting the assistant's change rather than presenting both as\n * equal options. That is the designer's call to make, not this component's.\n *\n * The actions are always visible. Revealing them on hover was tried and dropped: a change\n * waiting on a decision is the point of the row, and hiding the only two controls that\n * resolve it made them easy to miss — and unreachable on a touch screen, which has no hover\n * to reveal them with.\n */\nconst ChangeReviewItem: React.FC<ChangeReviewItemProps> = ({\n label,\n fieldName,\n before,\n after,\n kind = 'changed',\n origin = 'assistant',\n children,\n onApprove,\n onDeny,\n headerActions,\n onPreviewRevert,\n disabled = false,\n className = '',\n}) => {\n const [isPreviewingRevert, setIsPreviewingRevert] = useState(false);\n const accessibleFieldName = fieldName ?? (typeof label === 'string' ? label : undefined);\n\n // No-ops when `onPreviewRevert` is absent, which also keeps `isPreviewingRevert` from ever\n // flipping true — so the hint below never renders unless a caller asked for the feature.\n const startRevertPreview = () => {\n if (onPreviewRevert === undefined) {\n return;\n }\n setIsPreviewingRevert(true);\n onPreviewRevert(true);\n };\n\n const endRevertPreview = () => {\n if (onPreviewRevert === undefined) {\n return;\n }\n setIsPreviewingRevert(false);\n onPreviewRevert(false);\n };\n\n const badgeAndLabel = (\n <div className=\"flex flex-wrap items-center gap-2\">\n {typeof label === 'string' ? (\n <Typography.Text size=\"small\" fontWeight=\"semi-bold\">\n {label}\n </Typography.Text>\n ) : (\n label\n )}\n <span className=\"sr-only\">{`${KIND_WORDS[kind]} by ${origin}`}</span>\n </div>\n );\n\n /*\n * The mark and the actions, as one tray.\n *\n * One box with the tag fill rather than two boxes meeting: the sparkle keeps that fill and\n * no shape of its own, so it reads as a marker, and the two actions sit inset on the lighter\n * assistant surface. Two violets a step apart separate what this is from what you can do\n * about it, with no border needed.\n *\n * The glyphs are sized in the style rather than by a class: the button centres whatever it\n * is given, and a bare arrow inherits the control's own font size otherwise.\n *\n * Always visible, not revealed on hover: a change waiting on a decision is the point of the\n * row, and hiding the only two controls that resolve it made them easy to miss entirely,\n * and unreachable on a touch screen.\n */\n const glyphStyle: React.CSSProperties = { fontSize: 11, lineHeight: 1 };\n\n const tray = (\n <div\n className=\"flex flex-shrink-0 items-center gap-1 rounded-md px-1\"\n style={{ background: 'var(--malachite-tag-assistant-background)', height: 24 }}\n >\n <Tooltip text={badgeTooltip(kind, origin)}>\n <span\n aria-hidden=\"true\"\n className=\"flex flex-shrink-0 items-center justify-center\"\n style={{ color: 'var(--malachite-tag-assistant-foreground)' }}\n >\n <SparkleIcon size={11} />\n </span>\n </Tooltip>\n <Button\n variant=\"destructive\"\n size=\"xsmall\"\n iconOnly\n aria-label={\n accessibleFieldName === undefined\n ? 'Revert change'\n : `Revert ${accessibleFieldName}`\n }\n disabled={disabled}\n onClick={onDeny}\n onMouseEnter={startRevertPreview}\n onMouseLeave={endRevertPreview}\n onFocus={startRevertPreview}\n onBlur={endRevertPreview}\n icon={\n /* Reload rather than a cross: reverting restores the previous value rather\n than dismissing the field. */\n <span aria-hidden=\"true\" style={glyphStyle}>\n ↺\n </span>\n }\n />\n <Button\n variant=\"success\"\n size=\"xsmall\"\n iconOnly\n aria-label={\n accessibleFieldName === undefined\n ? 'Accept change'\n : `Accept ${accessibleFieldName}`\n }\n disabled={disabled}\n onClick={onApprove}\n icon={\n <span aria-hidden=\"true\" style={glyphStyle}>\n ✓\n </span>\n }\n />\n </div>\n );\n\n const displaysChange = before !== undefined || after !== undefined;\n\n const beforeAfter = (\n <>\n {displaysChange && (\n <div className=\"flex flex-wrap items-baseline gap-1\">\n <Typography.SecondaryText size=\"small\">\n {/* Struck through, so a glance separates what it was from what it is\n without having to read the labels. */}\n Was {isEmptyDisplacedValue(before) ? <i>empty</i> : <s>{before}</s>}\n {after !== undefined ? ' →' : null}\n </Typography.SecondaryText>\n {after !== undefined && (\n <Typography.Text\n size=\"small\"\n style={{ color: 'var(--malachite-assistant-foreground)' }}\n >\n {after}\n </Typography.Text>\n )}\n </div>\n )}\n {isPreviewingRevert && (\n <Typography.SecondaryText size=\"small\">\n Previewing the revert — release to keep the AI value\n </Typography.SecondaryText>\n )}\n </>\n );\n\n // With a field to wrap, the header (tag/label/actions) and the before/after line split\n // to opposite sides of `children` instead of sitting together above it — see the\n // component doc comment on `children`.\n if (children !== undefined) {\n return (\n <div\n className={`flex flex-col gap-2 rounded-lg p-2 ${className}`}\n style={{ background: 'var(--malachite-assistant-surface-background)' }}\n >\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n {badgeAndLabel}\n <div className=\"flex flex-wrap items-center gap-2\">\n {headerActions}\n {tray}\n </div>\n </div>\n {children}\n <div className=\"flex flex-col gap-1\">{beforeAfter}</div>\n </div>\n );\n }\n\n return (\n <div\n className={`flex items-start gap-2 rounded-lg p-2 ${className}`}\n style={{ background: 'var(--malachite-assistant-surface-background)' }}\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n {badgeAndLabel}\n {beforeAfter}\n </div>\n {headerActions}\n {tray}\n </div>\n );\n};\n\nexport default ChangeReviewItem;\nexport { ChangeReviewItem };\n"],"names":["KIND_WORDS","badgeTooltip","kind","origin","isEmptyDisplacedValue","value","ChangeReviewItem","label","fieldName","before","after","children","onApprove","onDeny","headerActions","onPreviewRevert","disabled","className","isPreviewingRevert","setIsPreviewingRevert","useState","accessibleFieldName","startRevertPreview","endRevertPreview","badgeAndLabel","jsxs","jsx","Typography","glyphStyle","tray","Tooltip","SparkleIcon","Button","beforeAfter","Fragment"],"mappings":";;;;;;AA6DA,MAAMA,IAAyC;AAAA,EAC3C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AACb,GAOMC,IAAe,CAACC,GAAkBC,MACpCD,MAAS,YACH,yBAAyBC,CAAM,iDAC/B,GAAGH,EAAWE,CAAI,CAAC,OAAOC,CAAM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tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport Button from '../Button';\nimport SparkleIcon from '../CustomIcons/SparkleIcon';\nimport Tooltip from '../Tooltip';\nimport { Typography } from '../Typography';\n\nexport type ChangeKind = 'changed' | 'added' | 'removed';\n\nexport interface ChangeReviewItemProps {\n /**\n * What changed — a field name, or the name of a group of them. Omit it when the field this\n * item annotates already carries its own visible heading elsewhere on the page (so the name\n * doesn't render twice) — pass `fieldName` instead, so the badge and actions still know what\n * they belong to.\n *\n * A node rather than a string, because a field's heading is not always only its name: one\n * with an explainer behind an info icon has to hand the whole heading over, or it loses the\n * icon for as long as it is marked. A node carries no accessible name, so `fieldName` is\n * required alongside anything that is not a plain string.\n */\n label?: React.ReactNode;\n /**\n * Names the field the badge and actions act on, for assistive tech. Defaults to `label`, so\n * passing only `label` keeps working as before. Set it explicitly when `label` is omitted —\n * otherwise \"Accept\"/\"Revert\" would have nothing telling a screen reader which field they act\n * on.\n */\n fieldName?: string;\n /** How it read before. A node, so a caller can show chips or code rather than a string. */\n before?: React.ReactNode;\n /** How it reads now. Usually omitted: the field itself is showing it. */\n after?: React.ReactNode;\n kind?: ChangeKind;\n /** What made the change. Names the assistant by default. */\n origin?: string;\n /**\n * The field the change is annotating. When given, the tag/label/actions form a header band\n * above it and the before/after line moves below it, so \"Was …\" reads next to the value it\n * describes instead of stacked with the header. Omit it for the standalone card.\n */\n children?: React.ReactNode;\n /**\n * The caller's own controls for this field, in the header band beside accept and revert.\n * A capability's Remove belongs to the field rather than to the review, but while the field\n * is marked the header is the only row its heading has, so without a slot here the button\n * has nowhere to sit that is not on top of something.\n */\n headerActions?: React.ReactNode;\n onApprove: () => void;\n onDeny: () => void;\n /**\n * Fires while the revert control is hovered or focused, and again when it stops being\n * either. A callback rather than internal state because the thing being previewed — the\n * field this change came from — lives elsewhere on the page, outside what `Item` renders;\n * only the caller can swap what that field shows.\n */\n onPreviewRevert?: (previewing: boolean) => void;\n disabled?: boolean;\n className?: string;\n}\n\nconst KIND_WORDS: Record<ChangeKind, string> = {\n changed: 'Changed',\n added: 'Added',\n removed: 'To be removed',\n};\n\nconst GLYPH_STYLE: React.CSSProperties = { fontSize: 11, lineHeight: 1 };\n\n/**\n * What the \"AI\" pill means, for its tooltip. The badge is two letters, which says who wrote\n * the value but not that the reader is expected to do something about it — and the accept and\n * revert controls it refers to are hidden until the row is hovered or focused.\n */\nconst badgeTooltip = (kind: ChangeKind, origin: string): string =>\n kind === 'removed'\n ? `Marked for removal by ${origin}. Accept to remove it, or revert to keep it.`\n : `${KIND_WORDS[kind]} by ${origin}. Accept to keep it, or revert to restore the previous value.`;\n\n// A multi-select with nothing chosen reaches this as `[]`, not `undefined` — that, a blank or\n// whitespace-only string, and an absent value all read as \"nothing was there\" rather than\n// printing nothing (or, worse, the literal word \"undefined\").\nconst isEmptyDisplacedValue = (value: React.ReactNode): boolean => {\n if (value === undefined || value === null) {\n return true;\n }\n if (typeof value === 'string') {\n return value.trim() === '';\n }\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n return false;\n};\n\n/**\n * Says that something on screen was changed by a machine, shows what it displaced, and offers\n * the two ways out.\n *\n * Accept is deliberately the heavier control (filled, dark) against Revert's quiet outline —\n * the design leans toward accepting the assistant's change rather than presenting both as\n * equal options. That is the designer's call to make, not this component's.\n *\n * The actions are always visible. Revealing them on hover was tried and dropped: a change\n * waiting on a decision is the point of the row, and hiding the only two controls that\n * resolve it made them easy to miss — and unreachable on a touch screen, which has no hover\n * to reveal them with.\n */\nconst ChangeReviewItem: React.FC<ChangeReviewItemProps> = ({\n label,\n fieldName,\n before,\n after,\n kind = 'changed',\n origin = 'assistant',\n children,\n onApprove,\n onDeny,\n headerActions,\n onPreviewRevert,\n disabled = false,\n className = '',\n}) => {\n const [isPreviewingRevert, setIsPreviewingRevert] = useState(false);\n const accessibleFieldName = fieldName ?? (typeof label === 'string' ? label : undefined);\n\n // No-ops when `onPreviewRevert` is absent, which also keeps `isPreviewingRevert` from ever\n // flipping true — so the hint below never renders unless a caller asked for the feature.\n const startRevertPreview = () => {\n if (onPreviewRevert === undefined) {\n return;\n }\n setIsPreviewingRevert(true);\n onPreviewRevert(true);\n };\n\n const endRevertPreview = () => {\n if (onPreviewRevert === undefined) {\n return;\n }\n setIsPreviewingRevert(false);\n onPreviewRevert(false);\n };\n\n const badgeAndLabel = (\n <div className=\"flex flex-wrap items-center gap-2\">\n {typeof label === 'string' ? (\n <Typography.Text size=\"small\" fontWeight=\"semi-bold\">\n {label}\n </Typography.Text>\n ) : (\n label\n )}\n <span className=\"sr-only\">{`${KIND_WORDS[kind]} by ${origin}`}</span>\n </div>\n );\n\n /*\n * The mark and the actions, as one tray.\n *\n * One box with the tag fill rather than two boxes meeting: the sparkle keeps that fill and\n * no shape of its own, so it reads as a marker, and the two actions sit inset on the lighter\n * assistant surface. Two violets a step apart separate what this is from what you can do\n * about it, with no border needed.\n *\n * The glyphs are sized in the style rather than by a class: the button centres whatever it\n * is given, and a bare arrow inherits the control's own font size otherwise.\n *\n * Always visible, not revealed on hover: a change waiting on a decision is the point of the\n * row, and hiding the only two controls that resolve it made them easy to miss entirely,\n * and unreachable on a touch screen.\n */\n const tray = (\n <div\n className=\"flex flex-shrink-0 items-center gap-1 rounded-md px-1\"\n style={{ background: 'var(--malachite-tag-assistant-background)', height: 24 }}\n >\n <Tooltip text={badgeTooltip(kind, origin)}>\n <span\n aria-hidden=\"true\"\n className=\"flex flex-shrink-0 items-center justify-center\"\n style={{ color: 'var(--malachite-tag-assistant-foreground)' }}\n >\n <SparkleIcon size={11} />\n </span>\n </Tooltip>\n <Button\n variant=\"destructive\"\n size=\"xsmall\"\n iconOnly\n aria-label={\n accessibleFieldName === undefined\n ? 'Revert change'\n : `Revert ${accessibleFieldName}`\n }\n disabled={disabled}\n onClick={onDeny}\n onMouseEnter={startRevertPreview}\n onMouseLeave={endRevertPreview}\n onFocus={startRevertPreview}\n onBlur={endRevertPreview}\n icon={\n /* Reload rather than a cross: reverting restores the previous value rather\n than dismissing the field. */\n <span aria-hidden=\"true\" style={GLYPH_STYLE}>\n ↺\n </span>\n }\n />\n <Button\n variant=\"success\"\n size=\"xsmall\"\n iconOnly\n aria-label={\n accessibleFieldName === undefined\n ? 'Accept change'\n : `Accept ${accessibleFieldName}`\n }\n disabled={disabled}\n onClick={onApprove}\n icon={\n <span aria-hidden=\"true\" style={GLYPH_STYLE}>\n ✓\n </span>\n }\n />\n </div>\n );\n\n const displaysChange = before !== undefined || after !== undefined;\n\n const beforeAfter = (\n <>\n {displaysChange && (\n <div className=\"flex flex-wrap items-baseline gap-1\">\n <Typography.SecondaryText size=\"small\">\n {/* Struck through, so a glance separates what it was from what it is\n without having to read the labels. */}\n Was {isEmptyDisplacedValue(before) ? <i>empty</i> : <s>{before}</s>}\n {after !== undefined ? ' →' : null}\n </Typography.SecondaryText>\n {after !== undefined && (\n <Typography.Text\n size=\"small\"\n style={{ color: 'var(--malachite-assistant-foreground)' }}\n >\n {after}\n </Typography.Text>\n )}\n </div>\n )}\n {isPreviewingRevert && (\n <Typography.SecondaryText size=\"small\">\n Previewing the revert — release to keep the AI value\n </Typography.SecondaryText>\n )}\n </>\n );\n\n // With a field to wrap, the header (tag/label/actions) and the before/after line split\n // to opposite sides of `children` instead of sitting together above it — see the\n // component doc comment on `children`.\n if (children !== undefined) {\n return (\n <div\n className={`flex flex-col gap-2 rounded-lg p-2 ${className}`}\n style={{ background: 'var(--malachite-assistant-surface-background)' }}\n >\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n {badgeAndLabel}\n <div className=\"flex flex-wrap items-center gap-2\">\n {headerActions}\n {tray}\n </div>\n </div>\n {children}\n <div className=\"flex flex-col gap-1\">{beforeAfter}</div>\n </div>\n );\n }\n\n return (\n <div\n className={`flex items-start gap-2 rounded-lg p-2 ${className}`}\n style={{ background: 'var(--malachite-assistant-surface-background)' }}\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n {badgeAndLabel}\n {beforeAfter}\n </div>\n {headerActions}\n {tray}\n </div>\n );\n};\n\nexport default ChangeReviewItem;\nexport { ChangeReviewItem };\n"],"names":["KIND_WORDS","GLYPH_STYLE","badgeTooltip","kind","origin","isEmptyDisplacedValue","value","ChangeReviewItem","label","fieldName","before","after","children","onApprove","onDeny","headerActions","onPreviewRevert","disabled","className","isPreviewingRevert","setIsPreviewingRevert","useState","accessibleFieldName","startRevertPreview","endRevertPreview","badgeAndLabel","jsxs","jsx","Typography","tray","Tooltip","SparkleIcon","Button","beforeAfter","Fragment"],"mappings":";;;;;;AA6DA,MAAMA,IAAyC;AAAA,EAC3C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AACb,GAEMC,IAAmC,EAAE,UAAU,IAAI,YAAY,EAAA,GAO/DC,IAAe,CAACC,GAAkBC,MACpCD,MAAS,YACH,yBAAyBC,CAAM,iDAC/B,GAAGJ,EAAWG,CAAI,CAAC,OAAOC,CAAM,iEAKpCC,IAAwB,CAACC,MACAA,KAAU,OAC1B,KAEP,OAAOA,KAAU,WACVA,EAAM,WAAW,KAExB,MAAM,QAAQA,CAAK,IACZA,EAAM,WAAW,IAErB,IAgBLC,IAAoD,CAAC;AAAA,EACvD,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAR,IAAO;AAAA,EACP,QAAAC,IAAS;AAAA,EACT,UAAAQ;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAChB,MAAM;AACF,QAAM,CAACC,GAAoBC,CAAqB,IAAIC,EAAS,EAAK,GAC5DC,IAAsBb,MAAc,OAAOD,KAAU,WAAWA,IAAQ,SAIxEe,IAAqB,MAAM;AAC7B,IAAIP,MAAoB,WAGxBI,EAAsB,EAAI,GAC1BJ,EAAgB,EAAI;AAAA,EACxB,GAEMQ,IAAmB,MAAM;AAC3B,IAAIR,MAAoB,WAG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AAA,CACL;AAAA,QAAA,GACJ;AAAA,QACCjB;AAAA,QACD,gBAAAe,EAAC,OAAA,EAAI,WAAU,uBAAuB,UAAAM,EAAA,CAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAM1D,gBAAAP;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,yCAAyCR,CAAS;AAAA,MAC7D,OAAO,EAAE,YAAY,gDAAA;AAAA,MAErB,UAAA;AAAA,QAAA,gBAAAQ,EAAC,OAAA,EAAI,WAAU,sCACV,UAAA;AAAA,UAAAD;AAAA,UACAQ;AAAA,QAAA,GACL;AAAA,QACClB;AAAA,QACAc;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGb;"}
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { jsxs as l, jsx as r, Fragment as
|
|
2
|
-
import { useState as M, useId as v, useMemo as E, memo as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { jsxs as l, jsx as r, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { useState as M, useId as v, useMemo as E, memo as A } from "react";
|
|
3
|
+
import G from "./CopyOverlayButton.js";
|
|
4
|
+
import B from "./CustomIcons/CaretDownIcon.js";
|
|
5
5
|
import c from "./Typography/Text.js";
|
|
6
|
-
import { rowsWrapperStyle as
|
|
7
|
-
import { jsonTokensOf as
|
|
8
|
-
import { FOCUS_RING_INSET as S, FOCUS_RING as
|
|
9
|
-
import { isRenderableNode as
|
|
10
|
-
import { canCopyToClipboard as
|
|
11
|
-
const
|
|
6
|
+
import { rowsWrapperStyle as J } from "./codeBlockStyles.js";
|
|
7
|
+
import { jsonTokensOf as P, JSON_TOKEN_COLORS as U } from "./codePreviewJson.js";
|
|
8
|
+
import { FOCUS_RING_INSET as S, FOCUS_RING as W } from "./focusRing.js";
|
|
9
|
+
import { isRenderableNode as Y } from "./renderableNode.js";
|
|
10
|
+
import { canCopyToClipboard as K } from "./useClipboardCopy.js";
|
|
11
|
+
const I = 5, C = 2e3, V = [], X = 360, q = (e) => e ? 11 : 6, O = "var(--malachite-card-border,rgb(232,232,232))", _ = "var(--malachite-card-subtle-divider,rgb(241,241,241))", Q = (e) => e === "" ? [] : e.replace(/\r?\n$/, "").split(/\r\n|\r|\n/), w = (e, t) => !Number.isNaN(e) && e >= 1 ? Math.floor(e) : t, Z = (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", ee = (e, t, o) => {
|
|
12
12
|
if (e)
|
|
13
13
|
return "Show Less";
|
|
14
14
|
const s = o > 0 ? ` · ${o} flagged` : "";
|
|
15
15
|
return `Show All ${t} Lines${s}`;
|
|
16
|
-
},
|
|
17
|
-
Object.entries(
|
|
18
|
-
),
|
|
19
|
-
return /* @__PURE__ */ r(
|
|
16
|
+
}, re = Object.fromEntries(
|
|
17
|
+
Object.entries(U).map(([e, t]) => [e, { color: t }])
|
|
18
|
+
), ae = A(function({ line: t }) {
|
|
19
|
+
return /* @__PURE__ */ r(H, { children: P(t).map(
|
|
20
20
|
(o, s) => o.kind === "plain" ? o.text : (
|
|
21
21
|
// A token's position is its identity: its text can repeat.
|
|
22
|
-
/* @__PURE__ */ r("span", { "data-token": o.kind, style:
|
|
22
|
+
/* @__PURE__ */ r("span", { "data-token": o.kind, style: re[o.kind], children: o.text }, s)
|
|
23
23
|
)
|
|
24
24
|
) });
|
|
25
|
-
}),
|
|
25
|
+
}), be = ({
|
|
26
26
|
title: e,
|
|
27
27
|
meta: t,
|
|
28
28
|
titleHidden: o = !1,
|
|
29
29
|
code: s,
|
|
30
30
|
language: $,
|
|
31
|
-
previewLines:
|
|
32
|
-
highlightLines: y =
|
|
31
|
+
previewLines: T = I,
|
|
32
|
+
highlightLines: y = V,
|
|
33
33
|
showLineNumbers: i = !0,
|
|
34
|
-
copyable:
|
|
35
|
-
maxRenderedLines:
|
|
36
|
-
className:
|
|
34
|
+
copyable: k = !1,
|
|
35
|
+
maxRenderedLines: R = C,
|
|
36
|
+
className: L = ""
|
|
37
37
|
}) => {
|
|
38
|
-
const [p,
|
|
38
|
+
const [p, z] = M(!1), x = k && K(), m = v(), u = v(), n = E(() => Q(s), [s]), b = E(
|
|
39
39
|
() => new Set(
|
|
40
40
|
y.filter(
|
|
41
41
|
(a) => Number.isInteger(a) && a >= 1 && a <= n.length
|
|
42
42
|
)
|
|
43
43
|
),
|
|
44
44
|
[y, n.length]
|
|
45
|
-
), g =
|
|
45
|
+
), g = w(T, I), N = n.length > g, h = p || !N, f = Math.min(
|
|
46
46
|
h ? n.length : g,
|
|
47
|
-
|
|
48
|
-
),
|
|
47
|
+
w(R, C)
|
|
48
|
+
), D = n.slice(0, f), j = [...b].filter((a) => a > g).length, F = `max(40px, calc(${String(n.length).length}ch + 14px))`;
|
|
49
49
|
return /* @__PURE__ */ l(
|
|
50
50
|
"div",
|
|
51
51
|
{
|
|
52
|
-
className: `overflow-hidden rounded-[var(--malachite-radius-10,10px)] border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] ${
|
|
52
|
+
className: `overflow-hidden rounded-[var(--malachite-radius-10,10px)] border border-solid bg-[var(--malachite-card-background,rgb(255,255,255))] ${L}`,
|
|
53
53
|
style: { borderColor: O },
|
|
54
54
|
children: [
|
|
55
55
|
o ? /* @__PURE__ */ r("span", { id: m, className: "sr-only", children: e }) : /* @__PURE__ */ l(
|
|
56
56
|
"div",
|
|
57
57
|
{
|
|
58
58
|
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]",
|
|
59
|
-
style: { borderColor:
|
|
59
|
+
style: { borderColor: _ },
|
|
60
60
|
children: [
|
|
61
61
|
/* @__PURE__ */ r("span", { id: m, className: "flex min-w-0", children: /* @__PURE__ */ r(c, { size: "xsmall", color: "secondary", fontWeight: "semi-bold", children: e }) }),
|
|
62
|
-
|
|
62
|
+
Y(t) && /* @__PURE__ */ r(
|
|
63
63
|
c,
|
|
64
64
|
{
|
|
65
65
|
size: "xsmall",
|
|
@@ -85,16 +85,16 @@ const C = 5, I = 2e3, X = 360, Y = (e) => e ? 11 : 6, O = "var(--malachite-card-
|
|
|
85
85
|
style: {
|
|
86
86
|
maxHeight: X,
|
|
87
87
|
paddingInlineEnd: x ? 40 : void 0,
|
|
88
|
-
paddingBlock: i ?
|
|
88
|
+
paddingBlock: i ? q(x) : void 0
|
|
89
89
|
},
|
|
90
|
-
children: /* @__PURE__ */ l("span", { className: "block", style:
|
|
91
|
-
|
|
90
|
+
children: /* @__PURE__ */ l("span", { className: "block", style: J(!1), children: [
|
|
91
|
+
D.map((a, d) => (
|
|
92
92
|
// A line's position is its identity: its text can repeat.
|
|
93
93
|
/* @__PURE__ */ l(
|
|
94
94
|
"span",
|
|
95
95
|
{
|
|
96
96
|
"data-flagged": b.has(d + 1) || void 0,
|
|
97
|
-
className:
|
|
97
|
+
className: Z(b.has(d + 1)),
|
|
98
98
|
children: [
|
|
99
99
|
i && /* @__PURE__ */ r(
|
|
100
100
|
"span",
|
|
@@ -111,7 +111,7 @@ const C = 5, I = 2e3, X = 360, Y = (e) => e ? 11 : 6, O = "var(--malachite-card-
|
|
|
111
111
|
className: `min-w-0 whitespace-pre ${i ? "" : "px-[11px]"}`,
|
|
112
112
|
children: [
|
|
113
113
|
b.has(d + 1) && /* @__PURE__ */ r("span", { className: "sr-only select-none", children: "Flagged: " }),
|
|
114
|
-
a ? $ === "json" ? /* @__PURE__ */ r(
|
|
114
|
+
a ? $ === "json" ? /* @__PURE__ */ r(ae, { line: a }) : a : " "
|
|
115
115
|
]
|
|
116
116
|
}
|
|
117
117
|
)
|
|
@@ -125,12 +125,12 @@ const C = 5, I = 2e3, X = 360, Y = (e) => e ? 11 : 6, O = "var(--malachite-card-
|
|
|
125
125
|
}
|
|
126
126
|
),
|
|
127
127
|
x && /* @__PURE__ */ r(
|
|
128
|
-
|
|
128
|
+
G,
|
|
129
129
|
{
|
|
130
130
|
text: s,
|
|
131
131
|
"aria-label": `Copy ${e}`,
|
|
132
132
|
iconSize: 12,
|
|
133
|
-
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))] ${
|
|
133
|
+
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}`,
|
|
134
134
|
style: { borderColor: O }
|
|
135
135
|
}
|
|
136
136
|
)
|
|
@@ -143,13 +143,13 @@ const C = 5, I = 2e3, X = 360, Y = (e) => e ? 11 : 6, O = "var(--malachite-card-
|
|
|
143
143
|
"aria-expanded": p,
|
|
144
144
|
"aria-controls": u,
|
|
145
145
|
"aria-describedby": m,
|
|
146
|
-
onClick: () =>
|
|
146
|
+
onClick: () => z((a) => !a),
|
|
147
147
|
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))] ${S}`,
|
|
148
|
-
style: { borderColor:
|
|
148
|
+
style: { borderColor: _ },
|
|
149
149
|
children: [
|
|
150
|
-
/* @__PURE__ */ r(c, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", children:
|
|
150
|
+
/* @__PURE__ */ r(c, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", children: ee(p, n.length, j) }),
|
|
151
151
|
/* @__PURE__ */ r("span", { "aria-hidden": "true", className: "flex", children: /* @__PURE__ */ r(
|
|
152
|
-
|
|
152
|
+
B,
|
|
153
153
|
{
|
|
154
154
|
size: 12,
|
|
155
155
|
className: "transition-transform",
|
|
@@ -164,7 +164,7 @@ const C = 5, I = 2e3, X = 360, Y = (e) => e ? 11 : 6, O = "var(--malachite-card-
|
|
|
164
164
|
);
|
|
165
165
|
};
|
|
166
166
|
export {
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
be as CodePreview,
|
|
168
|
+
be as default
|
|
169
169
|
};
|
|
170
170
|
//# sourceMappingURL=CodePreview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodePreview.js","sources":["../../src/components/CodePreview.tsx"],"sourcesContent":["import type React from 'react';\nimport { memo, useId, useMemo, useState } from 'react';\nimport CopyOverlayButton from './CopyOverlayButton';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport Text from './Typography/Text';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { JSON_TOKEN_COLORS, jsonTokensOf } from './codePreviewJson';\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 /** `json` colours keys, strings, numbers and literals line by line. Plain text by default. */\n language?: 'json';\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\nconst JSON_TOKEN_STYLES = Object.fromEntries(\n Object.entries(JSON_TOKEN_COLORS).map(([kind, color]) => [kind, { color }]),\n) as Record<keyof typeof JSON_TOKEN_COLORS, React.CSSProperties>;\n\nconst JsonLine = memo(function JsonLine({ line }: { line: string }) {\n return (\n <>\n {jsonTokensOf(line).map((token, index) =>\n token.kind === 'plain' ? (\n token.text\n ) : (\n // A token's position is its identity: its text can repeat.\n <span key={index} data-token={token.kind} style={JSON_TOKEN_STYLES[token.kind]}>\n {token.text}\n </span>\n ),\n )}\n </>\n );\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 language,\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 language === 'json' ? (\n <JsonLine line={line} />\n ) : (\n line\n )\n ) : (\n ' '\n )}\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","JSON_TOKEN_STYLES","JSON_TOKEN_COLORS","kind","color","JsonLine","memo","line","jsx","Fragment","jsonTokensOf","token","index","CodePreview","title","meta","titleHidden","language","previewLines","highlightLines","showLineNumbers","copyable","maxRenderedLines","className","setExpanded","useState","canCopyToClipboard","titleId","useId","bodyId","lines","useMemo","limit","foldable","open","rendered","shown","gutter","jsxs","Text","isRenderableNode","FOCUS_RING_INSET","rowsWrapperStyle","CopyOverlayButton","FOCUS_RING","isOpen","CaretDownIcon"],"mappings":";;;;;;;;;;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ACA,CAAM;AAAA,YAC9C,WAAW,4NAA4NJ,CAAgB;AAAA,YACvP,OAAO,EAAE,aAAarD,EAAA;AAAA,YAEtB,UAAA;AAAA,cAAA,gBAAAoB,EAAC+B,GAAA,EAAK,MAAK,UAAS,YAAW,aAAY,OAAM,WAC5C,UAAA3C,EAAYC,GAAUiC,EAAM,QAAQ/B,CAAW,GACpD;AAAA,cACA,gBAAAS,EAAC,QAAA,EAAK,eAAY,QAAO,WAAU,QAC/B,UAAA,gBAAAA;AAAA,gBAACsC;AAAA,gBAAA;AAAA,kBACG,MAAM;AAAA,kBACN,WAAU;AAAA,kBACV,OAAO,EAAE,WAAWjD,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 { memo, useId, useMemo, useState } from 'react';\nimport CopyOverlayButton from './CopyOverlayButton';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport Text from './Typography/Text';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { JSON_TOKEN_COLORS, jsonTokensOf } from './codePreviewJson';\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 /** `json` colours keys, strings, numbers and literals line by line. Plain text by default. */\n language?: 'json';\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;\nconst EMPTY_HIGHLIGHT_LINES: readonly number[] = [];\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\nconst JSON_TOKEN_STYLES = Object.fromEntries(\n Object.entries(JSON_TOKEN_COLORS).map(([kind, color]) => [kind, { color }]),\n) as Record<keyof typeof JSON_TOKEN_COLORS, React.CSSProperties>;\n\nconst JsonLine = memo(function JsonLine({ line }: { line: string }) {\n return (\n <>\n {jsonTokensOf(line).map((token, index) =>\n token.kind === 'plain' ? (\n token.text\n ) : (\n // A token's position is its identity: its text can repeat.\n <span key={index} data-token={token.kind} style={JSON_TOKEN_STYLES[token.kind]}>\n {token.text}\n </span>\n ),\n )}\n </>\n );\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 language,\n previewLines = DEFAULT_PREVIEW_LINES,\n highlightLines = EMPTY_HIGHLIGHT_LINES,\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 language === 'json' ? (\n <JsonLine line={line} />\n ) : (\n line\n )\n ) : (\n ' '\n )}\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","EMPTY_HIGHLIGHT_LINES","MAX_BODY_HEIGHT","numberedRowsPadding","showsCopy","BORDER","DIVIDER","linesOf","code","countOf","value","fallback","lineClasses","flagged","toggleLabel","expanded","total","hiddenFlags","flags","JSON_TOKEN_STYLES","JSON_TOKEN_COLORS","kind","color","JsonLine","memo","line","jsx","Fragment","jsonTokensOf","token","index","CodePreview","title","meta","titleHidden","language","previewLines","highlightLines","showLineNumbers","copyable","maxRenderedLines","className","setExpanded","useState","canCopyToClipboard","titleId","useId","bodyId","lines","useMemo","limit","foldable","open","rendered","shown","gutter","jsxs","Text","isRenderableNode","FOCUS_RING_INSET","rowsWrapperStyle","CopyOverlayButton","FOCUS_RING","isOpen","CaretDownIcon"],"mappings":";;;;;;;;;;AAkCA,MAAMA,IAAwB,GACxBC,IAA6B,KAC7BC,IAA2C,CAAA,GAG3CC,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,KAAc,CAACC,GAAmBC,GAAeC,MAAgC;AACnF,MAAIF;AACA,WAAO;AAEX,QAAMG,IAAQD,IAAc,IAAI,MAAMA,CAAW,aAAa;AAC9D,SAAO,YAAYD,CAAK,SAASE,CAAK;AAC1C,GAEMC,KAAoB,OAAO;AAAA,EAC7B,OAAO,QAAQC,CAAiB,EAAE,IAAI,CAAC,CAACC,GAAMC,CAAK,MAAM,CAACD,GAAM,EAAE,OAAAC,EAAA,CAAO,CAAC;AAC9E,GAEMC,KAAWC,EAAK,SAAkB,EAAE,MAAAC,KAA0B;AAChE,SACI,gBAAAC,EAAAC,GAAA,EACK,UAAAC,EAAaH,CAAI,EAAE;AAAA,IAAI,CAACI,GAAOC,MAC5BD,EAAM,SAAS,UACXA,EAAM;AAAA;AAAA,MAGN,gBAAAH,E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