@devtable/dashboard 10.60.0 → 10.60.1
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/dashboard.es.js +9 -3
- package/dist/dashboard.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -1098,8 +1098,14 @@ function Z(e, {
|
|
|
1098
1098
|
absolute: t,
|
|
1099
1099
|
...n
|
|
1100
1100
|
}) {
|
|
1101
|
-
|
|
1102
|
-
|
|
1101
|
+
if (e === null)
|
|
1102
|
+
return "";
|
|
1103
|
+
try {
|
|
1104
|
+
let s = ni(e).value();
|
|
1105
|
+
return t && (s = Math.abs(s)), ni(s).format(n);
|
|
1106
|
+
} catch (s) {
|
|
1107
|
+
return console.error(s), "";
|
|
1108
|
+
}
|
|
1103
1109
|
}
|
|
1104
1110
|
function nm(e) {
|
|
1105
1111
|
return e === null ? "null" : e === void 0 ? "undefined" : Array.isArray(e) ? `Array(${e.length})` : e.toString();
|
|
@@ -1747,7 +1753,7 @@ class Ri {
|
|
|
1747
1753
|
}), this.instanceRegistry.clear(), this.factoryRegistry.clear();
|
|
1748
1754
|
}
|
|
1749
1755
|
}
|
|
1750
|
-
const rc = "10.60.
|
|
1756
|
+
const rc = "10.60.1", Lm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1751
1757
|
__proto__: null,
|
|
1752
1758
|
version: rc
|
|
1753
1759
|
}, Symbol.toStringTag, { value: "Module" }));
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -52,8 +52,8 @@ Check the top-level render call using <`+A+">.")}return D}}function Rc(w,D){{if(
|
|
|
52
52
|
</tbody>
|
|
53
53
|
</table>
|
|
54
54
|
`;function ds(e,t){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(i){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):i}}function ps(e,t){try{return ds(e,t)}catch(n){return console.error(n),n.message}}function Ru({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},mt)}catch(n){return console.error(n),e}}function Qu(e,t,n){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,mt,n)}catch(r){return console.error(r),t}}function Uu(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i!="authentication"&&e[i])n.push(t[r]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const o=Object.keys(e[i]).sort();for(let l=0;l<o.length;l++){const c=o[l];c!="sign"&&e[i][c]&&n.push(o[l]+"="+(typeof e[i][c]=="object"?JSON.stringify(e[i][c]):e[i][c]))}}}return n.sort().join("&")}function Ku(e,t){let n=Uu(e);return n+="&key="+t,$u.MD5(n).toString().toUpperCase()}class Ui{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:Ku({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}}getRequest(t,n){return(r,i,o,l)=>{const c=this.buildHeader(o),u=this.buildAxiosConfig(t,r,i,o,c,n);return tt(u).then(d=>l?d:d.data).catch(d=>Promise.reject(d))}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,n,r,i,o,l){const c={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?r:i.params,headers:o,signal:l};return["POST","PUT"].includes(t)&&(c.data=i.string?JSON.stringify(r):r,c.data.authentication=this.getAuthentication(c.data)),c}buildHeader(t){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...t.headers}}}class Yu{constructor(t){this.implementation=t}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}class Ki extends Ui{constructor(){super(...arguments);P(this,"makeQueryENV",null)}query(n){return async(r,i={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.post(n)("/query",r,i)}}httpDataSourceQuery(n){return async(r,i={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",n)("/query",r,i,!0)}}structure(n){return async(r,i={})=>this.post(n)("/query/structure",r,i)}}class Yi{constructor(t){this.implementation=t}query(t){return this.implementation.query(t)}httpDataSourceQuery(t){return this.implementation.httpDataSourceQuery(t)}structure(t){return this.implementation.structure(t)}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const It=new Ki;function hs(e){It.baseURL!==e.apiBaseURL&&(It.baseURL=e.apiBaseURL),e.app_id&&(It.app_id=e.app_id),e.app_secret&&(It.app_secret=e.app_secret),e.makeQueryENV&&(It.makeQueryENV=e.makeQueryENV)}const Xi=new Yi(It),Xe=Xi,Rt=f.forwardRef(function({value:t,onChange:n,...r},i){return s.jsx(a.TextInput,{ref:i,value:t,onChange:n,...r})});function z(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function Xu(e){return e.includes(".")?z(e):{queryID:"",columnKey:e}}function st(e,t){var i;const{queryID:n,columnKey:r}=z(t);return n?r?((i=e[n])==null?void 0:i.map(o=>o[r]))??[]:e[n]:[]}function Qt(e,t){const{queryID:n}=z(t);return n?e[n]:[]}function Ju(e){return Object.values(e)[0]}function pn(e,t){const{queryID:n,columnKey:r}=z(t);return e[r]}const Ji=["function aggregation({ queryData }, utils) {",' return "Aggregation Result";',"}"].join(`
|
|
55
|
-
`),Mt={type:"none",config:{},fallback:"0"};function Zu(e){const t=Array.from(e).sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function Hu(e,t){switch(t.type){case"sum":return y.sum(e);case"mean":return y.mean(e);case"median":return Zu(e);case"max":return y.max(e);case"min":return y.min(e);case"quantile":return qt.quantile(e,t.config.p);case"CV":const n=dn.std(...e),r=dn.mean(...e);return r?n/r:Number.NaN;case"std":return dn.std(...e);default:return e}}function xs(e,t){const n=e.map(Number),r=Hu(n,t);return typeof r=="number"?Number.isFinite(r)?r:t.fallback:r??t.fallback}function ed(e,t,n){try{const r=Qt(e,t);return new Function(`return ${n.config.func}`)()({queryData:r},mt)}catch(r){return console.error(r),r.message}}function hn(e,t,n){try{return n.type==="custom"?ed(e,t,n):xs(st(e,t),n)}catch(r){return console.error(r),null}}class td{constructor({valueRange:t,colorRange:n}){P(this,"mapper");this.mapper=ft.interpolate(t,n)}getColor(t){return this.mapper(t)}}const be={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function W(e,{absolute:t,...n}){let r=as(e).value();return t&&(r=Math.abs(r)),as(r).format(n)}function nd(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function rt({data_field:e,aggregation:t},n){return hn(n,e,t)}function Le({formatter:e,aggregation:t},n){if(typeof n!="string"||typeof n!="number")return nd(n);if(t.type==="custom")return n;try{return W(n,e)}catch(r){return console.error(r),n}}function sd(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{if(typeof t!="number")throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}`);return new td(e).getColor(t)}catch(n){return console.error(n),"black"}return"black"}function rd(e,t){const{color:n,data_field:r,aggregation:i,size:o,weight:l}=e,c=hn(t,r,i),u=Le(e,c);return s.jsx(a.Text,{sx:{fontSize:o,display:"inline"},color:sd(n,c),weight:l,children:u})}function id(e,t){const n={};return e.forEach(r=>{const i=r.name;n[i]=rd(r,t)}),n}function ad(e){return e.split(" ").map((t,n)=>s.jsxs(f.Fragment,{children:[t," "]},n))}function od(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
|
|
56
|
-
`,"<br/>").split("<br/>");return n.map((i,o)=>{const l=[ad(i)];return o!==n.length-1&&l.push(s.jsx("br",{},`br-${o}`)),l}).flat().filter(i=>i!==void 0)}function fs(e){return od(e)}function Ut(e,t,n){const r=id(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map((o,l)=>{const c=i.exec(o);if(!c)return fs(o);const u=r[c[1]];if(!u)return fs(o);const d=c[2]??"";return s.jsxs(f.Fragment,{children:[u,fs(d)]},`${o}-${l}`)})}function ld(e,t){const{data_field:n,aggregation:r}=e,i=hn(t,n,r);return Le(e,i)}function Zi(e,t){const n={};return e.forEach(r=>{n[r.name]=ld(r,t)}),n}function xn(e,t,n){const r=Zi(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{const l=i.exec(o);if(!l)return o;const c=r[l[1]];if(!c)return o;const u=l[2]??"";return`${c}${u}`}).join("")}const gs={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function cd(){K.registerTheme("merico-light",{color:Object.values(gs.graphics.multiple),visualMap:{color:Object.values(gs.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function Hi(){cd()}function*ud(e){const t=gs.graphics[e];if(!t)throw new Error("Invalid palette key provided");const n=Object.values(t);let r=0;for(;;)yield n[r%n.length],r++}function ea(){return{filters:{},context:{}}}function ms(e){const t=ea();if(!e)return ea();const{filters:n=t.filters,context:r=t.context}=e;return{filters:n,context:r}}const dd=new Zc.AsyncParser({withBOM:!0});async function ta(e){return!Array.isArray(e)||e.length===0?"":await dd.parse(e).promise()}async function pd(e,t){const n=await ta(t),r=new Blob([n],{type:"text/csv"});os.saveAs(r,`${e}.csv`)}function na(e){const t=new Hc,n=e.map(async({id:r,data:i})=>{const o=await ta(i);t.file(`${r}.csv`,o)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(r=>{os.saveAs(r,"dashboard_data.zip")})}).catch(r=>{console.error(r),gt.notifications.show({color:"red",title:"Failed to download data",message:r.message})})}function yt(e,t){const n=new Blob([t],{type:"application/json"});os.saveAs(n,`${e}.json`)}class Se extends f.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return s.jsxs(a.Box,{children:[s.jsx(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),s.jsx(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function hd(e,t){return new Function(`return ${e}`)()(t,mt)}function xd(e,t,n){return hd(e,{context:t,filters:n})}function fd(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,mt)}catch(n){return console.error(n),t}}function gd(e,t){return new Function(`return ${e.config.processing.post}`)()(t,mt)}function md(e,t,n){return e?new Function(`return ${e}`)()(t,mt,n):t}const fn=e=>y.cloneDeepWith(e,(t,n)=>{if(n!==void 0&&t)return R.toJS(t)}),gn={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function yd(e,t){const n=ki.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function bd({query:e,name:t,payload:n,additionals:r},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=ds(c,n),h=Ru({sql:p,pre_process:u}),x=ki.encode(h);yd(h,x);let m=await Xe.query(i)({type:o,key:l,query:x,...r},{params:{name:t}});return m=Qu(d,m,ms(n)),m}async function jd({type:e,key:t,configString:n,name:r,additionals:i},o){try{return await Xe.httpDataSourceQuery(o)({type:e,key:t,query:n,...i},{params:{name:r}})}catch(l){if(tt.isCancel(l))throw l;return console.error(l),l}}async function ys(){try{return(await Xe.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function sa(){try{return(await Xe.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class ra{constructor(t){P(this,"rootRef");this.rootRef=R.observable({current:t})}async deleteItem(t){R.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?R.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(y.isObject(n))R.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else R.runInAction(()=>{y.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return R.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:y.get(r,"fireImmediately",!1)})}}class vd{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new Ti)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Ti;return this.channels.set(t,r),r}}class wd{constructor(t){P(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new vd,instanceData:new ra(t.viz.conf)};return this.instances.set(t.id,r),r}}function ia(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ra({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const Cd=e=>{const{panel:t,vizManager:n,data:r,variables:i}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),c={...ia(l,r,n,i),viewport:{width:t.layout.w,height:t.layout.h}},u=o.viewRender;return s.jsx(u,{context:c,instance:l,...y.omit(e,["panel","vizManager","data"])})},Sd=e=>{const{vizManager:t,panel:n,data:r,variables:i}=e,o=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...ia(l,r,t,i)},u=o.configRender;return s.jsx(u,{context:c,instance:l,...y.omit(e,["panel","vizManager","data"])})},aa=(e,t)=>{const n=nt.bezier(e),r=nt.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},mn=e=>{const t=nt.bezier(e);return function(n){return t(n/100).hex()}},_d={type:"interpolation",displayName:"Red / Green",getColor:aa(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},kd={type:"interpolation",displayName:"Yellow / Blue",getColor:aa(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Td={type:"interpolation",displayName:"Red",getColor:mn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Dd={type:"interpolation",displayName:"Green",getColor:mn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Id={type:"interpolation",displayName:"Blue",getColor:mn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Md={type:"interpolation",displayName:"Orange",getColor:mn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class zd{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function it(e){return new zd(e)}class bs{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new bs;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=y.get(t,"dispose");y.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const oa="10.60.0",Ad=Object.freeze(Object.defineProperty({__proto__:null,version:oa},Symbol.toStringTag,{value:"Module"}));class Ed{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Pd{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Ld{constructor(){P(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),o=y.orderBy(i,"version","asc");if(((l=y.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,u)=>u.handler(c,r),n)}}class ie extends Ld{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,i)=>({version:t,...n(r,i)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),i=y.get(r,"version",0),o=this.run({from:i,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return y.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:r}]=V.useBoolean(!0),[i,o]=f.useState();f.useEffect(()=>(e.getItem(t).then(c=>{o(c),r()}),e.watchItem(t,c=>{o(c)})));const l=f.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:n,value:i,set:l}},De={top:16,right:16,bottom:16,left:16},We=e=>Math.max(0,e-De.left-De.right),Re=e=>Math.max(0,e-De.top-De.bottom),Kt=(e,t)=>({width:We(e),height:Re(t)}),Ie=({width:e,height:t,children:n})=>s.jsx(a.Box,{pt:De.top,pr:De.right,pb:De.bottom,pl:De.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),js={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};K.use([O.GridComponent,O.VisualMapComponent,O.LegendComponent,O.TooltipComponent,Ce.CanvasRenderer]);function Od({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:r,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=y.defaults({},t,js),h=f.useMemo(()=>Qt(n,o),[n,o]),{x,y:m,z:j}=f.useMemo(()=>({x:z(o),y:z(l),z:z(c)}),[o,l,c]),{min:C,max:T}=f.useMemo(()=>{const E=y.minBy(h,H=>H[j.columnKey]),F=y.maxBy(h,H=>H[j.columnKey]);return{min:y.get(E,j.columnKey),max:y.get(F,j.columnKey)}},[h,j]),M={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:C,max:T,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(E=>[E[x.columnKey],E[m.columnKey],E[j.columnKey]])}]};return t?s.jsx(Ie,{width:r,height:i,children:s.jsx(we,{echarts:K,option:M,style:Kt(r,i),notMerge:!0,theme:"merico-light"})}):null}const la=f.createContext(null),vs=la.Provider;function ws(){const e=f.useContext(la);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Y=()=>ws(),Cs=()=>ws(),ca=f.createContext({searchButtonProps:{}}),Ss=ca.Provider;function ua(){return f.useContext(ca)}const da=f.createContext(null),_s=da.Provider;function pa(){const e=f.useContext(da);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const X=()=>pa(),ce=()=>pa(),Bd={inEditMode:!1},yn=f.createContext(Bd),ha=f.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),ks=ha.Provider;function xa(){const e=f.useContext(ha);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const pt=()=>xa(),Oe=()=>xa(),$d={fullScreenPanelID:"",setFullScreenPanelID:y.noop},Ts=f.createContext($d);function fa(){const e=f.useContext(Ts);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const B=S.observer(f.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:i=!1,sx:o,...l},c)=>{const{panel:u}=Oe(),d=f.useMemo(()=>u.dataFieldOptions(n,i),[n,i]);if(d.length===0){const p=u.explainDataKey(n);return s.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.Box,{children:s.jsx(a.TextInput,{label:e,required:t,defaultValue:p.columnKey,readOnly:!0,disabled:!0})})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsxs(a.Group,{position:"left",spacing:0,children:[s.jsx(a.Text,{size:"xs",color:p.queryName?"black":"red",sx:{fontFamily:"monospace"},children:p.queryName??p.queryID}),s.jsx(a.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),s.jsx(a.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:p.columnKey})]})})]})}return s.jsx(a.Select,{ref:c,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function Vd({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),r=y.defaults({},t,js),{control:i,handleSubmit:o,reset:l}=b.useForm({defaultValues:r});return f.useEffect(()=>{l(r)},[t]),t?s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:o(n),children:[s.jsx(a.Text,{children:"X Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Text,{mt:"lg",children:"Y Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Text,{mt:"lg",children:"Z Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:s.jsxs(a.Button,{color:"blue",type:"submit",children:[s.jsx(_.DeviceFloppy,{size:20}),s.jsx(a.Text,{ml:"md",children:"Save"})]})})]})}):null}function Nd(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:o,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:r(i),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class qd extends ie{constructor(){super(...arguments);P(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:i}=n;return{...n,version:2,config:Nd(i,r)}})}}const Fd={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new qd,name:"bar-3d",viewRender:Od,configRender:Vd,createConfig(){return{version:2,config:y.cloneDeep(js)}}},Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
55
|
+
`),Mt={type:"none",config:{},fallback:"0"};function Zu(e){const t=Array.from(e).sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function Hu(e,t){switch(t.type){case"sum":return y.sum(e);case"mean":return y.mean(e);case"median":return Zu(e);case"max":return y.max(e);case"min":return y.min(e);case"quantile":return qt.quantile(e,t.config.p);case"CV":const n=dn.std(...e),r=dn.mean(...e);return r?n/r:Number.NaN;case"std":return dn.std(...e);default:return e}}function xs(e,t){const n=e.map(Number),r=Hu(n,t);return typeof r=="number"?Number.isFinite(r)?r:t.fallback:r??t.fallback}function ed(e,t,n){try{const r=Qt(e,t);return new Function(`return ${n.config.func}`)()({queryData:r},mt)}catch(r){return console.error(r),r.message}}function hn(e,t,n){try{return n.type==="custom"?ed(e,t,n):xs(st(e,t),n)}catch(r){return console.error(r),null}}class td{constructor({valueRange:t,colorRange:n}){P(this,"mapper");this.mapper=ft.interpolate(t,n)}getColor(t){return this.mapper(t)}}const be={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function W(e,{absolute:t,...n}){if(e===null)return"";try{let r=as(e).value();return t&&(r=Math.abs(r)),as(r).format(n)}catch(r){return console.error(r),""}}function nd(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function rt({data_field:e,aggregation:t},n){return hn(n,e,t)}function Le({formatter:e,aggregation:t},n){if(typeof n!="string"||typeof n!="number")return nd(n);if(t.type==="custom")return n;try{return W(n,e)}catch(r){return console.error(r),n}}function sd(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{if(typeof t!="number")throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}`);return new td(e).getColor(t)}catch(n){return console.error(n),"black"}return"black"}function rd(e,t){const{color:n,data_field:r,aggregation:i,size:o,weight:l}=e,c=hn(t,r,i),u=Le(e,c);return s.jsx(a.Text,{sx:{fontSize:o,display:"inline"},color:sd(n,c),weight:l,children:u})}function id(e,t){const n={};return e.forEach(r=>{const i=r.name;n[i]=rd(r,t)}),n}function ad(e){return e.split(" ").map((t,n)=>s.jsxs(f.Fragment,{children:[t," "]},n))}function od(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
|
|
56
|
+
`,"<br/>").split("<br/>");return n.map((i,o)=>{const l=[ad(i)];return o!==n.length-1&&l.push(s.jsx("br",{},`br-${o}`)),l}).flat().filter(i=>i!==void 0)}function fs(e){return od(e)}function Ut(e,t,n){const r=id(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map((o,l)=>{const c=i.exec(o);if(!c)return fs(o);const u=r[c[1]];if(!u)return fs(o);const d=c[2]??"";return s.jsxs(f.Fragment,{children:[u,fs(d)]},`${o}-${l}`)})}function ld(e,t){const{data_field:n,aggregation:r}=e,i=hn(t,n,r);return Le(e,i)}function Zi(e,t){const n={};return e.forEach(r=>{n[r.name]=ld(r,t)}),n}function xn(e,t,n){const r=Zi(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{const l=i.exec(o);if(!l)return o;const c=r[l[1]];if(!c)return o;const u=l[2]??"";return`${c}${u}`}).join("")}const gs={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function cd(){K.registerTheme("merico-light",{color:Object.values(gs.graphics.multiple),visualMap:{color:Object.values(gs.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function Hi(){cd()}function*ud(e){const t=gs.graphics[e];if(!t)throw new Error("Invalid palette key provided");const n=Object.values(t);let r=0;for(;;)yield n[r%n.length],r++}function ea(){return{filters:{},context:{}}}function ms(e){const t=ea();if(!e)return ea();const{filters:n=t.filters,context:r=t.context}=e;return{filters:n,context:r}}const dd=new Zc.AsyncParser({withBOM:!0});async function ta(e){return!Array.isArray(e)||e.length===0?"":await dd.parse(e).promise()}async function pd(e,t){const n=await ta(t),r=new Blob([n],{type:"text/csv"});os.saveAs(r,`${e}.csv`)}function na(e){const t=new Hc,n=e.map(async({id:r,data:i})=>{const o=await ta(i);t.file(`${r}.csv`,o)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(r=>{os.saveAs(r,"dashboard_data.zip")})}).catch(r=>{console.error(r),gt.notifications.show({color:"red",title:"Failed to download data",message:r.message})})}function yt(e,t){const n=new Blob([t],{type:"application/json"});os.saveAs(n,`${e}.json`)}class Se extends f.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return s.jsxs(a.Box,{children:[s.jsx(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),s.jsx(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function hd(e,t){return new Function(`return ${e}`)()(t,mt)}function xd(e,t,n){return hd(e,{context:t,filters:n})}function fd(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,mt)}catch(n){return console.error(n),t}}function gd(e,t){return new Function(`return ${e.config.processing.post}`)()(t,mt)}function md(e,t,n){return e?new Function(`return ${e}`)()(t,mt,n):t}const fn=e=>y.cloneDeepWith(e,(t,n)=>{if(n!==void 0&&t)return R.toJS(t)}),gn={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function yd(e,t){const n=ki.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function bd({query:e,name:t,payload:n,additionals:r},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=ds(c,n),h=Ru({sql:p,pre_process:u}),x=ki.encode(h);yd(h,x);let m=await Xe.query(i)({type:o,key:l,query:x,...r},{params:{name:t}});return m=Qu(d,m,ms(n)),m}async function jd({type:e,key:t,configString:n,name:r,additionals:i},o){try{return await Xe.httpDataSourceQuery(o)({type:e,key:t,query:n,...i},{params:{name:r}})}catch(l){if(tt.isCancel(l))throw l;return console.error(l),l}}async function ys(){try{return(await Xe.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function sa(){try{return(await Xe.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class ra{constructor(t){P(this,"rootRef");this.rootRef=R.observable({current:t})}async deleteItem(t){R.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?R.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(y.isObject(n))R.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else R.runInAction(()=>{y.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return R.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:y.get(r,"fireImmediately",!1)})}}class vd{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new Ti)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Ti;return this.channels.set(t,r),r}}class wd{constructor(t){P(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new vd,instanceData:new ra(t.viz.conf)};return this.instances.set(t.id,r),r}}function ia(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ra({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const Cd=e=>{const{panel:t,vizManager:n,data:r,variables:i}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),c={...ia(l,r,n,i),viewport:{width:t.layout.w,height:t.layout.h}},u=o.viewRender;return s.jsx(u,{context:c,instance:l,...y.omit(e,["panel","vizManager","data"])})},Sd=e=>{const{vizManager:t,panel:n,data:r,variables:i}=e,o=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...ia(l,r,t,i)},u=o.configRender;return s.jsx(u,{context:c,instance:l,...y.omit(e,["panel","vizManager","data"])})},aa=(e,t)=>{const n=nt.bezier(e),r=nt.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},mn=e=>{const t=nt.bezier(e);return function(n){return t(n/100).hex()}},_d={type:"interpolation",displayName:"Red / Green",getColor:aa(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},kd={type:"interpolation",displayName:"Yellow / Blue",getColor:aa(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Td={type:"interpolation",displayName:"Red",getColor:mn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Dd={type:"interpolation",displayName:"Green",getColor:mn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Id={type:"interpolation",displayName:"Blue",getColor:mn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Md={type:"interpolation",displayName:"Orange",getColor:mn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class zd{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function it(e){return new zd(e)}class bs{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new bs;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=y.get(t,"dispose");y.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const oa="10.60.1",Ad=Object.freeze(Object.defineProperty({__proto__:null,version:oa},Symbol.toStringTag,{value:"Module"}));class Ed{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Pd{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Ld{constructor(){P(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),o=y.orderBy(i,"version","asc");if(((l=y.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,u)=>u.handler(c,r),n)}}class ie extends Ld{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,i)=>({version:t,...n(r,i)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),i=y.get(r,"version",0),o=this.run({from:i,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return y.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:r}]=V.useBoolean(!0),[i,o]=f.useState();f.useEffect(()=>(e.getItem(t).then(c=>{o(c),r()}),e.watchItem(t,c=>{o(c)})));const l=f.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:n,value:i,set:l}},De={top:16,right:16,bottom:16,left:16},We=e=>Math.max(0,e-De.left-De.right),Re=e=>Math.max(0,e-De.top-De.bottom),Kt=(e,t)=>({width:We(e),height:Re(t)}),Ie=({width:e,height:t,children:n})=>s.jsx(a.Box,{pt:De.top,pr:De.right,pb:De.bottom,pl:De.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),js={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};K.use([O.GridComponent,O.VisualMapComponent,O.LegendComponent,O.TooltipComponent,Ce.CanvasRenderer]);function Od({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:r,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=y.defaults({},t,js),h=f.useMemo(()=>Qt(n,o),[n,o]),{x,y:m,z:j}=f.useMemo(()=>({x:z(o),y:z(l),z:z(c)}),[o,l,c]),{min:C,max:T}=f.useMemo(()=>{const E=y.minBy(h,H=>H[j.columnKey]),F=y.maxBy(h,H=>H[j.columnKey]);return{min:y.get(E,j.columnKey),max:y.get(F,j.columnKey)}},[h,j]),M={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:C,max:T,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(E=>[E[x.columnKey],E[m.columnKey],E[j.columnKey]])}]};return t?s.jsx(Ie,{width:r,height:i,children:s.jsx(we,{echarts:K,option:M,style:Kt(r,i),notMerge:!0,theme:"merico-light"})}):null}const la=f.createContext(null),vs=la.Provider;function ws(){const e=f.useContext(la);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Y=()=>ws(),Cs=()=>ws(),ca=f.createContext({searchButtonProps:{}}),Ss=ca.Provider;function ua(){return f.useContext(ca)}const da=f.createContext(null),_s=da.Provider;function pa(){const e=f.useContext(da);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const X=()=>pa(),ce=()=>pa(),Bd={inEditMode:!1},yn=f.createContext(Bd),ha=f.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),ks=ha.Provider;function xa(){const e=f.useContext(ha);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const pt=()=>xa(),Oe=()=>xa(),$d={fullScreenPanelID:"",setFullScreenPanelID:y.noop},Ts=f.createContext($d);function fa(){const e=f.useContext(Ts);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const B=S.observer(f.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:i=!1,sx:o,...l},c)=>{const{panel:u}=Oe(),d=f.useMemo(()=>u.dataFieldOptions(n,i),[n,i]);if(d.length===0){const p=u.explainDataKey(n);return s.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.Box,{children:s.jsx(a.TextInput,{label:e,required:t,defaultValue:p.columnKey,readOnly:!0,disabled:!0})})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsxs(a.Group,{position:"left",spacing:0,children:[s.jsx(a.Text,{size:"xs",color:p.queryName?"black":"red",sx:{fontFamily:"monospace"},children:p.queryName??p.queryID}),s.jsx(a.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),s.jsx(a.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:p.columnKey})]})})]})}return s.jsx(a.Select,{ref:c,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function Vd({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),r=y.defaults({},t,js),{control:i,handleSubmit:o,reset:l}=b.useForm({defaultValues:r});return f.useEffect(()=>{l(r)},[t]),t?s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:o(n),children:[s.jsx(a.Text,{children:"X Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Text,{mt:"lg",children:"Y Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Text,{mt:"lg",children:"Z Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:s.jsxs(a.Button,{color:"blue",type:"submit",children:[s.jsx(_.DeviceFloppy,{size:20}),s.jsx(a.Text,{ml:"md",children:"Save"})]})})]})}):null}function Nd(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:o,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:r(i),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class qd extends ie{constructor(){super(...arguments);P(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:i}=n;return{...n,version:2,config:Nd(i,r)}})}}const Fd={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new qd,name:"bar-3d",viewRender:Od,configRender:Vd,createConfig(){return{version:2,config:y.cloneDeep(js)}}},Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
57
57
|
`)},ga={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:Wd,configRender:Gd,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Gd(e){return s.jsx(s.Fragment,{})}function Wd(e){return s.jsx(a.Text,{children:"Click chart's series"})}const Rd=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],bn=f.forwardRef(({sectionTitle:e,value:t,onChange:n},r)=>{const i=o=>l=>{const c=y.cloneDeep(t);y.set(c,o,l),n(c)};return s.jsxs(a.Stack,{spacing:0,children:[e&&s.jsx(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(a.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:i("width")}),s.jsx(a.Select,{label:"Overflow",data:Rd,value:t.overflow,onChange:i("overflow")}),s.jsx(a.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),Je=f.forwardRef(({value:e,onChange:t},n)=>{const r=o=>{t({...e,on_axis:o})},i=o=>{t({...e,in_tooltip:o})};return s.jsxs(a.Stack,{ref:n,spacing:0,children:[s.jsx(bn,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:r}),s.jsx(bn,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:i})]})}),Ae={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function Qe({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],r=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
58
58
|
max-width: ${t}px;
|
|
59
59
|
word-break: ${n};
|