@nocobase/plugin-data-visualization 0.19.0-alpha.3 → 0.19.0-alpha.4
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(dt,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("ahooks"),require("@nocobase/utils/client"),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","ahooks","@nocobase/utils/client","@emotion/css"],z):(dt=typeof globalThis!="undefined"?globalThis:dt||self,z(dt["@nocobase/plugin-data-visualization"]={},dt["@nocobase/client"],dt.jsxRuntime,dt.react,dt["@ant-design/icons"],dt["@formily/antd-v5"],dt["@formily/core"],dt["@formily/react"],dt.antd,dt.lodash,dt["react-i18next"],dt.dayjs,dt["@formily/shared"],dt.ahooks,dt["@nocobase/utils"],dt["@emotion/css"]))})(this,function(dt,z,R,D,ni,Ie,on,mt,gt,He,Av,Ce,na,ln,bl,ao){"use strict";var E7=Object.defineProperty,k7=Object.defineProperties;var T7=Object.getOwnPropertyDescriptors;var Mv=Object.getOwnPropertySymbols;var lT=Object.prototype.hasOwnProperty,sT=Object.prototype.propertyIsEnumerable;var S0=(dt,z,R)=>z in dt?E7(dt,z,{enumerable:!0,configurable:!0,writable:!0,value:R}):dt[z]=R,J=(dt,z)=>{for(var R in z||(z={}))lT.call(z,R)&&S0(dt,R,z[R]);if(Mv)for(var R of Mv(z))sT.call(z,R)&&S0(dt,R,z[R]);return dt},yt=(dt,z)=>k7(dt,T7(z));var uT=(dt,z)=>{var R={};for(var D in dt)lT.call(dt,D)&&z.indexOf(D)<0&&(R[D]=dt[D]);if(dt!=null&&Mv)for(var D of Mv(dt))z.indexOf(D)<0&&sT.call(dt,D)&&(R[D]=dt[D]);return R};var Fr=(dt,z,R)=>(S0(dt,typeof z!="symbol"?z+"":z,R),R);var br=(dt,z,R)=>new Promise((D,ni)=>{var Ie=gt=>{try{mt(R.next(gt))}catch(He){ni(He)}},on=gt=>{try{mt(R.throw(gt))}catch(He){ni(He)}},mt=gt=>gt.done?D(gt.value):Promise.resolve(gt.value).then(Ie,on);mt((R=R.apply(dt,z)).next())});function cT(e,r){for(var t=0;t<r.length;t++){const n=r[t];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(n,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const zu=Object.freeze(Object.defineProperty({__proto__:null,get Base(){return qr},get Circle(){return Zz},get Ellipse(){return Qz},get Image(){return Kz},get Line(){return Jz},get Marker(){return e5},get Path(){return Ip},get Polygon(){return s5},get Polyline(){return u5},get Rect(){return h5},get Text(){return v5}},Symbol.toStringTag,{value:"Module"})),Yu=Object.freeze(Object.defineProperty({__proto__:null,get Base(){return Pr},get Circle(){return w5},get Dom(){return S5},get Ellipse(){return C5},get Image(){return M5},get Line(){return A5},get Marker(){return F5},get Path(){return b5},get Polygon(){return E5},get Polyline(){return k5},get Rect(){return I5},get Text(){return D5}},Symbol.toStringTag,{value:"Module"})),C0="data-visualization";function Et(e){return z.i18n.t(e,{ns:[C0,"client"]})}function jt(){return Av.useTranslation([C0,"client"],{nsMode:"fallback"})}const Fv={datetime:[{label:Et("YYYY"),value:"YYYY"},{label:Et("MM"),value:"MM"},{label:Et("DD"),value:"DD"},{label:Et("YYYY-MM"),value:"YYYY-MM"},{label:Et("YYYY-MM-DD"),value:"YYYY-MM-DD"},{label:Et("YYYY-MM-DD hh:mm"),value:"YYYY-MM-DD hh:mm"},{label:Et("YYYY-MM-DD hh:mm:ss"),value:"YYYY-MM-DD hh:mm:ss"}],date:[{label:Et("YYYY"),value:"YYYY"},{label:Et("MM"),value:"MM"},{label:Et("DD"),value:"DD"},{label:Et("YYYY-MM"),value:"YYYY-MM"},{label:Et("YYYY-MM-DD"),value:"YYYY-MM-DD"}],time:[{label:Et("hh:mm:ss"),value:"hh:mm:ss"},{label:Et("hh:mm"),value:"hh:mm"},{label:Et("hh"),value:"hh"}]},fT=D.createContext(null),bv={didCatch:!1,error:null};let M0=class extends D.Component{constructor(r){super(r),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=bv}static getDerivedStateFromError(r){return{didCatch:!0,error:r}}resetErrorBoundary(){const{error:r}=this.state;if(r!==null){for(var t,n,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];(t=(n=this.props).onReset)===null||t===void 0||t.call(n,{args:a,reason:"imperative-api"}),this.setState(bv)}}componentDidCatch(r,t){var n,i;(n=(i=this.props).onError)===null||n===void 0||n.call(i,r,t)}componentDidUpdate(r,t){const{didCatch:n}=this.state,{resetKeys:i}=this.props;if(n&&t.error!==null&&hT(r.resetKeys,i)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:i,prev:r.resetKeys,reason:"keys"}),this.setState(bv)}}render(){const{children:r,fallbackRender:t,FallbackComponent:n,fallback:i}=this.props,{didCatch:a,error:o}=this.state;let l=r;if(a){const s={error:o,resetErrorBoundary:this.resetErrorBoundary};if(D.isValidElement(i))l=i;else if(typeof t=="function")l=t(s);else if(n)l=D.createElement(n,s);else throw o}return D.createElement(fT.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},l)}};function hT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==r.length||e.some((t,n)=>!Object.is(t,r[n]))}const A0=(e,r={})=>{const{collection:t}=e;return{type:"void","x-decorator":"ChartRendererProvider","x-decorator-props":e,"x-acl-action":`${t}:list`,"x-designer":"ChartRenderer.Designer","x-component":"CardItem","x-component-props":{size:"small"},"x-initializer":"ChartInitializers",properties:{[na.uid()]:{type:"void","x-component":"ChartRenderer","x-component-props":r}}}},El=e=>{let r,t;return Array.isArray(e)?e.length===1?t=e[0]:e.length>1&&([r,t]=e):t=e,{target:r,name:t,alias:r?`${r}.${t}`:t}},Vu=(e,r)=>{var a,o;const{target:t,name:n}=El(r);return t?(o=(a=e.find(l=>l.name===t))==null?void 0:a.targetFields)==null?void 0:o.find(l=>l.name===n):e.find(l=>l.name===n)},oo=(e,r)=>{const t=l=>l.map(s=>{const u=Vu(e,s.field);return yt(J({},u),{key:s.alias||(u==null?void 0:u.key),label:s.alias||(u==null?void 0:u.label),value:s.alias||(u==null?void 0:u.value)})}),n=r.measures||[],i=r.dimensions||[];return[...new Map([...t(n),...t(i)].map(l=>[l.value,l])).values()]},vT=(e,r,t)=>{const n=(i,a)=>{var s;const o=(s=i.uiSchema)==null?void 0:s.enum;if(!o||!Array.isArray(o))return a;const l=o.find(u=>u.value===a);return mt.Schema.compile((l==null?void 0:l.label)||a,t)};return r.map(i=>{const a={};return Object.entries(i).forEach(([o,l])=>{const s=e.find(u=>u.value===o);if(!s){a[o]=l;return}switch(s.interface){case"select":case"radioGroup":a[o]=n(s,l);break;default:a[o]=l}}),a})},Ev=e=>{if(typeof e=="object"&&e!==null)if(Array.isArray(e)){const r=e.map(t=>Ev(t)).filter(Boolean);return r.length>0?r:null}else{const r={};for(const t in e){const n=Ev(e[t]);n&&!(typeof n=="object"&&Object.keys(n).length===0)&&(r[t]=n)}return Object.keys(r).length>0?r:null}else if(typeof e=="string"&&e.startsWith("{{$nFilter.")&&e.endsWith("}}"))return null;return e},dT=(e,r)=>{const t=r.split(".");let n=He.get(e,t.slice(0,-1).join("."));return Array.isArray(n)?n=n.map(i=>He.get(i,t.slice(-1)[0])):n=He.get(n,t.slice(-1)[0]),n},pT=e=>({boolean:"Checkbox",integer:"InputNumber",bigInt:"InputNumber",double:"InputNumber",decimal:"InputNumber",date:"DatePicker",string:"Input"})[e],gT=e=>({boolean:"boolean",integer:"integer",bigInt:"integer",double:"number",decimal:"number",date:"datetime",string:"input"})[e],kl=D.createContext({}),yT=e=>{const[r,t]=D.useState({}),n=ln.useMemoizedFn((a,{collection:o,service:l,query:s})=>{t(u=>yt(J({},u),{[a]:{collection:o,service:l,query:s}}))}),i=ln.useMemoizedFn(a=>{t(o=>yt(J({},o),{[a]:void 0}))});return R.jsx(kl.Provider,{value:{charts:r,addChart:n,removeChart:i},children:e.children})},_r=D.createContext({}),mT=e=>{const[r,t]=D.useState(!1),[n,i]=D.useState(!1),[a,o]=D.useState({}),[l,s]=D.useState({collapsed:!1,row:1}),[u,c]=D.useState(),f=ln.useMemoizedFn((y,g)=>{o(m=>yt(J({},m),{[y]:J(J({},m[y]||{}),g)}))}),h=ln.useMemoizedFn(y=>{o(g=>{const m=J({},g);return m[y]=void 0,m})}),v=ln.useMemoizedFn(c),d=ln.useMemoizedFn(i),p=({collapsed:y,row:g})=>{s(m=>({collapsed:y!==void 0?y:m.collapsed,row:g!==void 0?g:m.row}))};return D.useEffect(()=>t(!0),[]),R.jsx(_r.Provider,{value:{ready:r,enabled:n,setEnabled:d,fields:a,setField:f,removeField:h,collapse:l,setCollapse:p,form:u,setForm:v},children:e.children})},kn=D.createContext({}),F0=e=>{const{query:r,config:t,collection:n,transform:i}=e,{addChart:a}=D.useContext(kl),{ready:o,form:l,enabled:s}=D.useContext(_r),{getFilter:u,hasFilter:c,appendFilter:f}=so(),h=mt.useFieldSchema(),v=z.useAPIClient(),d=z.useRequest((p,y,g)=>new Promise((m,x)=>{var M;if(!(p&&((M=y==null?void 0:y.measures)!=null&&M.length))||s&&!l)return m(void 0);const w=u(),C=!g&&c({collection:p,query:y},w)?f({collection:p,query:y},w):y;v.request({url:"charts:query",method:"POST",data:yt(J({uid:h==null?void 0:h["x-uid"],collection:p},C),{filter:Ev(C.filter),dimensions:((y==null?void 0:y.dimensions)||[]).map(A=>{const b=J({},A);if(A.format&&!A.alias){const{alias:T}=El(A.field);b.alias=T}return b}),measures:((y==null?void 0:y.measures)||[]).map(A=>{const b=J({},A);if(A.aggregation&&!A.alias){const{alias:T}=El(A.field);b.alias=T}return b})})}).then(A=>{var b;m((b=A==null?void 0:A.data)==null?void 0:b.data),!g&&(h!=null&&h["x-uid"])&&a(h==null?void 0:h["x-uid"],{collection:p,service:d,query:y})}).catch(x)}),{defaultParams:[n,r],ready:o&&(!s||!!l)});return R.jsx(z.MaybeCollectionProvider,{collection:n,children:R.jsx(gt.ConfigProvider,{card:{style:{boxShadow:"none"}},children:R.jsx(kn.Provider,{value:{collection:n,config:t,transform:i,service:d,query:r},children:e.children})})})};class xT{constructor(){Fr(this,"charts",new Map)}setGroup(r,t){this.charts.set(r,t)}addGroup(r,t){if(this.charts.has(r))throw new Error(`[data-visualization] Chart group "${r}" already exists`);this.setGroup(r,t)}add(r,t){var n;this.charts.has(r)||this.setGroup(r,[]),(n=this.charts.get(r))==null||n.push(t)}getChartTypes(){const r=[];this.charts.forEach((n,i)=>{const a=n.map(o=>({key:`${i}.${o.name}`,label:Et(o.title),value:`${i}.${o.name}`}));r.push({label:Et(i),children:a})});const t=r.findIndex(n=>n.label===Et("Built-in"));if(t>-1){const[n]=r.splice(t,1);r.unshift(n)}return r}getCharts(){const r={};return this.charts.forEach((t,n)=>{t.forEach(i=>{r[`${n}.${i.name}`]=i})}),r}getChart(r){return this.getCharts()[r]}}const b0=()=>z.usePlugin(Cv).charts.getChartTypes(),wT=()=>{var r,t,n;return(n=(t=(r=b0()[0])==null?void 0:r.children)==null?void 0:t[0])==null?void 0:n.value},E0=()=>z.usePlugin(Cv).charts.getCharts(),ST=e=>z.usePlugin(Cv).charts.getChart(e),{Paragraph:CT,Text:MT}=gt.Typography,kv=e=>{const{t:r}=jt(),t=D.useContext(kn),{config:n,transform:i,collection:a,service:o,data:l}=t,s=ia(a),u=T0(l,a),c=(n==null?void 0:n.general)||{},f=(n==null?void 0:n.advanced)||{},h=z.useAPIClient(),v=ST(n==null?void 0:n.chartType),d=h.auth.getLocale(),p=LT(i,d),y=v==null?void 0:v.render({data:u,general:c,advanced:f,fieldProps:Object.keys(u[0]||{}).reduce((m,x)=>{if(!m[x]){const w=Vu(s,x.split(".")),C=p[x];m[x]={label:(w==null?void 0:w.label)||x,transformer:C,interface:w==null?void 0:w.interface}}return m},{})}),g=()=>v?R.jsx(M0,{onError:m=>{console.error(m)},FallbackComponent:AT,children:R.jsx(y,{})}):R.jsx(gt.Empty,{image:gt.Empty.PRESENTED_IMAGE_SIMPLE,description:r("Please configure chart")});return o.loading?R.jsx(gt.Spin,{}):u&&u.length?R.jsx(g,{}):R.jsx(gt.Empty,{image:gt.Empty.PRESENTED_IMAGE_SIMPLE,description:r("Please configure and run query")})};kv.Designer=function(){const{t:r}=jt(),{setVisible:t,setCurrent:n}=D.useContext(Tn),{removeChart:i}=D.useContext(kl),{service:a}=D.useContext(kn),o=mt.useField(),l=mt.useFieldSchema(),{insertAdjacent:s}=z.useDesignable(),{name:u,title:c}=z.useCollection();return R.jsxs(z.GeneralSchemaDesigner,{disableInitializer:!0,title:c||u,children:[R.jsx(z.SchemaSettingsItem,{title:"Configure",onClick:()=>br(this,null,function*(){n({schema:l,field:o,collection:u,service:a,data:a.data}),t(!0)}),children:r("Configure")},"configure"),R.jsx(z.SchemaSettingsItem,{title:"Duplicate",onClick:()=>s("afterEnd",z.gridRowColWrap(A0(l==null?void 0:l["x-decorator-props"]))),children:r("Duplicate")},"duplicate"),R.jsx(z.SchemaSettingsBlockTitleItem,{}),R.jsx(z.SchemaSettingsDivider,{}),R.jsx(z.SchemaSettingsRemove,{breakRemoveOn:{"x-component":"ChartV2Block"},confirm:{onOk:()=>{i(l["x-uid"])}}})]})};const AT=({error:e})=>{const{t:r}=jt();return R.jsx("div",{style:{backgroundColor:"white"},children:R.jsx(gt.Result,{status:"error",title:r("Render Failed"),subTitle:r("Please check the configuration."),children:R.jsx(CT,{copyable:!0,children:R.jsx(MT,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:e.message})})})})},FT=e=>{const{current:r}=D.useContext(Tn);e||(e=(r==null?void 0:r.collection)||"");const{getCollectionFields:t}=z.useCollectionManager();return(t(e)||[]).filter(i=>i.interface).map(i=>{var a;return yt(J({},i),{key:i.name,label:((a=i.uiSchema)==null?void 0:a.title)||i.name,value:i.name})})},ia=e=>{const{getCollectionFields:r,getInterface:t}=z.useCollectionManager(),{t:n}=Av.useTranslation(),i=FT(e);return D.useMemo(()=>i.map(a=>{var u,c,f,h;const o=(u=t(a.interface))==null?void 0:u.filterable,l=mt.Schema.compile(((c=a.uiSchema)==null?void 0:c.title)||a.name,{t:n});if(!(o&&(o!=null&&o.nested||(f=o==null?void 0:o.children)!=null&&f.length)))return yt(J({},a),{label:l});let s=[];if(o!=null&&o.nested){const v=(r(a.target)||[]).filter(d=>d.interface).map(d=>{var p;return yt(J({},d),{key:`${a.name}.${d.name}`,label:`${l} / ${mt.Schema.compile(((p=d.uiSchema)==null?void 0:p.title)||d.name,{t:n})}`,value:`${a.name}.${d.name}`})});s=[...s,...v]}if((h=o==null?void 0:o.children)!=null&&h.length){const v=o.children.map(d=>{var p;return yt(J({},d),{key:`${a.name}.${d.name}`,label:`${l} / ${mt.Schema.compile(((p=d.schema)==null?void 0:p.title)||d.title||d.name,{t:n})}`,value:`${a.name}.${d.name}`})});s=[...s,...v]}return yt(J({},a),{label:l,targetFields:s})}),[i])},k0=e=>r=>{const t=r.query("query").get("value")||{},n=oo(e,t);r.dataSource=n},bT=e=>r=>{var a;const t=r.query(".field").get("value");if(!t){r.dataSource=[];return}let n=[];switch((a=Vu(e,t))==null?void 0:a.interface){case"datetime":case"createdAt":case"updatedAt":n=Fv.datetime;break;case"date":n=Fv.date;break;case"time":n=Fv.time;break;default:n=[]}r.dataSource=n},ET=()=>{const{t:e}=Av.useTranslation(),{collections:r}=z.useCollectionManager(),{allowAll:t,parseAction:n}=z.useACLRoleContext(),i=r.filter(a=>t?!0:n(`${a.name}:list`)).map(a=>({label:a.title,value:a.name,key:a.name}));return D.useMemo(()=>mt.Schema.compile(i,{t:e}),[i])},kT=(e,r)=>t=>{const n=t.query("query").get("value")||{},{measures:i=[]}=n;if(!i.some(l=>l.aggregation)){t.componentProps.fieldNames={label:"title",value:"name",children:"children"},t.dataSource=e;return}const o=oo(r,n);t.componentProps.fieldNames={},t.dataSource=o},TT=(e,r)=>t=>{const n=t.query("query").get("value")||{},{measures:i=[]}=n,a=i.some(c=>c.aggregation);let o=e;const l=[];a?(o=oo(r,n),o.forEach(c=>{l.push(c.value)})):o.forEach(c=>{const f=c.children||[];f.length||l.push(c.value||c.name),f.forEach(h=>{l.push(`${c.name}.${h.name}`)})});const u=(t.value||[]).reduce((c,f)=>{const{alias:h}=El(f.field);return(!f.field||l.includes(h))&&c.push(f),c},[]);t.setValue(u)},T0=(e,r)=>{var s;const{t}=jt(),{service:n,query:i}=D.useContext(kn),a=ia(r),o=mt.useForm(),l=oo(a,((s=o==null?void 0:o.values)==null?void 0:s.query)||i);return vT(l,(n==null?void 0:n.data)||e||[],{t})},Tv={datetime:{YYYY:e=>Ce(e).format("YYYY"),MM:e=>Ce(e).format("MM"),DD:e=>Ce(e).format("DD"),"YYYY-MM":e=>Ce(e).format("YYYY-MM"),"YYYY-MM-DD":e=>Ce(e).format("YYYY-MM-DD"),"YYYY-MM-DD hh:mm":e=>Ce(e).format("YYYY-MM-DD hh:mm"),"YYYY-MM-DD hh:mm:ss":e=>Ce(e).format("YYYY-MM-DD hh:mm:ss")},date:{YYYY:e=>Ce(e).format("YYYY"),MM:e=>Ce(e).format("MM"),DD:e=>Ce(e).format("DD"),"YYYY-MM":e=>Ce(e).format("YYYY-MM"),"YYYY-MM-DD":e=>Ce(e).format("YYYY-MM-DD")},time:{"hh:mm:ss":e=>Ce(e).format("hh:mm:ss"),"hh:mm":e=>Ce(e).format("hh:mm"),hh:e=>Ce(e).format("hh")},number:{Percent:e=>new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Currency:(e,r="en-US")=>{const t={"zh-CN":"CNY","en-US":"USD","ja-JP":"JPY","ko-KR":"KRW","pt-BR":"BRL","ru-RU":"RUB","tr-TR":"TRY","es-ES":"EUR"}[r];return new Intl.NumberFormat(r,{style:"currency",currency:t}).format(e)},Exponential:e=>(+e).toExponential(),Abbreviation:(e,r="en-US")=>new Intl.NumberFormat(r,{notation:"compact"}).format(e)}},IT=e=>r=>{const t=r.query(".field").get("value"),n=r.query("query").get("value")||{},a=oo(e,n).find(f=>f.value===t),o=Object.keys(Tv);r.dataSource=o.map(f=>({label:Et(f),value:f}));const l={createdAt:"datetime",updatedAt:"datetime",double:"number",integer:"number",percent:"number"},s=a==null?void 0:a.interface,u=a==null?void 0:a.type,c=l[s]||l[u]||u;if(o.includes(c)){r.setState({value:c,disabled:!0});return}r.setState({value:null,disabled:!1})},PT=e=>{const r=e.query(".type").get("value");if(!r){e.dataSource=[];return}const t=Object.keys(Tv[r]||{}).map(n=>({label:Et(n),value:n}));e.dataSource=t},LT=(e,r="en-US")=>(e||[]).filter(t=>t.field&&t.type&&t.format).reduce((t,n)=>{const i=Tv[n.type][n.format];return i&&(t[n.field]=a=>i(a,r)),t},{});function Iv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var OT=function(r){return DT(r)&&!BT(r)};function DT(e){return!!e&&typeof e=="object"}function BT(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||zT(e)}var RT=typeof Symbol=="function"&&Symbol.for,NT=RT?Symbol.for("react.element"):60103;function zT(e){return e.$$typeof===NT}function YT(e){return Array.isArray(e)?[]:{}}function Tl(e,r){return r.clone!==!1&&r.isMergeableObject(e)?lo(YT(e),e,r):e}function VT(e,r,t){return e.concat(r).map(function(n){return Tl(n,t)})}function _T(e,r){if(!r.customMerge)return lo;var t=r.customMerge(e);return typeof t=="function"?t:lo}function $T(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function I0(e){return Object.keys(e).concat($T(e))}function P0(e,r){try{return r in e}catch(t){return!1}}function GT(e,r){return P0(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function HT(e,r,t){var n={};return t.isMergeableObject(e)&&I0(e).forEach(function(i){n[i]=Tl(e[i],t)}),I0(r).forEach(function(i){GT(e,i)||(P0(e,i)&&t.isMergeableObject(r[i])?n[i]=_T(i,t)(e[i],r[i],t):n[i]=Tl(r[i],t))}),n}function lo(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||VT,t.isMergeableObject=t.isMergeableObject||OT,t.cloneUnlessOtherwiseSpecified=Tl;var n=Array.isArray(r),i=Array.isArray(e),a=n===i;return a?n?t.arrayMerge(e,r,t):HT(e,r,t):Tl(r,t)}lo.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(n,i){return lo(n,i,t)},{})};var WT=lo,XT=WT;const jT=Iv(XT),L0=()=>{const{charts:e}=D.useContext(kl);return{getChartCollections:()=>Array.from(new Set(Object.values(e).filter(t=>t).map(t=>t.collection)))}},so=()=>{const{charts:e}=D.useContext(kl),{fieldSchema:r}=z.useActionContext(),t=r==null?void 0:r["x-action"],{getCollection:n,getInterface:i,getCollectionFields:a,getCollectionJoinField:o}=z.useCollectionManager(),{fields:l,form:s}=D.useContext(_r),u=y=>{const g=a(y),m=(A,b,T)=>{var L,H,N,_,$;const k=((L=A.uiSchema)==null?void 0:L.title)||A.name,P=i(A.interface),O=(N=(H=P==null?void 0:P.filterable)==null?void 0:H.operators)==null?void 0:N[0],V=n(A.target);b=b?`${b} / ${k}`:k;let W={type:"string",title:b,name:`${T}.${A.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-component":"CollectionField","x-decorator":"ChartFilterFormItem","x-collection-field":`${T}.${A.name}`,"x-component-props":yt(J({},(_=A.uiSchema)==null?void 0:_["x-component-props"]),{"filter-operator":O})};if(A.interface==="formula"){const X=pT(A.dataType)||"Input";W=yt(J({},W),{"x-component":X})}return["oho","o2m"].includes(A.interface)&&(W["x-component-props"].useOriginalFilter=!0),{key:`${T}.${A.name}`,name:A.name,type:"item",title:(($=A==null?void 0:A.uiSchema)==null?void 0:$.title)||A.name,Component:"CollectionFieldInitializer",remove:(X,K)=>{K(X,{breakRemoveOn:{"x-component":"Grid"}})},schemaInitialize:X=>{var K;(K=P==null?void 0:P.schemaInitialize)==null||K.call(P,X,{field:A,block:"FilterForm",readPretty:s.readPretty,action:t,targetCollection:V})},schema:W}},x=(A,b,T)=>{var W;const k=((W=A.uiSchema)==null?void 0:W.title)||A.name;b=b?`${b} / ${k}`:k;const P=A.operators[0];let O=yt(J({type:"string",name:`${T}.${A.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-decorator":"ChartFilterFormItem","x-collection-field":`${T}.${A.name}`},A.schema),{title:b,"x-component-props":{"filter-operator":P}});return P!=null&&P.noValue&&(O=yt(J({},O),{"x-component":"ChartFilterCheckbox","x-component-props":yt(J({},O["x-component-props"]),{content:mt.Schema.compile(P.label,{t:z.i18n.t})})})),{key:`${T}.${A.name}`,name:A.name,type:"item",title:A.title||A.name,Component:"CollectionFieldInitializer",remove:(q,L)=>{L(q,{breakRemoveOn:{"x-component":"Grid"}})},schema:O}},w=(A,b,T,k)=>{var L,H,N;if(!A.interface)return;const P=i(A.interface);if(!(P!=null&&P.filterable))return;const{nested:O,children:V}=P.filterable,W=((L=A.uiSchema)==null?void 0:L.title)||A.name,q=m(A,T,k);if(!(A.target&&b>2)){if(T=T?`${T} / ${W}`:W,V!=null&&V.length&&!["chinaRegion","createdBy","updatedBy"].includes(A.interface)){const _=V.map($=>x($,T,`${k}.${A.name}`));return{key:`${k}.${A.name}`,name:A.name,type:"subMenu",title:((H=A==null?void 0:A.uiSchema)==null?void 0:H.title)||A.name,children:_}}if(!b||b>2)return q;if(O){const $=a(A.target).map(X=>w(X,b+1,"",`${k}.${A.name}`));return{key:`${k}.${A.name}`,name:A.name,type:"subMenu",title:((N=A==null?void 0:A.uiSchema)==null?void 0:N.title)||A.name,children:$.filter(Boolean)}}return q}},C=[],M=[];return g.forEach(A=>{const b=A.interface,T=w(A,0,"",y.name);if(T&&C.push(T),["m2o"].includes(b)){const k=w(A,1,"",y.name);k&&M.push(k)}}),M.length&&C.push({name:"divider",type:"divider"},{name:"displayAssociationFields",type:"itemGroup",title:z.i18n.t("Display association fields"),children:M}),C},c=()=>{const y=(s==null?void 0:s.values)||{},g={};return Object.entries(l).forEach(([m,x])=>{const{operator:w}=x||{},C=o(m);C!=null&&C.target&&(m=`${m}.${C.targetKey||"id"}`);const[M,...A]=m.split("."),b=dT(y,m),T=(w==null?void 0:w.value)||"$eq";if(M!=="custom"){g[M]=g[M]||{$and:[]};const k={};He.set(k,A.join("."),{[T]:b}),g[M].$and.push(k)}else g[M]=g[M]||{},g[M][`$nFilter.${A.join(".")}`]=b}),g},f=(y,g)=>{const{collection:m,query:x}=y,{parameters:w}=bl.parse(x.filter||"");return y&&(g[m]||g.custom&&(w==null?void 0:w.find(C=>g.custom[C.key])))},h=(y,g)=>{const{collection:m,query:x}=y;let w=J({},x);const C=J({},w.filter||{});let M={};const A=bl.parse(C),{parameters:b}=A;return g.custom&&(b!=null&&b.find(T=>g.custom[T.key]))&&(M=A(g.custom)),M=jT(C,M),w=yt(J({},w),{filter:{$and:[M,g[m]]}}),w},v=()=>br(this,null,function*(){const y=c(),g=Object.values(e).filter(m=>f(m,y)).map(m=>()=>br(this,null,function*(){const{service:x,collection:w}=m;yield x.runAsync(w,h(m,y),!0)}));yield Promise.all(g.map(m=>m()))}),d=()=>br(this,null,function*(){const y=Object.values(e).filter(g=>g).map(g=>()=>br(this,null,function*(){const{service:m,collection:x,query:w}=g;yield m.runAsync(x,w,!0)}));yield Promise.all(y.map(g=>g()))}),p=ln.useMemoizedFn(y=>y.split(" / ").map(g=>z.i18n.t(mt.Schema.compile(g,{t:z.i18n.t}))).join(" / "));return{filter:v,refresh:d,getChartFilterFields:u,getFilter:c,hasFilter:f,appendFilter:h,getTranslatedTitle:p}},UT=()=>{const{t:e}=jt(),r=ln.useMemoizedFn(e),{enabled:t,fields:n}=D.useContext(_r),i=Object.entries(n).filter(([o,l])=>o.startsWith("custom.")&&l).map(([o,{title:l}])=>{const s=o.replace(/^custom\./,"");return{key:s,value:s,label:l}}),a=D.useMemo(()=>({label:r("Current filter"),value:"$nFilter",key:"$nFilter",children:i}),[i,r]);return!t||!i.length?null:a},O0=()=>{const{t:e}=jt(),{getChartCollections:r}=L0(),{getInterface:t,getCollectionFields:n,getCollection:i}=z.useCollectionManager(),{values:a}=D0(),o=(s,u)=>{var v,d,p;if(!s.interface)return;const c=t(s.interface);if(!(c!=null&&c.filterable))return;const{nested:f}=c.filterable,h={value:s.name,label:e(((v=s==null?void 0:s.uiSchema)==null?void 0:v.title)||s.name)};if(!(s.target&&u>2)){if(u>2)return h;if(f){const g=n(s.target).map(m=>o(m,u+1));return{value:s.name,label:e(((d=s==null?void 0:s.uiSchema)==null?void 0:d.title)||s.name),children:g.filter(m=>m)}}if(!(!a.includes((p=s.uiSchema)==null?void 0:p["x-component"])&&!a.includes(s.interface)))return h}},l=r();return D.useMemo(()=>{const s=[];return l.forEach(u=>{const c=i(u),f=[];n(c).forEach(v=>{const d=o(v,1);d&&f.push(d)}),f.length&&s.push({value:u,label:e(c.title),children:f})}),s},[l])},D0=()=>{const{t:e}=jt(),r=[{label:e("Input"),value:"Input"},{label:e("Number"),value:"InputNumber"},{label:e("Date"),value:"DatePicker"},{label:e("Date range"),value:"DatePicker.RangePicker"},{label:e("Time"),value:"TimePicker"},{label:e("Time range"),value:"TimePicker.RangePicker"},{label:e("Select"),value:"Select"},{label:e("Radio group"),value:"Radio.Group"},{label:e("Checkbox group"),value:"Checkbox.Group"}];return{options:r,values:r.map(t=>t.value)}},qT=e=>{const{getCollection:r,getCollectionField:t}=z.useCollectionManager();return D.useMemo(()=>{var u;if(!e)return;const[n,...i]=e.split(".");if(!(i!=null&&i.length))return;const a=r(n);let o=n,l,s=mt.Schema.compile(a==null?void 0:a.title,{t:z.i18n.t});for(;o&&i.length>0;){const c=i.shift();l=t(`${o}.${c}`);const f=((u=l==null?void 0:l.uiSchema)==null?void 0:u.title)||(l==null?void 0:l.name);f&&(s+=` / ${mt.Schema.compile(f,{t:z.i18n.t})}`),l!=null&&l.target?o=l.target:o=null}return s},[e])},ZT=()=>{const e=mt.useField(),{operator:r,schema:t}=e.data||{},n=z.useUserVariable({collectionField:{uiSchema:t},uiSchema:t}),i=z.useDateVariable({operator:r,schema:t}),a=UT(),o=D.useMemo(()=>[n,i,a].filter(Boolean),[i,n,a]);return!r||!t?[]:o},_u=(e={},r={})=>yt(J({type:"array","x-decorator":"FormItem","x-component":"ArrayItems"},r),{items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:yt(J({sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"}},e),{remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}})}}},properties:{add:{type:"void",title:'{{t("Add field")}}',"x-component":"ArrayItems.Addition"}}}),QT=e=>({type:"void",properties:{config:{type:"object",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 }}"},[na.uid()]:{type:"void",properties:{general:e}},[na.uid()]:{type:"void",properties:{advanced:{type:"json",title:'{{t("JSON config")}}',"x-decorator":"FormItem","x-decorator-props":{extra:Et("Same properties set in the form above will be overwritten by this JSON config.")},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:3}}}}},reference:{type:"string","x-reactions":{dependencies:[".chartType"],fulfill:{schema:{"x-content":"{{ getReference($deps[0]) }}"}}}}}}}}),KT={type:"void",properties:{settings:{type:"void",properties:{collection:{title:'{{t("Collection")}}',type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{ collectionOptions }}",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}}"},properties:{pane1:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:Et("Measures"),key:"measures"},properties:{measures:_u({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"}}}},{required:!0,"x-component-props":{style:{overflow:"auto"}}})}},pane2:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:Et("Dimensions"),key:"dimensions"},properties:{dimensions:_u({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:Et("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:Et("Sort"),key:"sort"},properties:{orders:_u({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"}}}}}}}}},JT={type:"void",properties:{transform:_u({field:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Field")}}',style:{maxWidth:"100px"}},"x-reactions":"{{ useChartFields }}"},type:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Type")}}'},"x-reactions":"{{ useFieldTypeOptions }}"},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Format")}}'},"x-reactions":"{{ useTransformers }}","x-visible":"{{ $self.dataSource && $self.dataSource.length }}"}},{"x-decorator-props":{style:{width:"50%"}}})}};function tI(e){const{value:r,onChange:t,renderSchemaComponent:n}=e,i=ZT();return R.jsx(z.Variable.Input,{value:r,onChange:t,scope:i,children:n()})}const Tn=D.createContext({visible:!0}),eI=e=>{var l;const{insertAdjacent:r}=z.useDesignable(),[t,n]=D.useState(!1),[i,a]=D.useState({}),{token:o}=gt.theme.useToken();return R.jsxs(Tn.Provider,{value:{visible:t,setVisible:n,current:i,setCurrent:a},children:[R.jsx("div",{className:ao.css`
|
|
1
|
+
(function(dt,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("ahooks"),require("@nocobase/utils/client"),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","ahooks","@nocobase/utils/client","@emotion/css"],z):(dt=typeof globalThis!="undefined"?globalThis:dt||self,z(dt["@nocobase/plugin-data-visualization"]={},dt["@nocobase/client"],dt.jsxRuntime,dt.react,dt["@ant-design/icons"],dt["@formily/antd-v5"],dt["@formily/core"],dt["@formily/react"],dt.antd,dt.lodash,dt["react-i18next"],dt.dayjs,dt["@formily/shared"],dt.ahooks,dt["@nocobase/utils"],dt["@emotion/css"]))})(this,function(dt,z,R,D,ni,Ie,on,mt,gt,He,Av,Ce,na,ln,bl,ao){"use strict";var E7=Object.defineProperty,k7=Object.defineProperties;var T7=Object.getOwnPropertyDescriptors;var Mv=Object.getOwnPropertySymbols;var lT=Object.prototype.hasOwnProperty,sT=Object.prototype.propertyIsEnumerable;var S0=(dt,z,R)=>z in dt?E7(dt,z,{enumerable:!0,configurable:!0,writable:!0,value:R}):dt[z]=R,J=(dt,z)=>{for(var R in z||(z={}))lT.call(z,R)&&S0(dt,R,z[R]);if(Mv)for(var R of Mv(z))sT.call(z,R)&&S0(dt,R,z[R]);return dt},yt=(dt,z)=>k7(dt,T7(z));var uT=(dt,z)=>{var R={};for(var D in dt)lT.call(dt,D)&&z.indexOf(D)<0&&(R[D]=dt[D]);if(dt!=null&&Mv)for(var D of Mv(dt))z.indexOf(D)<0&&sT.call(dt,D)&&(R[D]=dt[D]);return R};var Fr=(dt,z,R)=>(S0(dt,typeof z!="symbol"?z+"":z,R),R);var br=(dt,z,R)=>new Promise((D,ni)=>{var Ie=gt=>{try{mt(R.next(gt))}catch(He){ni(He)}},on=gt=>{try{mt(R.throw(gt))}catch(He){ni(He)}},mt=gt=>gt.done?D(gt.value):Promise.resolve(gt.value).then(Ie,on);mt((R=R.apply(dt,z)).next())});function cT(e,r){for(var t=0;t<r.length;t++){const n=r[t];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(n,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const zu=Object.freeze(Object.defineProperty({__proto__:null,get Base(){return qr},get Circle(){return Zz},get Ellipse(){return Qz},get Image(){return Kz},get Line(){return Jz},get Marker(){return e5},get Path(){return Ip},get Polygon(){return s5},get Polyline(){return u5},get Rect(){return h5},get Text(){return v5}},Symbol.toStringTag,{value:"Module"})),Yu=Object.freeze(Object.defineProperty({__proto__:null,get Base(){return Pr},get Circle(){return w5},get Dom(){return S5},get Ellipse(){return C5},get Image(){return M5},get Line(){return A5},get Marker(){return F5},get Path(){return b5},get Polygon(){return E5},get Polyline(){return k5},get Rect(){return I5},get Text(){return D5}},Symbol.toStringTag,{value:"Module"})),C0="data-visualization";function Et(e){return z.i18n.t(e,{ns:[C0,"client"]})}function jt(){return Av.useTranslation([C0,"client"],{nsMode:"fallback"})}const Fv={datetime:[{label:Et("YYYY"),value:"YYYY"},{label:Et("MM"),value:"MM"},{label:Et("DD"),value:"DD"},{label:Et("YYYY-MM"),value:"YYYY-MM"},{label:Et("YYYY-MM-DD"),value:"YYYY-MM-DD"},{label:Et("YYYY-MM-DD hh:mm"),value:"YYYY-MM-DD hh:mm"},{label:Et("YYYY-MM-DD hh:mm:ss"),value:"YYYY-MM-DD hh:mm:ss"}],date:[{label:Et("YYYY"),value:"YYYY"},{label:Et("MM"),value:"MM"},{label:Et("DD"),value:"DD"},{label:Et("YYYY-MM"),value:"YYYY-MM"},{label:Et("YYYY-MM-DD"),value:"YYYY-MM-DD"}],time:[{label:Et("hh:mm:ss"),value:"hh:mm:ss"},{label:Et("hh:mm"),value:"hh:mm"},{label:Et("hh"),value:"hh"}]},fT=D.createContext(null),bv={didCatch:!1,error:null};let M0=class extends D.Component{constructor(r){super(r),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=bv}static getDerivedStateFromError(r){return{didCatch:!0,error:r}}resetErrorBoundary(){const{error:r}=this.state;if(r!==null){for(var t,n,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];(t=(n=this.props).onReset)===null||t===void 0||t.call(n,{args:a,reason:"imperative-api"}),this.setState(bv)}}componentDidCatch(r,t){var n,i;(n=(i=this.props).onError)===null||n===void 0||n.call(i,r,t)}componentDidUpdate(r,t){const{didCatch:n}=this.state,{resetKeys:i}=this.props;if(n&&t.error!==null&&hT(r.resetKeys,i)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:i,prev:r.resetKeys,reason:"keys"}),this.setState(bv)}}render(){const{children:r,fallbackRender:t,FallbackComponent:n,fallback:i}=this.props,{didCatch:a,error:o}=this.state;let l=r;if(a){const s={error:o,resetErrorBoundary:this.resetErrorBoundary};if(D.isValidElement(i))l=i;else if(typeof t=="function")l=t(s);else if(n)l=D.createElement(n,s);else throw o}return D.createElement(fT.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},l)}};function hT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==r.length||e.some((t,n)=>!Object.is(t,r[n]))}const A0=(e,r={})=>{const{collection:t}=e;return{type:"void","x-decorator":"ChartRendererProvider","x-decorator-props":e,"x-acl-action":`${t}:list`,"x-designer":"ChartRenderer.Designer","x-component":"CardItem","x-component-props":{size:"small"},"x-initializer":"ChartInitializers",properties:{[na.uid()]:{type:"void","x-component":"ChartRenderer","x-component-props":r}}}},El=e=>{let r,t;return Array.isArray(e)?e.length===1?t=e[0]:e.length>1&&([r,t]=e):t=e,{target:r,name:t,alias:r?`${r}.${t}`:t}},Vu=(e,r)=>{var a,o;const{target:t,name:n}=El(r);return t?(o=(a=e.find(l=>l.name===t))==null?void 0:a.targetFields)==null?void 0:o.find(l=>l.name===n):e.find(l=>l.name===n)},oo=(e,r)=>{const t=l=>l.map(s=>{const u=Vu(e,s.field);return yt(J({},u),{key:s.alias||(u==null?void 0:u.key),label:s.alias||(u==null?void 0:u.label),value:s.alias||(u==null?void 0:u.value)})}),n=r.measures||[],i=r.dimensions||[];return[...new Map([...t(n),...t(i)].map(l=>[l.value,l])).values()]},vT=(e,r,t)=>{const n=(i,a)=>{var s;const o=(s=i.uiSchema)==null?void 0:s.enum;if(!o||!Array.isArray(o))return a;const l=o.find(u=>u.value===a);return mt.Schema.compile((l==null?void 0:l.label)||a,t)};return r.map(i=>{const a={};return Object.entries(i).forEach(([o,l])=>{const s=e.find(u=>u.value===o);if(!s){a[o]=l;return}switch(s.interface){case"select":case"radioGroup":a[o]=n(s,l);break;default:a[o]=l}}),a})},Ev=e=>{if(typeof e=="object"&&e!==null)if(Array.isArray(e)){const r=e.map(t=>Ev(t)).filter(Boolean);return r.length>0?r:null}else{const r={};for(const t in e){const n=Ev(e[t]);n!=null&&!(typeof n=="object"&&Object.keys(n).length===0)&&(r[t]=n)}return Object.keys(r).length>0?r:null}else if(typeof e=="string"&&e.startsWith("{{$nFilter.")&&e.endsWith("}}"))return null;return e},dT=(e,r)=>{const t=r.split(".");let n=He.get(e,t.slice(0,-1).join("."));return Array.isArray(n)?n=n.map(i=>He.get(i,t.slice(-1)[0])):n=He.get(n,t.slice(-1)[0]),n},pT=e=>({boolean:"Checkbox",integer:"InputNumber",bigInt:"InputNumber",double:"InputNumber",decimal:"InputNumber",date:"DatePicker",string:"Input"})[e],gT=e=>({boolean:"boolean",integer:"integer",bigInt:"integer",double:"number",decimal:"number",date:"datetime",string:"input"})[e],kl=D.createContext({}),yT=e=>{const[r,t]=D.useState({}),n=ln.useMemoizedFn((a,{collection:o,service:l,query:s})=>{t(u=>yt(J({},u),{[a]:{collection:o,service:l,query:s}}))}),i=ln.useMemoizedFn(a=>{t(o=>yt(J({},o),{[a]:void 0}))});return R.jsx(kl.Provider,{value:{charts:r,addChart:n,removeChart:i},children:e.children})},_r=D.createContext({}),mT=e=>{const[r,t]=D.useState(!1),[n,i]=D.useState(!1),[a,o]=D.useState({}),[l,s]=D.useState({collapsed:!1,row:1}),[u,c]=D.useState(),f=ln.useMemoizedFn((y,g)=>{o(m=>yt(J({},m),{[y]:J(J({},m[y]||{}),g)}))}),h=ln.useMemoizedFn(y=>{o(g=>{const m=J({},g);return m[y]=void 0,m})}),v=ln.useMemoizedFn(c),d=ln.useMemoizedFn(i),p=({collapsed:y,row:g})=>{s(m=>({collapsed:y!==void 0?y:m.collapsed,row:g!==void 0?g:m.row}))};return D.useEffect(()=>t(!0),[]),R.jsx(_r.Provider,{value:{ready:r,enabled:n,setEnabled:d,fields:a,setField:f,removeField:h,collapse:l,setCollapse:p,form:u,setForm:v},children:e.children})},kn=D.createContext({}),F0=e=>{const{query:r,config:t,collection:n,transform:i}=e,{addChart:a}=D.useContext(kl),{ready:o,form:l,enabled:s}=D.useContext(_r),{getFilter:u,hasFilter:c,appendFilter:f}=so(),h=mt.useFieldSchema(),v=z.useAPIClient(),d=z.useRequest((p,y,g)=>new Promise((m,x)=>{var M;if(!(p&&((M=y==null?void 0:y.measures)!=null&&M.length))||s&&!l)return m(void 0);const w=u(),C=!g&&c({collection:p,query:y},w)?f({collection:p,query:y},w):y;v.request({url:"charts:query",method:"POST",data:yt(J({uid:h==null?void 0:h["x-uid"],collection:p},C),{filter:Ev(C.filter),dimensions:((y==null?void 0:y.dimensions)||[]).map(A=>{const b=J({},A);if(A.format&&!A.alias){const{alias:T}=El(A.field);b.alias=T}return b}),measures:((y==null?void 0:y.measures)||[]).map(A=>{const b=J({},A);if(A.aggregation&&!A.alias){const{alias:T}=El(A.field);b.alias=T}return b})})}).then(A=>{var b;m((b=A==null?void 0:A.data)==null?void 0:b.data),!g&&(h!=null&&h["x-uid"])&&a(h==null?void 0:h["x-uid"],{collection:p,service:d,query:y})}).catch(x)}),{defaultParams:[n,r],ready:o&&(!s||!!l)});return R.jsx(z.MaybeCollectionProvider,{collection:n,children:R.jsx(gt.ConfigProvider,{card:{style:{boxShadow:"none"}},children:R.jsx(kn.Provider,{value:{collection:n,config:t,transform:i,service:d,query:r},children:e.children})})})};class xT{constructor(){Fr(this,"charts",new Map)}setGroup(r,t){this.charts.set(r,t)}addGroup(r,t){if(this.charts.has(r))throw new Error(`[data-visualization] Chart group "${r}" already exists`);this.setGroup(r,t)}add(r,t){var n;this.charts.has(r)||this.setGroup(r,[]),(n=this.charts.get(r))==null||n.push(t)}getChartTypes(){const r=[];this.charts.forEach((n,i)=>{const a=n.map(o=>({key:`${i}.${o.name}`,label:Et(o.title),value:`${i}.${o.name}`}));r.push({label:Et(i),children:a})});const t=r.findIndex(n=>n.label===Et("Built-in"));if(t>-1){const[n]=r.splice(t,1);r.unshift(n)}return r}getCharts(){const r={};return this.charts.forEach((t,n)=>{t.forEach(i=>{r[`${n}.${i.name}`]=i})}),r}getChart(r){return this.getCharts()[r]}}const b0=()=>z.usePlugin(Cv).charts.getChartTypes(),wT=()=>{var r,t,n;return(n=(t=(r=b0()[0])==null?void 0:r.children)==null?void 0:t[0])==null?void 0:n.value},E0=()=>z.usePlugin(Cv).charts.getCharts(),ST=e=>z.usePlugin(Cv).charts.getChart(e),{Paragraph:CT,Text:MT}=gt.Typography,kv=e=>{const{t:r}=jt(),t=D.useContext(kn),{config:n,transform:i,collection:a,service:o,data:l}=t,s=ia(a),u=T0(l,a),c=(n==null?void 0:n.general)||{},f=(n==null?void 0:n.advanced)||{},h=z.useAPIClient(),v=ST(n==null?void 0:n.chartType),d=h.auth.getLocale(),p=LT(i,d),y=v==null?void 0:v.render({data:u,general:c,advanced:f,fieldProps:Object.keys(u[0]||{}).reduce((m,x)=>{if(!m[x]){const w=Vu(s,x.split(".")),C=p[x];m[x]={label:(w==null?void 0:w.label)||x,transformer:C,interface:w==null?void 0:w.interface}}return m},{})}),g=()=>v?R.jsx(M0,{onError:m=>{console.error(m)},FallbackComponent:AT,children:R.jsx(y,{})}):R.jsx(gt.Empty,{image:gt.Empty.PRESENTED_IMAGE_SIMPLE,description:r("Please configure chart")});return o.loading?R.jsx(gt.Spin,{}):u&&u.length?R.jsx(g,{}):R.jsx(gt.Empty,{image:gt.Empty.PRESENTED_IMAGE_SIMPLE,description:r("Please configure and run query")})};kv.Designer=function(){const{t:r}=jt(),{setVisible:t,setCurrent:n}=D.useContext(Tn),{removeChart:i}=D.useContext(kl),{service:a}=D.useContext(kn),o=mt.useField(),l=mt.useFieldSchema(),{insertAdjacent:s}=z.useDesignable(),{name:u,title:c}=z.useCollection();return R.jsxs(z.GeneralSchemaDesigner,{disableInitializer:!0,title:c||u,children:[R.jsx(z.SchemaSettingsItem,{title:"Configure",onClick:()=>br(this,null,function*(){n({schema:l,field:o,collection:u,service:a,data:a.data}),t(!0)}),children:r("Configure")},"configure"),R.jsx(z.SchemaSettingsItem,{title:"Duplicate",onClick:()=>s("afterEnd",z.gridRowColWrap(A0(l==null?void 0:l["x-decorator-props"]))),children:r("Duplicate")},"duplicate"),R.jsx(z.SchemaSettingsBlockTitleItem,{}),R.jsx(z.SchemaSettingsDivider,{}),R.jsx(z.SchemaSettingsRemove,{breakRemoveOn:{"x-component":"ChartV2Block"},confirm:{onOk:()=>{i(l["x-uid"])}}})]})};const AT=({error:e})=>{const{t:r}=jt();return R.jsx("div",{style:{backgroundColor:"white"},children:R.jsx(gt.Result,{status:"error",title:r("Render Failed"),subTitle:r("Please check the configuration."),children:R.jsx(CT,{copyable:!0,children:R.jsx(MT,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:e.message})})})})},FT=e=>{const{current:r}=D.useContext(Tn);e||(e=(r==null?void 0:r.collection)||"");const{getCollectionFields:t}=z.useCollectionManager();return(t(e)||[]).filter(i=>i.interface).map(i=>{var a;return yt(J({},i),{key:i.name,label:((a=i.uiSchema)==null?void 0:a.title)||i.name,value:i.name})})},ia=e=>{const{getCollectionFields:r,getInterface:t}=z.useCollectionManager(),{t:n}=Av.useTranslation(),i=FT(e);return D.useMemo(()=>i.map(a=>{var u,c,f,h;const o=(u=t(a.interface))==null?void 0:u.filterable,l=mt.Schema.compile(((c=a.uiSchema)==null?void 0:c.title)||a.name,{t:n});if(!(o&&(o!=null&&o.nested||(f=o==null?void 0:o.children)!=null&&f.length)))return yt(J({},a),{label:l});let s=[];if(o!=null&&o.nested){const v=(r(a.target)||[]).filter(d=>d.interface).map(d=>{var p;return yt(J({},d),{key:`${a.name}.${d.name}`,label:`${l} / ${mt.Schema.compile(((p=d.uiSchema)==null?void 0:p.title)||d.name,{t:n})}`,value:`${a.name}.${d.name}`})});s=[...s,...v]}if((h=o==null?void 0:o.children)!=null&&h.length){const v=o.children.map(d=>{var p;return yt(J({},d),{key:`${a.name}.${d.name}`,label:`${l} / ${mt.Schema.compile(((p=d.schema)==null?void 0:p.title)||d.title||d.name,{t:n})}`,value:`${a.name}.${d.name}`})});s=[...s,...v]}return yt(J({},a),{label:l,targetFields:s})}),[i])},k0=e=>r=>{const t=r.query("query").get("value")||{},n=oo(e,t);r.dataSource=n},bT=e=>r=>{var a;const t=r.query(".field").get("value");if(!t){r.dataSource=[];return}let n=[];switch((a=Vu(e,t))==null?void 0:a.interface){case"datetime":case"createdAt":case"updatedAt":n=Fv.datetime;break;case"date":n=Fv.date;break;case"time":n=Fv.time;break;default:n=[]}r.dataSource=n},ET=()=>{const{t:e}=Av.useTranslation(),{collections:r}=z.useCollectionManager(),{allowAll:t,parseAction:n}=z.useACLRoleContext(),i=r.filter(a=>t?!0:n(`${a.name}:list`)).map(a=>({label:a.title,value:a.name,key:a.name}));return D.useMemo(()=>mt.Schema.compile(i,{t:e}),[i])},kT=(e,r)=>t=>{const n=t.query("query").get("value")||{},{measures:i=[]}=n;if(!i.some(l=>l.aggregation)){t.componentProps.fieldNames={label:"title",value:"name",children:"children"},t.dataSource=e;return}const o=oo(r,n);t.componentProps.fieldNames={},t.dataSource=o},TT=(e,r)=>t=>{const n=t.query("query").get("value")||{},{measures:i=[]}=n,a=i.some(c=>c.aggregation);let o=e;const l=[];a?(o=oo(r,n),o.forEach(c=>{l.push(c.value)})):o.forEach(c=>{const f=c.children||[];f.length||l.push(c.value||c.name),f.forEach(h=>{l.push(`${c.name}.${h.name}`)})});const u=(t.value||[]).reduce((c,f)=>{const{alias:h}=El(f.field);return(!f.field||l.includes(h))&&c.push(f),c},[]);t.setValue(u)},T0=(e,r)=>{var s;const{t}=jt(),{service:n,query:i}=D.useContext(kn),a=ia(r),o=mt.useForm(),l=oo(a,((s=o==null?void 0:o.values)==null?void 0:s.query)||i);return vT(l,(n==null?void 0:n.data)||e||[],{t})},Tv={datetime:{YYYY:e=>Ce(e).format("YYYY"),MM:e=>Ce(e).format("MM"),DD:e=>Ce(e).format("DD"),"YYYY-MM":e=>Ce(e).format("YYYY-MM"),"YYYY-MM-DD":e=>Ce(e).format("YYYY-MM-DD"),"YYYY-MM-DD hh:mm":e=>Ce(e).format("YYYY-MM-DD hh:mm"),"YYYY-MM-DD hh:mm:ss":e=>Ce(e).format("YYYY-MM-DD hh:mm:ss")},date:{YYYY:e=>Ce(e).format("YYYY"),MM:e=>Ce(e).format("MM"),DD:e=>Ce(e).format("DD"),"YYYY-MM":e=>Ce(e).format("YYYY-MM"),"YYYY-MM-DD":e=>Ce(e).format("YYYY-MM-DD")},time:{"hh:mm:ss":e=>Ce(e).format("hh:mm:ss"),"hh:mm":e=>Ce(e).format("hh:mm"),hh:e=>Ce(e).format("hh")},number:{Percent:e=>new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Currency:(e,r="en-US")=>{const t={"zh-CN":"CNY","en-US":"USD","ja-JP":"JPY","ko-KR":"KRW","pt-BR":"BRL","ru-RU":"RUB","tr-TR":"TRY","es-ES":"EUR"}[r];return new Intl.NumberFormat(r,{style:"currency",currency:t}).format(e)},Exponential:e=>(+e).toExponential(),Abbreviation:(e,r="en-US")=>new Intl.NumberFormat(r,{notation:"compact"}).format(e)}},IT=e=>r=>{const t=r.query(".field").get("value"),n=r.query("query").get("value")||{},a=oo(e,n).find(f=>f.value===t),o=Object.keys(Tv);r.dataSource=o.map(f=>({label:Et(f),value:f}));const l={createdAt:"datetime",updatedAt:"datetime",double:"number",integer:"number",percent:"number"},s=a==null?void 0:a.interface,u=a==null?void 0:a.type,c=l[s]||l[u]||u;if(o.includes(c)){r.setState({value:c,disabled:!0});return}r.setState({value:null,disabled:!1})},PT=e=>{const r=e.query(".type").get("value");if(!r){e.dataSource=[];return}const t=Object.keys(Tv[r]||{}).map(n=>({label:Et(n),value:n}));e.dataSource=t},LT=(e,r="en-US")=>(e||[]).filter(t=>t.field&&t.type&&t.format).reduce((t,n)=>{const i=Tv[n.type][n.format];return i&&(t[n.field]=a=>i(a,r)),t},{});function Iv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var OT=function(r){return DT(r)&&!BT(r)};function DT(e){return!!e&&typeof e=="object"}function BT(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||zT(e)}var RT=typeof Symbol=="function"&&Symbol.for,NT=RT?Symbol.for("react.element"):60103;function zT(e){return e.$$typeof===NT}function YT(e){return Array.isArray(e)?[]:{}}function Tl(e,r){return r.clone!==!1&&r.isMergeableObject(e)?lo(YT(e),e,r):e}function VT(e,r,t){return e.concat(r).map(function(n){return Tl(n,t)})}function _T(e,r){if(!r.customMerge)return lo;var t=r.customMerge(e);return typeof t=="function"?t:lo}function $T(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function I0(e){return Object.keys(e).concat($T(e))}function P0(e,r){try{return r in e}catch(t){return!1}}function GT(e,r){return P0(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function HT(e,r,t){var n={};return t.isMergeableObject(e)&&I0(e).forEach(function(i){n[i]=Tl(e[i],t)}),I0(r).forEach(function(i){GT(e,i)||(P0(e,i)&&t.isMergeableObject(r[i])?n[i]=_T(i,t)(e[i],r[i],t):n[i]=Tl(r[i],t))}),n}function lo(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||VT,t.isMergeableObject=t.isMergeableObject||OT,t.cloneUnlessOtherwiseSpecified=Tl;var n=Array.isArray(r),i=Array.isArray(e),a=n===i;return a?n?t.arrayMerge(e,r,t):HT(e,r,t):Tl(r,t)}lo.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(n,i){return lo(n,i,t)},{})};var WT=lo,XT=WT;const jT=Iv(XT),L0=()=>{const{charts:e}=D.useContext(kl);return{getChartCollections:()=>Array.from(new Set(Object.values(e).filter(t=>t).map(t=>t.collection)))}},so=()=>{const{charts:e}=D.useContext(kl),{fieldSchema:r}=z.useActionContext(),t=r==null?void 0:r["x-action"],{getCollection:n,getInterface:i,getCollectionFields:a,getCollectionJoinField:o}=z.useCollectionManager(),{fields:l,form:s}=D.useContext(_r),u=y=>{const g=a(y),m=(A,b,T)=>{var L,H,N,_,$;const k=((L=A.uiSchema)==null?void 0:L.title)||A.name,P=i(A.interface),O=(N=(H=P==null?void 0:P.filterable)==null?void 0:H.operators)==null?void 0:N[0],V=n(A.target);b=b?`${b} / ${k}`:k;let W={type:"string",title:b,name:`${T}.${A.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-component":"CollectionField","x-decorator":"ChartFilterFormItem","x-collection-field":`${T}.${A.name}`,"x-component-props":yt(J({},(_=A.uiSchema)==null?void 0:_["x-component-props"]),{"filter-operator":O})};if(A.interface==="formula"){const X=pT(A.dataType)||"Input";W=yt(J({},W),{"x-component":X})}return["oho","o2m"].includes(A.interface)&&(W["x-component-props"].useOriginalFilter=!0),{key:`${T}.${A.name}`,name:A.name,type:"item",title:(($=A==null?void 0:A.uiSchema)==null?void 0:$.title)||A.name,Component:"CollectionFieldInitializer",remove:(X,K)=>{K(X,{breakRemoveOn:{"x-component":"Grid"}})},schemaInitialize:X=>{var K;(K=P==null?void 0:P.schemaInitialize)==null||K.call(P,X,{field:A,block:"FilterForm",readPretty:s.readPretty,action:t,targetCollection:V})},schema:W}},x=(A,b,T)=>{var W;const k=((W=A.uiSchema)==null?void 0:W.title)||A.name;b=b?`${b} / ${k}`:k;const P=A.operators[0];let O=yt(J({type:"string",name:`${T}.${A.name}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-decorator":"ChartFilterFormItem","x-collection-field":`${T}.${A.name}`},A.schema),{title:b,"x-component-props":{"filter-operator":P}});return P!=null&&P.noValue&&(O=yt(J({},O),{"x-component":"ChartFilterCheckbox","x-component-props":yt(J({},O["x-component-props"]),{content:mt.Schema.compile(P.label,{t:z.i18n.t})})})),{key:`${T}.${A.name}`,name:A.name,type:"item",title:A.title||A.name,Component:"CollectionFieldInitializer",remove:(q,L)=>{L(q,{breakRemoveOn:{"x-component":"Grid"}})},schema:O}},w=(A,b,T,k)=>{var L,H,N;if(!A.interface)return;const P=i(A.interface);if(!(P!=null&&P.filterable))return;const{nested:O,children:V}=P.filterable,W=((L=A.uiSchema)==null?void 0:L.title)||A.name,q=m(A,T,k);if(!(A.target&&b>2)){if(T=T?`${T} / ${W}`:W,V!=null&&V.length&&!["chinaRegion","createdBy","updatedBy"].includes(A.interface)){const _=V.map($=>x($,T,`${k}.${A.name}`));return{key:`${k}.${A.name}`,name:A.name,type:"subMenu",title:((H=A==null?void 0:A.uiSchema)==null?void 0:H.title)||A.name,children:_}}if(!b||b>2)return q;if(O){const $=a(A.target).map(X=>w(X,b+1,"",`${k}.${A.name}`));return{key:`${k}.${A.name}`,name:A.name,type:"subMenu",title:((N=A==null?void 0:A.uiSchema)==null?void 0:N.title)||A.name,children:$.filter(Boolean)}}return q}},C=[],M=[];return g.forEach(A=>{const b=A.interface,T=w(A,0,"",y.name);if(T&&C.push(T),["m2o"].includes(b)){const k=w(A,1,"",y.name);k&&M.push(k)}}),M.length&&C.push({name:"divider",type:"divider"},{name:"displayAssociationFields",type:"itemGroup",title:z.i18n.t("Display association fields"),children:M}),C},c=()=>{const y=(s==null?void 0:s.values)||{},g={};return Object.entries(l).forEach(([m,x])=>{const{operator:w}=x||{},C=o(m);C!=null&&C.target&&(m=`${m}.${C.targetKey||"id"}`);const[M,...A]=m.split("."),b=dT(y,m),T=(w==null?void 0:w.value)||"$eq";if(M!=="custom"){g[M]=g[M]||{$and:[]};const k={};He.set(k,A.join("."),{[T]:b}),g[M].$and.push(k)}else g[M]=g[M]||{},g[M][`$nFilter.${A.join(".")}`]=b}),g},f=(y,g)=>{const{collection:m,query:x}=y,{parameters:w}=bl.parse(x.filter||"");return y&&(g[m]||g.custom&&(w==null?void 0:w.find(C=>g.custom[C.key])))},h=(y,g)=>{const{collection:m,query:x}=y;let w=J({},x);const C=J({},w.filter||{});let M={};const A=bl.parse(C),{parameters:b}=A;return g.custom&&(b!=null&&b.find(T=>g.custom[T.key]))&&(M=A(g.custom)),M=jT(C,M),w=yt(J({},w),{filter:{$and:[M,g[m]]}}),w},v=()=>br(this,null,function*(){const y=c(),g=Object.values(e).filter(m=>f(m,y)).map(m=>()=>br(this,null,function*(){const{service:x,collection:w}=m;yield x.runAsync(w,h(m,y),!0)}));yield Promise.all(g.map(m=>m()))}),d=()=>br(this,null,function*(){const y=Object.values(e).filter(g=>g).map(g=>()=>br(this,null,function*(){const{service:m,collection:x,query:w}=g;yield m.runAsync(x,w,!0)}));yield Promise.all(y.map(g=>g()))}),p=ln.useMemoizedFn(y=>y.split(" / ").map(g=>z.i18n.t(mt.Schema.compile(g,{t:z.i18n.t}))).join(" / "));return{filter:v,refresh:d,getChartFilterFields:u,getFilter:c,hasFilter:f,appendFilter:h,getTranslatedTitle:p}},UT=()=>{const{t:e}=jt(),r=ln.useMemoizedFn(e),{enabled:t,fields:n}=D.useContext(_r),i=Object.entries(n).filter(([o,l])=>o.startsWith("custom.")&&l).map(([o,{title:l}])=>{const s=o.replace(/^custom\./,"");return{key:s,value:s,label:l}}),a=D.useMemo(()=>({label:r("Current filter"),value:"$nFilter",key:"$nFilter",children:i}),[i,r]);return!t||!i.length?null:a},O0=()=>{const{t:e}=jt(),{getChartCollections:r}=L0(),{getInterface:t,getCollectionFields:n,getCollection:i}=z.useCollectionManager(),{values:a}=D0(),o=(s,u)=>{var v,d,p;if(!s.interface)return;const c=t(s.interface);if(!(c!=null&&c.filterable))return;const{nested:f}=c.filterable,h={value:s.name,label:e(((v=s==null?void 0:s.uiSchema)==null?void 0:v.title)||s.name)};if(!(s.target&&u>2)){if(u>2)return h;if(f){const g=n(s.target).map(m=>o(m,u+1));return{value:s.name,label:e(((d=s==null?void 0:s.uiSchema)==null?void 0:d.title)||s.name),children:g.filter(m=>m)}}if(!(!a.includes((p=s.uiSchema)==null?void 0:p["x-component"])&&!a.includes(s.interface)))return h}},l=r();return D.useMemo(()=>{const s=[];return l.forEach(u=>{const c=i(u),f=[];n(c).forEach(v=>{const d=o(v,1);d&&f.push(d)}),f.length&&s.push({value:u,label:e(c.title),children:f})}),s},[l])},D0=()=>{const{t:e}=jt(),r=[{label:e("Input"),value:"Input"},{label:e("Number"),value:"InputNumber"},{label:e("Date"),value:"DatePicker"},{label:e("Date range"),value:"DatePicker.RangePicker"},{label:e("Time"),value:"TimePicker"},{label:e("Time range"),value:"TimePicker.RangePicker"},{label:e("Select"),value:"Select"},{label:e("Radio group"),value:"Radio.Group"},{label:e("Checkbox group"),value:"Checkbox.Group"}];return{options:r,values:r.map(t=>t.value)}},qT=e=>{const{getCollection:r,getCollectionField:t}=z.useCollectionManager();return D.useMemo(()=>{var u;if(!e)return;const[n,...i]=e.split(".");if(!(i!=null&&i.length))return;const a=r(n);let o=n,l,s=mt.Schema.compile(a==null?void 0:a.title,{t:z.i18n.t});for(;o&&i.length>0;){const c=i.shift();l=t(`${o}.${c}`);const f=((u=l==null?void 0:l.uiSchema)==null?void 0:u.title)||(l==null?void 0:l.name);f&&(s+=` / ${mt.Schema.compile(f,{t:z.i18n.t})}`),l!=null&&l.target?o=l.target:o=null}return s},[e])},ZT=()=>{const e=mt.useField(),{operator:r,schema:t}=e.data||{},n=z.useUserVariable({collectionField:{uiSchema:t},uiSchema:t}),i=z.useDateVariable({operator:r,schema:t}),a=UT(),o=D.useMemo(()=>[n,i,a].filter(Boolean),[i,n,a]);return!r||!t?[]:o},_u=(e={},r={})=>yt(J({type:"array","x-decorator":"FormItem","x-component":"ArrayItems"},r),{items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:yt(J({sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"}},e),{remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}})}}},properties:{add:{type:"void",title:'{{t("Add field")}}',"x-component":"ArrayItems.Addition"}}}),QT=e=>({type:"void",properties:{config:{type:"object",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 }}"},[na.uid()]:{type:"void",properties:{general:e}},[na.uid()]:{type:"void",properties:{advanced:{type:"json",title:'{{t("JSON config")}}',"x-decorator":"FormItem","x-decorator-props":{extra:Et("Same properties set in the form above will be overwritten by this JSON config.")},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:3}}}}},reference:{type:"string","x-reactions":{dependencies:[".chartType"],fulfill:{schema:{"x-content":"{{ getReference($deps[0]) }}"}}}}}}}}),KT={type:"void",properties:{settings:{type:"void",properties:{collection:{title:'{{t("Collection")}}',type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{ collectionOptions }}",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}}"},properties:{pane1:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:Et("Measures"),key:"measures"},properties:{measures:_u({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"}}}},{required:!0,"x-component-props":{style:{overflow:"auto"}}})}},pane2:{type:"void","x-component":"FormCollapse.CollapsePanel","x-component-props":{header:Et("Dimensions"),key:"dimensions"},properties:{dimensions:_u({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:Et("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:Et("Sort"),key:"sort"},properties:{orders:_u({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"}}}}}}}}},JT={type:"void",properties:{transform:_u({field:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Field")}}',style:{maxWidth:"100px"}},"x-reactions":"{{ useChartFields }}"},type:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Type")}}'},"x-reactions":"{{ useFieldTypeOptions }}"},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Format")}}'},"x-reactions":"{{ useTransformers }}","x-visible":"{{ $self.dataSource && $self.dataSource.length }}"}},{"x-decorator-props":{style:{width:"50%"}}})}};function tI(e){const{value:r,onChange:t,renderSchemaComponent:n}=e,i=ZT();return R.jsx(z.Variable.Input,{value:r,onChange:t,scope:i,children:n()})}const Tn=D.createContext({visible:!0}),eI=e=>{var l;const{insertAdjacent:r}=z.useDesignable(),[t,n]=D.useState(!1),[i,a]=D.useState({}),{token:o}=gt.theme.useToken();return R.jsxs(Tn.Provider,{value:{visible:t,setVisible:n,current:i,setCurrent:a},children:[R.jsx("div",{className:ao.css`
|
|
2
2
|
.ant-card {
|
|
3
3
|
border: ${o.lineWidth}px ${o.lineType} ${o.colorBorderSecondary};
|
|
4
4
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
> .ant-formily-item-label {
|
|
18
18
|
display: none;
|
|
19
19
|
}
|
|
20
|
-
`]:n===!1}),[n]);return R.jsx(z.ACLCollectionFieldProvider,{children:R.jsx(z.BlockItem,{className:"nb-form-item",children:R.jsx(M0,{onError:s=>console.log(s),FallbackComponent:hI,children:R.jsx(Ie.FormItem,yt(J({className:a},e),{extra:i}))})})})},{displayName:"ChartFilterFormItem"}),dI=D.memo(e=>{const{locale:r}=D.useContext(gt.ConfigProvider.ConfigContext),{t}=jt(),n=ln.useMemoizedFn(t),{scope:i,components:a}=D.useContext(mt.SchemaOptionsContext),{theme:o}=z.useGlobalTheme(),{insert:l}=e,s=z.useSchemaInitializerItem(),{getCollectionJoinField:u,getInterface:c}=z.useCollectionManager(),f=O0(),{options:h,values:v}=D0(),d=D.useCallback(()=>br(this,null,function*(){var C,M;const p=yield z.FormDialog(n("Add custom field"),()=>R.jsx(z.SchemaComponentOptions,{scope:yt(J({},i),{useChartFilterSourceFields:O0}),components:yt(J({},a),{FieldComponentProps:fI}),children:R.jsxs(Ie.FormLayout,{layout:"vertical",children:[R.jsx(gt.Alert,{type:"info",message:n('To filter with custom fields, use "Current filter" variables in the chart configuration.'),style:{marginBottom:16}}),R.jsx(gt.ConfigProvider,{locale:r,children:R.jsx(z.SchemaComponent,{schema:{properties:{name:{type:"string",required:!0},title:{type:"string",title:n("Field title"),"x-component":"Input","x-decorator":"FormItem",required:!0},source:{type:"string",title:n("Field source"),"x-decorator":"FormItem","x-component":"Cascader",enum:f,description:n("Select a source field to use metadata of the field")},component:{type:"string",title:n("Field component"),"x-component":"Select","x-decorator":"FormItem",required:!0,enum:h},props:{type:"object",title:n("Component properties"),"x-component":"FieldComponentProps"}}}})})]})}),o).open({values:{name:`f_${na.uid()}`},effects(){on.onFieldValueChange("source",A=>{var V;const b=(V=A.value)==null?void 0:V.join("."),T=u(b);if(!T)return;const k=T.uiSchema||{};let P;if(v.includes(k["x-component"])){P=k["x-component"];const W=k["x-component-props"]||{};k.enum&&(W.options=k.enum),A.query(".props").take().setValue(W)}else v.includes(T.interface)&&(P=T.interface);if(!P)return;A.query(".component").take().setValue(P)})}}),{name:y,title:g,component:m,props:x}=p,w=((M=(C=c(m))==null?void 0:C.default)==null?void 0:M.uiSchema)||{};l(z.gridRowColWrap(yt(J({"x-component":m},w),{type:"string",title:g,name:`custom.${y}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-decorator":"ChartFilterFormItem","x-component-props":J(J({},w["x-component-props"]||{}),x)})))}),[o]);return R.jsx(z.SchemaInitializerItem,yt(J(J({},s),e),{onClick:d}))}),pI=new z.SchemaInitializer({name:"ChartFilterItemInitializers","data-testid":"configure-fields-button-of-chart-filter-item",wrap:z.gridRowColWrap,icon:"SettingOutlined",title:'{{ t("Configure fields") }}',items:[{type:"itemGroup",name:"displayFields",title:'{{ t("Display fields") }}',useChildren:()=>{const{getCollection:e}=z.useCollectionManager(),{getChartCollections:r}=L0(),{getChartFilterFields:t}=so(),n=r();return D.useMemo(()=>n.map(i=>{const a=e(i),o=t(a);return{name:a.key,type:"subMenu",title:a.title,children:o}}),[n])}},{name:"divider",type:"divider"},{name:"custom",type:"item",title:Et("Custom"),Component:()=>{const{insertAdjacent:e}=z.useDesignable();return R.jsx(dI,{insert:r=>e("beforeEnd",r)})}}]}),gI=()=>{const{filter:e}=so();return{onClick:e}},yI=()=>{const e=mt.useForm(),{filter:r}=so();return{onClick:()=>br(this,null,function*(){e.reset(),yield r()})}},mI=()=>{const{collapse:{collapsed:e},setCollapse:r}=D.useContext(_r),{t}=jt();return{onClick:()=>r({collapsed:!e}),title:R.jsxs(R.Fragment,{children:[R.jsx(ni.DownOutlined,{rotate:e?0:180})," ",t(e?"Expand":"Collapse")]})}},xI=e=>{const{t:r}=jt();return R.jsx(z.GeneralSchemaDesigner,yt(J({},e),{disableInitializer:!0,children:R.jsx(z.SchemaSettingsRemove,{breakRemoveOn:t=>t["x-component"]==="Space"||t["x-component"].endsWith("ActionBar"),confirm:{title:r("Delete action")}})}))},wI=e=>{const i=e,{buttonEditorProps:r}=i,t=uT(i,["buttonEditorProps"]),{t:n}=jt();return R.jsxs(z.GeneralSchemaDesigner,yt(J({},t),{disableInitializer:!0,children:[R.jsx(z.Action.Designer.ButtonEditor,J({},r)),R.jsx(z.SchemaSettingsDivider,{}),R.jsx(z.SchemaSettingsRemove,{breakRemoveOn:a=>a["x-component"]==="Space"||a["x-component"].endsWith("ActionBar"),confirm:{title:n("Delete action")}})]}))},SI=e=>{const r={title:'{{ t("Filter") }}',"x-action":"submit","x-component":"Action","x-designer":"ChartFilterActionDesigner","x-component-props":{type:"primary",useProps:"{{ useChartFilterActionProps }}"}};return R.jsx(z.ActionInitializer,yt(J({},e),{schema:r}))},CI=e=>{const r={title:'{{ t("Reset") }}',"x-action":"reset","x-component":"Action","x-designer":"ChartFilterActionDesigner","x-component-props":{useProps:"{{ useChartFilterResetProps }}"}};return R.jsx(z.ActionInitializer,yt(J({},e),{schema:r}))},MI=e=>{const r={title:'{{ t("Collapse") }}',"x-action":"collapse","x-component":"Action","x-component-props":{type:"link",useProps:"{{ useChartFilterCollapseProps }}"},"x-designer":"ChartFilterCollapseDesigner"};return R.jsx(z.ActionInitializer,yt(J({},e),{schema:r}))},AI=new z.SchemaInitializer({name:"ChartFilterActionInitializers","data-testid":"configure-actions-button-of-chart-filter",title:'{{t("Configure actions")}}',icon:"SettingOutlined",items:[{name:"enbaleActions",type:"itemGroup",title:'{{t("Enable actions")}}',children:[{name:"filter",type:"item",title:'{{t("Filter")}}',component:SI,schema:{"x-action-settings":{}}},{name:"reset",type:"item",title:'{{t("Reset")}}',component:CI,schema:{"x-action-settings":{}}},{name:"collapse",type:"item",title:'{{t("Collapse")}}',component:MI,schema:{"x-action-settings":{}}}]}]}),FI=e=>{var c;const{value:r,onChange:t,fieldSchema:n}=e,i=z.useUserVariable({collectionField:{uiSchema:n},uiSchema:n}),a=z.useDateVariable({operator:(c=n["x-component-props"])==null?void 0:c["filter-operator"],schema:n,noDisabled:!0}),o=D.useMemo(()=>[i,a].filter(Boolean),[a,i]),l=yt(J({},n),{"x-component":n["x-component"]||"Input","x-decorator":"",title:"",name:"value",default:""}),s=n["x-component-props"]||{},u=ln.useMemoizedFn(t);return D.useEffect(()=>{n.default&&u({value:n.default})},[n.default,u]),R.jsx(z.VariableScopeProvider,{scope:o,children:R.jsx(z.VariableInput,yt(J({},s),{renderSchemaComponent:()=>R.jsx(z.SchemaComponent,{schema:l}),fieldNames:{},value:r==null?void 0:r.value,scope:o,onChange:f=>{t({value:f})},shouldChange:z.getShouldChange({})}))})},{Text:bI}=gt.Typography,EI=()=>{const e=mt.useField(),r=mt.useFieldSchema(),{t}=jt(),{dn:n}=z.useDesignable(),{setField:i}=D.useContext(_r);return R.jsx(z.SchemaSettingsModalItem,{title:t("Edit field title"),schema:{type:"object",title:t("Edit field title"),properties:{title:{title:t("Field title"),default:e==null?void 0:e.title,required:!0,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:a})=>{a&&(e.title=a,r.title=a,n.emit("patch",{schema:{"x-uid":r["x-uid"],title:r.title}}),i(r.name,{title:a})),n.refresh()}},"edit-field-title")},kI=()=>{var y,g,m,x;const e=z.useCompile(),r=mt.useFieldSchema(),t=r.name,n=mt.useField(),{t:i}=jt(),{dn:a}=z.useDesignable(),{setField:o}=D.useContext(_r),{getInterface:l,getCollectionJoinField:s}=z.useCollectionManager(),u=w=>{var b;let C=w==null?void 0:w.interface;C==="formula"&&(C=gT(w.dataType)||w.dataType);const M=l(C);return{operatorList:((b=M==null?void 0:M.filterable)==null?void 0:b.operators)||[],interfaceConfig:M}};let c=s(t),{operatorList:f,interfaceConfig:h}=u(c);if(!f.length){const w=t.split("."),C=w.pop();if(c=s(w.join(".")),!c)return null;const M=u(c);if(f=M.operatorList,h=M.interfaceConfig,!h)return null;const b=((h==null?void 0:h.filterable.children)||[]).find(T=>T.name===C);f=(b==null?void 0:b.operators)||[]}if(!f.length)return null;const v=((g=(y=h==null?void 0:h.default)==null?void 0:y.uiSchema)==null?void 0:g["x-component"])||"Input",d=(m=r["x-component-props"])==null?void 0:m["filter-operator"],p=(w,C,M={})=>{const A=n.componentProps||{};n.component=C,n.componentProps=J(yt(J({},A),{"filter-operator":w}),M),r["x-component"]=C,r["x-component-props"]=J(yt(J({},r["x-component-props"]),{"filter-operator":w}),M),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component":C,"x-component-props":J(yt(J({},r["x-component-props"]),{"filter-operator":w}),M)}})};return R.jsx(z.SchemaSettingsSelectItem,{title:i("Operator"),value:(d==null?void 0:d.value)||((x=f[0])==null?void 0:x.value),options:e(f),onChange:w=>{var M;const C=f.find(A=>A.value===w);C.noValue?p(C,"ChartFilterCheckbox",{content:mt.Schema.compile(C.label,{t:i})}):(M=C.schema)!=null&&M["x-component"]?p(C,C.schema["x-component"]):p(C,v),o(t,{operator:C}),a.refresh()}},"operator")},TI=()=>{const{t:e}=jt(),{dn:r}=z.useDesignable(),t=mt.useField(),n=mt.useFieldSchema(),i=Pv(n["x-component"]);return R.jsx(z.SchemaSettingsModalItem,{title:e("Edit field properties"),schema:J({title:e("Edit field properties")},i),initialValues:t.componentProps,onSubmit:a=>{t.reset(),t.componentProps=a,n["x-component-props"]=a,r.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":a}}),r.refresh()}},"edit-field-props")},II=()=>{const{t:e}=jt(),{dn:r}=z.useDesignable(),t=D.useContext(z.VariablesContext),n=mt.useField(),i=mt.useFieldSchema(),{getTranslatedTitle:a}=so(),o=a(i.title);return R.jsx(z.SchemaSettingsModalItem,{title:e("Set default value"),components:{ChartFilterVariableInput:FI},schema:{type:"void",title:e("Set default value"),properties:{default:{title:o,"x-decorator":"FormItem","x-component":"ChartFilterVariableInput","x-component-props":{fieldSchema:i}}}},onSubmit:({default:{value:l}})=>{n.setInitialValue(l),i.default=l,r.emit("patch",{schema:{"x-uid":i["x-uid"],default:l}}),r.refresh(),B0(n,t)}},"set field default value")},PI=()=>{var f,h,v;const{getCollectionFields:e,getCollectionJoinField:r,getInterface:t}=z.useCollectionManager(),n=mt.useField(),i=mt.useFieldSchema(),{t:a}=jt(),{dn:o}=z.useDesignable(),l=z.useCompile(),s=r(i["x-collection-field"]),c=(s!=null&&s.target?e(s==null?void 0:s.target):(f=e(s==null?void 0:s.targetCollection))!=null?f:[]).filter(d=>{if(d!=null&&d.target||d.type==="boolean")return!1;const p=t(d==null?void 0:d.interface);return p==null?void 0:p.titleUsable}).map(d=>{var p;return{value:d==null?void 0:d.name,label:l((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||(d==null?void 0:d.name)}});return c.length>0&&i["x-component"]==="CollectionField"?R.jsx(z.SchemaSettingsSelectItem,{title:a("Title field"),options:c,value:(v=(h=n==null?void 0:n.componentProps)==null?void 0:h.fieldNames)==null?void 0:v.label,onChange:d=>{var g,m;const p={"x-uid":i["x-uid"]},y=yt(J(J({},(m=(g=s==null?void 0:s.uiSchema)==null?void 0:g["x-component-props"])==null?void 0:m.fieldNames),n.componentProps.fieldNames),{label:d});i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].fieldNames=y,p["x-component-props"]=i["x-component-props"],n.componentProps.fieldNames=i["x-component-props"].fieldNames,o.emit("patch",{schema:p}),o.refresh()}},"title-field"):null},LI=()=>{const{getCollectionJoinField:e}=z.useCollectionManager(),{getField:r}=z.useCollection(),{t}=jt(),n=mt.useFieldSchema(),i=n.name,a=r(i)||e(n["x-collection-field"]),o=i.startsWith("custom."),l=Pv(n["x-component"]),s=qT(i);return R.jsxs(z.GeneralSchemaDesigner,{disableInitializer:!0,children:[!o&&R.jsxs(R.Fragment,{children:[R.jsx(z.SchemaSettingsItem,{title:i,children:R.jsxs(bI,{type:"secondary",children:[t("Original field"),": ",s]})}),R.jsx(z.SchemaSettingsDivider,{})]}),R.jsx(EI,{}),R.jsx(z.EditDescription,{}),l&&o&&R.jsx(TI,{}),!o&&R.jsx(kI,{}),R.jsx(PI,{}),R.jsx(II,{}),a?R.jsx(z.SchemaSettingsDivider,{}):null,R.jsx(z.SchemaSettingsRemove,{confirm:{title:t("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},OI=mt.connect(e=>{const{content:r}=e,t=mt.useField(),n=()=>{t.setValue(!t.value)};return R.jsx(gt.Checkbox,{onClick:n,checked:t.value,children:r})}),DI=D.memo(e=>{const{setField:r,removeField:t,setForm:n}=D.useContext(_r),{getTranslatedTitle:i}=so(),a=D.useRef(null);a.current=D.useContext(z.VariablesContext);const o=D.useMemo(()=>on.createForm({effects(){const l=s=>{if(s.displayName!=="Field")return null;const{name:u}=s.props||{};return u};on.onFieldInit("*",s=>{l(s)&&s.setValue(null)}),on.onFieldMount("*",s=>br(this,null,function*(){const u=l(s);u&&(r(u,{title:s.title,operator:s.componentProps["filter-operator"]}),s.title.includes("/")&&(s.title=i(s.title)),B0(s,a.current))})),on.onFieldUnmount("*",s=>{const u=l(s);u&&t(u)})}}),[r,i,t,a]);return D.useEffect(()=>n(o),[o,n]),R.jsx(z.FormV2,yt(J({},e),{form:o}))}),BI=e=>{const{t:r}=jt(),{setEnabled:t}=D.useContext(_r);return D.useEffect(()=>{t(!0)},[t]),R.jsx("div",{className:ao.css`
|
|
20
|
+
`]:n===!1}),[n]);return R.jsx(z.ACLCollectionFieldProvider,{children:R.jsx(z.BlockItem,{className:"nb-form-item",children:R.jsx(M0,{onError:s=>console.log(s),FallbackComponent:hI,children:R.jsx(Ie.FormItem,yt(J({className:a},e),{extra:i}))})})})},{displayName:"ChartFilterFormItem"}),dI=D.memo(e=>{const{locale:r}=D.useContext(gt.ConfigProvider.ConfigContext),{t}=jt(),n=ln.useMemoizedFn(t),{scope:i,components:a}=D.useContext(mt.SchemaOptionsContext),{theme:o}=z.useGlobalTheme(),{insert:l}=e,s=z.useSchemaInitializerItem(),{getCollectionJoinField:u,getInterface:c}=z.useCollectionManager(),f=O0(),{options:h,values:v}=D0(),d=D.useCallback(()=>br(this,null,function*(){var C,M;const p=yield z.FormDialog(n("Add custom field"),()=>R.jsx(z.SchemaComponentOptions,{scope:yt(J({},i),{useChartFilterSourceFields:O0}),components:yt(J({},a),{FieldComponentProps:fI}),children:R.jsxs(Ie.FormLayout,{layout:"vertical",children:[R.jsx(gt.Alert,{type:"info",message:n('To filter with custom fields, use "Current filter" variables in the chart configuration.'),style:{marginBottom:16}}),R.jsx(gt.ConfigProvider,{locale:r,children:R.jsx(z.SchemaComponent,{schema:{properties:{name:{type:"string",required:!0},title:{type:"string",title:n("Field title"),"x-component":"Input","x-decorator":"FormItem",required:!0},source:{type:"string",title:n("Field source"),"x-decorator":"FormItem","x-component":"Cascader",enum:f,description:n("Select a source field to use metadata of the field")},component:{type:"string",title:n("Field component"),"x-component":"Select","x-decorator":"FormItem",required:!0,enum:h},props:{type:"object",title:n("Component properties"),"x-component":"FieldComponentProps"}}}})})]})}),o).open({values:{name:`f_${na.uid()}`},effects(){on.onFieldValueChange("source",A=>{var V;const b=(V=A.value)==null?void 0:V.join("."),T=u(b);if(!T)return;const k=T.uiSchema||{};let P;if(v.includes(k["x-component"])){P=k["x-component"];const W=k["x-component-props"]||{};k.enum&&(W.options=k.enum),A.query(".props").take().setValue(W)}else v.includes(T.interface)&&(P=T.interface);if(!P)return;A.query(".component").take().setValue(P)})}}),{name:y,title:g,component:m,props:x}=p,w=((M=(C=c(m))==null?void 0:C.default)==null?void 0:M.uiSchema)||{};l(z.gridRowColWrap(yt(J({"x-component":m},w),{type:"string",title:g,name:`custom.${y}`,required:!1,"x-designer":"ChartFilterItemDesigner","x-decorator":"ChartFilterFormItem","x-component-props":J(J({},w["x-component-props"]||{}),x)})))}),[o]);return R.jsx(z.SchemaInitializerItem,yt(J(J({},s),e),{onClick:d}))}),pI=new z.SchemaInitializer({name:"ChartFilterItemInitializers","data-testid":"configure-fields-button-of-chart-filter-item",wrap:z.gridRowColWrap,icon:"SettingOutlined",title:'{{ t("Configure fields") }}',items:[{type:"itemGroup",name:"displayFields",title:'{{ t("Display fields") }}',useChildren:()=>{const{getCollection:e}=z.useCollectionManager(),{getChartCollections:r}=L0(),{getChartFilterFields:t}=so(),n=r();return D.useMemo(()=>n.map(i=>{const a=e(i),o=t(a);return{name:a.key,type:"subMenu",title:a.title,children:o}}),[n])}},{name:"divider",type:"divider"},{name:"custom",type:"item",title:Et("Custom"),Component:()=>{const{insertAdjacent:e}=z.useDesignable();return R.jsx(dI,{insert:r=>e("beforeEnd",r)})}}]}),gI=()=>{const{filter:e}=so();return{onClick:e}},yI=()=>{const e=mt.useForm(),{filter:r}=so();return{onClick:()=>br(this,null,function*(){e.reset(),yield r()})}},mI=()=>{const{collapse:{collapsed:e},setCollapse:r}=D.useContext(_r),{t}=jt();return{onClick:()=>r({collapsed:!e}),title:R.jsxs(R.Fragment,{children:[R.jsx(ni.DownOutlined,{rotate:e?0:180})," ",t(e?"Expand":"Collapse")]})}},xI=e=>{const{t:r}=jt();return R.jsx(z.GeneralSchemaDesigner,yt(J({},e),{disableInitializer:!0,children:R.jsx(z.SchemaSettingsRemove,{breakRemoveOn:t=>t["x-component"]==="Space"||t["x-component"].endsWith("ActionBar"),confirm:{title:r("Delete action")}})}))},wI=e=>{const i=e,{buttonEditorProps:r}=i,t=uT(i,["buttonEditorProps"]),{t:n}=jt();return R.jsxs(z.GeneralSchemaDesigner,yt(J({},t),{disableInitializer:!0,children:[R.jsx(z.Action.Designer.ButtonEditor,J({},r)),R.jsx(z.SchemaSettingsDivider,{}),R.jsx(z.SchemaSettingsRemove,{breakRemoveOn:a=>a["x-component"]==="Space"||a["x-component"].endsWith("ActionBar"),confirm:{title:n("Delete action")}})]}))},SI=e=>{const r={title:'{{ t("Filter") }}',"x-action":"submit","x-component":"Action","x-designer":"ChartFilterActionDesigner","x-component-props":{htmlType:"submit",type:"primary",useProps:"{{ useChartFilterActionProps }}"}};return R.jsx(z.ActionInitializer,yt(J({},e),{schema:r}))},CI=e=>{const r={title:'{{ t("Reset") }}',"x-action":"reset","x-component":"Action","x-designer":"ChartFilterActionDesigner","x-component-props":{useProps:"{{ useChartFilterResetProps }}"}};return R.jsx(z.ActionInitializer,yt(J({},e),{schema:r}))},MI=e=>{const r={title:'{{ t("Collapse") }}',"x-action":"collapse","x-component":"Action","x-component-props":{type:"link",useProps:"{{ useChartFilterCollapseProps }}"},"x-designer":"ChartFilterCollapseDesigner"};return R.jsx(z.ActionInitializer,yt(J({},e),{schema:r}))},AI=new z.SchemaInitializer({name:"ChartFilterActionInitializers","data-testid":"configure-actions-button-of-chart-filter",title:'{{t("Configure actions")}}',icon:"SettingOutlined",items:[{name:"enbaleActions",type:"itemGroup",title:'{{t("Enable actions")}}',children:[{name:"filter",type:"item",title:'{{t("Filter")}}',component:SI,schema:{"x-action-settings":{}}},{name:"reset",type:"item",title:'{{t("Reset")}}',component:CI,schema:{"x-action-settings":{}}},{name:"collapse",type:"item",title:'{{t("Collapse")}}',component:MI,schema:{"x-action-settings":{}}}]}]}),FI=e=>{var c;const{value:r,onChange:t,fieldSchema:n}=e,i=z.useUserVariable({collectionField:{uiSchema:n},uiSchema:n}),a=z.useDateVariable({operator:(c=n["x-component-props"])==null?void 0:c["filter-operator"],schema:n,noDisabled:!0}),o=D.useMemo(()=>[i,a].filter(Boolean),[a,i]),l=yt(J({},n),{"x-component":n["x-component"]||"Input","x-decorator":"",title:"",name:"value",default:""}),s=n["x-component-props"]||{},u=ln.useMemoizedFn(t);return D.useEffect(()=>{n.default&&u({value:n.default})},[n.default,u]),R.jsx(z.VariableScopeProvider,{scope:o,children:R.jsx(z.VariableInput,yt(J({},s),{renderSchemaComponent:()=>R.jsx(z.SchemaComponent,{schema:l}),fieldNames:{},value:r==null?void 0:r.value,scope:o,onChange:f=>{t({value:f})},shouldChange:z.getShouldChange({})}))})},{Text:bI}=gt.Typography,EI=()=>{const e=mt.useField(),r=mt.useFieldSchema(),{t}=jt(),{dn:n}=z.useDesignable(),{setField:i}=D.useContext(_r);return R.jsx(z.SchemaSettingsModalItem,{title:t("Edit field title"),schema:{type:"object",title:t("Edit field title"),properties:{title:{title:t("Field title"),default:e==null?void 0:e.title,required:!0,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:a})=>{a&&(e.title=a,r.title=a,n.emit("patch",{schema:{"x-uid":r["x-uid"],title:r.title}}),i(r.name,{title:a})),n.refresh()}},"edit-field-title")},kI=()=>{var y,g,m,x;const e=z.useCompile(),r=mt.useFieldSchema(),t=r.name,n=mt.useField(),{t:i}=jt(),{dn:a}=z.useDesignable(),{setField:o}=D.useContext(_r),{getInterface:l,getCollectionJoinField:s}=z.useCollectionManager(),u=w=>{var b;let C=w==null?void 0:w.interface;C==="formula"&&(C=gT(w.dataType)||w.dataType);const M=l(C);return{operatorList:((b=M==null?void 0:M.filterable)==null?void 0:b.operators)||[],interfaceConfig:M}};let c=s(t),{operatorList:f,interfaceConfig:h}=u(c);if(!f.length){const w=t.split("."),C=w.pop();if(c=s(w.join(".")),!c)return null;const M=u(c);if(f=M.operatorList,h=M.interfaceConfig,!h)return null;const b=((h==null?void 0:h.filterable.children)||[]).find(T=>T.name===C);f=(b==null?void 0:b.operators)||[]}if(!f.length)return null;const v=((g=(y=h==null?void 0:h.default)==null?void 0:y.uiSchema)==null?void 0:g["x-component"])||"Input",d=(m=r["x-component-props"])==null?void 0:m["filter-operator"],p=(w,C,M={})=>{const A=n.componentProps||{};n.component=C,n.componentProps=J(yt(J({},A),{"filter-operator":w}),M),r["x-component"]=C,r["x-component-props"]=J(yt(J({},r["x-component-props"]),{"filter-operator":w}),M),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component":C,"x-component-props":J(yt(J({},r["x-component-props"]),{"filter-operator":w}),M)}})};return R.jsx(z.SchemaSettingsSelectItem,{title:i("Operator"),value:(d==null?void 0:d.value)||((x=f[0])==null?void 0:x.value),options:e(f),onChange:w=>{var M;const C=f.find(A=>A.value===w);C.noValue?p(C,"ChartFilterCheckbox",{content:mt.Schema.compile(C.label,{t:i})}):(M=C.schema)!=null&&M["x-component"]?p(C,C.schema["x-component"]):p(C,v),o(t,{operator:C}),a.refresh()}},"operator")},TI=()=>{const{t:e}=jt(),{dn:r}=z.useDesignable(),t=mt.useField(),n=mt.useFieldSchema(),i=Pv(n["x-component"]);return R.jsx(z.SchemaSettingsModalItem,{title:e("Edit field properties"),schema:J({title:e("Edit field properties")},i),initialValues:t.componentProps,onSubmit:a=>{t.reset(),t.componentProps=a,n["x-component-props"]=a,r.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":a}}),r.refresh()}},"edit-field-props")},II=()=>{const{t:e}=jt(),{dn:r}=z.useDesignable(),t=D.useContext(z.VariablesContext),n=mt.useField(),i=mt.useFieldSchema(),{getTranslatedTitle:a}=so(),o=a(i.title);return R.jsx(z.SchemaSettingsModalItem,{title:e("Set default value"),components:{ChartFilterVariableInput:FI},schema:{type:"void",title:e("Set default value"),properties:{default:{title:o,"x-decorator":"FormItem","x-component":"ChartFilterVariableInput","x-component-props":{fieldSchema:i}}}},onSubmit:({default:{value:l}})=>{n.setInitialValue(l),i.default=l,r.emit("patch",{schema:{"x-uid":i["x-uid"],default:l}}),r.refresh(),B0(n,t)}},"set field default value")},PI=()=>{var f,h,v;const{getCollectionFields:e,getCollectionJoinField:r,getInterface:t}=z.useCollectionManager(),n=mt.useField(),i=mt.useFieldSchema(),{t:a}=jt(),{dn:o}=z.useDesignable(),l=z.useCompile(),s=r(i["x-collection-field"]),c=(s!=null&&s.target?e(s==null?void 0:s.target):(f=e(s==null?void 0:s.targetCollection))!=null?f:[]).filter(d=>{if(d!=null&&d.target||d.type==="boolean")return!1;const p=t(d==null?void 0:d.interface);return p==null?void 0:p.titleUsable}).map(d=>{var p;return{value:d==null?void 0:d.name,label:l((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||(d==null?void 0:d.name)}});return c.length>0&&i["x-component"]==="CollectionField"?R.jsx(z.SchemaSettingsSelectItem,{title:a("Title field"),options:c,value:(v=(h=n==null?void 0:n.componentProps)==null?void 0:h.fieldNames)==null?void 0:v.label,onChange:d=>{var g,m;const p={"x-uid":i["x-uid"]},y=yt(J(J({},(m=(g=s==null?void 0:s.uiSchema)==null?void 0:g["x-component-props"])==null?void 0:m.fieldNames),n.componentProps.fieldNames),{label:d});i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].fieldNames=y,p["x-component-props"]=i["x-component-props"],n.componentProps.fieldNames=i["x-component-props"].fieldNames,o.emit("patch",{schema:p}),o.refresh()}},"title-field"):null},LI=()=>{const{getCollectionJoinField:e}=z.useCollectionManager(),{getField:r}=z.useCollection(),{t}=jt(),n=mt.useFieldSchema(),i=n.name,a=r(i)||e(n["x-collection-field"]),o=i.startsWith("custom."),l=Pv(n["x-component"]),s=qT(i);return R.jsxs(z.GeneralSchemaDesigner,{disableInitializer:!0,children:[!o&&R.jsxs(R.Fragment,{children:[R.jsx(z.SchemaSettingsItem,{title:i,children:R.jsxs(bI,{type:"secondary",children:[t("Original field"),": ",s]})}),R.jsx(z.SchemaSettingsDivider,{})]}),R.jsx(EI,{}),R.jsx(z.EditDescription,{}),l&&o&&R.jsx(TI,{}),!o&&R.jsx(kI,{}),R.jsx(PI,{}),R.jsx(II,{}),a?R.jsx(z.SchemaSettingsDivider,{}):null,R.jsx(z.SchemaSettingsRemove,{confirm:{title:t("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},OI=mt.connect(e=>{const{content:r}=e,t=mt.useField(),n=()=>{t.setValue(!t.value)};return R.jsx(gt.Checkbox,{onClick:n,checked:t.value,children:r})}),DI=D.memo(e=>{const{setField:r,removeField:t,setForm:n}=D.useContext(_r),{getTranslatedTitle:i}=so(),a=D.useRef(null);a.current=D.useContext(z.VariablesContext);const o=D.useMemo(()=>on.createForm({effects(){const l=s=>{if(s.displayName!=="Field")return null;const{name:u}=s.props||{};return u};on.onFieldInit("*",s=>{l(s)&&s.setValue(null)}),on.onFieldMount("*",s=>br(this,null,function*(){const u=l(s);u&&(r(u,{title:s.title,operator:s.componentProps["filter-operator"]}),s.title.includes("/")&&(s.title=i(s.title)),B0(s,a.current))})),on.onFieldUnmount("*",s=>{const u=l(s);u&&t(u)})}}),[r,i,t,a]);return D.useEffect(()=>n(o),[o,n]),R.jsx(z.FormV2,yt(J({},e),{form:o}))}),BI=e=>{const{t:r}=jt(),{setEnabled:t}=D.useContext(_r);return D.useEffect(()=>{t(!0)},[t]),R.jsx("div",{className:ao.css`
|
|
21
21
|
.ant-card {
|
|
22
22
|
box-shadow: none;
|
|
23
23
|
border: none;
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.19.0-alpha.
|
|
2
|
+
"@nocobase/client": "0.19.0-alpha.4",
|
|
3
3
|
"@formily/react": "2.3.0",
|
|
4
4
|
"@formily/shared": "2.3.0",
|
|
5
5
|
"lodash": "4.17.21",
|
|
6
|
-
"@nocobase/cache": "0.19.0-alpha.
|
|
7
|
-
"@nocobase/server": "0.19.0-alpha.
|
|
6
|
+
"@nocobase/cache": "0.19.0-alpha.4",
|
|
7
|
+
"@nocobase/server": "0.19.0-alpha.4",
|
|
8
8
|
"react": "18.2.0",
|
|
9
9
|
"@ant-design/icons": "5.2.6",
|
|
10
10
|
"ahooks": "3.7.8",
|
|
@@ -13,8 +13,8 @@ module.exports = {
|
|
|
13
13
|
"antd": "5.12.8",
|
|
14
14
|
"@formily/antd-v5": "1.1.9",
|
|
15
15
|
"@formily/core": "2.3.0",
|
|
16
|
-
"@nocobase/utils": "0.19.0-alpha.
|
|
17
|
-
"@nocobase/database": "0.19.0-alpha.
|
|
16
|
+
"@nocobase/utils": "0.19.0-alpha.4",
|
|
17
|
+
"@nocobase/database": "0.19.0-alpha.4",
|
|
18
18
|
"react-i18next": "11.18.6",
|
|
19
|
-
"@nocobase/actions": "0.19.0-alpha.
|
|
19
|
+
"@nocobase/actions": "0.19.0-alpha.4"
|
|
20
20
|
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Edit": "편집",
|
|
3
|
+
"Delete": "삭제",
|
|
4
|
+
"Cancel": "취소",
|
|
5
|
+
"Submit": "제출",
|
|
6
|
+
"Actions": "동작",
|
|
7
|
+
"Title": "제목",
|
|
8
|
+
"Enable": "활성화",
|
|
9
|
+
"Chart": "차트",
|
|
10
|
+
"ChartV2": "차트V2",
|
|
11
|
+
"Charts": "차트",
|
|
12
|
+
"Configure": "구성",
|
|
13
|
+
"Duplicate": "복제",
|
|
14
|
+
"Configure chart": "차트 구성",
|
|
15
|
+
"Transform": "데이터 변환",
|
|
16
|
+
"Chart type": "차트 유형",
|
|
17
|
+
"JSON config": "JSON 구성",
|
|
18
|
+
"Query": "쿼리",
|
|
19
|
+
"Data": "데이터",
|
|
20
|
+
"Run query": "쿼리 실행",
|
|
21
|
+
"Measures": "측정",
|
|
22
|
+
"Dimensions": "치수",
|
|
23
|
+
"Filter": "필터",
|
|
24
|
+
"Sort": "정렬",
|
|
25
|
+
"Limit": "결과 제한",
|
|
26
|
+
"Enable cache": "캐시 활성화",
|
|
27
|
+
"TTL (second)": "TTL (초)",
|
|
28
|
+
"Field": "필드",
|
|
29
|
+
"Aggregation": "집계",
|
|
30
|
+
"Alias": "별칭",
|
|
31
|
+
"Format": "형식",
|
|
32
|
+
"The first 10 records of the query result:": "쿼리 결과의 처음 10 개 레코드:",
|
|
33
|
+
"Please run query to retrieve data.": "데이터를 검색하려면 쿼리를 실행하십시오.",
|
|
34
|
+
"Type": "유형",
|
|
35
|
+
"Add field": "필드 추가",
|
|
36
|
+
"Add chart": "차트 추가",
|
|
37
|
+
"xField": "x축 필드",
|
|
38
|
+
"yField": "y축 필드",
|
|
39
|
+
"seriesField": "시리즈 필드",
|
|
40
|
+
"angleField": "각도 필드",
|
|
41
|
+
"colorField": "색상 필드",
|
|
42
|
+
"Line Chart": "선 그래프",
|
|
43
|
+
"Area Chart": "면적 그래프",
|
|
44
|
+
"Column Chart": "막대 그래프",
|
|
45
|
+
"Bar Chart": "막대 그래프",
|
|
46
|
+
"Pie Chart": "파이 차트",
|
|
47
|
+
"Dual Axes Chart": "이중 축 그래프",
|
|
48
|
+
"Scatter Chart": "산점도 차트",
|
|
49
|
+
"Gauge Chart": "게이지 차트",
|
|
50
|
+
"Statistic": "통계",
|
|
51
|
+
"Currency": "통화",
|
|
52
|
+
"Percent": "퍼센트",
|
|
53
|
+
"Exponential": "지수 표기법",
|
|
54
|
+
"Abbreviation": "약어",
|
|
55
|
+
"Please configure and run query": "쿼리를 구성하고 실행하세요.",
|
|
56
|
+
"Please configure chart": "차트를 구성하세요.",
|
|
57
|
+
"Are you sure to cancel?": "취소하시겠습니까?",
|
|
58
|
+
"Your changes are not saved. If you click OK, your changes will be lost.": "변경 내용이 저장되지 않았습니다. 확인을 클릭하면 변경 내용이 손실됩니다.",
|
|
59
|
+
"Same properties set in the form above will be overwritten by this JSON config.": "상단 양식에 설정된 동일한 속성은이 JSON 구성에 의해 덮어쓰기됩니다.",
|
|
60
|
+
"Built-in": "내장",
|
|
61
|
+
"Config reference: ": "구성 참조: ",
|
|
62
|
+
"Table": "테이블",
|
|
63
|
+
"Sum": "합계",
|
|
64
|
+
"Avg": "평균",
|
|
65
|
+
"Count": "계수",
|
|
66
|
+
"Min": "최소값",
|
|
67
|
+
"Max": "최대값",
|
|
68
|
+
"Please select a chart type.": "차트 유형을 선택하세요.",
|
|
69
|
+
"Collection": "데이터 테이블",
|
|
70
|
+
"isStack": "스택",
|
|
71
|
+
"isPercent": "백분율로 표시",
|
|
72
|
+
"isGroup": "그룹화",
|
|
73
|
+
"smooth": "부드러운 곡선",
|
|
74
|
+
"Collapse": "축소",
|
|
75
|
+
"Expand": "확장",
|
|
76
|
+
"Current filter": "현재 필터",
|
|
77
|
+
"Add custom field": "사용자 정의 필드 추가",
|
|
78
|
+
"To filter with custom fields, use 'Current filter' variables in the chart configuration.": "사용자 정의 필드로 필터링하려면 차트 구성에서 '현재 필터' 변수를 사용하세요.",
|
|
79
|
+
"Input": "입력",
|
|
80
|
+
"Date range": "날짜 범위",
|
|
81
|
+
"Time range": "시간 범위",
|
|
82
|
+
"Edit field properties": "필드 속성 편집",
|
|
83
|
+
"Select a source field to use metadata of the field": "필드의 메타데이터 구성에 사용할 소스 필드를 선택하세요.",
|
|
84
|
+
"Original field": "원본 필드"
|
|
85
|
+
}
|
|
@@ -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-01-
|
|
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-01-26T14:13:00.931Z"}
|
|
@@ -43,20 +43,21 @@ var import_utils = require("@nocobase/utils");
|
|
|
43
43
|
const postProcess = async (ctx, next) => {
|
|
44
44
|
const { data, fieldMap } = ctx.action.params.values;
|
|
45
45
|
ctx.body = data.map((record) => {
|
|
46
|
-
const result = {};
|
|
47
46
|
Object.entries(record).forEach(([key, value]) => {
|
|
47
|
+
if (!value) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
48
50
|
const { type } = fieldMap[key] || {};
|
|
49
51
|
switch (type) {
|
|
50
52
|
case "bigInt":
|
|
51
53
|
case "integer":
|
|
52
54
|
case "float":
|
|
53
55
|
case "double":
|
|
54
|
-
|
|
56
|
+
record[key] = Number(value);
|
|
55
57
|
break;
|
|
56
58
|
}
|
|
57
|
-
result[key] = value;
|
|
58
59
|
});
|
|
59
|
-
return
|
|
60
|
+
return record;
|
|
60
61
|
});
|
|
61
62
|
await next();
|
|
62
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-data-visualization",
|
|
3
|
-
"version": "0.19.0-alpha.
|
|
3
|
+
"version": "0.19.0-alpha.4",
|
|
4
4
|
"displayName": "Data Visualization",
|
|
5
5
|
"displayName.zh-CN": "数据可视化",
|
|
6
6
|
"description": "Provides business intelligence and data visualization features",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@nocobase/test": "0.x",
|
|
32
32
|
"@nocobase/utils": "0.x"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "9583023f7bea828da5192384a5c002782c341b65"
|
|
35
35
|
}
|