@nocobase/plugin-data-visualization 1.3.15-beta → 1.3.17-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(ct,z){typeof exports=="object"&&typeof module!="undefined"?z(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/react"),require("antd"),require("lodash"),require("react-i18next"),require("dayjs"),require("@formily/shared"),require("@nocobase/utils/client"),require("ahooks"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","@ant-design/icons","@formily/antd-v5","@formily/core","@formily/react","antd","lodash","react-i18next","dayjs","@formily/shared","@nocobase/utils/client","ahooks","@emotion/css"],z):(ct=typeof globalThis!="undefined"?globalThis:ct||self,z(ct["@nocobase/plugin-data-visualization"]={},ct["@nocobase/client"],ct.jsxRuntime,ct.react,ct["@ant-design/icons"],ct["@formily/antd-v5"],ct["@formily/core"],ct["@formily/react"],ct.antd,ct.lodash,ct["react-i18next"],ct.dayjs,ct["@formily/shared"],ct["@nocobase/utils"],ct.ahooks,ct["@emotion/css"]))})(this,function(ct,z,Y,K,In,ae,wn,dt,Ot,rn,My,Ve,Bo,au,Mi,zo){"use strict";var kSt=Object.defineProperty,TSt=Object.defineProperties;var LSt=Object.getOwnPropertyDescriptors;var Ey=Object.getOwnPropertySymbols;var X9=Object.prototype.hasOwnProperty,q9=Object.prototype.propertyIsEnumerable;var MS=(ct,z)=>(z=Symbol[ct])?z:Symbol.for("Symbol."+ct),Ce=Math.pow,PS=(ct,z,Y)=>z in ct?kSt(ct,z,{enumerable:!0,configurable:!0,writable:!0,value:Y}):ct[z]=Y,tt=(ct,z)=>{for(var Y in z||(z={}))X9.call(z,Y)&&PS(ct,Y,z[Y]);if(Ey)for(var Y of Ey(z))q9.call(z,Y)&&PS(ct,Y,z[Y]);return ct},ht=(ct,z)=>TSt(ct,LSt(z));var AS=(ct,z)=>{var Y={};for(var K in ct)X9.call(ct,K)&&z.indexOf(K)<0&&(Y[K]=ct[K]);if(ct!=null&&Ey)for(var K of Ey(ct))z.indexOf(K)<0&&q9.call(ct,K)&&(Y[K]=ct[K]);return Y};var ri=(ct,z,Y)=>(PS(ct,typeof z!="symbol"?z+"":z,Y),Y);var Nn=(ct,z,Y)=>new Promise((K,In)=>{var ae=Ot=>{try{dt(Y.next(Ot))}catch(rn){In(rn)}},wn=Ot=>{try{dt(Y.throw(Ot))}catch(rn){In(rn)}},dt=Ot=>Ot.done?K(Ot.value):Promise.resolve(Ot.value).then(ae,wn);dt((Y=Y.apply(ct,z)).next())}),NSt=function(ct,z){this[0]=ct,this[1]=z};var K9=ct=>{var z=ct[MS("asyncIterator")],Y=!1,K,In={};return z==null?(z=ct[MS("iterator")](),K=ae=>In[ae]=wn=>z[ae](wn)):(z=z.call(ct),K=ae=>In[ae]=wn=>{if(Y){if(Y=!1,ae==="throw")throw wn;return wn}return Y=!0,{done:!1,value:new NSt(new Promise(dt=>{var Ot=z[ae](wn);if(!(Ot instanceof Object))throw TypeError("Object expected");dt(Ot)}),1)}}),In[MS("iterator")]=()=>In,K("next"),"throw"in z?K("throw"):In.throw=ae=>{throw ae},"return"in z&&K("return"),In};function hB(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}const CS="data-visualization";function St(t){return z.i18n.t(t,{ns:[CS,"client"]})}function se(){return My.useTranslation([CS,"client"],{nsMode:"fallback"})}const Py={datetime:[{label:St("YYYY"),value:"YYYY"},{label:St("MM"),value:"MM"},{label:St("DD"),value:"DD"},{label:St("YYYY-MM"),value:"YYYY-MM"},{label:St("YYYY-MM-DD"),value:"YYYY-MM-DD"},{label:St("YYYY-MM-DD hh:mm"),value:"YYYY-MM-DD hh:mm"},{label:St("YYYY-MM-DD hh:mm:ss"),value:"YYYY-MM-DD hh:mm:ss"}],date:[{label:St("YYYY"),value:"YYYY"},{label:St("MM"),value:"MM"},{label:St("DD"),value:"DD"},{label:St("YYYY-MM"),value:"YYYY-MM"},{label:St("YYYY-MM-DD"),value:"YYYY-MM-DD"}],time:[{label:St("hh:mm:ss"),value:"hh:mm:ss"},{label:St("hh:mm"),value:"hh:mm"},{label:St("hh"),value:"hh"}]},pB=K.createContext(null),Ay={didCatch:!1,error:null};let kS=class extends K.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Ay}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var n,r,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(Ay)}}componentDidCatch(e,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,e,n)}componentDidUpdate(e,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&vB(e.resetKeys,i)){var o,a;(o=(a=this.props).onReset)===null||o===void 0||o.call(a,{next:i,prev:e.resetKeys,reason:"keys"}),this.setState(Ay)}}render(){const{children:e,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:o,error:a}=this.state;let s=e;if(o){const l={error:a,resetErrorBoundary:this.resetErrorBoundary};if(K.isValidElement(i))s=i;else if(typeof n=="function")s=n(l);else if(r)s=K.createElement(r,l);else throw a}return K.createElement(pB.Provider,{value:{didCatch:o,error:a,resetErrorBoundary:this.resetErrorBoundary}},s)}};function vB(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return t.length!==e.length||t.some((n,r)=>!Object.is(n,e[r]))}const TS=(t,e={})=>{const{collection:n,config:r}=t,{title:i,bordered:o}=r||{};return{type:"void","x-decorator":"ChartRendererProvider","x-decorator-props":t,"x-acl-action":`${n}:list`,"x-designer":"ChartRenderer.Designer","x-component":"CardItem","x-component-props":{size:"small",title:i,bordered:o},"x-initializer":"charts:addBlock",properties:{[Bo.uid()]:{type:"void","x-component":"ChartRenderer","x-component-props":e}}}},su=t=>{let e,n;return Array.isArray(t)?t.length===1?n=t[0]:t.length>1&&([e,n]=t):n=t,{target:e,name:n,alias:e?`${e}.${n}`:n}},ph=(t,e)=>{var o,a;const{target:n,name:r}=su(e);return n?(a=(o=t.find(s=>s.name===n))==null?void 0:o.targetFields)==null?void 0:a.find(s=>s.name===r):t.find(s=>s.name===r)},il=(t,e)=>{const n=s=>s.map(l=>{const c=ph(t,l.field);return ht(tt({},c),{key:l.alias||(c==null?void 0:c.key),label:l.alias||(c==null?void 0:c.label),value:l.alias||(c==null?void 0:c.value)})}),r=e.measures||[],i=e.dimensions||[];return[...new Map([...n(r),...n(i)].map(s=>[s.value,s])).values()]},gB=(t,e,n)=>{const r=(i,o)=>{var l;const a=(l=i.uiSchema)==null?void 0:l.enum;if(!a||!Array.isArray(a))return o;if(Array.isArray(o))return o.map(c=>r(i,c));const s=a.find(c=>{var u;return c.value===(((u=o==null?void 0:o.toString)==null?void 0:u.call(o))||o)});return dt.Schema.compile((s==null?void 0:s.label)||o,n)};return e.map(i=>{const o={};return Object.entries(i).forEach(([a,s])=>{const l=t.find(c=>c.value===a);if(!l){o[a]=s;return}switch(l.interface){case"select":case"radioGroup":case"multipleSelect":o[a]=r(l,s);break;default:o[a]=s}}),o})},Cy=t=>{if(typeof t=="object"&&t!==null)if(Array.isArray(t)){const e=t.map(n=>Cy(n)).filter(Boolean);return e.length>0?e:null}else{const e={};for(const n in t){const r=Cy(t[n]);r!=null&&!(typeof r=="object"&&Object.keys(r).length===0)&&(e[n]=r)}return Object.keys(e).length>0?e:null}else if(typeof t=="string"&&t.startsWith("{{$nFilter.")&&t.endsWith("}}"))return null;return t},yB=(t,e)=>{const n=e.split(".");let r=rn.get(t,n.slice(0,-1).join("."));return Array.isArray(r)?r=r.map(i=>rn.get(i,n.slice(-1)[0])):r=rn.get(r,n.slice(-1)[0]),r},mB=t=>({boolean:"Checkbox",integer:"InputNumber",bigInt:"InputNumber",double:"InputNumber",decimal:"InputNumber",date:"DatePicker",string:"Input"})[t],bB=t=>({boolean:"boolean",integer:"integer",bigInt:"integer",double:"number",decimal:"number",date:"datetime",string:"input"})[t],ol=K.createContext({});ol.displayName="ChartDataContext";const xB=t=>{const[e,n]=K.useState({}),r=Mi.useMemoizedFn((o,{dataSource:a,collection:s,service:l,query:c})=>{n(u=>ht(tt({},u),{[o]:{dataSource:a,collection:s,service:l,query:c}}))}),i=Mi.useMemoizedFn(o=>{n(a=>ht(tt({},a),{[o]:void 0}))});return Y.jsx(ol.Provider,{value:{charts:e,addChart:r,removeChart:i},children:t.children})},kr=K.createContext({});kr.displayName="ChartFilterContext";const wB=t=>{const[e,n]=K.useState(!1),[r,i]=K.useState(!1),[o,a]=K.useState({}),[s,l]=K.useState({collapsed:!1,row:1}),[c,u]=K.useState(),f=Mi.useMemoizedFn((g,y)=>{a(m=>ht(tt({},m),{[g]:tt(tt({},m[g]||{}),y)}))}),d=Mi.useMemoizedFn(g=>{a(y=>{const m=tt({},y);return m[g]=void 0,m})}),h=Mi.useMemoizedFn(u),p=Mi.useMemoizedFn(i),v=({collapsed:g,row:y})=>{l(m=>({collapsed:g!==void 0?g:m.collapsed,row:y!==void 0?y:m.row}))};return K.useEffect(()=>n(!0),[]),Y.jsx(kr.Provider,{value:{ready:e,enabled:r,setEnabled:p,fields:o,setField:f,removeField:d,collapse:s,setCollapse:v,form:c,setForm:h},children:t.children})},ii=K.createContext({});ii.displayName="ChartRendererContext";const LS=t=>{const{query:e,config:n,collection:r,transform:i,dataSource:o=z.DEFAULT_DATA_SOURCE_KEY}=t,{addChart:a}=K.useContext(ol),{ready:s,form:l,enabled:c}=K.useContext(kr),{getFilter:u,hasFilter:f,appendFilter:d,parseFilter:h}=sl(),p=dt.useFieldSchema(),v=z.useAPIClient(),g=z.useRequest((y,m,b,x)=>Nn(this,null,function*(){var M,P;if(!(m&&((M=b==null?void 0:b.measures)!=null&&M.length))||c&&!l)return;const w=u(),O=yield h(b.filter),_=ht(tt({},b),{filter:O}),S={dataSource:y,collection:m,query:_},E=!x&&f(S,w)?d(S,w):_;try{const k=yield v.request({url:"charts:query",method:"POST",data:ht(tt({uid:p==null?void 0:p["x-uid"],dataSource:y,collection:m},E),{filter:Cy(E.filter),dimensions:((b==null?void 0:b.dimensions)||[]).map(A=>{const C=tt({},A);if(A.format&&!A.alias){const{alias:T}=su(A.field);C.alias=T}return C}),measures:((b==null?void 0:b.measures)||[]).map(A=>{const C=tt({},A);if(A.aggregation&&!A.alias){const{alias:T}=su(A.field);C.alias=T}return C})})});return(P=k==null?void 0:k.data)==null?void 0:P.data}catch(k){throw console.error(k),k}finally{!x&&(p!=null&&p["x-uid"])&&a(p==null?void 0:p["x-uid"],{dataSource:y,collection:m,service:g,query:b})}}),{defaultParams:[o,r,e],ready:s&&(!c||!!l)});return Y.jsx(z.CollectionManagerProvider,{dataSource:o,children:Y.jsx(z.MaybeCollectionProvider,{collection:r,children:Y.jsx(ii.Provider,{value:{dataSource:o,collection:r,config:n,transform:i,service:g,query:e},children:t.children})})})};class OB{constructor(){ri(this,"charts",new Map)}setGroup(e,n){this.charts.set(e,n)}addGroup(e,n){if(this.charts.has(e))throw new Error(`[data-visualization] Chart group "${e}" already exists`);this.setGroup(e,n)}add(e,n){var r;this.charts.has(e)||this.setGroup(e,[]),(r=this.charts.get(e))==null||r.push(n)}getChartTypes(){const e=[];this.charts.forEach((r,i)=>{const o=r.map(a=>({key:`${i}.${a.name}`,label:St(a.title),value:`${i}.${a.name}`}));e.push({label:St(i),children:o})});const n=e.findIndex(r=>r.label===St("Built-in"));if(n>-1){const[r]=e.splice(n,1);e.unshift(r)}return e}getCharts(){const e={};return this.charts.forEach((n,r)=>{n.forEach(i=>{e[`${r}.${i.name}`]=i})}),e}getChart(e){return this.getCharts()[e]}}const NS=()=>z.usePlugin(Sy).charts.getChartTypes(),_B=()=>{var e,n,r;return(r=(n=(e=NS()[0])==null?void 0:e.children)==null?void 0:n[0])==null?void 0:r.value},IS=()=>z.usePlugin(Sy).charts.getCharts(),SB=t=>z.usePlugin(Sy).charts.getChart(t),{Paragraph:EB,Text:MB}=Ot.Typography,ky=t=>{const{t:e}=se(),n=K.useContext(ii),{config:r,transform:i,dataSource:o,collection:a,service:s,data:l}=n,c=Ua(o,a),u=DS(l,o,a),f=(r==null?void 0:r.general)||{},d=(r==null?void 0:r.advanced)||{},h=z.useAPIClient(),p=SB(r==null?void 0:r.chartType),v=h.auth.getLocale(),g=BB(i,v),y=p==null?void 0:p.getProps({data:u,general:f,advanced:d,fieldProps:Object.keys(u[0]||{}).reduce((x,w)=>{if(!x[w]){const O=ph(c,w.split(".")),_=g[w];x[w]={label:(O==null?void 0:O.label)||w,transformer:_,interface:O==null?void 0:O.interface}}return x},{})}),m=dt.Schema.compile(y),b=p==null?void 0:p.Component;return p?!(u&&u.length)&&!s.loading?Y.jsx(Ot.Empty,{image:Ot.Empty.PRESENTED_IMAGE_SIMPLE,description:e("No data")}):Y.jsx(Ot.Spin,{spinning:s.loading,children:Y.jsx(kS,{onError:x=>{console.error(x)},FallbackComponent:PB,children:Y.jsx(b,tt({},m))})}):Y.jsx(Ot.Empty,{image:Ot.Empty.PRESENTED_IMAGE_SIMPLE,description:e("Please configure chart")})};ky.Designer=function(){const{t:e}=se(),{setVisible:n,setCurrent:r}=K.useContext(Pi),{removeChart:i}=K.useContext(ol),{service:o}=K.useContext(ii),a=dt.useField(),s=dt.useFieldSchema(),{insertAdjacent:l}=z.useDesignable(),c=z.useDataSource(),{name:u,title:f}=z.useCollection_deprecated();return Y.jsxs(z.GeneralSchemaDesigner,{disableInitializer:!0,title:f||u,children:[Y.jsx(z.SchemaSettingsItem,{title:"Configure",onClick:()=>Nn(this,null,function*(){r({schema:s,field:a,dataSource:c.key,collection:u,service:o,data:o.data}),n(!0)}),children:e("Configure")},"configure"),Y.jsx(z.SchemaSettingsItem,{title:"Duplicate",onClick:()=>l("afterEnd",z.gridRowColWrap(TS(s==null?void 0:s["x-decorator-props"]))),children:e("Duplicate")},"duplicate"),Y.jsx(z.SchemaSettingsDivider,{}),Y.jsx(z.SchemaSettingsRemove,{breakRemoveOn:{"x-component":"ChartV2Block"},confirm:{onOk:()=>{i(s["x-uid"])}}})]})};const PB=({error:t})=>{const{t:e}=se();return Y.jsx("div",{style:{backgroundColor:"white"},children:Y.jsx(Ot.Result,{status:"error",title:e("Render Failed"),subTitle:e("Please check the configuration."),children:Y.jsx(EB,{copyable:!0,children:Y.jsx(MB,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:t.message})})})})},lu=t=>{const{current:e}=K.useContext(Pi),{dataSource:n=t||z.DEFAULT_DATA_SOURCE_KEY,collection:r}=e||{},i=z.useDataSourceManager(),o=i.getDataSource(n),a=i.collectionFieldInterfaceManager;return{cm:o==null?void 0:o.collectionManager,fim:a,collection:r}},AB=t=>(t||[]).filter(n=>n.interface).map(n=>{var r;return ht(tt({},n),{key:n.name,label:((r=n.uiSchema)==null?void 0:r.title)||n.name,value:n.name})}),Ua=(t,e)=>{const{t:n}=My.useTranslation(),{cm:r,fim:i,collection:o}=lu(t),a=r.getCollectionFields(e||o),s=AB(a);return K.useMemo(()=>s.map(l=>{var d,h,p,v;const c=(d=i.getFieldInterface(l.interface))==null?void 0:d.filterable,u=dt.Schema.compile(((h=l.uiSchema)==null?void 0:h.title)||l.name,{t:n});if(!(c&&(c!=null&&c.nested||(p=c==null?void 0:c.children)!=null&&p.length)))return ht(tt({},l),{label:u});let f=[];if(c!=null&&c.nested){const g=(r.getCollectionFields(l.target)||[]).filter(y=>y.interface).map(y=>{var m;return ht(tt({},y),{key:`${l.name}.${y.name}`,label:`${u} / ${dt.Schema.compile(((m=y.uiSchema)==null?void 0:m.title)||y.name,{t:n})}`,value:`${l.name}.${y.name}`})});f=[...f,...g]}if((v=c==null?void 0:c.children)!=null&&v.length){const g=c.children.map(y=>{var m;return ht(tt({},y),{key:`${l.name}.${y.name}`,label:`${u} / ${dt.Schema.compile(((m=y.schema)==null?void 0:m.title)||y.title||y.name,{t:n})}`,value:`${l.name}.${y.name}`})});f=[...f,...g]}return ht(tt({},l),{label:u,targetFields:f})}),[s])},jS=t=>e=>{const n=e.query("query").get("value")||{},r=il(t,n);e.dataSource=r},CB=t=>e=>{var o;const n=e.query(".field").get("value");if(!n){e.dataSource=[];return}let r=[];switch((o=ph(t,n))==null?void 0:o.interface){case"datetime":case"createdAt":case"updatedAt":r=Py.datetime;break;case"date":r=Py.date;break;case"time":r=Py.time;break;default:r=[]}e.dataSource=r},kB=()=>{const{t}=My.useTranslation(),e=z.useDataSourceManager(),{parseAction:n}=z.useACLRoleContext(),i=e.getAllCollections({filterCollection:o=>n(`${o.name}:list`)}).filter(({key:o,isDBInstance:a})=>o===z.DEFAULT_DATA_SOURCE_KEY||a).map(({key:o,displayName:a,collections:s})=>({value:o,label:a,children:s.map(l=>({value:l.name,label:l.title}))}));return K.useMemo(()=>dt.Schema.compile(i,{t}),[i])},TB=(t,e)=>n=>{const r=n.query("query").get("value")||{},{measures:i=[]}=r;if(!i.some(s=>s.aggregation)){n.componentProps.fieldNames={label:"title",value:"name",children:"children"},n.dataSource=t;return}const a=il(e,r);n.componentProps.fieldNames={},n.dataSource=a},LB=(t,e)=>n=>{const r=n.query("query").get("value")||{},{measures:i=[]}=r,o=i.some(u=>u.aggregation);let a=t;const s=[];o?(a=il(e,r),a.forEach(u=>{s.push(u.value)})):a.forEach(u=>{const f=u.children||[];f.length||s.push(u.value||u.name),f.forEach(d=>{s.push(`${u.name}.${d.name}`)})});const c=(n.value||[]).reduce((u,f)=>{const{alias:d}=su(f.field);return(!f.field||s.includes(d))&&u.push(f),u},[]);n.setValue(c)},DS=(t,e,n)=>{var c;const{t:r}=se(),{service:i,query:o}=K.useContext(ii),a=Ua(e,n),s=dt.useForm(),l=il(a,((c=s==null?void 0:s.values)==null?void 0:c.query)||o);return gB(l,(i==null?void 0:i.data)||t||[],{t:r})},NB=(t,e,n=2,r=[])=>{const{cm:i,fim:o,collection:a}=lu(t),l=i.getCollectionFields(e||a).filter(d=>!r.includes(d.interface)),c=(d,h,p)=>{var x;if(!d.interface||d.isForeignKey)return;const v=o.getFieldInterface(d.interface);if(!(v!=null&&v.filterable))return;const{nested:g,children:y}=v.filterable,m=p?`${p}.${d.name}`:d.name,b=ht(tt({},d),{name:d.name,title:((x=d==null?void 0:d.uiSchema)==null?void 0:x.title)||d.name,schema:d==null?void 0:d.uiSchema,key:m});if(!(d.target&&h>n)){if(h>n)return b;if(y!=null&&y.length&&(b.children=y.map(w=>ht(tt({},w),{key:`${d.name}.${w.name}`}))),g){const w=i.getCollectionFields(d.target).filter(_=>!r.includes(_.interface)),O=u(w,h+1,d.name).filter(Boolean);b.children=b.children||[],b.children.push(...O)}return b}},u=(d,h,p)=>{const v=[];return d.forEach(g=>{const y=c(g,h,p);y&&v.push(y)}),v};return u(l,1)},IB=(t,e)=>{const{cm:n,fim:r,collection:i}=lu(t);return K.useMemo(()=>{const o=n.getCollectionFields(e||i),a=(c,u)=>{var g,y;if(!c.interface||c.isForeignKey)return;const f=r.getFieldInterface(c.interface);if(!(f!=null&&f.filterable))return;const{nested:d,children:h,operators:p}=f.filterable,v={name:c.name,title:((g=c==null?void 0:c.uiSchema)==null?void 0:g.title)||c.name,schema:c==null?void 0:c.uiSchema,operators:((y=p==null?void 0:p.filter)==null?void 0:y.call(p,m=>!(m!=null&&m.visible)||m.visible(c)))||[],interface:c.interface};if(!(c.target&&u>2)){if(u>2)return v;if(h!=null&&h.length&&(v.children=h),d){const m=n.getCollectionFields(c.target),b=s(m,u+1).filter(Boolean);v.children=v.children||[],v.children.push(...b)}return v}},s=(c,u)=>{const f=[];return c.forEach(d=>{const h=a(d,u);h&&f.push(h)}),f};return s(o,1)},[e,n,r])},Yo={general:{Prefix:{schema:{"x-component":"Input"},fn:(t,e)=>e?`${e}${t}`:t},Suffix:{schema:{"x-component":"Input"},fn:(t,e)=>e?`${t}${e}`:t}},datetime:{Format:{schema:{"x-component":"AutoComplete","x-component-props":{allowClear:!0,style:{minWidth:200}},enum:[{label:"YYYY",value:"YYYY"},{label:"YYYY-MM",value:"YYYY-MM"},{label:"YYYY-MM-DD",value:"YYYY-MM-DD"},{label:"YYYY-MM-DD hh:mm",value:"YYYY-MM-DD hh:mm"},{label:"YYYY-MM-DD hh:mm:ss",value:"YYYY-MM-DD hh:mm:ss"}]},fn:(t,e)=>Ve(t).format(e)},YYYY:{label:"YYYY (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY")},MM:{label:"MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("MM")},DD:{label:"DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("DD")},"YYYY-MM":{label:"YYYY-MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM")},"YYYY-MM-DD":{label:"YYYY-MM-DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD")},"YYYY-MM-DD hh:mm":{label:"YYYY-MM-DD hh:mm (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD hh:mm")},"YYYY-MM-DD hh:mm:ss":{label:"YYYY-MM-DD hh:mm:ss (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD hh:mm:ss")}},date:{Format:{schema:{"x-component":"AutoComplete","x-component-props":{allowClear:!0,style:{minWidth:200}},enum:[{label:"YYYY",value:"YYYY"},{label:"MM",value:"MM"},{label:"DD",value:"DD"},{label:"YYYY-MM",value:"YYYY-MM"},{label:"YYYY-MM-DD",value:"YYYY-MM-DD"}]},fn:(t,e)=>Ve(t).format(e)},YYYY:{label:"YYYY (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY")},MM:{label:"MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("MM")},DD:{label:"DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("DD")},"YYYY-MM":{label:"YYYY-MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM")},"YYYY-MM-DD":{label:"YYYY-MM-DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD")}},time:{Format:{schema:{"x-component":"AutoComplete","x-component-props":{allowClear:!0,style:{minWidth:200}},enum:[{label:"hh:mm:ss",value:"hh:mm:ss"},{label:"hh:mm",value:"hh:mm"},{label:"hh",value:"hh"}]},fn:(t,e)=>Ve(t).format(e)},"hh:mm:ss":{label:"hh:mm:ss (Deprecated, use Format instead)",fn:t=>Ve(t).format("hh:mm:ss")},"hh:mm":{label:"hh:mm (Deprecated, use Format instead)",fn:t=>Ve(t).format("hh:mm")},hh:{label:"hh (Deprecated, use Format instead)",fn:t=>Ve(t).format("hh")}},number:{Precision:{schema:{"x-component":"Select",enum:[{label:"1",value:0},{label:"1.0",value:1},{label:"1.00",value:2},{label:"1.000",value:3}]},fn:(t,e)=>Number(t.toFixed(e))},Separator:{schema:{"x-component":"Select",enum:[{label:"100,000.00",value:"en-US"},{label:"100.000,00",value:"de-DE"},{label:"100 000.00",value:"ru-RU"}]},fn:(t,e)=>{switch(e){case"en-US":return t.toLocaleString("en-US",{minimumFractionDigits:2});case"de-DE":return t.toLocaleString("de-DE",{minimumFractionDigits:2});case"ru-RU":return t.toLocaleString("ru-RU",{minimumFractionDigits:2});default:return t}}},Percent:t=>new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:2,maximumFractionDigits:2}).format(t),Currency:{label:"Currency (Deprecated, use Separator & Prefix instead)",fn:(t,e="en-US")=>{const n={"zh-CN":"CNY","en-US":"USD","ja-JP":"JPY","ko-KR":"KRW","pt-BR":"BRL","ru-RU":"RUB","tr-TR":"TRY","es-ES":"EUR"}[e]||"USD";return new Intl.NumberFormat(e,{style:"currency",currency:n}).format(t)}},Exponential:t=>(+t).toExponential(),Abbreviation:{schema:{"x-component":"Select",enum:[{label:"en-US",value:"en-US"},{label:"zh-CN",value:"zh-CN"}]},fn:(t,e="en-US")=>new Intl.NumberFormat(e,{notation:"compact"}).format(t)}},string:{"Type conversion":{schema:{"x-component":"Select",enum:[{label:"Number",value:"Number"},{label:"Date",value:"Date"}]},fn:(t,e)=>{try{return new Function(`return ${e}(${t})`)()}catch(n){return console.log(n),t}}}}},jB=t=>function(){const n=dt.useField(),r=n.query("query").get("value")||{},i=il(t,r),o=Object.keys(Yo).filter(a=>a!=="general");return{onChange:a=>{n.value=a;const s=n.query(".type").take();a||s.setState({value:null});const l=i.find(h=>h.value===a);s.dataSource=o.map(h=>({label:St(h),value:h}));const c={createdAt:"datetime",updatedAt:"datetime",double:"number",integer:"number",percent:"number"},u=l==null?void 0:l.interface,f=l==null?void 0:l.type,d=c[u]||c[f]||f;if(o.includes(d)){s.setState({value:d});return}s.setState({value:null})}}},DB=()=>{const t=dt.useField();return{options:Object.keys(Yo).filter(r=>r!=="general").map(r=>({label:St(r),value:r})),onChange:r=>{t.value=r,t.query(".format").take().setValue(null)}}},FB=()=>{const t=dt.useField();return{onChange:e=>{t.value=e,t.query(".argument").take().setValue(null)}}},$B=t=>{const e=t.query(".type").get("value");if(!e){t.dataSource=[];return}const n=Object.entries(tt(tt({},Yo.general),Yo[e]||{})).map(([r,i])=>{const o=typeof i=="function"?r:i.label||r;return{label:St(o),value:r}});t.dataSource=n},RB=t=>{const e=t.query(".type").get("value"),n=t.query(".format").get("value");if(!n||!e){t.setComponentProps({schema:null});return}const r=Yo[e][n]||Yo.general[n];if(!r||typeof r=="function"){t.setComponentProps({schema:null});return}const i=Bo.uid();t.setComponentProps({schema:tt({name:i},r.schema)})},BB=(t,e="en-US")=>{const n=(t||[]).filter(i=>i.field&&i.type&&i.format).reduce((i,o)=>{const a=Yo[o.type][o.format]||Yo.general[o.format];return a&&(i[o.field]=[...i[o.field]||[],{transformer:a,argument:o.argument}]),i},{}),r={};return Object.entries(n).forEach(([i,o])=>{r[i]=o.reduce((a,s)=>{const{transformer:l}=s;let{argument:c}=s;return u=>{try{return typeof l=="function"?l(a(u),c):(!c&&!l.schema&&(c=e),l.fn(a(u),c))}catch(f){return console.log(f),u}}},a=>a)}),r};function cu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zB=function(e){return YB(e)&&!WB(e)};function YB(t){return!!t&&typeof t=="object"}function WB(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||UB(t)}var GB=typeof Symbol=="function"&&Symbol.for,HB=GB?Symbol.for("react.element"):60103;function UB(t){return t.$$typeof===HB}function VB(t){return Array.isArray(t)?[]:{}}function uu(t,e){return e.clone!==!1&&e.isMergeableObject(t)?al(VB(t),t,e):t}function XB(t,e,n){return t.concat(e).map(function(r){return uu(r,n)})}function qB(t,e){if(!e.customMerge)return al;var n=e.customMerge(t);return typeof n=="function"?n:al}function KB(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}function FS(t){return Object.keys(t).concat(KB(t))}function $S(t,e){try{return e in t}catch(n){return!1}}function ZB(t,e){return $S(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function QB(t,e,n){var r={};return n.isMergeableObject(t)&&FS(t).forEach(function(i){r[i]=uu(t[i],n)}),FS(e).forEach(function(i){ZB(t,i)||($S(t,i)&&n.isMergeableObject(e[i])?r[i]=qB(i,n)(t[i],e[i],n):r[i]=uu(e[i],n))}),r}function al(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||XB,n.isMergeableObject=n.isMergeableObject||zB,n.cloneUnlessOtherwiseSpecified=uu;var r=Array.isArray(e),i=Array.isArray(t),o=r===i;return o?r?n.arrayMerge(t,e,n):QB(t,e,n):uu(e,n)}al.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,i){return al(r,i,n)},{})};var JB=al,tz=JB;const ez=cu(tz),nz=()=>({title:'{{t("Options")}}',type:"array","x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object","x-decorator":"ArrayItems.Item",properties:{space:{type:"void","x-component":"Space",properties:{label:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Option label")}}'},required:!0},value:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Option value")}}'},required:!0},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:"Add","x-component":"ArrayItems.Addition"}}}),Ty=t=>{const e={type:"boolean","x-content":'{{ t("Show time") }}',"x-decorator":"FormItem","x-component":"Checkbox"},n={type:"string",title:'{{t("Date format")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"YYYY-MM-DD",enum:[{label:'{{t("Year/Month/Day")}}',value:"YYYY/MM/DD"},{label:'{{t("Year-Month-Day")}}',value:"YYYY-MM-DD"},{label:'{{t("Day/Month/Year")}}',value:"DD/MM/YYYY"}]},r=nz();return{DatePicker:{type:"object",properties:{dateFormat:n,showTime:e}},"DatePicker.RangePicker":{type:"object",properties:{dateFormat:n,showTime:e}},Select:{type:"object",properties:{mode:{type:"string",enum:[{label:'{{ t("Single select") }}',value:""},{label:'{{ t("Multiple select") }}',value:"multiple"}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{defaultValue:""}},options:r}},"Checkbox.Group":{type:"object",properties:{options:r}},"Radio.Group":{type:"object",properties:{options:r}}}[t]},rz=(t,e)=>{if(!t)return t;if(Ve.isDayjs(t))return e.showTime||(t=t.startOf("day")),au.moment2str(t,e);if(Array.isArray(t)&&t.length&&Ve.isDayjs(t[0])){let n=t[0],r=t[1];return e.showTime&&(n=n.startOf("day"),r=r.endOf("day")),[n.toISOString(),r.toISOString()]}return t},RS=(t,e)=>Nn(this,null,function*(){const n=t.initialValue;if(!(typeof n=="string"&&(n==null?void 0:n.startsWith("{{$"))&&(n==null?void 0:n.endsWith("}}")))||!e)t.setValue(n),t.setInitialValue(n);else{t.loading=!0;const{value:i}=yield e.parseVariable(n),o=rz(i,t.componentProps);t.setValue(o),t.setInitialValue(o),t.loading=!1}}),vh="-",fu=(t,e)=>t?`${t}${vh}${e}`:e,BS=t=>{const[e,n]=t.split(vh);return n?{dataSource:e,fieldName:n}:{dataSource:z.DEFAULT_DATA_SOURCE_KEY,fieldName:e}},Ly=(t,e,n)=>dt.Schema.isSchemaInstance(t)?t.reduceProperties((r,i)=>{let o=i[e];if(o.includes(vh)||(o=`${z.DEFAULT_DATA_SOURCE_KEY}${vh}${o}`),o===n)return i;if(i["x-component"]!=="Action.Container"&&i["x-component"]!=="AssociationField.Viewer"){const a=Ly(i,e,n);if(a)return a}return r}):null,Ny=()=>{const{charts:t}=K.useContext(ol),e=K.useMemo(()=>Object.values(t).filter(i=>i).reduce((i,o)=>{var l;const{dataSource:a,collection:s}=o;return(l=i[a])!=null&&l.includes(s)||(i[a]=[...i[a]||[],s]),i},{}),[t]),n=K.useMemo(()=>Object.keys(e).length>1,[e]),r=K.useCallback((i,o)=>{var a;return((a=e[i])==null?void 0:a.includes(o))||!1},[e]);return{chartCollections:e,showDataSource:n,getIsChartCollectionExists:r}},sl=()=>{const t=z.useDataSourceManager(),{charts:e}=K.useContext(ol),{fieldSchema:n}=z.useActionContext(),r=n==null?void 0:n["x-action"],{fields:i,form:o}=K.useContext(kr),a=z.useVariables(),s=({dataSource:v,collection:g,cm:y,fim:m})=>{const b=y.getCollectionFields(g.name),x=(E,M,P,k)=>{var I,F,$,R,B;const A=((I=E.uiSchema)==null?void 0:I.title)||E.name,C=m.getFieldInterface(E.interface),T=($=(F=C==null?void 0:C.filterable)==null?void 0:F.operators)==null?void 0:$[0],N=y.getCollection(E.target);M=M?`${M} / ${A}`:A;let j={type:"string",title:M,name:`${P}.${E.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-component":"CollectionField","x-decorator":"ChartFilterFormItem","x-data-source":v,"x-collection-field":`${k}.${E.name}`,"x-component-props":ht(tt({},(R=E.uiSchema)==null?void 0:R["x-component-props"]),{"filter-operator":T})};if(E.interface==="formula"){const W=mB(E.dataType)||"Input";j=ht(tt({},j),{"x-component":W})}return["oho","o2m"].includes(E.interface)&&rn.set(j,"x-component-props.useOriginalFilter",!0),{key:`${P}.${E.name}`,name:E.name,type:"item",title:((B=E==null?void 0:E.uiSchema)==null?void 0:B.title)||E.name,Component:"CollectionFieldInitializer",find:Ly,remove:(W,q)=>{q(W,{breakRemoveOn:{"x-component":"Grid"}})},schemaInitialize:W=>{var q;(q=C==null?void 0:C.schemaInitialize)==null||q.call(C,W,{field:E,block:"FilterForm",readPretty:o.readPretty,action:r,targetCollection:N})},schema:j}},w=(E,M,P,k)=>{var j;const A=((j=E.uiSchema)==null?void 0:j.title)||E.name;M=M?`${M} / ${A}`:A;const C=E.operators[0];let T=ht(tt({type:"string",name:`${P}.${E.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-decorator":"ChartFilterFormItem","x-data-source":v,"x-collection-field":`${k}.${E.name}`},E.schema),{title:M,"x-component-props":{"filter-operator":C}});return C!=null&&C.noValue&&(T=ht(tt({},T),{"x-component":"ChartFilterCheckbox","x-component-props":ht(tt({},T["x-component-props"]),{content:dt.Schema.compile(C.label,{t:z.i18n.t})})})),{key:`${P}.${E.name}`,name:E.name,type:"item",title:E.title||E.name,Component:"CollectionFieldInitializer",find:Ly,remove:(L,I)=>{I(L,{breakRemoveOn:{"x-component":"Grid"}})},schema:T}},O=(E,M,P,k,A)=>{var I,F,$;if(!E.interface||E.isForeignKey)return;const C=m.getFieldInterface(E.interface);if(!(C!=null&&C.filterable))return;const{nested:T,children:N}=C.filterable,j=((I=E.uiSchema)==null?void 0:I.title)||E.name,L=x(E,P,k,A);if(!(E.target&&M>2)){if(P=P?`${P} / ${j}`:j,N!=null&&N.length&&!["chinaRegion","createdBy","updatedBy","attachment"].includes(E.interface)){const R=N.map(B=>w(B,P,`${k}.${E.name}`,`${A}.${E.name}`));return{key:`${k}.${E.name}`,name:E.name,type:"subMenu",title:((F=E==null?void 0:E.uiSchema)==null?void 0:F.title)||E.name,children:R}}if(!M||M>2)return L;if(T){const B=y.getCollectionFields(E.target).map(W=>O(W,M+1,"",`${k}.${E.name}`,`${A}.${E.name}`));return{key:`${k}.${E.name}`,name:E.name,type:"subMenu",title:(($=E==null?void 0:E.uiSchema)==null?void 0:$.title)||E.name,children:B.filter(Boolean)}}return L}},_=[],S=[];return b.forEach(E=>{const M=E.interface,P=O(E,0,"",fu(v,g.name),g.name);if(P&&_.push(P),["m2o"].includes(M)){const k=O(E,1,"",fu(v,g.name),g.name);k&&S.push(k)}}),S.length&&_.push({name:"divider",type:"divider"},{name:"displayAssociationFields",type:"itemGroup",title:z.i18n.t("Display association fields"),children:S}),_},l=()=>{const v=(o==null?void 0:o.values)||{},g={};return Object.entries(i).filter(([y,m])=>m).forEach(([y,m])=>{const{operator:b}=m||{},{dataSource:x,fieldName:w}=BS(y);let O=w;const E=t.getDataSource(x).collectionManager.getCollectionField(O);if(E!=null&&E.target){const C=E.targetKey||"id";O=`${O}.${C}`,y=`${y}.${C}`}const[M,...P]=O.split("."),k=yB(v,y),A=(b==null?void 0:b.value)||"$eq";if(M!=="custom"){const C=fu(x,M);g[C]=g[C]||{$and:[]};const T={};rn.set(T,P.join("."),{[A]:k}),g[C].$and.push(T)}else g[M]=g[M]||{},g[M][`$nFilter.${P.join(".")}`]=k}),g},c=(v,g)=>{if(!v)return!1;const{dataSource:y,collection:m,query:b}=v,{parameters:x}=au.parse(b.filter||"");return g[fu(y,m)]||g.custom&&(x==null?void 0:x.find(({key:w})=>rn.has(g.custom,w)))},u=(v,g)=>{const{dataSource:y,collection:m,query:b}=v;let x=tt({},b);const w=tt({},x.filter||{});let O={};const _=au.parse(w),{parameters:S}=_;return g.custom&&(S!=null&&S.find(E=>g.custom[E.key]))&&(O=_(g.custom)),O=ez(w,O),x=ht(tt({},x),{filter:{$and:[O,g[fu(y,m)]]}}),x},f=()=>Nn(this,null,function*(){const v=l(),g=Object.values(e).filter(y=>c(y,v)).map(y=>()=>Nn(this,null,function*(){const{dataSource:m,service:b,collection:x}=y;yield b.runAsync(m,x,u(y,v),!0)}));yield Promise.all(g.map(y=>y()))}),d=()=>Nn(this,null,function*(){const v=Object.values(e).filter(g=>g).map(g=>()=>Nn(this,null,function*(){const{service:y,dataSource:m,collection:b,query:x}=g;yield y.runAsync(m,b,x,!0)}));yield Promise.all(v.map(g=>g()))}),h=Mi.useMemoizedFn(v=>v.split(" / ").map(g=>z.i18n.t(dt.Schema.compile(g,{t:z.i18n.t}))).join(" / ")),p=K.useCallback(v=>Nn(this,null,function*(){const g=au.flatten(v,{breakOn({key:m}){return m.startsWith("$")&&m!=="$and"&&m!=="$or"},transformValue(m){return!(typeof m=="string"&&m.startsWith("{{$")&&(m!=null&&m.endsWith("}}")))||["$user","$date","$nDate","$nRole","$nFilter"].some(x=>m.includes(x))?m:a==null?void 0:a.parseVariable(m).then(({value:x})=>x)}});return yield Promise.all(Object.keys(g).map(m=>Nn(this,null,function*(){return g[m]=yield g[m],g[m]===void 0&&delete g[m],g[m]}))),au.unflatten(g)}),[a]);return{filter:f,refresh:d,getChartFilterFields:s,getFilter:l,hasFilter:c,appendFilter:u,getTranslatedTitle:h,parseFilter:p}},iz=()=>{const{t}=se(),e=Mi.useMemoizedFn(t),{enabled:n,fields:r}=K.useContext(kr),i=Object.entries(r).filter(([a,s])=>a.startsWith("custom.")&&s).map(([a,{title:s}])=>{const l=a.replace(/^custom\./,"");return{key:l,value:l,label:s}}),o=K.useMemo(()=>({label:e("Current filter"),value:"$nFilter",key:"$nFilter",children:i}),[i,e]);return!n||!i.length?null:o},zS=()=>{const{t}=se(),{chartCollections:e}=Ny(),n=z.useDataSourceManager(),r=n.collectionFieldInterfaceManager,{values:i}=YS(),o=(a,s,l)=>{var d,h,p;if(!s.interface)return;const c=r.getFieldInterface(s.interface);if(!(c!=null&&c.filterable))return;const{nested:u}=c.filterable,f={value:s.name,label:t(((d=s==null?void 0:s.uiSchema)==null?void 0:d.title)||s.name)};if(!(s.target&&l>2)){if(l>2)return f;if(u){const g=a.getCollectionFields(s.target).map(y=>o(a,y,l+1));return{value:s.name,label:t(((h=s==null?void 0:s.uiSchema)==null?void 0:h.title)||s.name),children:g.filter(y=>y)}}if(!(!i.includes((p=s.uiSchema)==null?void 0:p["x-component"])&&!i.includes(s.interface)))return f}};return K.useMemo(()=>Object.entries(e).map(([s,l])=>{const c=n.getDataSource(s);return{value:s,label:dt.Schema.compile(c.displayName,{t}),children:l.map(u=>{const f=c.collectionManager,d=f.getCollection(u),p=f.getCollectionFields(u).map(v=>o(f,v,1)).filter(v=>v);return{value:u,label:dt.Schema.compile(d.title,{t}),children:p}})}}),[e])},YS=()=>{const{t}=se(),e=[{label:t("Input"),value:"Input"},{label:t("Number"),value:"InputNumber"},{label:t("Date"),value:"DatePicker"},{label:t("Date range"),value:"DatePicker.RangePicker"},{label:t("Time"),value:"TimePicker"},{label:t("Time range"),value:"TimePicker.RangePicker"},{label:t("Select"),value:"Select"},{label:t("Radio group"),value:"Radio.Group"},{label:t("Checkbox group"),value:"Checkbox.Group"}];return{options:e,values:e.map(n=>n.value)}},oz=(t,e)=>{const{t:n}=se(),r=z.useDataSourceManager(),{showDataSource:i}=Ny();return K.useMemo(()=>{var p;const o=r.getDataSource(t);if(!o)return;const a=o.collectionManager;if(!e)return;const{fieldName:s}=BS(e),[l,...c]=s.split(".");if(!(c!=null&&c.length))return;const u=a.getCollection(l);let f=l,d,h=dt.Schema.compile(u==null?void 0:u.title,{t:n});for(;f&&c.length>0;){const v=c.shift();d=a.getCollectionField(`${f}.${v}`);const g=((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||(d==null?void 0:d.name);g&&(h+=` / ${dt.Schema.compile(g,{t:n})}`),d!=null&&d.target?f=d.target:f=null}return i?`${dt.Schema.compile(o.displayName,{t:n})} > ${h}`:h},[e,t,i])},WS=(t,e)=>{const{currentUserSettings:n}=z.useCurrentUserVariable({collectionField:{uiSchema:t},uiSchema:t}),{currentRoleSettings:r}=z.useCurrentRoleVariable({uiSchema:t}),{apiTokenSettings:i}=z.useAPITokenVariable({noDisabled:!0}),{datetimeSettings:o}=z.useDatetimeVariable({operator:e,schema:t,noDisabled:!0}),{urlSearchParamsSettings:a}=z.useURLSearchParamsVariable(),s=K.useMemo(()=>[n,r,i,o,a].filter(Boolean),[o,n,r,a,i]);return t?s:[]},az=()=>{const t=dt.useField(),{operator:e,schema:n}=t.data||{},r=iz(),i=WS(n,e),o=K.useMemo(()=>[...i,r].filter(Boolean),[i,r]);return!e||!n?[]:o},Iy=(t={},e={})=>ht(tt({type:"array","x-decorator":"FormItem","x-component":"ArrayItems"},e),{items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:ht(tt({sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"}},t),{remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}})}}},properties:{add:{type:"void",title:'{{t("Add field")}}',"x-component":"ArrayItems.Addition"}}}),sz=t=>({type:"void",properties:{config:{type:"object",properties:{collapse:{type:"void","x-component":"FormCollapse","x-component-props":{formCollapse:"{{formCollapse}}",size:"small",style:{border:"none",boxShadow:"none"}},properties:{pane1:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Container"),key:"card"},properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},bordered:{type:"boolean","x-content":St("Show border"),"x-decorator":"FormItem","x-component":"Checkbox",default:!1}}},pane2:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Chart"),key:"basic",style:{border:"none"}},properties:{chartType:{type:"string",title:'{{t("Chart type")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Please select a chart type.")}}'},enum:"{{ chartTypes }}"},[Bo.uid()]:{type:"void",properties:{general:t}},[Bo.uid()]:{type:"void",properties:{advanced:{type:"json",title:'{{t("JSON config")}}',"x-decorator":"FormItem","x-decorator-props":{extra:St("Same properties set in the form above will be overwritten by this JSON config.")},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:3},json5:!0}}}},reference:{type:"string","x-reactions":{dependencies:[".chartType"],fulfill:{schema:{"x-content":"{{ getReference($deps[0]) }}"}}}}}}}}}}}}),lz={type:"void",properties:{settings:{type:"void",properties:{collection:{title:'{{t("Collection")}}',type:"string","x-decorator":"FormItem","x-component":"Cascader",enum:"{{ collectionOptions }}","x-component-props":{onChange:"{{ onCollectionChange }}",placeholder:'{{t("Collection")}}'}}}},query:{type:"object",properties:{builder:{type:"void",properties:{collapse:{type:"void","x-decorator":"FormItem","x-component":"FormCollapse","x-component-props":{formCollapse:"{{formCollapse}}",size:"small",style:{border:"none",boxShadow:"none"}},properties:{pane1:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Measures"),key:"measures"},properties:{measures:Iy({field:{type:"string","x-decorator":"FormItem","x-component":"Cascader","x-component-props":{placeholder:'{{t("Field")}}',fieldNames:{label:"title",value:"name",children:"children"}},enum:"{{ fieldOptions }}",required:!0},aggregation:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Aggregation")}}'},enum:[{label:'{{t("Sum")}}',value:"sum"},{label:'{{t("Count")}}',value:"count"},{label:'{{t("Avg")}}',value:"avg"},{label:'{{t("Max")}}',value:"max"},{label:'{{t("Min")}}',value:"min"}]},alias:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Alias")}}',style:{minWidth:"100px"}}},distinct:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Distinct")}}'}},{required:!0,"x-component-props":{style:{overflow:"auto"}}})}},pane2:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Dimensions"),key:"dimensions"},properties:{dimensions:Iy({field:{type:"string","x-decorator":"FormItem","x-component":"Cascader","x-component-props":{placeholder:'{{t("Field")}}',fieldNames:{label:"title",value:"name",children:"children"}},enum:"{{ fieldOptions }}",required:!0},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Format")}}',style:{maxWidth:"120px"}},"x-reactions":"{{ useFormatterOptions }}","x-visible":"{{ $self.dataSource && $self.dataSource.length }}"},alias:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Alias")}}',style:{minWidth:"100px"}}}},{"x-component-props":{style:{overflow:"auto"}}})}},pane3:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Filter"),key:"filter"},properties:{filter:{type:"object","x-decorator":"FormItem","x-decorator-props":{style:{overflow:"auto"}},enum:"{{ filterOptions }}","x-component":"Filter","x-component-props":{dynamicComponent:"FilterDynamicComponent"}}}},pane4:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Sort"),key:"sort",style:{border:"none"}},properties:{orders:Iy({field:{type:"string","x-decorator":"FormItem","x-component":"Cascader","x-component-props":{placeholder:'{{t("Field")}}'},"x-reactions":"{{ useOrderOptions }}",required:!0},order:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{defaultValue:"ASC",optionType:"button",style:{width:"128px"}},enum:["ASC","DESC"]}},{"x-reactions":"{{ useOrderReaction }}","x-component-props":{style:{overflow:"auto"}}})}}}},limit:{title:'{{t("Limit")}}',type:"number","x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{defaultValue:2e3,min:1,style:{width:"100px"}}}}},cache:{type:"object",properties:{enabled:{type:"boolean",title:'{{t("Enable cache")}}',"x-decorator":"FormItem","x-component":"Switch"},ttl:{type:"number",title:'{{t("TTL (second)")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{defaultValue:60,min:1,style:{width:"100px"}}}}}}}}},cz={type:"void",properties:{transform:{type:"array","x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{wrap:!0},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Field")}}'},"x-use-component-props":"useFieldSelectProps","x-reactions":"{{ useChartFields }}"},type:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Type")}}'},"x-use-component-props":"useFieldTypeSelectProps"},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Transformer")}}',style:{maxWidth:"200px"}},"x-use-component-props":"useTransformerSelectProps","x-reactions":"{{ useTransformers }}","x-visible":"{{ $self.dataSource && $self.dataSource.length }}"},argument:{type:"string","x-decorator":"FormItem","x-component":"TransformerDynamicComponent","x-reactions":"{{ useArgument }}"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add transformation")}}',"x-component":"ArrayItems.Addition"}}}}};function uz(t){const{value:e,onChange:n,renderSchemaComponent:r}=t,i=az();return Y.jsx(z.Variable.Input,{value:e,onChange:n,scope:i,children:r()})}const Pi=K.createContext({visible:!0});Pi.displayName="ChartConfigContext";const fz=t=>{var a;const{insertAdjacent:e}=z.useDesignable(),[n,r]=K.useState(!1),[i,o]=K.useState({});return Y.jsxs(Pi.Provider,{value:{visible:n,setVisible:r,current:i,setCurrent:o},children:[t.children,Y.jsx(LS,ht(tt({},(a=i.field)==null?void 0:a.decoratorProps),{children:Y.jsx(oi,{insert:(s,l)=>e("beforeEnd",s,l)})}))]})},dz=t=>{const{schema:e}=t,n=dt.useField();return e?Y.jsx(z.SchemaComponent,{schema:{type:"void",properties:{[e.name]:ht(tt({type:"void"},e),{value:n.value,"x-component-props":ht(tt({},e["x-component-props"]),{defaultValue:n.value,onChange:r=>{if(typeof r=="object"&&(r!=null&&r.target)){n.value=r.target.value;return}n.value=r}})})}}}):null},{Paragraph:ISt,Text:hz}=Ot.Typography,oi=t=>{const{t:e}=se(),{service:n}=K.useContext(ii),{visible:r,setVisible:i,current:o}=K.useContext(Pi),{schema:a,field:s,dataSource:l,collection:c,initialValues:u}=o||{},{dn:f}=z.useDesignable(),{modal:d}=Ot.App.useApp(),{insert:h}=t,p=IS(),v=Ua(l,c),g=(P=!1)=>{var I;if(!_.modified)return;const k=(I=_.values.config)==null?void 0:I.chartType;if(!k)return;const A=p[k];if(!(A==null?void 0:A.init)){P&&(_.values.config.general={},_.values.config.advanced={});return}const T=_.values.query,N=il(v,T),{general:j,advanced:L}=A.init(N,T);(j||P)&&(_.values.config.general=j),(L||P)&&(_.values.config.advanced=L||{})},[y,m]=K.useState([]),[b,x]=K.useState([]),w=(P,k)=>{var T,N;const A=((T=P.values.query)==null?void 0:T.measures.filter(j=>j.field))||[],C=((N=P.values.query)==null?void 0:N.dimensions.filter(j=>j.field))||[];rn.isEqual(A,y)&&rn.isEqual(C,b)||(k==null||k(),m(rn.cloneDeep(A)),x(rn.cloneDeep(C)))},O=_B(),_=K.useMemo(()=>{var A;const P=u||(a==null?void 0:a["x-decorator-props"]),k=(P==null?void 0:P.config)||{};return wn.createForm({values:ht(tt({},P),{config:ht(tt({chartType:O},k),{title:k.title||((A=s==null?void 0:s.componentProps)==null?void 0:A.title)}),collection:[l,c]}),effects:C=>{wn.onFieldChange("config.chartType",()=>g(!0)),wn.onFormInit(()=>w(C))}})},[s,r,l,c]),S=()=>Y.jsx(Ot.Button,{type:"link",loading:n==null?void 0:n.loading,icon:Y.jsx(In.RightSquareOutlined,{}),onClick:()=>Nn(this,null,function*(){const P=_.query("query").take();try{yield P==null?void 0:P.validate()}catch(k){return}try{yield n.runAsync(l,c,_.values.query,!0)}catch(k){console.log(k)}w(_,g)}),children:e("Run query")}),E=K.useRef(null),M=K.useRef(null);return K.useEffect(()=>{var P;r&&n.run(c,(P=s==null?void 0:s.decoratorProps)==null?void 0:P.query,"configure")},[r]),Y.jsx(Ot.Modal,{title:e("Configure chart"),open:r,onOk:()=>{const{query:P,config:k,transform:A,mode:C}=_.values,{title:T,bordered:N}=k||{},j=()=>{var I;i(!1),(I=o.service)==null||I.run(l,c,P),E.current.scrollTop=0,M.current.scrollTop=0,n.mutate(void 0)},L={query:P,config:k,dataSource:l,collection:c,transform:A,mode:C||"builder"};if(a&&a["x-uid"]){a["x-component-props"]=ht(tt({},a["x-component-props"]),{title:T,bordered:N}),a["x-decorator-props"]=L,s.decoratorProps=L,s.componentProps=ht(tt({},s.componentProps),{title:T,bordered:N}),s["x-acl-action"]=`${c}:list`,f.emit("patch",{schema:a}),j();return}h(z.gridRowColWrap(TS(L)),{onSuccess:j})},onCancel:()=>{d.confirm({title:e("Are you sure to cancel?"),content:e("You changes are not saved. If you click OK, your changes will be lost."),okButtonProps:{danger:!0},onOk:()=>{i(!1),E.current.scrollTop=0,M.current.scrollTop=0,n.mutate(void 0)}})},width:"95%",className:zo.css`
|
|
10
|
+
(function(ct,z){typeof exports=="object"&&typeof module!="undefined"?z(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/react"),require("antd"),require("lodash"),require("react-i18next"),require("dayjs"),require("@formily/shared"),require("@nocobase/utils/client"),require("ahooks"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","@ant-design/icons","@formily/antd-v5","@formily/core","@formily/react","antd","lodash","react-i18next","dayjs","@formily/shared","@nocobase/utils/client","ahooks","@emotion/css"],z):(ct=typeof globalThis!="undefined"?globalThis:ct||self,z(ct["@nocobase/plugin-data-visualization"]={},ct["@nocobase/client"],ct.jsxRuntime,ct.react,ct["@ant-design/icons"],ct["@formily/antd-v5"],ct["@formily/core"],ct["@formily/react"],ct.antd,ct.lodash,ct["react-i18next"],ct.dayjs,ct["@formily/shared"],ct["@nocobase/utils"],ct.ahooks,ct["@emotion/css"]))})(this,function(ct,z,Y,K,In,ae,wn,dt,Ot,rn,My,Ve,Bo,au,Mi,zo){"use strict";var kSt=Object.defineProperty,TSt=Object.defineProperties;var LSt=Object.getOwnPropertyDescriptors;var Ey=Object.getOwnPropertySymbols;var X9=Object.prototype.hasOwnProperty,q9=Object.prototype.propertyIsEnumerable;var MS=(ct,z)=>(z=Symbol[ct])?z:Symbol.for("Symbol."+ct),Ce=Math.pow,PS=(ct,z,Y)=>z in ct?kSt(ct,z,{enumerable:!0,configurable:!0,writable:!0,value:Y}):ct[z]=Y,tt=(ct,z)=>{for(var Y in z||(z={}))X9.call(z,Y)&&PS(ct,Y,z[Y]);if(Ey)for(var Y of Ey(z))q9.call(z,Y)&&PS(ct,Y,z[Y]);return ct},ht=(ct,z)=>TSt(ct,LSt(z));var AS=(ct,z)=>{var Y={};for(var K in ct)X9.call(ct,K)&&z.indexOf(K)<0&&(Y[K]=ct[K]);if(ct!=null&&Ey)for(var K of Ey(ct))z.indexOf(K)<0&&q9.call(ct,K)&&(Y[K]=ct[K]);return Y};var ri=(ct,z,Y)=>(PS(ct,typeof z!="symbol"?z+"":z,Y),Y);var Nn=(ct,z,Y)=>new Promise((K,In)=>{var ae=Ot=>{try{dt(Y.next(Ot))}catch(rn){In(rn)}},wn=Ot=>{try{dt(Y.throw(Ot))}catch(rn){In(rn)}},dt=Ot=>Ot.done?K(Ot.value):Promise.resolve(Ot.value).then(ae,wn);dt((Y=Y.apply(ct,z)).next())}),NSt=function(ct,z){this[0]=ct,this[1]=z};var K9=ct=>{var z=ct[MS("asyncIterator")],Y=!1,K,In={};return z==null?(z=ct[MS("iterator")](),K=ae=>In[ae]=wn=>z[ae](wn)):(z=z.call(ct),K=ae=>In[ae]=wn=>{if(Y){if(Y=!1,ae==="throw")throw wn;return wn}return Y=!0,{done:!1,value:new NSt(new Promise(dt=>{var Ot=z[ae](wn);if(!(Ot instanceof Object))throw TypeError("Object expected");dt(Ot)}),1)}}),In[MS("iterator")]=()=>In,K("next"),"throw"in z?K("throw"):In.throw=ae=>{throw ae},"return"in z&&K("return"),In};function hB(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}const CS="data-visualization";function St(t){return z.i18n.t(t,{ns:[CS,"client"]})}function se(){return My.useTranslation([CS,"client"],{nsMode:"fallback"})}const Py={datetime:[{label:St("YYYY"),value:"YYYY"},{label:St("MM"),value:"MM"},{label:St("DD"),value:"DD"},{label:St("YYYY-MM"),value:"YYYY-MM"},{label:St("YYYY-MM-DD"),value:"YYYY-MM-DD"},{label:St("YYYY-MM-DD hh:mm"),value:"YYYY-MM-DD hh:mm"},{label:St("YYYY-MM-DD hh:mm:ss"),value:"YYYY-MM-DD hh:mm:ss"}],date:[{label:St("YYYY"),value:"YYYY"},{label:St("MM"),value:"MM"},{label:St("DD"),value:"DD"},{label:St("YYYY-MM"),value:"YYYY-MM"},{label:St("YYYY-MM-DD"),value:"YYYY-MM-DD"}],time:[{label:St("hh:mm:ss"),value:"hh:mm:ss"},{label:St("hh:mm"),value:"hh:mm"},{label:St("hh"),value:"hh"}]},pB=K.createContext(null),Ay={didCatch:!1,error:null};let kS=class extends K.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Ay}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var n,r,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(Ay)}}componentDidCatch(e,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,e,n)}componentDidUpdate(e,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&vB(e.resetKeys,i)){var o,a;(o=(a=this.props).onReset)===null||o===void 0||o.call(a,{next:i,prev:e.resetKeys,reason:"keys"}),this.setState(Ay)}}render(){const{children:e,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:o,error:a}=this.state;let s=e;if(o){const l={error:a,resetErrorBoundary:this.resetErrorBoundary};if(K.isValidElement(i))s=i;else if(typeof n=="function")s=n(l);else if(r)s=K.createElement(r,l);else throw a}return K.createElement(pB.Provider,{value:{didCatch:o,error:a,resetErrorBoundary:this.resetErrorBoundary}},s)}};function vB(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return t.length!==e.length||t.some((n,r)=>!Object.is(n,e[r]))}const TS=(t,e={})=>{const{collection:n,config:r}=t,{title:i,bordered:o}=r||{};return{type:"void","x-decorator":"ChartRendererProvider","x-decorator-props":t,"x-acl-action":`${n}:list`,"x-designer":"ChartRenderer.Designer","x-component":"CardItem","x-component-props":{size:"small",title:i,bordered:o},"x-initializer":"charts:addBlock",properties:{[Bo.uid()]:{type:"void","x-component":"ChartRenderer","x-component-props":e}}}},su=t=>{let e,n;return Array.isArray(t)?t.length===1?n=t[0]:t.length>1&&([e,n]=t):n=t,{target:e,name:n,alias:e?`${e}.${n}`:n}},ph=(t,e)=>{var o,a;const{target:n,name:r}=su(e);return n?(a=(o=t.find(s=>s.name===n))==null?void 0:o.targetFields)==null?void 0:a.find(s=>s.name===r):t.find(s=>s.name===r)},il=(t,e)=>{const n=s=>s.map(l=>{const c=ph(t,l.field);return ht(tt({},c),{key:l.alias||(c==null?void 0:c.key),label:l.alias||(c==null?void 0:c.label),value:l.alias||(c==null?void 0:c.value),query:l})}),r=e.measures||[],i=e.dimensions||[];return[...new Map([...n(r),...n(i)].map(s=>[s.value,s])).values()]},gB=(t,e,n)=>{const r=(i,o)=>{var l;const a=(l=i.uiSchema)==null?void 0:l.enum;if(!a||!Array.isArray(a))return o;if(Array.isArray(o))return o.map(c=>r(i,c));const s=a.find(c=>{var u;return c.value===(((u=o==null?void 0:o.toString)==null?void 0:u.call(o))||o)});return dt.Schema.compile((s==null?void 0:s.label)||o,n)};return e.map(i=>{const o={};return Object.entries(i).forEach(([a,s])=>{const l=t.find(c=>{var u;return c.value===a&&!((u=c==null?void 0:c.query)!=null&&u.aggregation)});if(!l){o[a]=s;return}switch(l.interface){case"select":case"radioGroup":case"multipleSelect":o[a]=r(l,s);break;default:o[a]=s}}),o})},Cy=t=>{if(typeof t=="object"&&t!==null)if(Array.isArray(t)){const e=t.map(n=>Cy(n)).filter(Boolean);return e.length>0?e:null}else{const e={};for(const n in t){const r=Cy(t[n]);r!=null&&!(typeof r=="object"&&Object.keys(r).length===0)&&(e[n]=r)}return Object.keys(e).length>0?e:null}else if(typeof t=="string"&&t.startsWith("{{$nFilter.")&&t.endsWith("}}"))return null;return t},yB=(t,e)=>{const n=e.split(".");let r=rn.get(t,n.slice(0,-1).join("."));return Array.isArray(r)?r=r.map(i=>rn.get(i,n.slice(-1)[0])):r=rn.get(r,n.slice(-1)[0]),r},mB=t=>({boolean:"Checkbox",integer:"InputNumber",bigInt:"InputNumber",double:"InputNumber",decimal:"InputNumber",date:"DatePicker",string:"Input"})[t],bB=t=>({boolean:"boolean",integer:"integer",bigInt:"integer",double:"number",decimal:"number",date:"datetime",string:"input"})[t],ol=K.createContext({});ol.displayName="ChartDataContext";const xB=t=>{const[e,n]=K.useState({}),r=Mi.useMemoizedFn((o,{dataSource:a,collection:s,service:l,query:c})=>{n(u=>ht(tt({},u),{[o]:{dataSource:a,collection:s,service:l,query:c}}))}),i=Mi.useMemoizedFn(o=>{n(a=>ht(tt({},a),{[o]:void 0}))});return Y.jsx(ol.Provider,{value:{charts:e,addChart:r,removeChart:i},children:t.children})},kr=K.createContext({});kr.displayName="ChartFilterContext";const wB=t=>{const[e,n]=K.useState(!1),[r,i]=K.useState(!1),[o,a]=K.useState({}),[s,l]=K.useState({collapsed:!1,row:1}),[c,u]=K.useState(),f=Mi.useMemoizedFn((g,y)=>{a(m=>ht(tt({},m),{[g]:tt(tt({},m[g]||{}),y)}))}),d=Mi.useMemoizedFn(g=>{a(y=>{const m=tt({},y);return m[g]=void 0,m})}),h=Mi.useMemoizedFn(u),p=Mi.useMemoizedFn(i),v=({collapsed:g,row:y})=>{l(m=>({collapsed:g!==void 0?g:m.collapsed,row:y!==void 0?y:m.row}))};return K.useEffect(()=>n(!0),[]),Y.jsx(kr.Provider,{value:{ready:e,enabled:r,setEnabled:p,fields:o,setField:f,removeField:d,collapse:s,setCollapse:v,form:c,setForm:h},children:t.children})},ii=K.createContext({});ii.displayName="ChartRendererContext";const LS=t=>{const{query:e,config:n,collection:r,transform:i,dataSource:o=z.DEFAULT_DATA_SOURCE_KEY}=t,{addChart:a}=K.useContext(ol),{ready:s,form:l,enabled:c}=K.useContext(kr),{getFilter:u,hasFilter:f,appendFilter:d,parseFilter:h}=sl(),p=dt.useFieldSchema(),v=z.useAPIClient(),g=z.useRequest((y,m,b,x)=>Nn(this,null,function*(){var M,P;if(!(m&&((M=b==null?void 0:b.measures)!=null&&M.length))||c&&!l)return;const w=u(),O=yield h(b.filter),_=ht(tt({},b),{filter:O}),S={dataSource:y,collection:m,query:_},E=!x&&f(S,w)?d(S,w):_;try{const k=yield v.request({url:"charts:query",method:"POST",data:ht(tt({uid:p==null?void 0:p["x-uid"],dataSource:y,collection:m},E),{filter:Cy(E.filter),dimensions:((b==null?void 0:b.dimensions)||[]).map(A=>{const C=tt({},A);if(A.format&&!A.alias){const{alias:T}=su(A.field);C.alias=T}return C}),measures:((b==null?void 0:b.measures)||[]).map(A=>{const C=tt({},A);if(A.aggregation&&!A.alias){const{alias:T}=su(A.field);C.alias=T}return C})})});return(P=k==null?void 0:k.data)==null?void 0:P.data}catch(k){throw console.error(k),k}finally{!x&&(p!=null&&p["x-uid"])&&a(p==null?void 0:p["x-uid"],{dataSource:y,collection:m,service:g,query:b})}}),{defaultParams:[o,r,e],ready:s&&(!c||!!l)});return Y.jsx(z.CollectionManagerProvider,{dataSource:o,children:Y.jsx(z.MaybeCollectionProvider,{collection:r,children:Y.jsx(ii.Provider,{value:{dataSource:o,collection:r,config:n,transform:i,service:g,query:e},children:t.children})})})};class OB{constructor(){ri(this,"charts",new Map)}setGroup(e,n){this.charts.set(e,n)}addGroup(e,n){if(this.charts.has(e))throw new Error(`[data-visualization] Chart group "${e}" already exists`);this.setGroup(e,n)}add(e,n){var r;this.charts.has(e)||this.setGroup(e,[]),(r=this.charts.get(e))==null||r.push(n)}getChartTypes(){const e=[];this.charts.forEach((r,i)=>{const o=r.map(a=>({key:`${i}.${a.name}`,label:St(a.title),value:`${i}.${a.name}`}));e.push({label:St(i),children:o})});const n=e.findIndex(r=>r.label===St("Built-in"));if(n>-1){const[r]=e.splice(n,1);e.unshift(r)}return e}getCharts(){const e={};return this.charts.forEach((n,r)=>{n.forEach(i=>{e[`${r}.${i.name}`]=i})}),e}getChart(e){return this.getCharts()[e]}}const NS=()=>z.usePlugin(Sy).charts.getChartTypes(),_B=()=>{var e,n,r;return(r=(n=(e=NS()[0])==null?void 0:e.children)==null?void 0:n[0])==null?void 0:r.value},IS=()=>z.usePlugin(Sy).charts.getCharts(),SB=t=>z.usePlugin(Sy).charts.getChart(t),{Paragraph:EB,Text:MB}=Ot.Typography,ky=t=>{const{t:e}=se(),n=K.useContext(ii),{config:r,transform:i,dataSource:o,collection:a,service:s,data:l}=n,c=Ua(o,a),u=DS(l,o,a),f=(r==null?void 0:r.general)||{},d=(r==null?void 0:r.advanced)||{},h=z.useAPIClient(),p=SB(r==null?void 0:r.chartType),v=h.auth.getLocale(),g=BB(i,v),y=p==null?void 0:p.getProps({data:u,general:f,advanced:d,fieldProps:Object.keys(u[0]||{}).reduce((x,w)=>{if(!x[w]){const O=ph(c,w.split(".")),_=g[w];x[w]={label:(O==null?void 0:O.label)||w,transformer:_,interface:O==null?void 0:O.interface}}return x},{})}),m=dt.Schema.compile(y),b=p==null?void 0:p.Component;return p?!(u&&u.length)&&!s.loading?Y.jsx(Ot.Empty,{image:Ot.Empty.PRESENTED_IMAGE_SIMPLE,description:e("No data")}):Y.jsx(Ot.Spin,{spinning:s.loading,children:Y.jsx(kS,{onError:x=>{console.error(x)},FallbackComponent:PB,children:Y.jsx(b,tt({},m))})}):Y.jsx(Ot.Empty,{image:Ot.Empty.PRESENTED_IMAGE_SIMPLE,description:e("Please configure chart")})};ky.Designer=function(){const{t:e}=se(),{setVisible:n,setCurrent:r}=K.useContext(Pi),{removeChart:i}=K.useContext(ol),{service:o}=K.useContext(ii),a=dt.useField(),s=dt.useFieldSchema(),{insertAdjacent:l}=z.useDesignable(),c=z.useDataSource(),{name:u,title:f}=z.useCollection_deprecated();return Y.jsxs(z.GeneralSchemaDesigner,{disableInitializer:!0,title:f||u,children:[Y.jsx(z.SchemaSettingsItem,{title:"Configure",onClick:()=>Nn(this,null,function*(){r({schema:s,field:a,dataSource:c.key,collection:u,service:o,data:o.data}),n(!0)}),children:e("Configure")},"configure"),Y.jsx(z.SchemaSettingsItem,{title:"Duplicate",onClick:()=>l("afterEnd",z.gridRowColWrap(TS(s==null?void 0:s["x-decorator-props"]))),children:e("Duplicate")},"duplicate"),Y.jsx(z.SchemaSettingsDivider,{}),Y.jsx(z.SchemaSettingsRemove,{breakRemoveOn:{"x-component":"ChartV2Block"},confirm:{onOk:()=>{i(s["x-uid"])}}})]})};const PB=({error:t})=>{const{t:e}=se();return Y.jsx("div",{style:{backgroundColor:"white"},children:Y.jsx(Ot.Result,{status:"error",title:e("Render Failed"),subTitle:e("Please check the configuration."),children:Y.jsx(EB,{copyable:!0,children:Y.jsx(MB,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:t.message})})})})},lu=t=>{const{current:e}=K.useContext(Pi),{dataSource:n=t||z.DEFAULT_DATA_SOURCE_KEY,collection:r}=e||{},i=z.useDataSourceManager(),o=i.getDataSource(n),a=i.collectionFieldInterfaceManager;return{cm:o==null?void 0:o.collectionManager,fim:a,collection:r}},AB=t=>(t||[]).filter(n=>n.interface).map(n=>{var r;return ht(tt({},n),{key:n.name,label:((r=n.uiSchema)==null?void 0:r.title)||n.name,value:n.name})}),Ua=(t,e)=>{const{t:n}=My.useTranslation(),{cm:r,fim:i,collection:o}=lu(t),a=r.getCollectionFields(e||o),s=AB(a);return K.useMemo(()=>s.map(l=>{var d,h,p,v;const c=(d=i.getFieldInterface(l.interface))==null?void 0:d.filterable,u=dt.Schema.compile(((h=l.uiSchema)==null?void 0:h.title)||l.name,{t:n});if(!(c&&(c!=null&&c.nested||(p=c==null?void 0:c.children)!=null&&p.length)))return ht(tt({},l),{label:u});let f=[];if(c!=null&&c.nested){const g=(r.getCollectionFields(l.target)||[]).filter(y=>y.interface).map(y=>{var m;return ht(tt({},y),{key:`${l.name}.${y.name}`,label:`${u} / ${dt.Schema.compile(((m=y.uiSchema)==null?void 0:m.title)||y.name,{t:n})}`,value:`${l.name}.${y.name}`})});f=[...f,...g]}if((v=c==null?void 0:c.children)!=null&&v.length){const g=c.children.map(y=>{var m;return ht(tt({},y),{key:`${l.name}.${y.name}`,label:`${u} / ${dt.Schema.compile(((m=y.schema)==null?void 0:m.title)||y.title||y.name,{t:n})}`,value:`${l.name}.${y.name}`})});f=[...f,...g]}return ht(tt({},l),{label:u,targetFields:f})}),[s])},jS=t=>e=>{const n=e.query("query").get("value")||{},r=il(t,n);e.dataSource=r},CB=t=>e=>{var o;const n=e.query(".field").get("value");if(!n){e.dataSource=[];return}let r=[];switch((o=ph(t,n))==null?void 0:o.interface){case"datetime":case"createdAt":case"updatedAt":r=Py.datetime;break;case"date":r=Py.date;break;case"time":r=Py.time;break;default:r=[]}e.dataSource=r},kB=()=>{const{t}=My.useTranslation(),e=z.useDataSourceManager(),{parseAction:n}=z.useACLRoleContext(),i=e.getAllCollections({filterCollection:o=>n(`${o.name}:list`)}).filter(({key:o,isDBInstance:a})=>o===z.DEFAULT_DATA_SOURCE_KEY||a).map(({key:o,displayName:a,collections:s})=>({value:o,label:a,children:s.map(l=>({value:l.name,label:l.title}))}));return K.useMemo(()=>dt.Schema.compile(i,{t}),[i])},TB=(t,e)=>n=>{const r=n.query("query").get("value")||{},{measures:i=[]}=r;if(!i.some(s=>s.aggregation)){n.componentProps.fieldNames={label:"title",value:"name",children:"children"},n.dataSource=t;return}const a=il(e,r);n.componentProps.fieldNames={},n.dataSource=a},LB=(t,e)=>n=>{const r=n.query("query").get("value")||{},{measures:i=[]}=r,o=i.some(u=>u.aggregation);let a=t;const s=[];o?(a=il(e,r),a.forEach(u=>{s.push(u.value)})):a.forEach(u=>{const f=u.children||[];f.length||s.push(u.value||u.name),f.forEach(d=>{s.push(`${u.name}.${d.name}`)})});const c=(n.value||[]).reduce((u,f)=>{const{alias:d}=su(f.field);return(!f.field||s.includes(d))&&u.push(f),u},[]);n.setValue(c)},DS=(t,e,n)=>{var c;const{t:r}=se(),{service:i,query:o}=K.useContext(ii),a=Ua(e,n),s=dt.useForm(),l=il(a,((c=s==null?void 0:s.values)==null?void 0:c.query)||o);return gB(l,(i==null?void 0:i.data)||t||[],{t:r})},NB=(t,e,n=2,r=[])=>{const{cm:i,fim:o,collection:a}=lu(t),l=i.getCollectionFields(e||a).filter(d=>!r.includes(d.interface)),c=(d,h,p)=>{var x;if(!d.interface||d.isForeignKey)return;const v=o.getFieldInterface(d.interface);if(!(v!=null&&v.filterable))return;const{nested:g,children:y}=v.filterable,m=p?`${p}.${d.name}`:d.name,b=ht(tt({},d),{name:d.name,title:((x=d==null?void 0:d.uiSchema)==null?void 0:x.title)||d.name,schema:d==null?void 0:d.uiSchema,key:m});if(!(d.target&&h>n)){if(h>n)return b;if(y!=null&&y.length&&(b.children=y.map(w=>ht(tt({},w),{key:`${d.name}.${w.name}`}))),g){const w=i.getCollectionFields(d.target).filter(_=>!r.includes(_.interface)),O=u(w,h+1,d.name).filter(Boolean);b.children=b.children||[],b.children.push(...O)}return b}},u=(d,h,p)=>{const v=[];return d.forEach(g=>{const y=c(g,h,p);y&&v.push(y)}),v};return u(l,1)},IB=(t,e)=>{const{cm:n,fim:r,collection:i}=lu(t);return K.useMemo(()=>{const o=n.getCollectionFields(e||i),a=(c,u)=>{var g,y;if(!c.interface||c.isForeignKey)return;const f=r.getFieldInterface(c.interface);if(!(f!=null&&f.filterable))return;const{nested:d,children:h,operators:p}=f.filterable,v={name:c.name,title:((g=c==null?void 0:c.uiSchema)==null?void 0:g.title)||c.name,schema:c==null?void 0:c.uiSchema,operators:((y=p==null?void 0:p.filter)==null?void 0:y.call(p,m=>!(m!=null&&m.visible)||m.visible(c)))||[],interface:c.interface};if(!(c.target&&u>2)){if(u>2)return v;if(h!=null&&h.length&&(v.children=h),d){const m=n.getCollectionFields(c.target),b=s(m,u+1).filter(Boolean);v.children=v.children||[],v.children.push(...b)}return v}},s=(c,u)=>{const f=[];return c.forEach(d=>{const h=a(d,u);h&&f.push(h)}),f};return s(o,1)},[e,n,r])},Yo={general:{Prefix:{schema:{"x-component":"Input"},fn:(t,e)=>e?`${e}${t}`:t},Suffix:{schema:{"x-component":"Input"},fn:(t,e)=>e?`${t}${e}`:t}},datetime:{Format:{schema:{"x-component":"AutoComplete","x-component-props":{allowClear:!0,style:{minWidth:200}},enum:[{label:"YYYY",value:"YYYY"},{label:"YYYY-MM",value:"YYYY-MM"},{label:"YYYY-MM-DD",value:"YYYY-MM-DD"},{label:"YYYY-MM-DD hh:mm",value:"YYYY-MM-DD hh:mm"},{label:"YYYY-MM-DD hh:mm:ss",value:"YYYY-MM-DD hh:mm:ss"}]},fn:(t,e)=>Ve(t).format(e)},YYYY:{label:"YYYY (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY")},MM:{label:"MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("MM")},DD:{label:"DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("DD")},"YYYY-MM":{label:"YYYY-MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM")},"YYYY-MM-DD":{label:"YYYY-MM-DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD")},"YYYY-MM-DD hh:mm":{label:"YYYY-MM-DD hh:mm (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD hh:mm")},"YYYY-MM-DD hh:mm:ss":{label:"YYYY-MM-DD hh:mm:ss (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD hh:mm:ss")}},date:{Format:{schema:{"x-component":"AutoComplete","x-component-props":{allowClear:!0,style:{minWidth:200}},enum:[{label:"YYYY",value:"YYYY"},{label:"MM",value:"MM"},{label:"DD",value:"DD"},{label:"YYYY-MM",value:"YYYY-MM"},{label:"YYYY-MM-DD",value:"YYYY-MM-DD"}]},fn:(t,e)=>Ve(t).format(e)},YYYY:{label:"YYYY (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY")},MM:{label:"MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("MM")},DD:{label:"DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("DD")},"YYYY-MM":{label:"YYYY-MM (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM")},"YYYY-MM-DD":{label:"YYYY-MM-DD (Deprecated, use Format instead)",fn:t=>Ve(t).format("YYYY-MM-DD")}},time:{Format:{schema:{"x-component":"AutoComplete","x-component-props":{allowClear:!0,style:{minWidth:200}},enum:[{label:"hh:mm:ss",value:"hh:mm:ss"},{label:"hh:mm",value:"hh:mm"},{label:"hh",value:"hh"}]},fn:(t,e)=>Ve(t).format(e)},"hh:mm:ss":{label:"hh:mm:ss (Deprecated, use Format instead)",fn:t=>Ve(t).format("hh:mm:ss")},"hh:mm":{label:"hh:mm (Deprecated, use Format instead)",fn:t=>Ve(t).format("hh:mm")},hh:{label:"hh (Deprecated, use Format instead)",fn:t=>Ve(t).format("hh")}},number:{Precision:{schema:{"x-component":"Select",enum:[{label:"1",value:0},{label:"1.0",value:1},{label:"1.00",value:2},{label:"1.000",value:3}]},fn:(t,e)=>Number(t.toFixed(e))},Separator:{schema:{"x-component":"Select",enum:[{label:"100,000.00",value:"en-US"},{label:"100.000,00",value:"de-DE"},{label:"100 000.00",value:"ru-RU"}]},fn:(t,e)=>{switch(e){case"en-US":return t.toLocaleString("en-US",{minimumFractionDigits:2});case"de-DE":return t.toLocaleString("de-DE",{minimumFractionDigits:2});case"ru-RU":return t.toLocaleString("ru-RU",{minimumFractionDigits:2});default:return t}}},Percent:t=>new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:2,maximumFractionDigits:2}).format(t),Currency:{label:"Currency (Deprecated, use Separator & Prefix instead)",fn:(t,e="en-US")=>{const n={"zh-CN":"CNY","en-US":"USD","ja-JP":"JPY","ko-KR":"KRW","pt-BR":"BRL","ru-RU":"RUB","tr-TR":"TRY","es-ES":"EUR"}[e]||"USD";return new Intl.NumberFormat(e,{style:"currency",currency:n}).format(t)}},Exponential:t=>(+t).toExponential(),Abbreviation:{schema:{"x-component":"Select",enum:[{label:"en-US",value:"en-US"},{label:"zh-CN",value:"zh-CN"}]},fn:(t,e="en-US")=>new Intl.NumberFormat(e,{notation:"compact"}).format(t)}},string:{"Type conversion":{schema:{"x-component":"Select",enum:[{label:"Number",value:"Number"},{label:"Date",value:"Date"}]},fn:(t,e)=>{try{return new Function(`return ${e}(${t})`)()}catch(n){return console.log(n),t}}}}},jB=t=>function(){const n=dt.useField(),r=n.query("query").get("value")||{},i=il(t,r),o=Object.keys(Yo).filter(a=>a!=="general");return{onChange:a=>{n.value=a;const s=n.query(".type").take();a||s.setState({value:null});const l=i.find(h=>h.value===a);s.dataSource=o.map(h=>({label:St(h),value:h}));const c={createdAt:"datetime",updatedAt:"datetime",double:"number",integer:"number",percent:"number"},u=l==null?void 0:l.interface,f=l==null?void 0:l.type,d=c[u]||c[f]||f;if(o.includes(d)){s.setState({value:d});return}s.setState({value:null})}}},DB=()=>{const t=dt.useField();return{options:Object.keys(Yo).filter(r=>r!=="general").map(r=>({label:St(r),value:r})),onChange:r=>{t.value=r,t.query(".format").take().setValue(null)}}},FB=()=>{const t=dt.useField();return{onChange:e=>{t.value=e,t.query(".argument").take().setValue(null)}}},$B=t=>{const e=t.query(".type").get("value");if(!e){t.dataSource=[];return}const n=Object.entries(tt(tt({},Yo.general),Yo[e]||{})).map(([r,i])=>{const o=typeof i=="function"?r:i.label||r;return{label:St(o),value:r}});t.dataSource=n},RB=t=>{const e=t.query(".type").get("value"),n=t.query(".format").get("value");if(!n||!e){t.setComponentProps({schema:null});return}const r=Yo[e][n]||Yo.general[n];if(!r||typeof r=="function"){t.setComponentProps({schema:null});return}const i=Bo.uid();t.setComponentProps({schema:tt({name:i},r.schema)})},BB=(t,e="en-US")=>{const n=(t||[]).filter(i=>i.field&&i.type&&i.format).reduce((i,o)=>{const a=Yo[o.type][o.format]||Yo.general[o.format];return a&&(i[o.field]=[...i[o.field]||[],{transformer:a,argument:o.argument}]),i},{}),r={};return Object.entries(n).forEach(([i,o])=>{r[i]=o.reduce((a,s)=>{const{transformer:l}=s;let{argument:c}=s;return u=>{try{return typeof l=="function"?l(a(u),c):(!c&&!l.schema&&(c=e),l.fn(a(u),c))}catch(f){return console.log(f),u}}},a=>a)}),r};function cu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zB=function(e){return YB(e)&&!WB(e)};function YB(t){return!!t&&typeof t=="object"}function WB(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||UB(t)}var GB=typeof Symbol=="function"&&Symbol.for,HB=GB?Symbol.for("react.element"):60103;function UB(t){return t.$$typeof===HB}function VB(t){return Array.isArray(t)?[]:{}}function uu(t,e){return e.clone!==!1&&e.isMergeableObject(t)?al(VB(t),t,e):t}function XB(t,e,n){return t.concat(e).map(function(r){return uu(r,n)})}function qB(t,e){if(!e.customMerge)return al;var n=e.customMerge(t);return typeof n=="function"?n:al}function KB(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}function FS(t){return Object.keys(t).concat(KB(t))}function $S(t,e){try{return e in t}catch(n){return!1}}function ZB(t,e){return $S(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function QB(t,e,n){var r={};return n.isMergeableObject(t)&&FS(t).forEach(function(i){r[i]=uu(t[i],n)}),FS(e).forEach(function(i){ZB(t,i)||($S(t,i)&&n.isMergeableObject(e[i])?r[i]=qB(i,n)(t[i],e[i],n):r[i]=uu(e[i],n))}),r}function al(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||XB,n.isMergeableObject=n.isMergeableObject||zB,n.cloneUnlessOtherwiseSpecified=uu;var r=Array.isArray(e),i=Array.isArray(t),o=r===i;return o?r?n.arrayMerge(t,e,n):QB(t,e,n):uu(e,n)}al.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,i){return al(r,i,n)},{})};var JB=al,tz=JB;const ez=cu(tz),nz=()=>({title:'{{t("Options")}}',type:"array","x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object","x-decorator":"ArrayItems.Item",properties:{space:{type:"void","x-component":"Space",properties:{label:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Option label")}}'},required:!0},value:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Option value")}}'},required:!0},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:"Add","x-component":"ArrayItems.Addition"}}}),Ty=t=>{const e={type:"boolean","x-content":'{{ t("Show time") }}',"x-decorator":"FormItem","x-component":"Checkbox"},n={type:"string",title:'{{t("Date format")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"YYYY-MM-DD",enum:[{label:'{{t("Year/Month/Day")}}',value:"YYYY/MM/DD"},{label:'{{t("Year-Month-Day")}}',value:"YYYY-MM-DD"},{label:'{{t("Day/Month/Year")}}',value:"DD/MM/YYYY"}]},r=nz();return{DatePicker:{type:"object",properties:{dateFormat:n,showTime:e}},"DatePicker.RangePicker":{type:"object",properties:{dateFormat:n,showTime:e}},Select:{type:"object",properties:{mode:{type:"string",enum:[{label:'{{ t("Single select") }}',value:""},{label:'{{ t("Multiple select") }}',value:"multiple"}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{defaultValue:""}},options:r}},"Checkbox.Group":{type:"object",properties:{options:r}},"Radio.Group":{type:"object",properties:{options:r}}}[t]},rz=(t,e)=>{if(!t)return t;if(Ve.isDayjs(t))return e.showTime||(t=t.startOf("day")),au.moment2str(t,e);if(Array.isArray(t)&&t.length&&Ve.isDayjs(t[0])){let n=t[0],r=t[1];return e.showTime&&(n=n.startOf("day"),r=r.endOf("day")),[n.toISOString(),r.toISOString()]}return t},RS=(t,e)=>Nn(this,null,function*(){const n=t.initialValue;if(!(typeof n=="string"&&(n==null?void 0:n.startsWith("{{$"))&&(n==null?void 0:n.endsWith("}}")))||!e)t.setValue(n),t.setInitialValue(n);else{t.loading=!0;const{value:i}=yield e.parseVariable(n),o=rz(i,t.componentProps);t.setValue(o),t.setInitialValue(o),t.loading=!1}}),vh="-",fu=(t,e)=>t?`${t}${vh}${e}`:e,BS=t=>{const[e,n]=t.split(vh);return n?{dataSource:e,fieldName:n}:{dataSource:z.DEFAULT_DATA_SOURCE_KEY,fieldName:e}},Ly=(t,e,n)=>dt.Schema.isSchemaInstance(t)?t.reduceProperties((r,i)=>{let o=i[e];if(o.includes(vh)||(o=`${z.DEFAULT_DATA_SOURCE_KEY}${vh}${o}`),o===n)return i;if(i["x-component"]!=="Action.Container"&&i["x-component"]!=="AssociationField.Viewer"){const a=Ly(i,e,n);if(a)return a}return r}):null,Ny=()=>{const{charts:t}=K.useContext(ol),e=K.useMemo(()=>Object.values(t).filter(i=>i).reduce((i,o)=>{var l;const{dataSource:a,collection:s}=o;return(l=i[a])!=null&&l.includes(s)||(i[a]=[...i[a]||[],s]),i},{}),[t]),n=K.useMemo(()=>Object.keys(e).length>1,[e]),r=K.useCallback((i,o)=>{var a;return((a=e[i])==null?void 0:a.includes(o))||!1},[e]);return{chartCollections:e,showDataSource:n,getIsChartCollectionExists:r}},sl=()=>{const t=z.useDataSourceManager(),{charts:e}=K.useContext(ol),{fieldSchema:n}=z.useActionContext(),r=n==null?void 0:n["x-action"],{fields:i,form:o}=K.useContext(kr),a=z.useVariables(),s=({dataSource:v,collection:g,cm:y,fim:m})=>{const b=y.getCollectionFields(g.name),x=(E,M,P,k)=>{var I,F,$,R,B;const A=((I=E.uiSchema)==null?void 0:I.title)||E.name,C=m.getFieldInterface(E.interface),T=($=(F=C==null?void 0:C.filterable)==null?void 0:F.operators)==null?void 0:$[0],N=y.getCollection(E.target);M=M?`${M} / ${A}`:A;let j={type:"string",title:M,name:`${P}.${E.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-component":"CollectionField","x-decorator":"ChartFilterFormItem","x-data-source":v,"x-collection-field":`${k}.${E.name}`,"x-component-props":ht(tt({},(R=E.uiSchema)==null?void 0:R["x-component-props"]),{"filter-operator":T})};if(E.interface==="formula"){const W=mB(E.dataType)||"Input";j=ht(tt({},j),{"x-component":W})}return["oho","o2m"].includes(E.interface)&&rn.set(j,"x-component-props.useOriginalFilter",!0),{key:`${P}.${E.name}`,name:E.name,type:"item",title:((B=E==null?void 0:E.uiSchema)==null?void 0:B.title)||E.name,Component:"CollectionFieldInitializer",find:Ly,remove:(W,q)=>{q(W,{breakRemoveOn:{"x-component":"Grid"}})},schemaInitialize:W=>{var q;(q=C==null?void 0:C.schemaInitialize)==null||q.call(C,W,{field:E,block:"FilterForm",readPretty:o.readPretty,action:r,targetCollection:N})},schema:j}},w=(E,M,P,k)=>{var j;const A=((j=E.uiSchema)==null?void 0:j.title)||E.name;M=M?`${M} / ${A}`:A;const C=E.operators[0];let T=ht(tt({type:"string",name:`${P}.${E.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-decorator":"ChartFilterFormItem","x-data-source":v,"x-collection-field":`${k}.${E.name}`},E.schema),{title:M,"x-component-props":{"filter-operator":C}});return C!=null&&C.noValue&&(T=ht(tt({},T),{"x-component":"ChartFilterCheckbox","x-component-props":ht(tt({},T["x-component-props"]),{content:dt.Schema.compile(C.label,{t:z.i18n.t})})})),{key:`${P}.${E.name}`,name:E.name,type:"item",title:E.title||E.name,Component:"CollectionFieldInitializer",find:Ly,remove:(L,I)=>{I(L,{breakRemoveOn:{"x-component":"Grid"}})},schema:T}},O=(E,M,P,k,A)=>{var I,F,$;if(!E.interface||E.isForeignKey)return;const C=m.getFieldInterface(E.interface);if(!(C!=null&&C.filterable))return;const{nested:T,children:N}=C.filterable,j=((I=E.uiSchema)==null?void 0:I.title)||E.name,L=x(E,P,k,A);if(!(E.target&&M>2)){if(P=P?`${P} / ${j}`:j,N!=null&&N.length&&!["chinaRegion","createdBy","updatedBy","attachment"].includes(E.interface)){const R=N.map(B=>w(B,P,`${k}.${E.name}`,`${A}.${E.name}`));return{key:`${k}.${E.name}`,name:E.name,type:"subMenu",title:((F=E==null?void 0:E.uiSchema)==null?void 0:F.title)||E.name,children:R}}if(!M||M>2)return L;if(T){const B=y.getCollectionFields(E.target).map(W=>O(W,M+1,"",`${k}.${E.name}`,`${A}.${E.name}`));return{key:`${k}.${E.name}`,name:E.name,type:"subMenu",title:(($=E==null?void 0:E.uiSchema)==null?void 0:$.title)||E.name,children:B.filter(Boolean)}}return L}},_=[],S=[];return b.forEach(E=>{const M=E.interface,P=O(E,0,"",fu(v,g.name),g.name);if(P&&_.push(P),["m2o"].includes(M)){const k=O(E,1,"",fu(v,g.name),g.name);k&&S.push(k)}}),S.length&&_.push({name:"divider",type:"divider"},{name:"displayAssociationFields",type:"itemGroup",title:z.i18n.t("Display association fields"),children:S}),_},l=()=>{const v=(o==null?void 0:o.values)||{},g={};return Object.entries(i).filter(([y,m])=>m).forEach(([y,m])=>{const{operator:b}=m||{},{dataSource:x,fieldName:w}=BS(y);let O=w;const E=t.getDataSource(x).collectionManager.getCollectionField(O);if(E!=null&&E.target){const C=E.targetKey||"id";O=`${O}.${C}`,y=`${y}.${C}`}const[M,...P]=O.split("."),k=yB(v,y),A=(b==null?void 0:b.value)||"$eq";if(M!=="custom"){const C=fu(x,M);g[C]=g[C]||{$and:[]};const T={};rn.set(T,P.join("."),{[A]:k}),g[C].$and.push(T)}else g[M]=g[M]||{},g[M][`$nFilter.${P.join(".")}`]=k}),g},c=(v,g)=>{if(!v)return!1;const{dataSource:y,collection:m,query:b}=v,{parameters:x}=au.parse(b.filter||"");return g[fu(y,m)]||g.custom&&(x==null?void 0:x.find(({key:w})=>rn.has(g.custom,w)))},u=(v,g)=>{const{dataSource:y,collection:m,query:b}=v;let x=tt({},b);const w=tt({},x.filter||{});let O={};const _=au.parse(w),{parameters:S}=_;return g.custom&&(S!=null&&S.find(E=>g.custom[E.key]))&&(O=_(g.custom)),O=ez(w,O),x=ht(tt({},x),{filter:{$and:[O,g[fu(y,m)]]}}),x},f=()=>Nn(this,null,function*(){const v=l(),g=Object.values(e).filter(y=>c(y,v)).map(y=>()=>Nn(this,null,function*(){const{dataSource:m,service:b,collection:x}=y;yield b.runAsync(m,x,u(y,v),!0)}));yield Promise.all(g.map(y=>y()))}),d=()=>Nn(this,null,function*(){const v=Object.values(e).filter(g=>g).map(g=>()=>Nn(this,null,function*(){const{service:y,dataSource:m,collection:b,query:x}=g;yield y.runAsync(m,b,x,!0)}));yield Promise.all(v.map(g=>g()))}),h=Mi.useMemoizedFn(v=>v.split(" / ").map(g=>z.i18n.t(dt.Schema.compile(g,{t:z.i18n.t}))).join(" / ")),p=K.useCallback(v=>Nn(this,null,function*(){const g=au.flatten(v,{breakOn({key:m}){return m.startsWith("$")&&m!=="$and"&&m!=="$or"},transformValue(m){return!(typeof m=="string"&&m.startsWith("{{$")&&(m!=null&&m.endsWith("}}")))||["$user","$date","$nDate","$nRole","$nFilter"].some(x=>m.includes(x))?m:a==null?void 0:a.parseVariable(m).then(({value:x})=>x)}});return yield Promise.all(Object.keys(g).map(m=>Nn(this,null,function*(){return g[m]=yield g[m],g[m]===void 0&&delete g[m],g[m]}))),au.unflatten(g)}),[a]);return{filter:f,refresh:d,getChartFilterFields:s,getFilter:l,hasFilter:c,appendFilter:u,getTranslatedTitle:h,parseFilter:p}},iz=()=>{const{t}=se(),e=Mi.useMemoizedFn(t),{enabled:n,fields:r}=K.useContext(kr),i=Object.entries(r).filter(([a,s])=>a.startsWith("custom.")&&s).map(([a,{title:s}])=>{const l=a.replace(/^custom\./,"");return{key:l,value:l,label:s}}),o=K.useMemo(()=>({label:e("Current filter"),value:"$nFilter",key:"$nFilter",children:i}),[i,e]);return!n||!i.length?null:o},zS=()=>{const{t}=se(),{chartCollections:e}=Ny(),n=z.useDataSourceManager(),r=n.collectionFieldInterfaceManager,{values:i}=YS(),o=(a,s,l)=>{var d,h,p;if(!s.interface)return;const c=r.getFieldInterface(s.interface);if(!(c!=null&&c.filterable))return;const{nested:u}=c.filterable,f={value:s.name,label:t(((d=s==null?void 0:s.uiSchema)==null?void 0:d.title)||s.name)};if(!(s.target&&l>2)){if(l>2)return f;if(u){const g=a.getCollectionFields(s.target).map(y=>o(a,y,l+1));return{value:s.name,label:t(((h=s==null?void 0:s.uiSchema)==null?void 0:h.title)||s.name),children:g.filter(y=>y)}}if(!(!i.includes((p=s.uiSchema)==null?void 0:p["x-component"])&&!i.includes(s.interface)))return f}};return K.useMemo(()=>Object.entries(e).map(([s,l])=>{const c=n.getDataSource(s);return{value:s,label:dt.Schema.compile(c.displayName,{t}),children:l.map(u=>{const f=c.collectionManager,d=f.getCollection(u),p=f.getCollectionFields(u).map(v=>o(f,v,1)).filter(v=>v);return{value:u,label:dt.Schema.compile(d.title,{t}),children:p}})}}),[e])},YS=()=>{const{t}=se(),e=[{label:t("Input"),value:"Input"},{label:t("Number"),value:"InputNumber"},{label:t("Date"),value:"DatePicker"},{label:t("Date range"),value:"DatePicker.RangePicker"},{label:t("Time"),value:"TimePicker"},{label:t("Time range"),value:"TimePicker.RangePicker"},{label:t("Select"),value:"Select"},{label:t("Radio group"),value:"Radio.Group"},{label:t("Checkbox group"),value:"Checkbox.Group"}];return{options:e,values:e.map(n=>n.value)}},oz=(t,e)=>{const{t:n}=se(),r=z.useDataSourceManager(),{showDataSource:i}=Ny();return K.useMemo(()=>{var p;const o=r.getDataSource(t);if(!o)return;const a=o.collectionManager;if(!e)return;const{fieldName:s}=BS(e),[l,...c]=s.split(".");if(!(c!=null&&c.length))return;const u=a.getCollection(l);let f=l,d,h=dt.Schema.compile(u==null?void 0:u.title,{t:n});for(;f&&c.length>0;){const v=c.shift();d=a.getCollectionField(`${f}.${v}`);const g=((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||(d==null?void 0:d.name);g&&(h+=` / ${dt.Schema.compile(g,{t:n})}`),d!=null&&d.target?f=d.target:f=null}return i?`${dt.Schema.compile(o.displayName,{t:n})} > ${h}`:h},[e,t,i])},WS=(t,e)=>{const{currentUserSettings:n}=z.useCurrentUserVariable({collectionField:{uiSchema:t},uiSchema:t}),{currentRoleSettings:r}=z.useCurrentRoleVariable({uiSchema:t}),{apiTokenSettings:i}=z.useAPITokenVariable({noDisabled:!0}),{datetimeSettings:o}=z.useDatetimeVariable({operator:e,schema:t,noDisabled:!0}),{urlSearchParamsSettings:a}=z.useURLSearchParamsVariable(),s=K.useMemo(()=>[n,r,i,o,a].filter(Boolean),[o,n,r,a,i]);return t?s:[]},az=()=>{const t=dt.useField(),{operator:e,schema:n}=t.data||{},r=iz(),i=WS(n,e),o=K.useMemo(()=>[...i,r].filter(Boolean),[i,r]);return!e||!n?[]:o},Iy=(t={},e={})=>ht(tt({type:"array","x-decorator":"FormItem","x-component":"ArrayItems"},e),{items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:ht(tt({sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"}},t),{remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}})}}},properties:{add:{type:"void",title:'{{t("Add field")}}',"x-component":"ArrayItems.Addition"}}}),sz=t=>({type:"void",properties:{config:{type:"object",properties:{collapse:{type:"void","x-component":"FormCollapse","x-component-props":{formCollapse:"{{formCollapse}}",size:"small",style:{border:"none",boxShadow:"none"}},properties:{pane1:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Container"),key:"card"},properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},bordered:{type:"boolean","x-content":St("Show border"),"x-decorator":"FormItem","x-component":"Checkbox",default:!1}}},pane2:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Chart"),key:"basic",style:{border:"none"}},properties:{chartType:{type:"string",title:'{{t("Chart type")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Please select a chart type.")}}'},enum:"{{ chartTypes }}"},[Bo.uid()]:{type:"void",properties:{general:t}},[Bo.uid()]:{type:"void",properties:{advanced:{type:"json",title:'{{t("JSON config")}}',"x-decorator":"FormItem","x-decorator-props":{extra:St("Same properties set in the form above will be overwritten by this JSON config.")},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:3},json5:!0}}}},reference:{type:"string","x-reactions":{dependencies:[".chartType"],fulfill:{schema:{"x-content":"{{ getReference($deps[0]) }}"}}}}}}}}}}}}),lz={type:"void",properties:{settings:{type:"void",properties:{collection:{title:'{{t("Collection")}}',type:"string","x-decorator":"FormItem","x-component":"Cascader",enum:"{{ collectionOptions }}","x-component-props":{onChange:"{{ onCollectionChange }}",placeholder:'{{t("Collection")}}'}}}},query:{type:"object",properties:{builder:{type:"void",properties:{collapse:{type:"void","x-decorator":"FormItem","x-component":"FormCollapse","x-component-props":{formCollapse:"{{formCollapse}}",size:"small",style:{border:"none",boxShadow:"none"}},properties:{pane1:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Measures"),key:"measures"},properties:{measures:Iy({field:{type:"string","x-decorator":"FormItem","x-component":"Cascader","x-component-props":{placeholder:'{{t("Field")}}',fieldNames:{label:"title",value:"name",children:"children"}},enum:"{{ fieldOptions }}",required:!0},aggregation:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Aggregation")}}'},enum:[{label:'{{t("Sum")}}',value:"sum"},{label:'{{t("Count")}}',value:"count"},{label:'{{t("Avg")}}',value:"avg"},{label:'{{t("Max")}}',value:"max"},{label:'{{t("Min")}}',value:"min"}]},alias:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Alias")}}',style:{minWidth:"100px"}}},distinct:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Distinct")}}'}},{required:!0,"x-component-props":{style:{overflow:"auto"}}})}},pane2:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Dimensions"),key:"dimensions"},properties:{dimensions:Iy({field:{type:"string","x-decorator":"FormItem","x-component":"Cascader","x-component-props":{placeholder:'{{t("Field")}}',fieldNames:{label:"title",value:"name",children:"children"}},enum:"{{ fieldOptions }}",required:!0},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Format")}}',style:{maxWidth:"120px"}},"x-reactions":"{{ useFormatterOptions }}","x-visible":"{{ $self.dataSource && $self.dataSource.length }}"},alias:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Alias")}}',style:{minWidth:"100px"}}}},{"x-component-props":{style:{overflow:"auto"}}})}},pane3:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Filter"),key:"filter"},properties:{filter:{type:"object","x-decorator":"FormItem","x-decorator-props":{style:{overflow:"auto"}},enum:"{{ filterOptions }}","x-component":"Filter","x-component-props":{dynamicComponent:"FilterDynamicComponent"}}}},pane4:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:St("Sort"),key:"sort",style:{border:"none"}},properties:{orders:Iy({field:{type:"string","x-decorator":"FormItem","x-component":"Cascader","x-component-props":{placeholder:'{{t("Field")}}'},"x-reactions":"{{ useOrderOptions }}",required:!0},order:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{defaultValue:"ASC",optionType:"button",style:{width:"128px"}},enum:["ASC","DESC"]}},{"x-reactions":"{{ useOrderReaction }}","x-component-props":{style:{overflow:"auto"}}})}}}},limit:{title:'{{t("Limit")}}',type:"number","x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{defaultValue:2e3,min:1,style:{width:"100px"}}}}},cache:{type:"object",properties:{enabled:{type:"boolean",title:'{{t("Enable cache")}}',"x-decorator":"FormItem","x-component":"Switch"},ttl:{type:"number",title:'{{t("TTL (second)")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{defaultValue:60,min:1,style:{width:"100px"}}}}}}}}},cz={type:"void",properties:{transform:{type:"array","x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{wrap:!0},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Field")}}'},"x-use-component-props":"useFieldSelectProps","x-reactions":"{{ useChartFields }}"},type:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Type")}}'},"x-use-component-props":"useFieldTypeSelectProps"},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Transformer")}}',style:{maxWidth:"200px"}},"x-use-component-props":"useTransformerSelectProps","x-reactions":"{{ useTransformers }}","x-visible":"{{ $self.dataSource && $self.dataSource.length }}"},argument:{type:"string","x-decorator":"FormItem","x-component":"TransformerDynamicComponent","x-reactions":"{{ useArgument }}"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add transformation")}}',"x-component":"ArrayItems.Addition"}}}}};function uz(t){const{value:e,onChange:n,renderSchemaComponent:r}=t,i=az();return Y.jsx(z.Variable.Input,{value:e,onChange:n,scope:i,children:r()})}const Pi=K.createContext({visible:!0});Pi.displayName="ChartConfigContext";const fz=t=>{var a;const{insertAdjacent:e}=z.useDesignable(),[n,r]=K.useState(!1),[i,o]=K.useState({});return Y.jsxs(Pi.Provider,{value:{visible:n,setVisible:r,current:i,setCurrent:o},children:[t.children,Y.jsx(LS,ht(tt({},(a=i.field)==null?void 0:a.decoratorProps),{children:Y.jsx(oi,{insert:(s,l)=>e("beforeEnd",s,l)})}))]})},dz=t=>{const{schema:e}=t,n=dt.useField();return e?Y.jsx(z.SchemaComponent,{schema:{type:"void",properties:{[e.name]:ht(tt({type:"void"},e),{value:n.value,"x-component-props":ht(tt({},e["x-component-props"]),{defaultValue:n.value,onChange:r=>{if(typeof r=="object"&&(r!=null&&r.target)){n.value=r.target.value;return}n.value=r}})})}}}):null},{Paragraph:ISt,Text:hz}=Ot.Typography,oi=t=>{const{t:e}=se(),{service:n}=K.useContext(ii),{visible:r,setVisible:i,current:o}=K.useContext(Pi),{schema:a,field:s,dataSource:l,collection:c,initialValues:u}=o||{},{dn:f}=z.useDesignable(),{modal:d}=Ot.App.useApp(),{insert:h}=t,p=IS(),v=Ua(l,c),g=(P=!1)=>{var I;if(!_.modified)return;const k=(I=_.values.config)==null?void 0:I.chartType;if(!k)return;const A=p[k];if(!(A==null?void 0:A.init)){P&&(_.values.config.general={},_.values.config.advanced={});return}const T=_.values.query,N=il(v,T),{general:j,advanced:L}=A.init(N,T);(j||P)&&(_.values.config.general=j),(L||P)&&(_.values.config.advanced=L||{})},[y,m]=K.useState([]),[b,x]=K.useState([]),w=(P,k)=>{var T,N;const A=((T=P.values.query)==null?void 0:T.measures.filter(j=>j.field))||[],C=((N=P.values.query)==null?void 0:N.dimensions.filter(j=>j.field))||[];rn.isEqual(A,y)&&rn.isEqual(C,b)||(k==null||k(),m(rn.cloneDeep(A)),x(rn.cloneDeep(C)))},O=_B(),_=K.useMemo(()=>{var A;const P=u||(a==null?void 0:a["x-decorator-props"]),k=(P==null?void 0:P.config)||{};return wn.createForm({values:ht(tt({},P),{config:ht(tt({chartType:O},k),{title:k.title||((A=s==null?void 0:s.componentProps)==null?void 0:A.title)}),collection:[l,c]}),effects:C=>{wn.onFieldChange("config.chartType",()=>g(!0)),wn.onFormInit(()=>w(C))}})},[s,r,l,c]),S=()=>Y.jsx(Ot.Button,{type:"link",loading:n==null?void 0:n.loading,icon:Y.jsx(In.RightSquareOutlined,{}),onClick:()=>Nn(this,null,function*(){const P=_.query("query").take();try{yield P==null?void 0:P.validate()}catch(k){return}try{yield n.runAsync(l,c,_.values.query,!0)}catch(k){console.log(k)}w(_,g)}),children:e("Run query")}),E=K.useRef(null),M=K.useRef(null);return K.useEffect(()=>{var P;r&&n.run(c,(P=s==null?void 0:s.decoratorProps)==null?void 0:P.query,"configure")},[r]),Y.jsx(Ot.Modal,{title:e("Configure chart"),open:r,onOk:()=>{const{query:P,config:k,transform:A,mode:C}=_.values,{title:T,bordered:N}=k||{},j=()=>{var I;i(!1),(I=o.service)==null||I.run(l,c,P),E.current.scrollTop=0,M.current.scrollTop=0,n.mutate(void 0)},L={query:P,config:k,dataSource:l,collection:c,transform:A,mode:C||"builder"};if(a&&a["x-uid"]){a["x-component-props"]=ht(tt({},a["x-component-props"]),{title:T,bordered:N}),a["x-decorator-props"]=L,s.decoratorProps=L,s.componentProps=ht(tt({},s.componentProps),{title:T,bordered:N}),s["x-acl-action"]=`${c}:list`,f.emit("patch",{schema:a}),j();return}h(z.gridRowColWrap(TS(L)),{onSuccess:j})},onCancel:()=>{d.confirm({title:e("Are you sure to cancel?"),content:e("You changes are not saved. If you click OK, your changes will be lost."),okButtonProps:{danger:!0},onOk:()=>{i(!1),E.current.scrollTop=0,M.current.scrollTop=0,n.mutate(void 0)}})},width:"95%",className:zo.css`
|
|
11
11
|
.ant-modal-content {
|
|
12
12
|
padding: 0;
|
|
13
13
|
}
|
package/dist/client/utils.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { SelectedField } from './configure';
|
|
9
10
|
import { FieldOption } from './hooks';
|
|
10
11
|
import { QueryProps } from './renderer';
|
|
11
12
|
export declare const createRendererSchema: (decoratorProps: any, componentProps?: {}) => {
|
|
@@ -39,6 +40,7 @@ export declare const getSelectedFields: (fields: FieldOption[], query: QueryProp
|
|
|
39
40
|
key: string;
|
|
40
41
|
label: string;
|
|
41
42
|
value: string;
|
|
43
|
+
query: SelectedField;
|
|
42
44
|
alias?: string;
|
|
43
45
|
name?: string;
|
|
44
46
|
type?: string;
|
|
@@ -103,7 +105,9 @@ export declare const getSelectedFields: (fields: FieldOption[], query: QueryProp
|
|
|
103
105
|
target?: string;
|
|
104
106
|
targetFields?: FieldOption[];
|
|
105
107
|
}[];
|
|
106
|
-
export declare const processData: (selectedFields: FieldOption
|
|
108
|
+
export declare const processData: (selectedFields: (FieldOption & {
|
|
109
|
+
query?: any;
|
|
110
|
+
})[], data: any[], scope: any) => {}[];
|
|
107
111
|
export declare const removeUnparsableFilter: (filter: any) => any;
|
|
108
112
|
export declare const getValuesByPath: (values: any, path: string) => any;
|
|
109
113
|
export declare const getFormulaComponent: (type: string) => string;
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.3.
|
|
11
|
+
"@nocobase/client": "1.3.17-beta",
|
|
12
12
|
"dayjs": "1.11.10",
|
|
13
13
|
"@formily/react": "2.3.0",
|
|
14
14
|
"@formily/shared": "2.3.0",
|
|
15
15
|
"lodash": "4.17.21",
|
|
16
|
-
"@nocobase/cache": "1.3.
|
|
17
|
-
"@nocobase/server": "1.3.
|
|
16
|
+
"@nocobase/cache": "1.3.17-beta",
|
|
17
|
+
"@nocobase/server": "1.3.17-beta",
|
|
18
18
|
"react": "18.2.0",
|
|
19
19
|
"@emotion/css": "11.11.2",
|
|
20
20
|
"@ant-design/icons": "5.2.6",
|
|
@@ -22,9 +22,9 @@ module.exports = {
|
|
|
22
22
|
"antd": "5.12.8",
|
|
23
23
|
"@formily/antd-v5": "1.1.9",
|
|
24
24
|
"@formily/core": "2.3.0",
|
|
25
|
-
"@nocobase/utils": "1.3.
|
|
25
|
+
"@nocobase/utils": "1.3.17-beta",
|
|
26
26
|
"react-i18next": "11.18.6",
|
|
27
27
|
"sequelize": "6.35.2",
|
|
28
|
-
"@nocobase/actions": "1.3.
|
|
29
|
-
"@nocobase/database": "1.3.
|
|
28
|
+
"@nocobase/actions": "1.3.17-beta",
|
|
29
|
+
"@nocobase/database": "1.3.17-beta"
|
|
30
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"koa-compose","description":"compose Koa middleware","repository":"koajs/compose","version":"4.1.0","keywords":["koa","middleware","compose"],"files":["index.js"],"dependencies":{},"devDependencies":{"codecov":"^3.0.0","jest":"^21.0.0","matcha":"^0.7.0","standard":"^10.0.3"},"scripts":{"bench":"matcha bench/bench.js","lint":"standard --fix .","test":"jest --forceExit --coverage"},"jest":{"testEnvironment":"node"},"license":"MIT","_lastModified":"2024-09-
|
|
1
|
+
{"name":"koa-compose","description":"compose Koa middleware","repository":"koajs/compose","version":"4.1.0","keywords":["koa","middleware","compose"],"files":["index.js"],"dependencies":{},"devDependencies":{"codecov":"^3.0.0","jest":"^21.0.0","matcha":"^0.7.0","standard":"^10.0.3"},"scripts":{"bench":"matcha bench/bench.js","lint":"standard --fix .","test":"jest --forceExit --coverage"},"jest":{"testEnvironment":"node"},"license":"MIT","_lastModified":"2024-09-07T15:57:15.130Z"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-data-visualization",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17-beta",
|
|
4
4
|
"displayName": "Data visualization",
|
|
5
5
|
"displayName.zh-CN": "数据可视化",
|
|
6
6
|
"description": "Provides data visualization feature, including chart block and chart filter block, support line charts, area charts, bar charts and more than a dozen kinds of charts, you can also extend more chart types.",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@nocobase/test": "1.x",
|
|
35
35
|
"@nocobase/utils": "1.x"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "9c2f4d3b7b8d920f75a6c1514de047f36ec66ecc",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"Blocks"
|
|
40
40
|
]
|