@stackone/malachite 2.130.0 → 2.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +1 -1
- package/dist/components/Breadcrumbs.js +51 -45
- package/dist/components/Breadcrumbs.js.map +1 -1
- package/dist/components/CodeBlock.js +95 -91
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CopyOverlayButton.js +21 -17
- package/dist/components/CopyOverlayButton.js.map +1 -1
- package/dist/components/Input/Input.js +66 -65
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Modal.js +12 -12
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/Search.js +36 -36
- package/dist/components/Search.js.map +1 -1
- package/dist/components/Table/Table.js +2 -2
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tag.js +80 -70
- package/dist/components/Tag.js.map +1 -1
- package/dist/components/TextArea/TextArea.js +68 -67
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/focusRing.js +8 -6
- package/dist/components/focusRing.js.map +1 -1
- package/dist/components/visuallyHiddenStyle.js +6 -3
- package/dist/components/visuallyHiddenStyle.js.map +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -159,7 +159,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
159
159
|
|
|
160
160
|
## Theming & utility
|
|
161
161
|
|
|
162
|
-
- **`MalachiteContext`** — Wraps a subtree in the shadow root + theme context. Wrap groups of components in this. _Key props:_ `className`, `fillHeight`, `layer` (`'page'` by default; `'sidebar'` lifts the host above the page for a `Sidebar`)
|
|
162
|
+
- **`MalachiteContext`** — Wraps a subtree in the shadow root + theme context. Wrap groups of components in this. Text inside that sets no colour of its own takes the theme's primary text colour, not the host page's; to give it another, set `--malachite-default-text-color` on the host or any element above it. _Key props:_ `className`, `fillHeight`, `layer` (`'page'` by default; `'sidebar'` lifts the host above the page for a `Sidebar`)
|
|
163
163
|
- **`ThemeScope`** — Pins a subtree to a fixed theme (e.g. a dark island in a light app) via its own shadow root, since theme tokens are scoped per shadow root.
|
|
164
164
|
- **`CustomIcons`** — Namespace of all built-in icons (`CustomIcons.<Name>Icon`), coloured via `currentColor`.
|
|
165
165
|
- **`ShadowEscape`** — Renders children into the document (escaping the shadow root) for portals/overlays.
|
|
@@ -1,94 +1,100 @@
|
|
|
1
|
-
import { jsxs as u, jsx as
|
|
1
|
+
import { jsxs as u, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import N from "react";
|
|
3
3
|
import { Button as B } from "./Button.js";
|
|
4
4
|
import S from "./CustomIcons/ArrowLeftIcon.js";
|
|
5
5
|
import _ from "./CustomIcons/CaretRightIcon.js";
|
|
6
6
|
import $ from "./Typography/Text.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getTextColor as y } from "./Typography/textStyles.js";
|
|
8
|
+
import { hasBackButton as E } from "./breadcrumbsNav.js";
|
|
8
9
|
import { FOCUS_RING as x } from "./focusRing.js";
|
|
9
|
-
import { isSafeHref as
|
|
10
|
-
const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${x}`,
|
|
10
|
+
import { isSafeHref as A, safeHref as C } from "./safeHref.js";
|
|
11
|
+
const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${x}`, T = `flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--malachite-radius-10,10px)] no-underline bg-[var(--malachite-number-tag-background,rgba(0,0,0,0.08))] text-[var(--malachite-text-primary,rgb(10,10,10))] transition-colors duration-200 ease-in-out hover:bg-[var(--malachite-number-tag-emphasis-background,rgba(0,0,0,0.15))] ${x}`, p = (e, r) => A(e.href) ? r ? r(e) : /* @__PURE__ */ i("a", { ...e }) : e.children, v = { margin: 0 }, I = {
|
|
11
12
|
...v,
|
|
12
13
|
fontSize: "inherit",
|
|
13
14
|
fontWeight: "inherit"
|
|
14
|
-
}, f = (e, r, a) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
}, f = (e, r, a) => {
|
|
16
|
+
if (typeof e == "string")
|
|
17
|
+
return /* @__PURE__ */ i(
|
|
18
|
+
$,
|
|
19
|
+
{
|
|
20
|
+
as: a,
|
|
21
|
+
size: "medium",
|
|
22
|
+
fontWeight: "semi-bold",
|
|
23
|
+
color: r,
|
|
24
|
+
style: a ? v : void 0,
|
|
25
|
+
children: e
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
const o = { ...a ? I : {}, color: y(r) };
|
|
29
|
+
return N.createElement(a ?? "span", { style: o }, e);
|
|
30
|
+
}, z = ({
|
|
25
31
|
label: e,
|
|
26
32
|
onClick: r,
|
|
27
33
|
disabled: a,
|
|
28
|
-
variant:
|
|
34
|
+
variant: o,
|
|
29
35
|
icon: s,
|
|
30
36
|
href: d,
|
|
31
37
|
target: h,
|
|
32
|
-
tooltip:
|
|
33
|
-
tooltipPlacement:
|
|
34
|
-
},
|
|
35
|
-
const t =
|
|
36
|
-
return /* @__PURE__ */
|
|
38
|
+
tooltip: n,
|
|
39
|
+
tooltipPlacement: l
|
|
40
|
+
}, c) => {
|
|
41
|
+
const t = C(d);
|
|
42
|
+
return /* @__PURE__ */ i(
|
|
37
43
|
B,
|
|
38
44
|
{
|
|
39
45
|
size: "small",
|
|
40
|
-
variant:
|
|
46
|
+
variant: o ?? "outline",
|
|
41
47
|
disabled: a,
|
|
42
48
|
icon: s,
|
|
43
|
-
tooltip:
|
|
44
|
-
tooltipPlacement:
|
|
49
|
+
tooltip: n,
|
|
50
|
+
tooltipPlacement: l,
|
|
45
51
|
href: t,
|
|
46
52
|
target: t ? h ?? "_blank" : void 0,
|
|
47
53
|
onClick: t ? void 0 : r,
|
|
48
54
|
children: e
|
|
49
55
|
},
|
|
50
|
-
`${
|
|
56
|
+
`${c}-${e}`
|
|
51
57
|
);
|
|
52
|
-
},
|
|
58
|
+
}, F = ({
|
|
53
59
|
links: e,
|
|
54
60
|
actions: r,
|
|
55
61
|
renderLink: a,
|
|
56
|
-
titleElement:
|
|
62
|
+
titleElement: o,
|
|
57
63
|
className: s = "",
|
|
58
64
|
style: d
|
|
59
65
|
}) => {
|
|
60
66
|
if (e.length === 0 && !(r != null && r.length))
|
|
61
67
|
return null;
|
|
62
|
-
const h = e.length === 1 && !!e[0].isRoot,
|
|
68
|
+
const h = e.length === 1 && !!e[0].isRoot, n = E(e) ? e[e.length - 2] : void 0, l = n == null ? void 0 : n.name, c = !!(r != null && r.length);
|
|
63
69
|
return /* @__PURE__ */ u(
|
|
64
70
|
"div",
|
|
65
71
|
{
|
|
66
|
-
className: `flex items-center ${
|
|
72
|
+
className: `flex items-center ${c ? "justify-between" : ""} ${s}`,
|
|
67
73
|
style: d,
|
|
68
74
|
children: [
|
|
69
|
-
h ? f(e[0].name, "primary",
|
|
70
|
-
(
|
|
75
|
+
h ? f(e[0].name, "primary", o) : /* @__PURE__ */ u("div", { className: "flex items-center gap-4", children: [
|
|
76
|
+
(n == null ? void 0 : n.url) && p(
|
|
71
77
|
{
|
|
72
|
-
href:
|
|
73
|
-
"aria-label": typeof
|
|
74
|
-
className:
|
|
75
|
-
children: /* @__PURE__ */
|
|
78
|
+
href: n.url,
|
|
79
|
+
"aria-label": typeof l == "string" ? `Back to ${l}` : "Go back",
|
|
80
|
+
className: T,
|
|
81
|
+
children: /* @__PURE__ */ i(S, { size: 12 })
|
|
76
82
|
},
|
|
77
83
|
a
|
|
78
84
|
),
|
|
79
|
-
e.length > 0 && /* @__PURE__ */
|
|
80
|
-
const
|
|
85
|
+
e.length > 0 && /* @__PURE__ */ i("nav", { "aria-label": "Breadcrumb", children: /* @__PURE__ */ i("ol", { className: "flex flex-wrap items-center gap-2 m-0 p-0 list-none", children: e.map((t, g) => {
|
|
86
|
+
const m = g === e.length - 1, b = m ? "primary" : "muted";
|
|
81
87
|
return /* @__PURE__ */ u(
|
|
82
88
|
"li",
|
|
83
89
|
{
|
|
84
90
|
className: "flex items-center gap-2",
|
|
85
|
-
"aria-current":
|
|
91
|
+
"aria-current": m && !t.url ? "page" : void 0,
|
|
86
92
|
children: [
|
|
87
93
|
t.url ? p(
|
|
88
94
|
{
|
|
89
95
|
href: t.url,
|
|
90
|
-
"aria-current":
|
|
91
|
-
className: `${R} ${
|
|
96
|
+
"aria-current": m ? "page" : void 0,
|
|
97
|
+
className: `${R} ${m ? "text-[var(--malachite-text-primary,rgb(10,10,10))]" : "text-[var(--malachite-text-muted,rgb(76,75,75))]"}`,
|
|
92
98
|
children: f(
|
|
93
99
|
t.name,
|
|
94
100
|
"inherit"
|
|
@@ -96,12 +102,12 @@ const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200
|
|
|
96
102
|
},
|
|
97
103
|
a
|
|
98
104
|
) : f(t.name, b),
|
|
99
|
-
!
|
|
105
|
+
!m && /* @__PURE__ */ i(
|
|
100
106
|
"span",
|
|
101
107
|
{
|
|
102
108
|
"aria-hidden": "true",
|
|
103
109
|
className: "flex items-center text-[var(--malachite-text-dimmed,rgb(161,161,161))]",
|
|
104
|
-
children: /* @__PURE__ */
|
|
110
|
+
children: /* @__PURE__ */ i(_, { size: 13 })
|
|
105
111
|
}
|
|
106
112
|
)
|
|
107
113
|
]
|
|
@@ -110,13 +116,13 @@ const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200
|
|
|
110
116
|
);
|
|
111
117
|
}) }) })
|
|
112
118
|
] }),
|
|
113
|
-
|
|
119
|
+
c && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: r == null ? void 0 : r.map(z) })
|
|
114
120
|
]
|
|
115
121
|
}
|
|
116
122
|
);
|
|
117
123
|
};
|
|
118
124
|
export {
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
F as Breadcrumbs,
|
|
126
|
+
F as default
|
|
121
127
|
};
|
|
122
128
|
//# sourceMappingURL=Breadcrumbs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.js","sources":["../../src/components/Breadcrumbs.tsx"],"sourcesContent":["import React from 'react';\nimport Button from './Button';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport type { BreadcrumbLink, PageAction, RenderLink } from './PageLayout/types';\nimport Text, { type TextColor, type TextElement } from './Typography/Text';\nimport { hasBackButton } from './breadcrumbsNav';\nimport { FOCUS_RING } from './focusRing';\nimport { isSafeHref, safeHref } from './safeHref';\n\nexport interface BreadcrumbsProps {\n links: BreadcrumbLink[];\n actions?: PageAction[];\n renderLink?: RenderLink;\n /** The element a lone root crumb renders as, e.g. `h1` when it titles the page. */\n titleElement?: TextElement;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst CRUMB_LINK_CLASSES = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${FOCUS_RING}`;\n\nconst BACK_BUTTON_CLASSES = `flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--malachite-radius-10,10px)] no-underline bg-[var(--malachite-number-tag-background,rgba(0,0,0,0.08))] text-[var(--malachite-text-primary,rgb(10,10,10))] transition-colors duration-200 ease-in-out hover:bg-[var(--malachite-number-tag-emphasis-background,rgba(0,0,0,0.15))] ${FOCUS_RING}`;\n\ntype LinkProps = Parameters<RenderLink>[0];\n\nconst renderCrumbLink = (props: LinkProps, renderLink?: RenderLink): React.ReactNode => {\n // An unsafe url degrades to plain text rather than a link that could run a script.\n if (!isSafeHref(props.href)) {\n return props.children;\n }\n return renderLink ? renderLink(props) : <a {...props} />;\n};\n\nconst HEADING_RESET: React.CSSProperties = { margin: 0 };\n\nconst NODE_HEADING_RESET: React.CSSProperties = {\n ...HEADING_RESET,\n fontSize: 'inherit',\n fontWeight: 'inherit',\n};\n\nconst renderCrumbName = (\n name: React.ReactNode,\n color: TextColor,\n as?: TextElement,\n): React.ReactNode => {\n if (typeof name === 'string') {\n return (\n <Text\n as={as}\n size=\"medium\"\n fontWeight=\"semi-bold\"\n color={color}\n style={as ? HEADING_RESET : undefined}\n >\n {name}\n </Text>\n );\n }\n return as ? React.createElement(as, { style: NODE_HEADING_RESET }, name) : name;\n};\n\nconst renderAction = (\n {\n label,\n onClick,\n disabled,\n variant,\n icon,\n href,\n target,\n tooltip,\n tooltipPlacement,\n }: PageAction,\n index: number,\n) => {\n const safe = safeHref(href);\n return (\n <Button\n key={`${index}-${label}`}\n size=\"small\"\n variant={variant ?? 'outline'}\n disabled={disabled}\n icon={icon}\n tooltip={tooltip}\n tooltipPlacement={tooltipPlacement}\n href={safe}\n target={safe ? (target ?? '_blank') : undefined}\n onClick={safe ? undefined : onClick}\n >\n {label}\n </Button>\n );\n};\n\nconst Breadcrumbs: React.FC<BreadcrumbsProps> = ({\n links,\n actions,\n renderLink,\n titleElement,\n className = '',\n style,\n}) => {\n // PageLayout mounts this unconditionally, so returning markup would leave an empty\n // navigation landmark on every page without crumbs.\n if (links.length === 0 && !actions?.length) {\n return null;\n }\n\n const isTitle = links.length === 1 && Boolean(links[0].isRoot);\n const parentCrumb = hasBackButton(links) ? links[links.length - 2] : undefined;\n const parentName = parentCrumb?.name;\n const hasActions = Boolean(actions?.length);\n\n return (\n <div\n className={`flex items-center ${hasActions ? 'justify-between' : ''} ${className}`}\n style={style}\n >\n {isTitle ? (\n renderCrumbName(links[0].name, 'primary', titleElement)\n ) : (\n <div className=\"flex items-center gap-4\">\n {parentCrumb?.url &&\n renderCrumbLink(\n {\n href: parentCrumb.url,\n 'aria-label':\n typeof parentName === 'string'\n ? `Back to ${parentName}`\n : 'Go back',\n className: BACK_BUTTON_CLASSES,\n children: <ArrowLeftIcon size={12} />,\n },\n renderLink,\n )}\n {links.length > 0 && (\n <nav aria-label=\"Breadcrumb\">\n <ol className=\"flex flex-wrap items-center gap-2 m-0 p-0 list-none\">\n {links.map((link, index) => {\n const isLast = index === links.length - 1;\n const color: TextColor = isLast ? 'primary' : 'muted';\n\n return (\n <li\n key={`${link.url ?? ''}-${index}`}\n className=\"flex items-center gap-2\"\n aria-current={isLast && !link.url ? 'page' : undefined}\n >\n {link.url\n ? renderCrumbLink(\n {\n href: link.url,\n 'aria-current': isLast\n ? 'page'\n : undefined,\n className: `${CRUMB_LINK_CLASSES} ${\n isLast\n ? 'text-[var(--malachite-text-primary,rgb(10,10,10))]'\n : 'text-[var(--malachite-text-muted,rgb(76,75,75))]'\n }`,\n children: renderCrumbName(\n link.name,\n 'inherit',\n ),\n },\n renderLink,\n )\n : renderCrumbName(link.name, color)}\n {!isLast && (\n <span\n aria-hidden=\"true\"\n className=\"flex items-center text-[var(--malachite-text-dimmed,rgb(161,161,161))]\"\n >\n <CaretRightIcon size={13} />\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n )}\n </div>\n )}\n {hasActions && (\n <div className=\"flex items-center gap-2\">{actions?.map(renderAction)}</div>\n )}\n </div>\n );\n};\n\nexport { Breadcrumbs };\nexport default Breadcrumbs;\n"],"names":["CRUMB_LINK_CLASSES","FOCUS_RING","BACK_BUTTON_CLASSES","renderCrumbLink","props","renderLink","isSafeHref","jsx","HEADING_RESET","NODE_HEADING_RESET","renderCrumbName","name","color","as","Text","React","renderAction","label","onClick","disabled","variant","icon","href","target","tooltip","tooltipPlacement","index","safe","safeHref","Button","Breadcrumbs","links","actions","titleElement","className","style","isTitle","parentCrumb","hasBackButton","parentName","hasActions","jsxs","ArrowLeftIcon","link","isLast","CaretRightIcon"],"mappings":";;;;;;;;;AAoBA,MAAMA,IAAqB,mJAAmJC,CAAU,IAElLC,IAAsB,mVAAmVD,CAAU,IAInXE,IAAkB,CAACC,GAAkBC,MAElCC,EAAWF,EAAM,IAAI,IAGnBC,IAAaA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A;AAAA,sBACN,WAAW,GAAG5C,CAAkB,IAC5B4C,IACM,uDACA,kDACV;AAAA,sBACA,UAAUlC;AAAA,wBACNiC,EAAK;AAAA,wBACL;AAAA,sBAAA;AAAA,oBACJ;AAAA,oBAEJtC;AAAA,kBAAA,IAEJK,EAAgBiC,EAAK,MAAM/B,CAAK;AAAA,kBACrC,CAACgC,KACE,gBAAArC;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACG,eAAY;AAAA,sBACZ,WAAU;AAAA,sBAEV,UAAA,gBAAAA,EAACsC,GAAA,EAAe,MAAM,GAAA,CAAI;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAC9B;AAAA,cAAA;AAAA,cA9BC,GAAGF,EAAK,OAAO,EAAE,IAAIjB,CAAK;AAAA,YAAA;AAAA,UAkC3C,CAAC,GACL,EAAA,CACJ;AAAA,QAAA,GAER;AAAA,QAEHc,uBACI,OAAA,EAAI,WAAU,2BAA2B,UAAAR,KAAA,gBAAAA,EAAS,IAAIhB,GAAY,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIrF;"}
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.js","sources":["../../src/components/Breadcrumbs.tsx"],"sourcesContent":["import React from 'react';\nimport Button from './Button';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport type { BreadcrumbLink, PageAction, RenderLink } from './PageLayout/types';\nimport Text, { type TextColor, type TextElement } from './Typography/Text';\nimport { getTextColor } from './Typography/textStyles';\nimport { hasBackButton } from './breadcrumbsNav';\nimport { FOCUS_RING } from './focusRing';\nimport { isSafeHref, safeHref } from './safeHref';\n\nexport interface BreadcrumbsProps {\n links: BreadcrumbLink[];\n actions?: PageAction[];\n renderLink?: RenderLink;\n /** The element a lone root crumb renders as, e.g. `h1` when it titles the page. */\n titleElement?: TextElement;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst CRUMB_LINK_CLASSES = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${FOCUS_RING}`;\n\nconst BACK_BUTTON_CLASSES = `flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--malachite-radius-10,10px)] no-underline bg-[var(--malachite-number-tag-background,rgba(0,0,0,0.08))] text-[var(--malachite-text-primary,rgb(10,10,10))] transition-colors duration-200 ease-in-out hover:bg-[var(--malachite-number-tag-emphasis-background,rgba(0,0,0,0.15))] ${FOCUS_RING}`;\n\ntype LinkProps = Parameters<RenderLink>[0];\n\nconst renderCrumbLink = (props: LinkProps, renderLink?: RenderLink): React.ReactNode => {\n // An unsafe url degrades to plain text rather than a link that could run a script.\n if (!isSafeHref(props.href)) {\n return props.children;\n }\n return renderLink ? renderLink(props) : <a {...props} />;\n};\n\nconst HEADING_RESET: React.CSSProperties = { margin: 0 };\n\nconst NODE_HEADING_RESET: React.CSSProperties = {\n ...HEADING_RESET,\n fontSize: 'inherit',\n fontWeight: 'inherit',\n};\n\nconst renderCrumbName = (\n name: React.ReactNode,\n color: TextColor,\n as?: TextElement,\n): React.ReactNode => {\n if (typeof name === 'string') {\n return (\n <Text\n as={as}\n size=\"medium\"\n fontWeight=\"semi-bold\"\n color={color}\n style={as ? HEADING_RESET : undefined}\n >\n {name}\n </Text>\n );\n }\n // The crumb's colour, as a string crumb's `Text` sets it: left to inherit, a node takes the\n // consumer page's text colour through the shadow root instead.\n const style = { ...(as ? NODE_HEADING_RESET : {}), color: getTextColor(color) };\n return React.createElement(as ?? 'span', { style }, name);\n};\n\nconst renderAction = (\n {\n label,\n onClick,\n disabled,\n variant,\n icon,\n href,\n target,\n tooltip,\n tooltipPlacement,\n }: PageAction,\n index: number,\n) => {\n const safe = safeHref(href);\n return (\n <Button\n key={`${index}-${label}`}\n size=\"small\"\n variant={variant ?? 'outline'}\n disabled={disabled}\n icon={icon}\n tooltip={tooltip}\n tooltipPlacement={tooltipPlacement}\n href={safe}\n target={safe ? (target ?? '_blank') : undefined}\n onClick={safe ? undefined : onClick}\n >\n {label}\n </Button>\n );\n};\n\nconst Breadcrumbs: React.FC<BreadcrumbsProps> = ({\n links,\n actions,\n renderLink,\n titleElement,\n className = '',\n style,\n}) => {\n // PageLayout mounts this unconditionally, so returning markup would leave an empty\n // navigation landmark on every page without crumbs.\n if (links.length === 0 && !actions?.length) {\n return null;\n }\n\n const isTitle = links.length === 1 && Boolean(links[0].isRoot);\n const parentCrumb = hasBackButton(links) ? links[links.length - 2] : undefined;\n const parentName = parentCrumb?.name;\n const hasActions = Boolean(actions?.length);\n\n return (\n <div\n className={`flex items-center ${hasActions ? 'justify-between' : ''} ${className}`}\n style={style}\n >\n {isTitle ? (\n renderCrumbName(links[0].name, 'primary', titleElement)\n ) : (\n <div className=\"flex items-center gap-4\">\n {parentCrumb?.url &&\n renderCrumbLink(\n {\n href: parentCrumb.url,\n 'aria-label':\n typeof parentName === 'string'\n ? `Back to ${parentName}`\n : 'Go back',\n className: BACK_BUTTON_CLASSES,\n children: <ArrowLeftIcon size={12} />,\n },\n renderLink,\n )}\n {links.length > 0 && (\n <nav aria-label=\"Breadcrumb\">\n <ol className=\"flex flex-wrap items-center gap-2 m-0 p-0 list-none\">\n {links.map((link, index) => {\n const isLast = index === links.length - 1;\n const color: TextColor = isLast ? 'primary' : 'muted';\n\n return (\n <li\n key={`${link.url ?? ''}-${index}`}\n className=\"flex items-center gap-2\"\n aria-current={isLast && !link.url ? 'page' : undefined}\n >\n {link.url\n ? renderCrumbLink(\n {\n href: link.url,\n 'aria-current': isLast\n ? 'page'\n : undefined,\n className: `${CRUMB_LINK_CLASSES} ${\n isLast\n ? 'text-[var(--malachite-text-primary,rgb(10,10,10))]'\n : 'text-[var(--malachite-text-muted,rgb(76,75,75))]'\n }`,\n children: renderCrumbName(\n link.name,\n 'inherit',\n ),\n },\n renderLink,\n )\n : renderCrumbName(link.name, color)}\n {!isLast && (\n <span\n aria-hidden=\"true\"\n className=\"flex items-center text-[var(--malachite-text-dimmed,rgb(161,161,161))]\"\n >\n <CaretRightIcon size={13} />\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n )}\n </div>\n )}\n {hasActions && (\n <div className=\"flex items-center gap-2\">{actions?.map(renderAction)}</div>\n )}\n </div>\n );\n};\n\nexport { Breadcrumbs };\nexport default Breadcrumbs;\n"],"names":["CRUMB_LINK_CLASSES","FOCUS_RING","BACK_BUTTON_CLASSES","renderCrumbLink","props","renderLink","isSafeHref","jsx","HEADING_RESET","NODE_HEADING_RESET","renderCrumbName","name","color","as","Text","style","getTextColor","React","renderAction","label","onClick","disabled","variant","icon","href","target","tooltip","tooltipPlacement","index","safe","safeHref","Button","Breadcrumbs","links","actions","titleElement","className","isTitle","parentCrumb","hasBackButton","parentName","hasActions","jsxs","ArrowLeftIcon","link","isLast","CaretRightIcon"],"mappings":";;;;;;;;;;AAqBA,MAAMA,IAAqB,mJAAmJC,CAAU,IAElLC,IAAsB,mVAAmVD,CAAU,IAInXE,IAAkB,CAACC,GAAkBC,MAElCC,EAAWF,EAAM,IAAI,IAGnBC,IAAaA,EAAWD,CAAK,IAAI,gBAAAG,EAAC,KAAA,EAAG,GAAGH,GAAO,IAF3CA,EAAM,UAKfI,IAAqC,EAAE,QAAQ,EAAA,GAE/CC,IAA0C;AAAA,EAC5C,GAAGD;AAAA,EACH,UAAU;AAAA,EACV,YAAY;AAChB,GAEME,IAAkB,CACpBC,GACAC,GACAC,MACkB;AAClB,MAAI,OAAOF,KAAS;AAChB,WACI,gBAAAJ;AAAA,MAACO;AAAA,MAAA;AAAA,QACG,IAAAD;AAAA,QACA,MAAK;AAAA,QACL,YAAW;AAAA,QACX,OAAAD;AAAA,QACA,OAAOC,IAAKL,IAAgB;AAAA,QAE3B,UAAAG;AAAA,MAAA;AAAA,IAAA;AAMb,QAAMI,IAAQ,EAAE,GAAIF,IAAKJ,IAAqB,CAAA,GAAK,OAAOO,EAAaJ,CAAK,EAAA;AAC5E,SAAOK,E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AAAA,cA9BC,GAAGF,EAAK,OAAO,EAAE,IAAIhB,CAAK;AAAA,YAAA;AAAA,UAkC3C,CAAC,GACL,EAAA,CACJ;AAAA,QAAA,GAER;AAAA,QAEHa,uBACI,OAAA,EAAI,WAAU,2BAA2B,UAAAP,KAAA,gBAAAA,EAAS,IAAIhB,GAAY,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIrF;"}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as A, jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import v from "@uiw/react-json-view";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { diffHunks as
|
|
6
|
-
import { CodeLine as
|
|
7
|
-
import { rowsWrapperStyle as
|
|
8
|
-
import { devWarning as
|
|
9
|
-
import { FOCUS_RING_INSET as
|
|
10
|
-
const
|
|
11
|
-
const o =
|
|
3
|
+
import j from "react";
|
|
4
|
+
import M from "./CopyOverlayButton.js";
|
|
5
|
+
import { diffHunks as H } from "./codeBlockDiff.js";
|
|
6
|
+
import { CodeLine as P } from "./codeBlockLine.js";
|
|
7
|
+
import { rowsWrapperStyle as q } from "./codeBlockStyles.js";
|
|
8
|
+
import { devWarning as J } from "./devWarning.js";
|
|
9
|
+
import { FOCUS_RING_INSET as W, FOCUS_RING as z } from "./focusRing.js";
|
|
10
|
+
const I = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span", { ...r, style: { ...r.style, color: `var(--w-rjv-type-${o}-color)` }, children: e }) : null, E = (e) => e !== null && typeof e == "object" ? Object.keys(e).length : 0, O = (e, o, r) => r.length > 0 && E(o) > e, B = (e) => {
|
|
11
|
+
const o = E(e);
|
|
12
12
|
return `${o} ${o === 1 ? "item" : "items"}`;
|
|
13
|
-
},
|
|
14
|
-
var
|
|
15
|
-
if (!
|
|
13
|
+
}, V = (e) => e.map((o) => String(o) || '""').join("."), Q = (e) => (o, { value: r, keys: t }) => o || O(e, r, t), X = (e) => (o, { value: r, keys: t }) => {
|
|
14
|
+
var m;
|
|
15
|
+
if (!O(e, r, t ?? []))
|
|
16
16
|
return null;
|
|
17
|
-
const k = String(((
|
|
17
|
+
const k = String(((m = o.style) == null ? void 0 : m.transform) ?? "").includes("-90");
|
|
18
18
|
return /* @__PURE__ */ c(
|
|
19
19
|
"button",
|
|
20
20
|
{
|
|
21
21
|
type: "button",
|
|
22
22
|
"aria-expanded": !k,
|
|
23
|
-
"aria-label": `${
|
|
24
|
-
className: `${o.className ?? ""} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${
|
|
23
|
+
"aria-label": `${V(t ?? [])}, ${B(r)}`,
|
|
24
|
+
className: `${o.className ?? ""} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${z}`,
|
|
25
25
|
style: o.style,
|
|
26
26
|
children: o.children
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
|
-
},
|
|
29
|
+
}, Y = (e) => (
|
|
30
30
|
// This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.
|
|
31
|
-
((o, { value: r, keyName: t }) => Reflect.get(o, "data-expanded") &&
|
|
31
|
+
((o, { value: r, keyName: t }) => Reflect.get(o, "data-expanded") && O(e, r, t === void 0 ? [] : [t]) ? (
|
|
32
32
|
// Its toggle already names the size, so this would say it twice.
|
|
33
33
|
/* @__PURE__ */ c(
|
|
34
34
|
"span",
|
|
@@ -39,67 +39,67 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
|
|
|
39
39
|
}
|
|
40
40
|
)
|
|
41
41
|
) : null)
|
|
42
|
-
),
|
|
42
|
+
), T = j.lazy(() => import("./CodeBlockHighlighter.js")), Z = {
|
|
43
43
|
added: "var(--malachite-codeblock-diff-added-background)",
|
|
44
44
|
removed: "var(--malachite-codeblock-diff-removed-background)",
|
|
45
45
|
context: void 0
|
|
46
|
-
},
|
|
46
|
+
}, L = {
|
|
47
47
|
added: "+",
|
|
48
48
|
removed: "-",
|
|
49
49
|
context: void 0
|
|
50
|
-
},
|
|
50
|
+
}, ee = {
|
|
51
51
|
added: "var(--malachite-codeblock-diff-assistant-background)",
|
|
52
52
|
removed: "var(--malachite-codeblock-diff-assistant-removed-background)",
|
|
53
53
|
context: void 0
|
|
54
|
-
},
|
|
54
|
+
}, oe = {
|
|
55
55
|
added: "✦",
|
|
56
56
|
// U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.
|
|
57
57
|
removed: "−",
|
|
58
58
|
context: "·"
|
|
59
|
-
},
|
|
59
|
+
}, re = {
|
|
60
60
|
added: "var(--malachite-codeblock-diff-assistant-foreground)",
|
|
61
61
|
removed: "var(--malachite-codeblock-diff-removed-foreground)",
|
|
62
62
|
context: "var(--malachite-codeblock-diff-context-foreground)"
|
|
63
|
-
},
|
|
63
|
+
}, te = (e) => `⋯ ${e} unchanged ${e === 1 ? "line" : "lines"}`, ce = (e, o, r) => {
|
|
64
64
|
const t = r === "assistant";
|
|
65
65
|
return {
|
|
66
|
-
background: t ?
|
|
67
|
-
marker: t ?
|
|
68
|
-
markerColor: t ?
|
|
66
|
+
background: t ? ee[e.type] : Z[e.type],
|
|
67
|
+
marker: t ? oe[e.type] : L[e.type],
|
|
68
|
+
markerColor: t ? re[e.type] : void 0,
|
|
69
69
|
// Reserved on unchanged rows too, so the code column does not step in and out.
|
|
70
70
|
reserveMarker: !0,
|
|
71
71
|
// Context rows read as de-emphasised, not just unmarked, in the assistant palette.
|
|
72
72
|
textColor: t && e.type === "context" ? "var(--malachite-codeblock-diff-context-text)" : void 0,
|
|
73
73
|
strikethrough: t && e.type === "removed",
|
|
74
|
-
separatorAbove: e.skippedAbove === void 0 ? void 0 :
|
|
74
|
+
separatorAbove: e.skippedAbove === void 0 ? void 0 : te(e.skippedAbove),
|
|
75
75
|
// A removed line has no number in the after-text, so it keeps the one it had before.
|
|
76
76
|
lineNumber: o ? e.afterNumber ?? e.beforeNumber : void 0
|
|
77
77
|
};
|
|
78
|
-
},
|
|
78
|
+
}, ke = ({
|
|
79
79
|
code: e,
|
|
80
80
|
json: o,
|
|
81
81
|
showLineNumbers: r = !0,
|
|
82
82
|
className: t = "",
|
|
83
83
|
style: k = {},
|
|
84
|
-
height:
|
|
85
|
-
enableCopy:
|
|
84
|
+
height: m,
|
|
85
|
+
enableCopy: w = !0,
|
|
86
86
|
wrapLines: h = !1,
|
|
87
87
|
language: f,
|
|
88
|
-
collapsed:
|
|
88
|
+
collapsed: K = !1,
|
|
89
89
|
collapseLargerThan: a,
|
|
90
90
|
diff: d,
|
|
91
|
-
"aria-label":
|
|
92
|
-
"aria-labelledby":
|
|
91
|
+
"aria-label": p,
|
|
92
|
+
"aria-labelledby": y
|
|
93
93
|
}) => {
|
|
94
|
-
const n = a !== void 0 && Number.isInteger(a) && a >= 0 ? a : void 0;
|
|
95
|
-
a !== void 0 && n === void 0 &&
|
|
94
|
+
const R = j.useId(), n = a !== void 0 && Number.isInteger(a) && a >= 0 ? a : void 0;
|
|
95
|
+
a !== void 0 && n === void 0 && J(
|
|
96
96
|
`CodeBlock.collapseLargerThan:${a}`,
|
|
97
97
|
`CodeBlock's collapseLargerThan takes a whole count of 0 or more; ${a} is ignored.`
|
|
98
98
|
);
|
|
99
|
-
const l = d ?
|
|
100
|
-
`)) ?? "",
|
|
99
|
+
const l = d ? H(d.before, d.after, d.context) : null, g = (l == null ? void 0 : l.map((s) => s.text).join(`
|
|
100
|
+
`)) ?? "", _ = (() => {
|
|
101
101
|
if (l)
|
|
102
|
-
return
|
|
102
|
+
return g;
|
|
103
103
|
if (e)
|
|
104
104
|
return e;
|
|
105
105
|
if (o !== void 0)
|
|
@@ -108,36 +108,40 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
|
|
|
108
108
|
} catch {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
})(),
|
|
112
|
-
|
|
111
|
+
})(), F = w && _ !== void 0 && /* @__PURE__ */ c(
|
|
112
|
+
M,
|
|
113
113
|
{
|
|
114
|
-
text:
|
|
115
|
-
|
|
114
|
+
text: _,
|
|
115
|
+
...y ? {
|
|
116
|
+
id: R,
|
|
117
|
+
"aria-label": "Copy",
|
|
118
|
+
"aria-labelledby": `${R} ${y}`
|
|
119
|
+
} : { "aria-label": p ? `Copy ${p}` : "Copy" },
|
|
116
120
|
iconSize: 14,
|
|
117
|
-
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)] ${
|
|
121
|
+
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)] ${z}`,
|
|
118
122
|
style: { color: "var(--malachite-codeblock-line-number)" }
|
|
119
123
|
}
|
|
120
|
-
),
|
|
124
|
+
), b = {
|
|
121
125
|
role: "region",
|
|
122
|
-
"aria-label":
|
|
123
|
-
"aria-labelledby":
|
|
126
|
+
"aria-label": y ? p : p ?? "Code",
|
|
127
|
+
"aria-labelledby": y,
|
|
124
128
|
tabIndex: 0,
|
|
125
|
-
className: `box-border h-full overflow-auto ${
|
|
129
|
+
className: `box-border h-full overflow-auto ${W}`
|
|
126
130
|
};
|
|
127
131
|
if (o && !l)
|
|
128
|
-
return /* @__PURE__ */
|
|
132
|
+
return /* @__PURE__ */ A(
|
|
129
133
|
"div",
|
|
130
134
|
{
|
|
131
135
|
className: `relative border border-solid rounded-lg overflow-hidden ${t}`,
|
|
132
136
|
style: {
|
|
133
137
|
backgroundColor: "var(--malachite-codeblock-background)",
|
|
134
138
|
borderColor: "var(--malachite-codeblock-border)",
|
|
135
|
-
height:
|
|
139
|
+
height: m,
|
|
136
140
|
...k
|
|
137
141
|
},
|
|
138
142
|
children: [
|
|
139
|
-
|
|
140
|
-
/* @__PURE__ */ c("div", { ...
|
|
143
|
+
F,
|
|
144
|
+
/* @__PURE__ */ c("div", { ...b, children: /* @__PURE__ */ A(
|
|
141
145
|
v,
|
|
142
146
|
{
|
|
143
147
|
value: o,
|
|
@@ -176,24 +180,24 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
|
|
|
176
180
|
"--w-rjv-type-undefined-color": "var(--malachite-codeblock-keyword)"
|
|
177
181
|
},
|
|
178
182
|
displayDataTypes: !1,
|
|
179
|
-
enableClipboard:
|
|
180
|
-
collapsed:
|
|
181
|
-
shouldExpandNodeInitially: n === void 0 ? void 0 :
|
|
183
|
+
enableClipboard: w,
|
|
184
|
+
collapsed: K,
|
|
185
|
+
shouldExpandNodeInitially: n === void 0 ? void 0 : Q(n),
|
|
182
186
|
displayObjectSize: !1,
|
|
183
187
|
children: [
|
|
184
|
-
/* @__PURE__ */ c(v.Null, { render:
|
|
185
|
-
/* @__PURE__ */ c(v.Undefined, { render:
|
|
186
|
-
/* @__PURE__ */ c(v.Nan, { render:
|
|
188
|
+
/* @__PURE__ */ c(v.Null, { render: I("null", "null") }),
|
|
189
|
+
/* @__PURE__ */ c(v.Undefined, { render: I("undefined", "undefined") }),
|
|
190
|
+
/* @__PURE__ */ c(v.Nan, { render: I("NaN", "nan") }),
|
|
187
191
|
/* @__PURE__ */ c(
|
|
188
192
|
v.Arrow,
|
|
189
193
|
{
|
|
190
|
-
render: n === void 0 ? void 0 :
|
|
194
|
+
render: n === void 0 ? void 0 : X(n)
|
|
191
195
|
}
|
|
192
196
|
),
|
|
193
197
|
/* @__PURE__ */ c(
|
|
194
198
|
v.Ellipsis,
|
|
195
199
|
{
|
|
196
|
-
render: n === void 0 ? void 0 :
|
|
200
|
+
render: n === void 0 ? void 0 : Y(n)
|
|
197
201
|
}
|
|
198
202
|
)
|
|
199
203
|
]
|
|
@@ -202,32 +206,32 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
|
|
|
202
206
|
]
|
|
203
207
|
}
|
|
204
208
|
);
|
|
205
|
-
const
|
|
206
|
-
const
|
|
209
|
+
const N = w && (!!e || !!l), C = (s, i) => {
|
|
210
|
+
const S = s.split(`
|
|
207
211
|
`);
|
|
208
212
|
return /* @__PURE__ */ c(
|
|
209
213
|
"div",
|
|
210
214
|
{
|
|
211
|
-
...
|
|
212
|
-
className: `${
|
|
213
|
-
style: { paddingRight:
|
|
214
|
-
children: /* @__PURE__ */ c("div", { style:
|
|
215
|
-
const
|
|
215
|
+
...b,
|
|
216
|
+
className: `${b.className} p-4 text-left`,
|
|
217
|
+
style: { paddingRight: N ? 44 : void 0 },
|
|
218
|
+
children: /* @__PURE__ */ c("div", { style: q(h), children: S.map((u, $) => {
|
|
219
|
+
const x = i == null ? void 0 : i($);
|
|
216
220
|
return /* @__PURE__ */ c(
|
|
217
|
-
|
|
221
|
+
P,
|
|
218
222
|
{
|
|
219
223
|
line: u,
|
|
220
|
-
lineNumber: (
|
|
224
|
+
lineNumber: (x == null ? void 0 : x.lineNumber) ?? (r ? $ + 1 : void 0),
|
|
221
225
|
wrap: h,
|
|
222
|
-
decoration:
|
|
226
|
+
decoration: x,
|
|
223
227
|
children: u
|
|
224
228
|
},
|
|
225
|
-
|
|
229
|
+
$
|
|
226
230
|
);
|
|
227
231
|
}) })
|
|
228
232
|
}
|
|
229
233
|
);
|
|
230
|
-
},
|
|
234
|
+
}, D = () => e ? C(e) : null, U = (s) => {
|
|
231
235
|
if (s.length === 0)
|
|
232
236
|
return /* @__PURE__ */ c(
|
|
233
237
|
"div",
|
|
@@ -237,51 +241,51 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
|
|
|
237
241
|
children: "No changes"
|
|
238
242
|
}
|
|
239
243
|
);
|
|
240
|
-
const i = (
|
|
241
|
-
const u = s[
|
|
242
|
-
return u ?
|
|
244
|
+
const i = (S) => {
|
|
245
|
+
const u = s[S];
|
|
246
|
+
return u ? ce(u, r, d == null ? void 0 : d.origin) : void 0;
|
|
243
247
|
};
|
|
244
|
-
return f ? /* @__PURE__ */ c(
|
|
245
|
-
|
|
248
|
+
return f ? /* @__PURE__ */ c(j.Suspense, { fallback: C(g, i), children: /* @__PURE__ */ c(
|
|
249
|
+
T,
|
|
246
250
|
{
|
|
247
|
-
code:
|
|
251
|
+
code: g,
|
|
248
252
|
language: f,
|
|
249
253
|
showLineNumbers: r,
|
|
250
254
|
wrapLines: h,
|
|
251
|
-
copyClearance:
|
|
255
|
+
copyClearance: N,
|
|
252
256
|
decorate: i,
|
|
253
|
-
viewportProps:
|
|
257
|
+
viewportProps: b
|
|
254
258
|
}
|
|
255
|
-
) }) :
|
|
256
|
-
},
|
|
257
|
-
|
|
259
|
+
) }) : C(g, i);
|
|
260
|
+
}, G = () => e ? f ? /* @__PURE__ */ c(j.Suspense, { fallback: D(), children: /* @__PURE__ */ c(
|
|
261
|
+
T,
|
|
258
262
|
{
|
|
259
263
|
code: e,
|
|
260
264
|
language: f,
|
|
261
265
|
showLineNumbers: r,
|
|
262
266
|
wrapLines: h,
|
|
263
|
-
copyClearance:
|
|
264
|
-
viewportProps:
|
|
267
|
+
copyClearance: N,
|
|
268
|
+
viewportProps: b
|
|
265
269
|
}
|
|
266
|
-
) }) :
|
|
267
|
-
return /* @__PURE__ */
|
|
270
|
+
) }) : D() : null;
|
|
271
|
+
return /* @__PURE__ */ A(
|
|
268
272
|
"div",
|
|
269
273
|
{
|
|
270
274
|
className: `relative border border-solid rounded-lg overflow-hidden ${t}`,
|
|
271
275
|
style: {
|
|
272
276
|
backgroundColor: "var(--malachite-codeblock-background)",
|
|
273
277
|
borderColor: "var(--malachite-codeblock-border)",
|
|
274
|
-
height:
|
|
278
|
+
height: m,
|
|
275
279
|
...k
|
|
276
280
|
},
|
|
277
281
|
children: [
|
|
278
|
-
|
|
279
|
-
l ?
|
|
282
|
+
F,
|
|
283
|
+
l ? U(l) : G()
|
|
280
284
|
]
|
|
281
285
|
}
|
|
282
286
|
);
|
|
283
287
|
};
|
|
284
288
|
export {
|
|
285
|
-
|
|
289
|
+
ke as default
|
|
286
290
|
};
|
|
287
291
|
//# sourceMappingURL=CodeBlock.js.map
|