bi-sdk-react 0.0.7 → 0.0.9

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.
Files changed (31) hide show
  1. package/dist/es/css/bi-sdk.css +1 -1
  2. package/dist/es/js/bi-sdk.es.js +8 -8
  3. package/dist/types/components/PageDesigner.d.ts +3 -1
  4. package/dist/types/components/context/PageContext.d.ts +18 -0
  5. package/dist/types/components/index.d.ts +2 -2
  6. package/dist/types/components/utils.d.ts +1 -0
  7. package/dist/umd/css/bi-sdk.css +1 -1
  8. package/dist/umd/js/bi-sdk.umd.min.js +7 -7
  9. package/package.json +1 -1
  10. package/src/components/PageDesigner.tsx +30 -10
  11. package/src/components/context/{DesignerContext.tsx → PageContext.tsx} +8 -8
  12. package/src/components/dnd/DropContainer.tsx +2 -2
  13. package/src/components/index.ts +3 -2
  14. package/src/components/layout/PageCanvas.tsx +2 -2
  15. package/src/components/layout/PageItem.tsx +2 -2
  16. package/src/components/panel/AiPanel.tsx +8 -6
  17. package/src/components/panel/CascadePanel.tsx +2 -2
  18. package/src/components/panel/ChatInput.tsx +1 -1
  19. package/src/components/panel/CodePanel.tsx +2 -2
  20. package/src/components/panel/ComponentPanel.tsx +2 -2
  21. package/src/components/panel/DatasourcePanel.tsx +2 -2
  22. package/src/components/panel/LayerPanel.tsx +6 -4
  23. package/src/components/panel/PropertiesPanel.tsx +2 -2
  24. package/src/components/panel/ScriptPanel.tsx +2 -2
  25. package/src/components/panel/VariablesPanel.tsx +2 -2
  26. package/src/components/plugins/@antd/items/CardRender.tsx +1 -1
  27. package/src/components/plugins/@antd/items/ColRender.tsx +2 -2
  28. package/src/components/plugins/@antd/items/RowRender.tsx +2 -2
  29. package/src/components/plugins/@antd/items/SpaceRender.tsx +2 -2
  30. package/src/components/styles.css +4 -0
  31. package/src/components/utils.ts +19 -3
@@ -1,5 +1,5 @@
1
1
  /*! For license information please see bi-sdk.umd.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):"function"==typeof define&&define.amd?define(["@ant-design/icons","echarts","styled-components","react","antd","uuid","dayjs","@monaco-editor/react"],t):"object"==typeof exports?exports.BiSdk=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):e.BiSdk=t(e["@ant-design/icons"],e.echarts,e["styled-components"],e.react,e.antd,e.uuid,e.dayjs,e["@monaco-editor/react"])}(this,(e,t,l,n,r,a,i,o)=>(()=>{var s={290(e,t,l){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var r in t=arguments[l])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.bindAll=void 0;var r=l(352);function a(e){if(void 0!==e)return"boolean"==typeof e?{capture:e}:e}t.bindAll=function(e,t,l){var i=t.map(function(t){var i=null==l?t:n(n({},t),{options:n(n({},a(l)),a(t.options))});return(0,r.bind)(e,i)});return function(){i.forEach(function(e){return e()})}}},352(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bind=void 0,t.bind=function(e,t){var l=t.type,n=t.listener,r=t.options;return e.addEventListener(l,n,r),function(){e.removeEventListener(l,n,r)}}},951(e,t,l){"use strict";t.bindAll=t.bind=void 0;var n=l(352);Object.defineProperty(t,"bind",{enumerable:!0,get:function(){return n.bind}});var r=l(290);Object.defineProperty(t,"bindAll",{enumerable:!0,get:function(){return r.bindAll}})},965(e,t,l){"use strict";var n=l(426),r={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var l,a,i,o,s,d,c,u,p=!1;t||(t={}),i=t.debug||!1;try{if(s=n(),d=document.createRange(),c=document.getSelection(),(u=document.createElement("span")).textContent=e,u.ariaHidden="true",u.style.all="unset",u.style.position="fixed",u.style.top=0,u.style.clip="rect(0, 0, 0, 0)",u.style.whiteSpace="pre",u.style.webkitUserSelect="text",u.style.MozUserSelect="text",u.style.msUserSelect="text",u.style.userSelect="text",u.addEventListener("copy",function(l){if(l.stopPropagation(),t.format)if(l.preventDefault(),void 0===l.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var n=r[t.format]||r.default;window.clipboardData.setData(n,e)}else l.clipboardData.clearData(),l.clipboardData.setData(t.format,e);t.onCopy&&(l.preventDefault(),t.onCopy(l.clipboardData))}),document.body.appendChild(u),d.selectNodeContents(u),c.addRange(d),!document.execCommand("copy"))throw Error("copy command was unsuccessful");p=!0}catch(n){i&&console.error("unable to copy using execCommand: ",n),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),p=!0}catch(n){i&&console.error("unable to copy using clipboardData: ",n),i&&console.error("falling back to prompt"),l="message"in t?t.message:"Copy to clipboard: #{key}, Enter",a=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",o=l.replace(/#{\s*key\s*}/g,a),window.prompt(o,e)}}finally{c&&("function"==typeof c.removeRange?c.removeRange(d):c.removeAllRanges()),u&&document.body.removeChild(u),s()}return p}},20(e,t,l){"use strict";var n=l(155),r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function d(e,t,l){var n,a={},d=null,c=null;for(n in void 0!==l&&(d=""+l),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,n)&&!s.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:r,type:e,key:d,ref:c,props:a,_owner:o.current}}t.Fragment=a,t.jsx=d,t.jsxs=d},848(e,t,l){"use strict";e.exports=l(20)},426(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,l=[],n=0;n<e.rangeCount;n++)l.push(e.getRangeAt(n));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||l.forEach(function(t){e.addRange(t)}),t&&t.focus()}}},375(t){"use strict";t.exports=e},247(e){"use strict";e.exports=o},59(e){"use strict";e.exports=r},185(e){"use strict";e.exports=i},190(e){"use strict";e.exports=t},155(e){"use strict";e.exports=n},694(e){"use strict";e.exports=l},315(e){"use strict";e.exports=a}},d={};function c(e){var t=d[e];if(void 0!==t)return t.exports;var l=d[e]={exports:{}};return s[e].call(l.exports,l,l.exports,c),l.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var l in t)c.o(t,l)&&!c.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};return(()=>{"use strict";c.r(u),c.d(u,{EnvContext:()=>ex,DesignerContext:()=>eo,PageCanvas:()=>ev,PageSchema:()=>o.PageSchema,PageDesigner:()=>tu,PluginType:()=>o.PluginType,plugins:()=>tO,PropEditorProps:()=>s.PropEditorProps,handleCallback:()=>ez,DropContainer:()=>em});var e,t,l,n,r,a,i,o={};c.r(o),c.d(o,{P:()=>tp});var s={};c.r(s);var d=c(848),p=c(155),m=c.n(p),x=c(694),h=c.n(x);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function g(e,t){if(e){if("string"==typeof e)return f(e,t);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?f(e,t):void 0}}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var n,r,a,i,o=[],s=!0,d=!1;try{if(a=(l=l.call(e)).next,0===t){if(Object(l)!==l)return;s=!1}else for(;!(s=(n=a.call(l)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){d=!0,r=e}finally{try{if(!s&&null!=l.return&&(i=l.return(),Object(i)!==i))return}finally{if(d)throw r}}return o}}(e,t)||g(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var j=c(951),y="data-pdnd-honey-pot";function b(e){return e instanceof Element&&e.hasAttribute(y)}function w(e){var t=v(document.elementsFromPoint(e.x,e.y),2),l=t[0],n=t[1];return l?b(l)?null!=n?n:null:l:null}function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function S(e,t,l){var n;return(n=function(e,t){if("object"!=C(e)||!e)return e;var l=e[Symbol.toPrimitive];if(void 0!==l){var n=l.call(e,t||"default");if("object"!=C(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==C(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function I(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function z(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?I(Object(l),!0).forEach(function(t){S(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):I(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function k(e){var t,l,n,r,a={x:Math.min((r={x:Math.max((n={x:(l={x:Math.floor((t=e.client).x),y:Math.floor(t.y)}).x-1,y:l.y-1}).x,0),y:Math.max(n.y,0)}).x,window.innerWidth-2),y:Math.min(r.y,window.innerHeight-2)};return DOMRect.fromRect({x:a.x,y:a.y,width:2,height:2})}function O(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}function N(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e){var t=null;return function(){if(!t){for(var l=arguments.length,n=Array(l),r=0;r<l;r++)n[r]=arguments[r];t={result:e.apply(this,n)}}return t.result}}var R=T(function(){return navigator.userAgent.includes("Firefox")}),F=T(function(){var e=navigator.userAgent;return e.includes("AppleWebKit")&&!e.includes("Chrome")}),D={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};if("undefined"!=typeof window&&F()){var E=A();(0,j.bindAll)(window,[{type:"dragstart",listener:function(){E.enterCount=0,E.isOverWindow=!0}},{type:"drop",listener:B},{type:"dragend",listener:B},{type:"dragenter",listener:function(e){E.isOverWindow||0!==E.enterCount||(e[D.isEnteringWindow]=!0),E.isOverWindow=!0,E.enterCount++}},{type:"dragleave",listener:function(e){E.enterCount--,E.isOverWindow&&0===E.enterCount&&(e[D.isLeavingWindow]=!0,E.isOverWindow=!1)}}],{capture:!0})}function A(){return{enterCount:0,isOverWindow:!1}}function B(){E=A()}function M(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var L=(e=function(e){return e()},t=[],l=null,(n=function(){for(var n=arguments.length,r=Array(n),a=0;a<n;a++)r[a]=arguments[a];t=r,l||(l=requestAnimationFrame(function(){l=null,e.apply(void 0,t)}))}).cancel=function(){l&&(cancelAnimationFrame(l),l=null)},n),P=(r=null,{schedule:function(e){r={frameId:requestAnimationFrame(function(){r=null,e()}),fn:e}},flush:function(){r&&(cancelAnimationFrame(r.frameId),r.fn(),r=null)}}),$={isActive:!1};function Y(){return!$.isActive}function H(e){var t,l=e.event,n=null==(t=e.current[0])?void 0:t.dropEffect;null!=n&&l.dataTransfer&&(l.dataTransfer.dropEffect=n)}var q=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=e.dispatchEvent;if(Y()){var a,i,o=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=M(t);if("external"===l.startedFrom)return{input:r,dropTargets:[]};var a=n({input:r,source:l.payload,target:t.target,current:[]});return{input:r,dropTargets:a}}({event:t,dragType:l,getDropTargetsOver:n});$.isActive=!0;var s={current:o};H({event:t,current:o.dropTargets});var d=function(e){var t=e.source,l=e.initial,n=e.dispatchEvent,r={dropTargets:[]};function a(e){n(e),r={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var n=e.nativeSetDragImage,i={current:l,previous:r,initial:l};a({eventName:"onGenerateDragPreview",payload:{source:t,location:i,nativeSetDragImage:n}}),P.schedule(function(){a({eventName:"onDragStart",payload:{source:t,location:i}})})},dragUpdate:function(e){var n=e.current;P.flush(),L.cancel(),a({eventName:"onDropTargetChange",payload:{source:t,location:{initial:l,previous:r,current:n}}})},drag:function(e){var n=e.current;L(function(){P.flush(),a({eventName:"onDrag",payload:{source:t,location:{initial:l,previous:r,current:n}}})})},drop:function(e){var n=e.current,i=e.updatedSourcePayload;P.flush(),L.cancel(),a({eventName:"onDrop",payload:{source:null!=i?i:t,location:{current:n,previous:r,initial:l}}})}}}({source:l.payload,dispatchEvent:r,initial:o}),c=(0,j.bindAll)(window,[{type:"dragover",listener:function(e){p(e),d.drag({current:s.current})}},{type:"dragenter",listener:p},{type:"dragleave",listener:function(e){(function(e){var t=e.dragLeave,l=t.type,n=t.relatedTarget;return"dragleave"===l&&(F()?!!F()&&t.hasOwnProperty(D.isLeavingWindow):null==n||(R()?"nodeName"in n&&n.ownerDocument!==document:n instanceof HTMLIFrameElement))})({dragLeave:e})&&(u({input:s.current.input,dropTargets:[]}),"external"===l.startedFrom&&m())}},{type:"drop",listener:function(e){(s.current={dropTargets:s.current.dropTargets,input:M(e)},s.current.dropTargets.length)?(e.preventDefault(),H({event:e,current:s.current.dropTargets}),d.drop({current:s.current,updatedSourcePayload:"external"===l.type?l.getDropPayload(e):null}),x()):m()}},{type:"dragend",listener:function(e){s.current={dropTargets:s.current.dropTargets,input:M(e)},m()}}].concat(N([{type:"pointermove",listener:(i=0,function(){i<20?i++:a()})},{type:"pointerdown",listener:a=m}])),{capture:!0});d.start({nativeSetDragImage:t.dataTransfer?t.dataTransfer.setDragImage.bind(t.dataTransfer):null})}function u(e){var t=function(e){var t=e.current,l=e.next;if(t.length!==l.length)return!0;for(var n=0;n<t.length;n++)if(t[n].element!==l[n].element)return!0;return!1}({current:s.current.dropTargets,next:e.dropTargets});s.current=e,t&&d.dragUpdate({current:s.current})}function p(e){var t=M(e),r=n({target:b(e.target)?w({x:t.clientX,y:t.clientY}):e.target,input:t,source:l.payload,current:s.current.dropTargets});r.length&&(e.preventDefault(),H({event:e,current:r})),u({dropTargets:r,input:t})}function m(){s.current.dropTargets.length&&u({dropTargets:[],input:s.current.input}),d.drop({current:s.current,updatedSourcePayload:null}),x()}function x(){$.isActive=!1,c()}},G=new Map;function U(){for(var e=arguments.length,t=Array(e),l=0;l<e;l++)t[l]=arguments[l];return function(){t.forEach(function(e){return e()})}}function _(e,t){var l=t.attribute,n=t.value;return e.setAttribute(l,n),function(){return e.removeAttribute(l)}}function K(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function W(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?K(Object(l),!0).forEach(function(t){S(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):K(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function J(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return X(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?X(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function V(e){return e.slice(0).reverse()}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function Z(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}var ee=T(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),et="text/plain",el=new WeakMap,en=(a=null,{bindEvents:function(){return a=null,(0,j.bind)(window,{type:"pointermove",listener:function(e){a={x:e.clientX,y:e.clientY}},options:{capture:!0}})},getOnPostDispatch:function(){var e=null;return function(t){var l=t.eventName,n=t.payload;if("onDragStart"===l){var r,i,o,s=n.location.initial.input,d=null!=a?a:{x:s.clientX,y:s.clientY};(r=document.createElement("div")).setAttribute(y,"true"),i=k({client:d}),Object.assign(r.style,z(z({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},O({clientRect:i})),{},{pointerEvents:"auto",zIndex:0x7fffffff})),document.body.appendChild(r),o=(0,j.bind)(window,{type:"pointermove",listener:function(e){i=k({client:{x:e.clientX,y:e.clientY}}),Object.assign(r.style,O({clientRect:i}))},options:{capture:!0}}),e=function(e){var t,l,n,a=e.current;if(o(),l=(t={client:a,clientRect:i}).client,n=t.clientRect,l.x>=n.x&&l.x<=n.x+n.width&&l.y>=n.y&&l.y<=n.y+n.height)return void r.remove();function s(){d(),r.remove()}var d=(0,j.bindAll)(window,[{type:"pointerdown",listener:s},{type:"pointermove",listener:s},{type:"focusin",listener:s},{type:"focusout",listener:s},{type:"dragstart",listener:s},{type:"dragenter",listener:s},{type:"dragover",listener:s}],{capture:!0})}}if("onDrop"===l){var c,u=n.location.current.input;null==(c=e)||c({current:{x:u.clientX,y:u.clientY}}),e=null,a=null}}}}),er=function(e){var t=e.typeKey,l=e.mount,n=e.dispatchEventToSource,r=e.onPostDispatch,a=e.defaultDropEffect,i=function(){var e=new Set,t=null;function l(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}return{dispatchEvent:function(n){var r=n.eventName,a=n.payload;if("onGenerateDragPreview"===r){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var i,o=function(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return Q(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?Q(e,void 0):void 0}}(e))){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;l(s)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var d=Array.from(t.active),c=0;c<d.length;c++){var u,p=d[c];t.active.has(p)&&(null==(u=p[r])||u.call(p,a))}"onDrop"===r&&(t.active.clear(),t=null)}},monitorForConsumers:function(n){var r=function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?Z(Object(l),!0).forEach(function(t){S(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):Z(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}({},n);return e.add(r),l(r),T(function(){e.delete(r),t&&t.active.delete(r)})}}}(),o=function(e){var t=e.typeKey,l=e.defaultDropEffect,n=new WeakMap,r="data-drop-target-for-".concat(t),a="[".concat(r,"]");function i(e){var t,l=e.eventName,r=e.payload,a=J(r.location.current.dropTargets);try{for(a.s();!(t=a.n()).done;){var i,o=t.value,s=n.get(o.element),d=W(W({},r),{},{self:o});null==s||null==(i=s[l])||i.call(s,d)}}catch(e){a.e(e)}finally{a.f()}}var o={onGenerateDragPreview:i,onDrag:i,onDragStart:i,onDrop:i,onDropTargetChange:function(e){var t,l=e.payload,r=new Set(l.location.current.dropTargets.map(function(e){return e.element})),a=new Set,i=J(l.location.previous.dropTargets);try{for(i.s();!(t=i.n()).done;){var o,s,d=t.value;a.add(d.element);var c=n.get(d.element),u=r.has(d.element),p=W(W({},l),{},{self:d});null==c||null==(o=c.onDropTargetChange)||o.call(c,p),u||null==c||null==(s=c.onDragLeave)||s.call(c,p)}}catch(e){i.e(e)}finally{i.f()}var m,x=J(l.location.current.dropTargets);try{for(x.s();!(m=x.n()).done;){var h,f,g=m.value;if(!a.has(g.element)){var v=W(W({},l),{},{self:g}),j=n.get(g.element);null==j||null==(h=j.onDropTargetChange)||h.call(j,v),null==j||null==(f=j.onDragEnter)||f.call(j,v)}}}catch(e){x.e(e)}finally{x.f()}}};return{dropTargetForConsumers:function(e){return T(U(_(e.element,{attribute:r,value:"true"}),(n.set(e.element,e),function(){return n.delete(e.element)})))},getIsOver:function(e){var t=e.source,r=e.target,i=e.input,o=e.current,s=function e(t){var r,i,o,s,d=t.source,c=t.target,u=t.input,p=t.result,m=void 0===p?[]:p;if(null==c)return m;if(!(c instanceof Element))return c instanceof Node?e({source:d,target:c.parentElement,input:u,result:m}):m;var x=c.closest(a);if(null==x)return m;var h=n.get(x);if(null==h)return m;var f={input:u,source:d,element:h.element};if(h.canDrop&&!h.canDrop(f))return e({source:d,target:h.element.parentElement,input:u,result:m});var g=null!=(r=null==(i=h.getData)?void 0:i.call(h,f))?r:{},v=null!=(o=null==(s=h.getDropEffect)?void 0:s.call(h,f))?o:l,j={data:g,element:h.element,dropEffect:v,isActiveDueToStickiness:!1};return e({source:d,target:h.element.parentElement,input:u,result:[].concat(N(m),[j])})}({source:t,target:r,input:i});if(s.length>=o.length)return s;for(var d=V(o),c=V(s),u=[],p=0;p<d.length;p++){var m,x=d[p],h=c[p];if(null!=h){u.push(h);continue}var f=u[p-1],g=d[p-1];if((null==f?void 0:f.element)!==(null==g?void 0:g.element))break;var v=n.get(x.element);if(!v)break;var j={input:i,source:t,element:v.element};if(v.canDrop&&!v.canDrop(j)||!(null!=(m=v.getIsSticky)&&m.call(v,j)))break;u.push(W(W({},x),{},{isActiveDueToStickiness:!0}))}return V(u)},dispatchEvent:function(e){o[e.eventName](e)}}}({typeKey:t,defaultDropEffect:a});function s(e){null==n||n(e),o.dispatchEvent(e),i.dispatchEvent(e),null==r||r(e)}function d(e){q({event:e.event,dragType:e.dragType,getDropTargetsOver:o.getIsOver,dispatchEvent:s})}return{registerUsage:function(){var e,n;return n=function(e){var t=e.typeKey,l=e.mount,n=G.get(t);if(n)return n.usageCount++,n;var r={typeKey:t,unmount:l(),usageCount:1};return G.set(t,r),r}(e={typeKey:t,mount:function(){return l({canStart:Y,start:d})}}),function(){n.usageCount--,n.usageCount>0||(n.unmount(),G.delete(e.typeKey))}},dropTarget:o.dropTargetForConsumers,monitor:i.monitorForConsumers}}({typeKey:"element",defaultDropEffect:"move",mount:function(e){return U(en.bindEvents(),(0,j.bind)(document,{type:"dragstart",listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var l,n,r,a,i,o,s=t.target;if(s instanceof HTMLElement){var d=el.get(s);if(d){var c=M(t),u={element:d.element,dragHandle:null!=(l=d.dragHandle)?l:null,input:c};if(d.canDrag&&!d.canDrag(u))return void t.preventDefault();if(d.dragHandle){var p=w({x:c.clientX,y:c.clientY});if(!d.dragHandle.contains(p))return void t.preventDefault()}var m=null!=(n=null==(r=d.getInitialDataForExternal)?void 0:r.call(d,u))?n:null;if(m)for(var x=0,h=Object.entries(m);x<h.length;x++){var f=v(h[x],2),g=f[0],j=f[1];t.dataTransfer.setData(g,null!=j?j:"")}!ee()||t.dataTransfer.types.includes(et)||t.dataTransfer.types.includes("text/uri-list")||t.dataTransfer.setData(et,"pdnd:android-fallback"),t.dataTransfer.setData("application/vnd.pdnd","");var y={element:d.element,dragHandle:null!=(a=d.dragHandle)?a:null,data:null!=(i=null==(o=d.getInitialData)?void 0:o.call(d,u))?i:{}};e.start({event:t,dragType:{type:"element",payload:y,startedFrom:"internal"}})}}}}}))},dispatchEventToSource:function(e){var t,l,n=e.eventName,r=e.payload;null==(t=el.get(r.source.element))||null==(l=t[n])||l.call(t,r)},onPostDispatch:en.getOnPostDispatch()}),ea=er.dropTarget;function ei(e){return T(U(er.registerUsage(),(el.set(e.element,e),function(){el.delete(e.element)}),_(e.element,{attribute:"draggable",value:"true"})))}er.monitor;let eo=(0,p.createContext)({pageId:"",designable:!1,plugins:[],schema:{info:{},datasources:[],scripts:[],variables:[],items:[]},selectedItem:null,setSchema:()=>{},setSelectedItem:()=>{},updateSelectedItem:()=>{},forceUpdate:()=>{},datasetSelector:void 0,fetch:void 0}),es=e=>{let{pageId:t,designable:l,plugins:n,schema:r,selectedItem:a,setSchema:i,setSelectedItem:o,datasetSelector:s,fetch:c,children:u}=e;return(0,d.jsx)(eo.Provider,{value:{pageId:t,designable:!!l,plugins:n||[],schema:r,selectedItem:a,setSchema:i||(()=>{}),setSelectedItem:o||(()=>{}),updateSelectedItem:e=>{null==o||o(Object.assign(a,e||{})),null==i||i({...r})},datasetSelector:s,fetch:c,forceUpdate:()=>{null==i||i({...r})}},children:u})},ed=e=>{var t;let{item:l,onDelete:n,parentList:r,onListChange:a,index:i}=e,{designable:o,selectedItem:s,setSelectedItem:c,plugins:u}=(0,p.useContext)(eo),[m,x]=(0,p.useState)(!1),h=null==(t=u.find(e=>e.key===l.type))?void 0:t.component;return((0,p.useEffect)(()=>{let e=()=>{if(!t.current)return;let e=document.getElementById(`page-item-${l.id}`);if(!e)return void r();let n=e.getBoundingClientRect();if(0===n.width&&0===n.height){t.current.style.display="none";return}t.current.style.display="flex";let a=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,i=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;t.current.style.top=`${n.top+a-22}px`,t.current.style.left=`${n.left+i-1}px`},t={current:null},r=()=>{if(t.current){let l=t.current.querySelector("a");l&&l.removeEventListener("click",a),document.body.contains(t.current)&&document.body.removeChild(t.current),t.current=null,window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},a=e=>{e.stopPropagation(),n&&n()};if(s&&s===l&&o){let n=document.createElement("div");n.style.position="absolute",n.style.zIndex="1000",n.style.display="flex",n.style.gap="4px";let i=document.createElement("span");i.innerText=l.name||l.type+`(${l.id})`,i.style.background="#1890ff",i.style.color="#fff",i.style.fontSize="12px",i.style.borderTopLeftRadius="4px",i.style.borderTopRightRadius="4px",i.style.padding="2px 8px",i.style.cursor="pointer",i.style.userSelect="none",n.appendChild(i);let o=document.createElement("a");return o.innerText="X",o.style.background="#1890ff",o.style.color="#fff",o.style.fontSize="12px",o.style.borderTopLeftRadius="4px",o.style.borderTopRightRadius="4px",o.style.padding="2px 8px",o.style.cursor="pointer",o.style.userSelect="none",n.appendChild(o),o.addEventListener("click",a),document.body.appendChild(n),t.current=n,e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>r()}},[s,o,l,n]),(0,p.useEffect)(()=>{let e=document.getElementById(`page-item-${l.id}`);if(!e||!o)return;let t=ei({element:e,getInitialData:()=>({id:l.id,index:i,list:r,onListChange:a,data:l}),canDrag:()=>!!o,onDragStart:()=>{x(!0)},onDrop:()=>{x(!1)}}),n=e=>{e.stopPropagation(),c&&c(l)};return o&&e.addEventListener("click",n),()=>{t(),o&&e.removeEventListener("click",n)}},[o,l,i,r]),h)?(0,d.jsx)(h,{id:`page-item-${l.id}`,"data-item-id":l.id,...l.props||{},item:l,className:`page-item-component ${o?"designable":""} ${s===l?"selected":""}`,style:{...l.style||{},opacity:m?.5:1}}):null},ec=h().div`
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):"function"==typeof define&&define.amd?define(["@ant-design/icons","echarts","styled-components","react","antd","uuid","dayjs","@monaco-editor/react"],t):"object"==typeof exports?exports.BiSdk=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):e.BiSdk=t(e["@ant-design/icons"],e.echarts,e["styled-components"],e.react,e.antd,e.uuid,e.dayjs,e["@monaco-editor/react"])}(this,(e,t,l,n,r,a,i,o)=>(()=>{var s={290(e,t,l){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var r in t=arguments[l])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.bindAll=void 0;var r=l(352);function a(e){if(void 0!==e)return"boolean"==typeof e?{capture:e}:e}t.bindAll=function(e,t,l){var i=t.map(function(t){var i=null==l?t:n(n({},t),{options:n(n({},a(l)),a(t.options))});return(0,r.bind)(e,i)});return function(){i.forEach(function(e){return e()})}}},352(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bind=void 0,t.bind=function(e,t){var l=t.type,n=t.listener,r=t.options;return e.addEventListener(l,n,r),function(){e.removeEventListener(l,n,r)}}},951(e,t,l){"use strict";t.bindAll=t.bind=void 0;var n=l(352);Object.defineProperty(t,"bind",{enumerable:!0,get:function(){return n.bind}});var r=l(290);Object.defineProperty(t,"bindAll",{enumerable:!0,get:function(){return r.bindAll}})},965(e,t,l){"use strict";var n=l(426),r={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var l,a,i,o,s,d,c,u,p=!1;t||(t={}),i=t.debug||!1;try{if(s=n(),d=document.createRange(),c=document.getSelection(),(u=document.createElement("span")).textContent=e,u.ariaHidden="true",u.style.all="unset",u.style.position="fixed",u.style.top=0,u.style.clip="rect(0, 0, 0, 0)",u.style.whiteSpace="pre",u.style.webkitUserSelect="text",u.style.MozUserSelect="text",u.style.msUserSelect="text",u.style.userSelect="text",u.addEventListener("copy",function(l){if(l.stopPropagation(),t.format)if(l.preventDefault(),void 0===l.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var n=r[t.format]||r.default;window.clipboardData.setData(n,e)}else l.clipboardData.clearData(),l.clipboardData.setData(t.format,e);t.onCopy&&(l.preventDefault(),t.onCopy(l.clipboardData))}),document.body.appendChild(u),d.selectNodeContents(u),c.addRange(d),!document.execCommand("copy"))throw Error("copy command was unsuccessful");p=!0}catch(n){i&&console.error("unable to copy using execCommand: ",n),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),p=!0}catch(n){i&&console.error("unable to copy using clipboardData: ",n),i&&console.error("falling back to prompt"),l="message"in t?t.message:"Copy to clipboard: #{key}, Enter",a=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",o=l.replace(/#{\s*key\s*}/g,a),window.prompt(o,e)}}finally{c&&("function"==typeof c.removeRange?c.removeRange(d):c.removeAllRanges()),u&&document.body.removeChild(u),s()}return p}},20(e,t,l){"use strict";var n=l(155),r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function d(e,t,l){var n,a={},d=null,c=null;for(n in void 0!==l&&(d=""+l),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,n)&&!s.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:r,type:e,key:d,ref:c,props:a,_owner:o.current}}t.Fragment=a,t.jsx=d,t.jsxs=d},848(e,t,l){"use strict";e.exports=l(20)},426(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,l=[],n=0;n<e.rangeCount;n++)l.push(e.getRangeAt(n));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||l.forEach(function(t){e.addRange(t)}),t&&t.focus()}}},375(t){"use strict";t.exports=e},247(e){"use strict";e.exports=o},59(e){"use strict";e.exports=r},185(e){"use strict";e.exports=i},190(e){"use strict";e.exports=t},155(e){"use strict";e.exports=n},694(e){"use strict";e.exports=l},315(e){"use strict";e.exports=a}},d={};function c(e){var t=d[e];if(void 0!==t)return t.exports;var l=d[e]={exports:{}};return s[e].call(l.exports,l,l.exports,c),l.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var l in t)c.o(t,l)&&!c.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};return(()=>{"use strict";c.r(u),c.d(u,{EnvContext:()=>ex,PageCanvas:()=>ev,PageSchema:()=>o.PageSchema,PageContext:()=>eo,PageDesigner:()=>tu,PluginType:()=>o.PluginType,plugins:()=>tO,PropEditorProps:()=>s.PropEditorProps,PageProvider:()=>es,handleCallback:()=>ez,DropContainer:()=>em});var e,t,l,n,r,a,i,o={};c.r(o),c.d(o,{P:()=>tp});var s={};c.r(s);var d=c(848),p=c(155),m=c.n(p),x=c(694),h=c.n(x);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function g(e,t){if(e){if("string"==typeof e)return f(e,t);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?f(e,t):void 0}}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var n,r,a,i,o=[],s=!0,d=!1;try{if(a=(l=l.call(e)).next,0===t){if(Object(l)!==l)return;s=!1}else for(;!(s=(n=a.call(l)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){d=!0,r=e}finally{try{if(!s&&null!=l.return&&(i=l.return(),Object(i)!==i))return}finally{if(d)throw r}}return o}}(e,t)||g(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var j=c(951),y="data-pdnd-honey-pot";function b(e){return e instanceof Element&&e.hasAttribute(y)}function w(e){var t=v(document.elementsFromPoint(e.x,e.y),2),l=t[0],n=t[1];return l?b(l)?null!=n?n:null:l:null}function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function S(e,t,l){var n;return(n=function(e,t){if("object"!=C(e)||!e)return e;var l=e[Symbol.toPrimitive];if(void 0!==l){var n=l.call(e,t||"default");if("object"!=C(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==C(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function I(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function z(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?I(Object(l),!0).forEach(function(t){S(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):I(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function k(e){var t,l,n,r,a={x:Math.min((r={x:Math.max((n={x:(l={x:Math.floor((t=e.client).x),y:Math.floor(t.y)}).x-1,y:l.y-1}).x,0),y:Math.max(n.y,0)}).x,window.innerWidth-2),y:Math.min(r.y,window.innerHeight-2)};return DOMRect.fromRect({x:a.x,y:a.y,width:2,height:2})}function O(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}function N(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e){var t=null;return function(){if(!t){for(var l=arguments.length,n=Array(l),r=0;r<l;r++)n[r]=arguments[r];t={result:e.apply(this,n)}}return t.result}}var R=T(function(){return navigator.userAgent.includes("Firefox")}),F=T(function(){var e=navigator.userAgent;return e.includes("AppleWebKit")&&!e.includes("Chrome")}),D={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};if("undefined"!=typeof window&&F()){var E=A();(0,j.bindAll)(window,[{type:"dragstart",listener:function(){E.enterCount=0,E.isOverWindow=!0}},{type:"drop",listener:B},{type:"dragend",listener:B},{type:"dragenter",listener:function(e){E.isOverWindow||0!==E.enterCount||(e[D.isEnteringWindow]=!0),E.isOverWindow=!0,E.enterCount++}},{type:"dragleave",listener:function(e){E.enterCount--,E.isOverWindow&&0===E.enterCount&&(e[D.isLeavingWindow]=!0,E.isOverWindow=!1)}}],{capture:!0})}function A(){return{enterCount:0,isOverWindow:!1}}function B(){E=A()}function M(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var L=(e=function(e){return e()},t=[],l=null,(n=function(){for(var n=arguments.length,r=Array(n),a=0;a<n;a++)r[a]=arguments[a];t=r,l||(l=requestAnimationFrame(function(){l=null,e.apply(void 0,t)}))}).cancel=function(){l&&(cancelAnimationFrame(l),l=null)},n),P=(r=null,{schedule:function(e){r={frameId:requestAnimationFrame(function(){r=null,e()}),fn:e}},flush:function(){r&&(cancelAnimationFrame(r.frameId),r.fn(),r=null)}}),$={isActive:!1};function Y(){return!$.isActive}function H(e){var t,l=e.event,n=null==(t=e.current[0])?void 0:t.dropEffect;null!=n&&l.dataTransfer&&(l.dataTransfer.dropEffect=n)}var q=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=e.dispatchEvent;if(Y()){var a,i,o=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=M(t);if("external"===l.startedFrom)return{input:r,dropTargets:[]};var a=n({input:r,source:l.payload,target:t.target,current:[]});return{input:r,dropTargets:a}}({event:t,dragType:l,getDropTargetsOver:n});$.isActive=!0;var s={current:o};H({event:t,current:o.dropTargets});var d=function(e){var t=e.source,l=e.initial,n=e.dispatchEvent,r={dropTargets:[]};function a(e){n(e),r={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var n=e.nativeSetDragImage,i={current:l,previous:r,initial:l};a({eventName:"onGenerateDragPreview",payload:{source:t,location:i,nativeSetDragImage:n}}),P.schedule(function(){a({eventName:"onDragStart",payload:{source:t,location:i}})})},dragUpdate:function(e){var n=e.current;P.flush(),L.cancel(),a({eventName:"onDropTargetChange",payload:{source:t,location:{initial:l,previous:r,current:n}}})},drag:function(e){var n=e.current;L(function(){P.flush(),a({eventName:"onDrag",payload:{source:t,location:{initial:l,previous:r,current:n}}})})},drop:function(e){var n=e.current,i=e.updatedSourcePayload;P.flush(),L.cancel(),a({eventName:"onDrop",payload:{source:null!=i?i:t,location:{current:n,previous:r,initial:l}}})}}}({source:l.payload,dispatchEvent:r,initial:o}),c=(0,j.bindAll)(window,[{type:"dragover",listener:function(e){p(e),d.drag({current:s.current})}},{type:"dragenter",listener:p},{type:"dragleave",listener:function(e){(function(e){var t=e.dragLeave,l=t.type,n=t.relatedTarget;return"dragleave"===l&&(F()?!!F()&&t.hasOwnProperty(D.isLeavingWindow):null==n||(R()?"nodeName"in n&&n.ownerDocument!==document:n instanceof HTMLIFrameElement))})({dragLeave:e})&&(u({input:s.current.input,dropTargets:[]}),"external"===l.startedFrom&&m())}},{type:"drop",listener:function(e){(s.current={dropTargets:s.current.dropTargets,input:M(e)},s.current.dropTargets.length)?(e.preventDefault(),H({event:e,current:s.current.dropTargets}),d.drop({current:s.current,updatedSourcePayload:"external"===l.type?l.getDropPayload(e):null}),x()):m()}},{type:"dragend",listener:function(e){s.current={dropTargets:s.current.dropTargets,input:M(e)},m()}}].concat(N([{type:"pointermove",listener:(i=0,function(){i<20?i++:a()})},{type:"pointerdown",listener:a=m}])),{capture:!0});d.start({nativeSetDragImage:t.dataTransfer?t.dataTransfer.setDragImage.bind(t.dataTransfer):null})}function u(e){var t=function(e){var t=e.current,l=e.next;if(t.length!==l.length)return!0;for(var n=0;n<t.length;n++)if(t[n].element!==l[n].element)return!0;return!1}({current:s.current.dropTargets,next:e.dropTargets});s.current=e,t&&d.dragUpdate({current:s.current})}function p(e){var t=M(e),r=n({target:b(e.target)?w({x:t.clientX,y:t.clientY}):e.target,input:t,source:l.payload,current:s.current.dropTargets});r.length&&(e.preventDefault(),H({event:e,current:r})),u({dropTargets:r,input:t})}function m(){s.current.dropTargets.length&&u({dropTargets:[],input:s.current.input}),d.drop({current:s.current,updatedSourcePayload:null}),x()}function x(){$.isActive=!1,c()}},G=new Map;function U(){for(var e=arguments.length,t=Array(e),l=0;l<e;l++)t[l]=arguments[l];return function(){t.forEach(function(e){return e()})}}function _(e,t){var l=t.attribute,n=t.value;return e.setAttribute(l,n),function(){return e.removeAttribute(l)}}function K(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function W(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?K(Object(l),!0).forEach(function(t){S(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):K(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function J(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return X(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?X(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function V(e){return e.slice(0).reverse()}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function Z(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}var ee=T(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),et="text/plain",el=new WeakMap,en=(a=null,{bindEvents:function(){return a=null,(0,j.bind)(window,{type:"pointermove",listener:function(e){a={x:e.clientX,y:e.clientY}},options:{capture:!0}})},getOnPostDispatch:function(){var e=null;return function(t){var l=t.eventName,n=t.payload;if("onDragStart"===l){var r,i,o,s=n.location.initial.input,d=null!=a?a:{x:s.clientX,y:s.clientY};(r=document.createElement("div")).setAttribute(y,"true"),i=k({client:d}),Object.assign(r.style,z(z({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},O({clientRect:i})),{},{pointerEvents:"auto",zIndex:0x7fffffff})),document.body.appendChild(r),o=(0,j.bind)(window,{type:"pointermove",listener:function(e){i=k({client:{x:e.clientX,y:e.clientY}}),Object.assign(r.style,O({clientRect:i}))},options:{capture:!0}}),e=function(e){var t,l,n,a=e.current;if(o(),l=(t={client:a,clientRect:i}).client,n=t.clientRect,l.x>=n.x&&l.x<=n.x+n.width&&l.y>=n.y&&l.y<=n.y+n.height)return void r.remove();function s(){d(),r.remove()}var d=(0,j.bindAll)(window,[{type:"pointerdown",listener:s},{type:"pointermove",listener:s},{type:"focusin",listener:s},{type:"focusout",listener:s},{type:"dragstart",listener:s},{type:"dragenter",listener:s},{type:"dragover",listener:s}],{capture:!0})}}if("onDrop"===l){var c,u=n.location.current.input;null==(c=e)||c({current:{x:u.clientX,y:u.clientY}}),e=null,a=null}}}}),er=function(e){var t=e.typeKey,l=e.mount,n=e.dispatchEventToSource,r=e.onPostDispatch,a=e.defaultDropEffect,i=function(){var e=new Set,t=null;function l(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}return{dispatchEvent:function(n){var r=n.eventName,a=n.payload;if("onGenerateDragPreview"===r){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var i,o=function(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return Q(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?Q(e,void 0):void 0}}(e))){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;l(s)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var d=Array.from(t.active),c=0;c<d.length;c++){var u,p=d[c];t.active.has(p)&&(null==(u=p[r])||u.call(p,a))}"onDrop"===r&&(t.active.clear(),t=null)}},monitorForConsumers:function(n){var r=function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?Z(Object(l),!0).forEach(function(t){S(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):Z(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}({},n);return e.add(r),l(r),T(function(){e.delete(r),t&&t.active.delete(r)})}}}(),o=function(e){var t=e.typeKey,l=e.defaultDropEffect,n=new WeakMap,r="data-drop-target-for-".concat(t),a="[".concat(r,"]");function i(e){var t,l=e.eventName,r=e.payload,a=J(r.location.current.dropTargets);try{for(a.s();!(t=a.n()).done;){var i,o=t.value,s=n.get(o.element),d=W(W({},r),{},{self:o});null==s||null==(i=s[l])||i.call(s,d)}}catch(e){a.e(e)}finally{a.f()}}var o={onGenerateDragPreview:i,onDrag:i,onDragStart:i,onDrop:i,onDropTargetChange:function(e){var t,l=e.payload,r=new Set(l.location.current.dropTargets.map(function(e){return e.element})),a=new Set,i=J(l.location.previous.dropTargets);try{for(i.s();!(t=i.n()).done;){var o,s,d=t.value;a.add(d.element);var c=n.get(d.element),u=r.has(d.element),p=W(W({},l),{},{self:d});null==c||null==(o=c.onDropTargetChange)||o.call(c,p),u||null==c||null==(s=c.onDragLeave)||s.call(c,p)}}catch(e){i.e(e)}finally{i.f()}var m,x=J(l.location.current.dropTargets);try{for(x.s();!(m=x.n()).done;){var h,f,g=m.value;if(!a.has(g.element)){var v=W(W({},l),{},{self:g}),j=n.get(g.element);null==j||null==(h=j.onDropTargetChange)||h.call(j,v),null==j||null==(f=j.onDragEnter)||f.call(j,v)}}}catch(e){x.e(e)}finally{x.f()}}};return{dropTargetForConsumers:function(e){return T(U(_(e.element,{attribute:r,value:"true"}),(n.set(e.element,e),function(){return n.delete(e.element)})))},getIsOver:function(e){var t=e.source,r=e.target,i=e.input,o=e.current,s=function e(t){var r,i,o,s,d=t.source,c=t.target,u=t.input,p=t.result,m=void 0===p?[]:p;if(null==c)return m;if(!(c instanceof Element))return c instanceof Node?e({source:d,target:c.parentElement,input:u,result:m}):m;var x=c.closest(a);if(null==x)return m;var h=n.get(x);if(null==h)return m;var f={input:u,source:d,element:h.element};if(h.canDrop&&!h.canDrop(f))return e({source:d,target:h.element.parentElement,input:u,result:m});var g=null!=(r=null==(i=h.getData)?void 0:i.call(h,f))?r:{},v=null!=(o=null==(s=h.getDropEffect)?void 0:s.call(h,f))?o:l,j={data:g,element:h.element,dropEffect:v,isActiveDueToStickiness:!1};return e({source:d,target:h.element.parentElement,input:u,result:[].concat(N(m),[j])})}({source:t,target:r,input:i});if(s.length>=o.length)return s;for(var d=V(o),c=V(s),u=[],p=0;p<d.length;p++){var m,x=d[p],h=c[p];if(null!=h){u.push(h);continue}var f=u[p-1],g=d[p-1];if((null==f?void 0:f.element)!==(null==g?void 0:g.element))break;var v=n.get(x.element);if(!v)break;var j={input:i,source:t,element:v.element};if(v.canDrop&&!v.canDrop(j)||!(null!=(m=v.getIsSticky)&&m.call(v,j)))break;u.push(W(W({},x),{},{isActiveDueToStickiness:!0}))}return V(u)},dispatchEvent:function(e){o[e.eventName](e)}}}({typeKey:t,defaultDropEffect:a});function s(e){null==n||n(e),o.dispatchEvent(e),i.dispatchEvent(e),null==r||r(e)}function d(e){q({event:e.event,dragType:e.dragType,getDropTargetsOver:o.getIsOver,dispatchEvent:s})}return{registerUsage:function(){var e,n;return n=function(e){var t=e.typeKey,l=e.mount,n=G.get(t);if(n)return n.usageCount++,n;var r={typeKey:t,unmount:l(),usageCount:1};return G.set(t,r),r}(e={typeKey:t,mount:function(){return l({canStart:Y,start:d})}}),function(){n.usageCount--,n.usageCount>0||(n.unmount(),G.delete(e.typeKey))}},dropTarget:o.dropTargetForConsumers,monitor:i.monitorForConsumers}}({typeKey:"element",defaultDropEffect:"move",mount:function(e){return U(en.bindEvents(),(0,j.bind)(document,{type:"dragstart",listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var l,n,r,a,i,o,s=t.target;if(s instanceof HTMLElement){var d=el.get(s);if(d){var c=M(t),u={element:d.element,dragHandle:null!=(l=d.dragHandle)?l:null,input:c};if(d.canDrag&&!d.canDrag(u))return void t.preventDefault();if(d.dragHandle){var p=w({x:c.clientX,y:c.clientY});if(!d.dragHandle.contains(p))return void t.preventDefault()}var m=null!=(n=null==(r=d.getInitialDataForExternal)?void 0:r.call(d,u))?n:null;if(m)for(var x=0,h=Object.entries(m);x<h.length;x++){var f=v(h[x],2),g=f[0],j=f[1];t.dataTransfer.setData(g,null!=j?j:"")}!ee()||t.dataTransfer.types.includes(et)||t.dataTransfer.types.includes("text/uri-list")||t.dataTransfer.setData(et,"pdnd:android-fallback"),t.dataTransfer.setData("application/vnd.pdnd","");var y={element:d.element,dragHandle:null!=(a=d.dragHandle)?a:null,data:null!=(i=null==(o=d.getInitialData)?void 0:o.call(d,u))?i:{}};e.start({event:t,dragType:{type:"element",payload:y,startedFrom:"internal"}})}}}}}))},dispatchEventToSource:function(e){var t,l,n=e.eventName,r=e.payload;null==(t=el.get(r.source.element))||null==(l=t[n])||l.call(t,r)},onPostDispatch:en.getOnPostDispatch()}),ea=er.dropTarget;function ei(e){return T(U(er.registerUsage(),(el.set(e.element,e),function(){el.delete(e.element)}),_(e.element,{attribute:"draggable",value:"true"})))}er.monitor;let eo=(0,p.createContext)({pageId:"",designable:!1,plugins:[],schema:{info:{},datasources:[],scripts:[],variables:[],items:[]},selectedItem:null,setSchema:()=>{},setSelectedItem:()=>{},updateSelectedItem:()=>{},forceUpdate:()=>{},datasetSelector:void 0,fetch:void 0}),es=e=>{let{pageId:t,designable:l,plugins:n,schema:r,selectedItem:a,setSchema:i,setSelectedItem:o,datasetSelector:s,fetch:c,children:u}=e;return(0,d.jsx)(eo.Provider,{value:{pageId:t,designable:!!l,plugins:n||[],schema:r,selectedItem:a,setSchema:i||(()=>{}),setSelectedItem:o||(()=>{}),updateSelectedItem:e=>{null==o||o(Object.assign(a,e||{})),null==i||i({...r})},datasetSelector:s,fetch:c,forceUpdate:()=>{null==i||i({...r})}},children:u})},ed=e=>{var t;let{item:l,onDelete:n,parentList:r,onListChange:a,index:i}=e,{designable:o,selectedItem:s,setSelectedItem:c,plugins:u}=(0,p.useContext)(eo),[m,x]=(0,p.useState)(!1),h=null==(t=u.find(e=>e.key===l.type))?void 0:t.component;return((0,p.useEffect)(()=>{let e=()=>{if(!t.current)return;let e=document.getElementById(`page-item-${l.id}`);if(!e)return void r();let n=e.getBoundingClientRect();if(0===n.width&&0===n.height){t.current.style.display="none";return}t.current.style.display="flex";let a=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,i=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;t.current.style.top=`${n.top+a-22}px`,t.current.style.left=`${n.left+i-1}px`},t={current:null},r=()=>{if(t.current){let l=t.current.querySelector("a");l&&l.removeEventListener("click",a),document.body.contains(t.current)&&document.body.removeChild(t.current),t.current=null,window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},a=e=>{e.stopPropagation(),n&&n()};if(s&&s===l&&o){let n=document.createElement("div");n.style.position="absolute",n.style.zIndex="1000",n.style.display="flex",n.style.gap="4px";let i=document.createElement("span");i.innerText=l.name||l.type+`(${l.id})`,i.style.background="#1890ff",i.style.color="#fff",i.style.fontSize="12px",i.style.borderTopLeftRadius="4px",i.style.borderTopRightRadius="4px",i.style.padding="2px 8px",i.style.cursor="pointer",i.style.userSelect="none",n.appendChild(i);let o=document.createElement("a");return o.innerText="X",o.style.background="#1890ff",o.style.color="#fff",o.style.fontSize="12px",o.style.borderTopLeftRadius="4px",o.style.borderTopRightRadius="4px",o.style.padding="2px 8px",o.style.cursor="pointer",o.style.userSelect="none",n.appendChild(o),o.addEventListener("click",a),document.body.appendChild(n),t.current=n,e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>r()}},[s,o,l,n]),(0,p.useEffect)(()=>{let e=document.getElementById(`page-item-${l.id}`);if(!e||!o)return;let t=ei({element:e,getInitialData:()=>({id:l.id,index:i,list:r,onListChange:a,data:l}),canDrag:()=>!!o,onDragStart:()=>{x(!0)},onDrop:()=>{x(!1)}}),n=e=>{e.stopPropagation(),c&&c(l)};return o&&e.addEventListener("click",n),()=>{t(),o&&e.removeEventListener("click",n)}},[o,l,i,r]),h)?(0,d.jsx)(h,{id:`page-item-${l.id}`,"data-item-id":l.id,...l.props||{},item:l,className:`page-item-component ${o?"designable":""} ${s===l?"selected":""}`,style:{...l.style||{},opacity:m?.5:1}}):null},ec=h().div`
3
3
  position: absolute;
4
4
  background: #1890ff;
5
5
  pointer-events: none;
@@ -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;
@@ -373,7 +373,7 @@
373
373
  .conversation-list li small {
374
374
  white-space: nowrap;
375
375
  }
376
- `,e$=[],eY="bi-design",eH=e=>{let t,l,n,r,a,i,o,{agentList:s=e$,headExtra:c,style:u={},onEffect:x}=e,{pageId:h,fetch:f}=(0,p.useContext)(eo);if(!f)return null;let[g,v]=(0,p.useState)(null),[j,y]=(0,p.useState)([]),[b,w]=(0,p.useState)([]),C=m().useRef(null),S=()=>{setTimeout(()=>{C.current&&C.current.scrollToBottom()},100)},I=()=>{v(null),w([])},z=async e=>{ey.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=f.ai)?void 0:t.removeConversation(eY,h,e)),y(t=>t.filter(t=>t.id!==e)),w(t=>t.filter(t=>t.conversationId!==e)),g===e&&I()}})},k=async e=>{var t;v(e),y(t=>t.map(t=>({...t,isActived:t.id===e}))),w(await (null==(t=f.ai)?void 0:t.messageList(eY,h,e))||[])},O=async e=>{var t;let l={id:ek(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],sending:!0};w(e=>[...e,l]),S();let{id:n,answer:r,createdAt:a,conversation:i}=await (null==(t=f.ai)?void 0:t.chat(eY,h,g,e));v((null==i?void 0:i.id)||""),y(e=>[...e,i||{}]),Object.assign(l,{id:n,answer:r,createdAt:a,conversationId:(null==i?void 0:i.id)||"",sending:!1}),r.effect&&(null==x||x(r.effect)),w(e=>[...e]),S()},N=async e=>{var t;await (null==(t=f.ai)?void 0:t.removeMessage(eY,h,e)),w(t=>t.filter(t=>t.id!==e))},T=(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=[],j.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)),R=async()=>{try{var e,t;let l=await (null==(e=f.ai)?void 0:e.conversationList(eY,h));y(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){v(n.id);let e=await (null==(t=f.ai)?void 0:t.messageList(eY,h,n.id));w(e||[])}}catch(e){console.error(e)}};return(0,p.useEffect)(()=>{R()},[f]),(0,p.useEffect)(()=>{S()},[]),(0,d.jsxs)(eP,{style:u,children:[(0,d.jsx)(eL,{title:"智能助理",extra:(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:I,children:(0,d.jsx)(ew,{type:"icon-chat-plus"})})}),(0,d.jsx)(ey.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eU,{children:T.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:()=>k(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>z(e.id),children:(0,d.jsx)(ej.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ej.HistoryOutlined,{})})}),c]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:b.length?(0,d.jsx)(eK,{ref:C,list:b,onDeleteMessage:N}):(0,d.jsx)(eG,{})}),0===b.length&&j.length>0&&(0,d.jsx)(ey.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:j.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ej.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eO(e.createdAt)})]},e.id))})}),(0,d.jsx)(eB,{agentList:s,style:{padding:12},onUploading:null==f?void 0:f.upload,onSubmit:O})]})]})},eq=h().div`
376
+ `,e$=[],eY="bi-design",eH=e=>{let t,l,n,r,a,i,o,{agentList:s=e$,headExtra:c,style:u={},onEffect:x}=e,{pageId:h,fetch:f}=(0,p.useContext)(eo);if(!f)return null;let[g,v]=(0,p.useState)(null),[j,y]=(0,p.useState)([]),[b,w]=(0,p.useState)([]),C=m().useRef(null),S=()=>{setTimeout(()=>{C.current&&C.current.scrollToBottom()},100)},I=()=>{v(null),w([])},z=async e=>{ey.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=f.ai)?void 0:t.removeConversation(eY,h,e)),y(t=>t.filter(t=>t.id!==e)),w(t=>t.filter(t=>t.conversationId!==e)),g===e&&I()}})},k=async e=>{var t;v(e),y(t=>t.map(t=>({...t,isActived:t.id===e}))),w(await (null==(t=f.ai)?void 0:t.messageList(eY,h,e))||[])},O=async e=>{var t;let l={id:ek(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],sending:!0};w(e=>[...e,l]),S();let n=!g,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=f.ai)?void 0:t.chat(eY,h,g,e));v((null==o?void 0:o.id)||""),y(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)),w(e=>[...e]),S()},N=async e=>{var t;await (null==(t=f.ai)?void 0:t.removeMessage(eY,h,e)),w(t=>t.filter(t=>t.id!==e))},T=(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=[],j.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)),R=async()=>{try{var e,t;let l=await (null==(e=f.ai)?void 0:e.conversationList(eY,h));y(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){v(n.id);let e=await (null==(t=f.ai)?void 0:t.messageList(eY,h,n.id));w(e||[])}}catch(e){console.error(e)}};return(0,p.useEffect)(()=>{R()},[f]),(0,p.useEffect)(()=>{S()},[]),(0,d.jsxs)(eP,{style:u,children:[(0,d.jsx)(eL,{title:"智能助理",extra:(0,d.jsxs)(ey.Space,{children:[(0,d.jsx)(ey.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:I,children:(0,d.jsx)(ew,{type:"icon-chat-plus"})})}),(0,d.jsx)(ey.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eU,{children:T.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:()=>k(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>z(e.id),children:(0,d.jsx)(ej.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ej.HistoryOutlined,{})})}),c]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:b.length?(0,d.jsx)(eK,{ref:C,list:b,onDeleteMessage:N}):(0,d.jsx)(eG,{})}),0===b.length&&j.length>0&&(0,d.jsx)(ey.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:j.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ej.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eO(e.createdAt)})]},e.id))})}),(0,d.jsx)(eB,{agentList:s,style:{padding:12},onUploading:null==f?void 0:f.upload,onSubmit:O})]})]})},eq=h().div`
377
377
  flex: 1 1 auto;
378
378
  display: flex;
379
379
  align-items: center;
@@ -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.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/umd/js/bi-sdk.umd.min.js",
@@ -44,7 +44,7 @@ import { ScriptPanel } from "./panel/ScriptPanel";
44
44
  import { VariablesPanel } from "./panel/VariablesPanel";
45
45
 
46
46
  import { Editor } from "@monaco-editor/react";
47
- import { DesignerProvider } from "./context/DesignerContext";
47
+ import { PageProvider } from "./context/PageContext";
48
48
  import { useDeepCompareEffect } from "./hooks/useDeepCompareEffect";
49
49
  import "./styles.css";
50
50
  import {
@@ -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,13 +404,18 @@ 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
 
406
417
  return (
407
- <DesignerProvider
418
+ <PageProvider
408
419
  pageId={pageId}
409
420
  designable={designable}
410
421
  plugins={plugins}
@@ -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={{
@@ -760,7 +780,7 @@ export const PageDesigner = React.forwardRef<any, PageDesignerProps>(
760
780
  onEffect={handleAiEffect}
761
781
  />
762
782
  </Drawer>
763
- </DesignerProvider>
783
+ </PageProvider>
764
784
  );
765
785
  }
766
786
  );
@@ -1,7 +1,7 @@
1
1
  import { createContext, ReactNode } from "react";
2
2
  import { DatasetSelectorFunction, FetchType, PageSchema, PluginType, SchemaItemType } from "../typing";
3
3
 
4
- type DesignerContextType = {
4
+ type PageContextType = {
5
5
  pageId: string;
6
6
  designable: boolean;
7
7
  plugins: PluginType[];
@@ -15,7 +15,7 @@ type DesignerContextType = {
15
15
  fetch?: FetchType;
16
16
  };
17
17
 
18
- export const DesignerContext = createContext<DesignerContextType>({
18
+ export const PageContext = createContext<PageContextType>({
19
19
  pageId: "",
20
20
  designable: false,
21
21
  plugins: [],
@@ -35,15 +35,15 @@ export const DesignerContext = createContext<DesignerContextType>({
35
35
  fetch: undefined,
36
36
  });
37
37
 
38
- type DesignerProviderProps = React.PropsWithChildren<
38
+ type PageProviderProps = React.PropsWithChildren<
39
39
  Omit<
40
- Partial<DesignerContextType>,
40
+ Partial<PageContextType>,
41
41
  "updateSelectedItem" | "schema" | "forceUpdate"
42
42
  > &
43
- Pick<DesignerContextType, "schema" | "pageId">
43
+ Pick<PageContextType, "schema" | "pageId">
44
44
  >;
45
45
 
46
- export const DesignerProvider: React.FC<DesignerProviderProps> = ({
46
+ export const PageProvider: React.FC<PageProviderProps> = ({
47
47
  pageId,
48
48
  designable,
49
49
  plugins,
@@ -60,7 +60,7 @@ export const DesignerProvider: React.FC<DesignerProviderProps> = ({
60
60
  setSchema?.({ ...schema });
61
61
  };
62
62
  return (
63
- <DesignerContext.Provider
63
+ <PageContext.Provider
64
64
  value={{
65
65
  pageId,
66
66
  designable: !!designable,
@@ -78,6 +78,6 @@ export const DesignerProvider: React.FC<DesignerProviderProps> = ({
78
78
  }}
79
79
  >
80
80
  {children}
81
- </DesignerContext.Provider>
81
+ </PageContext.Provider>
82
82
  );
83
83
  };
@@ -3,7 +3,7 @@ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { PageItem, PageItemProps } from "../layout/PageItem";
4
4
  import { HtmlBaseProps, SchemaItemType } from "../typing";
5
5
  import styled from "styled-components";
6
- import { DesignerContext } from "../context/DesignerContext";
6
+ import { PageContext } from "../context/PageContext";
7
7
 
8
8
  type DropContainerProps = {
9
9
  rootComponent?: React.ComponentType<any>;
@@ -261,7 +261,7 @@ export const DropContainer: React.FC<DropContainerProps> = ({
261
261
  selectedItem,
262
262
  setSelectedItem: onSelect,
263
263
  forceUpdate,
264
- } = useContext(DesignerContext);
264
+ } = useContext(PageContext);
265
265
  const localRef = useRef<any | null>(null);
266
266
  const [isOver, setIsOver] = useState(false);
267
267
  const [indicatorOffset, setIndicatorOffset] = useState(0);
@@ -7,7 +7,7 @@ import { plugins, PropEditorProps } from "./plugins/@antd";
7
7
 
8
8
  import DropContainer from "./dnd/DropContainer";
9
9
 
10
- import { DesignerContext } from "./context/DesignerContext";
10
+ import { PageContext, PageProvider } from "./context/PageContext";
11
11
 
12
12
  import { EnvContext } from "./context/EnvContext";
13
13
 
@@ -20,7 +20,8 @@ export {
20
20
  PageDesigner,
21
21
  PageSchema,
22
22
  DropContainer,
23
- DesignerContext,
23
+ PageContext,
24
+ PageProvider,
24
25
  EnvContext,
25
26
  plugins,
26
27
  PropEditorProps,
@@ -9,7 +9,7 @@ import React, {
9
9
  import styled from "styled-components";
10
10
  import { DropContainer } from "../dnd/DropContainer";
11
11
  import { CallbacksType, EnvType, FetchType } from "../typing";
12
- import { DesignerContext } from "../context/DesignerContext";
12
+ import { PageContext } from "../context/PageContext";
13
13
  import { EnvProvider } from "../context/EnvContext";
14
14
 
15
15
  export type PageCanvasProps = {
@@ -55,7 +55,7 @@ const Wrapper = styled.div`
55
55
 
56
56
  export const PageCanvas = React.forwardRef<any, PageCanvasProps>(
57
57
  ({ device = "desktop", fetch }, ref) => {
58
- const { schema, forceUpdate } = useContext(DesignerContext);
58
+ const { schema, forceUpdate } = useContext(PageContext);
59
59
  const rootRef = useRef<HTMLDivElement | null>(null);
60
60
  const [canvasWidth, setCanvasWidth] = useState(0);
61
61
  const [callbacks, setCallbacks] = useState<CallbacksType>({});
@@ -1,6 +1,6 @@
1
1
  import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
2
2
  import React, { useContext, useEffect, useState } from "react";
3
- import { DesignerContext } from "../context/DesignerContext";
3
+ import { PageContext } from "../context/PageContext";
4
4
  import { SchemaItemType } from "../typing";
5
5
 
6
6
  export type PageItemProps = {
@@ -36,7 +36,7 @@ export const PageItem: React.FC<PageItemProps> = ({
36
36
  index,
37
37
  }) => {
38
38
  const { designable, selectedItem, setSelectedItem: onSelect, plugins } =
39
- useContext(DesignerContext);
39
+ useContext(PageContext);
40
40
  const [isDragging, setIsDragging] = useState(false);
41
41
 
42
42
  const Comp = plugins.find((p) => p.key === item.type)?.component as
@@ -25,7 +25,7 @@ import React, {
25
25
  useState,
26
26
  } from "react";
27
27
  import styled from "styled-components";
28
- import { DesignerContext } from "../context/DesignerContext";
28
+ import { PageContext } from "../context/PageContext";
29
29
  import { IconFont } from "../icon/IconFont";
30
30
  import {
31
31
  ChatConversationType,
@@ -97,7 +97,7 @@ export const AiPanel: React.FC<AiPanelProps> = ({
97
97
  style = {},
98
98
  onEffect,
99
99
  }) => {
100
- const { pageId, fetch } = useContext(DesignerContext);
100
+ const { pageId, fetch } = useContext(PageContext);
101
101
  if (!fetch) return null;
102
102
  const [conversationId, setConversationId] = useState<string | null>(null);
103
103
  const [conversationList, setConversationList] = useState<
@@ -159,6 +159,8 @@ export const AiPanel: React.FC<AiPanelProps> = ({
159
159
  setMessageList((list) => [...list, questionMessage]);
160
160
  scrollToBottom();
161
161
 
162
+ const newConversation = !conversationId
163
+
162
164
  const { id, answer, createdAt, conversation } = await fetch.ai?.chat(
163
165
  BIZ_TYPE,
164
166
  pageId,
@@ -167,9 +169,9 @@ export const AiPanel: React.FC<AiPanelProps> = ({
167
169
  )!;
168
170
  setConversationId(conversation?.id || "");
169
171
  setConversationList((list) => [
172
+ newConversation ? conversation || ({} as ChatConversationType) : null,
170
173
  ...list,
171
- conversation || ({} as ChatConversationType),
172
- ]);
174
+ ].filter((i) => i !== null));
173
175
  Object.assign(questionMessage, {
174
176
  id,
175
177
  answer,
@@ -570,8 +572,8 @@ const MessageRoot = styled.div`
570
572
  color: var(--ant-color-text-tertiary);
571
573
  }
572
574
  &-list {
573
- max-height: 200px;
574
- overflow: auto;
575
+ // max-height: 200px;
576
+ // overflow: auto;
575
577
  display: flex;
576
578
  flex-wrap: wrap;
577
579
  flex-direction: row;
@@ -8,7 +8,7 @@ import {
8
8
  import { PaneHeader } from "./PaneHeader";
9
9
  import { IconFont } from "../icon/IconFont";
10
10
  import styled from "styled-components";
11
- import { DesignerContext } from "../context/DesignerContext";
11
+ import { PageContext } from "../context/PageContext";
12
12
 
13
13
  const Root = styled.div`
14
14
  display: flex;
@@ -53,7 +53,7 @@ const Root = styled.div`
53
53
 
54
54
  export const CascadePanel: React.FC = ({}) => {
55
55
  const { schema, selectedItem, setSelectedItem, plugins, forceUpdate } =
56
- useContext(DesignerContext);
56
+ useContext(PageContext);
57
57
  const pluginMap = useMemo(() => {
58
58
  return (plugins || []).reduce((prev: Record<string, any>, cur: any) => {
59
59
  prev[cur.key] = cur;