bi-sdk-react 0.0.7 → 0.0.9

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 (31) hide show
  1. package/dist/es/css/bi-sdk.css +1 -1
  2. package/dist/es/js/bi-sdk.es.js +8 -8
  3. package/dist/types/components/PageDesigner.d.ts +3 -1
  4. package/dist/types/components/context/PageContext.d.ts +18 -0
  5. package/dist/types/components/index.d.ts +2 -2
  6. package/dist/types/components/utils.d.ts +1 -0
  7. package/dist/umd/css/bi-sdk.css +1 -1
  8. package/dist/umd/js/bi-sdk.umd.min.js +7 -7
  9. package/package.json +1 -1
  10. package/src/components/PageDesigner.tsx +30 -10
  11. package/src/components/context/{DesignerContext.tsx → PageContext.tsx} +8 -8
  12. package/src/components/dnd/DropContainer.tsx +2 -2
  13. package/src/components/index.ts +3 -2
  14. package/src/components/layout/PageCanvas.tsx +2 -2
  15. package/src/components/layout/PageItem.tsx +2 -2
  16. package/src/components/panel/AiPanel.tsx +8 -6
  17. package/src/components/panel/CascadePanel.tsx +2 -2
  18. package/src/components/panel/ChatInput.tsx +1 -1
  19. package/src/components/panel/CodePanel.tsx +2 -2
  20. package/src/components/panel/ComponentPanel.tsx +2 -2
  21. package/src/components/panel/DatasourcePanel.tsx +2 -2
  22. package/src/components/panel/LayerPanel.tsx +6 -4
  23. package/src/components/panel/PropertiesPanel.tsx +2 -2
  24. package/src/components/panel/ScriptPanel.tsx +2 -2
  25. package/src/components/panel/VariablesPanel.tsx +2 -2
  26. package/src/components/plugins/@antd/items/CardRender.tsx +1 -1
  27. package/src/components/plugins/@antd/items/ColRender.tsx +2 -2
  28. package/src/components/plugins/@antd/items/RowRender.tsx +2 -2
  29. package/src/components/plugins/@antd/items/SpaceRender.tsx +2 -2
  30. package/src/components/styles.css +4 -0
  31. package/src/components/utils.ts +19 -3
@@ -608,7 +608,7 @@ export const ChatInput = React.forwardRef<
608
608
  <div className="agent-info">
609
609
  {selectedAgent.map((item, index) => (
610
610
  <div key={String(item.id)}>
611
- <span className="name">@ {item.name}</span>
611
+ <span className="name"><IconFont type="icon-at" />{item.name}</span>
612
612
  <a className="remove" onClick={() => onRemoveAgent(index)}>
613
613
  ×
614
614
  </a>
@@ -4,10 +4,10 @@ import { Tooltip, Space, message } from "antd";
4
4
  import { CopyOutlined } from "@ant-design/icons";
5
5
  import copy from "copy-to-clipboard";
6
6
  import { PaneHeader } from "./PaneHeader";
7
- import { DesignerContext } from "../context/DesignerContext";
7
+ import { PageContext } from "../context/PageContext";
8
8
 
9
9
  export const CodePanel: React.FC = () => {
10
- const { schema } = useContext(DesignerContext);
10
+ const { schema } = useContext(PageContext);
11
11
  const code = useMemo(() => JSON.stringify(schema || {}, null, 2), [schema]);
12
12
  const handleCopy = () => {
13
13
  if (copy(code || "")) {
@@ -1,7 +1,7 @@
1
1
  import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
2
2
  import React, { useContext, useEffect, useMemo, useRef } from "react";
3
3
  import styled from "styled-components";
4
- import { DesignerContext } from "../context/DesignerContext";
4
+ import { PageContext } from "../context/PageContext";
5
5
  import { IconFont } from "../icon/IconFont";
6
6
  import { PluginType } from "../typing";
7
7
  import { uuid } from "../utils";
@@ -89,7 +89,7 @@ const PluginTile: React.FC<{ plugin: PluginType }> = ({ plugin }) => {
89
89
  };
90
90
 
91
91
  export const ComponentPanel: React.FC = () => {
92
- const { plugins } = useContext(DesignerContext);
92
+ const { plugins } = useContext(PageContext);
93
93
  const grouped = useMemo(() => {
94
94
  const grouped: { group: string; items: PluginType[] }[] = [];
95
95
  plugins.forEach((item) => {
@@ -18,7 +18,7 @@ import {
18
18
  } from "antd";
19
19
  import React, { useContext, useMemo, useState } from "react";
20
20
  import styled from "styled-components";
21
- import { DesignerContext } from "../context/DesignerContext";
21
+ import { PageContext } from "../context/PageContext";
22
22
  import { IconFont } from "../icon/IconFont";
23
23
  import { PaneHeader } from "./PaneHeader";
24
24
  import { uuid } from "../utils";
@@ -64,7 +64,7 @@ const Root = styled.div`
64
64
  `;
65
65
 
66
66
  export const DatasourcePanel: React.FC = () => {
67
- const { schema, setSchema } = useContext(DesignerContext);
67
+ const { schema, setSchema } = useContext(PageContext);
68
68
 
69
69
  const [apiVisible, setApiVisible] = useState(false);
70
70
  const [sqlVisible, setSqlVisible] = useState(false);
@@ -2,7 +2,7 @@ import { MinusSquareOutlined, PlusSquareOutlined } from "@ant-design/icons";
2
2
  import { Space, Tooltip, Tree } from "antd";
3
3
  import React, { useContext, useMemo, useState } from "react";
4
4
  import styled from "styled-components";
5
- import { DesignerContext } from "../context/DesignerContext";
5
+ import { PageContext } from "../context/PageContext";
6
6
  import { uuid } from "../utils";
7
7
  import { PaneHeader } from "./PaneHeader";
8
8
 
@@ -39,7 +39,7 @@ export const LayerPanel: React.FC = () => {
39
39
  selectedItem,
40
40
  setSelectedItem: onSelect,
41
41
  plugins,
42
- } = useContext(DesignerContext);
42
+ } = useContext(PageContext);
43
43
  const [expandedKeys, setExpandedKeys] = useState<string[]>([]);
44
44
  const selectedKeys = useMemo(
45
45
  () => (selectedItem ? [selectedItem.id!] : []),
@@ -59,13 +59,14 @@ export const LayerPanel: React.FC = () => {
59
59
  c.push({
60
60
  key: uuid(),
61
61
  type: "slot",
62
+ title: "插槽-" + k,
62
63
  slot: k,
63
64
  origin: children,
64
65
  children: compute(children[k]),
65
66
  });
66
67
  });
67
68
  }
68
- return { key: id, title: type, item, type, children: c };
69
+ return { key: id, title: item.name, item, type, children: c };
69
70
  });
70
71
  };
71
72
  return compute(schema.items);
@@ -183,9 +184,10 @@ export const LayerPanel: React.FC = () => {
183
184
 
184
185
  const treeData = useMemo(() => {
185
186
  const computeTreeData = (list: any[] = []): any[] => {
187
+ console.log(list)
186
188
  return list.map((item) => ({
187
189
  key: item.key,
188
- title: <span>{formatType(item.type, (item as any).slot)}</span>,
190
+ title: <>{item?.title || formatType(item.type, (item as any).slot)}</>,
189
191
  children: item.children ? computeTreeData(item.children) : undefined,
190
192
  dataRef: item,
191
193
  }));
@@ -19,7 +19,7 @@ import {
19
19
  } from "antd";
20
20
  import React, { useContext, useMemo, useRef, useState } from "react";
21
21
  import styled from "styled-components";
22
- import { DesignerContext } from "../context/DesignerContext";
22
+ import { PageContext } from "../context/PageContext";
23
23
  import { IconFont } from "../icon/IconFont";
24
24
  import { PaneHeader } from "./PaneHeader";
25
25
  import { DataSetOutput, SchemaItemType, FieldType } from "../typing";
@@ -82,7 +82,7 @@ export const PropertiesPanel: React.FC<{
82
82
  schema,
83
83
  setSchema,
84
84
  datasetSelector,
85
- } = useContext(DesignerContext);
85
+ } = useContext(PageContext);
86
86
  const refCustomDatasource = useRef<any>(null);
87
87
  const [selectedTab, setSelectedTab] = useState<"1" | "2">("1");
88
88
  const items = useMemo(() => computeItems(schema?.items || []), [schema]);
@@ -5,7 +5,7 @@ import { PaneHeader } from "./PaneHeader";
5
5
  import styled from "styled-components";
6
6
  import { IconFont } from "../icon/IconFont";
7
7
  import { DeleteOutlined, EditOutlined } from "@ant-design/icons";
8
- import { DesignerContext } from "../context/DesignerContext";
8
+ import { PageContext } from "../context/PageContext";
9
9
  import { ScriptItem } from "../typing";
10
10
 
11
11
 
@@ -51,7 +51,7 @@ const Root = styled.div`
51
51
  `;
52
52
 
53
53
  export const ScriptPanel: React.FC = () => {
54
- const {schema, setSchema} = useContext(DesignerContext);
54
+ const {schema, setSchema} = useContext(PageContext);
55
55
  const [visible, setVisible] = React.useState(false);
56
56
  const [editIndex, setEditIndex] = React.useState(-1);
57
57
  const [form] = Form.useForm<ScriptItem>();
@@ -4,7 +4,7 @@ import { Table, Button, Space, Popconfirm, Modal, Form, Input } from "antd";
4
4
  import { PaneHeader } from "./PaneHeader";
5
5
  import { DeleteOutlined, EditOutlined } from "@ant-design/icons";
6
6
  import { IconFont } from "../icon/IconFont";
7
- import { DesignerContext } from "../context/DesignerContext";
7
+ import { PageContext } from "../context/PageContext";
8
8
  import { VariableItem } from "../typing";
9
9
 
10
10
 
@@ -22,7 +22,7 @@ const Root = styled.div`
22
22
  `;
23
23
 
24
24
  export const VariablesPanel: React.FC = () => {
25
- const {schema, setSchema} = useContext(DesignerContext);
25
+ const {schema, setSchema} = useContext(PageContext);
26
26
  const [visible, setVisible] = React.useState(false);
27
27
  const [editIndex, setEditIndex] = React.useState(-1);
28
28
  const [form] = Form.useForm<VariableItem>();
@@ -2,7 +2,7 @@ import { Card, CardProps } from "antd";
2
2
  import React, { useContext, useMemo, useState } from "react";
3
3
  import { DropContainer } from "../../../dnd/DropContainer";
4
4
  import { HtmlBaseProps } from "../../../typing";
5
- import { DesignerContext } from "../../../context/DesignerContext";
5
+ import { PageContext } from "../../../context/PageContext";
6
6
 
7
7
  export type CardRenderProps = {
8
8
  bordered?: boolean;
@@ -3,7 +3,7 @@ import React, { useContext, useMemo, useState } from "react";
3
3
  import { PageItem } from "../../../layout/PageItem";
4
4
  import { DropContainer } from "../../../dnd/DropContainer";
5
5
  import { HtmlBaseProps } from "../../../typing";
6
- import { DesignerContext } from "../../../context/DesignerContext";
6
+ import { PageContext } from "../../../context/PageContext";
7
7
  import { EnvContext } from "../../../context/EnvContext";
8
8
 
9
9
  export type ColRenderProps = {
@@ -30,7 +30,7 @@ export const ColRender: React.FC<ColRenderProps> = ({
30
30
  style = {},
31
31
  className,
32
32
  }) => {
33
- const { designable } = useContext(DesignerContext);
33
+ const { designable } = useContext(PageContext);
34
34
  const { deviceWidth } = useContext(EnvContext);
35
35
  const [localChildren, setLocalChildren] = useState(item.children || []);
36
36
 
@@ -2,7 +2,7 @@ import { Row } from "antd";
2
2
  import React, { useContext, useState } from "react";
3
3
  import { DropContainer } from "../../../dnd/DropContainer";
4
4
  import { HtmlBaseProps } from "../../../typing";
5
- import { DesignerContext } from "../../../context/DesignerContext";
5
+ import { PageContext } from "../../../context/PageContext";
6
6
 
7
7
  export type RowRenderProps = {
8
8
  gutter?: number | [number, number];
@@ -22,7 +22,7 @@ export const RowRender: React.FC<RowRenderProps> = ({
22
22
  style,
23
23
  className,
24
24
  }) => {
25
- const { designable } = useContext(DesignerContext);
25
+ const { designable } = useContext(PageContext);
26
26
  const [localChildren, setLocalChildren] = useState(item.children || []);
27
27
 
28
28
  const onLocalChildrenChange = (list: any[]) => {
@@ -2,7 +2,7 @@ import { Space } from "antd";
2
2
  import React, { useContext, useMemo, useState } from "react";
3
3
  import { DropContainer } from "../../../dnd/DropContainer";
4
4
  import { HtmlBaseProps } from "../../../typing";
5
- import { DesignerContext } from "../../../context/DesignerContext";
5
+ import { PageContext } from "../../../context/PageContext";
6
6
  import { type SizeType } from "antd/es/config-provider/SizeContext";
7
7
 
8
8
  export type SpaceRenderProps = {
@@ -21,7 +21,7 @@ export const SpaceRender: React.FC<SpaceRenderProps> = ({
21
21
  style = {},
22
22
  className,
23
23
  }) => {
24
- const { designable } = useContext(DesignerContext);
24
+ const { designable } = useContext(PageContext);
25
25
  const [localChildren, setLocalChildren] = useState(item.children || []);
26
26
 
27
27
  const onLocalChildrenChange = (list: any[]) => {
@@ -30,3 +30,7 @@ a.toolbar {
30
30
  content: none;
31
31
  }
32
32
  }
33
+
34
+ .ant-btn-link {
35
+ padding: 0;
36
+ }
@@ -36,8 +36,6 @@ export const handleCallback = (
36
36
 
37
37
  export const uuid = () => v4();
38
38
 
39
-
40
-
41
39
  export const formatTime = (dateStr: string) => {
42
40
  if (!dateStr) return "";
43
41
  const date = new Date(dateStr);
@@ -74,4 +72,22 @@ export const formatTime = (dateStr: string) => {
74
72
 
75
73
  const YYYY = date.getFullYear();
76
74
  return `${YYYY}-${MM}-${DD} ${HH}:${mm}`;
77
- };
75
+ };
76
+
77
+ export const isMobile = () => {
78
+ const userAgent = navigator.userAgent;
79
+ const mobileKeywords = [
80
+ "Android",
81
+ "iPhone",
82
+ "iPad",
83
+ "Windows Phone",
84
+ "BlackBerry",
85
+ "Opera Mini",
86
+ "Symbian",
87
+ "Kindle",
88
+ "Mobile",
89
+ ];
90
+
91
+ const regex = new RegExp(mobileKeywords.join("|"), "i");
92
+ return regex.test(userAgent);
93
+ };