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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bi-sdk-react",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/umd/js/bi-sdk.umd.min.js",
@@ -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/font_5072483_3ofyyta7h1e.js",
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", padding: "0 10px" }}>
155
+ <div style={{ border: "1px solid #d9d9d9" }}>
156
156
  <div className="function-wrapper">function fixed(data) {"{"}</div>
157
157
  <Editor
158
158
  height="200px"
@@ -57,7 +57,7 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
57
57
  const html = useMemo(
58
58
  () =>
59
59
  (template || "").replace(
60
- /##\s*([^#]+)\s*##/g,
60
+ /{\s*{\s*([^#]+)\s*}\s*}/g,
61
61
  (_match: any, p1: string) => {
62
62
  try {
63
63
  return (func(p1) as any)(...args);
package/src/example.tsx CHANGED
@@ -383,7 +383,7 @@ const example = {
383
383
  name: "平均成绩数值",
384
384
  type: "b-html",
385
385
  props: {
386
- template: "##score## 分",
386
+ template: "{{score}} 分",
387
387
  classNames: [
388
388
  "text-3xl",
389
389
  "font-bold",
@@ -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 {};