bi-sdk-react 0.0.7 → 0.0.8

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.
@@ -1 +1 @@
1
- .ant-dropdown-menu-vertical{max-height:70vh;overflow:auto}a.toolbar{color:var(--ant-color-text-secondary)}a.toolbar.active{color:var(--ant-color-primary)}.ant-form-compact .ant-form-item{margin-bottom:8px}.ant-form-item-label label{align-items:center;display:inline-flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label{justify-content:space-between;align-items:center;width:100%;display:flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label:after{content:none}
1
+ .ant-dropdown-menu-vertical{max-height:70vh;overflow:auto}a.toolbar{color:var(--ant-color-text-secondary)}a.toolbar.active{color:var(--ant-color-primary)}.ant-form-compact .ant-form-item{margin-bottom:8px}.ant-form-item-label label{align-items:center;display:inline-flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label{justify-content:space-between;align-items:center;width:100%;display:flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label:after{content:none}.ant-btn-link{padding:0}
@@ -316,7 +316,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
316
316
  .send-btn.send-btn-active {
317
317
  background-color: var(--ant-color-primary);
318
318
  }
319
- `,tE=[],tD=[],tA=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],tB=[".xlsx",".wav"],tR=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[o,s]=(0,eO.useState)([]);(0,eO.useEffect)(()=>{t&&s([])},[t]);let d=[...tB,...tA].join(",");return(0,eN.jsxs)(q,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(o),l()},onCancel:l,width:600,children:[(0,eN.jsx)("div",{style:{marginBottom:16},children:(0,eN.jsxs)(ec.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,eN.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,eN.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,eN.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,eN.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,eN.jsxs)(eu.Dragger,{...{name:"file",multiple:!0,accept:d,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(s(t=>[...t,e]),!1):(ep.error(`不支持的文件类型: ${e.name}`),eu.LIST_IGNORE)}},children:[(0,eN.jsx)("p",{className:"ant-upload-drag-icon",children:(0,eN.jsx)(v,{})}),(0,eN.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,eN.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),o.length>0&&(0,eN.jsxs)("div",{style:{marginTop:16},children:[(0,eN.jsxs)(ec.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",o.length,")"]}),(0,eN.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:o.map((e,t)=>(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(h,{style:{color:"#52c41a"}}):(0,eN.jsx)(i,{style:{color:"#1890ff"}}),(0,eN.jsx)(ec.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,eN.jsxs)(ec.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,eN.jsx)(M,{type:"text",size:"small",icon:(0,eN.jsx)(c,{}),onClick:()=>{s(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},tL=eO.default.forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=tE,agentId:s=null,attachments:d=tD,onInput:u,onSubmit:p,onUpdateAgentId:x,onUpdateAttachments:m,onUploading:h,style:f={}}=e,g=(0,eO.useRef)(null),[v,j]=(0,eO.useState)([]),[y,b]=(0,eO.useState)(l||""),[w,C]=(0,eO.useState)(0),[S,z]=(0,eO.useState)(Array.isArray(d)?d:[]),[k,I]=(0,eO.useState)(!1),N=(0,eO.useMemo)(()=>!1,[]);(0,eO.useImperativeHandle)(t,()=>({focus(){var e;null==(e=g.current)||e.focus()}})),(0,eO.useEffect)(()=>b(l||""),[l]),(0,eO.useEffect)(()=>{u&&u(y)},[y]),(0,eO.useEffect)(()=>z(Array.isArray(d)?d:[]),[d]);let T=!!(y&&y.trim()),E=async e=>{if(I(!1),!h||!e.length)return;let t=[];for(let l of e)try{let e=await h(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...S,...t]),m&&m([...S,...t])},D=()=>{if(!T||a)return;let e=Date.now();if(e-w<400)return;C(e);let t=(y||"").trim();if(!t)return;let l={message:t,agents:v.map(e=>({id:e.id,name:e.name})),files:S.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};p&&p(l),b("")},A=(0,eN.jsx)(tO,{children:(0,eN.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,eN.jsx)("li",{children:(0,eN.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),j(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,eN.jsx)(tT,{style:f,children:(0,eN.jsxs)("div",{className:"chat-input",children:[(0,eN.jsxs)("div",{className:"input-stack",children:[S.length>0&&(0,eN.jsx)("div",{className:"attachment-bar",children:S.map(e=>(0,eN.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(tS,{type:"icon-excel"}):(0,eN.jsx)(tS,{type:"icon-audio"}),(0,eN.jsx)(ec.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=S.filter(e=>e.id!==t)),m&&m(l))},children:(0,eN.jsx)(c,{})})]},e.id))}),v.length>0&&(0,eN.jsx)("div",{className:"agent-info",children:v.map((e,t)=>(0,eN.jsxs)("div",{children:[(0,eN.jsxs)("span",{className:"name",children:["@ ",e.name]}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),j(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,eN.jsx)(U.TextArea,{ref:g,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:y,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),D()))},onChange:e=>b(e.target.value)})]}),(0,eN.jsxs)("div",{className:"footer",children:[(0,eN.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,eN.jsx)(W,{trigger:["click"],popupRender:()=>A,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,eN.jsx)(es,{title:"选择助理",children:(0,eN.jsx)(M,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,eN.jsx)(tS,{type:"icon-at"})})})}),h&&(0,eN.jsxs)(eN.Fragment,{children:[(0,eN.jsx)(es,{title:"上传文件",children:(0,eN.jsx)(M,{className:"attach-upload",onClick:()=>I(!0),disabled:r||a,children:(0,eN.jsx)(tS,{type:"icon-paper-clip"})})}),(0,eN.jsx)(tR,{open:k,onCancel:()=>I(!1),onOk:E,allowedExtensions:tB,allowedMimeTypes:tA})]})]}),(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,eN.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,eN.jsx)("a",{className:`send-btn ${!a&&(null==y?void 0:y.length)>0?"send-btn-active":""}`,onClick:D,children:(0,eN.jsx)(O,{})})]})]})]})})}),tM=t.div`
319
+ `,tE=[],tD=[],tA=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],tB=[".xlsx",".wav"],tR=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[o,s]=(0,eO.useState)([]);(0,eO.useEffect)(()=>{t&&s([])},[t]);let d=[...tB,...tA].join(",");return(0,eN.jsxs)(q,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(o),l()},onCancel:l,width:600,children:[(0,eN.jsx)("div",{style:{marginBottom:16},children:(0,eN.jsxs)(ec.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,eN.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,eN.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,eN.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,eN.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,eN.jsxs)(eu.Dragger,{...{name:"file",multiple:!0,accept:d,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(s(t=>[...t,e]),!1):(ep.error(`不支持的文件类型: ${e.name}`),eu.LIST_IGNORE)}},children:[(0,eN.jsx)("p",{className:"ant-upload-drag-icon",children:(0,eN.jsx)(v,{})}),(0,eN.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,eN.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),o.length>0&&(0,eN.jsxs)("div",{style:{marginTop:16},children:[(0,eN.jsxs)(ec.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",o.length,")"]}),(0,eN.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:o.map((e,t)=>(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(h,{style:{color:"#52c41a"}}):(0,eN.jsx)(i,{style:{color:"#1890ff"}}),(0,eN.jsx)(ec.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,eN.jsxs)(ec.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,eN.jsx)(M,{type:"text",size:"small",icon:(0,eN.jsx)(c,{}),onClick:()=>{s(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},tL=eO.default.forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=tE,agentId:s=null,attachments:d=tD,onInput:u,onSubmit:p,onUpdateAgentId:x,onUpdateAttachments:m,onUploading:h,style:f={}}=e,g=(0,eO.useRef)(null),[v,j]=(0,eO.useState)([]),[y,b]=(0,eO.useState)(l||""),[w,C]=(0,eO.useState)(0),[S,z]=(0,eO.useState)(Array.isArray(d)?d:[]),[k,I]=(0,eO.useState)(!1),N=(0,eO.useMemo)(()=>!1,[]);(0,eO.useImperativeHandle)(t,()=>({focus(){var e;null==(e=g.current)||e.focus()}})),(0,eO.useEffect)(()=>b(l||""),[l]),(0,eO.useEffect)(()=>{u&&u(y)},[y]),(0,eO.useEffect)(()=>z(Array.isArray(d)?d:[]),[d]);let T=!!(y&&y.trim()),E=async e=>{if(I(!1),!h||!e.length)return;let t=[];for(let l of e)try{let e=await h(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...S,...t]),m&&m([...S,...t])},D=()=>{if(!T||a)return;let e=Date.now();if(e-w<400)return;C(e);let t=(y||"").trim();if(!t)return;let l={message:t,agents:v.map(e=>({id:e.id,name:e.name})),files:S.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};p&&p(l),b("")},A=(0,eN.jsx)(tO,{children:(0,eN.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,eN.jsx)("li",{children:(0,eN.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),j(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,eN.jsx)(tT,{style:f,children:(0,eN.jsxs)("div",{className:"chat-input",children:[(0,eN.jsxs)("div",{className:"input-stack",children:[S.length>0&&(0,eN.jsx)("div",{className:"attachment-bar",children:S.map(e=>(0,eN.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(tS,{type:"icon-excel"}):(0,eN.jsx)(tS,{type:"icon-audio"}),(0,eN.jsx)(ec.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=S.filter(e=>e.id!==t)),m&&m(l))},children:(0,eN.jsx)(c,{})})]},e.id))}),v.length>0&&(0,eN.jsx)("div",{className:"agent-info",children:v.map((e,t)=>(0,eN.jsxs)("div",{children:[(0,eN.jsxs)("span",{className:"name",children:[(0,eN.jsx)(tS,{type:"icon-at"}),e.name]}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),j(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,eN.jsx)(U.TextArea,{ref:g,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:y,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),D()))},onChange:e=>b(e.target.value)})]}),(0,eN.jsxs)("div",{className:"footer",children:[(0,eN.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,eN.jsx)(W,{trigger:["click"],popupRender:()=>A,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,eN.jsx)(es,{title:"选择助理",children:(0,eN.jsx)(M,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,eN.jsx)(tS,{type:"icon-at"})})})}),h&&(0,eN.jsxs)(eN.Fragment,{children:[(0,eN.jsx)(es,{title:"上传文件",children:(0,eN.jsx)(M,{className:"attach-upload",onClick:()=>I(!0),disabled:r||a,children:(0,eN.jsx)(tS,{type:"icon-paper-clip"})})}),(0,eN.jsx)(tR,{open:k,onCancel:()=>I(!1),onOk:E,allowedExtensions:tB,allowedMimeTypes:tA})]})]}),(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,eN.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,eN.jsx)("a",{className:`send-btn ${!a&&(null==y?void 0:y.length)>0?"send-btn-active":""}`,onClick:D,children:(0,eN.jsx)(O,{})})]})]})]})})}),tM=t.div`
320
320
  width: 100%;
321
321
  padding: 0 12px;
322
322
  border-bottom: solid 1px #e8e8e8;
@@ -561,8 +561,8 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
561
561
  color: var(--ant-color-text-tertiary);
562
562
  }
563
563
  &-list {
564
- max-height: 200px;
565
- overflow: auto;
564
+ // max-height: 200px;
565
+ // overflow: auto;
566
566
  display: flex;
567
567
  flex-wrap: wrap;
568
568
  flex-direction: row;
@@ -736,7 +736,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
736
736
  overflow: hidden;
737
737
  text-overflow: ellipsis;
738
738
  }
739
- `,t5=()=>{let{schema:e,setSchema:t,selectedItem:l,setSelectedItem:n,plugins:r}=(0,eO.useContext)(tu),[a,i]=(0,eO.useState)([]),o=(0,eO.useMemo)(()=>l?[l.id]:[],[l]),s=(0,eO.useMemo)(()=>{let t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>{let l,{id:n,type:r,children:a}=e;return Array.isArray(a)?l=t(a):"object"==typeof a&&a&&(l=[],Object.keys(a).forEach(e=>{Array.isArray(a[e])&&l.push({key:ex(),type:"slot",slot:e,origin:a,children:t(a[e])})})),{key:n,title:r,item:e,type:r,children:l}})};return t(e.items)},[e]),d=(0,eO.useMemo)(()=>{let e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t.map(t=>{var l,n,a;return{key:t.key,title:(0,eN.jsx)("span",{children:(l=t.type,n=t.slot,"slot"===l?"插槽-"+n:(null==(a=r.find(e=>e.key===l))?void 0:a.label)||l)}),children:t.children?e(t.children):void 0,dataRef:t}})};return e(s)},[s]);return(0,eN.jsxs)(t8,{className:"layer-panel",children:[(0,eN.jsx)(tP,{title:"图层",extra:(0,eN.jsxs)(en,{children:[(0,eN.jsx)(es,{title:"全部展开",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>{let t=[],l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{var n;t.push(e.id),(null==(n=e.children)?void 0:n.length)&&l(e.children)})};l(e.items),i(t)},children:(0,eN.jsx)(S,{})})}),(0,eN.jsx)(es,{title:"全部收起",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>i([]),children:(0,eN.jsx)(b,{})})})]})}),(0,eN.jsx)("div",{className:"body",children:(0,eN.jsx)(t6,{draggable:{icon:!1,nodeDraggable:e=>!1},showIcon:!1,showLine:{showLeafIcon:!1},treeData:d,selectedKeys:o,expandedKeys:a,onSelect:(e,t)=>{"slot"!==t.node.dataRef.type&&n&&n(t.node.dataRef.item)},onDrop:l=>{let n;if(!(e=>{let t=e.node,l=e.dragNode;if("slot"===l.dataRef.type||!e.dropToGap&&!["b-row","b-col","b-card","slot"].includes(t.dataRef.type))return!1;if("b-col"===l.dataRef.type)if(!e.dropToGap)return"b-row"===t.dataRef.type;else return"b-col"===t.dataRef.type;return("b-col"!==t.dataRef.type||!e.dropToGap)&&("b-row"!==t.dataRef.type||!!e.dropToGap)||"b-col"===l.dataRef.type})(l))return;let r=l.node.key,a=l.dragNode.key,i=l.node.pos.split("-"),o=l.dropPosition-Number(i[i.length-1]),s=(e,t,l)=>{e.forEach((e,n,r)=>{if(e.id===t)return(e.children=e.children||[],"slot"===e.type)?l(e,n,r,e.children[e.slot]):l(e,n,r,e.children);if(Array.isArray(e.children))return s(e.children,t,l);if("object"==typeof e.children)for(let n in e.children)Array.isArray(e.children[n])&&s(e.children[n],t,l)})},d=e.items;if(s(d,a,(e,t,l)=>{l.splice(t,1),n=e}),l.dropToGap)if((l.node.children||[]).length>0&&l.node.expanded&&1===o)s(d,r,(e,t,l)=>{e.children=e.children||[],e.children.unshift(n)});else{let e=[],t=0;s(d,r,(l,n,r)=>{e=r,t=n}),-1===o?e.splice(t,0,n):e.splice(t+1,0,n)}else{if("slot"===l.node.dataRef.type){let{slot:e,origin:t}=l.node.dataRef;console.log(e,JSON.stringify(t)),t[e]=t[e]||[],t[e].push(n)}s(d,r,e=>{e.children=e.children||[],e.children.push(n)})}t&&t({...e,items:d})},onExpand:e=>i(e)})})]})},t9=t.div`
739
+ `,t5=()=>{let{schema:e,setSchema:t,selectedItem:l,setSelectedItem:n,plugins:r}=(0,eO.useContext)(tu),[a,i]=(0,eO.useState)([]),o=(0,eO.useMemo)(()=>l?[l.id]:[],[l]),s=(0,eO.useMemo)(()=>{let t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>{let l,{id:n,type:r,children:a}=e;return Array.isArray(a)?l=t(a):"object"==typeof a&&a&&(l=[],Object.keys(a).forEach(e=>{Array.isArray(a[e])&&l.push({key:ex(),type:"slot",title:"插槽-"+e,slot:e,origin:a,children:t(a[e])})})),{key:n,title:e.name,item:e,type:r,children:l}})};return t(e.items)},[e]),d=(0,eO.useMemo)(()=>{let e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return console.log(t),t.map(t=>{var l,n,a;return{key:t.key,title:(0,eN.jsx)(eN.Fragment,{children:(null==t?void 0:t.title)||(l=t.type,n=t.slot,"slot"===l?"插槽-"+n:(null==(a=r.find(e=>e.key===l))?void 0:a.label)||l)}),children:t.children?e(t.children):void 0,dataRef:t}})};return e(s)},[s]);return(0,eN.jsxs)(t8,{className:"layer-panel",children:[(0,eN.jsx)(tP,{title:"图层",extra:(0,eN.jsxs)(en,{children:[(0,eN.jsx)(es,{title:"全部展开",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>{let t=[],l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{var n;t.push(e.id),(null==(n=e.children)?void 0:n.length)&&l(e.children)})};l(e.items),i(t)},children:(0,eN.jsx)(S,{})})}),(0,eN.jsx)(es,{title:"全部收起",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>i([]),children:(0,eN.jsx)(b,{})})})]})}),(0,eN.jsx)("div",{className:"body",children:(0,eN.jsx)(t6,{draggable:{icon:!1,nodeDraggable:e=>!1},showIcon:!1,showLine:{showLeafIcon:!1},treeData:d,selectedKeys:o,expandedKeys:a,onSelect:(e,t)=>{"slot"!==t.node.dataRef.type&&n&&n(t.node.dataRef.item)},onDrop:l=>{let n;if(!(e=>{let t=e.node,l=e.dragNode;if("slot"===l.dataRef.type||!e.dropToGap&&!["b-row","b-col","b-card","slot"].includes(t.dataRef.type))return!1;if("b-col"===l.dataRef.type)if(!e.dropToGap)return"b-row"===t.dataRef.type;else return"b-col"===t.dataRef.type;return("b-col"!==t.dataRef.type||!e.dropToGap)&&("b-row"!==t.dataRef.type||!!e.dropToGap)||"b-col"===l.dataRef.type})(l))return;let r=l.node.key,a=l.dragNode.key,i=l.node.pos.split("-"),o=l.dropPosition-Number(i[i.length-1]),s=(e,t,l)=>{e.forEach((e,n,r)=>{if(e.id===t)return(e.children=e.children||[],"slot"===e.type)?l(e,n,r,e.children[e.slot]):l(e,n,r,e.children);if(Array.isArray(e.children))return s(e.children,t,l);if("object"==typeof e.children)for(let n in e.children)Array.isArray(e.children[n])&&s(e.children[n],t,l)})},d=e.items;if(s(d,a,(e,t,l)=>{l.splice(t,1),n=e}),l.dropToGap)if((l.node.children||[]).length>0&&l.node.expanded&&1===o)s(d,r,(e,t,l)=>{e.children=e.children||[],e.children.unshift(n)});else{let e=[],t=0;s(d,r,(l,n,r)=>{e=r,t=n}),-1===o?e.splice(t,0,n):e.splice(t+1,0,n)}else{if("slot"===l.node.dataRef.type){let{slot:e,origin:t}=l.node.dataRef;console.log(e,JSON.stringify(t)),t[e]=t[e]||[],t[e].push(n)}s(d,r,e=>{e.children=e.children||[],e.children.push(n)})}t&&t({...e,items:d})},onExpand:e=>i(e)})})]})},t9=t.div`
740
740
  display: flex;
741
741
  flex-direction: column;
742
742
  height: 100%;
@@ -919,7 +919,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
919
919
  border-right: solid 2px #1890ff;
920
920
  background: linear-gradient(to left, #1890ff1a, #ffffff);
921
921
  }
922
- `,ls=e=>{let{open:t,onCancel:l,onOk:n}=e,[r,a]=(0,eO.useState)(JSON.stringify({info:{},datasources:[],scripts:[],variables:[],items:[]}));return(0,eN.jsx)(q,{title:"导入页面",open:t,width:800,onCancel:l,onOk:()=>null==n?void 0:n(JSON.parse(r)),okText:"导入",cancelText:"取消",styles:{body:{height:"calc(100vh - 250px)",overflow:"auto"}},children:(0,eN.jsx)("div",{className:"body",style:{flex:"1 1 auto",display:"flex",height:"100%"},children:(0,eN.jsx)(eh,{height:"100%",defaultLanguage:"json",value:r,options:{minimap:{enabled:!1}},onChange:e=>a(e||"")})})})},ld=eO.default.forwardRef((e,t)=>{var l;let n,{pageId:r,agentList:a=[],plugins:i=[],headerExtra:o,datasourceEnable:d=!0,scriptEnable:c=!0,datasetPanel:p,datasetSelector:h,fetch:f}=e,v=(0,eO.useRef)(null),j=(0,eO.useRef)(null),[y,b]=(0,eO.useState)(1),[C,S]=(0,eO.useState)([]),[k,N]=(0,eO.useState)([]),[O,D]=(0,eO.useState)(!1),[R,L]=(0,eO.useState)("desktop"),[P,_]=(0,eO.useState)("component"),[$,F]=(0,eO.useState)((null==f?void 0:f.ai)?"ai":"props"),[Y,W]=(0,eO.useState)(!0),[K,U]=(0,eO.useState)(!0),[J,q]=(0,eO.useState)(null),[X,V]=(0,eO.useState)({info:{},datasources:[],scripts:[],variables:[],items:[]}),[Q,ee]=(0,eO.useState)(!0),[et,el]=(0,eO.useState)(!1),[er,ea]=(0,eO.useState)(!1),ei=(0,eO.useMemo)(()=>{let e=Y?"250px":"",t=K?"400px":"";return{gridTemplateColumns:`${e} 1fr ${t}`}},[Y,K]),eo=(0,eO.useMemo)(()=>({display:Y?"flex":"none"}),[Y]),ed=(0,eO.useMemo)(()=>({display:K?"flex":"none"}),[K]);l=[X],(n=(0,eO.useRef)()).current===JSON.stringify(l)&&n.current||(n.current=JSON.stringify(l),(()=>{O||(S(e=>e.length?[...e,JSON.parse(JSON.stringify(X))].slice(-50):[JSON.parse(JSON.stringify(X))]),N([]))})()),(0,eO.useImperativeHandle)(t,()=>({handleOpen(e){D(!0),ec(e.items),V(e),S([JSON.parse(JSON.stringify(e))]),N([]),setTimeout(()=>D(!1),0)}}));let ec=(e,t)=>{e&&e.forEach(e=>{e.id||(e.id=t||Math.random().toString(36).slice(2,10)),Array.isArray(e.children)?ec(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&ec(e.children[t],Math.random().toString(36).slice(2,10))})})},eu=e=>{var t,l,n;if((null==(t=e.datasets)?void 0:t.length)&&(null==j||null==(l=j.current)?void 0:l.reload)&&j.current.reload(),e.schema)V(e.schema);else if(null==(n=e.pageItems)?void 0:n.length){let t=new Map(e.pageItems.map(e=>[e.id,e])),l=JSON.parse(JSON.stringify(X)),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{t.has(e.id)&&(Object.keys(e).forEach(t=>{"id"!==t&&delete e[t]}),Object.assign(e,t.get(e.id))),Array.isArray(e.children)?n(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&n(e.children[t])})})};n(l.items),V(l)}},ep=(0,eO.useMemo)(()=>"cascade"!==$||(null==J?void 0:J.cascadeIds)?$:"props",[J,$]);return(0,eN.jsxs)(tp,{pageId:r,designable:Q,plugins:i,schema:X,selectedItem:J,setSchema:V,setSelectedItem:q,datasetSelector:h,fetch:f,children:[(0,eN.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 24px",borderBottom:"solid 1px #e8e8e8"},children:[(0,eN.jsxs)(en,{children:[(0,eN.jsx)("span",{style:{fontSize:16,fontWeight:500},children:"创建数据报表"}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"保存",children:(0,eN.jsx)("a",{className:"toolbar",children:(0,eN.jsx)(I,{})})}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"撤销",children:(0,eN.jsx)("a",{className:`toolbar ${C.length>1?"active":""}`,onClick:()=>{S(e=>{if(e.length<=1)return e;D(!0);let t=e[e.length-2];return N(e=>[...e,JSON.parse(JSON.stringify(X))]),V(t),q(null),setTimeout(()=>D(!1),0),e.slice(0,-1)})},children:(0,eN.jsx)(E,{})})}),(0,eN.jsx)(es,{title:"重做",children:(0,eN.jsx)("a",{className:`toolbar ${k.length>0?"active":""}`,onClick:()=>{N(e=>e.length?(D(!0),S(e=>[...e,JSON.parse(JSON.stringify(X))]),V(e[e.length-1]),q(null),setTimeout(()=>D(!1),0),e.slice(0,-1)):e)},children:(0,eN.jsx)(z,{})})}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"导入JSON",children:(0,eN.jsx)("a",{className:`toolbar ${k.length>0?"active":""}`,onClick:()=>{el(!0)},children:(0,eN.jsx)(g,{})})})]}),(0,eN.jsxs)(en,{children:[(0,eN.jsx)(es,{title:"缩小",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>b(parseFloat(Math.max(y-.1,.5).toFixed(1))),children:(0,eN.jsx)(B,{})})}),(0,eN.jsxs)("div",{style:{fontSize:12,color:"#999",userSelect:"none"},children:[(100*y).toFixed(0),"%"]}),(0,eN.jsx)(es,{title:"放大",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>b(parseFloat(Math.min(y+.1,2).toFixed(1))),children:(0,eN.jsx)(A,{})})}),(0,eN.jsx)(es,{title:"重置缩放",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>b(1),children:(0,eN.jsx)(tS,{type:"icon-zoom-reset"})})}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"切换左侧栏",children:(0,eN.jsx)("a",{className:`toolbar ${Y?"active":""}`,onClick:()=>{W(e=>!e),setTimeout(()=>{var e,t;return null==(t=v.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,eN.jsx)(tS,{type:"icon-sider-l"})})}),(0,eN.jsx)(es,{title:"切换右侧栏",children:(0,eN.jsx)("a",{className:`toolbar ${K?"active":""}`,onClick:()=>{U(e=>!e),setTimeout(()=>{var e,t;return null==(t=v.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,eN.jsx)(tS,{type:"icon-sider-r"})})}),o]})]}),(0,eN.jsxs)(lo,{style:ei,children:[(0,eN.jsxs)("div",{className:"left",style:eo,children:[(0,eN.jsx)("div",{style:{padding:"22px 1px 22px 0",borderRight:"solid 1px #e8e8e8"},children:(0,eN.jsxs)(Z.Group,{value:P,onChange:e=>_(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"left-pane-tabs",children:[(0,eN.jsx)(Z.Button,{value:"component",children:(0,eN.jsx)(es,{title:"组件",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-puzzle"})})}),(0,eN.jsx)(Z.Button,{value:"layer",children:(0,eN.jsx)(es,{title:"图层",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-outline"})})}),!!p&&(0,eN.jsx)(Z.Button,{value:"dataset",children:(0,eN.jsx)(es,{title:"数据集",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-dataset"})})}),d&&(0,eN.jsx)(Z.Button,{value:"datasource",title:"数据源",children:(0,eN.jsx)(es,{title:"数据源",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-datasource"})})}),c&&(0,eN.jsx)(Z.Button,{value:"script",children:(0,eN.jsx)(es,{title:"脚本",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-js"})})}),(0,eN.jsx)(Z.Button,{value:"env",children:(0,eN.jsx)(es,{title:"环境变量",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-variable"})})}),(0,eN.jsx)(Z.Button,{value:"code",children:(0,eN.jsx)(es,{title:"源码",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-json"})})})]})}),(0,eN.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["component"===P&&(0,eN.jsx)(t1,{}),"layer"===P&&(0,eN.jsx)(t5,{}),d&&"datasource"===P&&(0,eN.jsx)(t4,{}),c&&"script"===P&&(0,eN.jsx)(ll,{}),"env"===P&&(0,eN.jsx)(lr,{}),"code"===P&&(0,eN.jsx)(tQ,{}),!!p&&"dataset"===P&&(0,eN.jsx)(li,{ref:j,renderNode:p})]})]}),(0,eN.jsxs)("div",{className:"center",style:{flex:"1 1 auto"},children:[(0,eN.jsx)(tP,{title:"页面",extra:(0,eN.jsxs)(en,{children:[(0,eN.jsx)(M,{size:"small",type:Q?"default":"primary",icon:Q?(0,eN.jsx)(x,{}):(0,eN.jsx)(m,{}),onClick:()=>ee(!Q)}),(0,eN.jsxs)(Z.Group,{value:R,onChange:e=>L(e.target.value),size:"small",buttonStyle:"outline",children:[(0,eN.jsx)(Z.Button,{value:"desktop",title:"桌面",children:(0,eN.jsx)(u,{})}),(0,eN.jsx)(Z.Button,{value:"mobile",title:"移动设备",children:(0,eN.jsx)(w,{})}),(0,eN.jsx)(Z.Button,{value:"tablet",title:"平板设备",children:(0,eN.jsx)(T,{})})]})]})}),(0,eN.jsx)("div",{className:["body",R].join(" "),children:(0,eN.jsx)("div",{style:{transform:`scale(${y})`,transformOrigin:"top center"},children:(0,eN.jsx)(tb,{ref:v,device:R,fetch:f})})})]}),(0,eN.jsxs)("div",{className:"right",style:ed,children:[(0,eN.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["ai"===ep&&(null==f?void 0:f.ai)&&(0,eN.jsx)(tY,{agentList:a,onEffect:eu}),"props"===ep&&(0,eN.jsx)(t7,{datasourceEnable:d}),"cascade"===ep&&(null==J?void 0:J.cascadeIds)&&(0,eN.jsx)(tq,{})]}),(0,eN.jsx)("div",{style:{padding:"22px 0",borderLeft:"solid 1px #e8e8e8",display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center"},children:(0,eN.jsxs)(Z.Group,{value:ep,onChange:e=>F(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"right-pane-tabs",children:[(null==f?void 0:f.ai)&&(0,eN.jsx)(Z.Button,{value:"ai",children:(0,eN.jsx)(es,{title:"智能助理",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-assistant"})})}),(0,eN.jsx)(Z.Button,{value:"props",children:(0,eN.jsx)(es,{title:"属性",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-info"})})}),(null==J?void 0:J.cascadeIds)&&(0,eN.jsx)(Z.Button,{value:"cascade",children:(0,eN.jsx)(es,{title:"联动",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-cascade"})})})]})})]})]})]}),(0,eN.jsx)(ls,{open:et,onOk:e=>{el(!1),V(e)},onCancel:()=>el(!1)}),(0,eN.jsx)(G,{open:er,size:400,mask:!1,title:null,closable:!1,styles:{body:{padding:0}},onClose:()=>ea(!1),children:(0,eN.jsx)(tY,{agentList:a,headExtra:(0,eN.jsx)(M,{type:"link",icon:(0,eN.jsx)(s,{}),onClick:()=>ea(!1)}),onEffect:eu})})]})});var lc=((ez={}).STRING="STRING",ez.NUMBER="NUMBER",ez.BOOLEAN="BOOLEAN",ez.OBJECT="OBJECT",ez.ARRAY="ARRAY",ez);let lu=t(j)`
922
+ `,ls=e=>{let{open:t,onCancel:l,onOk:n}=e,[r,a]=(0,eO.useState)(JSON.stringify({info:{},datasources:[],scripts:[],variables:[],items:[]}));return(0,eN.jsx)(q,{title:"导入页面",open:t,width:800,onCancel:l,onOk:()=>null==n?void 0:n(JSON.parse(r)),okText:"导入",cancelText:"取消",styles:{body:{height:"calc(100vh - 250px)",overflow:"auto"}},children:(0,eN.jsx)("div",{className:"body",style:{flex:"1 1 auto",display:"flex",height:"100%"},children:(0,eN.jsx)(eh,{height:"100%",defaultLanguage:"json",value:r,options:{minimap:{enabled:!1}},onChange:e=>a(e||"")})})})},ld=eO.default.forwardRef((e,t)=>{var l;let n,{pageId:r,agentList:a=[],plugins:i=[],headerExtra:o,datasourceEnable:d=!0,scriptEnable:c=!0,datasetPanel:p,datasetSelector:h,fetch:f,onSave:v,loading:j=!1}=e,y=(0,eO.useRef)(null),b=(0,eO.useRef)(null),[C,S]=(0,eO.useState)(1),[k,N]=(0,eO.useState)([]),[O,D]=(0,eO.useState)([]),[R,L]=(0,eO.useState)(!1),[P,_]=(0,eO.useState)("desktop"),[$,F]=(0,eO.useState)("component"),[Y,W]=(0,eO.useState)((null==f?void 0:f.ai)?"ai":"props"),[K,U]=(0,eO.useState)(!0),[J,q]=(0,eO.useState)(!0),[X,V]=(0,eO.useState)(null),[Q,ee]=(0,eO.useState)({info:{},datasources:[],scripts:[],variables:[],items:[]}),[et,el]=(0,eO.useState)(!0),[er,ea]=(0,eO.useState)(!1),[ei,eo]=(0,eO.useState)(!1),ed=(0,eO.useMemo)(()=>{let e=K?"250px":"",t=J?"400px":"";return{gridTemplateColumns:`${e} 1fr ${t}`}},[K,J]),ec=(0,eO.useMemo)(()=>({display:K?"flex":"none"}),[K]),eu=(0,eO.useMemo)(()=>({display:J?"flex":"none"}),[J]);l=[Q],(n=(0,eO.useRef)()).current===JSON.stringify(l)&&n.current||(n.current=JSON.stringify(l),(()=>{R||(N(e=>e.length?[...e,JSON.parse(JSON.stringify(Q))].slice(-50):[JSON.parse(JSON.stringify(Q))]),D([]))})()),(0,eO.useImperativeHandle)(t,()=>({handleOpen(e){L(!0),ep(e.items),ee(e),N([JSON.parse(JSON.stringify(e))]),D([]),setTimeout(()=>L(!1),0)}}));let ep=(e,t)=>{e&&e.forEach(e=>{e.id||(e.id=t||Math.random().toString(36).slice(2,10)),Array.isArray(e.children)?ep(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&ep(e.children[t],Math.random().toString(36).slice(2,10))})})},ex=e=>{var t,l,n;if((null==(t=e.datasets)?void 0:t.length)&&(null==b||null==(l=b.current)?void 0:l.reload)&&b.current.reload(),e.schema)ee(e.schema);else if(null==(n=e.pageItems)?void 0:n.length){let t=new Map(e.pageItems.map(e=>[e.id,e])),l=JSON.parse(JSON.stringify(Q)),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{t.has(e.id)&&(Object.keys(e).forEach(t=>{"id"!==t&&delete e[t]}),Object.assign(e,t.get(e.id))),Array.isArray(e.children)?n(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&n(e.children[t])})})};n(l.items),ee(l)}},em=(0,eO.useMemo)(()=>"cascade"!==Y||(null==X?void 0:X.cascadeIds)?Y:"props",[X,Y]);return(0,eN.jsxs)(tp,{pageId:r,designable:et,plugins:i,schema:Q,selectedItem:X,setSchema:ee,setSelectedItem:V,datasetSelector:h,fetch:f,children:[(0,eN.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 24px",borderBottom:"solid 1px #e8e8e8"},children:[(0,eN.jsxs)(en,{children:[(0,eN.jsx)("span",{style:{fontSize:16,fontWeight:500},children:"创建数据报表"}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"保存",children:(0,eN.jsx)(M,{type:"link",className:"toolbar",onClick:()=>{null==v||v(Q)},loading:j,children:(0,eN.jsx)(I,{})})}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"撤销",children:(0,eN.jsx)("a",{className:`toolbar ${k.length>1?"active":""}`,onClick:()=>{N(e=>{if(e.length<=1)return e;L(!0);let t=e[e.length-2];return D(e=>[...e,JSON.parse(JSON.stringify(Q))]),ee(t),V(null),setTimeout(()=>L(!1),0),e.slice(0,-1)})},children:(0,eN.jsx)(E,{})})}),(0,eN.jsx)(es,{title:"重做",children:(0,eN.jsx)("a",{className:`toolbar ${O.length>0?"active":""}`,onClick:()=>{D(e=>e.length?(L(!0),N(e=>[...e,JSON.parse(JSON.stringify(Q))]),ee(e[e.length-1]),V(null),setTimeout(()=>L(!1),0),e.slice(0,-1)):e)},children:(0,eN.jsx)(z,{})})}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"导入JSON",children:(0,eN.jsx)("a",{className:`toolbar ${O.length>0?"active":""}`,onClick:()=>{ea(!0)},children:(0,eN.jsx)(g,{})})})]}),(0,eN.jsxs)(en,{children:[(0,eN.jsx)(es,{title:"缩小",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>S(parseFloat(Math.max(C-.1,.5).toFixed(1))),children:(0,eN.jsx)(B,{})})}),(0,eN.jsxs)("div",{style:{fontSize:12,color:"#999",userSelect:"none"},children:[(100*C).toFixed(0),"%"]}),(0,eN.jsx)(es,{title:"放大",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>S(parseFloat(Math.min(C+.1,2).toFixed(1))),children:(0,eN.jsx)(A,{})})}),(0,eN.jsx)(es,{title:"重置缩放",children:(0,eN.jsx)("a",{className:"toolbar",onClick:()=>S(1),children:(0,eN.jsx)(tS,{type:"icon-zoom-reset"})})}),(0,eN.jsx)(H,{orientation:"vertical"}),(0,eN.jsx)(es,{title:"切换左侧栏",children:(0,eN.jsx)("a",{className:`toolbar ${K?"active":""}`,onClick:()=>{U(e=>!e),setTimeout(()=>{var e,t;return null==(t=y.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,eN.jsx)(tS,{type:"icon-sider-l"})})}),(0,eN.jsx)(es,{title:"切换右侧栏",children:(0,eN.jsx)("a",{className:`toolbar ${J?"active":""}`,onClick:()=>{q(e=>!e),setTimeout(()=>{var e,t;return null==(t=y.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,eN.jsx)(tS,{type:"icon-sider-r"})})}),o]})]}),(0,eN.jsxs)(lo,{style:ed,children:[(0,eN.jsxs)("div",{className:"left",style:ec,children:[(0,eN.jsx)("div",{style:{padding:"22px 1px 22px 0",borderRight:"solid 1px #e8e8e8"},children:(0,eN.jsxs)(Z.Group,{value:$,onChange:e=>F(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"left-pane-tabs",children:[(0,eN.jsx)(Z.Button,{value:"component",children:(0,eN.jsx)(es,{title:"组件",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-puzzle"})})}),(0,eN.jsx)(Z.Button,{value:"layer",children:(0,eN.jsx)(es,{title:"图层",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-outline"})})}),!!p&&(0,eN.jsx)(Z.Button,{value:"dataset",children:(0,eN.jsx)(es,{title:"数据集",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-dataset"})})}),d&&(0,eN.jsx)(Z.Button,{value:"datasource",title:"数据源",children:(0,eN.jsx)(es,{title:"数据源",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-datasource"})})}),c&&(0,eN.jsx)(Z.Button,{value:"script",children:(0,eN.jsx)(es,{title:"脚本",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-js"})})}),(0,eN.jsx)(Z.Button,{value:"env",children:(0,eN.jsx)(es,{title:"环境变量",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-variable"})})}),(0,eN.jsx)(Z.Button,{value:"code",children:(0,eN.jsx)(es,{title:"源码",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-json"})})})]})}),(0,eN.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["component"===$&&(0,eN.jsx)(t1,{}),"layer"===$&&(0,eN.jsx)(t5,{}),d&&"datasource"===$&&(0,eN.jsx)(t4,{}),c&&"script"===$&&(0,eN.jsx)(ll,{}),"env"===$&&(0,eN.jsx)(lr,{}),"code"===$&&(0,eN.jsx)(tQ,{}),!!p&&"dataset"===$&&(0,eN.jsx)(li,{ref:b,renderNode:p})]})]}),(0,eN.jsxs)("div",{className:"center",style:{flex:"1 1 auto"},children:[(0,eN.jsx)(tP,{title:"页面",extra:(0,eN.jsxs)(en,{children:[(0,eN.jsx)(M,{size:"small",type:et?"default":"primary",icon:et?(0,eN.jsx)(x,{}):(0,eN.jsx)(m,{}),onClick:()=>el(!et)}),(0,eN.jsxs)(Z.Group,{value:P,onChange:e=>_(e.target.value),size:"small",buttonStyle:"outline",children:[(0,eN.jsx)(Z.Button,{value:"desktop",title:"桌面",children:(0,eN.jsx)(u,{})}),(0,eN.jsx)(Z.Button,{value:"mobile",title:"移动设备",children:(0,eN.jsx)(w,{})}),(0,eN.jsx)(Z.Button,{value:"tablet",title:"平板设备",children:(0,eN.jsx)(T,{})})]})]})}),(0,eN.jsx)("div",{className:["body",P].join(" "),children:(0,eN.jsx)("div",{style:{transform:`scale(${C})`,transformOrigin:"top center"},children:(0,eN.jsx)(tb,{ref:y,device:P,fetch:f})})})]}),(0,eN.jsxs)("div",{className:"right",style:eu,children:[(0,eN.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["ai"===em&&(null==f?void 0:f.ai)&&(0,eN.jsx)(tY,{agentList:a,onEffect:ex}),"props"===em&&(0,eN.jsx)(t7,{datasourceEnable:d}),"cascade"===em&&(null==X?void 0:X.cascadeIds)&&(0,eN.jsx)(tq,{})]}),(0,eN.jsx)("div",{style:{padding:"22px 0",borderLeft:"solid 1px #e8e8e8",display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center"},children:(0,eN.jsxs)(Z.Group,{value:em,onChange:e=>W(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"right-pane-tabs",children:[(null==f?void 0:f.ai)&&(0,eN.jsx)(Z.Button,{value:"ai",children:(0,eN.jsx)(es,{title:"智能助理",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-assistant"})})}),(0,eN.jsx)(Z.Button,{value:"props",children:(0,eN.jsx)(es,{title:"属性",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-info"})})}),(null==X?void 0:X.cascadeIds)&&(0,eN.jsx)(Z.Button,{value:"cascade",children:(0,eN.jsx)(es,{title:"联动",placement:"right",children:(0,eN.jsx)(tS,{type:"icon-cascade"})})})]})})]})]})]}),(0,eN.jsx)(ls,{open:er,onOk:e=>{ea(!1),ee(e)},onCancel:()=>ea(!1)}),(0,eN.jsx)(G,{open:ei,size:400,mask:!1,title:null,closable:!1,styles:{body:{padding:0}},onClose:()=>eo(!1),children:(0,eN.jsx)(tY,{agentList:a,headExtra:(0,eN.jsx)(M,{type:"link",icon:(0,eN.jsx)(s,{}),onClick:()=>eo(!1)}),onEffect:ex})})]})});var lc=((ez={}).STRING="STRING",ez.NUMBER="NUMBER",ez.BOOLEAN="BOOLEAN",ez.OBJECT="OBJECT",ez.ARRAY="ARRAY",ez);let lu=t(j)`
923
923
  vertical-align: middle;
924
924
  margin-left: 2px;
925
925
  color: var(--ant-color-text-description);
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import "./styles.css";
3
- import { DatasetSelectorFunction, FetchType, PluginType } from "./typing";
3
+ import { DatasetSelectorFunction, FetchType, PageSchema, PluginType } from "./typing";
4
4
  export type PageDesignerProps = {
5
5
  pageId: string;
6
6
  agentList?: any[];
@@ -13,6 +13,8 @@ export type PageDesignerProps = {
13
13
  }>>;
14
14
  datasetSelector?: DatasetSelectorFunction;
15
15
  fetch?: FetchType;
16
+ onSave?: (schema: PageSchema) => void;
17
+ loading?: boolean;
16
18
  };
17
19
  export declare const PageDesigner: React.ForwardRefExoticComponent<PageDesignerProps & React.RefAttributes<any>>;
18
20
  export default PageDesigner;
@@ -1 +1 @@
1
- .ant-dropdown-menu-vertical{max-height:70vh;overflow:auto}a.toolbar{color:var(--ant-color-text-secondary)}a.toolbar.active{color:var(--ant-color-primary)}.ant-form-compact .ant-form-item{margin-bottom:8px}.ant-form-item-label label{align-items:center;display:inline-flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label{justify-content:space-between;align-items:center;width:100%;display:flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label:after{content:none}
1
+ .ant-dropdown-menu-vertical{max-height:70vh;overflow:auto}a.toolbar{color:var(--ant-color-text-secondary)}a.toolbar.active{color:var(--ant-color-primary)}.ant-form-compact .ant-form-item{margin-bottom:8px}.ant-form-item-label label{align-items:center;display:inline-flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label{justify-content:space-between;align-items:center;width:100%;display:flex}.ant-form-item.ant-form-item-label-space .ant-form-item-label label:after{content:none}.ant-btn-link{padding:0}
@@ -316,7 +316,7 @@
316
316
  .send-btn.send-btn-active {
317
317
  background-color: var(--ant-color-primary);
318
318
  }
319
- `,eR=[],eF=[],eD=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],eE=[".xlsx",".wav"],eA=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[i,o]=(0,p.useState)([]);(0,p.useEffect)(()=>{t&&o([])},[t]);let s=[...eE,...eD].join(",");return(0,d.jsxs)(ey.Modal,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(i),l()},onCancel:l,width:600,children:[(0,d.jsx)("div",{style:{marginBottom:16},children:(0,d.jsxs)(ey.Typography.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,d.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,d.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,d.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,d.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,d.jsxs)(ey.Upload.Dragger,{...{name:"file",multiple:!0,accept:s,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(o(t=>[...t,e]),!1):(ey.message.error(`不支持的文件类型: ${e.name}`),ey.Upload.LIST_IGNORE)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ej.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),i.length>0&&(0,d.jsxs)("div",{style:{marginTop:16},children:[(0,d.jsxs)(ey.Typography.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",i.length,")"]}),(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:i.map((e,t)=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ej.FileExcelOutlined,{style:{color:"#52c41a"}}):(0,d.jsx)(ej.AudioOutlined,{style:{color:"#1890ff"}}),(0,d.jsx)(ey.Typography.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,d.jsxs)(ey.Typography.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,d.jsx)(ey.Button,{type:"text",size:"small",icon:(0,d.jsx)(ej.DeleteOutlined,{}),onClick:()=>{o(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},eB=m().forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=eR,agentId:s=null,attachments:c=eF,onInput:u,onSubmit:m,onUpdateAgentId:x,onUpdateAttachments:h,onUploading:f,style:g={}}=e,v=(0,p.useRef)(null),[j,y]=(0,p.useState)([]),[b,w]=(0,p.useState)(l||""),[C,S]=(0,p.useState)(0),[I,z]=(0,p.useState)(Array.isArray(c)?c:[]),[k,O]=(0,p.useState)(!1),N=(0,p.useMemo)(()=>!1,[]);(0,p.useImperativeHandle)(t,()=>({focus(){var e;null==(e=v.current)||e.focus()}})),(0,p.useEffect)(()=>w(l||""),[l]),(0,p.useEffect)(()=>{u&&u(b)},[b]),(0,p.useEffect)(()=>z(Array.isArray(c)?c:[]),[c]);let T=!!(b&&b.trim()),R=async e=>{if(O(!1),!f||!e.length)return;let t=[];for(let l of e)try{let e=await f(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...I,...t]),h&&h([...I,...t])},F=()=>{if(!T||a)return;let e=Date.now();if(e-C<400)return;S(e);let t=(b||"").trim();if(!t)return;let l={message:t,agents:j.map(e=>({id:e.id,name:e.name})),files:I.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};m&&m(l),w("")},D=(0,d.jsx)(eN,{children:(0,d.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),y(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,d.jsx)(eT,{style:g,children:(0,d.jsxs)("div",{className:"chat-input",children:[(0,d.jsxs)("div",{className:"input-stack",children:[I.length>0&&(0,d.jsx)("div",{className:"attachment-bar",children:I.map(e=>(0,d.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ew,{type:"icon-excel"}):(0,d.jsx)(ew,{type:"icon-audio"}),(0,d.jsx)(ey.Typography.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,d.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=I.filter(e=>e.id!==t)),h&&h(l))},children:(0,d.jsx)(ej.DeleteOutlined,{})})]},e.id))}),j.length>0&&(0,d.jsx)("div",{className:"agent-info",children:j.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:["@ ",e.name]}),(0,d.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),y(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,d.jsx)(ey.Input.TextArea,{ref:v,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:b,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),F()))},onChange:e=>w(e.target.value)})]}),(0,d.jsxs)("div",{className:"footer",children:[(0,d.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,d.jsx)(ey.Dropdown,{trigger:["click"],popupRender:()=>D,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,d.jsx)(ey.Tooltip,{title:"选择助理",children:(0,d.jsx)(ey.Button,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,d.jsx)(ew,{type:"icon-at"})})})}),f&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ey.Tooltip,{title:"上传文件",children:(0,d.jsx)(ey.Button,{className:"attach-upload",onClick:()=>O(!0),disabled:r||a,children:(0,d.jsx)(ew,{type:"icon-paper-clip"})})}),(0,d.jsx)(eA,{open:k,onCancel:()=>O(!1),onOk:R,allowedExtensions:eE,allowedMimeTypes:eD})]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,d.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,d.jsx)("a",{className:`send-btn ${!a&&(null==b?void 0:b.length)>0?"send-btn-active":""}`,onClick:F,children:(0,d.jsx)(ej.SendOutlined,{})})]})]})]})})}),eM=h().div`
319
+ `,eR=[],eF=[],eD=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],eE=[".xlsx",".wav"],eA=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[i,o]=(0,p.useState)([]);(0,p.useEffect)(()=>{t&&o([])},[t]);let s=[...eE,...eD].join(",");return(0,d.jsxs)(ey.Modal,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(i),l()},onCancel:l,width:600,children:[(0,d.jsx)("div",{style:{marginBottom:16},children:(0,d.jsxs)(ey.Typography.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,d.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,d.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,d.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,d.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,d.jsxs)(ey.Upload.Dragger,{...{name:"file",multiple:!0,accept:s,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(o(t=>[...t,e]),!1):(ey.message.error(`不支持的文件类型: ${e.name}`),ey.Upload.LIST_IGNORE)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ej.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),i.length>0&&(0,d.jsxs)("div",{style:{marginTop:16},children:[(0,d.jsxs)(ey.Typography.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",i.length,")"]}),(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:i.map((e,t)=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ej.FileExcelOutlined,{style:{color:"#52c41a"}}):(0,d.jsx)(ej.AudioOutlined,{style:{color:"#1890ff"}}),(0,d.jsx)(ey.Typography.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,d.jsxs)(ey.Typography.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,d.jsx)(ey.Button,{type:"text",size:"small",icon:(0,d.jsx)(ej.DeleteOutlined,{}),onClick:()=>{o(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},eB=m().forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=eR,agentId:s=null,attachments:c=eF,onInput:u,onSubmit:m,onUpdateAgentId:x,onUpdateAttachments:h,onUploading:f,style:g={}}=e,v=(0,p.useRef)(null),[j,y]=(0,p.useState)([]),[b,w]=(0,p.useState)(l||""),[C,S]=(0,p.useState)(0),[I,z]=(0,p.useState)(Array.isArray(c)?c:[]),[k,O]=(0,p.useState)(!1),N=(0,p.useMemo)(()=>!1,[]);(0,p.useImperativeHandle)(t,()=>({focus(){var e;null==(e=v.current)||e.focus()}})),(0,p.useEffect)(()=>w(l||""),[l]),(0,p.useEffect)(()=>{u&&u(b)},[b]),(0,p.useEffect)(()=>z(Array.isArray(c)?c:[]),[c]);let T=!!(b&&b.trim()),R=async e=>{if(O(!1),!f||!e.length)return;let t=[];for(let l of e)try{let e=await f(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...I,...t]),h&&h([...I,...t])},F=()=>{if(!T||a)return;let e=Date.now();if(e-C<400)return;S(e);let t=(b||"").trim();if(!t)return;let l={message:t,agents:j.map(e=>({id:e.id,name:e.name})),files:I.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};m&&m(l),w("")},D=(0,d.jsx)(eN,{children:(0,d.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),y(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,d.jsx)(eT,{style:g,children:(0,d.jsxs)("div",{className:"chat-input",children:[(0,d.jsxs)("div",{className:"input-stack",children:[I.length>0&&(0,d.jsx)("div",{className:"attachment-bar",children:I.map(e=>(0,d.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ew,{type:"icon-excel"}):(0,d.jsx)(ew,{type:"icon-audio"}),(0,d.jsx)(ey.Typography.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,d.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=I.filter(e=>e.id!==t)),h&&h(l))},children:(0,d.jsx)(ej.DeleteOutlined,{})})]},e.id))}),j.length>0&&(0,d.jsx)("div",{className:"agent-info",children:j.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:[(0,d.jsx)(ew,{type:"icon-at"}),e.name]}),(0,d.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),y(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,d.jsx)(ey.Input.TextArea,{ref:v,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:b,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),F()))},onChange:e=>w(e.target.value)})]}),(0,d.jsxs)("div",{className:"footer",children:[(0,d.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,d.jsx)(ey.Dropdown,{trigger:["click"],popupRender:()=>D,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,d.jsx)(ey.Tooltip,{title:"选择助理",children:(0,d.jsx)(ey.Button,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,d.jsx)(ew,{type:"icon-at"})})})}),f&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ey.Tooltip,{title:"上传文件",children:(0,d.jsx)(ey.Button,{className:"attach-upload",onClick:()=>O(!0),disabled:r||a,children:(0,d.jsx)(ew,{type:"icon-paper-clip"})})}),(0,d.jsx)(eA,{open:k,onCancel:()=>O(!1),onOk:R,allowedExtensions:eE,allowedMimeTypes:eD})]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,d.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,d.jsx)("a",{className:`send-btn ${!a&&(null==b?void 0:b.length)>0?"send-btn-active":""}`,onClick:F,children:(0,d.jsx)(ej.SendOutlined,{})})]})]})]})})}),eM=h().div`
320
320
  width: 100%;
321
321
  padding: 0 12px;
322
322
  border-bottom: solid 1px #e8e8e8;
@@ -561,8 +561,8 @@
561
561
  color: var(--ant-color-text-tertiary);
562
562
  }
563
563
  &-list {
564
- max-height: 200px;
565
- overflow: auto;
564
+ // max-height: 200px;
565
+ // overflow: auto;
566
566
  display: flex;
567
567
  flex-wrap: wrap;
568
568
  flex-direction: row;
@@ -736,7 +736,7 @@
736
736
  overflow: hidden;
737
737
  text-overflow: ellipsis;
738
738
  }
739
- `,e3=()=>{let{schema:e,setSchema:t,selectedItem:l,setSelectedItem:n,plugins:r}=(0,p.useContext)(eo),[a,i]=(0,p.useState)([]),o=(0,p.useMemo)(()=>l?[l.id]:[],[l]),s=(0,p.useMemo)(()=>{let t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>{let l,{id:n,type:r,children:a}=e;return Array.isArray(a)?l=t(a):"object"==typeof a&&a&&(l=[],Object.keys(a).forEach(e=>{Array.isArray(a[e])&&l.push({key:ek(),type:"slot",slot:e,origin:a,children:t(a[e])})})),{key:n,title:r,item:e,type:r,children:l}})};return t(e.items)},[e]),c=(0,p.useMemo)(()=>{let e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t.map(t=>{var l,n,a;return{key:t.key,title:(0,d.jsx)("span",{children:(l=t.type,n=t.slot,"slot"===l?"插槽-"+n:(null==(a=r.find(e=>e.key===l))?void 0:a.label)||l)}),children:t.children?e(t.children):void 0,dataRef:t}})};return e(s)},[s]);return(0,d.jsxs)(e6,{className:"layer-panel",children:[(0,d.jsx)(eL,{title:"图层",extra:(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Tooltip,{title:"全部展开",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>{let t=[],l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{var n;t.push(e.id),(null==(n=e.children)?void 0:n.length)&&l(e.children)})};l(e.items),i(t)},children:(0,d.jsx)(ej.PlusSquareOutlined,{})})}),(0,d.jsx)(ey.Tooltip,{title:"全部收起",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>i([]),children:(0,d.jsx)(ej.MinusSquareOutlined,{})})})]})}),(0,d.jsx)("div",{className:"body",children:(0,d.jsx)(e9,{draggable:{icon:!1,nodeDraggable:e=>!1},showIcon:!1,showLine:{showLeafIcon:!1},treeData:c,selectedKeys:o,expandedKeys:a,onSelect:(e,t)=>{"slot"!==t.node.dataRef.type&&n&&n(t.node.dataRef.item)},onDrop:l=>{let n;if(!(e=>{let t=e.node,l=e.dragNode;if("slot"===l.dataRef.type||!e.dropToGap&&!["b-row","b-col","b-card","slot"].includes(t.dataRef.type))return!1;if("b-col"===l.dataRef.type)if(!e.dropToGap)return"b-row"===t.dataRef.type;else return"b-col"===t.dataRef.type;return("b-col"!==t.dataRef.type||!e.dropToGap)&&("b-row"!==t.dataRef.type||!!e.dropToGap)||"b-col"===l.dataRef.type})(l))return;let r=l.node.key,a=l.dragNode.key,i=l.node.pos.split("-"),o=l.dropPosition-Number(i[i.length-1]),s=(e,t,l)=>{e.forEach((e,n,r)=>{if(e.id===t)return(e.children=e.children||[],"slot"===e.type)?l(e,n,r,e.children[e.slot]):l(e,n,r,e.children);if(Array.isArray(e.children))return s(e.children,t,l);if("object"==typeof e.children)for(let n in e.children)Array.isArray(e.children[n])&&s(e.children[n],t,l)})},d=e.items;if(s(d,a,(e,t,l)=>{l.splice(t,1),n=e}),l.dropToGap)if((l.node.children||[]).length>0&&l.node.expanded&&1===o)s(d,r,(e,t,l)=>{e.children=e.children||[],e.children.unshift(n)});else{let e=[],t=0;s(d,r,(l,n,r)=>{e=r,t=n}),-1===o?e.splice(t,0,n):e.splice(t+1,0,n)}else{if("slot"===l.node.dataRef.type){let{slot:e,origin:t}=l.node.dataRef;console.log(e,JSON.stringify(t)),t[e]=t[e]||[],t[e].push(n)}s(d,r,e=>{e.children=e.children||[],e.children.push(n)})}t&&t({...e,items:d})},onExpand:e=>i(e)})})]})},e7=h().div`
739
+ `,e3=()=>{let{schema:e,setSchema:t,selectedItem:l,setSelectedItem:n,plugins:r}=(0,p.useContext)(eo),[a,i]=(0,p.useState)([]),o=(0,p.useMemo)(()=>l?[l.id]:[],[l]),s=(0,p.useMemo)(()=>{let t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>{let l,{id:n,type:r,children:a}=e;return Array.isArray(a)?l=t(a):"object"==typeof a&&a&&(l=[],Object.keys(a).forEach(e=>{Array.isArray(a[e])&&l.push({key:ek(),type:"slot",title:"插槽-"+e,slot:e,origin:a,children:t(a[e])})})),{key:n,title:e.name,item:e,type:r,children:l}})};return t(e.items)},[e]),c=(0,p.useMemo)(()=>{let e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return console.log(t),t.map(t=>{var l,n,a;return{key:t.key,title:(0,d.jsx)(d.Fragment,{children:(null==t?void 0:t.title)||(l=t.type,n=t.slot,"slot"===l?"插槽-"+n:(null==(a=r.find(e=>e.key===l))?void 0:a.label)||l)}),children:t.children?e(t.children):void 0,dataRef:t}})};return e(s)},[s]);return(0,d.jsxs)(e6,{className:"layer-panel",children:[(0,d.jsx)(eL,{title:"图层",extra:(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Tooltip,{title:"全部展开",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>{let t=[],l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{var n;t.push(e.id),(null==(n=e.children)?void 0:n.length)&&l(e.children)})};l(e.items),i(t)},children:(0,d.jsx)(ej.PlusSquareOutlined,{})})}),(0,d.jsx)(ey.Tooltip,{title:"全部收起",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>i([]),children:(0,d.jsx)(ej.MinusSquareOutlined,{})})})]})}),(0,d.jsx)("div",{className:"body",children:(0,d.jsx)(e9,{draggable:{icon:!1,nodeDraggable:e=>!1},showIcon:!1,showLine:{showLeafIcon:!1},treeData:c,selectedKeys:o,expandedKeys:a,onSelect:(e,t)=>{"slot"!==t.node.dataRef.type&&n&&n(t.node.dataRef.item)},onDrop:l=>{let n;if(!(e=>{let t=e.node,l=e.dragNode;if("slot"===l.dataRef.type||!e.dropToGap&&!["b-row","b-col","b-card","slot"].includes(t.dataRef.type))return!1;if("b-col"===l.dataRef.type)if(!e.dropToGap)return"b-row"===t.dataRef.type;else return"b-col"===t.dataRef.type;return("b-col"!==t.dataRef.type||!e.dropToGap)&&("b-row"!==t.dataRef.type||!!e.dropToGap)||"b-col"===l.dataRef.type})(l))return;let r=l.node.key,a=l.dragNode.key,i=l.node.pos.split("-"),o=l.dropPosition-Number(i[i.length-1]),s=(e,t,l)=>{e.forEach((e,n,r)=>{if(e.id===t)return(e.children=e.children||[],"slot"===e.type)?l(e,n,r,e.children[e.slot]):l(e,n,r,e.children);if(Array.isArray(e.children))return s(e.children,t,l);if("object"==typeof e.children)for(let n in e.children)Array.isArray(e.children[n])&&s(e.children[n],t,l)})},d=e.items;if(s(d,a,(e,t,l)=>{l.splice(t,1),n=e}),l.dropToGap)if((l.node.children||[]).length>0&&l.node.expanded&&1===o)s(d,r,(e,t,l)=>{e.children=e.children||[],e.children.unshift(n)});else{let e=[],t=0;s(d,r,(l,n,r)=>{e=r,t=n}),-1===o?e.splice(t,0,n):e.splice(t+1,0,n)}else{if("slot"===l.node.dataRef.type){let{slot:e,origin:t}=l.node.dataRef;console.log(e,JSON.stringify(t)),t[e]=t[e]||[],t[e].push(n)}s(d,r,e=>{e.children=e.children||[],e.children.push(n)})}t&&t({...e,items:d})},onExpand:e=>i(e)})})]})},e7=h().div`
740
740
  display: flex;
741
741
  flex-direction: column;
742
742
  height: 100%;
@@ -919,7 +919,7 @@
919
919
  border-right: solid 2px #1890ff;
920
920
  background: linear-gradient(to left, #1890ff1a, #ffffff);
921
921
  }
922
- `,tc=e=>{let{open:t,onCancel:l,onOk:n}=e,[r,a]=(0,p.useState)(JSON.stringify({info:{},datasources:[],scripts:[],variables:[],items:[]}));return(0,d.jsx)(ey.Modal,{title:"导入页面",open:t,width:800,onCancel:l,onOk:()=>null==n?void 0:n(JSON.parse(r)),okText:"导入",cancelText:"取消",styles:{body:{height:"calc(100vh - 250px)",overflow:"auto"}},children:(0,d.jsx)("div",{className:"body",style:{flex:"1 1 auto",display:"flex",height:"100%"},children:(0,d.jsx)(eX.Editor,{height:"100%",defaultLanguage:"json",value:r,options:{minimap:{enabled:!1}},onChange:e=>a(e||"")})})})},tu=m().forwardRef((e,t)=>{var l;let n,{pageId:r,agentList:a=[],plugins:i=[],headerExtra:o,datasourceEnable:s=!0,scriptEnable:c=!0,datasetPanel:u,datasetSelector:m,fetch:x}=e,h=(0,p.useRef)(null),f=(0,p.useRef)(null),[g,v]=(0,p.useState)(1),[j,y]=(0,p.useState)([]),[b,w]=(0,p.useState)([]),[C,S]=(0,p.useState)(!1),[I,z]=(0,p.useState)("desktop"),[k,O]=(0,p.useState)("component"),[N,T]=(0,p.useState)((null==x?void 0:x.ai)?"ai":"props"),[R,F]=(0,p.useState)(!0),[D,E]=(0,p.useState)(!0),[A,B]=(0,p.useState)(null),[M,L]=(0,p.useState)({info:{},datasources:[],scripts:[],variables:[],items:[]}),[P,$]=(0,p.useState)(!0),[Y,H]=(0,p.useState)(!1),[q,G]=(0,p.useState)(!1),U=(0,p.useMemo)(()=>{let e=R?"250px":"",t=D?"400px":"";return{gridTemplateColumns:`${e} 1fr ${t}`}},[R,D]),_=(0,p.useMemo)(()=>({display:R?"flex":"none"}),[R]),K=(0,p.useMemo)(()=>({display:D?"flex":"none"}),[D]);l=[M],(n=(0,p.useRef)()).current===JSON.stringify(l)&&n.current||(n.current=JSON.stringify(l),(()=>{C||(y(e=>e.length?[...e,JSON.parse(JSON.stringify(M))].slice(-50):[JSON.parse(JSON.stringify(M))]),w([]))})()),(0,p.useImperativeHandle)(t,()=>({handleOpen(e){S(!0),W(e.items),L(e),y([JSON.parse(JSON.stringify(e))]),w([]),setTimeout(()=>S(!1),0)}}));let W=(e,t)=>{e&&e.forEach(e=>{e.id||(e.id=t||Math.random().toString(36).slice(2,10)),Array.isArray(e.children)?W(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&W(e.children[t],Math.random().toString(36).slice(2,10))})})},J=e=>{var t,l,n;if((null==(t=e.datasets)?void 0:t.length)&&(null==f||null==(l=f.current)?void 0:l.reload)&&f.current.reload(),e.schema)L(e.schema);else if(null==(n=e.pageItems)?void 0:n.length){let t=new Map(e.pageItems.map(e=>[e.id,e])),l=JSON.parse(JSON.stringify(M)),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{t.has(e.id)&&(Object.keys(e).forEach(t=>{"id"!==t&&delete e[t]}),Object.assign(e,t.get(e.id))),Array.isArray(e.children)?n(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&n(e.children[t])})})};n(l.items),L(l)}},X=(0,p.useMemo)(()=>"cascade"!==N||(null==A?void 0:A.cascadeIds)?N:"props",[A,N]);return(0,d.jsxs)(es,{pageId:r,designable:P,plugins:i,schema:M,selectedItem:A,setSchema:L,setSelectedItem:B,datasetSelector:m,fetch:x,children:[(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 24px",borderBottom:"solid 1px #e8e8e8"},children:[(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)("span",{style:{fontSize:16,fontWeight:500},children:"创建数据报表"}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"保存",children:(0,d.jsx)("a",{className:"toolbar",children:(0,d.jsx)(ej.SaveOutlined,{})})}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"撤销",children:(0,d.jsx)("a",{className:`toolbar ${j.length>1?"active":""}`,onClick:()=>{y(e=>{if(e.length<=1)return e;S(!0);let t=e[e.length-2];return w(e=>[...e,JSON.parse(JSON.stringify(M))]),L(t),B(null),setTimeout(()=>S(!1),0),e.slice(0,-1)})},children:(0,d.jsx)(ej.UndoOutlined,{})})}),(0,d.jsx)(ey.Tooltip,{title:"重做",children:(0,d.jsx)("a",{className:`toolbar ${b.length>0?"active":""}`,onClick:()=>{w(e=>e.length?(S(!0),y(e=>[...e,JSON.parse(JSON.stringify(M))]),L(e[e.length-1]),B(null),setTimeout(()=>S(!1),0),e.slice(0,-1)):e)},children:(0,d.jsx)(ej.RedoOutlined,{})})}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"导入JSON",children:(0,d.jsx)("a",{className:`toolbar ${b.length>0?"active":""}`,onClick:()=>{H(!0)},children:(0,d.jsx)(ej.ImportOutlined,{})})})]}),(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Tooltip,{title:"缩小",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>v(parseFloat(Math.max(g-.1,.5).toFixed(1))),children:(0,d.jsx)(ej.ZoomOutOutlined,{})})}),(0,d.jsxs)("div",{style:{fontSize:12,color:"#999",userSelect:"none"},children:[(100*g).toFixed(0),"%"]}),(0,d.jsx)(ey.Tooltip,{title:"放大",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>v(parseFloat(Math.min(g+.1,2).toFixed(1))),children:(0,d.jsx)(ej.ZoomInOutlined,{})})}),(0,d.jsx)(ey.Tooltip,{title:"重置缩放",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>v(1),children:(0,d.jsx)(ew,{type:"icon-zoom-reset"})})}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"切换左侧栏",children:(0,d.jsx)("a",{className:`toolbar ${R?"active":""}`,onClick:()=>{F(e=>!e),setTimeout(()=>{var e,t;return null==(t=h.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(ew,{type:"icon-sider-l"})})}),(0,d.jsx)(ey.Tooltip,{title:"切换右侧栏",children:(0,d.jsx)("a",{className:`toolbar ${D?"active":""}`,onClick:()=>{E(e=>!e),setTimeout(()=>{var e,t;return null==(t=h.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(ew,{type:"icon-sider-r"})})}),o]})]}),(0,d.jsxs)(td,{style:U,children:[(0,d.jsxs)("div",{className:"left",style:_,children:[(0,d.jsx)("div",{style:{padding:"22px 1px 22px 0",borderRight:"solid 1px #e8e8e8"},children:(0,d.jsxs)(ey.Radio.Group,{value:k,onChange:e=>O(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"left-pane-tabs",children:[(0,d.jsx)(ey.Radio.Button,{value:"component",children:(0,d.jsx)(ey.Tooltip,{title:"组件",placement:"right",children:(0,d.jsx)(ew,{type:"icon-puzzle"})})}),(0,d.jsx)(ey.Radio.Button,{value:"layer",children:(0,d.jsx)(ey.Tooltip,{title:"图层",placement:"right",children:(0,d.jsx)(ew,{type:"icon-outline"})})}),!!u&&(0,d.jsx)(ey.Radio.Button,{value:"dataset",children:(0,d.jsx)(ey.Tooltip,{title:"数据集",placement:"right",children:(0,d.jsx)(ew,{type:"icon-dataset"})})}),s&&(0,d.jsx)(ey.Radio.Button,{value:"datasource",title:"数据源",children:(0,d.jsx)(ey.Tooltip,{title:"数据源",placement:"right",children:(0,d.jsx)(ew,{type:"icon-datasource"})})}),c&&(0,d.jsx)(ey.Radio.Button,{value:"script",children:(0,d.jsx)(ey.Tooltip,{title:"脚本",placement:"right",children:(0,d.jsx)(ew,{type:"icon-js"})})}),(0,d.jsx)(ey.Radio.Button,{value:"env",children:(0,d.jsx)(ey.Tooltip,{title:"环境变量",placement:"right",children:(0,d.jsx)(ew,{type:"icon-variable"})})}),(0,d.jsx)(ey.Radio.Button,{value:"code",children:(0,d.jsx)(ey.Tooltip,{title:"源码",placement:"right",children:(0,d.jsx)(ew,{type:"icon-json"})})})]})}),(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["component"===k&&(0,d.jsx)(e4,{}),"layer"===k&&(0,d.jsx)(e3,{}),s&&"datasource"===k&&(0,d.jsx)(e5,{}),c&&"script"===k&&(0,d.jsx)(tr,{}),"env"===k&&(0,d.jsx)(ti,{}),"code"===k&&(0,d.jsx)(e0,{}),!!u&&"dataset"===k&&(0,d.jsx)(ts,{ref:f,renderNode:u})]})]}),(0,d.jsxs)("div",{className:"center",style:{flex:"1 1 auto"},children:[(0,d.jsx)(eL,{title:"页面",extra:(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Button,{size:"small",type:P?"default":"primary",icon:P?(0,d.jsx)(ej.EyeInvisibleOutlined,{}):(0,d.jsx)(ej.EyeOutlined,{}),onClick:()=>$(!P)}),(0,d.jsxs)(ey.Radio.Group,{value:I,onChange:e=>z(e.target.value),size:"small",buttonStyle:"outline",children:[(0,d.jsx)(ey.Radio.Button,{value:"desktop",title:"桌面",children:(0,d.jsx)(ej.DesktopOutlined,{})}),(0,d.jsx)(ey.Radio.Button,{value:"mobile",title:"移动设备",children:(0,d.jsx)(ej.MobileOutlined,{})}),(0,d.jsx)(ey.Radio.Button,{value:"tablet",title:"平板设备",children:(0,d.jsx)(ej.TabletOutlined,{})})]})]})}),(0,d.jsx)("div",{className:["body",I].join(" "),children:(0,d.jsx)("div",{style:{transform:`scale(${g})`,transformOrigin:"top center"},children:(0,d.jsx)(eg,{ref:h,device:I,fetch:x})})})]}),(0,d.jsxs)("div",{className:"right",style:K,children:[(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["ai"===X&&(null==x?void 0:x.ai)&&(0,d.jsx)(eH,{agentList:a,onEffect:J}),"props"===X&&(0,d.jsx)(tt,{datasourceEnable:s}),"cascade"===X&&(null==A?void 0:A.cascadeIds)&&(0,d.jsx)(eJ,{})]}),(0,d.jsx)("div",{style:{padding:"22px 0",borderLeft:"solid 1px #e8e8e8",display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center"},children:(0,d.jsxs)(ey.Radio.Group,{value:X,onChange:e=>T(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"right-pane-tabs",children:[(null==x?void 0:x.ai)&&(0,d.jsx)(ey.Radio.Button,{value:"ai",children:(0,d.jsx)(ey.Tooltip,{title:"智能助理",placement:"right",children:(0,d.jsx)(ew,{type:"icon-assistant"})})}),(0,d.jsx)(ey.Radio.Button,{value:"props",children:(0,d.jsx)(ey.Tooltip,{title:"属性",placement:"right",children:(0,d.jsx)(ew,{type:"icon-info"})})}),(null==A?void 0:A.cascadeIds)&&(0,d.jsx)(ey.Radio.Button,{value:"cascade",children:(0,d.jsx)(ey.Tooltip,{title:"联动",placement:"right",children:(0,d.jsx)(ew,{type:"icon-cascade"})})})]})})]})]})]}),(0,d.jsx)(tc,{open:Y,onOk:e=>{H(!1),L(e)},onCancel:()=>H(!1)}),(0,d.jsx)(ey.Drawer,{open:q,size:400,mask:!1,title:null,closable:!1,styles:{body:{padding:0}},onClose:()=>G(!1),children:(0,d.jsx)(eH,{agentList:a,headExtra:(0,d.jsx)(ey.Button,{type:"link",icon:(0,d.jsx)(ej.CloseOutlined,{}),onClick:()=>G(!1)}),onEffect:J})})]})});var tp=((i={}).STRING="STRING",i.NUMBER="NUMBER",i.BOOLEAN="BOOLEAN",i.OBJECT="OBJECT",i.ARRAY="ARRAY",i);let tm=h()(ej.InfoCircleOutlined)`
922
+ `,tc=e=>{let{open:t,onCancel:l,onOk:n}=e,[r,a]=(0,p.useState)(JSON.stringify({info:{},datasources:[],scripts:[],variables:[],items:[]}));return(0,d.jsx)(ey.Modal,{title:"导入页面",open:t,width:800,onCancel:l,onOk:()=>null==n?void 0:n(JSON.parse(r)),okText:"导入",cancelText:"取消",styles:{body:{height:"calc(100vh - 250px)",overflow:"auto"}},children:(0,d.jsx)("div",{className:"body",style:{flex:"1 1 auto",display:"flex",height:"100%"},children:(0,d.jsx)(eX.Editor,{height:"100%",defaultLanguage:"json",value:r,options:{minimap:{enabled:!1}},onChange:e=>a(e||"")})})})},tu=m().forwardRef((e,t)=>{var l;let n,{pageId:r,agentList:a=[],plugins:i=[],headerExtra:o,datasourceEnable:s=!0,scriptEnable:c=!0,datasetPanel:u,datasetSelector:m,fetch:x,onSave:h,loading:f=!1}=e,g=(0,p.useRef)(null),v=(0,p.useRef)(null),[j,y]=(0,p.useState)(1),[b,w]=(0,p.useState)([]),[C,S]=(0,p.useState)([]),[I,z]=(0,p.useState)(!1),[k,O]=(0,p.useState)("desktop"),[N,T]=(0,p.useState)("component"),[R,F]=(0,p.useState)((null==x?void 0:x.ai)?"ai":"props"),[D,E]=(0,p.useState)(!0),[A,B]=(0,p.useState)(!0),[M,L]=(0,p.useState)(null),[P,$]=(0,p.useState)({info:{},datasources:[],scripts:[],variables:[],items:[]}),[Y,H]=(0,p.useState)(!0),[q,G]=(0,p.useState)(!1),[U,_]=(0,p.useState)(!1),K=(0,p.useMemo)(()=>{let e=D?"250px":"",t=A?"400px":"";return{gridTemplateColumns:`${e} 1fr ${t}`}},[D,A]),W=(0,p.useMemo)(()=>({display:D?"flex":"none"}),[D]),J=(0,p.useMemo)(()=>({display:A?"flex":"none"}),[A]);l=[P],(n=(0,p.useRef)()).current===JSON.stringify(l)&&n.current||(n.current=JSON.stringify(l),(()=>{I||(w(e=>e.length?[...e,JSON.parse(JSON.stringify(P))].slice(-50):[JSON.parse(JSON.stringify(P))]),S([]))})()),(0,p.useImperativeHandle)(t,()=>({handleOpen(e){z(!0),X(e.items),$(e),w([JSON.parse(JSON.stringify(e))]),S([]),setTimeout(()=>z(!1),0)}}));let X=(e,t)=>{e&&e.forEach(e=>{e.id||(e.id=t||Math.random().toString(36).slice(2,10)),Array.isArray(e.children)?X(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&X(e.children[t],Math.random().toString(36).slice(2,10))})})},V=e=>{var t,l,n;if((null==(t=e.datasets)?void 0:t.length)&&(null==v||null==(l=v.current)?void 0:l.reload)&&v.current.reload(),e.schema)$(e.schema);else if(null==(n=e.pageItems)?void 0:n.length){let t=new Map(e.pageItems.map(e=>[e.id,e])),l=JSON.parse(JSON.stringify(P)),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach(e=>{t.has(e.id)&&(Object.keys(e).forEach(t=>{"id"!==t&&delete e[t]}),Object.assign(e,t.get(e.id))),Array.isArray(e.children)?n(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&n(e.children[t])})})};n(l.items),$(l)}},Q=(0,p.useMemo)(()=>"cascade"!==R||(null==M?void 0:M.cascadeIds)?R:"props",[M,R]);return(0,d.jsxs)(es,{pageId:r,designable:Y,plugins:i,schema:P,selectedItem:M,setSchema:$,setSelectedItem:L,datasetSelector:m,fetch:x,children:[(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 24px",borderBottom:"solid 1px #e8e8e8"},children:[(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)("span",{style:{fontSize:16,fontWeight:500},children:"创建数据报表"}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"保存",children:(0,d.jsx)(ey.Button,{type:"link",className:"toolbar",onClick:()=>{null==h||h(P)},loading:f,children:(0,d.jsx)(ej.SaveOutlined,{})})}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"撤销",children:(0,d.jsx)("a",{className:`toolbar ${b.length>1?"active":""}`,onClick:()=>{w(e=>{if(e.length<=1)return e;z(!0);let t=e[e.length-2];return S(e=>[...e,JSON.parse(JSON.stringify(P))]),$(t),L(null),setTimeout(()=>z(!1),0),e.slice(0,-1)})},children:(0,d.jsx)(ej.UndoOutlined,{})})}),(0,d.jsx)(ey.Tooltip,{title:"重做",children:(0,d.jsx)("a",{className:`toolbar ${C.length>0?"active":""}`,onClick:()=>{S(e=>e.length?(z(!0),w(e=>[...e,JSON.parse(JSON.stringify(P))]),$(e[e.length-1]),L(null),setTimeout(()=>z(!1),0),e.slice(0,-1)):e)},children:(0,d.jsx)(ej.RedoOutlined,{})})}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"导入JSON",children:(0,d.jsx)("a",{className:`toolbar ${C.length>0?"active":""}`,onClick:()=>{G(!0)},children:(0,d.jsx)(ej.ImportOutlined,{})})})]}),(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Tooltip,{title:"缩小",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>y(parseFloat(Math.max(j-.1,.5).toFixed(1))),children:(0,d.jsx)(ej.ZoomOutOutlined,{})})}),(0,d.jsxs)("div",{style:{fontSize:12,color:"#999",userSelect:"none"},children:[(100*j).toFixed(0),"%"]}),(0,d.jsx)(ey.Tooltip,{title:"放大",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>y(parseFloat(Math.min(j+.1,2).toFixed(1))),children:(0,d.jsx)(ej.ZoomInOutlined,{})})}),(0,d.jsx)(ey.Tooltip,{title:"重置缩放",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>y(1),children:(0,d.jsx)(ew,{type:"icon-zoom-reset"})})}),(0,d.jsx)(ey.Divider,{orientation:"vertical"}),(0,d.jsx)(ey.Tooltip,{title:"切换左侧栏",children:(0,d.jsx)("a",{className:`toolbar ${D?"active":""}`,onClick:()=>{E(e=>!e),setTimeout(()=>{var e,t;return null==(t=g.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(ew,{type:"icon-sider-l"})})}),(0,d.jsx)(ey.Tooltip,{title:"切换右侧栏",children:(0,d.jsx)("a",{className:`toolbar ${A?"active":""}`,onClick:()=>{B(e=>!e),setTimeout(()=>{var e,t;return null==(t=g.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(ew,{type:"icon-sider-r"})})}),o]})]}),(0,d.jsxs)(td,{style:K,children:[(0,d.jsxs)("div",{className:"left",style:W,children:[(0,d.jsx)("div",{style:{padding:"22px 1px 22px 0",borderRight:"solid 1px #e8e8e8"},children:(0,d.jsxs)(ey.Radio.Group,{value:N,onChange:e=>T(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"left-pane-tabs",children:[(0,d.jsx)(ey.Radio.Button,{value:"component",children:(0,d.jsx)(ey.Tooltip,{title:"组件",placement:"right",children:(0,d.jsx)(ew,{type:"icon-puzzle"})})}),(0,d.jsx)(ey.Radio.Button,{value:"layer",children:(0,d.jsx)(ey.Tooltip,{title:"图层",placement:"right",children:(0,d.jsx)(ew,{type:"icon-outline"})})}),!!u&&(0,d.jsx)(ey.Radio.Button,{value:"dataset",children:(0,d.jsx)(ey.Tooltip,{title:"数据集",placement:"right",children:(0,d.jsx)(ew,{type:"icon-dataset"})})}),s&&(0,d.jsx)(ey.Radio.Button,{value:"datasource",title:"数据源",children:(0,d.jsx)(ey.Tooltip,{title:"数据源",placement:"right",children:(0,d.jsx)(ew,{type:"icon-datasource"})})}),c&&(0,d.jsx)(ey.Radio.Button,{value:"script",children:(0,d.jsx)(ey.Tooltip,{title:"脚本",placement:"right",children:(0,d.jsx)(ew,{type:"icon-js"})})}),(0,d.jsx)(ey.Radio.Button,{value:"env",children:(0,d.jsx)(ey.Tooltip,{title:"环境变量",placement:"right",children:(0,d.jsx)(ew,{type:"icon-variable"})})}),(0,d.jsx)(ey.Radio.Button,{value:"code",children:(0,d.jsx)(ey.Tooltip,{title:"源码",placement:"right",children:(0,d.jsx)(ew,{type:"icon-json"})})})]})}),(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["component"===N&&(0,d.jsx)(e4,{}),"layer"===N&&(0,d.jsx)(e3,{}),s&&"datasource"===N&&(0,d.jsx)(e5,{}),c&&"script"===N&&(0,d.jsx)(tr,{}),"env"===N&&(0,d.jsx)(ti,{}),"code"===N&&(0,d.jsx)(e0,{}),!!u&&"dataset"===N&&(0,d.jsx)(ts,{ref:v,renderNode:u})]})]}),(0,d.jsxs)("div",{className:"center",style:{flex:"1 1 auto"},children:[(0,d.jsx)(eL,{title:"页面",extra:(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Button,{size:"small",type:Y?"default":"primary",icon:Y?(0,d.jsx)(ej.EyeInvisibleOutlined,{}):(0,d.jsx)(ej.EyeOutlined,{}),onClick:()=>H(!Y)}),(0,d.jsxs)(ey.Radio.Group,{value:k,onChange:e=>O(e.target.value),size:"small",buttonStyle:"outline",children:[(0,d.jsx)(ey.Radio.Button,{value:"desktop",title:"桌面",children:(0,d.jsx)(ej.DesktopOutlined,{})}),(0,d.jsx)(ey.Radio.Button,{value:"mobile",title:"移动设备",children:(0,d.jsx)(ej.MobileOutlined,{})}),(0,d.jsx)(ey.Radio.Button,{value:"tablet",title:"平板设备",children:(0,d.jsx)(ej.TabletOutlined,{})})]})]})}),(0,d.jsx)("div",{className:["body",k].join(" "),children:(0,d.jsx)("div",{style:{transform:`scale(${j})`,transformOrigin:"top center"},children:(0,d.jsx)(eg,{ref:g,device:k,fetch:x})})})]}),(0,d.jsxs)("div",{className:"right",style:J,children:[(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["ai"===Q&&(null==x?void 0:x.ai)&&(0,d.jsx)(eH,{agentList:a,onEffect:V}),"props"===Q&&(0,d.jsx)(tt,{datasourceEnable:s}),"cascade"===Q&&(null==M?void 0:M.cascadeIds)&&(0,d.jsx)(eJ,{})]}),(0,d.jsx)("div",{style:{padding:"22px 0",borderLeft:"solid 1px #e8e8e8",display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center"},children:(0,d.jsxs)(ey.Radio.Group,{value:Q,onChange:e=>F(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"right-pane-tabs",children:[(null==x?void 0:x.ai)&&(0,d.jsx)(ey.Radio.Button,{value:"ai",children:(0,d.jsx)(ey.Tooltip,{title:"智能助理",placement:"right",children:(0,d.jsx)(ew,{type:"icon-assistant"})})}),(0,d.jsx)(ey.Radio.Button,{value:"props",children:(0,d.jsx)(ey.Tooltip,{title:"属性",placement:"right",children:(0,d.jsx)(ew,{type:"icon-info"})})}),(null==M?void 0:M.cascadeIds)&&(0,d.jsx)(ey.Radio.Button,{value:"cascade",children:(0,d.jsx)(ey.Tooltip,{title:"联动",placement:"right",children:(0,d.jsx)(ew,{type:"icon-cascade"})})})]})})]})]})]}),(0,d.jsx)(tc,{open:q,onOk:e=>{G(!1),$(e)},onCancel:()=>G(!1)}),(0,d.jsx)(ey.Drawer,{open:U,size:400,mask:!1,title:null,closable:!1,styles:{body:{padding:0}},onClose:()=>_(!1),children:(0,d.jsx)(eH,{agentList:a,headExtra:(0,d.jsx)(ey.Button,{type:"link",icon:(0,d.jsx)(ej.CloseOutlined,{}),onClick:()=>_(!1)}),onEffect:V})})]})});var tp=((i={}).STRING="STRING",i.NUMBER="NUMBER",i.BOOLEAN="BOOLEAN",i.OBJECT="OBJECT",i.ARRAY="ARRAY",i);let tm=h()(ej.InfoCircleOutlined)`
923
923
  vertical-align: middle;
924
924
  margin-left: 2px;
925
925
  color: var(--ant-color-text-description);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bi-sdk-react",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/umd/js/bi-sdk.umd.min.js",
@@ -72,6 +72,8 @@ export type PageDesignerProps = {
72
72
  >;
73
73
  datasetSelector?: DatasetSelectorFunction;
74
74
  fetch?: FetchType;
75
+ onSave?: (schema: PageSchema) => void;
76
+ loading?: boolean;
75
77
  };
76
78
 
77
79
  const Container = styled.div`
@@ -222,6 +224,8 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
222
224
  datasetPanel,
223
225
  datasetSelector,
224
226
  fetch,
227
+ onSave,
228
+ loading = false,
225
229
  },
226
230
  ref
227
231
  ) => {
@@ -370,7 +374,9 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
370
374
  if (effect.schema) {
371
375
  setSchema(effect.schema);
372
376
  } else if (effect.pageItems?.length) {
373
- const effectItemMap = new Map(effect.pageItems.map((item) => [item.id, item]));
377
+ const effectItemMap = new Map(
378
+ effect.pageItems.map((item) => [item.id, item])
379
+ );
374
380
  const cloneSchema = JSON.parse(JSON.stringify(schema));
375
381
  const loop = (list: any[] = []) => {
376
382
  list.forEach((item) => {
@@ -398,8 +404,13 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
398
404
  }
399
405
  };
400
406
 
407
+ const handleSave = () => {
408
+ onSave?.(schema);
409
+ };
410
+
401
411
  const rightActiveKey = useMemo(() => {
402
- if (rightPanelActiveKey === "cascade" && !selectedItem?.cascadeIds) return "props";
412
+ if (rightPanelActiveKey === "cascade" && !selectedItem?.cascadeIds)
413
+ return "props";
403
414
  return rightPanelActiveKey;
404
415
  }, [selectedItem, rightPanelActiveKey]);
405
416
 
@@ -433,9 +444,14 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
433
444
  </span>
434
445
  <Divider orientation="vertical" />
435
446
  <Tooltip title="保存">
436
- <a className="toolbar">
447
+ <Button
448
+ type="link"
449
+ className="toolbar"
450
+ onClick={handleSave}
451
+ loading={loading}
452
+ >
437
453
  <SaveOutlined />
438
- </a>
454
+ </Button>
439
455
  </Tooltip>
440
456
  <Divider orientation="vertical" />
441
457
  <Tooltip title="撤销">
@@ -585,7 +601,10 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
585
601
  {leftPanelActiveKey === "env" && <VariablesPanel />}
586
602
  {leftPanelActiveKey === "code" && <CodePanel />}
587
603
  {!!datasetPanel && leftPanelActiveKey === "dataset" && (
588
- <DatasetPanel ref={datasetPanelRef} renderNode={datasetPanel} />
604
+ <DatasetPanel
605
+ ref={datasetPanelRef}
606
+ renderNode={datasetPanel}
607
+ />
589
608
  )}
590
609
  </div>
591
610
  </div>
@@ -651,8 +670,9 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
651
670
  {rightActiveKey === "props" && (
652
671
  <PropertiesPanel datasourceEnable={datasourceEnable} />
653
672
  )}
654
- {rightActiveKey === "cascade" &&
655
- selectedItem?.cascadeIds && <CascadePanel />}
673
+ {rightActiveKey === "cascade" && selectedItem?.cascadeIds && (
674
+ <CascadePanel />
675
+ )}
656
676
  </div>
657
677
  <div
658
678
  style={{
@@ -570,8 +570,8 @@ const MessageRoot = styled.div`
570
570
  color: var(--ant-color-text-tertiary);
571
571
  }
572
572
  &-list {
573
- max-height: 200px;
574
- overflow: auto;
573
+ // max-height: 200px;
574
+ // overflow: auto;
575
575
  display: flex;
576
576
  flex-wrap: wrap;
577
577
  flex-direction: row;
@@ -608,7 +608,7 @@ export const ChatInput = React.forwardRef<
608
608
  <div className="agent-info">
609
609
  {selectedAgent.map((item, index) => (
610
610
  <div key={String(item.id)}>
611
- <span className="name">@ {item.name}</span>
611
+ <span className="name"><IconFont type="icon-at" />{item.name}</span>
612
612
  <a className="remove" onClick={() => onRemoveAgent(index)}>
613
613
  ×
614
614
  </a>
@@ -59,13 +59,14 @@ export const LayerPanel: React.FC = () => {
59
59
  c.push({
60
60
  key: uuid(),
61
61
  type: "slot",
62
+ title: "插槽-" + k,
62
63
  slot: k,
63
64
  origin: children,
64
65
  children: compute(children[k]),
65
66
  });
66
67
  });
67
68
  }
68
- return { key: id, title: type, item, type, children: c };
69
+ return { key: id, title: item.name, item, type, children: c };
69
70
  });
70
71
  };
71
72
  return compute(schema.items);
@@ -183,9 +184,10 @@ export const LayerPanel: React.FC = () => {
183
184
 
184
185
  const treeData = useMemo(() => {
185
186
  const computeTreeData = (list: any[] = []): any[] => {
187
+ console.log(list)
186
188
  return list.map((item) => ({
187
189
  key: item.key,
188
- title: <span>{formatType(item.type, (item as any).slot)}</span>,
190
+ title: <>{item?.title || formatType(item.type, (item as any).slot)}</>,
189
191
  children: item.children ? computeTreeData(item.children) : undefined,
190
192
  dataRef: item,
191
193
  }));
@@ -30,3 +30,7 @@ a.toolbar {
30
30
  content: none;
31
31
  }
32
32
  }
33
+
34
+ .ant-btn-link {
35
+ padding: 0;
36
+ }