bi-sdk-react 0.0.11 → 0.0.12

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.
@@ -1048,7 +1048,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
1048
1048
  const module = undefined;
1049
1049
  const exports = undefined;
1050
1050
  ${e}
1051
- `)(eg,console,Math,Date,Array,Object,String,Number,Boolean,p)}catch(e){return console.error("ECharts 配置解析失败:",e),null}}})(l);c&&e&&(c.setOption(e),setTimeout(()=>c.resize(),50))},[c,l]),(0,eN.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,eN.jsx)("div",{ref:d,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,eO.useRef)(null);return(0,eN.jsx)(K,{layout:"vertical",children:(0,eN.jsx)(K.Item,{label:(0,eN.jsxs)(eN.Fragment,{children:["Echarts 渲染脚本"," ",(0,eN.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,eN.jsx)(tS,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,eN.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,eN.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,eN.jsx)(em,{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,eN.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1051
+ `)(eg,console,Math,Date,Array,Object,String,Number,Boolean,p)}catch(e){return console.error("ECharts 配置解析失败:",e),null}}})(l);c&&e&&(c.setOption(e),setTimeout(()=>c.resize(),50))},[c,l]),(0,eN.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,eN.jsx)("div",{ref:d,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,eO.useRef)(null);return(0,eN.jsxs)(K,{children:[(0,eN.jsx)(K.Item,{name:"height",label:"高度",labelCol:{span:6},wrapperCol:{span:18},children:(0,eN.jsx)(J,{size:"small",min:10,max:1e3,suffix:"px",onChange:e=>l&&l({...t,height:e})})}),(0,eN.jsx)(K.Item,{layout:"vertical",label:(0,eN.jsxs)(eN.Fragment,{children:["Echarts 渲染脚本"," ",(0,eN.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,eN.jsx)(tS,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,eN.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,eN.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,eN.jsx)(em,{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,eN.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1052
1052
  return {
1053
1053
  xAxis: { type: 'category', data: data.map(i => i.name) },
1054
1054
  yAxis: { type: 'value' },
@@ -2,5 +2,6 @@ import React from "react";
2
2
  import type { PropEditorProps } from "./types";
3
3
  export type EchartsModel = {
4
4
  script: string;
5
+ height?: number;
5
6
  };
6
7
  export declare const EchartsProps: React.FC<PropEditorProps<EchartsModel>>;
@@ -1048,7 +1048,7 @@
1048
1048
  const module = undefined;
1049
1049
  const exports = undefined;
1050
1050
  ${e}
1051
- `)(tI,console,Math,Date,Array,Object,String,Number,Boolean,x)}catch(e){return console.error("ECharts 配置解析失败:",e),null}}})(l);u&&e&&(u.setOption(e),setTimeout(()=>u.resize(),50))},[u,l]),(0,d.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,d.jsx)("div",{ref:c,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,p.useRef)(null);return(0,d.jsx)(ey.Form,{layout:"vertical",children:(0,d.jsx)(ey.Form.Item,{label:(0,d.jsxs)(d.Fragment,{children:["Echarts 渲染脚本"," ",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(ew,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,d.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,d.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,d.jsx)(eV(),{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,d.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1051
+ `)(tI,console,Math,Date,Array,Object,String,Number,Boolean,x)}catch(e){return console.error("ECharts 配置解析失败:",e),null}}})(l);u&&e&&(u.setOption(e),setTimeout(()=>u.resize(),50))},[u,l]),(0,d.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,d.jsx)("div",{ref:c,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,p.useRef)(null);return(0,d.jsxs)(ey.Form,{children:[(0,d.jsx)(ey.Form.Item,{name:"height",label:"高度",labelCol:{span:6},wrapperCol:{span:18},children:(0,d.jsx)(ey.InputNumber,{size:"small",min:10,max:1e3,suffix:"px",onChange:e=>l&&l({...t,height:e})})}),(0,d.jsx)(ey.Form.Item,{layout:"vertical",label:(0,d.jsxs)(d.Fragment,{children:["Echarts 渲染脚本"," ",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(ew,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,d.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,d.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,d.jsx)(eV(),{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,d.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1052
1052
  return {
1053
1053
  xAxis: { type: 'category', data: data.map(i => i.name) },
1054
1054
  yAxis: { type: 'value' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bi-sdk-react",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/umd/js/bi-sdk.umd.min.js",
@@ -1,10 +1,10 @@
1
1
  import React, { useRef } from "react";
2
- import { Form } from "antd";
2
+ import { Form, InputNumber } from "antd";
3
3
  import Editor from "@monaco-editor/react";
4
4
  import type { PropEditorProps } from "./types";
5
5
  import { IconFont } from "../../../icon/IconFont";
6
6
 
7
- export type EchartsModel = { script: string };
7
+ export type EchartsModel = { script: string; height?: number };
8
8
 
9
9
  export const EchartsProps: React.FC<PropEditorProps<EchartsModel>> = ({
10
10
  model,
@@ -13,14 +13,20 @@ export const EchartsProps: React.FC<PropEditorProps<EchartsModel>> = ({
13
13
  const ref = useRef<any>(null);
14
14
  const setScript = (v?: string) =>
15
15
  onChange && onChange({ ...model, script: v || "" });
16
+ const triggerModel = (key: keyof EchartsModel, value: any) =>
17
+ onChange && onChange({ ...model, [key]: value });
16
18
  const format = () => {
17
19
  // Monaco-react does not expose format directly; relying on editor action
18
20
  const editor = (ref.current as any)?.editor;
19
21
  editor?.getAction("editor.action.formatDocument")?.run();
20
22
  };
21
23
  return (
22
- <Form layout="vertical">
24
+ <Form>
25
+ <Form.Item name="height" label="高度" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
26
+ <InputNumber size="small" min={10} max={1000} suffix="px" onChange={(v) => triggerModel("height", v)} />
27
+ </Form.Item>
23
28
  <Form.Item
29
+ layout="vertical"
24
30
  label={
25
31
  <>
26
32
  Echarts 渲染脚本{" "}