@frontmcp/ui 0.12.2 → 1.0.0-beta.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/README.md +279 -72
- package/bridge/adapters/claude.adapter.d.ts.map +1 -1
- package/bridge/adapters/gemini.adapter.d.ts.map +1 -1
- package/bridge/index.js +2 -36
- package/components/Alert/Alert.d.ts +11 -0
- package/components/Alert/Alert.d.ts.map +1 -0
- package/components/Alert/index.d.ts +4 -0
- package/components/Alert/index.d.ts.map +1 -0
- package/components/Alert/index.js +61 -0
- package/components/Avatar/Avatar.d.ts +10 -0
- package/components/Avatar/Avatar.d.ts.map +1 -0
- package/components/Avatar/index.d.ts +4 -0
- package/components/Avatar/index.d.ts.map +1 -0
- package/components/Avatar/index.js +43 -0
- package/components/Badge/Badge.d.ts +13 -0
- package/components/Badge/Badge.d.ts.map +1 -0
- package/components/Badge/index.d.ts +4 -0
- package/components/Badge/index.d.ts.map +1 -0
- package/{render → components/Badge}/index.js +54 -42
- package/components/Button/Button.d.ts +16 -0
- package/components/Button/Button.d.ts.map +1 -0
- package/components/Button/index.d.ts +4 -0
- package/components/Button/index.d.ts.map +1 -0
- package/components/Button/index.js +91 -0
- package/components/Card/Card.d.ts +25 -0
- package/components/Card/Card.d.ts.map +1 -0
- package/components/Card/index.d.ts +4 -0
- package/components/Card/index.d.ts.map +1 -0
- package/components/Card/index.js +110 -0
- package/components/List/List.d.ts +15 -0
- package/components/List/List.d.ts.map +1 -0
- package/components/List/index.d.ts +4 -0
- package/components/List/index.d.ts.map +1 -0
- package/components/List/index.js +58 -0
- package/components/Loader/Loader.d.ts +28 -0
- package/components/Loader/Loader.d.ts.map +1 -0
- package/components/Loader/LoaderContext.d.ts +20 -0
- package/components/Loader/LoaderContext.d.ts.map +1 -0
- package/components/Loader/index.d.ts +6 -0
- package/components/Loader/index.d.ts.map +1 -0
- package/components/Loader/index.js +174 -0
- package/components/Modal/Modal.d.ts +22 -0
- package/components/Modal/Modal.d.ts.map +1 -0
- package/components/Modal/index.d.ts +4 -0
- package/components/Modal/index.d.ts.map +1 -0
- package/components/Modal/index.js +80 -0
- package/components/Select/Select.d.ts +21 -0
- package/components/Select/Select.d.ts.map +1 -0
- package/components/Select/index.d.ts +4 -0
- package/components/Select/index.d.ts.map +1 -0
- package/components/Select/index.js +78 -0
- package/components/Table/Table.d.ts +15 -0
- package/components/Table/Table.d.ts.map +1 -0
- package/components/Table/index.d.ts +4 -0
- package/components/Table/index.d.ts.map +1 -0
- package/components/Table/index.js +70 -0
- package/components/TextField/TextField.d.ts +19 -0
- package/components/TextField/TextField.d.ts.map +1 -0
- package/components/TextField/index.d.ts +4 -0
- package/components/TextField/index.d.ts.map +1 -0
- package/components/TextField/index.js +77 -0
- package/components/index.d.ts +22 -28
- package/components/index.d.ts.map +1 -1
- package/components/index.js +523 -2521
- package/esm/bridge/index.mjs +2 -6
- package/esm/components/Alert/index.mjs +28 -0
- package/esm/components/Avatar/index.mjs +10 -0
- package/esm/components/Badge/index.mjs +56 -0
- package/esm/components/Button/index.mjs +58 -0
- package/esm/components/Card/index.mjs +77 -0
- package/esm/components/List/index.mjs +25 -0
- package/esm/components/Loader/index.mjs +141 -0
- package/esm/components/Modal/index.mjs +47 -0
- package/esm/components/Select/index.mjs +45 -0
- package/esm/components/Table/index.mjs +37 -0
- package/esm/components/TextField/index.mjs +44 -0
- package/esm/components/index.mjs +513 -2415
- package/esm/index.mjs +62 -4652
- package/esm/package.json +372 -16
- package/esm/react/index.mjs +2 -285
- package/esm/renderer/charts/index.mjs +336 -0
- package/esm/renderer/common/index.mjs +135 -0
- package/esm/renderer/csv/index.mjs +193 -0
- package/esm/renderer/flow/index.mjs +259 -0
- package/esm/renderer/html/index.mjs +99 -0
- package/esm/renderer/image/index.mjs +125 -0
- package/esm/renderer/index.mjs +2173 -0
- package/esm/renderer/maps/index.mjs +217 -0
- package/esm/renderer/math/index.mjs +229 -0
- package/esm/renderer/mdx/index.mjs +261 -0
- package/esm/renderer/media/index.mjs +235 -0
- package/esm/renderer/mermaid/index.mjs +220 -0
- package/esm/renderer/pdf/index.mjs +229 -0
- package/esm/renderer/react/index.mjs +230 -0
- package/esm/runtime/index.mjs +194 -0
- package/esm/theme/index.mjs +93 -0
- package/index.d.ts +10 -18
- package/index.d.ts.map +1 -1
- package/index.js +63 -4806
- package/package.json +372 -16
- package/react/index.d.ts +8 -54
- package/react/index.d.ts.map +1 -1
- package/react/index.js +2 -295
- package/renderer/auto-detect.d.ts +39 -0
- package/renderer/auto-detect.d.ts.map +1 -0
- package/renderer/charts/index.d.ts +22 -0
- package/renderer/charts/index.d.ts.map +1 -0
- package/renderer/charts/index.js +367 -0
- package/renderer/common/index.d.ts +5 -0
- package/renderer/common/index.d.ts.map +1 -0
- package/renderer/common/index.js +158 -0
- package/renderer/common/inject-stylesheet.d.ts +9 -0
- package/renderer/common/inject-stylesheet.d.ts.map +1 -0
- package/renderer/common/lazy-import.d.ts +85 -0
- package/renderer/common/lazy-import.d.ts.map +1 -0
- package/renderer/common/use-lazy-module.d.ts +13 -0
- package/renderer/common/use-lazy-module.d.ts.map +1 -0
- package/renderer/common/use-renderer-theme.d.ts +35 -0
- package/renderer/common/use-renderer-theme.d.ts.map +1 -0
- package/renderer/csv/index.d.ts +12 -0
- package/renderer/csv/index.d.ts.map +1 -0
- package/renderer/csv/index.js +224 -0
- package/renderer/flow/index.d.ts +40 -0
- package/renderer/flow/index.d.ts.map +1 -0
- package/renderer/flow/index.js +290 -0
- package/renderer/html/index.d.ts +12 -0
- package/renderer/html/index.d.ts.map +1 -0
- package/renderer/html/index.js +130 -0
- package/renderer/image/index.d.ts +11 -0
- package/renderer/image/index.d.ts.map +1 -0
- package/renderer/image/index.js +156 -0
- package/renderer/index.d.ts +32 -0
- package/renderer/index.d.ts.map +1 -0
- package/renderer/index.js +2206 -0
- package/renderer/maps/index.d.ts +27 -0
- package/renderer/maps/index.d.ts.map +1 -0
- package/renderer/maps/index.js +248 -0
- package/renderer/math/index.d.ts +11 -0
- package/renderer/math/index.d.ts.map +1 -0
- package/renderer/math/index.js +260 -0
- package/renderer/mdx/index.d.ts +10 -0
- package/renderer/mdx/index.d.ts.map +1 -0
- package/renderer/mdx/index.js +292 -0
- package/renderer/media/index.d.ts +20 -0
- package/renderer/media/index.d.ts.map +1 -0
- package/renderer/media/index.js +266 -0
- package/renderer/mermaid/index.d.ts +11 -0
- package/renderer/mermaid/index.d.ts.map +1 -0
- package/renderer/mermaid/index.js +251 -0
- package/renderer/pdf/index.d.ts +10 -0
- package/renderer/pdf/index.d.ts.map +1 -0
- package/renderer/pdf/index.js +260 -0
- package/renderer/react/index.d.ts +45 -0
- package/renderer/react/index.d.ts.map +1 -0
- package/renderer/react/index.js +261 -0
- package/renderer/types.d.ts +24 -0
- package/renderer/types.d.ts.map +1 -0
- package/runtime/babel-runtime.d.ts +70 -0
- package/runtime/babel-runtime.d.ts.map +1 -0
- package/runtime/content-detector.d.ts +43 -0
- package/runtime/content-detector.d.ts.map +1 -0
- package/runtime/index.d.ts +10 -0
- package/runtime/index.d.ts.map +1 -0
- package/runtime/index.js +217 -0
- package/theme/FrontMcpThemeProvider.d.ts +4 -0
- package/theme/FrontMcpThemeProvider.d.ts.map +1 -0
- package/theme/create-theme.d.ts +9 -0
- package/theme/create-theme.d.ts.map +1 -0
- package/theme/index.d.ts +5 -0
- package/theme/index.d.ts.map +1 -0
- package/theme/index.js +126 -0
- package/theme/types.d.ts +28 -0
- package/theme/types.d.ts.map +1 -0
- package/theme/use-theme.d.ts +3 -0
- package/theme/use-theme.d.ts.map +1 -0
- package/bundler/browser-components.d.ts +0 -42
- package/bundler/browser-components.d.ts.map +0 -1
- package/bundler/bundler.d.ts +0 -282
- package/bundler/bundler.d.ts.map +0 -1
- package/bundler/index.d.ts +0 -43
- package/bundler/index.d.ts.map +0 -1
- package/bundler/index.js +0 -3168
- package/bundler/types.d.ts +0 -883
- package/bundler/types.d.ts.map +0 -1
- package/components/alert.d.ts +0 -83
- package/components/alert.d.ts.map +0 -1
- package/components/alert.schema.d.ts +0 -98
- package/components/alert.schema.d.ts.map +0 -1
- package/components/avatar.d.ts +0 -77
- package/components/avatar.d.ts.map +0 -1
- package/components/avatar.schema.d.ts +0 -170
- package/components/avatar.schema.d.ts.map +0 -1
- package/components/badge.d.ts +0 -78
- package/components/badge.d.ts.map +0 -1
- package/components/badge.schema.d.ts +0 -91
- package/components/badge.schema.d.ts.map +0 -1
- package/components/button.d.ts +0 -100
- package/components/button.d.ts.map +0 -1
- package/components/button.schema.d.ts +0 -120
- package/components/button.schema.d.ts.map +0 -1
- package/components/card.d.ts +0 -76
- package/components/card.d.ts.map +0 -1
- package/components/card.schema.d.ts +0 -93
- package/components/card.schema.d.ts.map +0 -1
- package/components/form.d.ts +0 -227
- package/components/form.d.ts.map +0 -1
- package/components/form.schema.d.ts +0 -365
- package/components/form.schema.d.ts.map +0 -1
- package/components/list.d.ts +0 -121
- package/components/list.d.ts.map +0 -1
- package/components/list.schema.d.ts +0 -129
- package/components/list.schema.d.ts.map +0 -1
- package/components/modal.d.ts +0 -100
- package/components/modal.d.ts.map +0 -1
- package/components/modal.schema.d.ts +0 -151
- package/components/modal.schema.d.ts.map +0 -1
- package/components/table.d.ts +0 -91
- package/components/table.d.ts.map +0 -1
- package/components/table.schema.d.ts +0 -123
- package/components/table.schema.d.ts.map +0 -1
- package/esm/bundler/index.mjs +0 -3136
- package/esm/layouts/index.mjs +0 -409
- package/esm/render/index.mjs +0 -45
- package/esm/renderers/index.mjs +0 -621
- package/esm/universal/index.mjs +0 -1946
- package/esm/web-components/index.mjs +0 -2023
- package/layouts/base.d.ts +0 -86
- package/layouts/base.d.ts.map +0 -1
- package/layouts/index.d.ts +0 -8
- package/layouts/index.d.ts.map +0 -1
- package/layouts/index.js +0 -437
- package/layouts/presets.d.ts +0 -134
- package/layouts/presets.d.ts.map +0 -1
- package/react/Alert.d.ts +0 -101
- package/react/Alert.d.ts.map +0 -1
- package/react/Badge.d.ts +0 -100
- package/react/Badge.d.ts.map +0 -1
- package/react/Button.d.ts +0 -108
- package/react/Button.d.ts.map +0 -1
- package/react/Card.d.ts +0 -103
- package/react/Card.d.ts.map +0 -1
- package/react/types.d.ts +0 -105
- package/react/types.d.ts.map +0 -1
- package/render/index.d.ts +0 -8
- package/render/index.d.ts.map +0 -1
- package/render/prerender.d.ts +0 -57
- package/render/prerender.d.ts.map +0 -1
- package/renderers/index.d.ts +0 -26
- package/renderers/index.d.ts.map +0 -1
- package/renderers/index.js +0 -666
- package/renderers/mdx.renderer.d.ts +0 -99
- package/renderers/mdx.renderer.d.ts.map +0 -1
- package/renderers/react.adapter.d.ts +0 -70
- package/renderers/react.adapter.d.ts.map +0 -1
- package/renderers/react.renderer.d.ts +0 -105
- package/renderers/react.renderer.d.ts.map +0 -1
- package/renderers/transpiler.d.ts +0 -49
- package/renderers/transpiler.d.ts.map +0 -1
- package/universal/UniversalApp.d.ts +0 -108
- package/universal/UniversalApp.d.ts.map +0 -1
- package/universal/cached-runtime.d.ts +0 -139
- package/universal/cached-runtime.d.ts.map +0 -1
- package/universal/context.d.ts +0 -122
- package/universal/context.d.ts.map +0 -1
- package/universal/index.d.ts +0 -57
- package/universal/index.d.ts.map +0 -1
- package/universal/index.js +0 -2032
- package/universal/renderers/html.renderer.d.ts +0 -36
- package/universal/renderers/html.renderer.d.ts.map +0 -1
- package/universal/renderers/index.d.ts +0 -112
- package/universal/renderers/index.d.ts.map +0 -1
- package/universal/renderers/markdown.renderer.d.ts +0 -33
- package/universal/renderers/markdown.renderer.d.ts.map +0 -1
- package/universal/renderers/mdx.renderer.d.ts +0 -38
- package/universal/renderers/mdx.renderer.d.ts.map +0 -1
- package/universal/renderers/react.renderer.d.ts +0 -46
- package/universal/renderers/react.renderer.d.ts.map +0 -1
- package/universal/runtime-builder.d.ts +0 -33
- package/universal/runtime-builder.d.ts.map +0 -1
- package/universal/store.d.ts +0 -135
- package/universal/store.d.ts.map +0 -1
- package/universal/types.d.ts +0 -199
- package/universal/types.d.ts.map +0 -1
- package/web-components/core/attribute-parser.d.ts +0 -82
- package/web-components/core/attribute-parser.d.ts.map +0 -1
- package/web-components/core/base-element.d.ts +0 -197
- package/web-components/core/base-element.d.ts.map +0 -1
- package/web-components/core/index.d.ts +0 -9
- package/web-components/core/index.d.ts.map +0 -1
- package/web-components/elements/fmcp-alert.d.ts +0 -46
- package/web-components/elements/fmcp-alert.d.ts.map +0 -1
- package/web-components/elements/fmcp-badge.d.ts +0 -47
- package/web-components/elements/fmcp-badge.d.ts.map +0 -1
- package/web-components/elements/fmcp-button.d.ts +0 -117
- package/web-components/elements/fmcp-button.d.ts.map +0 -1
- package/web-components/elements/fmcp-card.d.ts +0 -53
- package/web-components/elements/fmcp-card.d.ts.map +0 -1
- package/web-components/elements/fmcp-input.d.ts +0 -96
- package/web-components/elements/fmcp-input.d.ts.map +0 -1
- package/web-components/elements/fmcp-select.d.ts +0 -100
- package/web-components/elements/fmcp-select.d.ts.map +0 -1
- package/web-components/elements/index.d.ts +0 -13
- package/web-components/elements/index.d.ts.map +0 -1
- package/web-components/index.d.ts +0 -49
- package/web-components/index.d.ts.map +0 -1
- package/web-components/index.js +0 -2058
- package/web-components/register.d.ts +0 -57
- package/web-components/register.d.ts.map +0 -1
- package/web-components/types.d.ts +0 -122
- package/web-components/types.d.ts.map +0 -1
package/esm/react/index.mjs
CHANGED
|
@@ -1,274 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// libs/ui/src/react/Card.tsx
|
|
9
|
-
import {
|
|
10
|
-
getCardVariantClasses,
|
|
11
|
-
getCardSizeClasses,
|
|
12
|
-
cn
|
|
13
|
-
} from "@frontmcp/uipack/styles";
|
|
14
|
-
|
|
15
|
-
// libs/ui/src/render/prerender.ts
|
|
16
|
-
async function renderToString(element) {
|
|
17
|
-
const { prerender } = await import("react-dom/static");
|
|
18
|
-
const { prelude } = await prerender(element);
|
|
19
|
-
const reader = prelude.getReader();
|
|
20
|
-
const chunks = [];
|
|
21
|
-
while (true) {
|
|
22
|
-
const { done, value } = await reader.read();
|
|
23
|
-
if (done) break;
|
|
24
|
-
if (value) chunks.push(value);
|
|
25
|
-
}
|
|
26
|
-
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
27
|
-
const combined = new Uint8Array(totalLength);
|
|
28
|
-
let offset = 0;
|
|
29
|
-
for (const chunk of chunks) {
|
|
30
|
-
combined.set(chunk, offset);
|
|
31
|
-
offset += chunk.length;
|
|
32
|
-
}
|
|
33
|
-
return new TextDecoder().decode(combined);
|
|
34
|
-
}
|
|
35
|
-
function renderToStringSync(element) {
|
|
36
|
-
const ReactDOMServer = __require("react-dom/server");
|
|
37
|
-
return ReactDOMServer.renderToStaticMarkup(element);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// libs/ui/src/react/Card.tsx
|
|
41
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
42
|
-
function Card({
|
|
43
|
-
title,
|
|
44
|
-
subtitle,
|
|
45
|
-
headerActions,
|
|
46
|
-
footer,
|
|
47
|
-
variant = "default",
|
|
48
|
-
size = "md",
|
|
49
|
-
className,
|
|
50
|
-
id,
|
|
51
|
-
clickable,
|
|
52
|
-
href,
|
|
53
|
-
children
|
|
54
|
-
}) {
|
|
55
|
-
const variantClasses = getCardVariantClasses(variant);
|
|
56
|
-
const sizeClasses = getCardSizeClasses(size);
|
|
57
|
-
const clickableClasses = clickable ? "cursor-pointer hover:shadow-md transition-shadow" : "";
|
|
58
|
-
const allClasses = cn(variantClasses, sizeClasses, clickableClasses, className);
|
|
59
|
-
const hasHeader = title || subtitle || headerActions;
|
|
60
|
-
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
61
|
-
hasHeader && /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between mb-4", children: [
|
|
62
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
63
|
-
title && /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-text-primary", children: title }),
|
|
64
|
-
subtitle && /* @__PURE__ */ jsx("p", { className: "text-sm text-text-secondary mt-1", children: subtitle })
|
|
65
|
-
] }),
|
|
66
|
-
headerActions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: headerActions })
|
|
67
|
-
] }),
|
|
68
|
-
children,
|
|
69
|
-
footer && /* @__PURE__ */ jsx("div", { className: "mt-4 pt-4 border-t border-divider", children: footer })
|
|
70
|
-
] });
|
|
71
|
-
if (href) {
|
|
72
|
-
return /* @__PURE__ */ jsx("a", { href, className: allClasses, id, children: content });
|
|
73
|
-
}
|
|
74
|
-
return /* @__PURE__ */ jsx("div", { className: allClasses, id, children: content });
|
|
75
|
-
}
|
|
76
|
-
async function renderCard(props) {
|
|
77
|
-
const { children, headerActions, footer, ...rest } = props;
|
|
78
|
-
const element = /* @__PURE__ */ jsx(
|
|
79
|
-
Card,
|
|
80
|
-
{
|
|
81
|
-
...rest,
|
|
82
|
-
headerActions: headerActions ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: headerActions } }) : void 0,
|
|
83
|
-
footer: footer ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: footer } }) : void 0,
|
|
84
|
-
children: children ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: children } }) : void 0
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
return renderToString(element);
|
|
88
|
-
}
|
|
89
|
-
function renderCardSync(props) {
|
|
90
|
-
const { children, headerActions, footer, ...rest } = props;
|
|
91
|
-
const element = /* @__PURE__ */ jsx(
|
|
92
|
-
Card,
|
|
93
|
-
{
|
|
94
|
-
...rest,
|
|
95
|
-
headerActions: headerActions ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: headerActions } }) : void 0,
|
|
96
|
-
footer: footer ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: footer } }) : void 0,
|
|
97
|
-
children: children ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: children } }) : void 0
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
return renderToStringSync(element);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// libs/ui/src/react/Badge.tsx
|
|
104
|
-
import {
|
|
105
|
-
getBadgeVariantClasses,
|
|
106
|
-
getBadgeSizeClasses,
|
|
107
|
-
getBadgeDotSizeClasses,
|
|
108
|
-
getBadgeDotVariantClasses,
|
|
109
|
-
cn as cn2
|
|
110
|
-
} from "@frontmcp/uipack/styles";
|
|
111
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
112
|
-
function Badge({
|
|
113
|
-
variant = "default",
|
|
114
|
-
size = "md",
|
|
115
|
-
pill = false,
|
|
116
|
-
icon,
|
|
117
|
-
dot = false,
|
|
118
|
-
className,
|
|
119
|
-
removable = false,
|
|
120
|
-
onRemove,
|
|
121
|
-
children
|
|
122
|
-
}) {
|
|
123
|
-
if (dot) {
|
|
124
|
-
const dotClasses = cn2(
|
|
125
|
-
"inline-block rounded-full",
|
|
126
|
-
getBadgeDotSizeClasses(size),
|
|
127
|
-
getBadgeDotVariantClasses(variant),
|
|
128
|
-
className
|
|
129
|
-
);
|
|
130
|
-
const label = typeof children === "string" ? children : void 0;
|
|
131
|
-
return /* @__PURE__ */ jsx2("span", { className: dotClasses, "aria-label": label, title: label });
|
|
132
|
-
}
|
|
133
|
-
const variantClasses = getBadgeVariantClasses(variant);
|
|
134
|
-
const sizeClasses = getBadgeSizeClasses(size);
|
|
135
|
-
const baseClasses = cn2(
|
|
136
|
-
"inline-flex items-center font-medium",
|
|
137
|
-
pill ? "rounded-full" : "rounded-md",
|
|
138
|
-
variantClasses,
|
|
139
|
-
sizeClasses,
|
|
140
|
-
className
|
|
141
|
-
);
|
|
142
|
-
return /* @__PURE__ */ jsxs2("span", { className: baseClasses, children: [
|
|
143
|
-
icon && /* @__PURE__ */ jsx2("span", { className: "mr-1", children: icon }),
|
|
144
|
-
children,
|
|
145
|
-
removable && /* @__PURE__ */ jsx2(
|
|
146
|
-
"button",
|
|
147
|
-
{
|
|
148
|
-
type: "button",
|
|
149
|
-
className: "ml-1.5 -mr-1 hover:opacity-70 transition-opacity",
|
|
150
|
-
"aria-label": "Remove",
|
|
151
|
-
onClick: onRemove,
|
|
152
|
-
children: /* @__PURE__ */ jsx2("svg", { className: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx2("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M6 18L18 6M6 6l12 12" }) })
|
|
153
|
-
}
|
|
154
|
-
)
|
|
155
|
-
] });
|
|
156
|
-
}
|
|
157
|
-
async function renderBadge(props) {
|
|
158
|
-
const { children, icon, ...rest } = props;
|
|
159
|
-
const element = /* @__PURE__ */ jsx2(Badge, { ...rest, icon: icon ? /* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: icon } }) : void 0, children });
|
|
160
|
-
return renderToString(element);
|
|
161
|
-
}
|
|
162
|
-
function renderBadgeSync(props) {
|
|
163
|
-
const { children, icon, ...rest } = props;
|
|
164
|
-
const element = /* @__PURE__ */ jsx2(Badge, { ...rest, icon: icon ? /* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: icon } }) : void 0, children });
|
|
165
|
-
return renderToStringSync(element);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// libs/ui/src/react/Button.tsx
|
|
169
|
-
import {
|
|
170
|
-
getButtonVariantClasses,
|
|
171
|
-
getButtonSizeClasses,
|
|
172
|
-
BUTTON_BASE_CLASSES,
|
|
173
|
-
LOADING_SPINNER,
|
|
174
|
-
cn as cn3
|
|
175
|
-
} from "@frontmcp/uipack/styles";
|
|
176
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
177
|
-
function Button({
|
|
178
|
-
variant = "primary",
|
|
179
|
-
size = "md",
|
|
180
|
-
disabled = false,
|
|
181
|
-
loading = false,
|
|
182
|
-
fullWidth = false,
|
|
183
|
-
iconPosition = "left",
|
|
184
|
-
icon,
|
|
185
|
-
iconOnly = false,
|
|
186
|
-
type = "button",
|
|
187
|
-
className,
|
|
188
|
-
onClick,
|
|
189
|
-
children
|
|
190
|
-
}) {
|
|
191
|
-
const variantClasses = getButtonVariantClasses(variant);
|
|
192
|
-
const sizeClasses = getButtonSizeClasses(size, iconOnly);
|
|
193
|
-
const disabledClasses = disabled || loading ? "opacity-50 cursor-not-allowed" : "";
|
|
194
|
-
const widthClasses = fullWidth ? "w-full" : "";
|
|
195
|
-
const allClasses = cn3(BUTTON_BASE_CLASSES, variantClasses, sizeClasses, disabledClasses, widthClasses, className);
|
|
196
|
-
const iconElement = icon && /* @__PURE__ */ jsx3("span", { className: iconPosition === "left" ? "mr-2" : "ml-2", children: icon });
|
|
197
|
-
return /* @__PURE__ */ jsxs3("button", { type, className: allClasses, disabled: disabled || loading, onClick, children: [
|
|
198
|
-
loading && /* @__PURE__ */ jsx3("span", { className: "mr-2", dangerouslySetInnerHTML: { __html: LOADING_SPINNER } }),
|
|
199
|
-
!loading && icon && iconPosition === "left" && iconElement,
|
|
200
|
-
!iconOnly && children,
|
|
201
|
-
!loading && icon && iconPosition === "right" && iconElement
|
|
202
|
-
] });
|
|
203
|
-
}
|
|
204
|
-
async function renderButton(props) {
|
|
205
|
-
const { children, icon, ...rest } = props;
|
|
206
|
-
const element = /* @__PURE__ */ jsx3(Button, { ...rest, icon: icon ? /* @__PURE__ */ jsx3("span", { dangerouslySetInnerHTML: { __html: icon } }) : void 0, children });
|
|
207
|
-
return renderToString(element);
|
|
208
|
-
}
|
|
209
|
-
function renderButtonSync(props) {
|
|
210
|
-
const { children, icon, ...rest } = props;
|
|
211
|
-
const element = /* @__PURE__ */ jsx3(Button, { ...rest, icon: icon ? /* @__PURE__ */ jsx3("span", { dangerouslySetInnerHTML: { __html: icon } }) : void 0, children });
|
|
212
|
-
return renderToStringSync(element);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// libs/ui/src/react/Alert.tsx
|
|
216
|
-
import {
|
|
217
|
-
getAlertVariantClasses,
|
|
218
|
-
ALERT_BASE_CLASSES,
|
|
219
|
-
ALERT_ICONS,
|
|
220
|
-
CLOSE_ICON,
|
|
221
|
-
cn as cn4
|
|
222
|
-
} from "@frontmcp/uipack/styles";
|
|
223
|
-
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
224
|
-
function Alert({
|
|
225
|
-
variant = "info",
|
|
226
|
-
title,
|
|
227
|
-
icon,
|
|
228
|
-
showIcon = true,
|
|
229
|
-
dismissible = false,
|
|
230
|
-
onDismiss,
|
|
231
|
-
className,
|
|
232
|
-
children
|
|
233
|
-
}) {
|
|
234
|
-
const variantStyles = getAlertVariantClasses(variant);
|
|
235
|
-
const allClasses = cn4(ALERT_BASE_CLASSES, variantStyles.container, className);
|
|
236
|
-
const iconContent = icon || (showIcon ? /* @__PURE__ */ jsx4(
|
|
237
|
-
"span",
|
|
238
|
-
{
|
|
239
|
-
className: cn4("flex-shrink-0", variantStyles.icon),
|
|
240
|
-
dangerouslySetInnerHTML: { __html: ALERT_ICONS[variant] }
|
|
241
|
-
}
|
|
242
|
-
) : null);
|
|
243
|
-
return /* @__PURE__ */ jsx4("div", { className: allClasses, role: "alert", children: /* @__PURE__ */ jsxs4("div", { className: "flex", children: [
|
|
244
|
-
iconContent && /* @__PURE__ */ jsx4("div", { className: "flex-shrink-0 mr-3", children: iconContent }),
|
|
245
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex-1", children: [
|
|
246
|
-
title && /* @__PURE__ */ jsx4("h4", { className: "font-semibold mb-1", children: title }),
|
|
247
|
-
/* @__PURE__ */ jsx4("div", { className: "text-sm", children })
|
|
248
|
-
] }),
|
|
249
|
-
dismissible && /* @__PURE__ */ jsx4(
|
|
250
|
-
"button",
|
|
251
|
-
{
|
|
252
|
-
type: "button",
|
|
253
|
-
className: "flex-shrink-0 ml-3 hover:opacity-70 transition-opacity",
|
|
254
|
-
"aria-label": "Dismiss",
|
|
255
|
-
onClick: onDismiss,
|
|
256
|
-
children: /* @__PURE__ */ jsx4("span", { dangerouslySetInnerHTML: { __html: CLOSE_ICON } })
|
|
257
|
-
}
|
|
258
|
-
)
|
|
259
|
-
] }) });
|
|
260
|
-
}
|
|
261
|
-
async function renderAlert(props) {
|
|
262
|
-
const { children, icon, ...rest } = props;
|
|
263
|
-
const element = /* @__PURE__ */ jsx4(Alert, { ...rest, icon: icon ? /* @__PURE__ */ jsx4("span", { dangerouslySetInnerHTML: { __html: icon } }) : void 0, children });
|
|
264
|
-
return renderToString(element);
|
|
265
|
-
}
|
|
266
|
-
function renderAlertSync(props) {
|
|
267
|
-
const { children, icon, ...rest } = props;
|
|
268
|
-
const element = /* @__PURE__ */ jsx4(Alert, { ...rest, icon: icon ? /* @__PURE__ */ jsx4("span", { dangerouslySetInnerHTML: { __html: icon } }) : void 0, children });
|
|
269
|
-
return renderToStringSync(element);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
1
|
// libs/ui/src/react/hooks/context.tsx
|
|
273
2
|
import { createContext, useContext, useEffect, useState, useMemo } from "react";
|
|
274
3
|
|
|
@@ -809,7 +538,7 @@ var FrontMcpBridge = class {
|
|
|
809
538
|
};
|
|
810
539
|
|
|
811
540
|
// libs/ui/src/react/hooks/context.tsx
|
|
812
|
-
import { jsx
|
|
541
|
+
import { jsx } from "react/jsx-runtime";
|
|
813
542
|
var McpBridgeContext = createContext(null);
|
|
814
543
|
function McpBridgeProvider({ children, config, onReady, onError }) {
|
|
815
544
|
const [bridge, setBridge] = useState(null);
|
|
@@ -855,7 +584,7 @@ function McpBridgeProvider({ children, config, onReady, onError }) {
|
|
|
855
584
|
}),
|
|
856
585
|
[bridge, loading, error]
|
|
857
586
|
);
|
|
858
|
-
return /* @__PURE__ */
|
|
587
|
+
return /* @__PURE__ */ jsx(McpBridgeContext.Provider, { value: contextValue, children });
|
|
859
588
|
}
|
|
860
589
|
var SSR_DEFAULT_CONTEXT = {
|
|
861
590
|
bridge: null,
|
|
@@ -1154,19 +883,7 @@ function useOpenLink() {
|
|
|
1154
883
|
);
|
|
1155
884
|
}
|
|
1156
885
|
export {
|
|
1157
|
-
Alert,
|
|
1158
|
-
Badge,
|
|
1159
|
-
Button,
|
|
1160
|
-
Card,
|
|
1161
886
|
McpBridgeProvider,
|
|
1162
|
-
renderAlert,
|
|
1163
|
-
renderAlertSync,
|
|
1164
|
-
renderBadge,
|
|
1165
|
-
renderBadgeSync,
|
|
1166
|
-
renderButton,
|
|
1167
|
-
renderButtonSync,
|
|
1168
|
-
renderCard,
|
|
1169
|
-
renderCardSync,
|
|
1170
887
|
useCallTool,
|
|
1171
888
|
useCapability,
|
|
1172
889
|
useDisplayMode,
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// libs/ui/src/renderer/charts/index.ts
|
|
2
|
+
import React, { useMemo as useMemo2 } from "react";
|
|
3
|
+
import Box from "@mui/material/Box";
|
|
4
|
+
import Alert from "@mui/material/Alert";
|
|
5
|
+
import Typography from "@mui/material/Typography";
|
|
6
|
+
import { styled } from "@mui/material/styles";
|
|
7
|
+
|
|
8
|
+
// libs/ui/src/renderer/common/lazy-import.ts
|
|
9
|
+
var ESM_SH_BASE = "https://esm.sh/";
|
|
10
|
+
function esmShUrl(pkg, options) {
|
|
11
|
+
let url = `${ESM_SH_BASE}${pkg}`;
|
|
12
|
+
if (options?.external?.length) {
|
|
13
|
+
url += `?external=${options.external.join(",")}`;
|
|
14
|
+
}
|
|
15
|
+
return url;
|
|
16
|
+
}
|
|
17
|
+
function runtimeImport(specifier) {
|
|
18
|
+
const dynamicImport = new Function("s", "return import(s)");
|
|
19
|
+
return dynamicImport(specifier);
|
|
20
|
+
}
|
|
21
|
+
async function runtimeImportWithFallback(bareSpecifier, fallbackUrl) {
|
|
22
|
+
try {
|
|
23
|
+
return await runtimeImport(bareSpecifier);
|
|
24
|
+
} catch {
|
|
25
|
+
return runtimeImport(fallbackUrl);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function createLazyImport(moduleId, importer) {
|
|
29
|
+
let state = { status: "idle" };
|
|
30
|
+
const doImport = importer ?? (async () => {
|
|
31
|
+
const mod = await runtimeImport(moduleId);
|
|
32
|
+
return mod["default"] ?? mod;
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
load() {
|
|
36
|
+
if (state.status === "loaded") return Promise.resolve(state.module);
|
|
37
|
+
if (state.status === "loading") return state.promise;
|
|
38
|
+
if (state.status === "error") {
|
|
39
|
+
state = { status: "idle" };
|
|
40
|
+
}
|
|
41
|
+
const promise = doImport().then(
|
|
42
|
+
(mod) => {
|
|
43
|
+
state = { status: "loaded", module: mod };
|
|
44
|
+
return mod;
|
|
45
|
+
},
|
|
46
|
+
(err) => {
|
|
47
|
+
const error = err instanceof Error ? err : new Error(`Failed to load module "${moduleId}": ${String(err)}`);
|
|
48
|
+
state = { status: "error", error };
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
state = { status: "loading", promise };
|
|
53
|
+
return promise;
|
|
54
|
+
},
|
|
55
|
+
get() {
|
|
56
|
+
return state.status === "loaded" ? state.module : void 0;
|
|
57
|
+
},
|
|
58
|
+
getState() {
|
|
59
|
+
return state;
|
|
60
|
+
},
|
|
61
|
+
reset() {
|
|
62
|
+
state = { status: "idle" };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// libs/ui/src/renderer/common/use-renderer-theme.ts
|
|
68
|
+
import { useMemo } from "react";
|
|
69
|
+
import { useTheme } from "@mui/material/styles";
|
|
70
|
+
function extractThemeValues(theme) {
|
|
71
|
+
const palette = theme.palette;
|
|
72
|
+
return {
|
|
73
|
+
mode: palette.mode,
|
|
74
|
+
primary: palette.primary.main,
|
|
75
|
+
secondary: palette.secondary.main,
|
|
76
|
+
error: palette.error.main,
|
|
77
|
+
warning: palette.warning.main,
|
|
78
|
+
success: palette.success.main,
|
|
79
|
+
info: palette.info.main,
|
|
80
|
+
background: palette.background.default,
|
|
81
|
+
paper: palette.background.paper,
|
|
82
|
+
textPrimary: palette.text.primary,
|
|
83
|
+
textSecondary: palette.text.secondary,
|
|
84
|
+
divider: palette.divider,
|
|
85
|
+
fontFamily: theme.typography.fontFamily ?? "sans-serif",
|
|
86
|
+
monoFontFamily: theme.typography["monoFontFamily"] ?? '"SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace',
|
|
87
|
+
fontSize: theme.typography.fontSize ?? 14,
|
|
88
|
+
borderRadius: typeof theme.shape.borderRadius === "number" ? theme.shape.borderRadius : 4,
|
|
89
|
+
seriesColors: [
|
|
90
|
+
palette.primary.main,
|
|
91
|
+
palette.secondary.main,
|
|
92
|
+
palette.error.main,
|
|
93
|
+
palette.warning.main,
|
|
94
|
+
palette.success.main,
|
|
95
|
+
palette.info.main
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function useRendererTheme() {
|
|
100
|
+
const theme = useTheme();
|
|
101
|
+
return useMemo(() => extractThemeValues(theme), [theme]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// libs/ui/src/renderer/common/use-lazy-module.ts
|
|
105
|
+
import { useState, useEffect } from "react";
|
|
106
|
+
function useLazyModule(lazy) {
|
|
107
|
+
const [, forceUpdate] = useState(0);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (lazy.getState().status === "loaded") {
|
|
110
|
+
forceUpdate((n) => n + 1);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
lazy.load().then(
|
|
114
|
+
() => forceUpdate((n) => n + 1),
|
|
115
|
+
() => forceUpdate((n) => n + 1)
|
|
116
|
+
);
|
|
117
|
+
}, [lazy]);
|
|
118
|
+
return lazy.get();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// libs/ui/src/renderer/charts/index.ts
|
|
122
|
+
var CHART_TYPE_RE = /"type"\s*:\s*"(?:bar|line|area|pie|scatter|radar|composed)"/;
|
|
123
|
+
function isChart(content) {
|
|
124
|
+
const trimmed = content.trim();
|
|
125
|
+
if (trimmed.charCodeAt(0) !== 123) return false;
|
|
126
|
+
return CHART_TYPE_RE.test(trimmed) && trimmed.includes('"data"');
|
|
127
|
+
}
|
|
128
|
+
var lazyRecharts = createLazyImport("recharts", async () => {
|
|
129
|
+
const mod = await runtimeImportWithFallback("recharts", esmShUrl("recharts@2", { external: ["react", "react-dom"] }));
|
|
130
|
+
return mod;
|
|
131
|
+
});
|
|
132
|
+
var ChartRoot = styled(Box, {
|
|
133
|
+
name: "FrontMcpChart",
|
|
134
|
+
slot: "Root"
|
|
135
|
+
})(({ theme }) => ({
|
|
136
|
+
width: "100%",
|
|
137
|
+
padding: theme.spacing(2)
|
|
138
|
+
}));
|
|
139
|
+
function ChartView({ config, className }) {
|
|
140
|
+
const themeValues = useRendererTheme();
|
|
141
|
+
const recharts = useLazyModule(lazyRecharts);
|
|
142
|
+
const colors = useMemo2(() => config.colors ?? themeValues.seriesColors, [config.colors, themeValues.seriesColors]);
|
|
143
|
+
if (!recharts) {
|
|
144
|
+
return React.createElement(Alert, { severity: "info" }, "Loading chart library...");
|
|
145
|
+
}
|
|
146
|
+
const { ResponsiveContainer, Tooltip, Legend, CartesianGrid, XAxis, YAxis } = recharts;
|
|
147
|
+
const height = config.height ?? 400;
|
|
148
|
+
const xKey = config.xKey ?? "name";
|
|
149
|
+
const yKeys = config.yKeys ?? Object.keys(config.data?.[0] ?? {}).filter((k) => k !== xKey);
|
|
150
|
+
const chartContent = renderChartType(
|
|
151
|
+
recharts,
|
|
152
|
+
config.type,
|
|
153
|
+
config.data,
|
|
154
|
+
xKey,
|
|
155
|
+
yKeys,
|
|
156
|
+
colors,
|
|
157
|
+
themeValues.borderRadius
|
|
158
|
+
);
|
|
159
|
+
return React.createElement(
|
|
160
|
+
ChartRoot,
|
|
161
|
+
{ className },
|
|
162
|
+
config.title && React.createElement(
|
|
163
|
+
Typography,
|
|
164
|
+
{ variant: "subtitle1", gutterBottom: true, fontWeight: 600, textAlign: "center" },
|
|
165
|
+
config.title
|
|
166
|
+
),
|
|
167
|
+
React.createElement(ResponsiveContainer, { width: "100%", height }, chartContent)
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function renderChartType(rc, type, data, xKey, yKeys, colors, borderRadius) {
|
|
171
|
+
const commonProps = { data };
|
|
172
|
+
const grid = React.createElement(rc.CartesianGrid, { strokeDasharray: "3 3", opacity: 0.3 });
|
|
173
|
+
const xAxis = React.createElement(rc.XAxis, { dataKey: xKey });
|
|
174
|
+
const yAxis = React.createElement(rc.YAxis);
|
|
175
|
+
const tooltip = React.createElement(rc.Tooltip, { contentStyle: { borderRadius } });
|
|
176
|
+
const legend = React.createElement(rc.Legend);
|
|
177
|
+
switch (type) {
|
|
178
|
+
case "bar":
|
|
179
|
+
return React.createElement(
|
|
180
|
+
rc.BarChart,
|
|
181
|
+
commonProps,
|
|
182
|
+
grid,
|
|
183
|
+
xAxis,
|
|
184
|
+
yAxis,
|
|
185
|
+
tooltip,
|
|
186
|
+
legend,
|
|
187
|
+
...yKeys.map(
|
|
188
|
+
(key, i) => React.createElement(rc.Bar, {
|
|
189
|
+
key,
|
|
190
|
+
dataKey: key,
|
|
191
|
+
fill: colors[i % colors.length],
|
|
192
|
+
radius: [borderRadius, borderRadius, 0, 0]
|
|
193
|
+
})
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
case "line":
|
|
197
|
+
return React.createElement(
|
|
198
|
+
rc.LineChart,
|
|
199
|
+
commonProps,
|
|
200
|
+
grid,
|
|
201
|
+
xAxis,
|
|
202
|
+
yAxis,
|
|
203
|
+
tooltip,
|
|
204
|
+
legend,
|
|
205
|
+
...yKeys.map(
|
|
206
|
+
(key, i) => React.createElement(rc.Line, {
|
|
207
|
+
key,
|
|
208
|
+
type: "monotone",
|
|
209
|
+
dataKey: key,
|
|
210
|
+
stroke: colors[i % colors.length],
|
|
211
|
+
strokeWidth: 2
|
|
212
|
+
})
|
|
213
|
+
)
|
|
214
|
+
);
|
|
215
|
+
case "area":
|
|
216
|
+
return React.createElement(
|
|
217
|
+
rc.AreaChart,
|
|
218
|
+
commonProps,
|
|
219
|
+
grid,
|
|
220
|
+
xAxis,
|
|
221
|
+
yAxis,
|
|
222
|
+
tooltip,
|
|
223
|
+
legend,
|
|
224
|
+
...yKeys.map(
|
|
225
|
+
(key, i) => React.createElement(rc.Area, {
|
|
226
|
+
key,
|
|
227
|
+
type: "monotone",
|
|
228
|
+
dataKey: key,
|
|
229
|
+
stroke: colors[i % colors.length],
|
|
230
|
+
fill: colors[i % colors.length],
|
|
231
|
+
fillOpacity: 0.3
|
|
232
|
+
})
|
|
233
|
+
)
|
|
234
|
+
);
|
|
235
|
+
case "pie":
|
|
236
|
+
return React.createElement(
|
|
237
|
+
rc.PieChart,
|
|
238
|
+
{},
|
|
239
|
+
tooltip,
|
|
240
|
+
legend,
|
|
241
|
+
React.createElement(
|
|
242
|
+
rc.Pie,
|
|
243
|
+
{ data, dataKey: yKeys[0] ?? "value", nameKey: xKey, cx: "50%", cy: "50%", outerRadius: "80%", label: true },
|
|
244
|
+
...data.map((_, i) => React.createElement(rc.Cell, { key: i, fill: colors[i % colors.length] }))
|
|
245
|
+
)
|
|
246
|
+
);
|
|
247
|
+
case "scatter":
|
|
248
|
+
return React.createElement(
|
|
249
|
+
rc.ScatterChart,
|
|
250
|
+
{},
|
|
251
|
+
grid,
|
|
252
|
+
xAxis,
|
|
253
|
+
yAxis,
|
|
254
|
+
tooltip,
|
|
255
|
+
legend,
|
|
256
|
+
...yKeys.map(
|
|
257
|
+
(key, i) => React.createElement(rc.Scatter, { key, name: key, dataKey: key, data, fill: colors[i % colors.length] })
|
|
258
|
+
)
|
|
259
|
+
);
|
|
260
|
+
case "radar":
|
|
261
|
+
return React.createElement(
|
|
262
|
+
rc.RadarChart,
|
|
263
|
+
{ cx: "50%", cy: "50%", outerRadius: "80%", data },
|
|
264
|
+
React.createElement(rc.PolarGrid),
|
|
265
|
+
React.createElement(rc.PolarAngleAxis, { dataKey: xKey }),
|
|
266
|
+
React.createElement(rc.PolarRadiusAxis),
|
|
267
|
+
tooltip,
|
|
268
|
+
legend,
|
|
269
|
+
...yKeys.map(
|
|
270
|
+
(key, i) => React.createElement(rc.Radar, {
|
|
271
|
+
key,
|
|
272
|
+
name: key,
|
|
273
|
+
dataKey: key,
|
|
274
|
+
stroke: colors[i % colors.length],
|
|
275
|
+
fill: colors[i % colors.length],
|
|
276
|
+
fillOpacity: 0.3
|
|
277
|
+
})
|
|
278
|
+
)
|
|
279
|
+
);
|
|
280
|
+
case "composed":
|
|
281
|
+
return React.createElement(
|
|
282
|
+
rc.ComposedChart,
|
|
283
|
+
commonProps,
|
|
284
|
+
grid,
|
|
285
|
+
xAxis,
|
|
286
|
+
yAxis,
|
|
287
|
+
tooltip,
|
|
288
|
+
legend,
|
|
289
|
+
...yKeys.map((key, i) => {
|
|
290
|
+
if (i % 2 === 0) {
|
|
291
|
+
return React.createElement(rc.Bar, {
|
|
292
|
+
key,
|
|
293
|
+
dataKey: key,
|
|
294
|
+
fill: colors[i % colors.length],
|
|
295
|
+
radius: [borderRadius, borderRadius, 0, 0]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return React.createElement(rc.Line, {
|
|
299
|
+
key,
|
|
300
|
+
type: "monotone",
|
|
301
|
+
dataKey: key,
|
|
302
|
+
stroke: colors[i % colors.length],
|
|
303
|
+
strokeWidth: 2
|
|
304
|
+
});
|
|
305
|
+
})
|
|
306
|
+
);
|
|
307
|
+
default:
|
|
308
|
+
return React.createElement(rc.BarChart, commonProps, grid, xAxis, yAxis, tooltip, legend);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
lazyRecharts.load().catch(() => {
|
|
312
|
+
});
|
|
313
|
+
var ChartsRenderer = class {
|
|
314
|
+
type = "chart";
|
|
315
|
+
priority = 80;
|
|
316
|
+
canHandle(content) {
|
|
317
|
+
return isChart(content);
|
|
318
|
+
}
|
|
319
|
+
render(content, options) {
|
|
320
|
+
try {
|
|
321
|
+
const config = JSON.parse(content);
|
|
322
|
+
return React.createElement(ChartView, {
|
|
323
|
+
config,
|
|
324
|
+
className: options?.className ?? "fmcp-chart-content"
|
|
325
|
+
});
|
|
326
|
+
} catch {
|
|
327
|
+
return React.createElement(Alert, { severity: "error" }, "Invalid chart JSON");
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
var chartsRenderer = new ChartsRenderer();
|
|
332
|
+
export {
|
|
333
|
+
ChartsRenderer,
|
|
334
|
+
chartsRenderer,
|
|
335
|
+
isChart
|
|
336
|
+
};
|