@donglegeyu/company-ui 1.2.46 → 1.2.48
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/cjs/ai-assistant/AiSessionEngine.d.ts +3 -0
- package/dist/cjs/ai-assistant/AiSessionEngine.js +13 -0
- package/dist/cjs/ai-assistant/MockAiTransport.d.ts +4 -1
- package/dist/cjs/ai-assistant/MockAiTransport.js +14 -2
- package/dist/cjs/ai-assistant/types.d.ts +12 -0
- package/dist/cjs/basic-components/CompanyChart/Chart.d.ts +20 -0
- package/dist/cjs/basic-components/CompanyChart/Chart.js +93 -0
- package/dist/cjs/basic-components/CompanyChart/index.d.ts +3 -0
- package/dist/cjs/basic-components/CompanyChart/index.js +27 -0
- package/dist/cjs/basic-components/CompanyChart/presets.d.ts +102 -0
- package/dist/cjs/basic-components/CompanyChart/presets.js +147 -0
- package/dist/cjs/basic-components/CompanyChart/theme.d.ts +9 -0
- package/dist/cjs/basic-components/CompanyChart/theme.js +45 -0
- package/dist/cjs/basic-components/CompanyChart/utils.d.ts +6 -0
- package/dist/cjs/basic-components/CompanyChart/utils.js +39 -0
- package/dist/cjs/basic-components/index.d.ts +2 -0
- package/dist/cjs/basic-components/index.js +5 -1
- package/dist/cjs/shared-components/CompanyAiAssistant/index.js +12 -1
- package/dist/cjs/shared-components/CompanyAiAssistant/index.scss +12 -0
- package/dist/cjs/sidebar-config.d.ts +2 -0
- package/dist/cjs/sidebar-config.js +23 -0
- package/dist/es/ai-assistant/AiSessionEngine.d.ts +3 -0
- package/dist/es/ai-assistant/AiSessionEngine.js +28 -1
- package/dist/es/ai-assistant/MockAiTransport.d.ts +4 -1
- package/dist/es/ai-assistant/MockAiTransport.js +11 -2
- package/dist/es/ai-assistant/types.d.ts +12 -0
- package/dist/es/basic-components/CompanyChart/Chart.d.ts +20 -0
- package/dist/es/basic-components/CompanyChart/Chart.js +91 -0
- package/dist/es/basic-components/CompanyChart/index.d.ts +3 -0
- package/dist/es/basic-components/CompanyChart/index.js +3 -0
- package/dist/es/basic-components/CompanyChart/presets.d.ts +102 -0
- package/dist/es/basic-components/CompanyChart/presets.js +229 -0
- package/dist/es/basic-components/CompanyChart/theme.d.ts +9 -0
- package/dist/es/basic-components/CompanyChart/theme.js +36 -0
- package/dist/es/basic-components/CompanyChart/utils.d.ts +6 -0
- package/dist/es/basic-components/CompanyChart/utils.js +26 -0
- package/dist/es/basic-components/index.d.ts +2 -0
- package/dist/es/basic-components/index.js +3 -1
- package/dist/es/shared-components/CompanyAiAssistant/index.js +15 -3
- package/dist/es/shared-components/CompanyAiAssistant/index.scss +12 -0
- package/dist/es/sidebar-config.d.ts +2 -0
- package/dist/es/sidebar-config.js +30 -0
- package/package.json +2 -1
|
@@ -7,6 +7,8 @@ export interface AiSessionEngineOptions {
|
|
|
7
7
|
getCapability: (tabKey: string) => AiPageCapability | undefined;
|
|
8
8
|
/** 版本栈深度,默认 10(超出丢弃最旧) */
|
|
9
9
|
maxSnapshots?: number;
|
|
10
|
+
/** 随请求发送的对话历史上限条数,默认 20(不含本轮消息) */
|
|
11
|
+
maxHistory?: number;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* 会话引擎:SSE 流式接收、消息历史、草稿版本栈。
|
|
@@ -21,6 +23,7 @@ export declare class AiSessionEngine {
|
|
|
21
23
|
private readonly transport;
|
|
22
24
|
private readonly getCapability;
|
|
23
25
|
private readonly maxSnapshots;
|
|
26
|
+
private readonly maxHistory;
|
|
24
27
|
constructor(options: AiSessionEngineOptions);
|
|
25
28
|
/** 订阅会话表变更(订阅时立即回调一次当前快照) */
|
|
26
29
|
subscribe(listener: (sessions: Record<string, AiSession>) => void): () => void;
|
|
@@ -53,6 +53,7 @@ var AiSessionEngine = class {
|
|
|
53
53
|
this.transport = options.transport;
|
|
54
54
|
this.getCapability = options.getCapability;
|
|
55
55
|
this.maxSnapshots = options.maxSnapshots ?? 10;
|
|
56
|
+
this.maxHistory = options.maxHistory ?? 20;
|
|
56
57
|
}
|
|
57
58
|
/** 订阅会话表变更(订阅时立即回调一次当前快照) */
|
|
58
59
|
subscribe(listener) {
|
|
@@ -92,6 +93,7 @@ var AiSessionEngine = class {
|
|
|
92
93
|
} catch {
|
|
93
94
|
context = void 0;
|
|
94
95
|
}
|
|
96
|
+
const history = session.messages.filter((item) => item.content.trim().length > 0).slice(-this.maxHistory).map((item) => ({ role: item.role, content: item.content }));
|
|
95
97
|
this.update(tabKey, {
|
|
96
98
|
messages: [
|
|
97
99
|
...session.messages,
|
|
@@ -115,6 +117,16 @@ var AiSessionEngine = class {
|
|
|
115
117
|
this.update(tabKey, { messages });
|
|
116
118
|
break;
|
|
117
119
|
}
|
|
120
|
+
case "thinking": {
|
|
121
|
+
if (isPlaceholder) {
|
|
122
|
+
messages[messages.length - 1] = {
|
|
123
|
+
...last,
|
|
124
|
+
reasoning: (last.reasoning ?? "") + event.text
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
this.update(tabKey, { messages });
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
118
130
|
case "action": {
|
|
119
131
|
if (isPlaceholder) {
|
|
120
132
|
messages[messages.length - 1] = {
|
|
@@ -178,6 +190,7 @@ ${reason}` : reason
|
|
|
178
190
|
// 无页面契约时为系统级交互,后端按 system 场景路由通用问答
|
|
179
191
|
scene: (capability == null ? void 0 : capability.scene) ?? "system",
|
|
180
192
|
context,
|
|
193
|
+
history,
|
|
181
194
|
message: trimmed,
|
|
182
195
|
onEvent: handleEvent
|
|
183
196
|
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { AiContext, AiStreamEvent, AiTransport } from "./types";
|
|
1
|
+
import type { AiContext, AiHistoryMessage, AiStreamEvent, AiTransport } from "./types";
|
|
2
2
|
export interface MockAiTransportOptions {
|
|
3
3
|
/** 自定义应答脚本:返回流式帧序列;缺省使用内置通用问答脚本 */
|
|
4
4
|
respond?: (params: {
|
|
5
5
|
scene: string;
|
|
6
6
|
context?: AiContext;
|
|
7
|
+
/** 近 N 轮对话历史(不含本轮 message) */
|
|
8
|
+
history?: AiHistoryMessage[];
|
|
7
9
|
message: string;
|
|
8
10
|
}) => AiStreamEvent[];
|
|
9
11
|
/** 每帧间隔(ms),默认 120 */
|
|
@@ -20,6 +22,7 @@ export declare class MockAiTransport implements AiTransport {
|
|
|
20
22
|
send(params: {
|
|
21
23
|
scene: string;
|
|
22
24
|
context?: AiContext;
|
|
25
|
+
history?: AiHistoryMessage[];
|
|
23
26
|
message: string;
|
|
24
27
|
onEvent: (event: AiStreamEvent) => void;
|
|
25
28
|
}): void;
|
|
@@ -23,9 +23,15 @@ __export(MockAiTransport_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(MockAiTransport_exports);
|
|
25
25
|
function defaultRespond(params) {
|
|
26
|
-
var _a;
|
|
26
|
+
var _a, _b;
|
|
27
27
|
const title = (_a = params.context) == null ? void 0 : _a.sceneTitle;
|
|
28
|
+
const historyCount = ((_b = params.history) == null ? void 0 : _b.length) ?? 0;
|
|
28
29
|
return [
|
|
30
|
+
{ type: "thinking", text: "先理解用户诉求,结合当前页面上下文判断意图。" },
|
|
31
|
+
{
|
|
32
|
+
type: "thinking",
|
|
33
|
+
text: historyCount > 0 ? `结合此前 ${historyCount} 轮对话历史与页面信息,组织本次回答。` : "本轮暂无对话历史,基于页面上下文组织回答。"
|
|
34
|
+
},
|
|
29
35
|
{ type: "delta", text: title ? `收到,当前为[${title}]。` : "收到。" },
|
|
30
36
|
{
|
|
31
37
|
type: "delta",
|
|
@@ -45,8 +51,14 @@ var MockAiTransport = class {
|
|
|
45
51
|
const events = ((_b = (_a = this.options).respond) == null ? void 0 : _b.call(_a, {
|
|
46
52
|
scene: params.scene,
|
|
47
53
|
context: params.context,
|
|
54
|
+
history: params.history,
|
|
55
|
+
message: params.message
|
|
56
|
+
})) ?? defaultRespond({
|
|
57
|
+
scene: params.scene,
|
|
58
|
+
context: params.context,
|
|
59
|
+
history: params.history,
|
|
48
60
|
message: params.message
|
|
49
|
-
})
|
|
61
|
+
});
|
|
50
62
|
let index = 0;
|
|
51
63
|
this.timer = setInterval(() => {
|
|
52
64
|
if (index >= events.length) {
|
|
@@ -95,6 +95,8 @@ export interface AiMessage {
|
|
|
95
95
|
role: AiMessageRole;
|
|
96
96
|
/** 文本内容(流式期间为已累积文本) */
|
|
97
97
|
content: string;
|
|
98
|
+
/** 思考过程文本(thinking 帧累积;仅 assistant 消息,缺省表示本轮无思考内容) */
|
|
99
|
+
reasoning?: string;
|
|
98
100
|
/** 携带的结构化建议(仅 assistant 消息) */
|
|
99
101
|
suggestion?: AiSuggestion;
|
|
100
102
|
/** 建议是否已确认回填(已确认后芯片置为已完成态) */
|
|
@@ -119,10 +121,18 @@ export interface AiSession {
|
|
|
119
121
|
/** 内置版本栈(栈深 maxSnapshots,超出丢弃最旧) */
|
|
120
122
|
snapshots: AiSnapshot[];
|
|
121
123
|
}
|
|
124
|
+
/** 对话历史条目(发送给后端的精简消息结构,不含建议卡片/工具调用等面板专有字段) */
|
|
125
|
+
export interface AiHistoryMessage {
|
|
126
|
+
role: AiMessageRole;
|
|
127
|
+
content: string;
|
|
128
|
+
}
|
|
122
129
|
/** 流式帧(P1 为 mock;P2 与 SSE 网关帧结构对齐) */
|
|
123
130
|
export type AiStreamEvent = {
|
|
124
131
|
type: "delta";
|
|
125
132
|
text: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "thinking";
|
|
135
|
+
text: string;
|
|
126
136
|
} | {
|
|
127
137
|
type: "action";
|
|
128
138
|
actionType: "backfill";
|
|
@@ -154,6 +164,8 @@ export interface AiTransport {
|
|
|
154
164
|
send(params: {
|
|
155
165
|
scene: string;
|
|
156
166
|
context?: AiContext;
|
|
167
|
+
/** 近 N 轮对话历史(不含本轮 message;引擎按 maxHistory 截断并过滤空内容) */
|
|
168
|
+
history?: AiHistoryMessage[];
|
|
157
169
|
message: string;
|
|
158
170
|
onEvent: (event: AiStreamEvent) => void;
|
|
159
171
|
}): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Chart } from "@antv/g2";
|
|
3
|
+
import type { G2Spec } from "@antv/g2";
|
|
4
|
+
export interface CompanyChartProps {
|
|
5
|
+
/** G2 5.x 图表描述配置(品牌主题已默认注入,可通过 options.theme 覆盖) */
|
|
6
|
+
options: G2Spec;
|
|
7
|
+
/** 容器高度(px),默认 320 */
|
|
8
|
+
height?: number;
|
|
9
|
+
/** 容器类名 */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** 容器样式 */
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
/** 图表渲染完成回调,返回 G2 Chart 实例(可用于事件绑定、实例方法调用) */
|
|
14
|
+
onReady?: (chart: Chart) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 图表 Chart:基于 AntV G2 5.x 的通用图表容器。
|
|
18
|
+
* 直接传入 G2 spec 即可渲染,品牌色板(category10/20)已默认注入。
|
|
19
|
+
*/
|
|
20
|
+
export declare const CompanyChart: React.ForwardRefExoticComponent<CompanyChartProps & React.RefAttributes<Chart>>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/basic-components/CompanyChart/Chart.tsx
|
|
30
|
+
var Chart_exports = {};
|
|
31
|
+
__export(Chart_exports, {
|
|
32
|
+
CompanyChart: () => CompanyChart
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Chart_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_g2 = require("@antv/g2");
|
|
37
|
+
var import_theme = require("./theme");
|
|
38
|
+
var import_utils = require("./utils");
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
var buildSpec = (options) => {
|
|
41
|
+
const { theme, ...rest } = options;
|
|
42
|
+
let mergedTheme = import_theme.companyChartTheme;
|
|
43
|
+
if (typeof theme === "string") {
|
|
44
|
+
mergedTheme = theme;
|
|
45
|
+
} else if (theme) {
|
|
46
|
+
mergedTheme = (0, import_utils.deepMerge)(import_theme.companyChartTheme, theme);
|
|
47
|
+
}
|
|
48
|
+
return { ...rest, theme: mergedTheme };
|
|
49
|
+
};
|
|
50
|
+
var CompanyChart = import_react.default.forwardRef((props, ref) => {
|
|
51
|
+
const { options, height = 320, className, style, onReady } = props;
|
|
52
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
53
|
+
const chartRef = (0, import_react.useRef)(null);
|
|
54
|
+
const optionsRef = (0, import_react.useRef)(options);
|
|
55
|
+
const onReadyRef = (0, import_react.useRef)(onReady);
|
|
56
|
+
onReadyRef.current = onReady;
|
|
57
|
+
(0, import_react.useEffect)(() => {
|
|
58
|
+
const container = containerRef.current;
|
|
59
|
+
if (!container)
|
|
60
|
+
return void 0;
|
|
61
|
+
const chart = new import_g2.Chart({ container, autoFit: true });
|
|
62
|
+
chartRef.current = chart;
|
|
63
|
+
return () => {
|
|
64
|
+
chart.destroy();
|
|
65
|
+
chartRef.current = null;
|
|
66
|
+
};
|
|
67
|
+
}, []);
|
|
68
|
+
(0, import_react.useEffect)(() => {
|
|
69
|
+
optionsRef.current = options;
|
|
70
|
+
const chart = chartRef.current;
|
|
71
|
+
if (!chart)
|
|
72
|
+
return void 0;
|
|
73
|
+
let cancelled = false;
|
|
74
|
+
chart.options(buildSpec(options));
|
|
75
|
+
chart.render().then(() => {
|
|
76
|
+
var _a;
|
|
77
|
+
if (!cancelled)
|
|
78
|
+
(_a = onReadyRef.current) == null ? void 0 : _a.call(onReadyRef, chart);
|
|
79
|
+
}).catch((error) => {
|
|
80
|
+
console.error("[CompanyChart] 图表渲染失败:", error);
|
|
81
|
+
});
|
|
82
|
+
return () => {
|
|
83
|
+
cancelled = true;
|
|
84
|
+
};
|
|
85
|
+
}, [options]);
|
|
86
|
+
(0, import_react.useImperativeHandle)(ref, () => chartRef.current, []);
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: containerRef, className, style: { height, ...style } });
|
|
88
|
+
});
|
|
89
|
+
CompanyChart.displayName = "CompanyChart";
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
CompanyChart
|
|
93
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/basic-components/CompanyChart/index.ts
|
|
17
|
+
var CompanyChart_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(CompanyChart_exports);
|
|
19
|
+
__reExport(CompanyChart_exports, require("./Chart"), module.exports);
|
|
20
|
+
__reExport(CompanyChart_exports, require("./presets"), module.exports);
|
|
21
|
+
__reExport(CompanyChart_exports, require("./theme"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./Chart"),
|
|
25
|
+
...require("./presets"),
|
|
26
|
+
...require("./theme")
|
|
27
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { G2Spec } from "@antv/g2";
|
|
3
|
+
/** 图表数据项 */
|
|
4
|
+
export type CompanyChartDatum = Record<string, unknown>;
|
|
5
|
+
/** 预设图表通用覆盖配置(深度合并到内置 spec,优先级最高) */
|
|
6
|
+
type ChartOverrides = Omit<Partial<G2Spec>, "type" | "data">;
|
|
7
|
+
/** 预设图表通用 Props */
|
|
8
|
+
export interface CompanyPresetChartProps {
|
|
9
|
+
/** 数据源(扁平数组) */
|
|
10
|
+
data: CompanyChartDatum[];
|
|
11
|
+
/** 容器高度(px),默认 320 */
|
|
12
|
+
height?: number;
|
|
13
|
+
/** 容器类名 */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** 容器样式 */
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
/** 覆盖 G2 配置(深度合并,优先级高于内置默认) */
|
|
18
|
+
options?: ChartOverrides;
|
|
19
|
+
}
|
|
20
|
+
export interface CompanyLineChartProps extends CompanyPresetChartProps {
|
|
21
|
+
/** x 编码字段 */
|
|
22
|
+
xField: string;
|
|
23
|
+
/** y 编码字段 */
|
|
24
|
+
yField: string;
|
|
25
|
+
/** 系列分组字段(多系列折线时配置) */
|
|
26
|
+
colorField?: string;
|
|
27
|
+
/** 是否平滑曲线,默认 false */
|
|
28
|
+
smooth?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface CompanyAreaChartProps extends CompanyPresetChartProps {
|
|
31
|
+
/** x 编码字段 */
|
|
32
|
+
xField: string;
|
|
33
|
+
/** y 编码字段 */
|
|
34
|
+
yField: string;
|
|
35
|
+
/** 系列分组字段(多系列面积时配置) */
|
|
36
|
+
colorField?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface CompanyBarChartProps extends CompanyPresetChartProps {
|
|
39
|
+
/** x 编码字段(分类轴) */
|
|
40
|
+
xField: string;
|
|
41
|
+
/** y 编码字段(数值轴) */
|
|
42
|
+
yField: string;
|
|
43
|
+
/** 系列分组字段(彩色柱时配置) */
|
|
44
|
+
colorField?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface CompanyGroupedBarChartProps extends CompanyPresetChartProps {
|
|
47
|
+
/** x 编码字段(分类轴) */
|
|
48
|
+
xField: string;
|
|
49
|
+
/** y 编码字段(数值轴) */
|
|
50
|
+
yField: string;
|
|
51
|
+
/** 分组字段(必填,决定柱子分组) */
|
|
52
|
+
colorField: string;
|
|
53
|
+
}
|
|
54
|
+
export interface CompanyStackedBarChartProps extends CompanyPresetChartProps {
|
|
55
|
+
/** x 编码字段(分类轴) */
|
|
56
|
+
xField: string;
|
|
57
|
+
/** y 编码字段(数值轴) */
|
|
58
|
+
yField: string;
|
|
59
|
+
/** 堆叠字段(必填,决定堆叠层级) */
|
|
60
|
+
colorField: string;
|
|
61
|
+
}
|
|
62
|
+
export interface CompanyPieChartProps extends CompanyPresetChartProps {
|
|
63
|
+
/** 分类(扇区名称)字段 */
|
|
64
|
+
colorField: string;
|
|
65
|
+
/** 扇区角度对应的数值字段 */
|
|
66
|
+
angleField: string;
|
|
67
|
+
/** 内半径比例(0~1),饼图默认 0 */
|
|
68
|
+
innerRadius?: number;
|
|
69
|
+
/** 外半径比例(0~1) */
|
|
70
|
+
outerRadius?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface CompanyDonutChartProps extends CompanyPieChartProps {
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 折线图 LineChart
|
|
76
|
+
*/
|
|
77
|
+
export declare const CompanyLineChart: React.FC<CompanyLineChartProps>;
|
|
78
|
+
/**
|
|
79
|
+
* 面积图 AreaChart
|
|
80
|
+
*/
|
|
81
|
+
export declare const CompanyAreaChart: React.FC<CompanyAreaChartProps>;
|
|
82
|
+
/**
|
|
83
|
+
* 柱形图 BarChart
|
|
84
|
+
*/
|
|
85
|
+
export declare const CompanyBarChart: React.FC<CompanyBarChartProps>;
|
|
86
|
+
/**
|
|
87
|
+
* 分组柱形图 GroupedBarChart
|
|
88
|
+
*/
|
|
89
|
+
export declare const CompanyGroupedBarChart: React.FC<CompanyGroupedBarChartProps>;
|
|
90
|
+
/**
|
|
91
|
+
* 堆叠柱形图 StackedBarChart
|
|
92
|
+
*/
|
|
93
|
+
export declare const CompanyStackedBarChart: React.FC<CompanyStackedBarChartProps>;
|
|
94
|
+
/**
|
|
95
|
+
* 饼图 PieChart
|
|
96
|
+
*/
|
|
97
|
+
export declare const CompanyPieChart: React.FC<CompanyPieChartProps>;
|
|
98
|
+
/**
|
|
99
|
+
* 环形图 DonutChart
|
|
100
|
+
*/
|
|
101
|
+
export declare const CompanyDonutChart: React.FC<CompanyDonutChartProps>;
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/basic-components/CompanyChart/presets.tsx
|
|
20
|
+
var presets_exports = {};
|
|
21
|
+
__export(presets_exports, {
|
|
22
|
+
CompanyAreaChart: () => CompanyAreaChart,
|
|
23
|
+
CompanyBarChart: () => CompanyBarChart,
|
|
24
|
+
CompanyDonutChart: () => CompanyDonutChart,
|
|
25
|
+
CompanyGroupedBarChart: () => CompanyGroupedBarChart,
|
|
26
|
+
CompanyLineChart: () => CompanyLineChart,
|
|
27
|
+
CompanyPieChart: () => CompanyPieChart,
|
|
28
|
+
CompanyStackedBarChart: () => CompanyStackedBarChart
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(presets_exports);
|
|
31
|
+
var import_Chart = require("./Chart");
|
|
32
|
+
var import_utils = require("./utils");
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var rectAxisDefaults = {
|
|
35
|
+
axis: {
|
|
36
|
+
x: { title: false },
|
|
37
|
+
y: { title: false }
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var CompanyLineChart = (props) => {
|
|
41
|
+
const { data, xField, yField, colorField, smooth = false, options, ...rest } = props;
|
|
42
|
+
const spec = {
|
|
43
|
+
type: "line",
|
|
44
|
+
data: data || [],
|
|
45
|
+
encode: {
|
|
46
|
+
x: xField,
|
|
47
|
+
y: yField,
|
|
48
|
+
...colorField ? { color: colorField } : {}
|
|
49
|
+
},
|
|
50
|
+
...smooth ? { style: { shape: "smooth" } } : {},
|
|
51
|
+
...rectAxisDefaults
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Chart.CompanyChart, { ...rest, options: (0, import_utils.deepMerge)(spec, options) });
|
|
54
|
+
};
|
|
55
|
+
var CompanyAreaChart = (props) => {
|
|
56
|
+
const { data, xField, yField, colorField, options, ...rest } = props;
|
|
57
|
+
const spec = {
|
|
58
|
+
type: "area",
|
|
59
|
+
data: data || [],
|
|
60
|
+
encode: {
|
|
61
|
+
x: xField,
|
|
62
|
+
y: yField,
|
|
63
|
+
...colorField ? { color: colorField } : {}
|
|
64
|
+
},
|
|
65
|
+
...rectAxisDefaults
|
|
66
|
+
};
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Chart.CompanyChart, { ...rest, options: (0, import_utils.deepMerge)(spec, options) });
|
|
68
|
+
};
|
|
69
|
+
var CompanyBarChart = (props) => {
|
|
70
|
+
const { data, xField, yField, colorField, options, ...rest } = props;
|
|
71
|
+
const spec = {
|
|
72
|
+
type: "interval",
|
|
73
|
+
data: data || [],
|
|
74
|
+
encode: {
|
|
75
|
+
x: xField,
|
|
76
|
+
y: yField,
|
|
77
|
+
...colorField ? { color: colorField } : {}
|
|
78
|
+
},
|
|
79
|
+
...rectAxisDefaults
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Chart.CompanyChart, { ...rest, options: (0, import_utils.deepMerge)(spec, options) });
|
|
82
|
+
};
|
|
83
|
+
var CompanyGroupedBarChart = (props) => {
|
|
84
|
+
const { data, xField, yField, colorField, options, ...rest } = props;
|
|
85
|
+
const spec = {
|
|
86
|
+
type: "interval",
|
|
87
|
+
data: data || [],
|
|
88
|
+
encode: {
|
|
89
|
+
x: xField,
|
|
90
|
+
y: yField,
|
|
91
|
+
color: colorField
|
|
92
|
+
},
|
|
93
|
+
transform: [{ type: "dodgeX" }],
|
|
94
|
+
...rectAxisDefaults
|
|
95
|
+
};
|
|
96
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Chart.CompanyChart, { ...rest, options: (0, import_utils.deepMerge)(spec, options) });
|
|
97
|
+
};
|
|
98
|
+
var CompanyStackedBarChart = (props) => {
|
|
99
|
+
const { data, xField, yField, colorField, options, ...rest } = props;
|
|
100
|
+
const spec = {
|
|
101
|
+
type: "interval",
|
|
102
|
+
data: data || [],
|
|
103
|
+
encode: {
|
|
104
|
+
x: xField,
|
|
105
|
+
y: yField,
|
|
106
|
+
color: colorField
|
|
107
|
+
},
|
|
108
|
+
transform: [{ type: "stackY" }],
|
|
109
|
+
...rectAxisDefaults
|
|
110
|
+
};
|
|
111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Chart.CompanyChart, { ...rest, options: (0, import_utils.deepMerge)(spec, options) });
|
|
112
|
+
};
|
|
113
|
+
var buildPieSpec = (data, colorField, angleField, innerRadius, outerRadius) => ({
|
|
114
|
+
type: "interval",
|
|
115
|
+
data: data || [],
|
|
116
|
+
encode: {
|
|
117
|
+
y: angleField,
|
|
118
|
+
color: colorField
|
|
119
|
+
},
|
|
120
|
+
transform: [{ type: "stackY" }],
|
|
121
|
+
coordinate: {
|
|
122
|
+
type: "theta",
|
|
123
|
+
...innerRadius !== void 0 ? { innerRadius } : {},
|
|
124
|
+
...outerRadius !== void 0 ? { outerRadius } : {}
|
|
125
|
+
},
|
|
126
|
+
axis: false
|
|
127
|
+
});
|
|
128
|
+
var CompanyPieChart = (props) => {
|
|
129
|
+
const { data, colorField, angleField, innerRadius = 0, outerRadius, options, ...rest } = props;
|
|
130
|
+
const spec = buildPieSpec(data || [], colorField, angleField, innerRadius, outerRadius);
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Chart.CompanyChart, { ...rest, options: (0, import_utils.deepMerge)(spec, options) });
|
|
132
|
+
};
|
|
133
|
+
var CompanyDonutChart = (props) => {
|
|
134
|
+
const { data, colorField, angleField, innerRadius = 0.6, outerRadius, options, ...rest } = props;
|
|
135
|
+
const spec = buildPieSpec(data || [], colorField, angleField, innerRadius, outerRadius);
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Chart.CompanyChart, { ...rest, options: (0, import_utils.deepMerge)(spec, options) });
|
|
137
|
+
};
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
CompanyAreaChart,
|
|
141
|
+
CompanyBarChart,
|
|
142
|
+
CompanyDonutChart,
|
|
143
|
+
CompanyGroupedBarChart,
|
|
144
|
+
CompanyLineChart,
|
|
145
|
+
CompanyPieChart,
|
|
146
|
+
CompanyStackedBarChart
|
|
147
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { G2Spec } from "@antv/g2";
|
|
2
|
+
/** 图表主题配置类型(G2 5.x 部分主题对象) */
|
|
3
|
+
export type CompanyChartThemeOption = NonNullable<G2Spec["theme"]>;
|
|
4
|
+
/** 分类色板(category10,品牌橙 #F95914 打头) */
|
|
5
|
+
export declare const CHART_COLOR_10: string[];
|
|
6
|
+
/** 扩展分类色板(category20:主色 + 各色板 4 号位浅色交错,用于高基数系列场景) */
|
|
7
|
+
export declare const CHART_COLOR_20: string[];
|
|
8
|
+
/** 企业图表主题:基于 G2 内置 classic 主题,色板取自站点主题体系(Seed Token 派生) */
|
|
9
|
+
export declare const companyChartTheme: CompanyChartThemeOption;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/basic-components/CompanyChart/theme.ts
|
|
20
|
+
var theme_exports = {};
|
|
21
|
+
__export(theme_exports, {
|
|
22
|
+
CHART_COLOR_10: () => CHART_COLOR_10,
|
|
23
|
+
CHART_COLOR_20: () => CHART_COLOR_20,
|
|
24
|
+
companyChartTheme: () => companyChartTheme
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(theme_exports);
|
|
27
|
+
var import_paletteMapping = require("../../theme/paletteMapping");
|
|
28
|
+
var uniqueChartColors = [...new Set(import_paletteMapping.CHART_SEQUENCE.map((s) => s.color))];
|
|
29
|
+
var CHART_COLOR_10 = uniqueChartColors;
|
|
30
|
+
var CHART_COLOR_20 = import_paletteMapping.PALETTES.filter(
|
|
31
|
+
(p) => uniqueChartColors.includes(p.colors[5])
|
|
32
|
+
).flatMap((p) => [p.colors[5], p.colors[3]]);
|
|
33
|
+
var companyChartTheme = {
|
|
34
|
+
type: "classic",
|
|
35
|
+
/** 单系列默认色(G2 Light 主题 colorDefault 为蓝色 #1783FF,必须覆盖为品牌橙) */
|
|
36
|
+
color: CHART_COLOR_10[0],
|
|
37
|
+
category10: CHART_COLOR_10,
|
|
38
|
+
category20: CHART_COLOR_20
|
|
39
|
+
};
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
CHART_COLOR_10,
|
|
43
|
+
CHART_COLOR_20,
|
|
44
|
+
companyChartTheme
|
|
45
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/basic-components/CompanyChart/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
deepMerge: () => deepMerge
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var isPlainObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
|
|
26
|
+
function deepMerge(target, source) {
|
|
27
|
+
if (!isPlainObject(source) || !isPlainObject(target)) {
|
|
28
|
+
return source === void 0 ? target : source;
|
|
29
|
+
}
|
|
30
|
+
const result = { ...target };
|
|
31
|
+
for (const key of Object.keys(source)) {
|
|
32
|
+
result[key] = deepMerge(result[key], source[key]);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
deepMerge
|
|
39
|
+
});
|
|
@@ -13,6 +13,7 @@ export * from "./CompanyBubble";
|
|
|
13
13
|
export * from "./CompanyButton";
|
|
14
14
|
export * from "./CompanyCalendar";
|
|
15
15
|
export * from "./CompanyCard";
|
|
16
|
+
export * from "./CompanyChart";
|
|
16
17
|
export * from "./CompanyCarousel";
|
|
17
18
|
export * from "./CompanyCascader";
|
|
18
19
|
export * from "./CompanyCheckbox";
|
|
@@ -85,3 +86,4 @@ export * from "./CompanyTypography";
|
|
|
85
86
|
export * from "./CompanyUpload";
|
|
86
87
|
export * from "./CompanyWatermark";
|
|
87
88
|
export * from "./CompanyWelcome";
|
|
89
|
+
export * from "./CompanyXProvider";
|