prod-test-chat-sdk 0.0.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/.prettierrc.js +24 -0
- package/README.md +46 -0
- package/config/env.js +104 -0
- package/config/getHttpsConfig.js +66 -0
- package/config/jest/babelTransform.js +29 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +134 -0
- package/config/paths.js +77 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +785 -0
- package/config/webpackDevServer.config.js +127 -0
- package/dist/Chat/AgentList/index.d.ts +9 -0
- package/dist/Chat/ChatFooter/index.d.ts +17 -0
- package/dist/Chat/Conversation/index.d.ts +11 -0
- package/dist/Chat/MessageContainer/index.d.ts +19 -0
- package/dist/Chat/MobileAgents/index.d.ts +11 -0
- package/dist/Chat/components/AgentTip/index.d.ts +8 -0
- package/dist/Chat/components/ConversationModal/index.d.ts +10 -0
- package/dist/Chat/components/CopilotAvatar/index.d.ts +2 -0
- package/dist/Chat/components/Message.d.ts +10 -0
- package/dist/Chat/components/RecommendQuestions/index.d.ts +6 -0
- package/dist/Chat/components/Text.d.ts +9 -0
- package/dist/Chat/constants.d.ts +19 -0
- package/dist/Chat/index.d.ts +17 -0
- package/dist/Chat/service.d.ts +11 -0
- package/dist/Chat/type.d.ts +97 -0
- package/dist/Copilot/constants.d.ts +11 -0
- package/dist/Copilot/index.d.ts +13 -0
- package/dist/ShowCase/index.d.ts +8 -0
- package/dist/ShowCase/service.d.ts +2 -0
- package/dist/ShowCase/type.d.ts +11 -0
- package/dist/common/constants.d.ts +58 -0
- package/dist/common/env.d.ts +3 -0
- package/dist/common/type.d.ts +247 -0
- package/dist/components/ChatItem/ExecuteItem.d.ts +25 -0
- package/dist/components/ChatItem/ExpandParseTip.d.ts +20 -0
- package/dist/components/ChatItem/FilterItem.d.ts +17 -0
- package/dist/components/ChatItem/Loading.d.ts +2 -0
- package/dist/components/ChatItem/ParseTip.d.ts +26 -0
- package/dist/components/ChatItem/ParseTipUtils.d.ts +10 -0
- package/dist/components/ChatItem/SimilarQuestionItem.d.ts +10 -0
- package/dist/components/ChatItem/SqlItem.d.ts +17 -0
- package/dist/components/ChatItem/SwitchEntity.d.ts +9 -0
- package/dist/components/ChatItem/Text.d.ts +6 -0
- package/dist/components/ChatItem/Typing.d.ts +2 -0
- package/dist/components/ChatItem/index.d.ts +33 -0
- package/dist/components/ChatMsg/ApplyAuth/index.d.ts +7 -0
- package/dist/components/ChatMsg/Bar/index.d.ts +13 -0
- package/dist/components/ChatMsg/DateOptions/index.d.ts +9 -0
- package/dist/components/ChatMsg/FilterSection/index.d.ts +8 -0
- package/dist/components/ChatMsg/MarkDown/index.d.ts +10 -0
- package/dist/components/ChatMsg/Message/index.d.ts +18 -0
- package/dist/components/ChatMsg/MetricCard/PeriodCompareItem.d.ts +7 -0
- package/dist/components/ChatMsg/MetricCard/index.d.ts +10 -0
- package/dist/components/ChatMsg/MetricTrend/MetricInfo.d.ts +8 -0
- package/dist/components/ChatMsg/MetricTrend/MetricTrendChart.d.ts +14 -0
- package/dist/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.d.ts +12 -0
- package/dist/components/ChatMsg/MetricTrend/index.d.ts +16 -0
- package/dist/components/ChatMsg/NoPermissionChart/index.d.ts +8 -0
- package/dist/components/ChatMsg/Pie/PieChart.d.ts +11 -0
- package/dist/components/ChatMsg/Pie/index.d.ts +14 -0
- package/dist/components/ChatMsg/Table/index.d.ts +12 -0
- package/dist/components/ChatMsg/Text/index.d.ts +9 -0
- package/dist/components/ChatMsg/WebPage/index.d.ts +8 -0
- package/dist/components/ChatMsg/index.d.ts +15 -0
- package/dist/components/DrillDownDimensions/DimensionSection.d.ts +11 -0
- package/dist/components/DrillDownDimensions/index.d.ts +13 -0
- package/dist/components/IconFont/index.d.ts +3 -0
- package/dist/components/MetricOptions/index.d.ts +11 -0
- package/dist/components/RecommendOptions/index.d.ts +9 -0
- package/dist/components/Tools/FeedbackModal.d.ts +9 -0
- package/dist/components/Tools/index.d.ts +12 -0
- package/dist/demo/Chat.d.ts +2 -0
- package/dist/demo/ChatDemo.d.ts +4 -0
- package/dist/demo/CopilotDemo.d.ts +2 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useComposing.d.ts +5 -0
- package/dist/hooks/useExportByEcharts.d.ts +10 -0
- package/dist/hooks/useMethodRegister.d.ts +4 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.es.js +1 -0
- package/dist/service/axiosInstance.d.ts +3 -0
- package/dist/service/index.d.ts +25 -0
- package/dist/utils/utils.d.ts +45 -0
- package/package.json +214 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/manifest.json +15 -0
- package/public/robots.txt +3 -0
- package/rollup/rollup.config.mjs +37 -0
- package/rollup/rollup.esm.config.mjs +21 -0
- package/rollup/rollup.umd.config.mjs +30 -0
- package/scripts/build.js +217 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +52 -0
- package/src/Chat/AgentList/index.tsx +52 -0
- package/src/Chat/AgentList/style.module.less +83 -0
- package/src/Chat/ChatFooter/index.tsx +423 -0
- package/src/Chat/ChatFooter/style.module.less +225 -0
- package/src/Chat/Conversation/index.tsx +236 -0
- package/src/Chat/Conversation/style.module.less +171 -0
- package/src/Chat/MessageContainer/index.tsx +145 -0
- package/src/Chat/MessageContainer/style.module.less +53 -0
- package/src/Chat/MobileAgents/index.tsx +62 -0
- package/src/Chat/MobileAgents/style.module.less +55 -0
- package/src/Chat/components/AgentTip/index.tsx +48 -0
- package/src/Chat/components/AgentTip/style.module.less +44 -0
- package/src/Chat/components/ConversationModal/index.tsx +65 -0
- package/src/Chat/components/CopilotAvatar/index.tsx +8 -0
- package/src/Chat/components/CopilotAvatar/style.module.less +13 -0
- package/src/Chat/components/Message.tsx +38 -0
- package/src/Chat/components/RecommendQuestions/index.tsx +64 -0
- package/src/Chat/components/RecommendQuestions/style.module.less +36 -0
- package/src/Chat/components/Text.tsx +42 -0
- package/src/Chat/components/style.module.less +311 -0
- package/src/Chat/constants.ts +37 -0
- package/src/Chat/index.tsx +526 -0
- package/src/Chat/service.ts +49 -0
- package/src/Chat/style.module.less +119 -0
- package/src/Chat/type.ts +107 -0
- package/src/Copilot/constants.ts +11 -0
- package/src/Copilot/index.tsx +149 -0
- package/src/Copilot/style.module.less +151 -0
- package/src/ShowCase/index.tsx +120 -0
- package/src/ShowCase/service.ts +12 -0
- package/src/ShowCase/style.module.less +46 -0
- package/src/ShowCase/type.ts +14 -0
- package/src/common/constants.ts +93 -0
- package/src/common/env.ts +5 -0
- package/src/common/type.ts +270 -0
- package/src/components/ChatItem/ExecuteItem.tsx +211 -0
- package/src/components/ChatItem/ExpandParseTip.tsx +333 -0
- package/src/components/ChatItem/FilterItem.tsx +209 -0
- package/src/components/ChatItem/Loading.tsx +14 -0
- package/src/components/ChatItem/ParseTip.tsx +322 -0
- package/src/components/ChatItem/ParseTipUtils.tsx +205 -0
- package/src/components/ChatItem/SimilarQuestionItem.tsx +84 -0
- package/src/components/ChatItem/SqlItem.tsx +410 -0
- package/src/components/ChatItem/SwitchEntity.tsx +52 -0
- package/src/components/ChatItem/Text.tsx +17 -0
- package/src/components/ChatItem/Typing.tsx +19 -0
- package/src/components/ChatItem/index.tsx +843 -0
- package/src/components/ChatItem/style.less +670 -0
- package/src/components/ChatMsg/ApplyAuth/index.tsx +30 -0
- package/src/components/ChatMsg/ApplyAuth/style.less +13 -0
- package/src/components/ChatMsg/Bar/index.tsx +223 -0
- package/src/components/ChatMsg/Bar/style.less +60 -0
- package/src/components/ChatMsg/DateOptions/index.tsx +46 -0
- package/src/components/ChatMsg/DateOptions/style.less +43 -0
- package/src/components/ChatMsg/FilterSection/index.tsx +42 -0
- package/src/components/ChatMsg/FilterSection/style.less +37 -0
- package/src/components/ChatMsg/MarkDown/index.tsx +26 -0
- package/src/components/ChatMsg/MarkDown/style.less +9 -0
- package/src/components/ChatMsg/Message/index.tsx +105 -0
- package/src/components/ChatMsg/Message/style.less +119 -0
- package/src/components/ChatMsg/MetricCard/PeriodCompareItem.tsx +29 -0
- package/src/components/ChatMsg/MetricCard/index.tsx +80 -0
- package/src/components/ChatMsg/MetricCard/style.less +126 -0
- package/src/components/ChatMsg/MetricTrend/MetricInfo.tsx +60 -0
- package/src/components/ChatMsg/MetricTrend/MetricTrendChart.tsx +235 -0
- package/src/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.tsx +162 -0
- package/src/components/ChatMsg/MetricTrend/index.tsx +127 -0
- package/src/components/ChatMsg/MetricTrend/style.less +195 -0
- package/src/components/ChatMsg/NoPermissionChart/index.tsx +28 -0
- package/src/components/ChatMsg/NoPermissionChart/style.less +26 -0
- package/src/components/ChatMsg/Pie/PieChart.tsx +134 -0
- package/src/components/ChatMsg/Pie/index.tsx +88 -0
- package/src/components/ChatMsg/Pie/style.less +43 -0
- package/src/components/ChatMsg/Table/index.tsx +105 -0
- package/src/components/ChatMsg/Table/style.less +131 -0
- package/src/components/ChatMsg/Text/index.tsx +70 -0
- package/src/components/ChatMsg/Text/style.less +38 -0
- package/src/components/ChatMsg/WebPage/index.tsx +125 -0
- package/src/components/ChatMsg/index.tsx +428 -0
- package/src/components/ChatMsg/style.less +28 -0
- package/src/components/DrillDownDimensions/DimensionSection.tsx +99 -0
- package/src/components/DrillDownDimensions/index.tsx +76 -0
- package/src/components/DrillDownDimensions/style.less +64 -0
- package/src/components/IconFont/index.tsx +7 -0
- package/src/components/MetricOptions/index.tsx +75 -0
- package/src/components/MetricOptions/style.less +69 -0
- package/src/components/RecommendOptions/index.tsx +126 -0
- package/src/components/RecommendOptions/style.less +24 -0
- package/src/components/Tools/FeedbackModal.tsx +55 -0
- package/src/components/Tools/index.tsx +126 -0
- package/src/components/Tools/style.less +67 -0
- package/src/demo/Chat.tsx +73 -0
- package/src/demo/ChatDemo.tsx +14 -0
- package/src/demo/CopilotDemo.tsx +43 -0
- package/src/demo/style.module.less +19 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useComposing.ts +31 -0
- package/src/hooks/useExportByEcharts.ts +41 -0
- package/src/hooks/useMethodRegister.ts +25 -0
- package/src/index.tsx +44 -0
- package/src/service/axiosInstance.ts +58 -0
- package/src/service/index.ts +174 -0
- package/src/setupProxy.js +18 -0
- package/src/setupTests.ts +5 -0
- package/src/styles/global.less +52 -0
- package/src/styles/index.less +39 -0
- package/src/styles/reboot.less +14 -0
- package/src/styles/variables.less +80 -0
- package/src/typings.d.ts +179 -0
- package/src/utils/utils.ts +346 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { CHART_BLUE_COLOR, CHART_SECONDARY_COLOR, PREFIX_CLS } from '../../../common/constants';
|
|
2
|
+
import { MsgDataType } from '../../../common/type';
|
|
3
|
+
import {
|
|
4
|
+
formatByDataFormatType,
|
|
5
|
+
getChartLightenColor,
|
|
6
|
+
getFormattedValue,
|
|
7
|
+
} from '../../../utils/utils';
|
|
8
|
+
import type { ECharts } from 'echarts';
|
|
9
|
+
import * as echarts from 'echarts';
|
|
10
|
+
import {
|
|
11
|
+
forwardRef,
|
|
12
|
+
ForwardRefRenderFunction,
|
|
13
|
+
useContext,
|
|
14
|
+
useEffect,
|
|
15
|
+
useImperativeHandle,
|
|
16
|
+
useRef,
|
|
17
|
+
} from 'react';
|
|
18
|
+
import NoPermissionChart from '../NoPermissionChart';
|
|
19
|
+
import { ColumnType } from '../../../common/type';
|
|
20
|
+
import { Spin } from 'antd';
|
|
21
|
+
import { ChartItemContext } from '../../ChatItem';
|
|
22
|
+
import { useExportByEcharts } from '../../../hooks';
|
|
23
|
+
import moment from 'moment';
|
|
24
|
+
|
|
25
|
+
type Props = {
|
|
26
|
+
data: MsgDataType;
|
|
27
|
+
question?: string;
|
|
28
|
+
triggerResize?: boolean;
|
|
29
|
+
loading: boolean;
|
|
30
|
+
metricField: ColumnType;
|
|
31
|
+
onApplyAuth?: (model: string) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const BarChart: React.FC<Props> = ({
|
|
35
|
+
data,
|
|
36
|
+
question="",
|
|
37
|
+
triggerResize,
|
|
38
|
+
loading,
|
|
39
|
+
metricField,
|
|
40
|
+
onApplyAuth,
|
|
41
|
+
}) => {
|
|
42
|
+
const chartRef = useRef<any>();
|
|
43
|
+
const instanceRef = useRef<ECharts>();
|
|
44
|
+
|
|
45
|
+
const { queryColumns, queryResults, entityInfo } = data;
|
|
46
|
+
|
|
47
|
+
const categoryColumnName =
|
|
48
|
+
queryColumns?.find(column => column.showType === 'CATEGORY')?.bizName || '';
|
|
49
|
+
const metricColumn = queryColumns?.find(column => column.showType === 'NUMBER');
|
|
50
|
+
const metricColumnName = metricColumn?.bizName || '';
|
|
51
|
+
|
|
52
|
+
const renderChart = () => {
|
|
53
|
+
let instanceObj: any;
|
|
54
|
+
if (!instanceRef.current) {
|
|
55
|
+
instanceObj = echarts.init(chartRef.current);
|
|
56
|
+
instanceRef.current = instanceObj;
|
|
57
|
+
} else {
|
|
58
|
+
instanceObj = instanceRef.current;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const data = (queryResults || []);
|
|
62
|
+
|
|
63
|
+
// 检查是否有日期字段,如果有则按时间排序
|
|
64
|
+
const dateColumn = queryResults[0] ? Object.keys(queryResults[0]).find(key =>
|
|
65
|
+
key.toLowerCase().includes('date') || key.toLowerCase().includes('time')
|
|
66
|
+
) : null;
|
|
67
|
+
|
|
68
|
+
let sortedData = data;
|
|
69
|
+
if (dateColumn) {
|
|
70
|
+
sortedData = [...data].sort((a, b) => {
|
|
71
|
+
return moment(a[dateColumn]).diff(moment(b[dateColumn]));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const xData = sortedData.map(item =>
|
|
76
|
+
item[categoryColumnName] !== undefined ? item[categoryColumnName] : '未知'
|
|
77
|
+
);
|
|
78
|
+
instanceObj.setOption({
|
|
79
|
+
xAxis: {
|
|
80
|
+
type: 'category',
|
|
81
|
+
axisTick: {
|
|
82
|
+
show: false,
|
|
83
|
+
},
|
|
84
|
+
axisLine: {
|
|
85
|
+
lineStyle: {
|
|
86
|
+
color: CHART_SECONDARY_COLOR,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
axisLabel: {
|
|
90
|
+
width: 200,
|
|
91
|
+
overflow: 'truncate',
|
|
92
|
+
showMaxLabel: true,
|
|
93
|
+
hideOverlap: false,
|
|
94
|
+
interval: 0,
|
|
95
|
+
color: '#333',
|
|
96
|
+
rotate: 30,
|
|
97
|
+
},
|
|
98
|
+
data: xData,
|
|
99
|
+
},
|
|
100
|
+
yAxis: {
|
|
101
|
+
type: 'value',
|
|
102
|
+
splitLine: {
|
|
103
|
+
lineStyle: {
|
|
104
|
+
opacity: 0.3,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
axisLabel: {
|
|
108
|
+
formatter: function (value: any) {
|
|
109
|
+
return value === 0
|
|
110
|
+
? 0
|
|
111
|
+
: metricField.dataFormatType === 'percent'
|
|
112
|
+
? formatByDataFormatType(value, metricField.dataFormatType, metricField.dataFormat)
|
|
113
|
+
: getFormattedValue(value);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
tooltip: {
|
|
118
|
+
trigger: 'axis',
|
|
119
|
+
formatter: function (params: any[]) {
|
|
120
|
+
const param = params[0];
|
|
121
|
+
const valueLabels = params
|
|
122
|
+
.map(
|
|
123
|
+
(item: any) =>
|
|
124
|
+
`<div style="margin-top: 3px;">${
|
|
125
|
+
item.marker
|
|
126
|
+
} <span style="display: inline-block; width: 70px; margin-right: 12px;">${
|
|
127
|
+
item.seriesName
|
|
128
|
+
}</span><span style="display: inline-block; width: 90px; text-align: right; font-weight: 500;">${
|
|
129
|
+
item.value === ''
|
|
130
|
+
? '-'
|
|
131
|
+
: metricField.dataFormatType === 'percent' ||
|
|
132
|
+
metricField.dataFormatType === 'decimal'
|
|
133
|
+
? formatByDataFormatType(item.value, metricField.dataFormatType, metricField.dataFormat)
|
|
134
|
+
: getFormattedValue(item.value)
|
|
135
|
+
}</span></div>`
|
|
136
|
+
)
|
|
137
|
+
.join('');
|
|
138
|
+
return `${param.name}<br />${valueLabels}`;
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
grid: {
|
|
142
|
+
left: '2%',
|
|
143
|
+
right: '1%',
|
|
144
|
+
bottom: '3%',
|
|
145
|
+
top: 20,
|
|
146
|
+
containLabel: true,
|
|
147
|
+
},
|
|
148
|
+
series: {
|
|
149
|
+
type: 'bar',
|
|
150
|
+
name: metricColumn?.name,
|
|
151
|
+
barWidth: 20,
|
|
152
|
+
itemStyle: {
|
|
153
|
+
borderRadius: [10, 10, 0, 0],
|
|
154
|
+
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
155
|
+
{ offset: 0, color: CHART_BLUE_COLOR },
|
|
156
|
+
{ offset: 1, color: getChartLightenColor(CHART_BLUE_COLOR) },
|
|
157
|
+
]),
|
|
158
|
+
},
|
|
159
|
+
label: {
|
|
160
|
+
show: true,
|
|
161
|
+
position: 'top',
|
|
162
|
+
formatter: function ({ value }: any) {
|
|
163
|
+
return value === 0
|
|
164
|
+
? 0
|
|
165
|
+
: metricField.dataFormatType === 'percent'
|
|
166
|
+
? formatByDataFormatType(value, metricField.dataFormatType, metricField.dataFormat)
|
|
167
|
+
: getFormattedValue(value);
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
data: sortedData.map(item => {
|
|
171
|
+
return item[metricColumn?.bizName || ''];
|
|
172
|
+
}),
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
instanceObj.resize();
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (queryResults && queryResults.length > 0 && metricColumn?.authorized) {
|
|
180
|
+
renderChart();
|
|
181
|
+
}
|
|
182
|
+
}, [queryResults]);
|
|
183
|
+
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (triggerResize && instanceRef.current) {
|
|
186
|
+
instanceRef.current.resize();
|
|
187
|
+
}
|
|
188
|
+
}, [triggerResize]);
|
|
189
|
+
|
|
190
|
+
if (metricColumn && !metricColumn?.authorized) {
|
|
191
|
+
return (
|
|
192
|
+
<NoPermissionChart
|
|
193
|
+
model={entityInfo?.dataSetInfo.name || ''}
|
|
194
|
+
chartType="barChart"
|
|
195
|
+
onApplyAuth={onApplyAuth}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const prefixCls = `${PREFIX_CLS}-bar`;
|
|
201
|
+
|
|
202
|
+
const { downloadChartAsImage } = useExportByEcharts({
|
|
203
|
+
instanceRef,
|
|
204
|
+
question,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const { register } = useContext(ChartItemContext);
|
|
208
|
+
|
|
209
|
+
register('downloadChartAsImage', downloadChartAsImage);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<div>
|
|
213
|
+
<div className={`${prefixCls}-top-bar`}>
|
|
214
|
+
<div className={`${prefixCls}-indicator-name`}>{question}</div>
|
|
215
|
+
</div>
|
|
216
|
+
<Spin spinning={loading}>
|
|
217
|
+
<div className={`${prefixCls}-chart`} ref={chartRef} />
|
|
218
|
+
</Spin>
|
|
219
|
+
</div>
|
|
220
|
+
);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export default BarChart;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@bar-cls: ~'@{supersonic-chat-prefix}-bar';
|
|
4
|
+
|
|
5
|
+
.@{bar-cls} {
|
|
6
|
+
|
|
7
|
+
&-chart {
|
|
8
|
+
height: 260px;
|
|
9
|
+
margin-top: 16px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&-top-bar {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: baseline;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
column-gap: 8px;
|
|
17
|
+
row-gap: 12px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&-filter-section-wrapper {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
color: var(--text-color-third);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&-filter-section {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
font-size: 13px;
|
|
30
|
+
column-gap: 12px;
|
|
31
|
+
color: var(--text-color-third);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&-filter-item {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&-filter-item-label {
|
|
40
|
+
color: var(--text-color-third);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-filter-item-value {
|
|
44
|
+
color: var(--text-color);
|
|
45
|
+
font-weight: 500;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&-indicator-name {
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
color: var(--text-color);
|
|
51
|
+
font-weight: 500;
|
|
52
|
+
margin-top: 2px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&-date-range {
|
|
56
|
+
margin-top: 12px;
|
|
57
|
+
font-size: 13px;
|
|
58
|
+
color: var(--text-color-third);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { CLS_PREFIX, DATE_TYPES } from '../../../common/constants';
|
|
3
|
+
import { isMobile } from '../../../utils/utils';
|
|
4
|
+
import { ChatContextType } from '../../../common/type';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
chatContext: ChatContextType;
|
|
8
|
+
currentDateOption?: number;
|
|
9
|
+
onSelectDateOption: (value: number) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const DateOptions: React.FC<Props> = ({ chatContext, currentDateOption, onSelectDateOption }) => {
|
|
13
|
+
const prefixCls = `${CLS_PREFIX}-date-options`;
|
|
14
|
+
|
|
15
|
+
const dateOptions = DATE_TYPES[chatContext?.dateInfo?.period] || DATE_TYPES.DAY;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={prefixCls}>
|
|
19
|
+
{dateOptions.map((dateOption: { label: string; value: number }, index: number) => {
|
|
20
|
+
const dateOptionClass = classNames(`${prefixCls}-item`, {
|
|
21
|
+
[`${prefixCls}-date-active`]: dateOption.value === currentDateOption,
|
|
22
|
+
[`${prefixCls}-date-mobile`]: isMobile,
|
|
23
|
+
});
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<div
|
|
27
|
+
key={dateOption.value}
|
|
28
|
+
className={dateOptionClass}
|
|
29
|
+
onClick={() => {
|
|
30
|
+
onSelectDateOption(dateOption.value);
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
{dateOption.label}
|
|
34
|
+
{dateOption.value === currentDateOption && (
|
|
35
|
+
<div className={`${prefixCls}-active-identifier`} />
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
{index !== dateOptions.length - 1 && <div className={`${prefixCls}-item-divider`} />}
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
})}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default DateOptions;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@date-options-prefix-cls: ~'@{supersonic-chat-prefix}-date-options';
|
|
4
|
+
|
|
5
|
+
.@{date-options-prefix-cls} {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
column-gap: 20px;
|
|
9
|
+
font-size: 14px;
|
|
10
|
+
|
|
11
|
+
&-item {
|
|
12
|
+
position: relative;
|
|
13
|
+
color: var(--text-color-secondary);
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
|
|
16
|
+
&:hover {
|
|
17
|
+
color: var(--chat-blue);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&-date-active {
|
|
22
|
+
color: var(--chat-blue);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-date-mobile {
|
|
26
|
+
font-size: 12px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-active-identifier {
|
|
30
|
+
position: absolute;
|
|
31
|
+
bottom: -6px;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 4px;
|
|
34
|
+
background-color: var(--chat-blue);
|
|
35
|
+
border-radius: 4px 4px 0 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-item-divider {
|
|
39
|
+
width: 1px;
|
|
40
|
+
height: 16px;
|
|
41
|
+
background-color: var(--text-color-fifth);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PREFIX_CLS } from '../../../common/constants';
|
|
2
|
+
import { ChatContextType, EntityInfoType } from '../../../common/type';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
chatContext?: ChatContextType;
|
|
6
|
+
entityInfo?: EntityInfoType;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const FilterSection: React.FC<Props> = ({ chatContext, entityInfo }) => {
|
|
10
|
+
const prefixCls = `${PREFIX_CLS}-filter-section`;
|
|
11
|
+
|
|
12
|
+
const entityInfoList =
|
|
13
|
+
entityInfo?.dimensions?.filter(dimension => !dimension.bizName.includes('photo')) || [];
|
|
14
|
+
|
|
15
|
+
const { dimensionFilters } = chatContext || {};
|
|
16
|
+
|
|
17
|
+
const hasFilterSection = dimensionFilters && dimensionFilters.length > 0;
|
|
18
|
+
|
|
19
|
+
return hasFilterSection ? (
|
|
20
|
+
<div className={prefixCls}>
|
|
21
|
+
<div className={`${prefixCls}-field-label`}>筛选条件:</div>
|
|
22
|
+
<div className={`${prefixCls}-filter-values`}>
|
|
23
|
+
{(entityInfoList.length > 0 ? entityInfoList : dimensionFilters).map(filterItem => {
|
|
24
|
+
const filterValue =
|
|
25
|
+
typeof filterItem.value === 'string' ? [filterItem.value] : filterItem.value || [];
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
className={`${prefixCls}-filter-item`}
|
|
29
|
+
key={filterItem.name}
|
|
30
|
+
title={filterValue.join('、')}
|
|
31
|
+
>
|
|
32
|
+
<span className={`${prefixCls}-field-name`}>{filterItem.name}:</span>
|
|
33
|
+
<span className={`${prefixCls}-filter-value`}>{filterValue.join('、')}</span>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
})}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
) : null;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default FilterSection;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@filter-section-prefix-cls: ~'@{supersonic-chat-prefix}-filter-section';
|
|
4
|
+
|
|
5
|
+
.@{filter-section-prefix-cls} {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
row-gap: 12px;
|
|
10
|
+
color: var(--text-color-secondary);
|
|
11
|
+
font-weight: normal;
|
|
12
|
+
font-size: 13px;
|
|
13
|
+
|
|
14
|
+
&-field-label {
|
|
15
|
+
color: var(--text-color-fourth);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-filter-values {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
column-gap: 12px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-filter-item {
|
|
26
|
+
color: var(--text-color-third);
|
|
27
|
+
max-width: 200px;
|
|
28
|
+
text-overflow: ellipsis;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-filter-value {
|
|
34
|
+
color: var(--text-color);
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CLS_PREFIX } from '../../../common/constants';
|
|
2
|
+
import rehypeHighlight from 'rehype-highlight';
|
|
3
|
+
import remarkGfm from 'remark-gfm';
|
|
4
|
+
import Markdown from 'react-markdown';
|
|
5
|
+
import 'github-markdown-css/github-markdown.css';
|
|
6
|
+
import 'highlight.js/styles/github.css';
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
markdown: string;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
onApplyAuth?: (model: string) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const MarkDown: React.FC<Props> = ({ markdown, loading, onApplyAuth }) => {
|
|
15
|
+
const prefixCls = `${CLS_PREFIX}-markdown`;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={`${prefixCls} markdown-body`} style={{ fontSize: 14 }}>
|
|
19
|
+
<Markdown rehypePlugins={[rehypeHighlight]} remarkPlugins={[remarkGfm]}>
|
|
20
|
+
{markdown}
|
|
21
|
+
</Markdown>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default MarkDown;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { EntityInfoType, ChatContextType } from '../../../common/type';
|
|
2
|
+
import { PREFIX_CLS } from '../../../common/constants';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
position: 'left' | 'right';
|
|
6
|
+
width?: number | string;
|
|
7
|
+
maxWidth?: number | string;
|
|
8
|
+
height?: number | string;
|
|
9
|
+
title?: string;
|
|
10
|
+
followQuestions?: string[];
|
|
11
|
+
bubbleClassName?: string;
|
|
12
|
+
chatContext?: ChatContextType;
|
|
13
|
+
entityInfo?: EntityInfoType;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
isMobileMode?: boolean;
|
|
16
|
+
queryMode?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const Message: React.FC<Props> = ({
|
|
20
|
+
width,
|
|
21
|
+
maxWidth,
|
|
22
|
+
height,
|
|
23
|
+
children,
|
|
24
|
+
bubbleClassName,
|
|
25
|
+
entityInfo,
|
|
26
|
+
queryMode,
|
|
27
|
+
chatContext,
|
|
28
|
+
}) => {
|
|
29
|
+
const prefixCls = `${PREFIX_CLS}-message`;
|
|
30
|
+
|
|
31
|
+
const { modelName, dateInfo, dimensionFilters } = chatContext || {};
|
|
32
|
+
const { startDate, endDate } = dateInfo || {};
|
|
33
|
+
|
|
34
|
+
const entityInfoList =
|
|
35
|
+
entityInfo?.dimensions?.filter(dimension => !dimension.bizName.includes('photo')) || [];
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className={prefixCls}>
|
|
39
|
+
<div className={`${prefixCls}-content`}>
|
|
40
|
+
<div className={`${prefixCls}-body`}>
|
|
41
|
+
<div
|
|
42
|
+
className={`${prefixCls}-bubble${bubbleClassName ? ` ${bubbleClassName}` : ''}`}
|
|
43
|
+
style={{ width, height, maxWidth }}
|
|
44
|
+
onClick={e => {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
{(queryMode === 'METRIC_ID' || queryMode === 'TAG_DETAIL') &&
|
|
49
|
+
entityInfoList.length > 0 && (
|
|
50
|
+
<div className={`${prefixCls}-info-bar`}>
|
|
51
|
+
<div className={`${prefixCls}-main-entity-info`}>
|
|
52
|
+
{entityInfoList.slice(0, 4).map(dimension => {
|
|
53
|
+
return (
|
|
54
|
+
<div className={`${prefixCls}-info-item`} key={dimension.bizName}>
|
|
55
|
+
<div className={`${prefixCls}-info-name`}>{dimension.name}:</div>
|
|
56
|
+
{dimension.bizName.includes('photo') ? (
|
|
57
|
+
<img width={40} height={40} src={dimension.value} alt="" />
|
|
58
|
+
) : (
|
|
59
|
+
<div className={`${prefixCls}-info-value`}>{dimension.value}</div>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
})}
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
{queryMode === 'TAG_LIST_FILTER' && (
|
|
68
|
+
<div className={`${prefixCls}-info-bar`}>
|
|
69
|
+
<div className={`${prefixCls}-main-entity-info`}>
|
|
70
|
+
<div className={`${prefixCls}-info-item`}>
|
|
71
|
+
<div className={`${prefixCls}-info-name`}>数据模型:</div>
|
|
72
|
+
<div className={`${prefixCls}-info-value`}>{modelName}</div>
|
|
73
|
+
</div>
|
|
74
|
+
<div className={`${prefixCls}-info-item`}>
|
|
75
|
+
<div className={`${prefixCls}-info-name`}>时间:</div>
|
|
76
|
+
<div className={`${prefixCls}-info-value`}>
|
|
77
|
+
{startDate === endDate ? startDate : `${startDate} ~ ${endDate}`}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
{dimensionFilters && dimensionFilters?.length > 0 && (
|
|
81
|
+
<div className={`${prefixCls}-info-item`}>
|
|
82
|
+
<div className={`${prefixCls}-info-name`}>筛选条件:</div>
|
|
83
|
+
{dimensionFilters.map((filter, index) => (
|
|
84
|
+
<div className={`${prefixCls}-info-value`}>
|
|
85
|
+
<span>{filter.name}:</span>
|
|
86
|
+
<span>
|
|
87
|
+
{Array.isArray(filter.value) ? filter.value.join('、') : filter.value}
|
|
88
|
+
</span>
|
|
89
|
+
{index !== dimensionFilters.length - 1 && <span>、</span>}
|
|
90
|
+
</div>
|
|
91
|
+
))}
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
<div className={`${prefixCls}-children`}>{children}</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default Message;
|