bi-sdk-react 0.0.3 → 0.0.5

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 (51) hide show
  1. package/dist/es/css/bi-sdk.css +1 -1
  2. package/dist/es/js/bi-sdk.es.js +295 -67
  3. package/dist/types/components/PageDesigner.d.ts +9 -1
  4. package/dist/types/components/context/DesignerContext.d.ts +5 -2
  5. package/dist/types/components/context/EnvContext.d.ts +2 -1
  6. package/dist/types/components/icon/IconFont.d.ts +2 -1
  7. package/dist/types/components/layout/PageCanvas.d.ts +2 -0
  8. package/dist/types/components/panel/AiPanel.d.ts +4 -0
  9. package/dist/types/components/panel/ChatInput.d.ts +13 -6
  10. package/dist/types/components/panel/DatasetPanel.d.ts +11 -0
  11. package/dist/types/components/panel/PaneHeader.d.ts +1 -0
  12. package/dist/types/components/panel/PropertiesPanel.d.ts +3 -1
  13. package/dist/types/components/plugins/@antd/item-props/CheckboxProps.d.ts +3 -3
  14. package/dist/types/components/plugins/@antd/item-props/ColProps.d.ts +2 -2
  15. package/dist/types/components/plugins/@antd/item-props/EchartsProps.d.ts +2 -2
  16. package/dist/types/components/plugins/@antd/item-props/TextProps.d.ts +1 -0
  17. package/dist/types/components/plugins/@antd/items/TableRender.d.ts +1 -0
  18. package/dist/types/components/plugins/@antd/items/TextRender.d.ts +1 -0
  19. package/dist/types/components/typing.d.ts +97 -2
  20. package/dist/types/components/utils.d.ts +1 -0
  21. package/dist/umd/css/bi-sdk.css +1 -1
  22. package/dist/umd/js/bi-sdk.umd.min.js +299 -71
  23. package/package.json +1 -1
  24. package/src/components/PageDesigner.tsx +293 -35
  25. package/src/components/context/DesignerContext.tsx +15 -3
  26. package/src/components/context/EnvContext.tsx +4 -1
  27. package/src/components/icon/IconFont.tsx +15 -11
  28. package/src/components/layout/PageCanvas.tsx +4 -2
  29. package/src/components/layout/PageItem.tsx +1 -1
  30. package/src/components/panel/AiPanel.tsx +609 -43
  31. package/src/components/panel/ChatInput.tsx +322 -180
  32. package/src/components/panel/DatasetPanel.tsx +65 -0
  33. package/src/components/panel/PaneHeader.tsx +3 -2
  34. package/src/components/panel/PropertiesPanel.tsx +334 -127
  35. package/src/components/plugins/@antd/index.ts +12 -9
  36. package/src/components/plugins/@antd/item-props/CapsuleProps.tsx +1 -1
  37. package/src/components/plugins/@antd/item-props/CheckboxProps.tsx +90 -42
  38. package/src/components/plugins/@antd/item-props/ColProps.tsx +139 -25
  39. package/src/components/plugins/@antd/item-props/EchartsProps.tsx +52 -22
  40. package/src/components/plugins/@antd/item-props/HtmlProps.tsx +8 -9
  41. package/src/components/plugins/@antd/item-props/SelectProps.tsx +1 -1
  42. package/src/components/plugins/@antd/item-props/TextProps.tsx +14 -3
  43. package/src/components/plugins/@antd/items/EchartsRender.tsx +9 -1
  44. package/src/components/plugins/@antd/items/HtmlRender.tsx +13 -1
  45. package/src/components/plugins/@antd/items/ListRender.tsx +18 -1
  46. package/src/components/plugins/@antd/items/TableRender.tsx +16 -1
  47. package/src/components/plugins/@antd/items/TextRender.tsx +3 -1
  48. package/src/components/styles.css +20 -0
  49. package/src/components/typing.ts +111 -2
  50. package/src/components/utils.ts +40 -0
  51. package/src/example.tsx +314 -13
@@ -1,10 +1,18 @@
1
1
  import React from "react";
2
- import { PluginType } from "./typing";
3
2
  import "./styles.css";
3
+ import { DatasetSelectorFunction, FetchType, PluginType } from "./typing";
4
4
  export type PageDesignerProps = {
5
+ pageId: string;
5
6
  agentList?: any[];
6
7
  plugins?: PluginType[];
7
8
  headerExtra?: React.ReactNode;
9
+ datasourceEnable?: boolean;
10
+ scriptEnable?: boolean;
11
+ datasetPanel?: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<{
12
+ handleAdd: () => void;
13
+ }>>;
14
+ datasetSelector?: DatasetSelectorFunction;
15
+ fetch?: FetchType;
8
16
  };
9
17
  export declare const PageDesigner: React.ForwardRefExoticComponent<PageDesignerProps & React.RefAttributes<any>>;
10
18
  export default PageDesigner;
@@ -1,5 +1,6 @@
1
- import { PageSchema, PluginType, SchemaItemType } from "../typing";
1
+ import { DatasetSelectorFunction, FetchType, PageSchema, PluginType, SchemaItemType } from "../typing";
2
2
  type DesignerContextType = {
3
+ pageId: string;
3
4
  designable: boolean;
4
5
  plugins: PluginType[];
5
6
  schema: PageSchema;
@@ -8,8 +9,10 @@ type DesignerContextType = {
8
9
  setSelectedItem: React.Dispatch<React.SetStateAction<SchemaItemType | null>>;
9
10
  updateSelectedItem: (selectedItem?: Partial<SchemaItemType> | null) => void;
10
11
  forceUpdate: () => void;
12
+ datasetSelector?: DatasetSelectorFunction;
13
+ fetch?: FetchType;
11
14
  };
12
15
  export declare const DesignerContext: import("react").Context<DesignerContextType>;
13
- type DesignerProviderProps = React.PropsWithChildren<Omit<Partial<DesignerContextType>, "updateSelectedItem" | "schema" | "forceUpdate"> & Pick<DesignerContextType, "schema">>;
16
+ type DesignerProviderProps = React.PropsWithChildren<Omit<Partial<DesignerContextType>, "updateSelectedItem" | "schema" | "forceUpdate"> & Pick<DesignerContextType, "schema" | "pageId">>;
14
17
  export declare const DesignerProvider: React.FC<DesignerProviderProps>;
15
18
  export {};
@@ -1,5 +1,5 @@
1
1
  import { FC, PropsWithChildren } from "react";
2
- import { CallbacksType, EnvType } from "../typing";
2
+ import { CallbacksType, EnvType, FetchType } from "../typing";
3
3
  type InitCallbackParams = {
4
4
  id: string;
5
5
  callback: (v: any) => void;
@@ -7,6 +7,7 @@ type InitCallbackParams = {
7
7
  type EnvContextType = {
8
8
  deviceWidth: number;
9
9
  env: EnvType;
10
+ fetch?: FetchType;
10
11
  callbacks: CallbacksType;
11
12
  initCallback: ({ id, callback }: InitCallbackParams) => void;
12
13
  };
@@ -1,6 +1,7 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  export type IconFontProps = {
3
3
  type: string;
4
4
  className?: string;
5
+ style?: React.CSSProperties;
5
6
  };
6
7
  export declare const IconFont: React.FC<IconFontProps>;
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
+ import { FetchType } from "../typing";
2
3
  export type PageCanvasProps = {
3
4
  device?: "desktop" | "mobile" | "tablet";
5
+ fetch?: FetchType;
4
6
  };
5
7
  export declare const PageCanvas: React.ForwardRefExoticComponent<PageCanvasProps & React.RefAttributes<any>>;
6
8
  export default PageCanvas;
@@ -1,8 +1,12 @@
1
1
  import React from "react";
2
+ import { ChatResponseAnswerEffectType } from "../typing";
2
3
  export type AiPanelProps = {
3
4
  agentList?: {
4
5
  id: string;
5
6
  name: string;
6
7
  }[];
8
+ headExtra?: React.ReactNode;
9
+ style?: React.CSSProperties;
10
+ onEffect?: (effect: ChatResponseAnswerEffectType) => void;
7
11
  };
8
12
  export declare const AiPanel: React.FC<AiPanelProps>;
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { FetchType } from "../typing";
2
3
  export type ChatInputProps = {
3
4
  value?: string;
4
5
  placeholder?: string;
@@ -9,19 +10,25 @@ export type ChatInputProps = {
9
10
  id: string | number;
10
11
  name: string;
11
12
  }[];
12
- title?: string;
13
13
  agentId?: string | number | null;
14
14
  attachments?: any[];
15
15
  onInput?: (text: string) => void;
16
16
  onSubmit?: (data: {
17
- demand: string;
18
- title: string;
19
- agentId?: string | number;
20
- csvData: Record<string, string>;
17
+ message: string;
18
+ agents?: {
19
+ id: string | number;
20
+ name: string;
21
+ }[] | null;
22
+ files?: {
23
+ id: string;
24
+ name: string;
25
+ extension: string;
26
+ }[] | null;
21
27
  }) => void;
22
- onUpdateTitle?: (title: string) => void;
23
28
  onUpdateAgentId?: (id: string | number | null) => void;
24
29
  onUpdateAttachments?: (list: any[]) => void;
30
+ onUploading?: FetchType["upload"];
31
+ style?: React.CSSProperties;
25
32
  };
26
33
  export declare const ChatInput: React.ForwardRefExoticComponent<ChatInputProps & React.RefAttributes<{
27
34
  focus: () => void;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ type DatasetPanelType = {
3
+ renderNode: React.ForwardRefExoticComponent<any & React.RefAttributes<{
4
+ reload: () => void;
5
+ handleAdd: () => void;
6
+ }>>;
7
+ };
8
+ export declare const DatasetPanel: React.ForwardRefExoticComponent<DatasetPanelType & React.RefAttributes<{
9
+ reload: () => void;
10
+ }>>;
11
+ export {};
@@ -2,5 +2,6 @@ import React from 'react';
2
2
  export type PaneHeaderProps = {
3
3
  title?: string;
4
4
  extra?: React.ReactNode;
5
+ style?: React.CSSProperties;
5
6
  };
6
7
  export declare const PaneHeader: React.FC<PaneHeaderProps>;
@@ -1,2 +1,4 @@
1
1
  import React from "react";
2
- export declare const PropertiesPanel: React.FC;
2
+ export declare const PropertiesPanel: React.FC<{
3
+ datasourceEnable?: boolean;
4
+ }>;
@@ -1,12 +1,12 @@
1
- import React from 'react';
2
- import type { PropEditorProps } from './types';
1
+ import React from "react";
2
+ import type { PropEditorProps } from "./types";
3
3
  export type CheckboxOption = {
4
4
  label: string;
5
5
  value: any;
6
6
  };
7
7
  export type CheckboxModel = {
8
8
  var?: string;
9
- layout?: 'horizontal' | 'vertical' | 'grid';
9
+ layout?: "horizontal" | "vertical" | "grid";
10
10
  lineNumber?: number;
11
11
  options: CheckboxOption[];
12
12
  };
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import type { PropEditorProps } from './types';
1
+ import React from "react";
2
+ import type { PropEditorProps } from "./types";
3
3
  export type ColModel = {
4
4
  span?: number;
5
5
  xs?: number;
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import type { PropEditorProps } from './types';
1
+ import React from "react";
2
+ import type { PropEditorProps } from "./types";
3
3
  export type EchartsModel = {
4
4
  script: string;
5
5
  };
@@ -3,5 +3,6 @@ import type { PropEditorProps } from "./types";
3
3
  export type TextModel = {
4
4
  text?: string;
5
5
  customStyle?: React.CSSProperties;
6
+ classNames?: string[];
6
7
  };
7
8
  export declare const TextProps: React.FC<PropEditorProps<TextModel>>;
@@ -8,5 +8,6 @@ export type TableRenderProps = {
8
8
  bordered?: boolean;
9
9
  size?: TableProps["size"];
10
10
  showHeader?: boolean;
11
+ item: any;
11
12
  } & HtmlBaseProps;
12
13
  export declare const TableRender: React.FC<TableRenderProps>;
@@ -6,5 +6,6 @@ export type TextRenderProps = {
6
6
  item?: {
7
7
  style?: React.CSSProperties;
8
8
  };
9
+ classNames?: string[];
9
10
  } & HtmlBaseProps;
10
11
  export declare const TextRender: React.FC<TextRenderProps>;
@@ -1,4 +1,76 @@
1
- import { MouseEventHandler } from "react";
1
+ import React, { MouseEventHandler } from "react";
2
+ export type ChatRequestType = {
3
+ message: string;
4
+ files?: {
5
+ id: string;
6
+ name: string;
7
+ extension: string;
8
+ }[] | null;
9
+ agents?: {
10
+ id: string | number;
11
+ name: string;
12
+ }[] | null;
13
+ page?: PageSchema | null;
14
+ pageItems?: SchemaItemType[] | null;
15
+ };
16
+ export type ChatResponseAnswerEffectType = {
17
+ datasets?: DataSetType[] | null;
18
+ schema?: PageSchema;
19
+ pageItems?: SchemaItemType[] | null;
20
+ };
21
+ export type ChatResponseAnswerType = {
22
+ answer: string;
23
+ effect?: ChatResponseAnswerEffectType | null;
24
+ extra?: {
25
+ id: string;
26
+ element: string;
27
+ action: string;
28
+ area: string;
29
+ }[] | null;
30
+ };
31
+ export type ChatResponseType = {
32
+ id: string;
33
+ answer: ChatResponseAnswerType;
34
+ createdAt: string;
35
+ conversation?: ChatConversationType | null;
36
+ };
37
+ export type ChatConversationType = {
38
+ id: string;
39
+ name: string;
40
+ createdAt: string;
41
+ isActived: boolean;
42
+ };
43
+ export type ChatMessageType = {
44
+ id: string;
45
+ conversationId: string | null;
46
+ question: string;
47
+ answer: ChatResponseAnswerType;
48
+ files: {
49
+ id: string;
50
+ name: string;
51
+ extension: string;
52
+ }[];
53
+ agents: {
54
+ id: string | number;
55
+ name: string;
56
+ }[];
57
+ createdAt: string;
58
+ sending?: boolean;
59
+ };
60
+ export type FetchType = {
61
+ upload?: (file: File) => Promise<{
62
+ id: string;
63
+ name: string;
64
+ }>;
65
+ ai?: {
66
+ chat: (bizType: string, bizId: string, conversationId: string | null, request: ChatRequestType) => Promise<ChatResponseType>;
67
+ conversationList: (bizType: string, bizId: string) => Promise<ChatConversationType[]>;
68
+ messageList: (bizType: string, bizId: string, conversationId?: string | null) => Promise<ChatMessageType[]>;
69
+ removeConversation: (bizType: string, bizId: string, conversationId: string) => Promise<boolean>;
70
+ removeMessage: (bizType: string, bizId: string, messageId: string) => Promise<boolean>;
71
+ };
72
+ dataset?: (dataSetId: string, params: Record<string, any>) => Promise<any>;
73
+ };
2
74
  export type HtmlBaseProps = {
3
75
  id?: string;
4
76
  style?: React.CSSProperties;
@@ -15,10 +87,11 @@ export type SchemaItemType = {
15
87
  cascadeIds?: string[];
16
88
  children?: SchemaItemType[] | Record<string, SchemaItemType[]>;
17
89
  datasource?: {
18
- source?: "custom" | "define";
90
+ source?: "custom" | "define" | "dataset";
19
91
  datasourceId?: string | null;
20
92
  scriptId?: string | null;
21
93
  custom?: string | null;
94
+ dataset?: DataSetType;
22
95
  };
23
96
  };
24
97
  export type PluginType = {
@@ -60,6 +133,27 @@ export type SqlType = {
60
133
  name: string;
61
134
  query: string;
62
135
  };
136
+ export declare enum FieldType {
137
+ STRING = "STRING",
138
+ NUMBER = "NUMBER",
139
+ BOOLEAN = "BOOLEAN",
140
+ OBJECT = "OBJECT",
141
+ ARRAY = "ARRAY"
142
+ }
143
+ export type DataSetOutputField = {
144
+ key?: string;
145
+ name?: string;
146
+ type?: FieldType;
147
+ schema?: DataSetOutput;
148
+ };
149
+ export type DataSetOutput = {
150
+ fields?: DataSetOutputField[];
151
+ };
152
+ export type DataSetType = {
153
+ id: string;
154
+ name: string;
155
+ output: DataSetOutput;
156
+ };
63
157
  export type PageInfo = {
64
158
  name?: string;
65
159
  description?: string;
@@ -77,4 +171,5 @@ export type EnvType = {
77
171
  local: Record<string, Record<string, any>>;
78
172
  };
79
173
  export type CallbacksType = Record<string, (v: any) => void>;
174
+ export type DatasetSelectorFunction = (onSelect: (dataset: DataSetType) => void) => React.ReactNode;
80
175
  export {};
@@ -6,4 +6,5 @@ export declare const getVars: (env: Env, item: SchemaItemType) => {
6
6
  export declare const setVar: (env: Env, item: SchemaItemType, key: string, value: any) => void;
7
7
  export declare const handleCallback: (env: Env, item: SchemaItemType, callbacks: CallbacksType) => void;
8
8
  export declare const uuid: () => string;
9
+ export declare const formatTime: (dateStr: string) => string;
9
10
  export {};
@@ -1 +1 @@
1
- .ant-dropdown-menu-vertical{max-height:70vh;overflow:auto}a.toolbar{color:var(--ant-color-text-secondary)}a.toolbar.active{color:var(--ant-color-primary)}
1
+ .ant-dropdown-menu-vertical{max-height:70vh;overflow:auto}a.toolbar{color:var(--ant-color-text-secondary)}a.toolbar.active{color:var(--ant-color-primary)}.ant-form-compact .ant-form-item{margin-bottom:8px}.ant-form-item-label label{align-items:center;display:inline-flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label{justify-content:space-between;align-items:center;width:100%;display:flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label:after{content:none}