bi-sdk-react 0.0.4 → 0.0.6

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 (45) hide show
  1. package/dist/es/css/bi-sdk.css +1 -1
  2. package/dist/es/js/bi-sdk.es.js +296 -63
  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/EchartsProps.d.ts +2 -2
  14. package/dist/types/components/plugins/@antd/item-props/TextProps.d.ts +1 -0
  15. package/dist/types/components/plugins/@antd/items/TableRender.d.ts +1 -0
  16. package/dist/types/components/plugins/@antd/items/TextRender.d.ts +1 -0
  17. package/dist/types/components/typing.d.ts +102 -2
  18. package/dist/types/components/utils.d.ts +1 -0
  19. package/dist/umd/css/bi-sdk.css +1 -1
  20. package/dist/umd/js/bi-sdk.umd.min.js +300 -67
  21. package/package.json +3 -2
  22. package/src/components/PageDesigner.tsx +231 -37
  23. package/src/components/context/DesignerContext.tsx +15 -3
  24. package/src/components/context/EnvContext.tsx +4 -1
  25. package/src/components/icon/IconFont.tsx +15 -11
  26. package/src/components/layout/PageCanvas.tsx +4 -2
  27. package/src/components/layout/PageItem.tsx +1 -1
  28. package/src/components/panel/AiPanel.tsx +656 -43
  29. package/src/components/panel/ChatInput.tsx +259 -147
  30. package/src/components/panel/DatasetPanel.tsx +65 -0
  31. package/src/components/panel/PaneHeader.tsx +3 -2
  32. package/src/components/panel/PropertiesPanel.tsx +332 -125
  33. package/src/components/plugins/@antd/index.ts +12 -8
  34. package/src/components/plugins/@antd/item-props/EchartsProps.tsx +52 -22
  35. package/src/components/plugins/@antd/item-props/HtmlProps.tsx +8 -9
  36. package/src/components/plugins/@antd/item-props/TextProps.tsx +13 -1
  37. package/src/components/plugins/@antd/items/EchartsRender.tsx +9 -1
  38. package/src/components/plugins/@antd/items/HtmlRender.tsx +13 -1
  39. package/src/components/plugins/@antd/items/ListRender.tsx +18 -1
  40. package/src/components/plugins/@antd/items/TableRender.tsx +16 -1
  41. package/src/components/plugins/@antd/items/TextRender.tsx +3 -1
  42. package/src/components/styles.css +20 -0
  43. package/src/components/typing.ts +117 -2
  44. package/src/components/utils.ts +40 -0
  45. package/src/example.tsx +344 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bi-sdk-react",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/umd/js/bi-sdk.umd.min.js",
@@ -15,7 +15,8 @@
15
15
  "build:lib": "npm run build:lib:umd && npm run build:lib:es",
16
16
  "build:lib:umd": "cross-env NODE_ENV=production BUILD_TARGET=lib rsbuild build --config rsbuild.lib.config.ts",
17
17
  "build:lib:es": "cross-env NODE_ENV=production BUILD_TARGET=lib rsbuild build --config rsbuild.es.config.ts",
18
- "preview": "rsbuild preview"
18
+ "preview": "rsbuild preview",
19
+ "publish": "npm run build:types && npm run build:lib && npm publish --access public"
19
20
  },
20
21
  "dependencies": {
21
22
  "@ant-design/icons": "^6.1.0",
@@ -1,4 +1,5 @@
1
1
  import {
2
+ CloseOutlined,
2
3
  DesktopOutlined,
3
4
  EyeInvisibleOutlined,
4
5
  EyeOutlined,
@@ -11,12 +12,22 @@ import {
11
12
  ZoomInOutlined,
12
13
  ZoomOutOutlined,
13
14
  } from "@ant-design/icons";
14
- import { Button, Divider, Modal, Radio, Space, Tooltip } from "antd";
15
+ import {
16
+ Button,
17
+ Divider,
18
+ Drawer,
19
+ Modal,
20
+ Popover,
21
+ Radio,
22
+ Space,
23
+ Tooltip,
24
+ } from "antd";
15
25
  import React, {
26
+ ReactNode,
16
27
  useImperativeHandle,
17
28
  useMemo,
18
29
  useRef,
19
- useState
30
+ useState,
20
31
  } from "react";
21
32
  import styled from "styled-components";
22
33
  import { IconFont } from "./icon/IconFont";
@@ -36,12 +47,31 @@ import { Editor } from "@monaco-editor/react";
36
47
  import { DesignerProvider } from "./context/DesignerContext";
37
48
  import { useDeepCompareEffect } from "./hooks/useDeepCompareEffect";
38
49
  import "./styles.css";
39
- import { PageSchema, PluginType } from "./typing";
50
+ import {
51
+ ChatResponseAnswerEffectType,
52
+ DatasetSelectorFunction,
53
+ FetchType,
54
+ PageSchema,
55
+ PluginType,
56
+ SchemaItemType,
57
+ } from "./typing";
58
+ import { DatasetPanel } from "./panel/DatasetPanel";
40
59
 
41
60
  export type PageDesignerProps = {
61
+ pageId: string;
42
62
  agentList?: any[];
43
63
  plugins?: PluginType[];
44
64
  headerExtra?: React.ReactNode;
65
+ datasourceEnable?: boolean;
66
+ scriptEnable?: boolean;
67
+ datasetPanel?: React.ForwardRefExoticComponent<
68
+ Omit<any, "ref"> &
69
+ React.RefAttributes<{
70
+ handleAdd: () => void;
71
+ }>
72
+ >;
73
+ datasetSelector?: DatasetSelectorFunction;
74
+ fetch?: FetchType;
45
75
  };
46
76
 
47
77
  const Container = styled.div`
@@ -112,6 +142,7 @@ const Container = styled.div`
112
142
  flex-direction: column;
113
143
  gap: 12px;
114
144
  padding: 12px;
145
+ height: calc(100% - 40px);
115
146
  }
116
147
  .left-pane-tabs > label,
117
148
  .right-pane-tabs > label {
@@ -161,7 +192,10 @@ const ImportModal: React.FC<{
161
192
  cancelText="取消"
162
193
  styles={{ body: { height: "calc(100vh - 250px)", overflow: "auto" } }}
163
194
  >
164
- <div className="body" style={{ flex: "1 1 auto", display: "flex", height: "100%" }}>
195
+ <div
196
+ className="body"
197
+ style={{ flex: "1 1 auto", display: "flex", height: "100%" }}
198
+ >
165
199
  <Editor
166
200
  height="100%"
167
201
  defaultLanguage="json"
@@ -177,8 +211,22 @@ const ImportModal: React.FC<{
177
211
  };
178
212
 
179
213
  export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
180
- ({ agentList = [], plugins = [], headerExtra }, ref) => {
214
+ (
215
+ {
216
+ pageId,
217
+ agentList = [],
218
+ plugins = [],
219
+ headerExtra,
220
+ datasourceEnable = true,
221
+ scriptEnable = true,
222
+ datasetPanel,
223
+ datasetSelector,
224
+ fetch,
225
+ },
226
+ ref
227
+ ) => {
181
228
  const pageCanvasRef = useRef<any>(null);
229
+ const datasetPanelRef = useRef<any>(null);
182
230
  const [zoom, setZoom] = useState(1);
183
231
  const [history, setHistory] = useState<any[]>([]);
184
232
  const [future, setFuture] = useState<any[]>([]);
@@ -187,14 +235,22 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
187
235
  "desktop" | "mobile" | "tablet"
188
236
  >("desktop");
189
237
  const [leftPanelActiveKey, setLeftPanelActiveKey] = useState<
190
- "component" | "layer" | "datasource" | "script" | "env" | "code"
238
+ | "component"
239
+ | "layer"
240
+ | "datasource"
241
+ | "script"
242
+ | "env"
243
+ | "code"
244
+ | "dataset"
191
245
  >("component");
192
246
  const [rightPanelActiveKey, setRightPanelActiveKey] = useState<
193
247
  "ai" | "props" | "cascade"
194
- >("ai");
248
+ >(fetch?.ai ? "ai" : "props");
195
249
  const [showLeft, setShowLeft] = useState(true);
196
250
  const [showRight, setShowRight] = useState(true);
197
- const [selectedItem, setSelectedItem] = useState<any>(null);
251
+ const [selectedItem, setSelectedItem] = useState<SchemaItemType | null>(
252
+ null
253
+ );
198
254
  const [schema, setSchema] = useState<PageSchema>({
199
255
  info: {},
200
256
  datasources: [],
@@ -204,6 +260,7 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
204
260
  });
205
261
  const [designable, setDesignable] = useState(true);
206
262
  const [importModalOpen, setImportModalOpen] = useState(false);
263
+ const [aiPaneOpen, setAiPaneOpen] = useState(false);
207
264
  const containerStyle = useMemo(() => {
208
265
  const left = showLeft ? "250px" : "";
209
266
  const right = showRight ? "400px" : "";
@@ -303,14 +360,60 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
303
360
  setSchema(s);
304
361
  };
305
362
 
363
+ /**
364
+ * 处理效果
365
+ */
366
+ const handleAiEffect = (effect: ChatResponseAnswerEffectType) => {
367
+ if (effect.datasets?.length && datasetPanelRef?.current?.reload) {
368
+ datasetPanelRef.current.reload();
369
+ }
370
+ if (effect.schema) {
371
+ setSchema(effect.schema);
372
+ } else if (effect.pageItems?.length) {
373
+ const effectItemMap = new Map(effect.pageItems.map((item) => [item.id, item]));
374
+ const cloneSchema = JSON.parse(JSON.stringify(schema));
375
+ const loop = (list: any[] = []) => {
376
+ list.forEach((item) => {
377
+ if (effectItemMap.has(item.id)) {
378
+ Object.keys(item).forEach((k) => {
379
+ if (k !== "id") {
380
+ delete item[k];
381
+ }
382
+ });
383
+ Object.assign(item, effectItemMap.get(item.id)!);
384
+ }
385
+ if (Array.isArray(item.children)) {
386
+ loop(item.children);
387
+ } else if (typeof item.children === "object" && item.children) {
388
+ Object.keys(item.children).forEach((k) => {
389
+ if (Array.isArray(item.children[k])) {
390
+ loop(item.children[k]);
391
+ }
392
+ });
393
+ }
394
+ });
395
+ };
396
+ loop(cloneSchema.items);
397
+ setSchema(cloneSchema);
398
+ }
399
+ };
400
+
401
+ const rightActiveKey = useMemo(() => {
402
+ if (rightPanelActiveKey === "cascade" && !selectedItem?.cascadeIds) return "props";
403
+ return rightPanelActiveKey;
404
+ }, [selectedItem, rightPanelActiveKey]);
405
+
306
406
  return (
307
407
  <DesignerProvider
408
+ pageId={pageId}
308
409
  designable={designable}
309
410
  plugins={plugins}
310
411
  schema={schema}
311
412
  selectedItem={selectedItem}
312
413
  setSchema={setSchema}
313
414
  setSelectedItem={setSelectedItem}
415
+ datasetSelector={datasetSelector}
416
+ fetch={fetch}
314
417
  >
315
418
  <div
316
419
  style={{ display: "flex", flexDirection: "column", height: "100%" }}
@@ -430,16 +533,27 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
430
533
  <IconFont type="icon-outline" />
431
534
  </Tooltip>
432
535
  </Radio.Button>
433
- <Radio.Button value="datasource">
434
- <Tooltip title="数据集" placement="right">
435
- <IconFont type="icon-datasource" />
436
- </Tooltip>
437
- </Radio.Button>
438
- <Radio.Button value="script">
439
- <Tooltip title="脚本" placement="right">
440
- <IconFont type="icon-js" />
441
- </Tooltip>
442
- </Radio.Button>
536
+ {!!datasetPanel && (
537
+ <Radio.Button value="dataset">
538
+ <Tooltip title="数据集" placement="right">
539
+ <IconFont type="icon-dataset" />
540
+ </Tooltip>
541
+ </Radio.Button>
542
+ )}
543
+ {datasourceEnable && (
544
+ <Radio.Button value="datasource" title="数据源">
545
+ <Tooltip title="数据源" placement="right">
546
+ <IconFont type="icon-datasource" />
547
+ </Tooltip>
548
+ </Radio.Button>
549
+ )}
550
+ {scriptEnable && (
551
+ <Radio.Button value="script">
552
+ <Tooltip title="脚本" placement="right">
553
+ <IconFont type="icon-js" />
554
+ </Tooltip>
555
+ </Radio.Button>
556
+ )}
443
557
  <Radio.Button value="env">
444
558
  <Tooltip title="环境变量" placement="right">
445
559
  <IconFont type="icon-variable" />
@@ -462,10 +576,17 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
462
576
  >
463
577
  {leftPanelActiveKey === "component" && <ComponentPanel />}
464
578
  {leftPanelActiveKey === "layer" && <LayerPanel />}
465
- {leftPanelActiveKey === "datasource" && <DatasourcePanel />}
466
- {leftPanelActiveKey === "script" && <ScriptPanel />}
579
+ {datasourceEnable && leftPanelActiveKey === "datasource" && (
580
+ <DatasourcePanel />
581
+ )}
582
+ {scriptEnable && leftPanelActiveKey === "script" && (
583
+ <ScriptPanel />
584
+ )}
467
585
  {leftPanelActiveKey === "env" && <VariablesPanel />}
468
586
  {leftPanelActiveKey === "code" && <CodePanel />}
587
+ {!!datasetPanel && leftPanelActiveKey === "dataset" && (
588
+ <DatasetPanel ref={datasetPanelRef} renderNode={datasetPanel} />
589
+ )}
469
590
  </div>
470
591
  </div>
471
592
  <div className="center" style={{ flex: "1 1 auto" }}>
@@ -507,7 +628,11 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
507
628
  transformOrigin: "top center",
508
629
  }}
509
630
  >
510
- <PageCanvas ref={pageCanvasRef} device={deviceType} />
631
+ <PageCanvas
632
+ ref={pageCanvasRef}
633
+ device={deviceType}
634
+ fetch={fetch}
635
+ />
511
636
  </div>
512
637
  </div>
513
638
  </div>
@@ -520,17 +645,27 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
520
645
  width: "calc(100% - 47px)",
521
646
  }}
522
647
  >
523
- {rightPanelActiveKey === "ai" && (
524
- <AiPanel agentList={agentList} />
648
+ {rightActiveKey === "ai" && fetch?.ai && (
649
+ <AiPanel agentList={agentList} onEffect={handleAiEffect} />
650
+ )}
651
+ {rightActiveKey === "props" && (
652
+ <PropertiesPanel datasourceEnable={datasourceEnable} />
525
653
  )}
526
- {rightPanelActiveKey === "props" && <PropertiesPanel />}
527
- {rightPanelActiveKey === "cascade" && <CascadePanel />}
654
+ {rightActiveKey === "cascade" &&
655
+ selectedItem?.cascadeIds && <CascadePanel />}
528
656
  </div>
529
657
  <div
530
- style={{ padding: "22px 0", borderLeft: "solid 1px #e8e8e8" }}
658
+ style={{
659
+ padding: "22px 0",
660
+ borderLeft: "solid 1px #e8e8e8",
661
+ display: "flex",
662
+ flexDirection: "column",
663
+ justifyContent: "space-between",
664
+ alignItems: "center",
665
+ }}
531
666
  >
532
667
  <Radio.Group
533
- value={rightPanelActiveKey}
668
+ value={rightActiveKey}
534
669
  onChange={(e) => setRightPanelActiveKey(e.target.value)}
535
670
  buttonStyle="outline"
536
671
  style={{
@@ -541,22 +676,56 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
541
676
  }}
542
677
  className="right-pane-tabs"
543
678
  >
544
- <Radio.Button value="ai">
545
- <Tooltip title="智能体" placement="right">
546
- <IconFont type="icon-assistant" />
547
- </Tooltip>
548
- </Radio.Button>
679
+ {fetch?.ai && (
680
+ <Radio.Button value="ai">
681
+ <Tooltip title="智能助理" placement="right">
682
+ <IconFont type="icon-assistant" />
683
+ </Tooltip>
684
+ </Radio.Button>
685
+ )}
549
686
  <Radio.Button value="props">
550
687
  <Tooltip title="属性" placement="right">
551
688
  <IconFont type="icon-info" />
552
689
  </Tooltip>
553
690
  </Radio.Button>
554
- <Radio.Button value="cascade">
555
- <Tooltip title="联动" placement="right">
556
- <IconFont type="icon-cascade" />
557
- </Tooltip>
558
- </Radio.Button>
691
+ {selectedItem?.cascadeIds && (
692
+ <Radio.Button value="cascade">
693
+ <Tooltip title="联动" placement="right">
694
+ <IconFont type="icon-cascade" />
695
+ </Tooltip>
696
+ </Radio.Button>
697
+ )}
559
698
  </Radio.Group>
699
+ {/* <Popover
700
+ content={
701
+ <AiPanel
702
+ agentList={agentList}
703
+ style={{ width: 400, height: "85vh" }}
704
+ onEffect={handleAiEffect}
705
+ />
706
+ }
707
+ trigger="click"
708
+ placement="bottomLeft"
709
+ styles={{
710
+ root: {
711
+ right: 15,
712
+ },
713
+ container: {
714
+ boxShadow: "0 0 10px 1px #0000008a",
715
+ padding: 0,
716
+ },
717
+ }}
718
+ > */}
719
+ {/* <Tooltip title="智能助理" placement="left">
720
+ <Button
721
+ type="link"
722
+ style={{ fontSize: 20 }}
723
+ onClick={() => setAiPaneOpen(true)}
724
+ >
725
+ <IconFont type="icon-assistant" />
726
+ </Button>
727
+ </Tooltip> */}
728
+ {/* </Popover> */}
560
729
  </div>
561
730
  </div>
562
731
  </Container>
@@ -566,6 +735,31 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
566
735
  onOk={handleImportOk}
567
736
  onCancel={() => setImportModalOpen(false)}
568
737
  />
738
+ <Drawer
739
+ open={aiPaneOpen}
740
+ size={400}
741
+ mask={false}
742
+ title={null}
743
+ closable={false}
744
+ styles={{
745
+ body: {
746
+ padding: 0,
747
+ },
748
+ }}
749
+ onClose={() => setAiPaneOpen(false)}
750
+ >
751
+ <AiPanel
752
+ agentList={agentList}
753
+ headExtra={
754
+ <Button
755
+ type="link"
756
+ icon={<CloseOutlined />}
757
+ onClick={() => setAiPaneOpen(false)}
758
+ />
759
+ }
760
+ onEffect={handleAiEffect}
761
+ />
762
+ </Drawer>
569
763
  </DesignerProvider>
570
764
  );
571
765
  }
@@ -1,7 +1,8 @@
1
- import { createContext } from "react";
2
- import { PageSchema, PluginType, SchemaItemType } from "../typing";
1
+ import { createContext, ReactNode } from "react";
2
+ import { DatasetSelectorFunction, FetchType, PageSchema, PluginType, SchemaItemType } from "../typing";
3
3
 
4
4
  type DesignerContextType = {
5
+ pageId: string;
5
6
  designable: boolean;
6
7
  plugins: PluginType[];
7
8
  schema: PageSchema;
@@ -10,9 +11,12 @@ type DesignerContextType = {
10
11
  setSelectedItem: React.Dispatch<React.SetStateAction<SchemaItemType | null>>;
11
12
  updateSelectedItem: (selectedItem?: Partial<SchemaItemType> | null) => void;
12
13
  forceUpdate: () => void;
14
+ datasetSelector?: DatasetSelectorFunction;
15
+ fetch?: FetchType;
13
16
  };
14
17
 
15
18
  export const DesignerContext = createContext<DesignerContextType>({
19
+ pageId: "",
16
20
  designable: false,
17
21
  plugins: [],
18
22
  schema: {
@@ -27,6 +31,8 @@ export const DesignerContext = createContext<DesignerContextType>({
27
31
  setSelectedItem: () => {},
28
32
  updateSelectedItem: () => {},
29
33
  forceUpdate: () => {},
34
+ datasetSelector: undefined,
35
+ fetch: undefined,
30
36
  });
31
37
 
32
38
  type DesignerProviderProps = React.PropsWithChildren<
@@ -34,16 +40,19 @@ type DesignerProviderProps = React.PropsWithChildren<
34
40
  Partial<DesignerContextType>,
35
41
  "updateSelectedItem" | "schema" | "forceUpdate"
36
42
  > &
37
- Pick<DesignerContextType, "schema">
43
+ Pick<DesignerContextType, "schema" | "pageId">
38
44
  >;
39
45
 
40
46
  export const DesignerProvider: React.FC<DesignerProviderProps> = ({
47
+ pageId,
41
48
  designable,
42
49
  plugins,
43
50
  schema,
44
51
  selectedItem,
45
52
  setSchema,
46
53
  setSelectedItem,
54
+ datasetSelector,
55
+ fetch,
47
56
  children,
48
57
  }) => {
49
58
  const updateSelectedItem = (props?: Partial<SchemaItemType> | null) => {
@@ -53,6 +62,7 @@ export const DesignerProvider: React.FC<DesignerProviderProps> = ({
53
62
  return (
54
63
  <DesignerContext.Provider
55
64
  value={{
65
+ pageId,
56
66
  designable: !!designable,
57
67
  plugins: plugins || [],
58
68
  schema,
@@ -60,6 +70,8 @@ export const DesignerProvider: React.FC<DesignerProviderProps> = ({
60
70
  setSchema: setSchema || (() => {}),
61
71
  setSelectedItem: setSelectedItem || (() => {}),
62
72
  updateSelectedItem,
73
+ datasetSelector,
74
+ fetch,
63
75
  forceUpdate: () => {
64
76
  setSchema?.({ ...schema });
65
77
  },
@@ -1,5 +1,5 @@
1
1
  import { createContext, FC, PropsWithChildren } from "react";
2
- import { CallbacksType, EnvType } from "../typing";
2
+ import { CallbacksType, EnvType, FetchType } from "../typing";
3
3
 
4
4
  type InitCallbackParams = {
5
5
  id: string;
@@ -9,6 +9,7 @@ type InitCallbackParams = {
9
9
  type EnvContextType = {
10
10
  deviceWidth: number;
11
11
  env: EnvType;
12
+ fetch?: FetchType;
12
13
  callbacks: CallbacksType;
13
14
  initCallback: ({ id, callback }: InitCallbackParams) => void;
14
15
  };
@@ -23,6 +24,7 @@ export const EnvContext = createContext<EnvContextType>({
23
24
  export const EnvProvider: FC<PropsWithChildren<EnvContextType>> = ({
24
25
  deviceWidth,
25
26
  env,
27
+ fetch,
26
28
  callbacks,
27
29
  initCallback,
28
30
  children,
@@ -32,6 +34,7 @@ export const EnvProvider: FC<PropsWithChildren<EnvContextType>> = ({
32
34
  value={{
33
35
  deviceWidth,
34
36
  env,
37
+ fetch,
35
38
  callbacks,
36
39
  initCallback,
37
40
  }}
@@ -1,16 +1,20 @@
1
- import React from 'react'
2
- import { createFromIconfontCN } from '@ant-design/icons'
1
+ import React from "react";
2
+ import { createFromIconfontCN } from "@ant-design/icons";
3
3
 
4
4
  const IconFontCN = createFromIconfontCN({
5
- scriptUrl: 'https://at.alicdn.com/t/c/font_5072483_pswdqptbsip.js'
6
- })
5
+ scriptUrl: "https://at.alicdn.com/t/c/font_5072483_zvtcct793i.js",
6
+ });
7
7
 
8
8
  export type IconFontProps = {
9
- type: string
10
- className?: string
11
- }
12
-
13
- export const IconFont: React.FC<IconFontProps> = ({ type, className = '' }) => {
14
- return <IconFontCN type={type} className={className} />
15
- }
9
+ type: string;
10
+ className?: string;
11
+ style?: React.CSSProperties;
12
+ };
16
13
 
14
+ export const IconFont: React.FC<IconFontProps> = ({
15
+ type,
16
+ className = "",
17
+ style = {},
18
+ }) => {
19
+ return <IconFontCN type={type} className={className} style={style} />;
20
+ };
@@ -8,12 +8,13 @@ import React, {
8
8
  } from "react";
9
9
  import styled from "styled-components";
10
10
  import { DropContainer } from "../dnd/DropContainer";
11
- import { CallbacksType, EnvType } from "../typing";
11
+ import { CallbacksType, EnvType, FetchType } from "../typing";
12
12
  import { DesignerContext } from "../context/DesignerContext";
13
13
  import { EnvProvider } from "../context/EnvContext";
14
14
 
15
15
  export type PageCanvasProps = {
16
16
  device?: "desktop" | "mobile" | "tablet";
17
+ fetch?: FetchType;
17
18
  };
18
19
 
19
20
  const Wrapper = styled.div`
@@ -53,7 +54,7 @@ const Wrapper = styled.div`
53
54
  `;
54
55
 
55
56
  export const PageCanvas = React.forwardRef<any, PageCanvasProps>(
56
- function PageCanvas({ device = "desktop" }, ref) {
57
+ ({ device = "desktop", fetch }, ref) => {
57
58
  const { schema, forceUpdate } = useContext(DesignerContext);
58
59
  const rootRef = useRef<HTMLDivElement | null>(null);
59
60
  const [canvasWidth, setCanvasWidth] = useState(0);
@@ -129,6 +130,7 @@ export const PageCanvas = React.forwardRef<any, PageCanvasProps>(
129
130
  env={env}
130
131
  callbacks={callbacks}
131
132
  initCallback={initCallback}
133
+ fetch={fetch}
132
134
  >
133
135
  <Wrapper ref={rootRef}>
134
136
  <DropContainer
@@ -90,7 +90,7 @@ export const PageItem: React.FC<PageItemProps> = ({
90
90
  if (selectedItem && selectedItem === item && designable) {
91
91
  const div = document.createElement("div");
92
92
  div.style.position = "absolute";
93
- div.style.zIndex = "9999";
93
+ div.style.zIndex = "1000";
94
94
  div.style.display = "flex";
95
95
  div.style.gap = "4px";
96
96
  const text = document.createElement("span");