@baishuyun/chat-sdk 0.0.10 → 0.0.11
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/CHANGELOG.md +8 -0
- package/dist/chat-sdk.js +18664 -18155
- package/dist/chat-sdk.js.map +1 -1
- package/dist/chat-sdk.umd.cjs +170 -170
- package/dist/chat-sdk.umd.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/package.json +4 -4
- package/src/chat.tsx +20 -1
- package/src/components/biz-comp/FieldChecker.tsx +23 -2
- package/src/components/biz-comp/FieldCheckerListMsg.tsx +18 -3
- package/src/components/biz-comp/chat-client.tsx +11 -6
- package/src/components/biz-comp/field-icon.tsx +1 -1
- package/src/components/biz-comp/preview-message.tsx +7 -0
- package/src/components/bs-ui/bs-icons.tsx +15 -1
- package/src/components/bs-ui/chat-area-header.tsx +12 -2
- package/src/components/bs-ui/collapsible-txt-msg.tsx +1 -1
- package/src/components/bs-ui/icon-btn.tsx +11 -4
- package/src/components/bs-ui/line-checker.tsx +26 -14
- package/src/components/bs-ui/previewer-header.tsx +1 -1
- package/src/components/bs-ui/primary-confirm-btn.tsx +10 -5
- package/src/components/bs-ui/primary-entry-btn.tsx +1 -1
- package/src/components/bs-ui/square-checker.tsx +62 -0
- package/src/const/index.ts +7 -1
- package/src/index.tsx +1 -1
- package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/components/create-form-confirm.tsx +3 -2
- package/src/plugins/form-builder-plugin/components/entry-btn.tsx +44 -0
- package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/components/msg-part.tsx +44 -27
- package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/index.ts +16 -5
- package/src/plugins/form-filling-plugin/components/FormFillingOpeningLines.tsx +1 -0
- package/src/plugins/form-filling-plugin/components/avatar.tsx +9 -3
- package/src/plugins/form-filling-plugin/index.ts +9 -0
- package/src/plugins/report-query-plugin/components/query-msg-part.tsx +1 -0
- package/src/plugins/report-query-plugin/components/query-opening-lines.tsx +30 -0
- package/src/plugins/report-query-plugin/components/result-cards/DataTableCard.tsx +0 -1
- package/src/plugins/report-query-plugin/index.ts +11 -0
- package/src/plugins/report-query-plugin/utils/build-dash-component.ts +122 -0
- package/src/plugins/report-query-plugin/utils/create-default-dash-styles.ts +29 -0
- package/src/plugins/report-query-plugin/utils/create-default-widget-attr-list.ts +59 -0
- package/src/plugins/report-query-plugin/utils/field-enhance.ts +62 -0
- package/src/plugins/report-query-plugin/utils/index.tsx +109 -0
- package/src/stories/PrimaryConfirmBtn.stories.tsx +7 -0
- package/src/stories/SquareChecker.stories.tsx +96 -0
- package/src/style.css +4 -0
- package/src/plugins/mcp-form-builder-plugin/components/entry-btn.tsx +0 -9
- package/src/plugins/report-query-plugin/utils.tsx +0 -379
- /package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/components/follow-up.tsx +0 -0
- /package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/const/index.ts +0 -0
- /package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/hooks/index.ts +0 -0
- /package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/hooks/use-fields-confirmed.ts +0 -0
- /package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/types.ts +0 -0
- /package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/utils/index.ts +0 -0
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IQueryResult,
|
|
3
|
-
IQueryResultPreviewerProps,
|
|
4
|
-
IQueryResultCreateParams,
|
|
5
|
-
IDashComponent,
|
|
6
|
-
IDashComponentField,
|
|
7
|
-
IDashComponentFilterCond,
|
|
8
|
-
IFilterField,
|
|
9
|
-
IQueryResultField,
|
|
10
|
-
FieldType,
|
|
11
|
-
} from '@baishuyun/types';
|
|
12
|
-
import { XFieldEnhance, MetricEnhance } from './utils/field-enhance';
|
|
13
|
-
import { getFieldIcon } from './utils/get-field-icon';
|
|
14
|
-
|
|
15
|
-
/** 生成唯一的 widget ID */
|
|
16
|
-
const generateWidgetId = (): string => {
|
|
17
|
-
return `_widget_${Date.now()}`;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** 将 IQueryResultField 转换为 IDashComponentField */
|
|
21
|
-
const convertField = (
|
|
22
|
-
field: IQueryResultField,
|
|
23
|
-
formId: string,
|
|
24
|
-
index: number
|
|
25
|
-
): IDashComponentField => {
|
|
26
|
-
return {
|
|
27
|
-
id: field.id ?? index,
|
|
28
|
-
name: field.name,
|
|
29
|
-
text: field.title,
|
|
30
|
-
type: field.type,
|
|
31
|
-
title: field.title,
|
|
32
|
-
form: formId,
|
|
33
|
-
isEditable: field.isEditable ?? false,
|
|
34
|
-
icon: getFieldIcon(field.type as FieldType),
|
|
35
|
-
group: field.group || 'dimension',
|
|
36
|
-
formula: '',
|
|
37
|
-
tag: `f_${Date.now() + index}`,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/** 将 IFilterField 转换为 IDashComponentFilterCond */
|
|
42
|
-
const convertFilterField = (filter: IFilterField, formId: string): IDashComponentFilterCond => {
|
|
43
|
-
return {
|
|
44
|
-
title: filter.title,
|
|
45
|
-
name: filter.name,
|
|
46
|
-
type: filter.type,
|
|
47
|
-
entryId: formId,
|
|
48
|
-
form: formId,
|
|
49
|
-
field: filter.name,
|
|
50
|
-
method: filter.method,
|
|
51
|
-
value: filter.value ?? [],
|
|
52
|
-
hasEmpty: filter.method !== 'not_empty',
|
|
53
|
-
fieldvalueMode: 'widget',
|
|
54
|
-
fieldvalueName: '',
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const createLabelField = (formId: string): IDashComponentField => {
|
|
59
|
-
return {
|
|
60
|
-
name: 'label',
|
|
61
|
-
text: '标题',
|
|
62
|
-
type: 'textarea',
|
|
63
|
-
title: '标题',
|
|
64
|
-
form: formId,
|
|
65
|
-
isEditable: true,
|
|
66
|
-
icon: getFieldIcon('textarea'),
|
|
67
|
-
group: 'dimension',
|
|
68
|
-
formula: '',
|
|
69
|
-
tag: `f_${Date.now()}`,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/** 创建默认样式配置 */
|
|
74
|
-
const createDefaultStyles = () => ({
|
|
75
|
-
theme: {
|
|
76
|
-
name: 'preset_style_light_1',
|
|
77
|
-
highLightColor: '#0265FF',
|
|
78
|
-
palette: 'preset_1',
|
|
79
|
-
gradation: 'preset_map_1',
|
|
80
|
-
},
|
|
81
|
-
background: {
|
|
82
|
-
type: 'color',
|
|
83
|
-
color: '#F4F6F9',
|
|
84
|
-
},
|
|
85
|
-
widget: {
|
|
86
|
-
theme: {
|
|
87
|
-
color: '#E9E9E9',
|
|
88
|
-
icon: 1,
|
|
89
|
-
cardName: 'preset_metric_1',
|
|
90
|
-
},
|
|
91
|
-
background: {
|
|
92
|
-
type: 'color',
|
|
93
|
-
color: '#FFFFFF',
|
|
94
|
-
},
|
|
95
|
-
fontSetting: {
|
|
96
|
-
titleColor: '#1F2D3D',
|
|
97
|
-
headColor: '#5E6D82',
|
|
98
|
-
textColor: '#1F2D3D',
|
|
99
|
-
textAlign: 'default',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
/** 创建默认的 attrList 配置 */
|
|
105
|
-
const createDefaultAttrList = () => ({
|
|
106
|
-
title: {
|
|
107
|
-
show: false,
|
|
108
|
-
text: '标题内容',
|
|
109
|
-
textStyle: {
|
|
110
|
-
color: '#333333',
|
|
111
|
-
fontStyle: 'normal',
|
|
112
|
-
fontSize: 16,
|
|
113
|
-
fontWeight: 'normal',
|
|
114
|
-
},
|
|
115
|
-
left: 'left',
|
|
116
|
-
borderColor: 'transparent',
|
|
117
|
-
borderWidth: 2,
|
|
118
|
-
padding: 5,
|
|
119
|
-
onBorderColor: false,
|
|
120
|
-
borderRadius: 0,
|
|
121
|
-
backgroundColor: 'transparent',
|
|
122
|
-
},
|
|
123
|
-
orient: 'vertical',
|
|
124
|
-
legend: {
|
|
125
|
-
textStyle: {
|
|
126
|
-
fontStyle: 'normal',
|
|
127
|
-
fontSize: 10,
|
|
128
|
-
fontWeight: 'normal',
|
|
129
|
-
},
|
|
130
|
-
itemWidth: 12,
|
|
131
|
-
itemHeight: 12,
|
|
132
|
-
position: 'bottom',
|
|
133
|
-
type: 'plain',
|
|
134
|
-
padding: 10,
|
|
135
|
-
},
|
|
136
|
-
itemStyle: {
|
|
137
|
-
opacity: 0.7,
|
|
138
|
-
borderWidth: 2,
|
|
139
|
-
},
|
|
140
|
-
tooltip: {
|
|
141
|
-
show: true,
|
|
142
|
-
triggerOn: 'mousemove',
|
|
143
|
-
position: '0',
|
|
144
|
-
seriesName: '',
|
|
145
|
-
formatter: '1',
|
|
146
|
-
opacity: 1,
|
|
147
|
-
textStyle: {
|
|
148
|
-
color: '#FFFFFF',
|
|
149
|
-
fontStyle: 'normal',
|
|
150
|
-
fontSize: 14,
|
|
151
|
-
fontWeight: 'normal',
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
label: {
|
|
155
|
-
fontStyle: 'normal',
|
|
156
|
-
fontWeight: 'normal',
|
|
157
|
-
fontSize: 10,
|
|
158
|
-
position: 'top',
|
|
159
|
-
formatter: '1',
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
/** 将 IQueryResult 转换为 IQueryResultPreviewerProps */
|
|
164
|
-
export const queryResult2previewerProps = (
|
|
165
|
-
result: IQueryResult,
|
|
166
|
-
entryId: string
|
|
167
|
-
): IQueryResultPreviewerProps => {
|
|
168
|
-
const appId = result.appID || '';
|
|
169
|
-
const widgetId = generateWidgetId();
|
|
170
|
-
const formId = result.formIds?.[0] || '';
|
|
171
|
-
const componentName = result.title || '未命名数据表';
|
|
172
|
-
|
|
173
|
-
// 转换字段
|
|
174
|
-
const fields: IDashComponentField[] =
|
|
175
|
-
result.fields?.map((field, index) => convertField(field, formId, index)) || [];
|
|
176
|
-
|
|
177
|
-
// 转换过滤条件
|
|
178
|
-
const filterConds: IDashComponentFilterCond[] =
|
|
179
|
-
result.filter?.conds?.map((cond) => convertFilterField(cond, formId)) || [];
|
|
180
|
-
const filterRel = result.filter?.rel || 'and';
|
|
181
|
-
// 创建组件配置
|
|
182
|
-
const component: IDashComponent = {
|
|
183
|
-
title: componentName,
|
|
184
|
-
forms: result.formIds || [],
|
|
185
|
-
|
|
186
|
-
hasExport: false,
|
|
187
|
-
widgetId,
|
|
188
|
-
palette: 'default',
|
|
189
|
-
chart_label: { enable: true },
|
|
190
|
-
width: 30,
|
|
191
|
-
height: 20,
|
|
192
|
-
posX: 0,
|
|
193
|
-
posY: 0,
|
|
194
|
-
formulas: result.formulas || [],
|
|
195
|
-
widgetNameAlias: widgetId,
|
|
196
|
-
permission: 'all',
|
|
197
|
-
triggers: [],
|
|
198
|
-
defaultSort: [],
|
|
199
|
-
reportAuth: [],
|
|
200
|
-
enableRowEdit: false,
|
|
201
|
-
attrList: createDefaultAttrList(),
|
|
202
|
-
batchmenu: { enable: true, set: [] },
|
|
203
|
-
itemSeleable: true,
|
|
204
|
-
itemMarekerable: true,
|
|
205
|
-
mapScale: 14,
|
|
206
|
-
itemDataable: true,
|
|
207
|
-
scopefields: [],
|
|
208
|
-
menu: { enable: true, set: [] },
|
|
209
|
-
onSwitchButton: false,
|
|
210
|
-
BtnName: '点击操作',
|
|
211
|
-
FunctionBtn: 'itemManualData',
|
|
212
|
-
dryRun: true,
|
|
213
|
-
DataMode: false,
|
|
214
|
-
mapfields: [],
|
|
215
|
-
tFields: [],
|
|
216
|
-
bgColorFilter: [],
|
|
217
|
-
cardConfig: { widget_id: '{}' },
|
|
218
|
-
cardConfigFields: [],
|
|
219
|
-
selectFields: [],
|
|
220
|
-
mapFields: [],
|
|
221
|
-
selectArg: {},
|
|
222
|
-
thresholds: [],
|
|
223
|
-
guideline: [],
|
|
224
|
-
treeFields: {},
|
|
225
|
-
batchmenuAuth: {},
|
|
226
|
-
|
|
227
|
-
...result,
|
|
228
|
-
|
|
229
|
-
xFields: (result.xFields || []).map((x, index) => {
|
|
230
|
-
return XFieldEnhance(x, result.type, index);
|
|
231
|
-
}),
|
|
232
|
-
|
|
233
|
-
yFields: (result.yFields || []).map((y, index) => {
|
|
234
|
-
return XFieldEnhance(y, result.type, index);
|
|
235
|
-
}),
|
|
236
|
-
|
|
237
|
-
metrics: (result.metrics || []).map((m, index) => {
|
|
238
|
-
return MetricEnhance(m, result.type, index);
|
|
239
|
-
}),
|
|
240
|
-
|
|
241
|
-
fields,
|
|
242
|
-
filter: {
|
|
243
|
-
cond: filterConds,
|
|
244
|
-
rel: filterRel,
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
console.log(component, result.formIds);
|
|
249
|
-
|
|
250
|
-
const components: Record<string, IDashComponent> = {
|
|
251
|
-
[widgetId]: component,
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
const styles = createDefaultStyles();
|
|
255
|
-
|
|
256
|
-
// 创建 entry 配置(用于 allComponentDash)
|
|
257
|
-
const entry = {
|
|
258
|
-
appId,
|
|
259
|
-
entryId,
|
|
260
|
-
hasLazyLoad: true,
|
|
261
|
-
styles,
|
|
262
|
-
autoLoad: true,
|
|
263
|
-
rel: filterRel,
|
|
264
|
-
cacheFilter: 0,
|
|
265
|
-
isMobileFilteringButton: 0 as const,
|
|
266
|
-
showFilter: 0 as const,
|
|
267
|
-
components,
|
|
268
|
-
mode: 'preview' as const,
|
|
269
|
-
dryRun: true,
|
|
270
|
-
name: result.title || '未命名分析报表',
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
return {
|
|
274
|
-
appId,
|
|
275
|
-
entryId,
|
|
276
|
-
hasLazyLoad: true,
|
|
277
|
-
styles,
|
|
278
|
-
autoLoad: true,
|
|
279
|
-
rel: 'and',
|
|
280
|
-
cacheFilter: 0,
|
|
281
|
-
isMobileFilteringButton: 1,
|
|
282
|
-
showFilter: 0,
|
|
283
|
-
components,
|
|
284
|
-
mode: 'preview',
|
|
285
|
-
showType: 'popup',
|
|
286
|
-
name: result.title || '未命名分析报表',
|
|
287
|
-
allComponentDash: {
|
|
288
|
-
entry,
|
|
289
|
-
},
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export const queryResult2createParams = (
|
|
294
|
-
result: IQueryResult,
|
|
295
|
-
entryId: string
|
|
296
|
-
): IQueryResultCreateParams => {
|
|
297
|
-
const appId = result.appID || '';
|
|
298
|
-
const widgetId = generateWidgetId();
|
|
299
|
-
const formId = result.formIds?.[0] || '';
|
|
300
|
-
const componentName = result.title || '未命名数据表';
|
|
301
|
-
|
|
302
|
-
const labelField = createLabelField(formId);
|
|
303
|
-
const fields: IDashComponentField[] = [labelField].concat(
|
|
304
|
-
result.fields?.map((field, index) => convertField(field, formId, index)) || []
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
const filterConds: IDashComponentFilterCond[] =
|
|
308
|
-
result.filter?.conds?.map((cond) => convertFilterField(cond, formId)) || [];
|
|
309
|
-
const filterRel = result.filter?.rel || 'and';
|
|
310
|
-
|
|
311
|
-
const widget: IDashComponent = {
|
|
312
|
-
title: componentName,
|
|
313
|
-
forms: result.formIds || [],
|
|
314
|
-
type: result.type,
|
|
315
|
-
xFields: (result.xFields || []).map((x, index) => {
|
|
316
|
-
return XFieldEnhance(x, result.type, index);
|
|
317
|
-
}),
|
|
318
|
-
|
|
319
|
-
yFields: (result.yFields || []).map((y, index) => {
|
|
320
|
-
return XFieldEnhance(y, result.type, index);
|
|
321
|
-
}),
|
|
322
|
-
|
|
323
|
-
metrics: (result.metrics || []).map((m, index) => {
|
|
324
|
-
return MetricEnhance(m, result.type, index);
|
|
325
|
-
}),
|
|
326
|
-
|
|
327
|
-
hasExport: false,
|
|
328
|
-
widgetId,
|
|
329
|
-
palette: 'default',
|
|
330
|
-
chart_label: { enable: true },
|
|
331
|
-
width: 30,
|
|
332
|
-
height: 20,
|
|
333
|
-
posX: 0,
|
|
334
|
-
posY: 0,
|
|
335
|
-
fields,
|
|
336
|
-
formulas: result.formulas || [],
|
|
337
|
-
widgetNameAlias: widgetId,
|
|
338
|
-
permission: 'all',
|
|
339
|
-
triggers: [],
|
|
340
|
-
filter: {
|
|
341
|
-
cond: filterConds,
|
|
342
|
-
rel: filterRel,
|
|
343
|
-
},
|
|
344
|
-
defaultSort: [],
|
|
345
|
-
reportAuth: [],
|
|
346
|
-
enableRowEdit: false,
|
|
347
|
-
attrList: createDefaultAttrList(),
|
|
348
|
-
batchmenu: { enable: true, set: [] },
|
|
349
|
-
itemSeleable: true,
|
|
350
|
-
itemMarekerable: true,
|
|
351
|
-
mapScale: 14,
|
|
352
|
-
itemDataable: true,
|
|
353
|
-
scopefields: [],
|
|
354
|
-
menu: { enable: true, set: [] },
|
|
355
|
-
onSwitchButton: false,
|
|
356
|
-
BtnName: '点击操作',
|
|
357
|
-
FunctionBtn: 'itemManualData',
|
|
358
|
-
DataMode: false,
|
|
359
|
-
mapfields: [],
|
|
360
|
-
tFields: [],
|
|
361
|
-
bgColorFilter: [],
|
|
362
|
-
cardConfig: { widget_id: {} },
|
|
363
|
-
cardConfigFields: [],
|
|
364
|
-
selectFields: [],
|
|
365
|
-
mapFields: [],
|
|
366
|
-
selectArg: {},
|
|
367
|
-
thresholds: [],
|
|
368
|
-
guideline: [],
|
|
369
|
-
treeFields: {},
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
return {
|
|
373
|
-
appId,
|
|
374
|
-
entryId,
|
|
375
|
-
widget,
|
|
376
|
-
datahelpers_remove: [],
|
|
377
|
-
datahelpers: {},
|
|
378
|
-
};
|
|
379
|
-
};
|
/package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/components/follow-up.tsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/plugins/{mcp-form-builder-plugin → form-builder-plugin}/hooks/use-fields-confirmed.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|