bi-sdk-react 0.0.26 → 0.0.27

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 (42) hide show
  1. package/dist/es/js/bi-sdk.es.js +34 -34
  2. package/dist/types/components/context/PageContext.d.ts +12 -2
  3. package/dist/types/components/hooks/datasource.d.ts +2 -1
  4. package/dist/types/components/index.d.ts +1 -3
  5. package/dist/types/components/layout/PageCanvas.d.ts +0 -2
  6. package/dist/types/components/plugins/@antd/items/ButtonRender.d.ts +1 -1
  7. package/dist/types/components/plugins/@antd/items/CapsuleRender.d.ts +1 -1
  8. package/dist/types/components/plugins/@antd/items/CheckboxRender.d.ts +1 -1
  9. package/dist/types/components/plugins/@antd/items/DatePickerRender.d.ts +3 -3
  10. package/dist/types/components/plugins/@antd/items/InputNumberRender.d.ts +1 -1
  11. package/dist/types/components/plugins/@antd/items/InputRender.d.ts +2 -2
  12. package/dist/types/components/plugins/@antd/items/SelectRender.d.ts +2 -2
  13. package/dist/types/components/plugins/@antd/items/SwitchRender.d.ts +1 -1
  14. package/dist/types/components/plugins/@antd/items/TableRender.d.ts +1 -1
  15. package/dist/types/components/typing.d.ts +6 -2
  16. package/dist/types/components/utils.d.ts +0 -8
  17. package/dist/umd/js/bi-sdk.umd.min.js +34 -34
  18. package/package.json +1 -1
  19. package/src/components/PageDesigner.tsx +0 -1
  20. package/src/components/context/PageContext.tsx +106 -3
  21. package/src/components/hooks/datasource.ts +29 -10
  22. package/src/components/index.ts +4 -10
  23. package/src/components/layout/PageCanvas.tsx +13 -45
  24. package/src/components/panel/LayerPanel.tsx +0 -2
  25. package/src/components/panel/PropertiesPanel.tsx +11 -1
  26. package/src/components/plugins/@antd/items/ButtonRender.tsx +7 -6
  27. package/src/components/plugins/@antd/items/CapsuleRender.tsx +6 -6
  28. package/src/components/plugins/@antd/items/CheckboxRender.tsx +6 -6
  29. package/src/components/plugins/@antd/items/ColRender.tsx +2 -4
  30. package/src/components/plugins/@antd/items/DatePickerRender.tsx +8 -8
  31. package/src/components/plugins/@antd/items/EchartsRender.tsx +31 -16
  32. package/src/components/plugins/@antd/items/HtmlRender.tsx +22 -13
  33. package/src/components/plugins/@antd/items/InputNumberRender.tsx +5 -6
  34. package/src/components/plugins/@antd/items/InputRender.tsx +6 -7
  35. package/src/components/plugins/@antd/items/ListRender.tsx +19 -15
  36. package/src/components/plugins/@antd/items/SelectRender.tsx +6 -7
  37. package/src/components/plugins/@antd/items/SwitchRender.tsx +5 -6
  38. package/src/components/plugins/@antd/items/TableRender.tsx +4 -6
  39. package/src/components/typing.ts +7 -1
  40. package/src/components/utils.ts +0 -34
  41. package/src/example.tsx +1 -1
  42. package/src/components/context/EnvContext.tsx +0 -45
@@ -1,4 +1,8 @@
1
- import { DatasetAddFunction, DatasetSelectorFunction, FetchType, PageSchema, PluginType, SchemaItemType } from "../typing";
1
+ import { CallbackType, DatasetAddFunction, DatasetSelectorFunction, FetchType, PageSchema, PluginType, SchemaItemType } from "../typing";
2
+ type InitCallbackParams = {
3
+ id: string;
4
+ callback: CallbackType;
5
+ };
2
6
  type PageContextType = {
3
7
  pageId: string;
4
8
  designable: boolean;
@@ -15,8 +19,14 @@ type PageContextType = {
15
19
  onAddAtItem?: (item: SchemaItemType) => void;
16
20
  onRemoveAtItem?: (item: SchemaItemType, index?: number) => void;
17
21
  fetch?: FetchType;
22
+ deviceWidth: number;
23
+ setDeviceWidth: (width: number) => void;
24
+ initCallback: ({ id, callback }: InitCallbackParams) => any;
25
+ handleCallback: (item: SchemaItemType, refresh?: boolean, consume?: (item: Omit<SchemaItemType, "children">, data: any) => void) => void;
26
+ getVars: (id: string) => Record<string, any>;
27
+ setVar: (item: SchemaItemType, key: string, value: any) => void;
18
28
  };
19
29
  export declare const PageContext: import("react").Context<PageContextType>;
20
- type PageProviderProps = React.PropsWithChildren<Omit<Partial<PageContextType>, "updateSelectedItem" | "schema" | "forceUpdate"> & Pick<PageContextType, "schema" | "pageId">>;
30
+ type PageProviderProps = React.PropsWithChildren<Omit<Partial<PageContextType>, "updateSelectedItem" | "schema" | "forceUpdate" | "deviceWidth" | "setDeviceWidth" | "initCallback" | "handleCallback" | "getVars" | "setVar"> & Pick<PageContextType, "schema" | "pageId">>;
21
31
  export declare const PageProvider: React.FC<PageProviderProps>;
22
32
  export {};
@@ -1,2 +1,3 @@
1
1
  import { SchemaItemType } from "../typing";
2
- export declare const useDatasource: (id?: string, datasource?: SchemaItemType["datasource"]) => any;
2
+ export type Signal = string | number;
3
+ export declare const useDatasource: (item: SchemaItemType, signal?: Signal) => any;
@@ -4,7 +4,5 @@ import { PageSchema } from "./typing";
4
4
  import { plugins, PropEditorProps } from "./plugins/@antd";
5
5
  import DropContainer from "./dnd/DropContainer";
6
6
  import { PageContext, PageProvider } from "./context/PageContext";
7
- import { EnvContext } from "./context/EnvContext";
8
- import { handleCallback } from "./utils";
9
7
  import { PluginType } from "./typing";
10
- export { PageCanvas, PageDesigner, PageSchema, DropContainer, PageContext, PageProvider, EnvContext, plugins, PropEditorProps, PluginType, handleCallback, };
8
+ export { DropContainer, PageCanvas, PageContext, PageDesigner, PageProvider, PageSchema, plugins, PluginType, PropEditorProps, };
@@ -1,8 +1,6 @@
1
1
  import React from "react";
2
- import { FetchType } from "../typing";
3
2
  export type PageCanvasProps = {
4
3
  device?: "desktop" | "mobile" | "tablet";
5
- fetch?: FetchType;
6
4
  };
7
5
  export declare const PageCanvas: React.ForwardRefExoticComponent<PageCanvasProps & React.RefAttributes<any>>;
8
6
  export default PageCanvas;
@@ -9,6 +9,6 @@ export type ButtonRenderProps = {
9
9
  block?: ButtonProps["block"];
10
10
  shape?: ButtonProps["shape"];
11
11
  ghost?: ButtonProps["ghost"];
12
- item?: SchemaItemType;
12
+ item: SchemaItemType;
13
13
  } & HtmlBaseProps;
14
14
  export declare const ButtonRender: React.FC<ButtonRenderProps>;
@@ -8,7 +8,7 @@ export type CapsuleRenderProps = {
8
8
  label: string;
9
9
  value: any;
10
10
  }[];
11
- item?: SchemaItemType;
11
+ item: SchemaItemType;
12
12
  onChange?: (v: any) => void;
13
13
  } & HtmlBaseProps;
14
14
  export declare const CapsuleRender: React.FC<CapsuleRenderProps>;
@@ -8,7 +8,7 @@ export type CheckboxRenderProps = {
8
8
  label: string;
9
9
  value: any;
10
10
  }[];
11
- item?: SchemaItemType;
11
+ item: SchemaItemType;
12
12
  onChange?: (value: any[]) => void;
13
13
  } & HtmlBaseProps;
14
14
  export declare const CheckboxRender: React.FC<CheckboxRenderProps>;
@@ -1,14 +1,14 @@
1
1
  import { type DatePickerProps } from "antd";
2
2
  import React from "react";
3
- import { HtmlBaseProps } from "../../../typing";
3
+ import { HtmlBaseProps, SchemaItemType } from "../../../typing";
4
4
  export type DatePickerRenderProps = {
5
5
  var?: string;
6
- size?: DatePickerProps['size'];
6
+ size?: DatePickerProps["size"];
7
7
  allowClear?: boolean;
8
8
  type?: "date" | "time" | "month" | "year" | "range";
9
9
  showTime?: boolean;
10
10
  value?: string | [string, string];
11
- item?: any;
11
+ item: SchemaItemType;
12
12
  onChange?: (value?: string | [string, string]) => void;
13
13
  } & HtmlBaseProps;
14
14
  export declare const DatePickerRender: React.FC<DatePickerRenderProps>;
@@ -11,7 +11,7 @@ export type InputNumberRenderProps = {
11
11
  max?: number;
12
12
  step?: number;
13
13
  precision?: number;
14
- item?: SchemaItemType;
14
+ item: SchemaItemType;
15
15
  onChange?: (v?: number) => void;
16
16
  } & HtmlBaseProps;
17
17
  export declare const InputNumberRender: React.FC<InputNumberRenderProps>;
@@ -6,10 +6,10 @@ export type InputRenderProps = {
6
6
  placeholder?: string;
7
7
  prefix?: React.ReactNode | string;
8
8
  suffix?: React.ReactNode | string;
9
- size?: InputProps['size'];
9
+ size?: InputProps["size"];
10
10
  allowClear?: boolean;
11
11
  search?: boolean;
12
- item?: SchemaItemType;
12
+ item: SchemaItemType;
13
13
  value?: string;
14
14
  onChange?: (v: string) => void;
15
15
  onSearch?: (v: string) => void;
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import { HtmlBaseProps, SchemaItemType } from "../../../typing";
4
4
  export type SelectRenderProps = {
5
5
  var?: string;
6
- size?: SelectProps['size'];
6
+ size?: SelectProps["size"];
7
7
  placeholder?: string;
8
8
  allowClear?: boolean;
9
9
  multiple?: boolean;
@@ -11,7 +11,7 @@ export type SelectRenderProps = {
11
11
  label: string;
12
12
  value: any;
13
13
  }[];
14
- item?: SchemaItemType;
14
+ item: SchemaItemType;
15
15
  value?: any;
16
16
  onChange?: (v: any) => void;
17
17
  } & HtmlBaseProps;
@@ -8,7 +8,7 @@ export type SwitchRenderProps = {
8
8
  size?: SwitchProps["size"];
9
9
  checkedChildren?: string;
10
10
  unCheckedChildren?: string;
11
- item?: SchemaItemType;
11
+ item: SchemaItemType;
12
12
  onChange?: (checked: boolean) => void;
13
13
  } & HtmlBaseProps;
14
14
  export declare const SwitchRender: React.FC<SwitchRenderProps>;
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { type TableProps } from "antd";
2
+ import React from "react";
3
3
  import { HtmlBaseProps } from "../../../typing";
4
4
  export type TableRenderProps = {
5
5
  dataSource?: any[];
@@ -182,7 +182,11 @@ export type EnvType = {
182
182
  global: Record<string, any>;
183
183
  local: Record<string, Record<string, any>>;
184
184
  };
185
- export type CallbacksType = Record<string, (v: any) => void>;
185
+ export type CallbackType = (refresh?: boolean, args?: any) => {
186
+ target: Omit<SchemaItemType, "children">;
187
+ data: any;
188
+ } | null | undefined | void;
189
+ export type CallbacksType = Record<string, CallbackType>;
186
190
  export type DatasetSelectorFunction = (onSelect: (dataset: DataSetType) => void) => React.ReactNode;
187
- export type DatasetAddFunction = (onAdd: (dataset: DataSetType) => void, onClose: () => void) => React.ReactNode;
191
+ export type DatasetAddFunction = (item: SchemaItemType, onAdd: (dataset: DataSetType) => void, onClose: () => void) => React.ReactNode;
188
192
  export {};
@@ -1,11 +1,3 @@
1
- import { CallbacksType, EnvType, SchemaItemType } from "./typing";
2
- type Env = EnvType;
3
- export declare const getVars: (env: Env, item: SchemaItemType) => {
4
- [x: string]: any;
5
- };
6
- export declare const setVar: (env: Env, item: SchemaItemType, key: string, value: any) => void;
7
- export declare const handleCallback: (env: Env, item: SchemaItemType, callbacks: CallbacksType) => void;
8
1
  export declare const uuid: () => string;
9
2
  export declare const formatTime: (dateStr: string) => string;
10
3
  export declare const isMobile: () => boolean;
11
- export {};