bi-sdk-react 0.0.52 → 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.
- package/dist/es/js/bi-sdk.es.js +14 -14
- package/dist/types/components/context/PageContext.d.ts +2 -0
- package/dist/umd/js/bi-sdk.umd.min.js +12 -12
- package/package.json +1 -1
- package/src/components/context/PageContext.tsx +10 -0
- package/src/components/icon/IconFont.tsx +1 -1
- package/src/components/panel/ScriptPanel.tsx +1 -1
- package/src/components/plugins/@antd/items/HtmlRender.tsx +1 -1
- package/src/example.tsx +1 -1
- package/dist/types/components/context/DesignerContext.d.ts +0 -18
- package/dist/types/components/context/EnvContext.d.ts +0 -16
package/package.json
CHANGED
|
@@ -60,6 +60,8 @@ type PageContextType = {
|
|
|
60
60
|
) => any;
|
|
61
61
|
getVars: (id: string) => Record<string, any>;
|
|
62
62
|
setVar: (item: SchemaItemType, key: string, value: any) => void;
|
|
63
|
+
getGlobalVar: (key: string) => string | undefined | null;
|
|
64
|
+
setGlobalVar: (key: string, value: any) => void;
|
|
63
65
|
setItemData?: (id: string, data: any) => void;
|
|
64
66
|
};
|
|
65
67
|
|
|
@@ -95,6 +97,8 @@ export const PageContext = createContext<PageContextType>({
|
|
|
95
97
|
handleMethod: () => {},
|
|
96
98
|
getVars: () => ({}),
|
|
97
99
|
setVar: () => {},
|
|
100
|
+
getGlobalVar: () => undefined,
|
|
101
|
+
setGlobalVar: () => {},
|
|
98
102
|
setItemData: () => {},
|
|
99
103
|
});
|
|
100
104
|
|
|
@@ -214,6 +218,10 @@ export const PageProvider: React.FC<PageProviderProps> = ({
|
|
|
214
218
|
next.local[id][key] = value;
|
|
215
219
|
});
|
|
216
220
|
};
|
|
221
|
+
const getGlobalVar = (key: string) => env.global[key];
|
|
222
|
+
const setGlobalVar = (key: string, value: any) => {
|
|
223
|
+
setEnv((e: EnvType) => ({ ...e, global: { ...e.global, [key]: value } }));
|
|
224
|
+
};
|
|
217
225
|
|
|
218
226
|
useEffect(() => {
|
|
219
227
|
const nextGlobal: Record<string, any> = {};
|
|
@@ -252,6 +260,8 @@ export const PageProvider: React.FC<PageProviderProps> = ({
|
|
|
252
260
|
handleMethod,
|
|
253
261
|
getVars,
|
|
254
262
|
setVar,
|
|
263
|
+
getGlobalVar,
|
|
264
|
+
setGlobalVar,
|
|
255
265
|
setItemData,
|
|
256
266
|
}}
|
|
257
267
|
>
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { createFromIconfontCN } from "@ant-design/icons";
|
|
3
3
|
|
|
4
4
|
const IconFontCN = createFromIconfontCN({
|
|
5
|
-
scriptUrl: "https://at.alicdn.com/t/c/
|
|
5
|
+
scriptUrl: "https://at.alicdn.com/t/c/font_5072483_8ex0em5yn29.js",
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export type IconFontProps = {
|
|
@@ -152,7 +152,7 @@ export const ScriptPanel: React.FC = () => {
|
|
|
152
152
|
name="script"
|
|
153
153
|
rules={[{ required: true, message: "请输入脚本语句" }]}
|
|
154
154
|
>
|
|
155
|
-
<div style={{ border: "1px solid #d9d9d9"
|
|
155
|
+
<div style={{ border: "1px solid #d9d9d9" }}>
|
|
156
156
|
<div className="function-wrapper">function fixed(data) {"{"}</div>
|
|
157
157
|
<Editor
|
|
158
158
|
height="200px"
|
package/src/example.tsx
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DatasetSelectorFunction, FetchType, PageSchema, PluginType, SchemaItemType } from "../typing";
|
|
2
|
-
type DesignerContextType = {
|
|
3
|
-
pageId: string;
|
|
4
|
-
designable: boolean;
|
|
5
|
-
plugins: PluginType[];
|
|
6
|
-
schema: PageSchema;
|
|
7
|
-
selectedItem?: SchemaItemType | null;
|
|
8
|
-
setSchema: React.Dispatch<React.SetStateAction<PageSchema>>;
|
|
9
|
-
setSelectedItem: React.Dispatch<React.SetStateAction<SchemaItemType | null>>;
|
|
10
|
-
updateSelectedItem: (selectedItem?: Partial<SchemaItemType> | null) => void;
|
|
11
|
-
forceUpdate: () => void;
|
|
12
|
-
datasetSelector?: DatasetSelectorFunction;
|
|
13
|
-
fetch?: FetchType;
|
|
14
|
-
};
|
|
15
|
-
export declare const DesignerContext: import("react").Context<DesignerContextType>;
|
|
16
|
-
type DesignerProviderProps = React.PropsWithChildren<Omit<Partial<DesignerContextType>, "updateSelectedItem" | "schema" | "forceUpdate"> & Pick<DesignerContextType, "schema" | "pageId">>;
|
|
17
|
-
export declare const DesignerProvider: React.FC<DesignerProviderProps>;
|
|
18
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { CallbacksType, EnvType, FetchType } from "../typing";
|
|
3
|
-
type InitCallbackParams = {
|
|
4
|
-
id: string;
|
|
5
|
-
callback: (v: any) => void;
|
|
6
|
-
};
|
|
7
|
-
type EnvContextType = {
|
|
8
|
-
deviceWidth: number;
|
|
9
|
-
env: EnvType;
|
|
10
|
-
fetch?: FetchType;
|
|
11
|
-
callbacks: CallbacksType;
|
|
12
|
-
initCallback: ({ id, callback }: InitCallbackParams) => void;
|
|
13
|
-
};
|
|
14
|
-
export declare const EnvContext: import("react").Context<EnvContextType>;
|
|
15
|
-
export declare const EnvProvider: FC<PropsWithChildren<EnvContextType>>;
|
|
16
|
-
export {};
|