bi-sdk-react 0.0.51 → 0.0.53

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 (29) hide show
  1. package/dist/es/js/bi-sdk.es.js +103 -38
  2. package/dist/types/components/context/PageContext.d.ts +12 -0
  3. package/dist/types/components/hooks/event.d.ts +4 -0
  4. package/dist/types/components/hooks/method.d.ts +4 -0
  5. package/dist/types/components/panel/EventPanel.d.ts +2 -0
  6. package/dist/types/components/plugins/@antd/items/EchartsRender.d.ts +2 -2
  7. package/dist/types/components/typing.d.ts +13 -1
  8. package/dist/umd/js/bi-sdk.umd.min.js +104 -39
  9. package/package.json +1 -1
  10. package/src/components/PageDesigner.tsx +57 -41
  11. package/src/components/context/PageContext.tsx +54 -1
  12. package/src/components/dnd/DropContainer.tsx +0 -1
  13. package/src/components/hooks/event.ts +68 -0
  14. package/src/components/hooks/method.ts +13 -0
  15. package/src/components/icon/IconFont.tsx +1 -1
  16. package/src/components/panel/EventPanel.tsx +186 -0
  17. package/src/components/panel/ScriptPanel.tsx +1 -1
  18. package/src/components/plugins/@antd/index.ts +9 -1
  19. package/src/components/plugins/@antd/item-props/DrawerProps.tsx +18 -1
  20. package/src/components/plugins/@antd/item-props/ModalProps.tsx +18 -1
  21. package/src/components/plugins/@antd/items/ButtonRender.tsx +3 -0
  22. package/src/components/plugins/@antd/items/DrawerRender.tsx +15 -6
  23. package/src/components/plugins/@antd/items/EchartsRender.tsx +30 -3
  24. package/src/components/plugins/@antd/items/HtmlRender.tsx +1 -1
  25. package/src/components/plugins/@antd/items/ModalRender.tsx +14 -2
  26. package/src/components/typing.ts +13 -1
  27. package/src/example.tsx +1 -1
  28. package/dist/types/components/context/DesignerContext.d.ts +0 -18
  29. package/dist/types/components/context/EnvContext.d.ts +0 -16
@@ -3,6 +3,11 @@ type InitCallbackParams = {
3
3
  id: string;
4
4
  callback: CallbackType;
5
5
  };
6
+ type MethodParams = {
7
+ sourceId: string;
8
+ arg?: any;
9
+ };
10
+ type MethodType = Record<string, (params?: MethodParams) => any>;
6
11
  type PageContextType = {
7
12
  pageId: string;
8
13
  designable: boolean;
@@ -24,8 +29,15 @@ type PageContextType = {
24
29
  setDeviceWidth: (width: number) => void;
25
30
  initCallback: ({ id, callback }: InitCallbackParams) => any;
26
31
  handleCallback: (item: SchemaItemType, refresh?: boolean, consume?: (item: Omit<SchemaItemType, "children">, data: any) => void) => void;
32
+ initMethod: ({ id, method, }: {
33
+ id: string;
34
+ method: MethodType;
35
+ }) => any;
36
+ handleMethod: (item: SchemaItemType, targetId: string, methodName: string, arg?: any) => any;
27
37
  getVars: (id: string) => Record<string, any>;
28
38
  setVar: (item: SchemaItemType, key: string, value: any) => void;
39
+ getGlobalVar: (key: string) => string | undefined | null;
40
+ setGlobalVar: (key: string, value: any) => void;
29
41
  setItemData?: (id: string, data: any) => void;
30
42
  };
31
43
  export declare const PageContext: import("react").Context<PageContextType>;
@@ -0,0 +1,4 @@
1
+ import { SchemaItemType } from "../typing";
2
+ export declare const useEvent: (item: SchemaItemType) => {
3
+ handleEvent: (eventName: string, arg?: any) => any;
4
+ };
@@ -0,0 +1,4 @@
1
+ import { SchemaItemType } from "../typing";
2
+ export declare const useMethods: (item: SchemaItemType) => {
3
+ callMethod: (targetId: string, methodName: string, arg?: any) => any;
4
+ };
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const EventPanel: React.FC;
@@ -1,9 +1,9 @@
1
1
  import "echarts-wordcloud";
2
2
  import "echarts-liquidfill";
3
3
  import React from "react";
4
- import { HtmlBaseProps } from "../../../typing";
4
+ import { HtmlBaseProps, SchemaItemType } from "../../../typing";
5
5
  export type EchartsRenderProps = {
6
- item: any;
6
+ item: SchemaItemType;
7
7
  title?: string;
8
8
  script?: string;
9
9
  height?: number;
@@ -106,6 +106,10 @@ export type SchemaItemType = {
106
106
  custom?: string | null;
107
107
  dataset?: DataSetType;
108
108
  };
109
+ events?: {
110
+ name: string;
111
+ script: string;
112
+ }[];
109
113
  };
110
114
  export type PluginType = {
111
115
  group: string;
@@ -114,7 +118,15 @@ export type PluginType = {
114
118
  icon: string;
115
119
  component: React.FC<any>;
116
120
  formComponent?: React.FC<any>;
117
- defaultOptions?: Pick<SchemaItemType, "props" | "children" | "cascadeIds" | "datasource" | "style">;
121
+ defaultOptions?: Pick<SchemaItemType, "props" | "children" | "cascadeIds" | "datasource" | "events" | "style">;
122
+ events?: {
123
+ name: string;
124
+ handler: string;
125
+ }[];
126
+ methods?: {
127
+ name: string;
128
+ handler: string;
129
+ }[];
118
130
  };
119
131
  type NameValue = {
120
132
  name?: string;