@donglegeyu/company-ui 1.2.45 → 1.2.47

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.
Files changed (47) hide show
  1. package/dist/cjs/ai-assistant/AiSessionEngine.d.ts +3 -0
  2. package/dist/cjs/ai-assistant/AiSessionEngine.js +33 -0
  3. package/dist/cjs/ai-assistant/MockAiTransport.d.ts +4 -1
  4. package/dist/cjs/ai-assistant/MockAiTransport.js +14 -2
  5. package/dist/cjs/ai-assistant/index.d.ts +1 -1
  6. package/dist/cjs/ai-assistant/types.d.ts +41 -0
  7. package/dist/cjs/basic-components/CompanyChart/Chart.d.ts +20 -0
  8. package/dist/cjs/basic-components/CompanyChart/Chart.js +93 -0
  9. package/dist/cjs/basic-components/CompanyChart/index.d.ts +3 -0
  10. package/dist/cjs/basic-components/CompanyChart/index.js +27 -0
  11. package/dist/cjs/basic-components/CompanyChart/presets.d.ts +102 -0
  12. package/dist/cjs/basic-components/CompanyChart/presets.js +147 -0
  13. package/dist/cjs/basic-components/CompanyChart/theme.d.ts +9 -0
  14. package/dist/cjs/basic-components/CompanyChart/theme.js +45 -0
  15. package/dist/cjs/basic-components/CompanyChart/utils.d.ts +6 -0
  16. package/dist/cjs/basic-components/CompanyChart/utils.js +39 -0
  17. package/dist/cjs/basic-components/index.d.ts +2 -0
  18. package/dist/cjs/basic-components/index.js +5 -1
  19. package/dist/cjs/shared-components/CompanyAiAssistant/index.d.ts +3 -1
  20. package/dist/cjs/shared-components/CompanyAiAssistant/index.js +99 -26
  21. package/dist/cjs/shared-components/CompanyAiAssistant/index.scss +79 -0
  22. package/dist/cjs/sidebar-config.d.ts +2 -0
  23. package/dist/cjs/sidebar-config.js +23 -0
  24. package/dist/es/ai-assistant/AiSessionEngine.d.ts +3 -0
  25. package/dist/es/ai-assistant/AiSessionEngine.js +56 -1
  26. package/dist/es/ai-assistant/MockAiTransport.d.ts +4 -1
  27. package/dist/es/ai-assistant/MockAiTransport.js +11 -2
  28. package/dist/es/ai-assistant/index.d.ts +1 -1
  29. package/dist/es/ai-assistant/types.d.ts +41 -0
  30. package/dist/es/basic-components/CompanyChart/Chart.d.ts +20 -0
  31. package/dist/es/basic-components/CompanyChart/Chart.js +91 -0
  32. package/dist/es/basic-components/CompanyChart/index.d.ts +3 -0
  33. package/dist/es/basic-components/CompanyChart/index.js +3 -0
  34. package/dist/es/basic-components/CompanyChart/presets.d.ts +102 -0
  35. package/dist/es/basic-components/CompanyChart/presets.js +229 -0
  36. package/dist/es/basic-components/CompanyChart/theme.d.ts +9 -0
  37. package/dist/es/basic-components/CompanyChart/theme.js +36 -0
  38. package/dist/es/basic-components/CompanyChart/utils.d.ts +6 -0
  39. package/dist/es/basic-components/CompanyChart/utils.js +26 -0
  40. package/dist/es/basic-components/index.d.ts +2 -0
  41. package/dist/es/basic-components/index.js +3 -1
  42. package/dist/es/shared-components/CompanyAiAssistant/index.d.ts +3 -1
  43. package/dist/es/shared-components/CompanyAiAssistant/index.js +121 -37
  44. package/dist/es/shared-components/CompanyAiAssistant/index.scss +79 -0
  45. package/dist/es/sidebar-config.d.ts +2 -0
  46. package/dist/es/sidebar-config.js +30 -0
  47. package/package.json +3 -2
@@ -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] = {
@@ -130,6 +142,26 @@ var AiSessionEngine = class {
130
142
  this.update(tabKey, { messages });
131
143
  break;
132
144
  }
145
+ case "tool": {
146
+ if (isPlaceholder) {
147
+ const calls = [...last.toolCalls ?? []];
148
+ const view = {
149
+ callId: event.callId,
150
+ name: event.name,
151
+ status: event.status,
152
+ ...event.args !== void 0 ? { args: event.args } : {},
153
+ ...event.result !== void 0 ? { result: event.result } : {}
154
+ };
155
+ const index = calls.findIndex((call) => call.callId === event.callId);
156
+ if (index >= 0)
157
+ calls[index] = { ...calls[index], ...view };
158
+ else
159
+ calls.push(view);
160
+ messages[messages.length - 1] = { ...last, toolCalls: calls };
161
+ }
162
+ this.update(tabKey, { messages });
163
+ break;
164
+ }
133
165
  case "done": {
134
166
  this.update(tabKey, { messages, streaming: false });
135
167
  break;
@@ -158,6 +190,7 @@ ${reason}` : reason
158
190
  // 无页面契约时为系统级交互,后端按 system 场景路由通用问答
159
191
  scene: (capability == null ? void 0 : capability.scene) ?? "system",
160
192
  context,
193
+ history,
161
194
  message: trimmed,
162
195
  onEvent: handleEvent
163
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
- })) ?? defaultRespond({ scene: params.scene, context: params.context, message: params.message });
61
+ });
50
62
  let index = 0;
51
63
  this.timer = setInterval(() => {
52
64
  if (index >= events.length) {
@@ -1,6 +1,6 @@
1
1
  export * from "./AiActionGuard";
2
2
  export * from "./aiDraft";
3
- export type { AiContext, AiMessage, AiMessageRole, AiPageActions, AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSnapshot, AiStreamEvent, AiSuggestion, AiTransport, AiValidateIssue, AiValidateReport, FormPatch, } from "./types";
3
+ export type { AiContext, AiMessage, AiMessageRole, AiPageActions, AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSnapshot, AiStreamEvent, AiSuggestion, AiToolCallStatus, AiToolCallView, AiTransport, AiValidateIssue, AiValidateReport, FormPatch, } from "./types";
4
4
  export { AiSessionEngine } from "./AiSessionEngine";
5
5
  export type { AiSessionEngineOptions } from "./AiSessionEngine";
6
6
  export { MockAiTransport } from "./MockAiTransport";
@@ -74,16 +74,35 @@ export interface AiSuggestion {
74
74
  /** 补丁数据:确认后传给 actions.backfill */
75
75
  patch: FormPatch;
76
76
  }
77
+ /** 工具调用状态 */
78
+ export type AiToolCallStatus = "pending" | "running" | "succeeded" | "failed" | "skipped";
79
+ /** 工具调用视图(tool 帧按 callId 归并后的展示结构;面板受控渲染) */
80
+ export interface AiToolCallView {
81
+ /** 调用唯一标识(同一 callId 的后续帧覆盖状态与结果) */
82
+ callId: string;
83
+ /** 工具名 */
84
+ name: string;
85
+ /** 入参(自由结构;面板仅做只读摘要展示,完整入参不进面板) */
86
+ args?: Record<string, unknown>;
87
+ /** 调用状态 */
88
+ status: AiToolCallStatus;
89
+ /** 结果摘要(单行简述;完整结果不进面板) */
90
+ result?: string;
91
+ }
77
92
  /** 面板消息 */
78
93
  export interface AiMessage {
79
94
  id: string;
80
95
  role: AiMessageRole;
81
96
  /** 文本内容(流式期间为已累积文本) */
82
97
  content: string;
98
+ /** 思考过程文本(thinking 帧累积;仅 assistant 消息,缺省表示本轮无思考内容) */
99
+ reasoning?: string;
83
100
  /** 携带的结构化建议(仅 assistant 消息) */
84
101
  suggestion?: AiSuggestion;
85
102
  /** 建议是否已确认回填(已确认后芯片置为已完成态) */
86
103
  applied?: boolean;
104
+ /** 本轮工具调用(tool 帧按 callId 归并;仅 assistant 消息) */
105
+ toolCalls?: AiToolCallView[];
87
106
  createdAt: number;
88
107
  }
89
108
  /** 草稿快照(backfill 前自动压栈,rollback 出栈恢复) */
@@ -102,16 +121,36 @@ export interface AiSession {
102
121
  /** 内置版本栈(栈深 maxSnapshots,超出丢弃最旧) */
103
122
  snapshots: AiSnapshot[];
104
123
  }
124
+ /** 对话历史条目(发送给后端的精简消息结构,不含建议卡片/工具调用等面板专有字段) */
125
+ export interface AiHistoryMessage {
126
+ role: AiMessageRole;
127
+ content: string;
128
+ }
105
129
  /** 流式帧(P1 为 mock;P2 与 SSE 网关帧结构对齐) */
106
130
  export type AiStreamEvent = {
107
131
  type: "delta";
108
132
  text: string;
133
+ } | {
134
+ type: "thinking";
135
+ text: string;
109
136
  } | {
110
137
  type: "action";
111
138
  actionType: "backfill";
112
139
  patch: FormPatch;
113
140
  title?: string;
114
141
  items?: string[];
142
+ } | {
143
+ type: "tool";
144
+ /** 调用唯一标识(同一 callId 多帧归并为一次调用,后帧覆盖状态与结果) */
145
+ callId: string;
146
+ /** 工具名 */
147
+ name: string;
148
+ /** 入参(自由结构) */
149
+ args?: Record<string, unknown>;
150
+ /** 调用状态 */
151
+ status: AiToolCallStatus;
152
+ /** 结果摘要 */
153
+ result?: string;
115
154
  } | {
116
155
  type: "done";
117
156
  } | {
@@ -125,6 +164,8 @@ export interface AiTransport {
125
164
  send(params: {
126
165
  scene: string;
127
166
  context?: AiContext;
167
+ /** 近 N 轮对话历史(不含本轮 message;引擎按 maxHistory 截断并过滤空内容) */
168
+ history?: AiHistoryMessage[];
128
169
  message: string;
129
170
  onEvent: (event: AiStreamEvent) => void;
130
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,3 @@
1
+ export * from "./Chart";
2
+ export * from "./presets";
3
+ export * from "./theme";
@@ -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;