bi-sdk-react 0.0.72 → 0.0.74
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/es/js/bi-sdk.es.js +46 -46
- package/dist/types/components/panel/PaneHeader.d.ts +2 -2
- package/dist/types/components/plugins/@antd/items/CapsuleRender.d.ts +1 -1
- package/dist/types/components/typing.d.ts +22 -1
- package/dist/umd/js/bi-sdk.umd.min.js +34 -34
- package/package.json +1 -1
- package/src/components/icon/IconFont.tsx +1 -1
- package/src/components/panel/ComponentPanel.tsx +564 -13
- package/src/components/panel/PaneHeader.tsx +14 -10
- package/src/components/plugins/@antd/index.ts +7 -0
- package/src/components/plugins/@antd/items/CapsuleRender.tsx +4 -2
- package/src/components/plugins/@antd/items/CheckboxRender.tsx +3 -1
- package/src/components/plugins/@antd/items/DatePickerRender.tsx +6 -2
- package/src/components/plugins/@antd/items/InputNumberRender.tsx +3 -0
- package/src/components/plugins/@antd/items/InputRender.tsx +3 -0
- package/src/components/plugins/@antd/items/SelectRender.tsx +3 -0
- package/src/components/plugins/@antd/items/SwitchRender.tsx +3 -0
- package/src/components/typing.ts +35 -5
- package/src/example.tsx +33 -4
|
@@ -283,6 +283,7 @@ export const InputPlugin: PluginType = {
|
|
|
283
283
|
},
|
|
284
284
|
cascadeIds: [],
|
|
285
285
|
},
|
|
286
|
+
events: [{name: "内容变化", handler: "change"}]
|
|
286
287
|
};
|
|
287
288
|
|
|
288
289
|
export const InputNumberPlugin: PluginType = {
|
|
@@ -307,6 +308,7 @@ export const InputNumberPlugin: PluginType = {
|
|
|
307
308
|
},
|
|
308
309
|
cascadeIds: [],
|
|
309
310
|
},
|
|
311
|
+
events: [{name: "内容变化", handler: "change"}]
|
|
310
312
|
};
|
|
311
313
|
|
|
312
314
|
export const SelectPlugin: PluginType = {
|
|
@@ -329,6 +331,7 @@ export const SelectPlugin: PluginType = {
|
|
|
329
331
|
},
|
|
330
332
|
cascadeIds: [],
|
|
331
333
|
},
|
|
334
|
+
events: [{name: "内容变化", handler: "change"}]
|
|
332
335
|
};
|
|
333
336
|
|
|
334
337
|
export const CapsulePlugin: PluginType = {
|
|
@@ -351,6 +354,7 @@ export const CapsulePlugin: PluginType = {
|
|
|
351
354
|
},
|
|
352
355
|
cascadeIds: [],
|
|
353
356
|
},
|
|
357
|
+
events: [{name: "内容变化", handler: "change"}]
|
|
354
358
|
};
|
|
355
359
|
|
|
356
360
|
export const CheckboxPlugin: PluginType = {
|
|
@@ -372,6 +376,7 @@ export const CheckboxPlugin: PluginType = {
|
|
|
372
376
|
},
|
|
373
377
|
cascadeIds: [],
|
|
374
378
|
},
|
|
379
|
+
events: [{name: "内容变化", handler: "change"}]
|
|
375
380
|
};
|
|
376
381
|
|
|
377
382
|
export const DatePickerPlugin: PluginType = {
|
|
@@ -391,6 +396,7 @@ export const DatePickerPlugin: PluginType = {
|
|
|
391
396
|
},
|
|
392
397
|
cascadeIds: [],
|
|
393
398
|
},
|
|
399
|
+
events: [{name: "内容变化", handler: "change"}]
|
|
394
400
|
};
|
|
395
401
|
|
|
396
402
|
export const SwitchPlugin: PluginType = {
|
|
@@ -409,6 +415,7 @@ export const SwitchPlugin: PluginType = {
|
|
|
409
415
|
},
|
|
410
416
|
cascadeIds: [],
|
|
411
417
|
},
|
|
418
|
+
events: [{name: "内容变化", handler: "change"}]
|
|
412
419
|
};
|
|
413
420
|
|
|
414
421
|
export const SpacePlugin: PluginType = {
|
|
@@ -2,11 +2,11 @@ import { Radio, type RadioGroupProps } from "antd";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import { PageContext } from "../../../context/PageContext";
|
|
4
4
|
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
5
|
-
|
|
5
|
+
import { useEvent } from "../../../hooks/event";
|
|
6
6
|
|
|
7
7
|
export type CapsuleRenderProps = {
|
|
8
8
|
var?: string;
|
|
9
|
-
size?: RadioGroupProps[
|
|
9
|
+
size?: RadioGroupProps["size"];
|
|
10
10
|
options?: { label: string; value: any }[];
|
|
11
11
|
item: SchemaItemType;
|
|
12
12
|
onChange?: (v: any) => void;
|
|
@@ -23,10 +23,12 @@ export const CapsuleRender: React.FC<CapsuleRenderProps> = ({
|
|
|
23
23
|
className,
|
|
24
24
|
}) => {
|
|
25
25
|
const { handleCallback, setVar } = useContext(PageContext);
|
|
26
|
+
const { handleEvent } = useEvent(item);
|
|
26
27
|
const change = (v: any) => {
|
|
27
28
|
if (onChange) onChange(v);
|
|
28
29
|
if (item && varName) setVar(item, varName, v);
|
|
29
30
|
handleCallback(item);
|
|
31
|
+
handleEvent("change", v);
|
|
30
32
|
};
|
|
31
33
|
return (
|
|
32
34
|
<span id={id}>
|
|
@@ -2,7 +2,7 @@ import { Checkbox } from "antd";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import { PageContext } from "../../../context/PageContext";
|
|
4
4
|
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
5
|
-
|
|
5
|
+
import { useEvent } from "../../../hooks/event";
|
|
6
6
|
|
|
7
7
|
export type CheckboxRenderProps = {
|
|
8
8
|
var?: string;
|
|
@@ -25,6 +25,7 @@ export const CheckboxRender: React.FC<CheckboxRenderProps> = ({
|
|
|
25
25
|
className,
|
|
26
26
|
}) => {
|
|
27
27
|
const { handleCallback, setVar } = useContext(PageContext);
|
|
28
|
+
const { handleEvent } = useEvent(item);
|
|
28
29
|
const groupStyle: React.CSSProperties = {
|
|
29
30
|
...style,
|
|
30
31
|
display: layout === "grid" ? "grid" : "flex",
|
|
@@ -37,6 +38,7 @@ export const CheckboxRender: React.FC<CheckboxRenderProps> = ({
|
|
|
37
38
|
if (onChange) onChange(v);
|
|
38
39
|
if (item && varName) setVar(item, varName, v);
|
|
39
40
|
handleCallback(item);
|
|
41
|
+
handleEvent("change", v);
|
|
40
42
|
};
|
|
41
43
|
return (
|
|
42
44
|
<span id={id}>
|
|
@@ -3,7 +3,7 @@ import dayjs, { Dayjs } from "dayjs";
|
|
|
3
3
|
import React, { useContext } from "react";
|
|
4
4
|
import { PageContext } from "../../../context/PageContext";
|
|
5
5
|
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
6
|
-
|
|
6
|
+
import { useEvent } from "../../../hooks/event";
|
|
7
7
|
|
|
8
8
|
export type DatePickerRenderProps = {
|
|
9
9
|
var?: string;
|
|
@@ -30,10 +30,12 @@ export const DatePickerRender: React.FC<DatePickerRenderProps> = ({
|
|
|
30
30
|
className,
|
|
31
31
|
}) => {
|
|
32
32
|
const { handleCallback, setVar } = useContext(PageContext);
|
|
33
|
+
const { handleEvent } = useEvent(item);
|
|
33
34
|
const change = (val?: string | [string, string]) => {
|
|
34
35
|
if (onChange) onChange(val);
|
|
35
36
|
if (item && varName) setVar(item, varName, val as any);
|
|
36
37
|
handleCallback(item);
|
|
38
|
+
handleEvent("change", val);
|
|
37
39
|
};
|
|
38
40
|
if (type === "time") {
|
|
39
41
|
const v =
|
|
@@ -90,7 +92,9 @@ export const DatePickerRender: React.FC<DatePickerRenderProps> = ({
|
|
|
90
92
|
showTime={showTime}
|
|
91
93
|
onChange={(d) =>
|
|
92
94
|
change(
|
|
93
|
-
d && d[0] && d[1]
|
|
95
|
+
d && d[0] && d[1]
|
|
96
|
+
? [d[0].format(fmt), d[1].format(fmt)]
|
|
97
|
+
: undefined,
|
|
94
98
|
)
|
|
95
99
|
}
|
|
96
100
|
style={{ ...(item?.style || {}), ...style }}
|
|
@@ -2,6 +2,7 @@ import { InputNumber, type InputNumberProps } from "antd";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import { PageContext } from "../../../context/PageContext";
|
|
4
4
|
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
5
|
+
import { useEvent } from "../../../hooks/event";
|
|
5
6
|
|
|
6
7
|
export type InputNumberRenderProps = {
|
|
7
8
|
var?: string;
|
|
@@ -33,10 +34,12 @@ export const InputNumberRender: React.FC<InputNumberRenderProps> = ({
|
|
|
33
34
|
className,
|
|
34
35
|
}) => {
|
|
35
36
|
const { handleCallback, setVar } = useContext(PageContext);
|
|
37
|
+
const { handleEvent } = useEvent(item);
|
|
36
38
|
const change = (v?: number) => {
|
|
37
39
|
if (onChange) onChange(v);
|
|
38
40
|
if (item && varName) setVar(item, varName, v);
|
|
39
41
|
handleCallback(item);
|
|
42
|
+
handleEvent("change", v);
|
|
40
43
|
};
|
|
41
44
|
return (
|
|
42
45
|
<InputNumber
|
|
@@ -2,6 +2,7 @@ import { Input, type InputProps } from "antd";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import { PageContext } from "../../../context/PageContext";
|
|
4
4
|
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
5
|
+
import { useEvent } from "../../../hooks/event";
|
|
5
6
|
|
|
6
7
|
export type InputRenderProps = {
|
|
7
8
|
var?: string;
|
|
@@ -34,9 +35,11 @@ export const InputRender: React.FC<InputRenderProps> = ({
|
|
|
34
35
|
className,
|
|
35
36
|
}) => {
|
|
36
37
|
const { handleCallback, setVar } = useContext(PageContext);
|
|
38
|
+
const { handleEvent } = useEvent(item);
|
|
37
39
|
const change = (v: string) => {
|
|
38
40
|
if (onChange) onChange(v);
|
|
39
41
|
if (item && varName) setVar(item, varName, v);
|
|
42
|
+
handleEvent("change", v);
|
|
40
43
|
};
|
|
41
44
|
const searchClick = () => {
|
|
42
45
|
if (onSearch) onSearch(value || "");
|
|
@@ -2,6 +2,7 @@ import { Select, type SelectProps } from "antd";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import { PageContext } from "../../../context/PageContext";
|
|
4
4
|
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
5
|
+
import { useEvent } from "../../../hooks/event";
|
|
5
6
|
|
|
6
7
|
export type SelectRenderProps = {
|
|
7
8
|
var?: string;
|
|
@@ -30,10 +31,12 @@ export const SelectRender: React.FC<SelectRenderProps> = ({
|
|
|
30
31
|
className,
|
|
31
32
|
}) => {
|
|
32
33
|
const { handleCallback, setVar } = useContext(PageContext);
|
|
34
|
+
const { handleEvent } = useEvent(item);
|
|
33
35
|
const change = (v: any) => {
|
|
34
36
|
if (onChange) onChange(v);
|
|
35
37
|
if (item && varName) setVar(item, varName, v);
|
|
36
38
|
handleCallback(item);
|
|
39
|
+
handleEvent("change", v);
|
|
37
40
|
};
|
|
38
41
|
return (
|
|
39
42
|
<Select
|
|
@@ -2,6 +2,7 @@ import { Switch, type SwitchProps } from "antd";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import { PageContext } from "../../../context/PageContext";
|
|
4
4
|
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
5
|
+
import { useEvent } from "../../../hooks/event";
|
|
5
6
|
|
|
6
7
|
export type SwitchRenderProps = {
|
|
7
8
|
var?: string;
|
|
@@ -28,10 +29,12 @@ export const SwitchRender: React.FC<SwitchRenderProps> = ({
|
|
|
28
29
|
className,
|
|
29
30
|
}) => {
|
|
30
31
|
const { handleCallback, setVar } = useContext(PageContext);
|
|
32
|
+
const { handleEvent } = useEvent(item);
|
|
31
33
|
const change = (v: boolean) => {
|
|
32
34
|
if (onChange) onChange(v);
|
|
33
35
|
if (item && varName) setVar(item, varName, v);
|
|
34
36
|
handleCallback(item);
|
|
37
|
+
handleEvent("change", v);
|
|
35
38
|
};
|
|
36
39
|
return (
|
|
37
40
|
<span>
|
package/src/components/typing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { MouseEventHandler } from "react";
|
|
1
|
+
import React, { Key, MouseEventHandler } from "react";
|
|
2
2
|
|
|
3
3
|
export type ChatRequestType = {
|
|
4
4
|
message: string;
|
|
@@ -61,8 +61,31 @@ export type ChatMessageType = {
|
|
|
61
61
|
sending?: boolean;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
export type ExampleItemType = {
|
|
65
|
+
id: Key;
|
|
66
|
+
name: string;
|
|
67
|
+
description?: string | null;
|
|
68
|
+
cover?: string;
|
|
69
|
+
item: SchemaItemType;
|
|
70
|
+
};
|
|
71
|
+
export type TemplateItemType = {
|
|
72
|
+
id: Key;
|
|
73
|
+
name: string;
|
|
74
|
+
description?: string | null;
|
|
75
|
+
cover?: string;
|
|
76
|
+
schema: PageSchema;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type PaginationType<T> = {
|
|
80
|
+
total: number;
|
|
81
|
+
list: T[];
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
export type FetchType = {
|
|
65
85
|
upload?: (file: File) => Promise<{ id: string; name: string }>;
|
|
86
|
+
exampleList?: (current?: number, size?: number, keyword?: string) => Promise<ExampleItemType[] | PaginationType<ExampleItemType>>;
|
|
87
|
+
templateList?: (current?: number, size?: number, keyword?: string) => Promise<Omit<TemplateItemType, "schema">[] | PaginationType<Omit<TemplateItemType, "schema">>>;
|
|
88
|
+
templateDetail?: (id: Key) => Promise<TemplateItemType>;
|
|
66
89
|
ai?: {
|
|
67
90
|
chat: (
|
|
68
91
|
bizType: string,
|
|
@@ -75,11 +98,18 @@ export type FetchType = {
|
|
|
75
98
|
bizId: string,
|
|
76
99
|
) => Promise<ChatConversationType[]>;
|
|
77
100
|
activateConversation?: (conversationId: string) => Promise<boolean>;
|
|
78
|
-
messageList: (
|
|
101
|
+
messageList: (
|
|
102
|
+
conversationId: string,
|
|
103
|
+
prevId?: string,
|
|
104
|
+
) => Promise<ChatMessageType[]>;
|
|
79
105
|
removeConversation: (conversationId: string) => Promise<boolean>;
|
|
80
106
|
removeMessage: (messageId: string) => Promise<boolean>;
|
|
81
107
|
};
|
|
82
|
-
dataset?: (
|
|
108
|
+
dataset?: (
|
|
109
|
+
dataSetId: string,
|
|
110
|
+
params: Record<string, any>,
|
|
111
|
+
aiPrompt?: string,
|
|
112
|
+
) => Promise<any>;
|
|
83
113
|
};
|
|
84
114
|
|
|
85
115
|
export type HtmlBaseProps = {
|
|
@@ -109,7 +139,7 @@ export type SchemaItemType = {
|
|
|
109
139
|
events?: {
|
|
110
140
|
name: string;
|
|
111
141
|
script: string;
|
|
112
|
-
}[]
|
|
142
|
+
}[];
|
|
113
143
|
};
|
|
114
144
|
|
|
115
145
|
export type PluginType = {
|
|
@@ -198,7 +228,7 @@ export type PageSchema = {
|
|
|
198
228
|
aiPrompt?: string;
|
|
199
229
|
output: DataSetOutput;
|
|
200
230
|
dependencies?: string[];
|
|
201
|
-
}[]
|
|
231
|
+
}[];
|
|
202
232
|
};
|
|
203
233
|
|
|
204
234
|
export type EnvType = {
|
package/src/example.tsx
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
DatasetAddFunction,
|
|
16
16
|
DatasetSelectorFunction,
|
|
17
17
|
FieldType,
|
|
18
|
+
PageSchema,
|
|
19
|
+
SchemaItemType,
|
|
18
20
|
} from "./components/typing";
|
|
19
21
|
import { uuid } from "./components/utils";
|
|
20
22
|
|
|
@@ -194,8 +196,7 @@ export const Example: React.FC = () => {
|
|
|
194
196
|
),
|
|
195
197
|
removeConversation: async (conversationId) =>
|
|
196
198
|
Promise.resolve(true),
|
|
197
|
-
removeMessage: async (messageId) =>
|
|
198
|
-
Promise.resolve(true),
|
|
199
|
+
removeMessage: async (messageId) => Promise.resolve(true),
|
|
199
200
|
},
|
|
200
201
|
dataset: async (dataSetId, params, aiPrompt) => {
|
|
201
202
|
console.log("dataset", dataSetId, params, aiPrompt);
|
|
@@ -203,11 +204,37 @@ export const Example: React.FC = () => {
|
|
|
203
204
|
code: "OK",
|
|
204
205
|
data: {
|
|
205
206
|
...params,
|
|
206
|
-
}
|
|
207
|
+
},
|
|
207
208
|
});
|
|
208
209
|
},
|
|
209
210
|
upload: async (file) =>
|
|
210
211
|
Promise.resolve({ id: uuid(), name: file.name }),
|
|
212
|
+
exampleList: async () =>
|
|
213
|
+
Promise.resolve({
|
|
214
|
+
total: 1,
|
|
215
|
+
list: [
|
|
216
|
+
{
|
|
217
|
+
id: 1,
|
|
218
|
+
name: "example",
|
|
219
|
+
description: "exampleexampleexampleexampleexampleexample",
|
|
220
|
+
item: schema.items[0] as SchemaItemType,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
}),
|
|
224
|
+
templateList: async () =>
|
|
225
|
+
Promise.resolve([
|
|
226
|
+
{
|
|
227
|
+
id: 1,
|
|
228
|
+
name: "example",
|
|
229
|
+
description: "exampleexampleexampleexampleexampleexample",
|
|
230
|
+
},
|
|
231
|
+
]),
|
|
232
|
+
templateDetail: async (id) =>
|
|
233
|
+
Promise.resolve({
|
|
234
|
+
id,
|
|
235
|
+
name: "test",
|
|
236
|
+
schema: schema as PageSchema,
|
|
237
|
+
}),
|
|
211
238
|
}}
|
|
212
239
|
/>
|
|
213
240
|
</EditDrawer>
|
|
@@ -301,7 +328,9 @@ function datasetAdd(): DatasetAddFunction {
|
|
|
301
328
|
onClose();
|
|
302
329
|
}}
|
|
303
330
|
>
|
|
304
|
-
<Button onClick={() => onAdd({...dataset, id: uuid()})}
|
|
331
|
+
<Button onClick={() => onAdd({ ...dataset, id: uuid() })}>
|
|
332
|
+
添加数据集
|
|
333
|
+
</Button>
|
|
305
334
|
</Drawer>
|
|
306
335
|
);
|
|
307
336
|
};
|