bi-sdk-react 0.0.9 → 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/dist/es/js/bi-sdk.es.js +51 -43
- package/dist/types/components/plugins/@antd/item-props/HtmlProps.d.ts +1 -0
- package/dist/types/components/plugins/@antd/items/HtmlRender.d.ts +1 -0
- package/dist/umd/js/bi-sdk.umd.min.js +49 -41
- package/package.json +1 -1
- package/src/components/PageDesigner.tsx +44 -14
- package/src/components/panel/AiPanel.tsx +26 -39
- package/src/components/panel/CascadePanel.tsx +1 -1
- package/src/components/panel/ComponentPanel.tsx +1 -1
- package/src/components/panel/DatasetPanel.tsx +1 -1
- package/src/components/panel/DatasourcePanel.tsx +1 -1
- package/src/components/panel/LayerPanel.tsx +1 -1
- package/src/components/panel/PropertiesPanel.tsx +1 -1
- package/src/components/panel/ScriptPanel.tsx +1 -1
- package/src/components/panel/VariablesPanel.tsx +1 -1
- package/src/components/plugins/@antd/item-props/HtmlProps.tsx +13 -5
- package/src/components/plugins/@antd/items/HtmlRender.tsx +4 -2
package/package.json
CHANGED
|
@@ -84,7 +84,7 @@ const Container = styled.div`
|
|
|
84
84
|
box-sizing: border-box;
|
|
85
85
|
}
|
|
86
86
|
& > div {
|
|
87
|
-
height: calc(100vh -
|
|
87
|
+
height: calc(100vh - 49px);
|
|
88
88
|
display: flex;
|
|
89
89
|
flex-direction: column;
|
|
90
90
|
}
|
|
@@ -144,7 +144,7 @@ const Container = styled.div`
|
|
|
144
144
|
flex-direction: column;
|
|
145
145
|
gap: 12px;
|
|
146
146
|
padding: 12px;
|
|
147
|
-
height: calc(100% -
|
|
147
|
+
height: calc(100% - 49px);
|
|
148
148
|
}
|
|
149
149
|
.left-pane-tabs > label,
|
|
150
150
|
.right-pane-tabs > label {
|
|
@@ -167,6 +167,29 @@ const Container = styled.div`
|
|
|
167
167
|
border-right: solid 2px #1890ff;
|
|
168
168
|
background: linear-gradient(to left, #1890ff1a, #ffffff);
|
|
169
169
|
}
|
|
170
|
+
|
|
171
|
+
.beautified_scrollbar {
|
|
172
|
+
overflow: auto;
|
|
173
|
+
scrollbar-width: none;
|
|
174
|
+
&::-webkit-scrollbar {
|
|
175
|
+
width: 0;
|
|
176
|
+
height: 0;
|
|
177
|
+
}
|
|
178
|
+
&:hover {
|
|
179
|
+
scrollbar-width: thin;
|
|
180
|
+
}
|
|
181
|
+
&:hover::-webkit-scrollbar {
|
|
182
|
+
width: 8px;
|
|
183
|
+
height: 8px;
|
|
184
|
+
}
|
|
185
|
+
&:hover::-webkit-scrollbar-thumb {
|
|
186
|
+
background: var(--ant-color-border);
|
|
187
|
+
border-radius: 4px;
|
|
188
|
+
}
|
|
189
|
+
&:hover::-webkit-scrollbar-track {
|
|
190
|
+
background: transparent;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
170
193
|
`;
|
|
171
194
|
|
|
172
195
|
const ImportModal: React.FC<{
|
|
@@ -181,7 +204,7 @@ const ImportModal: React.FC<{
|
|
|
181
204
|
scripts: [],
|
|
182
205
|
variables: [],
|
|
183
206
|
items: [],
|
|
184
|
-
})
|
|
207
|
+
}),
|
|
185
208
|
);
|
|
186
209
|
return (
|
|
187
210
|
<Modal
|
|
@@ -227,7 +250,7 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
227
250
|
onSave,
|
|
228
251
|
loading = false,
|
|
229
252
|
},
|
|
230
|
-
ref
|
|
253
|
+
ref,
|
|
231
254
|
) => {
|
|
232
255
|
const pageCanvasRef = useRef<any>(null);
|
|
233
256
|
const datasetPanelRef = useRef<any>(null);
|
|
@@ -253,7 +276,7 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
253
276
|
const [showLeft, setShowLeft] = useState(true);
|
|
254
277
|
const [showRight, setShowRight] = useState(true);
|
|
255
278
|
const [selectedItem, setSelectedItem] = useState<SchemaItemType | null>(
|
|
256
|
-
null
|
|
279
|
+
null,
|
|
257
280
|
);
|
|
258
281
|
const [schema, setSchema] = useState<PageSchema>({
|
|
259
282
|
info: {},
|
|
@@ -272,11 +295,11 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
272
295
|
}, [showLeft, showRight]);
|
|
273
296
|
const leftStyle = useMemo(
|
|
274
297
|
() => ({ display: showLeft ? "flex" : "none" }),
|
|
275
|
-
[showLeft]
|
|
298
|
+
[showLeft],
|
|
276
299
|
);
|
|
277
300
|
const rightStyle = useMemo(
|
|
278
301
|
() => ({ display: showRight ? "flex" : "none" }),
|
|
279
|
-
[showRight]
|
|
302
|
+
[showRight],
|
|
280
303
|
);
|
|
281
304
|
useDeepCompareEffect(() => {
|
|
282
305
|
if (isReplaying) return;
|
|
@@ -310,7 +333,7 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
310
333
|
if (Array.isArray(item.children[k])) {
|
|
311
334
|
ensureIds(
|
|
312
335
|
item.children[k],
|
|
313
|
-
Math.random().toString(36).slice(2, 10)
|
|
336
|
+
Math.random().toString(36).slice(2, 10),
|
|
314
337
|
);
|
|
315
338
|
}
|
|
316
339
|
});
|
|
@@ -375,7 +398,7 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
375
398
|
setSchema(effect.schema);
|
|
376
399
|
} else if (effect.pageItems?.length) {
|
|
377
400
|
const effectItemMap = new Map(
|
|
378
|
-
effect.pageItems.map((item) => [item.id, item])
|
|
401
|
+
effect.pageItems.map((item) => [item.id, item]),
|
|
379
402
|
);
|
|
380
403
|
const cloneSchema = JSON.parse(JSON.stringify(schema));
|
|
381
404
|
const loop = (list: any[] = []) => {
|
|
@@ -640,7 +663,9 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
640
663
|
</Space>
|
|
641
664
|
}
|
|
642
665
|
/>
|
|
643
|
-
<div
|
|
666
|
+
<div
|
|
667
|
+
className={["body beautified_scrollbar", deviceType].join(" ")}
|
|
668
|
+
>
|
|
644
669
|
<div
|
|
645
670
|
style={{
|
|
646
671
|
transform: `scale(${zoom})`,
|
|
@@ -664,9 +689,14 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
664
689
|
width: "calc(100% - 47px)",
|
|
665
690
|
}}
|
|
666
691
|
>
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
692
|
+
<AiPanel
|
|
693
|
+
agentList={agentList}
|
|
694
|
+
onEffect={handleAiEffect}
|
|
695
|
+
style={{
|
|
696
|
+
display:
|
|
697
|
+
rightActiveKey === "ai" && fetch?.ai ? undefined : "none",
|
|
698
|
+
}}
|
|
699
|
+
/>
|
|
670
700
|
{rightActiveKey === "props" && (
|
|
671
701
|
<PropertiesPanel datasourceEnable={datasourceEnable} />
|
|
672
702
|
)}
|
|
@@ -782,7 +812,7 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
|
|
|
782
812
|
</Drawer>
|
|
783
813
|
</PageProvider>
|
|
784
814
|
);
|
|
785
|
-
}
|
|
815
|
+
},
|
|
786
816
|
);
|
|
787
817
|
|
|
788
818
|
export default PageDesigner;
|
|
@@ -473,26 +473,7 @@ const MessageRoot = styled.div`
|
|
|
473
473
|
flex-direction: column;
|
|
474
474
|
gap: 12px;
|
|
475
475
|
padding-right: 8px;
|
|
476
|
-
|
|
477
|
-
scrollbar-width: none;
|
|
478
|
-
&::-webkit-scrollbar {
|
|
479
|
-
width: 0;
|
|
480
|
-
height: 0;
|
|
481
|
-
}
|
|
482
|
-
&:hover {
|
|
483
|
-
scrollbar-width: thin;
|
|
484
|
-
}
|
|
485
|
-
&:hover::-webkit-scrollbar {
|
|
486
|
-
width: 8px;
|
|
487
|
-
height: 8px;
|
|
488
|
-
}
|
|
489
|
-
&:hover::-webkit-scrollbar-thumb {
|
|
490
|
-
background: var(--ant-color-border);
|
|
491
|
-
border-radius: 4px;
|
|
492
|
-
}
|
|
493
|
-
&:hover::-webkit-scrollbar-track {
|
|
494
|
-
background: transparent;
|
|
495
|
-
}
|
|
476
|
+
|
|
496
477
|
.msg {
|
|
497
478
|
display: flex;
|
|
498
479
|
flex-direction: column;
|
|
@@ -503,8 +484,6 @@ const MessageRoot = styled.div`
|
|
|
503
484
|
background: var(--ant-color-bg-container);
|
|
504
485
|
|
|
505
486
|
.user-message {
|
|
506
|
-
background: var(--ant-color-primary-bg);
|
|
507
|
-
padding: 8px 10px;
|
|
508
487
|
max-width: 90%;
|
|
509
488
|
margin: 10px 0 10px auto;
|
|
510
489
|
position: relative;
|
|
@@ -523,7 +502,13 @@ const MessageRoot = styled.div`
|
|
|
523
502
|
.msg-header {
|
|
524
503
|
justify-content: flex-end;
|
|
525
504
|
color: var(--ant-color-text-tertiary);
|
|
526
|
-
padding: 4px
|
|
505
|
+
padding: 4px 10px 8px 10px;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.msg-section {
|
|
509
|
+
background: var(--ant-color-primary-bg);
|
|
510
|
+
padding: 8px 10px;
|
|
511
|
+
border-radius: var(--ant-border-radius);
|
|
527
512
|
}
|
|
528
513
|
}
|
|
529
514
|
.assistant-message {
|
|
@@ -632,7 +617,7 @@ const MessageList = forwardRef<
|
|
|
632
617
|
}));
|
|
633
618
|
|
|
634
619
|
return (
|
|
635
|
-
<MessageRoot className="message-list" ref={ref}>
|
|
620
|
+
<MessageRoot className="message-list beautified_scrollbar" ref={ref}>
|
|
636
621
|
{list.map((msg) => (
|
|
637
622
|
<div className="msg" key={msg.id}>
|
|
638
623
|
<div className="user-message">
|
|
@@ -655,21 +640,23 @@ const MessageList = forwardRef<
|
|
|
655
640
|
{/* <span className="msg-title">用户</span> */}
|
|
656
641
|
<span>{formatTime(msg.createdAt)}</span>
|
|
657
642
|
</div>
|
|
658
|
-
<div className="msg-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
<
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
<
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
643
|
+
<div className="msg-section">
|
|
644
|
+
<div className="msg-content">{msg.question}</div>
|
|
645
|
+
{msg.files?.length || msg.agents?.length ? (
|
|
646
|
+
<div className="msg-meta">
|
|
647
|
+
{msg.files?.map((f) => (
|
|
648
|
+
<Tag key={f.id} color="processing">
|
|
649
|
+
<IconFont type="icon-paper-clip" /> {f.name}
|
|
650
|
+
</Tag>
|
|
651
|
+
))}
|
|
652
|
+
{msg.agents?.map((a) => (
|
|
653
|
+
<Tag key={a.id} color="blue">
|
|
654
|
+
<IconFont type="icon-at" /> {a.name}
|
|
655
|
+
</Tag>
|
|
656
|
+
))}
|
|
657
|
+
</div>
|
|
658
|
+
) : null}
|
|
659
|
+
</div>
|
|
673
660
|
</div>
|
|
674
661
|
{/* <div
|
|
675
662
|
style={{
|
|
@@ -102,7 +102,7 @@ export const ComponentPanel: React.FC = () => {
|
|
|
102
102
|
return (
|
|
103
103
|
<Root className="component-panel">
|
|
104
104
|
<PaneHeader title="组件库" />
|
|
105
|
-
<div className="body">
|
|
105
|
+
<div className="body beautified_scrollbar">
|
|
106
106
|
{grouped.map((group) => (
|
|
107
107
|
<div className="plugin-group" key={group.group}>
|
|
108
108
|
<div className="group-title">{group.group}</div>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
|
-
import { Form } from "antd";
|
|
2
|
+
import { Form, Select } from "antd";
|
|
3
3
|
import Editor from "@monaco-editor/react";
|
|
4
4
|
import type { PropEditorProps } from "./types";
|
|
5
5
|
import { IconFont } from "../../../icon/IconFont";
|
|
6
6
|
|
|
7
|
-
export type HtmlModel = { template: string };
|
|
7
|
+
export type HtmlModel = { template: string; classNames?: string[] };
|
|
8
8
|
|
|
9
9
|
export const HtmlProps: React.FC<PropEditorProps<HtmlModel>> = ({
|
|
10
10
|
model,
|
|
11
11
|
onChange,
|
|
12
12
|
}) => {
|
|
13
13
|
const ref = useRef<any>(null);
|
|
14
|
-
const
|
|
15
|
-
onChange && onChange({ ...model,
|
|
14
|
+
const triggerModel = (key: keyof HtmlModel, value: any) =>
|
|
15
|
+
onChange && onChange({ ...model, [key]: value });
|
|
16
16
|
const format = () => {
|
|
17
17
|
const editor = (ref.current as any)?.editor;
|
|
18
18
|
editor?.getAction("editor.action.formatDocument")?.run();
|
|
@@ -20,6 +20,14 @@ export const HtmlProps: React.FC<PropEditorProps<HtmlModel>> = ({
|
|
|
20
20
|
return (
|
|
21
21
|
<div>
|
|
22
22
|
<Form layout="vertical">
|
|
23
|
+
<Form.Item label="类名">
|
|
24
|
+
<Select
|
|
25
|
+
size="small"
|
|
26
|
+
value={model.classNames}
|
|
27
|
+
mode="tags"
|
|
28
|
+
onChange={(value) => triggerModel("classNames", value)}
|
|
29
|
+
/>
|
|
30
|
+
</Form.Item>
|
|
23
31
|
<Form.Item
|
|
24
32
|
label={
|
|
25
33
|
<>
|
|
@@ -45,7 +53,7 @@ export const HtmlProps: React.FC<PropEditorProps<HtmlModel>> = ({
|
|
|
45
53
|
height="300px"
|
|
46
54
|
defaultLanguage="html"
|
|
47
55
|
value={model.template}
|
|
48
|
-
onChange={(v) =>
|
|
56
|
+
onChange={(v) => triggerModel("template", v || "")}
|
|
49
57
|
options={{
|
|
50
58
|
minimap: { enabled: false },
|
|
51
59
|
scrollBeyondLastLine: false,
|
|
@@ -9,6 +9,7 @@ export type HtmlRenderProps = {
|
|
|
9
9
|
template?: string;
|
|
10
10
|
style?: React.CSSProperties;
|
|
11
11
|
item: any;
|
|
12
|
+
classNames?: string[];
|
|
12
13
|
} & HtmlBaseProps;
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -28,6 +29,7 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
|
|
|
28
29
|
item,
|
|
29
30
|
style,
|
|
30
31
|
className,
|
|
32
|
+
classNames = [],
|
|
31
33
|
}) => {
|
|
32
34
|
const { env, initCallback } = useContext(EnvContext);
|
|
33
35
|
const datasource = useDatasource(id, item.datasource);
|
|
@@ -54,7 +56,7 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
|
|
|
54
56
|
const html = useMemo(
|
|
55
57
|
() =>
|
|
56
58
|
(template || "").replace(
|
|
57
|
-
/{{\s*([^}]+)\s*}}/g,
|
|
59
|
+
/{ *{\s*([^}]+)\s*} *}/g,
|
|
58
60
|
(_match: any, p1: string) => {
|
|
59
61
|
try {
|
|
60
62
|
return (func(p1) as any)(...args);
|
|
@@ -79,7 +81,7 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
|
|
|
79
81
|
<div
|
|
80
82
|
id={id}
|
|
81
83
|
style={style}
|
|
82
|
-
className={className}
|
|
84
|
+
className={(classNames || []).join(" ") + (" " + className || "")}
|
|
83
85
|
dangerouslySetInnerHTML={{ __html: html }}
|
|
84
86
|
/>
|
|
85
87
|
);
|