bi-sdk-react 0.0.19 → 0.0.21

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.
@@ -377,7 +377,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
377
377
  .conversation-list li small {
378
378
  white-space: nowrap;
379
379
  }
380
- `,t$=[],tF="bi-design",tY=e=>{let t,l,n,r,a,i,o,{agentList:s=t$,headExtra:d,style:u={},onEffect:p}=e,{pageId:x,schema:m,fetch:h,atItems:g,onRemoveAtItem:v}=(0,eO.useContext)(tu);if(!h)return null;let[j,b]=(0,eO.useState)(null),[w,C]=(0,eO.useState)([]),[S,z]=(0,eO.useState)([]),k=eO.default.useRef(null),I=()=>{setTimeout(()=>{k.current&&k.current.scrollToBottom()},100)},N=()=>{b(null),z([])},O=async e=>{q.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=h.ai)?void 0:t.removeConversation(tF,x,e)),C(t=>t.filter(t=>t.id!==e)),z(t=>t.filter(t=>t.conversationId!==e)),j===e&&N()}})},T=async e=>{var t;b(e),C(t=>t.map(t=>({...t,isActived:t.id===e}))),z(await (null==(t=h.ai)?void 0:t.messageList(tF,x,e))||[])},E=async e=>{var t;let l={id:ex(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:g,sending:!0};z(e=>[...e,l]),I();let n=!j,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=h.ai)?void 0:t.chat(tF,x,j,{...e,page:m,pageItems:g}));b((null==o?void 0:o.id)||""),C(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==p||p(a.effect)),z(e=>[...e]),I()},A=async e=>{var t;await (null==(t=h.ai)?void 0:t.removeMessage(tF,x,e)),z(t=>t.filter(t=>t.id!==e))},D=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],w.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),B=async()=>{try{var e,t;let l=await (null==(e=h.ai)?void 0:e.conversationList(tF,x));C(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){b(n.id);let e=await (null==(t=h.ai)?void 0:t.messageList(tF,x,n.id));z(e||[])}}catch(e){console.error(e)}};return(0,eO.useEffect)(()=>{B()},[h]),(0,eO.useEffect)(()=>{I()},[]),(0,eN.jsxs)(tM,{style:u,children:[(0,eN.jsx)(tP,{title:"智能助理",extra:(0,eN.jsxs)(en,{children:[(0,eN.jsx)(es,{title:"新对话",placement:"topRight",children:(0,eN.jsx)("a",{onClick:N,children:(0,eN.jsx)(tS,{type:"icon-chat-plus"})})}),(0,eN.jsx)(W,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,eN.jsx)(tW,{children:D.map(e=>(0,eN.jsxs)("div",{className:"group",children:[(0,eN.jsx)("div",{className:"group-title",children:e.title}),(0,eN.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,eN.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,eN.jsx)("a",{onClick:()=>T(e.id),children:e.name}),(0,eN.jsx)("small",{children:(0,eN.jsx)("a",{onClick:()=>O(e.id),children:(0,eN.jsx)(c,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,eN.jsx)("a",{children:(0,eN.jsx)(f,{})})}),d]}),style:{width:"initial"}}),(0,eN.jsxs)("div",{className:"body",children:[(0,eN.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:S.length?(0,eN.jsx)(tJ,{ref:k,list:S,onDeleteMessage:A}):(0,eN.jsx)(tG,{})}),0===S.length&&w.length>0&&(0,eN.jsx)(P,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,eN.jsx)("ul",{className:"conversation-list",children:w.slice(0,3).map(e=>(0,eN.jsxs)("li",{children:[(0,eN.jsxs)("a",{children:[(0,eN.jsx)(y,{}),e.name]}),(0,eN.jsx)("small",{children:tN(e.createdAt)})]},e.id))})}),(0,eN.jsx)(tL,{agentList:s,style:{padding:12},atItems:g,onUploading:null==h?void 0:h.upload,onSubmit:E,onRemoveAtItem:v})]})]})},tH=t.div`
380
+ `,t$=[],tF="bi-design",tY=e=>{let t,l,n,r,a,i,o,{agentList:s=t$,headExtra:d,style:u={},onEffect:p}=e,{pageId:x,schema:m,fetch:h,atItems:g,onRemoveAtItem:v}=(0,eO.useContext)(tu);if(!h)return null;let[j,b]=(0,eO.useState)(null),[w,C]=(0,eO.useState)([]),[S,z]=(0,eO.useState)([]),k=eO.default.useRef(null),I=()=>{setTimeout(()=>{k.current&&k.current.scrollToBottom()},100)},N=()=>{b(null),z([])},O=async e=>{q.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=h.ai)?void 0:t.removeConversation(tF,x,e)),C(t=>t.filter(t=>t.id!==e)),z(t=>t.filter(t=>t.conversationId!==e)),j===e&&N()}})},T=async e=>{var t;b(e),C(t=>t.map(t=>({...t,isActived:t.id===e}))),z(await (null==(t=h.ai)?void 0:t.messageList(tF,x,e))||[])},E=async e=>{var t;let l={id:ex(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:g,sending:!0};z(e=>[...e,l]),I();let n=!j,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=h.ai)?void 0:t.chat(tF,x,j,{...e,page:JSON.stringify(m),pageItems:g}));b((null==o?void 0:o.id)||""),C(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==p||p(a.effect)),z(e=>[...e]),I()},A=async e=>{var t;await (null==(t=h.ai)?void 0:t.removeMessage(tF,x,e)),z(t=>t.filter(t=>t.id!==e))},D=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],w.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),B=async()=>{try{var e,t;let l=await (null==(e=h.ai)?void 0:e.conversationList(tF,x));C(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){b(n.id);let e=await (null==(t=h.ai)?void 0:t.messageList(tF,x,n.id));z(e||[])}}catch(e){console.error(e)}};return(0,eO.useEffect)(()=>{B()},[h]),(0,eO.useEffect)(()=>{I()},[]),(0,eN.jsxs)(tM,{style:u,children:[(0,eN.jsx)(tP,{title:"智能助理",extra:(0,eN.jsxs)(en,{children:[(0,eN.jsx)(es,{title:"新对话",placement:"topRight",children:(0,eN.jsx)("a",{onClick:N,children:(0,eN.jsx)(tS,{type:"icon-chat-plus"})})}),(0,eN.jsx)(W,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,eN.jsx)(tW,{children:D.map(e=>(0,eN.jsxs)("div",{className:"group",children:[(0,eN.jsx)("div",{className:"group-title",children:e.title}),(0,eN.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,eN.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,eN.jsx)("a",{onClick:()=>T(e.id),children:e.name}),(0,eN.jsx)("small",{children:(0,eN.jsx)("a",{onClick:()=>O(e.id),children:(0,eN.jsx)(c,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,eN.jsx)("a",{children:(0,eN.jsx)(f,{})})}),d]}),style:{width:"initial"}}),(0,eN.jsxs)("div",{className:"body",children:[(0,eN.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:S.length?(0,eN.jsx)(tJ,{ref:k,list:S,onDeleteMessage:A}):(0,eN.jsx)(tG,{})}),0===S.length&&w.length>0&&(0,eN.jsx)(P,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,eN.jsx)("ul",{className:"conversation-list",children:w.slice(0,3).map(e=>(0,eN.jsxs)("li",{children:[(0,eN.jsxs)("a",{children:[(0,eN.jsx)(y,{}),e.name]}),(0,eN.jsx)("small",{children:tN(e.createdAt)})]},e.id))})}),(0,eN.jsx)(tL,{agentList:s,style:{padding:12},atItems:g,onUploading:null==h?void 0:h.upload,onSubmit:E,onRemoveAtItem:v})]})]})},tH=t.div`
381
381
  flex: 1 1 auto;
382
382
  display: flex;
383
383
  align-items: center;
@@ -1032,7 +1032,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
1032
1032
  const module = undefined;
1033
1033
  const exports = undefined;
1034
1034
  ${e.customRender}
1035
- `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),h=()=>{console.log("callback table",tz(u,l))};return(0,eO.useEffect)(()=>{p({id:l.id,callback:h})},[]),(0,eN.jsx)(ea,{id:t,dataSource:n,columns:m,pagination:x,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...d},className:c})},formComponent:e=>{let{model:t,onChange:l}=e,i=(e,n)=>l&&l({...t,[e]:n}),o=(e,l)=>{let n=[...t.columns||[]];n[e]={...n[e],...l},i("columns",n)},[s,d]=(0,eO.useState)(!1),[u,x]=(0,eO.useState)(null),m=null!=u&&t.columns[u]?t.columns[u]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},h=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,n)=>(0,eN.jsxs)(en,{children:[(0,eN.jsx)("a",{onClick:()=>{x(n),d(!0)},children:(0,eN.jsx)(p,{})}),(0,eN.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(n,1),i("columns",e)},children:(0,eN.jsx)(c,{})})]})}];return(0,eN.jsxs)("div",{children:[(0,eN.jsxs)(K,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,eN.jsx)(K.Item,{label:"大小",children:(0,eN.jsxs)(Z.Group,{size:"small",value:t.size,onChange:e=>i("size",e.target.value),children:[(0,eN.jsx)(Z.Button,{value:"small",children:"小"}),(0,eN.jsx)(Z.Button,{value:"middle",children:"中"}),(0,eN.jsx)(Z.Button,{value:"large",children:"大"})]})}),(0,eN.jsx)(K.Item,{label:"边框",children:(0,eN.jsx)(er,{size:"small",checked:!!t.bordered,onChange:e=>i("bordered",e)})}),(0,eN.jsx)(K.Item,{label:"显示表头",children:(0,eN.jsx)(er,{size:"small",checked:!!t.showHeader,onChange:e=>i("showHeader",e)})}),(0,eN.jsx)(K.Item,{label:"分页大小",children:(0,eN.jsx)(U,{size:"small",value:t.pageSize,onChange:e=>i("pageSize",e)})})]}),(0,eN.jsx)(H,{children:"表格列设置"}),(0,eN.jsx)(ea,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:h,pagination:!1,bordered:!0}),(0,eN.jsx)(_,{size:"small",onClick:()=>{i("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,eN.jsx)(q,{title:"编辑列",open:s,footer:null,width:400,onCancel:()=>d(!1),children:(0,eN.jsx)(K,{layout:"vertical",children:(0,eN.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,eN.jsx)(K.Item,{label:"列名",children:(0,eN.jsx)(J,{value:m.title,onChange:e=>o(u,{title:e.target.value})})}),(0,eN.jsx)(K.Item,{label:"数据索引",children:(0,eN.jsx)(J,{value:m.dataIndex,onChange:e=>o(u,{dataIndex:e.target.value})})}),(0,eN.jsx)(K.Item,{label:"宽度",children:(0,eN.jsx)(J,{value:m.width,onChange:e=>o(u,{width:e.target.value})})}),(0,eN.jsx)(K.Item,{label:"对齐",children:(0,eN.jsxs)(Z.Group,{value:m.align,onChange:e=>o(u,{align:e.target.value}),children:[(0,eN.jsx)(Z.Button,{value:"left",children:(0,eN.jsx)(r,{})}),(0,eN.jsx)(Z.Button,{value:"center",children:(0,eN.jsx)(n,{})}),(0,eN.jsx)(Z.Button,{value:"right",children:(0,eN.jsx)(a,{})})]})}),(0,eN.jsx)(K.Item,{label:"省略",children:(0,eN.jsx)(er,{checked:!!m.ellipsis,onChange:e=>o(u,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:d}=e,{env:c,initCallback:u}=(0,eO.useContext)(tv),p=lx(t,i.datasource)||[],x=(0,eO.useMemo)(()=>!!l&&!(l<=p.length)&&{total:p.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,p.length,r]),m=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,d],h=()=>{console.log("callback list",tz(c,i))};return(0,eO.useEffect)(()=>{u({id:i.id,callback:h})},[]),(0,eN.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:m.filter(Boolean).join(" "),children:[(0,eN.jsx)(lw,{list:p,split:o,bordered:n,size:r,itemLayout:a}),x&&(0,eN.jsx)(X,{...x})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=K.useForm();return(0,eO.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,eN.jsxs)(K,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,eN.jsx)(K.Item,{label:"大小",name:"size",children:(0,eN.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eN.jsx)(Z.Button,{value:"default",children:"默认"}),(0,eN.jsx)(Z.Button,{value:"small",children:"小"})]})}),(0,eN.jsx)(K.Item,{label:"布局",name:"itemLayout",children:(0,eN.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eN.jsx)(Z.Button,{value:"horizontal",children:"水平"}),(0,eN.jsx)(Z.Button,{value:"vertical",children:"垂直"})]})}),(0,eN.jsx)(K.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,eN.jsx)(er,{size:"small"})}),(0,eN.jsx)(K.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,eN.jsx)(er,{size:"small"})}),(0,eN.jsx)(K.Item,{label:"分页大小",name:"pageSize",children:(0,eN.jsx)(U,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{env:o,initCallback:s}=(0,eO.useContext)(tv),d=lx(t,n.datasource),c=(0,eO.useMemo)(()=>Object.keys(d||{}),[d]),u=(0,eO.useMemo)(()=>c.map(e=>null==d?void 0:d[e]),[c,d]),p=(0,eO.useMemo)(()=>(l||"").replace(/{ *{\s*([^}]+)\s*} *}/g,(e,t)=>{try{return Function(...c,`
1035
+ `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),h=()=>{console.log("callback table",tz(u,l))};return(0,eO.useEffect)(()=>{p({id:l.id,callback:h})},[]),(0,eN.jsx)(ea,{id:t,dataSource:n,columns:m,pagination:x,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...d},className:c})},formComponent:e=>{let{model:t,onChange:l}=e,i=(e,n)=>l&&l({...t,[e]:n}),o=(e,l)=>{let n=[...t.columns||[]];n[e]={...n[e],...l},i("columns",n)},[s,d]=(0,eO.useState)(!1),[u,x]=(0,eO.useState)(null),m=null!=u&&t.columns[u]?t.columns[u]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},h=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,n)=>(0,eN.jsxs)(en,{children:[(0,eN.jsx)("a",{onClick:()=>{x(n),d(!0)},children:(0,eN.jsx)(p,{})}),(0,eN.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(n,1),i("columns",e)},children:(0,eN.jsx)(c,{})})]})}];return(0,eN.jsxs)("div",{children:[(0,eN.jsxs)(K,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,eN.jsx)(K.Item,{label:"大小",children:(0,eN.jsxs)(Z.Group,{size:"small",value:t.size,onChange:e=>i("size",e.target.value),children:[(0,eN.jsx)(Z.Button,{value:"small",children:"小"}),(0,eN.jsx)(Z.Button,{value:"middle",children:"中"}),(0,eN.jsx)(Z.Button,{value:"large",children:"大"})]})}),(0,eN.jsx)(K.Item,{label:"边框",children:(0,eN.jsx)(er,{size:"small",checked:!!t.bordered,onChange:e=>i("bordered",e)})}),(0,eN.jsx)(K.Item,{label:"显示表头",children:(0,eN.jsx)(er,{size:"small",checked:!!t.showHeader,onChange:e=>i("showHeader",e)})}),(0,eN.jsx)(K.Item,{label:"分页大小",children:(0,eN.jsx)(U,{size:"small",value:t.pageSize,onChange:e=>i("pageSize",e)})})]}),(0,eN.jsx)(H,{children:"表格列设置"}),(0,eN.jsx)(ea,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:h,pagination:!1,bordered:!0}),(0,eN.jsx)(_,{size:"small",onClick:()=>{i("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,eN.jsx)(q,{title:"编辑列",open:s,footer:null,width:400,onCancel:()=>d(!1),children:(0,eN.jsx)(K,{layout:"vertical",children:(0,eN.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,eN.jsx)(K.Item,{label:"列名",children:(0,eN.jsx)(J,{value:m.title,onChange:e=>o(u,{title:e.target.value})})}),(0,eN.jsx)(K.Item,{label:"数据索引",children:(0,eN.jsx)(J,{value:m.dataIndex,onChange:e=>o(u,{dataIndex:e.target.value})})}),(0,eN.jsx)(K.Item,{label:"宽度",children:(0,eN.jsx)(J,{value:m.width,onChange:e=>o(u,{width:e.target.value})})}),(0,eN.jsx)(K.Item,{label:"对齐",children:(0,eN.jsxs)(Z.Group,{value:m.align,onChange:e=>o(u,{align:e.target.value}),children:[(0,eN.jsx)(Z.Button,{value:"left",children:(0,eN.jsx)(r,{})}),(0,eN.jsx)(Z.Button,{value:"center",children:(0,eN.jsx)(n,{})}),(0,eN.jsx)(Z.Button,{value:"right",children:(0,eN.jsx)(a,{})})]})}),(0,eN.jsx)(K.Item,{label:"省略",children:(0,eN.jsx)(er,{checked:!!m.ellipsis,onChange:e=>o(u,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:d}=e,{env:c,initCallback:u}=(0,eO.useContext)(tv),p=lx(t,i.datasource)||[],x=(0,eO.useMemo)(()=>!!l&&!(l<=p.length)&&{total:p.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,p.length,r]),m=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,d],h=()=>{console.log("callback list",tz(c,i))};return(0,eO.useEffect)(()=>{u({id:i.id,callback:h})},[]),(0,eN.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:m.filter(Boolean).join(" "),children:[(0,eN.jsx)(lw,{list:p,split:o,bordered:n,size:r,itemLayout:a}),x&&(0,eN.jsx)(X,{...x})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=K.useForm();return(0,eO.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,eN.jsxs)(K,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,eN.jsx)(K.Item,{label:"大小",name:"size",children:(0,eN.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eN.jsx)(Z.Button,{value:"default",children:"默认"}),(0,eN.jsx)(Z.Button,{value:"small",children:"小"})]})}),(0,eN.jsx)(K.Item,{label:"布局",name:"itemLayout",children:(0,eN.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eN.jsx)(Z.Button,{value:"horizontal",children:"水平"}),(0,eN.jsx)(Z.Button,{value:"vertical",children:"垂直"})]})}),(0,eN.jsx)(K.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,eN.jsx)(er,{size:"small"})}),(0,eN.jsx)(K.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,eN.jsx)(er,{size:"small"})}),(0,eN.jsx)(K.Item,{label:"分页大小",name:"pageSize",children:(0,eN.jsx)(U,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{env:o,initCallback:s}=(0,eO.useContext)(tv),d=lx(t,n.datasource),c=(0,eO.useMemo)(()=>Object.keys(d||{}),[d]),u=(0,eO.useMemo)(()=>c.map(e=>null==d?void 0:d[e]),[c,d]),p=(0,eO.useMemo)(()=>(l||"").replace(/##\s*([^#]+)\s*##/g,(e,t)=>{try{return Function(...c,`
1036
1036
  "use strict";
1037
1037
  const window = undefined;
1038
1038
  const document = undefined;
@@ -10,7 +10,7 @@ export type ChatRequestType = {
10
10
  id: string | number;
11
11
  name: string;
12
12
  }[] | null;
13
- page?: PageSchema | null;
13
+ page?: string | null;
14
14
  pageItems?: SchemaItemType[] | null;
15
15
  };
16
16
  export type PageItemEffectType = {
@@ -377,7 +377,7 @@
377
377
  .conversation-list li small {
378
378
  white-space: nowrap;
379
379
  }
380
- `,e$=[],eY="bi-design",e_=e=>{let t,l,n,r,a,i,o,{agentList:s=e$,headExtra:c,style:u={},onEffect:x}=e,{pageId:h,schema:f,fetch:g,atItems:v,onRemoveAtItem:y}=(0,p.useContext)(eo);if(!g)return null;let[j,b]=(0,p.useState)(null),[w,C]=(0,p.useState)([]),[S,I]=(0,p.useState)([]),z=m().useRef(null),k=()=>{setTimeout(()=>{z.current&&z.current.scrollToBottom()},100)},O=()=>{b(null),I([])},N=async e=>{ej.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=g.ai)?void 0:t.removeConversation(eY,h,e)),C(t=>t.filter(t=>t.id!==e)),I(t=>t.filter(t=>t.conversationId!==e)),j===e&&O()}})},T=async e=>{var t;b(e),C(t=>t.map(t=>({...t,isActived:t.id===e}))),I(await (null==(t=g.ai)?void 0:t.messageList(eY,h,e))||[])},R=async e=>{var t;let l={id:ek(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:v,sending:!0};I(e=>[...e,l]),k();let n=!j,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=g.ai)?void 0:t.chat(eY,h,j,{...e,page:f,pageItems:v}));b((null==o?void 0:o.id)||""),C(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==x||x(a.effect)),I(e=>[...e]),k()},F=async e=>{var t;await (null==(t=g.ai)?void 0:t.removeMessage(eY,h,e)),I(t=>t.filter(t=>t.id!==e))},D=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],w.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),A=async()=>{try{var e,t;let l=await (null==(e=g.ai)?void 0:e.conversationList(eY,h));C(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){b(n.id);let e=await (null==(t=g.ai)?void 0:t.messageList(eY,h,n.id));I(e||[])}}catch(e){console.error(e)}};return(0,p.useEffect)(()=>{A()},[g]),(0,p.useEffect)(()=>{k()},[]),(0,d.jsxs)(eP,{style:u,children:[(0,d.jsx)(eM,{title:"智能助理",extra:(0,d.jsxs)(ej.Space,{children:[(0,d.jsx)(ej.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:O,children:(0,d.jsx)(ew,{type:"icon-chat-plus"})})}),(0,d.jsx)(ej.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eG,{children:D.map(e=>(0,d.jsxs)("div",{className:"group",children:[(0,d.jsx)("div",{className:"group-title",children:e.title}),(0,d.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,d.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,d.jsx)("a",{onClick:()=>T(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>N(e.id),children:(0,d.jsx)(ey.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ey.HistoryOutlined,{})})}),c]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:S.length?(0,d.jsx)(eK,{ref:z,list:S,onDeleteMessage:F}):(0,d.jsx)(eq,{})}),0===S.length&&w.length>0&&(0,d.jsx)(ej.Card,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,d.jsx)("ul",{className:"conversation-list",children:w.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ey.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eO(e.createdAt)})]},e.id))})}),(0,d.jsx)(eB,{agentList:s,style:{padding:12},atItems:v,onUploading:null==g?void 0:g.upload,onSubmit:R,onRemoveAtItem:y})]})]})},eH=h().div`
380
+ `,e$=[],eY="bi-design",e_=e=>{let t,l,n,r,a,i,o,{agentList:s=e$,headExtra:c,style:u={},onEffect:x}=e,{pageId:h,schema:f,fetch:g,atItems:v,onRemoveAtItem:y}=(0,p.useContext)(eo);if(!g)return null;let[j,b]=(0,p.useState)(null),[w,C]=(0,p.useState)([]),[S,I]=(0,p.useState)([]),z=m().useRef(null),k=()=>{setTimeout(()=>{z.current&&z.current.scrollToBottom()},100)},O=()=>{b(null),I([])},N=async e=>{ej.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=g.ai)?void 0:t.removeConversation(eY,h,e)),C(t=>t.filter(t=>t.id!==e)),I(t=>t.filter(t=>t.conversationId!==e)),j===e&&O()}})},T=async e=>{var t;b(e),C(t=>t.map(t=>({...t,isActived:t.id===e}))),I(await (null==(t=g.ai)?void 0:t.messageList(eY,h,e))||[])},R=async e=>{var t;let l={id:ek(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:v,sending:!0};I(e=>[...e,l]),k();let n=!j,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=g.ai)?void 0:t.chat(eY,h,j,{...e,page:JSON.stringify(f),pageItems:v}));b((null==o?void 0:o.id)||""),C(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==x||x(a.effect)),I(e=>[...e]),k()},F=async e=>{var t;await (null==(t=g.ai)?void 0:t.removeMessage(eY,h,e)),I(t=>t.filter(t=>t.id!==e))},D=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],w.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),A=async()=>{try{var e,t;let l=await (null==(e=g.ai)?void 0:e.conversationList(eY,h));C(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){b(n.id);let e=await (null==(t=g.ai)?void 0:t.messageList(eY,h,n.id));I(e||[])}}catch(e){console.error(e)}};return(0,p.useEffect)(()=>{A()},[g]),(0,p.useEffect)(()=>{k()},[]),(0,d.jsxs)(eP,{style:u,children:[(0,d.jsx)(eM,{title:"智能助理",extra:(0,d.jsxs)(ej.Space,{children:[(0,d.jsx)(ej.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:O,children:(0,d.jsx)(ew,{type:"icon-chat-plus"})})}),(0,d.jsx)(ej.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eG,{children:D.map(e=>(0,d.jsxs)("div",{className:"group",children:[(0,d.jsx)("div",{className:"group-title",children:e.title}),(0,d.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,d.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,d.jsx)("a",{onClick:()=>T(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>N(e.id),children:(0,d.jsx)(ey.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ey.HistoryOutlined,{})})}),c]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:S.length?(0,d.jsx)(eK,{ref:z,list:S,onDeleteMessage:F}):(0,d.jsx)(eq,{})}),0===S.length&&w.length>0&&(0,d.jsx)(ej.Card,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,d.jsx)("ul",{className:"conversation-list",children:w.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ey.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eO(e.createdAt)})]},e.id))})}),(0,d.jsx)(eB,{agentList:s,style:{padding:12},atItems:v,onUploading:null==g?void 0:g.upload,onSubmit:R,onRemoveAtItem:y})]})]})},eH=h().div`
381
381
  flex: 1 1 auto;
382
382
  display: flex;
383
383
  align-items: center;
@@ -1032,7 +1032,7 @@
1032
1032
  const module = undefined;
1033
1033
  const exports = undefined;
1034
1034
  ${e.customRender}
1035
- `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),g=()=>{console.log("callback table",eS(m,l))};return(0,p.useEffect)(()=>{x({id:l.id,callback:g})},[]),(0,d.jsx)(ej.Table,{id:t,dataSource:n,columns:f,pagination:h,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...c},className:u})},formComponent:e=>{let{model:t,onChange:l}=e,n=(e,n)=>l&&l({...t,[e]:n}),r=(e,l)=>{let r=[...t.columns||[]];r[e]={...r[e],...l},n("columns",r)},[a,i]=(0,p.useState)(!1),[o,s]=(0,p.useState)(null),c=null!=o&&t.columns[o]?t.columns[o]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},u=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,r)=>(0,d.jsxs)(ej.Space,{children:[(0,d.jsx)("a",{onClick:()=>{s(r),i(!0)},children:(0,d.jsx)(ey.EditOutlined,{})}),(0,d.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(r,1),n("columns",e)},children:(0,d.jsx)(ey.DeleteOutlined,{})})]})}];return(0,d.jsxs)("div",{children:[(0,d.jsxs)(ej.Form,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,d.jsx)(ej.Form.Item,{label:"大小",children:(0,d.jsxs)(ej.Radio.Group,{size:"small",value:t.size,onChange:e=>n("size",e.target.value),children:[(0,d.jsx)(ej.Radio.Button,{value:"small",children:"小"}),(0,d.jsx)(ej.Radio.Button,{value:"middle",children:"中"}),(0,d.jsx)(ej.Radio.Button,{value:"large",children:"大"})]})}),(0,d.jsx)(ej.Form.Item,{label:"边框",children:(0,d.jsx)(ej.Switch,{size:"small",checked:!!t.bordered,onChange:e=>n("bordered",e)})}),(0,d.jsx)(ej.Form.Item,{label:"显示表头",children:(0,d.jsx)(ej.Switch,{size:"small",checked:!!t.showHeader,onChange:e=>n("showHeader",e)})}),(0,d.jsx)(ej.Form.Item,{label:"分页大小",children:(0,d.jsx)(ej.InputNumber,{size:"small",value:t.pageSize,onChange:e=>n("pageSize",e)})})]}),(0,d.jsx)(ej.Divider,{children:"表格列设置"}),(0,d.jsx)(ej.Table,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:u,pagination:!1,bordered:!0}),(0,d.jsx)(ej.Button,{size:"small",onClick:()=>{n("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,d.jsx)(ej.Modal,{title:"编辑列",open:a,footer:null,width:400,onCancel:()=>i(!1),children:(0,d.jsx)(ej.Form,{layout:"vertical",children:(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,d.jsx)(ej.Form.Item,{label:"列名",children:(0,d.jsx)(ej.Input,{value:c.title,onChange:e=>r(o,{title:e.target.value})})}),(0,d.jsx)(ej.Form.Item,{label:"数据索引",children:(0,d.jsx)(ej.Input,{value:c.dataIndex,onChange:e=>r(o,{dataIndex:e.target.value})})}),(0,d.jsx)(ej.Form.Item,{label:"宽度",children:(0,d.jsx)(ej.Input,{value:c.width,onChange:e=>r(o,{width:e.target.value})})}),(0,d.jsx)(ej.Form.Item,{label:"对齐",children:(0,d.jsxs)(ej.Radio.Group,{value:c.align,onChange:e=>r(o,{align:e.target.value}),children:[(0,d.jsx)(ej.Radio.Button,{value:"left",children:(0,d.jsx)(ey.AlignLeftOutlined,{})}),(0,d.jsx)(ej.Radio.Button,{value:"center",children:(0,d.jsx)(ey.AlignCenterOutlined,{})}),(0,d.jsx)(ej.Radio.Button,{value:"right",children:(0,d.jsx)(ey.AlignRightOutlined,{})})]})}),(0,d.jsx)(ej.Form.Item,{label:"省略",children:(0,d.jsx)(ej.Switch,{checked:!!c.ellipsis,onChange:e=>r(o,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:c}=e,{env:u,initCallback:m}=(0,p.useContext)(ex),x=th(t,i.datasource)||[],h=(0,p.useMemo)(()=>!!l&&!(l<=x.length)&&{total:x.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,x.length,r]),f=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,c],g=()=>{console.log("callback list",eS(u,i))};return(0,p.useEffect)(()=>{m({id:i.id,callback:g})},[]),(0,d.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:f.filter(Boolean).join(" "),children:[(0,d.jsx)(tS,{list:x,split:o,bordered:n,size:r,itemLayout:a}),h&&(0,d.jsx)(ej.Pagination,{...h})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=ej.Form.useForm();return(0,p.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,d.jsxs)(ej.Form,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,d.jsx)(ej.Form.Item,{label:"大小",name:"size",children:(0,d.jsxs)(ej.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ej.Radio.Button,{value:"default",children:"默认"}),(0,d.jsx)(ej.Radio.Button,{value:"small",children:"小"})]})}),(0,d.jsx)(ej.Form.Item,{label:"布局",name:"itemLayout",children:(0,d.jsxs)(ej.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ej.Radio.Button,{value:"horizontal",children:"水平"}),(0,d.jsx)(ej.Radio.Button,{value:"vertical",children:"垂直"})]})}),(0,d.jsx)(ej.Form.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,d.jsx)(ej.Switch,{size:"small"})}),(0,d.jsx)(ej.Form.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,d.jsx)(ej.Switch,{size:"small"})}),(0,d.jsx)(ej.Form.Item,{label:"分页大小",name:"pageSize",children:(0,d.jsx)(ej.InputNumber,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{env:o,initCallback:s}=(0,p.useContext)(ex),c=th(t,n.datasource),u=(0,p.useMemo)(()=>Object.keys(c||{}),[c]),m=(0,p.useMemo)(()=>u.map(e=>null==c?void 0:c[e]),[u,c]),x=(0,p.useMemo)(()=>(l||"").replace(/{ *{\s*([^}]+)\s*} *}/g,(e,t)=>{try{return Function(...u,`
1035
+ `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),g=()=>{console.log("callback table",eS(m,l))};return(0,p.useEffect)(()=>{x({id:l.id,callback:g})},[]),(0,d.jsx)(ej.Table,{id:t,dataSource:n,columns:f,pagination:h,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...c},className:u})},formComponent:e=>{let{model:t,onChange:l}=e,n=(e,n)=>l&&l({...t,[e]:n}),r=(e,l)=>{let r=[...t.columns||[]];r[e]={...r[e],...l},n("columns",r)},[a,i]=(0,p.useState)(!1),[o,s]=(0,p.useState)(null),c=null!=o&&t.columns[o]?t.columns[o]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},u=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,r)=>(0,d.jsxs)(ej.Space,{children:[(0,d.jsx)("a",{onClick:()=>{s(r),i(!0)},children:(0,d.jsx)(ey.EditOutlined,{})}),(0,d.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(r,1),n("columns",e)},children:(0,d.jsx)(ey.DeleteOutlined,{})})]})}];return(0,d.jsxs)("div",{children:[(0,d.jsxs)(ej.Form,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,d.jsx)(ej.Form.Item,{label:"大小",children:(0,d.jsxs)(ej.Radio.Group,{size:"small",value:t.size,onChange:e=>n("size",e.target.value),children:[(0,d.jsx)(ej.Radio.Button,{value:"small",children:"小"}),(0,d.jsx)(ej.Radio.Button,{value:"middle",children:"中"}),(0,d.jsx)(ej.Radio.Button,{value:"large",children:"大"})]})}),(0,d.jsx)(ej.Form.Item,{label:"边框",children:(0,d.jsx)(ej.Switch,{size:"small",checked:!!t.bordered,onChange:e=>n("bordered",e)})}),(0,d.jsx)(ej.Form.Item,{label:"显示表头",children:(0,d.jsx)(ej.Switch,{size:"small",checked:!!t.showHeader,onChange:e=>n("showHeader",e)})}),(0,d.jsx)(ej.Form.Item,{label:"分页大小",children:(0,d.jsx)(ej.InputNumber,{size:"small",value:t.pageSize,onChange:e=>n("pageSize",e)})})]}),(0,d.jsx)(ej.Divider,{children:"表格列设置"}),(0,d.jsx)(ej.Table,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:u,pagination:!1,bordered:!0}),(0,d.jsx)(ej.Button,{size:"small",onClick:()=>{n("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,d.jsx)(ej.Modal,{title:"编辑列",open:a,footer:null,width:400,onCancel:()=>i(!1),children:(0,d.jsx)(ej.Form,{layout:"vertical",children:(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,d.jsx)(ej.Form.Item,{label:"列名",children:(0,d.jsx)(ej.Input,{value:c.title,onChange:e=>r(o,{title:e.target.value})})}),(0,d.jsx)(ej.Form.Item,{label:"数据索引",children:(0,d.jsx)(ej.Input,{value:c.dataIndex,onChange:e=>r(o,{dataIndex:e.target.value})})}),(0,d.jsx)(ej.Form.Item,{label:"宽度",children:(0,d.jsx)(ej.Input,{value:c.width,onChange:e=>r(o,{width:e.target.value})})}),(0,d.jsx)(ej.Form.Item,{label:"对齐",children:(0,d.jsxs)(ej.Radio.Group,{value:c.align,onChange:e=>r(o,{align:e.target.value}),children:[(0,d.jsx)(ej.Radio.Button,{value:"left",children:(0,d.jsx)(ey.AlignLeftOutlined,{})}),(0,d.jsx)(ej.Radio.Button,{value:"center",children:(0,d.jsx)(ey.AlignCenterOutlined,{})}),(0,d.jsx)(ej.Radio.Button,{value:"right",children:(0,d.jsx)(ey.AlignRightOutlined,{})})]})}),(0,d.jsx)(ej.Form.Item,{label:"省略",children:(0,d.jsx)(ej.Switch,{checked:!!c.ellipsis,onChange:e=>r(o,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:c}=e,{env:u,initCallback:m}=(0,p.useContext)(ex),x=th(t,i.datasource)||[],h=(0,p.useMemo)(()=>!!l&&!(l<=x.length)&&{total:x.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,x.length,r]),f=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,c],g=()=>{console.log("callback list",eS(u,i))};return(0,p.useEffect)(()=>{m({id:i.id,callback:g})},[]),(0,d.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:f.filter(Boolean).join(" "),children:[(0,d.jsx)(tS,{list:x,split:o,bordered:n,size:r,itemLayout:a}),h&&(0,d.jsx)(ej.Pagination,{...h})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=ej.Form.useForm();return(0,p.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,d.jsxs)(ej.Form,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,d.jsx)(ej.Form.Item,{label:"大小",name:"size",children:(0,d.jsxs)(ej.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ej.Radio.Button,{value:"default",children:"默认"}),(0,d.jsx)(ej.Radio.Button,{value:"small",children:"小"})]})}),(0,d.jsx)(ej.Form.Item,{label:"布局",name:"itemLayout",children:(0,d.jsxs)(ej.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ej.Radio.Button,{value:"horizontal",children:"水平"}),(0,d.jsx)(ej.Radio.Button,{value:"vertical",children:"垂直"})]})}),(0,d.jsx)(ej.Form.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,d.jsx)(ej.Switch,{size:"small"})}),(0,d.jsx)(ej.Form.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,d.jsx)(ej.Switch,{size:"small"})}),(0,d.jsx)(ej.Form.Item,{label:"分页大小",name:"pageSize",children:(0,d.jsx)(ej.InputNumber,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{env:o,initCallback:s}=(0,p.useContext)(ex),c=th(t,n.datasource),u=(0,p.useMemo)(()=>Object.keys(c||{}),[c]),m=(0,p.useMemo)(()=>u.map(e=>null==c?void 0:c[e]),[u,c]),x=(0,p.useMemo)(()=>(l||"").replace(/##\s*([^#]+)\s*##/g,(e,t)=>{try{return Function(...u,`
1036
1036
  "use strict";
1037
1037
  const window = undefined;
1038
1038
  const document = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bi-sdk-react",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/umd/js/bi-sdk.umd.min.js",
@@ -166,7 +166,7 @@ export const AiPanel: React.FC<AiPanelProps> = ({
166
166
  conversationId,
167
167
  {
168
168
  ...data,
169
- page: schema,
169
+ page: JSON.stringify(schema),
170
170
  pageItems: atItems,
171
171
  }
172
172
  )!;
@@ -56,7 +56,7 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
56
56
  const html = useMemo(
57
57
  () =>
58
58
  (template || "").replace(
59
- /{ *{\s*([^}]+)\s*} *}/g,
59
+ /##\s*([^#]+)\s*##/g,
60
60
  (_match: any, p1: string) => {
61
61
  try {
62
62
  return (func(p1) as any)(...args);
@@ -4,7 +4,7 @@ export type ChatRequestType = {
4
4
  message: string;
5
5
  files?: { id: string; name: string; extension: string }[] | null;
6
6
  agents?: { id: string | number; name: string }[] | null;
7
- page?: PageSchema | null;
7
+ page?: string | null;
8
8
  pageItems?: SchemaItemType[] | null;
9
9
  };
10
10