@stackone/malachite 2.107.0 → 2.108.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/dist/ShadowRootWrapper.js +43 -36
- package/dist/ShadowRootWrapper.js.map +1 -1
- package/dist/components/CodeBlock.js +2 -2
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CommandPalette.js +64 -62
- package/dist/components/CommandPalette.js.map +1 -1
- package/dist/components/MalachiteContext.js +11 -9
- package/dist/components/MalachiteContext.js.map +1 -1
- package/dist/components/Surface.js +2 -2
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/Toolbar.js +2 -2
- package/dist/components/Toolbar.js.map +1 -1
- package/dist/components/Tooltip.js +130 -129
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Typography/Text.js +21 -19
- package/dist/components/Typography/Text.js.map +1 -1
- package/dist/fontInjection.js +21 -0
- package/dist/fontInjection.js.map +1 -0
- package/dist/geist-font.js +10 -16
- package/dist/geist-font.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/inter-font.js +21 -27
- package/dist/inter-font.js.map +1 -1
- package/dist/stack-sans-font.js +5 -11
- package/dist/stack-sans-font.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,58 +1,65 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as w, useCallback as F, useState as R, useEffect as u } from "react";
|
|
3
|
+
import { createPortal as I } from "react-dom";
|
|
4
4
|
import { ensureDroppedFocusTracking as S } from "./components/droppedFocus.js";
|
|
5
|
-
import {
|
|
6
|
-
import { ensureInterFontFace as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { useFontInjection as g, FontInjectionProvider as j } from "./fontInjection.js";
|
|
6
|
+
import { ensureInterFontFace as v } from "./inter-font.js";
|
|
7
|
+
import { adoptTailwindSheet as y } from "./tailwindSheet.js";
|
|
8
|
+
import { ensureThemeInitialized as T, applyThemeVars as k, registerShadowRoot as b, unregisterShadowRoot as E } from "./theme.js";
|
|
9
|
+
const A = ({
|
|
10
|
+
children: l,
|
|
11
|
+
theme: n,
|
|
12
|
+
hostStyle: a,
|
|
13
|
+
hostProps: c,
|
|
14
|
+
hostRef: i,
|
|
15
|
+
fillHeight: f = !1,
|
|
16
|
+
injectFonts: h
|
|
17
|
+
}) => {
|
|
18
|
+
const p = g(), s = h ?? p, t = w(null), d = F(
|
|
19
|
+
(r) => {
|
|
20
|
+
t.current = r, i && (i.current = r);
|
|
14
21
|
},
|
|
15
|
-
[
|
|
16
|
-
), [
|
|
17
|
-
return
|
|
18
|
-
if (t.current && !
|
|
19
|
-
const
|
|
20
|
-
|
|
22
|
+
[i]
|
|
23
|
+
), [o, m] = R(null);
|
|
24
|
+
return u(() => {
|
|
25
|
+
if (t.current && !o) {
|
|
26
|
+
const r = t.current.shadowRoot ?? t.current.attachShadow({ mode: "open" });
|
|
27
|
+
y(r), m(r);
|
|
21
28
|
}
|
|
22
|
-
}, [
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
|
|
29
|
+
}, [o]), u(() => {
|
|
30
|
+
if (o) {
|
|
31
|
+
if (T(), S(), s && v(), n) {
|
|
32
|
+
k(o, n);
|
|
26
33
|
return;
|
|
27
34
|
}
|
|
28
|
-
return
|
|
35
|
+
return b(o), () => {
|
|
29
36
|
try {
|
|
30
|
-
E(
|
|
31
|
-
} catch (
|
|
32
|
-
console.warn("Error during shadow root cleanup:",
|
|
37
|
+
E(o);
|
|
38
|
+
} catch (r) {
|
|
39
|
+
console.warn("Error during shadow root cleanup:", r);
|
|
33
40
|
}
|
|
34
41
|
};
|
|
35
42
|
}
|
|
36
|
-
}, [
|
|
43
|
+
}, [o, n, s]), o === null ? /* @__PURE__ */ e(
|
|
37
44
|
"div",
|
|
38
45
|
{
|
|
39
|
-
...
|
|
40
|
-
ref:
|
|
46
|
+
...c,
|
|
47
|
+
ref: d,
|
|
41
48
|
"data-testid": "shadow-root-wrapper",
|
|
42
|
-
style:
|
|
49
|
+
style: a
|
|
43
50
|
}
|
|
44
|
-
) : /* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */
|
|
51
|
+
) : /* @__PURE__ */ e("div", { ...c, ref: d, style: a, children: o && I(
|
|
52
|
+
/* @__PURE__ */ e(j, { enabled: s, children: /* @__PURE__ */ e(
|
|
46
53
|
"div",
|
|
47
54
|
{
|
|
48
55
|
style: f ? { isolation: "isolate", height: "100%" } : { isolation: "isolate" },
|
|
49
|
-
children:
|
|
56
|
+
children: l
|
|
50
57
|
}
|
|
51
|
-
),
|
|
52
|
-
|
|
58
|
+
) }),
|
|
59
|
+
o
|
|
53
60
|
) });
|
|
54
61
|
};
|
|
55
62
|
export {
|
|
56
|
-
|
|
63
|
+
A as ShadowRootWrapper
|
|
57
64
|
};
|
|
58
65
|
//# sourceMappingURL=ShadowRootWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureDroppedFocusTracking } from './components/droppedFocus';\nimport {
|
|
1
|
+
{"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureDroppedFocusTracking } from './components/droppedFocus';\nimport { FontInjectionProvider, useFontInjection } from './fontInjection';\nimport { ensureInterFontFace } from './inter-font';\nimport { adoptTailwindSheet } from './tailwindSheet';\nimport {\n type ThemeMode,\n applyThemeVars,\n ensureThemeInitialized,\n registerShadowRoot,\n unregisterShadowRoot,\n} from './theme';\n\nexport const ShadowRootWrapper: React.FC<{\n children: React.ReactNode;\n theme?: ThemeMode;\n hostStyle?: React.CSSProperties;\n /** Identity for the shadow host, so host CSS matching unclassed `body` children cannot\n * blanket-hide a portaled one. Narrow on purpose: a wider type would let a caller\n * clobber `style`, `ref` or `data-testid` through the spread below. */\n hostProps?: { className?: string } & Record<`data-${string}`, string>;\n /** Reads back the shadow host, which a caller needs to promote it into the top layer. */\n hostRef?: { current: HTMLDivElement | null };\n /** Stretches the portal's inner wrapper div (inside the shadow root) to 100% height, to\n * match a `hostStyle` height a caller supplies on the host itself — without this, a tall\n * host div still collapses to content height one level in, because this wrapper div has\n * no height of its own. Off by default: sizing it for every consumer would change layout\n * for callers that rely on it hugging its content. */\n fillHeight?: boolean;\n /** Set `false` to skip Malachite's font injection (Inter, and Geist / Stack Sans for the\n * components that use them), for a consumer that loads the fonts itself. Inherited from an\n * enclosing wrapper when omitted, otherwise on. */\n injectFonts?: boolean;\n}> = ({\n children,\n theme,\n hostStyle,\n hostProps,\n hostRef: externalHostRef,\n fillHeight = false,\n injectFonts,\n}) => {\n const inheritedInjectFonts = useFontInjection();\n const shouldInjectFonts = injectFonts ?? inheritedInjectFonts;\n const hostRef = useRef<HTMLDivElement | null>(null);\n const takeHost = useCallback(\n (node: HTMLDivElement | null) => {\n hostRef.current = node;\n if (externalHostRef) {\n externalHostRef.current = node;\n }\n },\n [externalHostRef],\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (hostRef.current && !shadowRoot) {\n const shadow =\n hostRef.current.shadowRoot ?? hostRef.current.attachShadow({ mode: 'open' });\n // Adopt the stylesheet before setShadowRoot triggers the render that\n // portals children in: adopting in a later effect leaves a window where\n // the browser can paint the children unstyled (e.g. hover-hidden\n // controls flash fully visible on page load until `opacity: 0` lands).\n adoptTailwindSheet(shadow);\n setShadowRoot(shadow);\n }\n }, [shadowRoot]);\n\n useEffect(() => {\n if (!shadowRoot) {\n return;\n }\n // Both of these belong to the document, not the shadow root: @font-face does not\n // load fonts from inside a shadow root, and the theme's custom properties are set on\n // documentElement so light-DOM content and portals resolve them too.\n ensureThemeInitialized();\n ensureDroppedFocusTracking();\n if (shouldInjectFonts) {\n ensureInterFontFace();\n }\n if (theme) {\n applyThemeVars(shadowRoot, theme);\n return;\n }\n registerShadowRoot(shadowRoot);\n return () => {\n try {\n unregisterShadowRoot(shadowRoot);\n } catch (error) {\n // Silently handle cleanup errors during hot reloading\n console.warn('Error during shadow root cleanup:', error);\n }\n };\n }, [shadowRoot, theme, shouldInjectFonts]);\n\n if (shadowRoot === null) {\n // Initial render, attach shadow root first\n return (\n <div\n {...hostProps}\n ref={takeHost}\n data-testid=\"shadow-root-wrapper\"\n style={hostStyle}\n />\n );\n }\n\n // Container div inside the shadow root keeps React context working across the portal.\n return (\n <div {...hostProps} ref={takeHost} style={hostStyle}>\n {shadowRoot &&\n createPortal(\n <FontInjectionProvider enabled={shouldInjectFonts}>\n <div\n style={\n fillHeight\n ? { isolation: 'isolate', height: '100%' }\n : { isolation: 'isolate' }\n }\n >\n {children}\n </div>\n </FontInjectionProvider>,\n shadowRoot,\n )}\n </div>\n );\n};\n"],"names":["ShadowRootWrapper","children","theme","hostStyle","hostProps","externalHostRef","fillHeight","injectFonts","inheritedInjectFonts","useFontInjection","shouldInjectFonts","hostRef","useRef","takeHost","useCallback","node","shadowRoot","setShadowRoot","useState","useEffect","shadow","adoptTailwindSheet","ensureThemeInitialized","ensureDroppedFocusTracking","ensureInterFontFace","applyThemeVars","registerShadowRoot","unregisterShadowRoot","error","jsx","createPortal","FontInjectionProvider"],"mappings":";;;;;;;;AAcO,MAAMA,IAoBR,CAAC;AAAA,EACF,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAASC;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,aAAAC;AACJ,MAAM;AACF,QAAMC,IAAuBC,EAAA,GACvBC,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,IAChC,EAAE,WAAW,UAAA;AAAA,QAGtB,UAAAL;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,IACAe;AAAA,EAAA,GAEZ;AAER;"}
|
|
@@ -30,7 +30,7 @@ const $ = (e, o) => (t, { type: c }) => c === "value" ? /* @__PURE__ */ r("span"
|
|
|
30
30
|
);
|
|
31
31
|
}, re = (e) => (
|
|
32
32
|
// This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.
|
|
33
|
-
(o, { value: t, keyName: c }) => Reflect.get(o, "data-expanded") && I(e, t, c === void 0 ? [] : [c]) ? (
|
|
33
|
+
((o, { value: t, keyName: c }) => Reflect.get(o, "data-expanded") && I(e, t, c === void 0 ? [] : [c]) ? (
|
|
34
34
|
// Its toggle already names the size, so this would say it twice.
|
|
35
35
|
/* @__PURE__ */ r(
|
|
36
36
|
"span",
|
|
@@ -40,7 +40,7 @@ const $ = (e, o) => (t, { type: c }) => c === "value" ? /* @__PURE__ */ r("span"
|
|
|
40
40
|
children: `… ${E(t)}`
|
|
41
41
|
}
|
|
42
42
|
)
|
|
43
|
-
) : null
|
|
43
|
+
) : null)
|
|
44
44
|
), T = A.lazy(() => import("./CodeBlockHighlighter.js")), te = {
|
|
45
45
|
added: "var(--malachite-codeblock-diff-added-background)",
|
|
46
46
|
removed: "var(--malachite-codeblock-diff-removed-background)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import JsonView from '@uiw/react-json-view';\nimport React from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport { type DiffDisplayRow, type DiffRowType, diffHunks } from './codeBlockDiff';\nimport { CodeLine, type CodeLineDecoration } from './codeBlockLine';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { useClipboardCopy } from './useClipboardCopy';\n\n/**\n * The value side of a JSON literal that has no value of its own to print, in its type's\n * colour. These read as keywords, as `true` and `false` do: the comment grey is under AA\n * contrast on the light background.\n */\nconst renderLiteral =\n (text: string, type: 'null' | 'undefined' | 'nan') =>\n (props: React.HTMLAttributes<HTMLSpanElement>, { type: part }: { type: 'type' | 'value' }) =>\n part === 'value' ? (\n <span {...props} style={{ ...props.style, color: `var(--w-rjv-type-${type}-color)` }}>\n {text}\n </span>\n ) : null;\n\n/** A json node's own entries, as the library counts them to draw it. */\nconst entryCount = (value: unknown): number =>\n value !== null && typeof value === 'object' ? Object.keys(value).length : 0;\n\n/** A nested node over the limit: the only kind the limit folds, toggles and sizes. */\nconst isOverLimit = (limit: number, value: unknown, keys: readonly (number | string)[]): boolean =>\n keys.length > 0 && entryCount(value) > limit;\n\nconst sizeOf = (value: unknown): string => {\n const count = entryCount(value);\n return `${count} ${count === 1 ? 'item' : 'items'}`;\n};\n\n/** Where a node sits, so two toggles for nodes sharing a key read apart: `users.0.roles`. */\nconst pathOf = (keys: readonly (number | string)[]): string =>\n keys.map((key) => String(key) || '\"\"').join('.');\n\n// The library's flag is the inverse of its name: returning true starts the node collapsed.\nconst collapseNodesLargerThan =\n (limit: number) =>\n (\n isCollapsed: boolean,\n { value, keys }: { value?: unknown; keys: (number | string)[] },\n ): boolean =>\n isCollapsed || isOverLimit(limit, value, keys);\n\n// The row around the arrow owns the click and the arrow's rotation is its only state, so this\n// button is a keyboard toggle that reads `aria-expanded` from it.\nconst toggleArrowOver =\n (limit: number) =>\n (\n props: { className?: string; style?: React.CSSProperties; children?: React.ReactNode },\n { value, keys }: { value?: unknown; keys?: (number | string)[] },\n ) => {\n if (!isOverLimit(limit, value, keys ?? [])) {\n return null;\n }\n const collapsed = String(props.style?.transform ?? '').includes('-90');\n return (\n <button\n type=\"button\"\n aria-expanded={!collapsed}\n aria-label={`${pathOf(keys ?? [])}, ${sizeOf(value)}`}\n className={`${props.className ?? ''} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${FOCUS_RING}`}\n style={props.style}\n >\n {props.children}\n </button>\n );\n };\n\nconst foldedSizeOver =\n (limit: number) =>\n // This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.\n (props: object, { value, keyName }: { value?: unknown; keyName?: string | number }) =>\n Reflect.get(props, 'data-expanded') &&\n isOverLimit(limit, value, keyName === undefined ? [] : [keyName]) ? (\n // Its toggle already names the size, so this would say it twice.\n <span\n aria-hidden=\"true\"\n className={`${Reflect.get(props, 'className') ?? ''} mx-[4px] cursor-pointer select-none text-[var(--malachite-codeblock-foreground)]`}\n >\n {`\\u2026 ${sizeOf(value)}`}\n </span>\n ) : null;\n\nconst CodeBlockHighlighter = React.lazy(() => import('./CodeBlockHighlighter'));\n\nexport interface CodeBlockProps {\n /** The code content to display */\n code?: string;\n /** JSON object to display as formatted JSON */\n json?: object;\n /** Show line numbers */\n showLineNumbers?: boolean;\n /** Custom class name */\n className?: string;\n /** Custom styles */\n style?: React.CSSProperties;\n /** Height of the code block */\n height?: string | number;\n /** Enable copy functionality */\n enableCopy?: boolean;\n /** Wrap long lines instead of scrolling horizontally */\n wrapLines?: boolean;\n /**\n * Highlight the code with this language's grammar. `cedar` is a grammar this library\n * ships itself (`prismCedar.ts`), since Prism and refractor carry none; widen the union\n * as further grammars are registered in CodeBlockHighlighter.\n */\n language?: 'yaml' | 'cedar';\n /** How much of a `json` tree starts collapsed: `true` all of it, a number below that depth. */\n collapsed?: boolean | number;\n /**\n * Starts any nested node with more entries than this collapsed, at any depth, behind a keyboard\n * toggle naming its path and size; nodes within the limit keep the library's arrow. 0 or more.\n */\n collapseLargerThan?: number;\n /**\n * Renders the change between two texts rather than one text, and takes precedence over\n * `code` and `json`. Only the changed lines are shown, with `context` unchanged ones either\n * side, so a small edit to a long document reads as a few hunks instead of the whole thing.\n */\n diff?: {\n before: string;\n after: string;\n /** Unchanged lines kept either side of each change. Three by convention. */\n context?: number;\n /**\n * Swaps the `+`/`-` gutter and tinted rows for the palette a mock specified for\n * AI-authored changes: star, minus-sign and middle-dot markers, and a struck-through\n * removal. Omit to keep the neutral markers; there is no default consumer for the\n * assistant look yet.\n */\n origin?: 'assistant';\n };\n /** Names the scrollable region. Defaults to \"Code\". */\n 'aria-label'?: string;\n /** Names the scrollable region by a visible label instead of `aria-label`. */\n 'aria-labelledby'?: string;\n}\n\nconst DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-added-background)',\n removed: 'var(--malachite-codeblock-diff-removed-background)',\n context: undefined,\n};\n\nconst DIFF_MARKERS: Record<DiffRowType, string | undefined> = {\n added: '+',\n removed: '-',\n context: undefined,\n};\n\n// The assistant palette also marks context rows, which the neutral one leaves bare.\nconst ASSISTANT_DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-assistant-background)',\n removed: 'var(--malachite-codeblock-diff-assistant-removed-background)',\n context: undefined,\n};\n\nconst ASSISTANT_DIFF_MARKERS: Record<DiffRowType, string> = {\n added: '\\u2726',\n // U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.\n removed: '\\u2212',\n context: '\\u00b7',\n};\n\nconst ASSISTANT_DIFF_MARKER_COLORS: Record<DiffRowType, string> = {\n added: 'var(--malachite-codeblock-diff-assistant-foreground)',\n removed: 'var(--malachite-codeblock-diff-removed-foreground)',\n context: 'var(--malachite-codeblock-diff-context-foreground)',\n};\n\nconst unchangedRun = (count: number): string =>\n `\\u22ef ${count} unchanged ${count === 1 ? 'line' : 'lines'}`;\n\nconst diffDecoration = (\n row: DiffDisplayRow,\n showLineNumbers: boolean,\n origin?: 'assistant',\n): CodeLineDecoration => {\n const assistant = origin === 'assistant';\n\n return {\n background: assistant ? ASSISTANT_DIFF_BACKGROUNDS[row.type] : DIFF_BACKGROUNDS[row.type],\n marker: assistant ? ASSISTANT_DIFF_MARKERS[row.type] : DIFF_MARKERS[row.type],\n markerColor: assistant ? ASSISTANT_DIFF_MARKER_COLORS[row.type] : undefined,\n // Reserved on unchanged rows too, so the code column does not step in and out.\n reserveMarker: true,\n // Context rows read as de-emphasised, not just unmarked, in the assistant palette.\n textColor:\n assistant && row.type === 'context'\n ? 'var(--malachite-codeblock-diff-context-text)'\n : undefined,\n strikethrough: assistant && row.type === 'removed',\n separatorAbove: row.skippedAbove === undefined ? undefined : unchangedRun(row.skippedAbove),\n // A removed line has no number in the after-text, so it keeps the one it had before.\n lineNumber: showLineNumbers ? (row.afterNumber ?? row.beforeNumber) : undefined,\n };\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n code,\n json,\n showLineNumbers = true,\n className = '',\n style = {},\n height,\n enableCopy = true,\n wrapLines = false,\n language,\n collapsed = false,\n collapseLargerThan,\n diff,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const limit =\n collapseLargerThan !== undefined &&\n Number.isInteger(collapseLargerThan) &&\n collapseLargerThan >= 0\n ? collapseLargerThan\n : undefined;\n if (collapseLargerThan !== undefined && limit === undefined) {\n devWarning(\n `CodeBlock.collapseLargerThan:${collapseLargerThan}`,\n `CodeBlock's collapseLargerThan takes a whole count of 0 or more; ${collapseLargerThan} is ignored.`,\n );\n }\n const diffRows = diff ? diffHunks(diff.before, diff.after, diff.context) : null;\n const diffText = diffRows?.map((row) => row.text).join('\\n') ?? '';\n\n /**\n * What the button puts on the clipboard, in the same form the block is showing. A JSON\n * block is pretty-printed rather than handed over minified: the reader is copying what\n * they can see. `undefined` means there is nothing to copy and no button to offer.\n */\n const copyText = (): string | undefined => {\n if (diffRows) {\n return diffText;\n }\n\n // An empty block has nothing to copy, so it offers no button — `!== undefined` would\n // hand back the empty string and put a dead control on it.\n if (code) {\n return code;\n }\n\n if (json !== undefined) {\n try {\n return JSON.stringify(json, null, 2);\n } catch {\n // A cycle or a BigInt: no honest text to copy, so offer no button.\n return undefined;\n }\n }\n\n return undefined;\n };\n\n const textToCopy = copyText();\n\n const { outcome: copyOutcome, copy } = useClipboardCopy(textToCopy);\n const copied = copyOutcome === 'copied';\n\n const handleCopy = () => {\n if (textToCopy !== undefined) {\n void copy(textToCopy);\n }\n };\n\n // Declared once and rendered by both the JSON branch and the code branch below, so the\n // two tabs of one document do not disagree about whether it can be copied.\n const copyButton = enableCopy && textToCopy !== undefined && (\n <>\n <button\n type=\"button\"\n aria-label=\"Copy\"\n onClick={handleCopy}\n className={`absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${FOCUS_RING}`}\n style={{ color: 'var(--malachite-codeblock-line-number)' }}\n >\n {copied ? <CheckmarkIcon size={14} /> : <CopyIcon size={14} />}\n </button>\n {/* Not role=\"status\": one per block would collide with a page's own status queries. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? 'Copied to clipboard' : ''}\n </span>\n </>\n );\n\n // Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.\n const viewportProps = {\n role: 'region',\n 'aria-label': ariaLabelledBy ? ariaLabel : (ariaLabel ?? 'Code'),\n 'aria-labelledby': ariaLabelledBy,\n tabIndex: 0,\n className: `box-border h-full overflow-auto ${FOCUS_RING_INSET}`,\n } satisfies React.HTMLAttributes<HTMLElement>;\n\n // If JSON is provided, use JsonView component\n if (json && !diffRows) {\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {/* The frame clips at `height`; this scrolls inside it, so the copy button stays put. */}\n <div {...viewportProps}>\n <JsonView\n value={json}\n style={\n {\n backgroundColor: 'var(--malachite-codeblock-background)',\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n padding: '16px',\n lineHeight: '1.5',\n textAlign: 'left',\n '--w-rjv-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-key-string': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-background-color': 'var(--malachite-codeblock-background)',\n '--w-rjv-line-color': 'var(--malachite-codeblock-border)',\n '--w-rjv-arrow-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-edit-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-info-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-update-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-copied-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-copied-success-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-curlybraces-color':\n 'var(--malachite-codeblock-foreground)',\n '--w-rjv-colon-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-brackets-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-quotes-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-quotes-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-int-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-float-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-bigint-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-boolean-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-date-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-url-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-null-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-nan-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-undefined-color':\n 'var(--malachite-codeblock-keyword)',\n } as React.CSSProperties\n }\n displayDataTypes={false}\n enableClipboard={enableCopy}\n collapsed={collapsed}\n shouldExpandNodeInitially={\n limit === undefined ? undefined : collapseNodesLargerThan(limit)\n }\n displayObjectSize={false}\n >\n {/* The library draws these three only as their type label, which\n `displayDataTypes` turns off, so without a value of their own a\n `null` reads as a key with nothing after it. */}\n <JsonView.Null render={renderLiteral('null', 'null')} />\n <JsonView.Undefined render={renderLiteral('undefined', 'undefined')} />\n <JsonView.Nan render={renderLiteral('NaN', 'nan')} />\n {/* Mounted either way: the library keeps a slot's last render, so it is\n switched off by passing none rather than by unmounting. */}\n <JsonView.Arrow\n render={limit === undefined ? undefined : toggleArrowOver(limit)}\n />\n <JsonView.Ellipsis\n render={limit === undefined ? undefined : foldedSizeOver(limit)}\n />\n </JsonView>\n </div>\n </div>\n );\n }\n\n // Reserve clearance so a wide first line never sits under the floating copy button.\n const copyClearance = enableCopy && (!!code || !!diffRows);\n\n const renderPlainLines = (\n text: string,\n decorate?: (index: number) => CodeLineDecoration | undefined,\n ) => {\n const lines = text.split('\\n');\n\n return (\n <div\n {...viewportProps}\n className={`${viewportProps.className} p-4 text-left`}\n style={{ paddingRight: copyClearance ? 44 : undefined }}\n >\n <div style={rowsWrapperStyle(wrapLines)}>\n {lines.map((line, index) => {\n const decoration = decorate?.(index);\n\n return (\n <CodeLine\n key={index}\n line={line}\n lineNumber={\n decoration?.lineNumber ??\n (showLineNumbers ? index + 1 : undefined)\n }\n wrap={wrapLines}\n decoration={decoration}\n >\n {line}\n </CodeLine>\n );\n })}\n </div>\n </div>\n );\n };\n\n const renderPlainCode = () => (code ? renderPlainLines(code) : null);\n\n const renderDiff = (rows: DiffDisplayRow[]) => {\n if (rows.length === 0) {\n return (\n <div\n className=\"p-4 text-left\"\n style={{ color: 'var(--malachite-codeblock-comment)' }}\n >\n No changes\n </div>\n );\n }\n\n const decorate = (index: number) => {\n const row = rows[index];\n\n return row ? diffDecoration(row, showLineNumbers, diff?.origin) : undefined;\n };\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainLines(diffText, decorate)}>\n {/*\n * The whole merged text goes to the highlighter in one piece, so a hunk\n * is tokenised in the company of its neighbours rather than on its own.\n * Prism still cannot see the lines the hunks left out, so a construct\n * spanning an omitted run can highlight oddly — the reason `context`\n * defaults to a few lines rather than none.\n */}\n <CodeBlockHighlighter\n code={diffText}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n decorate={decorate}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainLines(diffText, decorate);\n };\n\n // For code strings, create a simple syntax-highlighted view\n const renderCodeContent = () => {\n if (!code) {\n return null;\n }\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainCode()}>\n <CodeBlockHighlighter\n code={code}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainCode();\n };\n\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {diffRows ? renderDiff(diffRows) : renderCodeContent()}\n </div>\n );\n};\n\nexport default CodeBlock;\n"],"names":["renderLiteral","text","type","props","part","jsx","entryCount","value","isOverLimit","limit","keys","sizeOf","count","pathOf","key","collapseNodesLargerThan","isCollapsed","toggleArrowOver","collapsed","_a","FOCUS_RING","foldedSizeOver","keyName","CodeBlockHighlighter","React","DIFF_BACKGROUNDS","DIFF_MARKERS","ASSISTANT_DIFF_BACKGROUNDS","ASSISTANT_DIFF_MARKERS","ASSISTANT_DIFF_MARKER_COLORS","unchangedRun","diffDecoration","row","showLineNumbers","origin","assistant","CodeBlock","code","json","className","style","height","enableCopy","wrapLines","language","collapseLargerThan","diff","ariaLabel","ariaLabelledBy","devWarning","diffRows","diffHunks","diffText","textToCopy","copyOutcome","copy","useClipboardCopy","copied","copyButton","jsxs","Fragment","CheckmarkIcon","CopyIcon","viewportProps","FOCUS_RING_INSET","JsonView","copyClearance","renderPlainLines","decorate","lines","rowsWrapperStyle","line","index","decoration","CodeLine","renderPlainCode","renderDiff","rows","renderC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M,IAAI;AAAA,IACtE;AAEA,WAAIF,IAEI,gBAAAvC,EAACmB,EAAM,UAAN,EAAe,UAAU2C,EAAiBf,GAAUgB,CAAQ,GAQzD,UAAA,gBAAA/D;AAAA,MAACkB;AAAA,MAAA;AAAA,QACG,MAAM6B;AAAA,QACN,UAAAR;AAAA,QACA,iBAAAX;AAAA,QACA,WAAAU;AAAA,QACA,eAAAuB;AAAA,QACA,UAAAE;AAAA,QACA,eAAAL;AAAA,MAAA;AAAA,IAAA,GAER,IAIDI,EAAiBf,GAAUgB,CAAQ;AAAA,EAC9C,GAGMU,IAAoB,MACjBzC,IAIDO,sBAEKpB,EAAM,UAAN,EAAe,UAAUmD,KACtB,UAAA,gBAAAtE;AAAA,IAACkB;AAAA,IAAA;AAAA,MACG,MAAAc;AAAA,MACA,UAAAO;AAAA,MACA,iBAAAX;AAAA,MACA,WAAAU;AAAA,MACA,eAAAuB;AAAA,MACA,eAAAH;AAAA,IAAA;AAAA,EAAA,GAER,IAIDY,EAAA,IAlBI;AAqBf,SACI,gBAAAhB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,2DAA2DpB,CAAS;AAAA,MAC/E,OAAO;AAAA,QACH,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,QAAAE;AAAA,QACA,GAAGD;AAAA,MAAA;AAAA,MAGN,UAAA;AAAA,QAAAkB;AAAA,QACAR,IAAW0B,EAAW1B,CAAQ,IAAI4B,EAAA;AAAA,MAAkB;AAAA,IAAA;AAAA,EAAA;AAGjE;"}
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import JsonView from '@uiw/react-json-view';\nimport React from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport { type DiffDisplayRow, type DiffRowType, diffHunks } from './codeBlockDiff';\nimport { CodeLine, type CodeLineDecoration } from './codeBlockLine';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { useClipboardCopy } from './useClipboardCopy';\n\n/**\n * The value side of a JSON literal that has no value of its own to print, in its type's\n * colour. These read as keywords, as `true` and `false` do: the comment grey is under AA\n * contrast on the light background.\n */\nconst renderLiteral =\n (text: string, type: 'null' | 'undefined' | 'nan') =>\n (props: React.HTMLAttributes<HTMLSpanElement>, { type: part }: { type: 'type' | 'value' }) =>\n part === 'value' ? (\n <span {...props} style={{ ...props.style, color: `var(--w-rjv-type-${type}-color)` }}>\n {text}\n </span>\n ) : null;\n\n/** A json node's own entries, as the library counts them to draw it. */\nconst entryCount = (value: unknown): number =>\n value !== null && typeof value === 'object' ? Object.keys(value).length : 0;\n\n/** A nested node over the limit: the only kind the limit folds, toggles and sizes. */\nconst isOverLimit = (limit: number, value: unknown, keys: readonly (number | string)[]): boolean =>\n keys.length > 0 && entryCount(value) > limit;\n\nconst sizeOf = (value: unknown): string => {\n const count = entryCount(value);\n return `${count} ${count === 1 ? 'item' : 'items'}`;\n};\n\n/** Where a node sits, so two toggles for nodes sharing a key read apart: `users.0.roles`. */\nconst pathOf = (keys: readonly (number | string)[]): string =>\n keys.map((key) => String(key) || '\"\"').join('.');\n\n// The library's flag is the inverse of its name: returning true starts the node collapsed.\nconst collapseNodesLargerThan =\n (limit: number) =>\n (\n isCollapsed: boolean,\n { value, keys }: { value?: unknown; keys: (number | string)[] },\n ): boolean =>\n isCollapsed || isOverLimit(limit, value, keys);\n\n// The row around the arrow owns the click and the arrow's rotation is its only state, so this\n// button is a keyboard toggle that reads `aria-expanded` from it.\nconst toggleArrowOver =\n (limit: number) =>\n (\n props: { className?: string; style?: React.CSSProperties; children?: React.ReactNode },\n { value, keys }: { value?: unknown; keys?: (number | string)[] },\n ) => {\n if (!isOverLimit(limit, value, keys ?? [])) {\n return null;\n }\n const collapsed = String(props.style?.transform ?? '').includes('-90');\n return (\n <button\n type=\"button\"\n aria-expanded={!collapsed}\n aria-label={`${pathOf(keys ?? [])}, ${sizeOf(value)}`}\n className={`${props.className ?? ''} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${FOCUS_RING}`}\n style={props.style}\n >\n {props.children}\n </button>\n );\n };\n\nconst foldedSizeOver =\n (limit: number) =>\n // This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.\n (props: object, { value, keyName }: { value?: unknown; keyName?: string | number }) =>\n Reflect.get(props, 'data-expanded') &&\n isOverLimit(limit, value, keyName === undefined ? [] : [keyName]) ? (\n // Its toggle already names the size, so this would say it twice.\n <span\n aria-hidden=\"true\"\n className={`${Reflect.get(props, 'className') ?? ''} mx-[4px] cursor-pointer select-none text-[var(--malachite-codeblock-foreground)]`}\n >\n {`\\u2026 ${sizeOf(value)}`}\n </span>\n ) : null;\n\nconst CodeBlockHighlighter = React.lazy(() => import('./CodeBlockHighlighter'));\n\nexport interface CodeBlockProps {\n /** The code content to display */\n code?: string;\n /** JSON object to display as formatted JSON */\n json?: object;\n /** Show line numbers */\n showLineNumbers?: boolean;\n /** Custom class name */\n className?: string;\n /** Custom styles */\n style?: React.CSSProperties;\n /** Height of the code block */\n height?: string | number;\n /** Enable copy functionality */\n enableCopy?: boolean;\n /** Wrap long lines instead of scrolling horizontally */\n wrapLines?: boolean;\n /**\n * Highlight the code with this language's grammar. `cedar` is a grammar this library\n * ships itself (`prismCedar.ts`), since Prism and refractor carry none; widen the union\n * as further grammars are registered in CodeBlockHighlighter.\n */\n language?: 'yaml' | 'cedar';\n /** How much of a `json` tree starts collapsed: `true` all of it, a number below that depth. */\n collapsed?: boolean | number;\n /**\n * Starts any nested node with more entries than this collapsed, at any depth, behind a keyboard\n * toggle naming its path and size; nodes within the limit keep the library's arrow. 0 or more.\n */\n collapseLargerThan?: number;\n /**\n * Renders the change between two texts rather than one text, and takes precedence over\n * `code` and `json`. Only the changed lines are shown, with `context` unchanged ones either\n * side, so a small edit to a long document reads as a few hunks instead of the whole thing.\n */\n diff?: {\n before: string;\n after: string;\n /** Unchanged lines kept either side of each change. Three by convention. */\n context?: number;\n /**\n * Swaps the `+`/`-` gutter and tinted rows for the palette a mock specified for\n * AI-authored changes: star, minus-sign and middle-dot markers, and a struck-through\n * removal. Omit to keep the neutral markers; there is no default consumer for the\n * assistant look yet.\n */\n origin?: 'assistant';\n };\n /** Names the scrollable region. Defaults to \"Code\". */\n 'aria-label'?: string;\n /** Names the scrollable region by a visible label instead of `aria-label`. */\n 'aria-labelledby'?: string;\n}\n\nconst DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-added-background)',\n removed: 'var(--malachite-codeblock-diff-removed-background)',\n context: undefined,\n};\n\nconst DIFF_MARKERS: Record<DiffRowType, string | undefined> = {\n added: '+',\n removed: '-',\n context: undefined,\n};\n\n// The assistant palette also marks context rows, which the neutral one leaves bare.\nconst ASSISTANT_DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-assistant-background)',\n removed: 'var(--malachite-codeblock-diff-assistant-removed-background)',\n context: undefined,\n};\n\nconst ASSISTANT_DIFF_MARKERS: Record<DiffRowType, string> = {\n added: '\\u2726',\n // U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.\n removed: '\\u2212',\n context: '\\u00b7',\n};\n\nconst ASSISTANT_DIFF_MARKER_COLORS: Record<DiffRowType, string> = {\n added: 'var(--malachite-codeblock-diff-assistant-foreground)',\n removed: 'var(--malachite-codeblock-diff-removed-foreground)',\n context: 'var(--malachite-codeblock-diff-context-foreground)',\n};\n\nconst unchangedRun = (count: number): string =>\n `\\u22ef ${count} unchanged ${count === 1 ? 'line' : 'lines'}`;\n\nconst diffDecoration = (\n row: DiffDisplayRow,\n showLineNumbers: boolean,\n origin?: 'assistant',\n): CodeLineDecoration => {\n const assistant = origin === 'assistant';\n\n return {\n background: assistant ? ASSISTANT_DIFF_BACKGROUNDS[row.type] : DIFF_BACKGROUNDS[row.type],\n marker: assistant ? ASSISTANT_DIFF_MARKERS[row.type] : DIFF_MARKERS[row.type],\n markerColor: assistant ? ASSISTANT_DIFF_MARKER_COLORS[row.type] : undefined,\n // Reserved on unchanged rows too, so the code column does not step in and out.\n reserveMarker: true,\n // Context rows read as de-emphasised, not just unmarked, in the assistant palette.\n textColor:\n assistant && row.type === 'context'\n ? 'var(--malachite-codeblock-diff-context-text)'\n : undefined,\n strikethrough: assistant && row.type === 'removed',\n separatorAbove: row.skippedAbove === undefined ? undefined : unchangedRun(row.skippedAbove),\n // A removed line has no number in the after-text, so it keeps the one it had before.\n lineNumber: showLineNumbers ? (row.afterNumber ?? row.beforeNumber) : undefined,\n };\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n code,\n json,\n showLineNumbers = true,\n className = '',\n style = {},\n height,\n enableCopy = true,\n wrapLines = false,\n language,\n collapsed = false,\n collapseLargerThan,\n diff,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const limit =\n collapseLargerThan !== undefined &&\n Number.isInteger(collapseLargerThan) &&\n collapseLargerThan >= 0\n ? collapseLargerThan\n : undefined;\n if (collapseLargerThan !== undefined && limit === undefined) {\n devWarning(\n `CodeBlock.collapseLargerThan:${collapseLargerThan}`,\n `CodeBlock's collapseLargerThan takes a whole count of 0 or more; ${collapseLargerThan} is ignored.`,\n );\n }\n const diffRows = diff ? diffHunks(diff.before, diff.after, diff.context) : null;\n const diffText = diffRows?.map((row) => row.text).join('\\n') ?? '';\n\n /**\n * What the button puts on the clipboard, in the same form the block is showing. A JSON\n * block is pretty-printed rather than handed over minified: the reader is copying what\n * they can see. `undefined` means there is nothing to copy and no button to offer.\n */\n const copyText = (): string | undefined => {\n if (diffRows) {\n return diffText;\n }\n\n // An empty block has nothing to copy, so it offers no button — `!== undefined` would\n // hand back the empty string and put a dead control on it.\n if (code) {\n return code;\n }\n\n if (json !== undefined) {\n try {\n return JSON.stringify(json, null, 2);\n } catch {\n // A cycle or a BigInt: no honest text to copy, so offer no button.\n return undefined;\n }\n }\n\n return undefined;\n };\n\n const textToCopy = copyText();\n\n const { outcome: copyOutcome, copy } = useClipboardCopy(textToCopy);\n const copied = copyOutcome === 'copied';\n\n const handleCopy = () => {\n if (textToCopy !== undefined) {\n void copy(textToCopy);\n }\n };\n\n // Declared once and rendered by both the JSON branch and the code branch below, so the\n // two tabs of one document do not disagree about whether it can be copied.\n const copyButton = enableCopy && textToCopy !== undefined && (\n <>\n <button\n type=\"button\"\n aria-label=\"Copy\"\n onClick={handleCopy}\n className={`absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${FOCUS_RING}`}\n style={{ color: 'var(--malachite-codeblock-line-number)' }}\n >\n {copied ? <CheckmarkIcon size={14} /> : <CopyIcon size={14} />}\n </button>\n {/* Not role=\"status\": one per block would collide with a page's own status queries. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? 'Copied to clipboard' : ''}\n </span>\n </>\n );\n\n // Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.\n const viewportProps = {\n role: 'region',\n 'aria-label': ariaLabelledBy ? ariaLabel : (ariaLabel ?? 'Code'),\n 'aria-labelledby': ariaLabelledBy,\n tabIndex: 0,\n className: `box-border h-full overflow-auto ${FOCUS_RING_INSET}`,\n } satisfies React.HTMLAttributes<HTMLElement>;\n\n // If JSON is provided, use JsonView component\n if (json && !diffRows) {\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {/* The frame clips at `height`; this scrolls inside it, so the copy button stays put. */}\n <div {...viewportProps}>\n <JsonView\n value={json}\n style={\n {\n backgroundColor: 'var(--malachite-codeblock-background)',\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n padding: '16px',\n lineHeight: '1.5',\n textAlign: 'left',\n '--w-rjv-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-key-string': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-background-color': 'var(--malachite-codeblock-background)',\n '--w-rjv-line-color': 'var(--malachite-codeblock-border)',\n '--w-rjv-arrow-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-edit-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-info-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-update-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-copied-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-copied-success-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-curlybraces-color':\n 'var(--malachite-codeblock-foreground)',\n '--w-rjv-colon-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-brackets-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-quotes-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-quotes-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-int-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-float-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-bigint-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-boolean-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-date-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-url-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-null-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-nan-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-undefined-color':\n 'var(--malachite-codeblock-keyword)',\n } as React.CSSProperties\n }\n displayDataTypes={false}\n enableClipboard={enableCopy}\n collapsed={collapsed}\n shouldExpandNodeInitially={\n limit === undefined ? undefined : collapseNodesLargerThan(limit)\n }\n displayObjectSize={false}\n >\n {/* The library draws these three only as their type label, which\n `displayDataTypes` turns off, so without a value of their own a\n `null` reads as a key with nothing after it. */}\n <JsonView.Null render={renderLiteral('null', 'null')} />\n <JsonView.Undefined render={renderLiteral('undefined', 'undefined')} />\n <JsonView.Nan render={renderLiteral('NaN', 'nan')} />\n {/* Mounted either way: the library keeps a slot's last render, so it is\n switched off by passing none rather than by unmounting. */}\n <JsonView.Arrow\n render={limit === undefined ? undefined : toggleArrowOver(limit)}\n />\n <JsonView.Ellipsis\n render={limit === undefined ? undefined : foldedSizeOver(limit)}\n />\n </JsonView>\n </div>\n </div>\n );\n }\n\n // Reserve clearance so a wide first line never sits under the floating copy button.\n const copyClearance = enableCopy && (!!code || !!diffRows);\n\n const renderPlainLines = (\n text: string,\n decorate?: (index: number) => CodeLineDecoration | undefined,\n ) => {\n const lines = text.split('\\n');\n\n return (\n <div\n {...viewportProps}\n className={`${viewportProps.className} p-4 text-left`}\n style={{ paddingRight: copyClearance ? 44 : undefined }}\n >\n <div style={rowsWrapperStyle(wrapLines)}>\n {lines.map((line, index) => {\n const decoration = decorate?.(index);\n\n return (\n <CodeLine\n key={index}\n line={line}\n lineNumber={\n decoration?.lineNumber ??\n (showLineNumbers ? index + 1 : undefined)\n }\n wrap={wrapLines}\n decoration={decoration}\n >\n {line}\n </CodeLine>\n );\n })}\n </div>\n </div>\n );\n };\n\n const renderPlainCode = () => (code ? renderPlainLines(code) : null);\n\n const renderDiff = (rows: DiffDisplayRow[]) => {\n if (rows.length === 0) {\n return (\n <div\n className=\"p-4 text-left\"\n style={{ color: 'var(--malachite-codeblock-comment)' }}\n >\n No changes\n </div>\n );\n }\n\n const decorate = (index: number) => {\n const row = rows[index];\n\n return row ? diffDecoration(row, showLineNumbers, diff?.origin) : undefined;\n };\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainLines(diffText, decorate)}>\n {/*\n * The whole merged text goes to the highlighter in one piece, so a hunk\n * is tokenised in the company of its neighbours rather than on its own.\n * Prism still cannot see the lines the hunks left out, so a construct\n * spanning an omitted run can highlight oddly — the reason `context`\n * defaults to a few lines rather than none.\n */}\n <CodeBlockHighlighter\n code={diffText}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n decorate={decorate}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainLines(diffText, decorate);\n };\n\n // For code strings, create a simple syntax-highlighted view\n const renderCodeContent = () => {\n if (!code) {\n return null;\n }\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainCode()}>\n <CodeBlockHighlighter\n code={code}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainCode();\n };\n\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {diffRows ? renderDiff(diffRows) : renderCodeContent()}\n </div>\n );\n};\n\nexport default CodeBlock;\n"],"names":["renderLiteral","text","type","props","part","jsx","entryCount","value","isOverLimit","limit","keys","sizeOf","count","pathOf","key","collapseNodesLargerThan","isCollapsed","toggleArrowOver","collapsed","_a","FOCUS_RING","foldedSizeOver","keyName","CodeBlockHighlighter","React","DIFF_BACKGROUNDS","DIFF_MARKERS","ASSISTANT_DIFF_BACKGROUNDS","ASSISTANT_DIFF_MARKERS","ASSISTANT_DIFF_MARKER_COLORS","unchangedRun","diffDecoration","row","showLineNumbers","origin","assistant","CodeBlock","code","json","className","style","height","enableCopy","wrapLines","language","collapseLargerThan","diff","ariaLabel","ariaLabelledBy","devWarning","diffRows","diffHunks","diffText","textToCopy","copyOutcome","copy","useClipboardCopy","copied","copyButton","jsxs","Fragment","CheckmarkIcon","CopyIcon","viewportProps","FOCUS_RING_INSET","JsonView","copyClearance","renderPlainLines","decorate","lines","rowsWrapperStyle","line","index","decoration","CodeLine","renderPlainCode","renderDiff","rows","renderCodeContent"],"mappings":";;;;;;;;;;;AAgBA,MAAMA,IACF,CAACC,GAAcC,MACf,CAACC,GAA8C,EAAE,MAAMC,EAAA,MACnDA,MAAS,UACL,gBAAAC,EAAC,QAAA,EAAM,GAAGF,GAAO,OAAO,EAAE,GAAGA,EAAM,OAAO,OAAO,oBAAoBD,CAAI,UAAA,GACpE,UAAAD,EAAA,CACL,IACA,MAGNK,IAAa,CAACC,MAChBA,MAAU,QAAQ,OAAOA,KAAU,WAAW,OAAO,KAAKA,CAAK,EAAE,SAAS,GAGxEC,IAAc,CAACC,GAAeF,GAAgBG,MAChDA,EAAK,SAAS,KAAKJ,EAAWC,CAAK,IAAIE,GAErCE,IAAS,CAACJ,MAA2B;AACvC,QAAMK,IAAQN,EAAWC,CAAK;AAC9B,SAAO,GAAGK,CAAK,IAAIA,MAAU,IAAI,SAAS,OAAO;AACrD,GAGMC,IAAS,CAACH,MACZA,EAAK,IAAI,CAACI,MAAQ,OAAOA,CAAG,KAAK,IAAI,EAAE,KAAK,GAAG,GAG7CC,KACF,CAACN,MACD,CACIO,GACA,EAAE,OAAAT,GAAO,MAAAG,EAAA,MAETM,KAAeR,EAAYC,GAAOF,GAAOG,CAAI,GAI/CO,KACF,CAACR,MACD,CACIN,GACA,EAAE,OAAAI,GAAO,MAAAG,QACR;;AACD,MAAI,CAACF,EAAYC,GAAOF,GAAOG,KAAQ,CAAA,CAAE;AACrC,WAAO;AAEX,QAAMQ,IAAY,SAAOC,IAAAhB,EAAM,UAAN,gBAAAgB,EAAa,cAAa,EAAE,EAAE,SAAS,KAAK;AACrE,SACI,gBAAAd;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,iBAAe,CAACa;AAAA,MAChB,cAAY,GAAGL,EAAOH,KAAQ,CAAA,CAAE,CAAC,KAAKC,EAAOJ,CAAK,CAAC;AA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C,EAAKL,CAAK;AAEtB,aAAOxC,IAAMD,GAAeC,GAAKC,GAAiBa,KAAA,gBAAAA,EAAM,MAAM,IAAI;AAAA,IACtE;AAEA,WAAIF,IAEI,gBAAAvC,EAACmB,EAAM,UAAN,EAAe,UAAU2C,EAAiBf,GAAUgB,CAAQ,GAQzD,UAAA,gBAAA/D;AAAA,MAACkB;AAAA,MAAA;AAAA,QACG,MAAM6B;AAAA,QACN,UAAAR;AAAA,QACA,iBAAAX;AAAA,QACA,WAAAU;AAAA,QACA,eAAAuB;AAAA,QACA,UAAAE;AAAA,QACA,eAAAL;AAAA,MAAA;AAAA,IAAA,GAER,IAIDI,EAAiBf,GAAUgB,CAAQ;AAAA,EAC9C,GAGMU,IAAoB,MACjBzC,IAIDO,sBAEKpB,EAAM,UAAN,EAAe,UAAUmD,KACtB,UAAA,gBAAAtE;AAAA,IAACkB;AAAA,IAAA;AAAA,MACG,MAAAc;AAAA,MACA,UAAAO;AAAA,MACA,iBAAAX;AAAA,MACA,WAAAU;AAAA,MACA,eAAAuB;AAAA,MACA,eAAAH;AAAA,IAAA;AAAA,EAAA,GAER,IAIDY,EAAA,IAlBI;AAqBf,SACI,gBAAAhB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,2DAA2DpB,CAAS;AAAA,MAC/E,OAAO;AAAA,QACH,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,QAAAE;AAAA,QACA,GAAGD;AAAA,MAAA;AAAA,MAGN,UAAA;AAAA,QAAAkB;AAAA,QACAR,IAAW0B,EAAW1B,CAAQ,IAAI4B,EAAA;AAAA,MAAkB;AAAA,IAAA;AAAA,EAAA;AAGjE;"}
|
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, jsxs as n, Fragment as v } from "react/jsx-runtime";
|
|
2
2
|
import w, { useState as y, useEffect as N, useRef as k, useCallback as $ } from "react";
|
|
3
3
|
import { createPortal as R } from "react-dom";
|
|
4
|
-
import {
|
|
4
|
+
import { useFontFace as _ } from "../fontInjection.js";
|
|
5
|
+
import { ShadowRootWrapper as F } from "../ShadowRootWrapper.js";
|
|
5
6
|
import { Keycap as z } from "./Keycap.js";
|
|
6
|
-
import
|
|
7
|
+
import L from "./TruncatedTooltip.js";
|
|
7
8
|
import { paintOnChild as c } from "./asChild.js";
|
|
8
|
-
import { useOverlayBehaviour as
|
|
9
|
-
import { OVERLAY_ELEVATED_ATTR as
|
|
10
|
-
import { isRenderableNode as
|
|
11
|
-
const
|
|
9
|
+
import { useOverlayBehaviour as C } from "./overlayBehaviour.js";
|
|
10
|
+
import { OVERLAY_ELEVATED_ATTR as E, overlayIdentity as f } from "./portalOverlay.js";
|
|
11
|
+
import { isRenderableNode as T } from "./renderableNode.js";
|
|
12
|
+
const I = "w-full max-w-[640px] overflow-hidden font-body antialiased rounded-[var(--malachite-radius-xxl,14px)] border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] outline-none [box-shadow:0_16px_48px_0_rgba(0,0,0,0.18)]", S = ({
|
|
12
13
|
children: a,
|
|
13
14
|
onDismiss: e,
|
|
14
|
-
"aria-label":
|
|
15
|
+
"aria-label": r,
|
|
15
16
|
className: l = "",
|
|
16
17
|
style: i
|
|
17
18
|
}) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
_("geist");
|
|
20
|
+
const [d, m] = y(!1);
|
|
21
|
+
N(() => m(!0), []);
|
|
22
|
+
const s = k(null), p = $(() => e == null ? void 0 : e(), [e]), { ref: x, isTopmost: h, zIndex: b, elevated: g } = C({
|
|
21
23
|
open: !0,
|
|
22
|
-
onClose:
|
|
24
|
+
onClose: p,
|
|
23
25
|
hostRef: s,
|
|
24
26
|
initialFocus: "content"
|
|
25
27
|
});
|
|
26
28
|
return d ? R(
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
|
|
29
|
+
/* @__PURE__ */ t(
|
|
30
|
+
F,
|
|
29
31
|
{
|
|
30
32
|
hostRef: s,
|
|
31
33
|
hostStyle: { position: "relative", zIndex: b },
|
|
32
|
-
hostProps:
|
|
33
|
-
children: /* @__PURE__ */
|
|
34
|
+
hostProps: g ? { ...f("commandpalette"), [E]: "" } : f("commandpalette"),
|
|
35
|
+
children: /* @__PURE__ */ t(
|
|
34
36
|
"div",
|
|
35
37
|
{
|
|
36
38
|
className: "fixed inset-0 z-[1000] flex items-start justify-center pt-[10vh] bg-[var(--malachite-overlay-scrim,rgba(0,0,0,0.5))]",
|
|
37
39
|
onClick: e ? (u) => u.target === u.currentTarget && e() : void 0,
|
|
38
40
|
role: "presentation",
|
|
39
|
-
children: /* @__PURE__ */
|
|
41
|
+
children: /* @__PURE__ */ t(
|
|
40
42
|
"div",
|
|
41
43
|
{
|
|
42
44
|
ref: x,
|
|
43
45
|
role: "dialog",
|
|
44
46
|
"aria-modal": h ? "true" : void 0,
|
|
45
|
-
"aria-label":
|
|
47
|
+
"aria-label": r,
|
|
46
48
|
tabIndex: -1,
|
|
47
|
-
className: `${
|
|
49
|
+
className: `${I} ${l}`.trim(),
|
|
48
50
|
style: i,
|
|
49
51
|
children: a
|
|
50
52
|
}
|
|
@@ -55,61 +57,61 @@ const T = "w-full max-w-[640px] overflow-hidden font-body antialiased rounded-[v
|
|
|
55
57
|
),
|
|
56
58
|
document.body
|
|
57
59
|
) : null;
|
|
58
|
-
},
|
|
60
|
+
}, j = "w-full border-none bg-transparent px-0 py-[18px] text-[length:var(--malachite-font-size-xlarge,18px)] text-[var(--malachite-text-primary)] outline-none placeholder:text-[var(--malachite-text-placeholder)]", A = ({ children: a, className: e = "", style: r }) => c(a, `${j} ${e}`.trim(), r), P = ({ children: a, scope: e, className: r = "" }) => /* @__PURE__ */ n(
|
|
59
61
|
"div",
|
|
60
62
|
{
|
|
61
|
-
className: `flex items-center gap-2 border-0 border-b border-solid border-[var(--malachite-card-border)] px-[18px] ${
|
|
63
|
+
className: `flex items-center gap-2 border-0 border-b border-solid border-[var(--malachite-card-border)] px-[18px] ${r}`.trim(),
|
|
62
64
|
children: [
|
|
63
65
|
e,
|
|
64
66
|
a
|
|
65
67
|
]
|
|
66
68
|
}
|
|
67
|
-
),
|
|
68
|
-
c(a, `${
|
|
69
|
-
e ? /* @__PURE__ */
|
|
69
|
+
), G = ({ children: a }) => /* @__PURE__ */ t("span", { className: "flex-none whitespace-nowrap rounded-lg border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-sunken-background)] px-2 py-[3px] text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-primary)]", children: a }), M = "max-h-[420px] overflow-auto py-1 bg-[var(--malachite-card-background)]", O = ({ children: a, hasMoreBelow: e = !1, className: r = "", style: l }) => /* @__PURE__ */ n("div", { className: "relative", children: [
|
|
70
|
+
c(a, `${M} ${r}`.trim(), l),
|
|
71
|
+
e ? /* @__PURE__ */ t(
|
|
70
72
|
"div",
|
|
71
73
|
{
|
|
72
74
|
"aria-hidden": !0,
|
|
73
75
|
className: "pointer-events-none absolute inset-x-0 bottom-0 h-[28px] bg-[linear-gradient(to_bottom,transparent,var(--malachite-card-background))]"
|
|
74
76
|
}
|
|
75
77
|
) : null
|
|
76
|
-
] }),
|
|
78
|
+
] }), V = ({ children: a, divider: e = !1, className: r = "", style: l }) => c(
|
|
77
79
|
a,
|
|
78
|
-
`block pt-1 pb-2 ${e ? "border-0 border-b border-solid border-[var(--malachite-card-border)]" : ""} ${
|
|
80
|
+
`block pt-1 pb-2 ${e ? "border-0 border-b border-solid border-[var(--malachite-card-border)]" : ""} ${r}`.trim(),
|
|
79
81
|
l
|
|
80
|
-
),
|
|
82
|
+
), H = ({
|
|
81
83
|
children: a,
|
|
82
84
|
trailing: e
|
|
83
85
|
}) => /* @__PURE__ */ n("div", { className: "mb-1 flex items-center gap-2 px-4 text-[length:var(--malachite-font-size-xsmall,11px)] font-semibold uppercase tracking-[0.06em] text-[var(--malachite-text-secondary)]", children: [
|
|
84
86
|
a,
|
|
85
87
|
e
|
|
86
|
-
] }),
|
|
88
|
+
] }), W = "group mx-2 flex cursor-pointer items-center gap-2 rounded-[var(--malachite-radius-xl,12px)] px-3 py-[10px] text-[length:var(--malachite-font-size-medium,14px)] text-[var(--malachite-text-primary)] transition-colors hover:bg-[var(--malachite-card-sunken-background)] data-[selected=true]:bg-[var(--malachite-card-sunken-background)]", B = ({
|
|
87
89
|
children: a,
|
|
88
90
|
selected: e = !1,
|
|
89
|
-
leading:
|
|
91
|
+
leading: r,
|
|
90
92
|
label: l,
|
|
91
93
|
labelTooltip: i,
|
|
92
94
|
tags: d,
|
|
93
|
-
crumb:
|
|
95
|
+
crumb: m,
|
|
94
96
|
meta: s,
|
|
95
|
-
status:
|
|
97
|
+
status: p,
|
|
96
98
|
hint: x,
|
|
97
99
|
className: h = ""
|
|
98
100
|
}) => c(
|
|
99
101
|
a,
|
|
100
|
-
`${
|
|
102
|
+
`${W} ${e ? "bg-[var(--malachite-card-sunken-background)]" : ""} ${h}`.trim(),
|
|
101
103
|
void 0,
|
|
102
|
-
/* @__PURE__ */ n(
|
|
103
|
-
|
|
104
|
+
/* @__PURE__ */ n(v, { children: [
|
|
105
|
+
r,
|
|
104
106
|
/* @__PURE__ */ n("span", { className: "flex min-w-0 flex-1 items-baseline gap-2", children: [
|
|
105
|
-
l && i ? /* @__PURE__ */
|
|
106
|
-
l && !i ? /* @__PURE__ */
|
|
107
|
-
d ? /* @__PURE__ */
|
|
108
|
-
|
|
109
|
-
s ? /* @__PURE__ */
|
|
107
|
+
l && i ? /* @__PURE__ */ t(L, { text: i, triggerAs: "span", describesTrigger: !1, children: l }) : null,
|
|
108
|
+
l && !i ? /* @__PURE__ */ t("span", { className: "min-w-0 flex-[0_1_auto] overflow-hidden text-ellipsis whitespace-nowrap", children: l }) : null,
|
|
109
|
+
d ? /* @__PURE__ */ t("span", { className: "flex flex-none items-center gap-1 self-center", children: d }) : null,
|
|
110
|
+
m ? /* @__PURE__ */ t("span", { className: "flex-none whitespace-nowrap", children: m }) : null,
|
|
111
|
+
s ? /* @__PURE__ */ t("span", { className: "min-w-0 flex-[1_1_0%] overflow-hidden text-ellipsis whitespace-nowrap", children: s }) : null
|
|
110
112
|
] }),
|
|
111
|
-
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
+
T(p) ? /* @__PURE__ */ t("span", { className: "flex min-w-[84px] flex-none justify-end", children: p }) : null,
|
|
114
|
+
/* @__PURE__ */ t(
|
|
113
115
|
"span",
|
|
114
116
|
{
|
|
115
117
|
className: `flex-none ${e ? "" : "invisible"} group-data-[selected=true]:visible`,
|
|
@@ -117,36 +119,36 @@ const T = "w-full max-w-[640px] overflow-hidden font-body antialiased rounded-[v
|
|
|
117
119
|
}
|
|
118
120
|
)
|
|
119
121
|
] })
|
|
120
|
-
),
|
|
122
|
+
), K = ({ children: a, className: e = "", style: r }) => {
|
|
121
123
|
const l = `block px-4 py-2 text-[length:var(--malachite-font-size-medium,14px)] text-[var(--malachite-text-secondary)] ${e}`.trim();
|
|
122
|
-
return w.isValidElement(a) ? c(a, l,
|
|
123
|
-
},
|
|
124
|
-
/* @__PURE__ */
|
|
124
|
+
return w.isValidElement(a) ? c(a, l, r) : /* @__PURE__ */ t("div", { className: l, style: r, children: a });
|
|
125
|
+
}, Y = ({ items: a }) => /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-[14px] px-4 pt-[10px] pb-1 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-secondary)]", children: a.map((e) => /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-[6px]", children: [
|
|
126
|
+
/* @__PURE__ */ t(z, { size: "small", children: e.key }),
|
|
125
127
|
e.label
|
|
126
|
-
] }, e.key)) }),
|
|
128
|
+
] }, e.key)) }), q = ({ children: a, columns: e = 2, className: r = "" }) => /* @__PURE__ */ t(
|
|
127
129
|
"div",
|
|
128
130
|
{
|
|
129
|
-
className: `grid gap-1 px-2 ${e === 2 ? "grid-cols-2" : "grid-cols-1"} ${
|
|
131
|
+
className: `grid gap-1 px-2 ${e === 2 ? "grid-cols-2" : "grid-cols-1"} ${r}`.trim(),
|
|
130
132
|
children: a
|
|
131
133
|
}
|
|
132
|
-
),
|
|
134
|
+
), J = ({
|
|
133
135
|
children: a,
|
|
134
136
|
trailing: e
|
|
135
137
|
}) => /* @__PURE__ */ n("div", { className: "flex items-center justify-between gap-3 border-0 border-t border-solid border-[var(--malachite-card-border)] px-4 py-3 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-secondary)]", children: [
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
e ? /* @__PURE__ */
|
|
138
|
-
] }), o =
|
|
139
|
-
o.FieldRow =
|
|
140
|
-
o.Field =
|
|
141
|
-
o.ScopeChip =
|
|
142
|
-
o.List =
|
|
143
|
-
o.Group =
|
|
144
|
-
o.Heading =
|
|
145
|
-
o.Row =
|
|
146
|
-
o.Grid =
|
|
147
|
-
o.Message =
|
|
148
|
-
o.Legend =
|
|
149
|
-
o.Footer =
|
|
138
|
+
/* @__PURE__ */ t("span", { className: "flex items-center gap-[10px]", children: a }),
|
|
139
|
+
e ? /* @__PURE__ */ t("span", { className: "flex items-center gap-[10px]", children: e }) : null
|
|
140
|
+
] }), o = S;
|
|
141
|
+
o.FieldRow = P;
|
|
142
|
+
o.Field = A;
|
|
143
|
+
o.ScopeChip = G;
|
|
144
|
+
o.List = O;
|
|
145
|
+
o.Group = V;
|
|
146
|
+
o.Heading = H;
|
|
147
|
+
o.Row = B;
|
|
148
|
+
o.Grid = q;
|
|
149
|
+
o.Message = K;
|
|
150
|
+
o.Legend = Y;
|
|
151
|
+
o.Footer = J;
|
|
150
152
|
export {
|
|
151
153
|
o as CommandPalette,
|
|
152
154
|
o as default
|