@devtable/dashboard 8.58.2 → 8.59.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 +8 -8
- package/dist/dashboard.umd.js +4 -4
- package/dist/filter/filter.d.ts +1 -1
- package/dist/main/dashboard-editor/index.d.ts +1 -1
- package/dist/plugins/viz-components/cartesian/option/y-axis.d.ts +1 -1
- package/dist/plugins/viz-components/funnel/option/index.d.ts +1 -1
- package/dist/plugins/viz-components/funnel/option/series.d.ts +1 -1
- package/dist/plugins/viz-components/heatmap/option/y-axis.d.ts +1 -1
- package/dist/plugins/viz-components/pareto-chart/option/index.d.ts +2 -2
- package/dist/plugins/viz-components/pareto-chart/option/y-axes.d.ts +2 -2
- package/dist/plugins/viz-components/scatter-chart/option/y-axis.d.ts +1 -1
- package/dist/plugins/viz-components/sunburst/option/levels.d.ts +1 -1
- package/package.json +5 -5
package/dist/dashboard.es.js
CHANGED
|
@@ -1914,7 +1914,7 @@ const gu = (e) => {
|
|
|
1914
1914
|
getColor: gr(["#fff7f1", "darkorange", "#b60000"]),
|
|
1915
1915
|
name: "orange",
|
|
1916
1916
|
category: "sequential"
|
|
1917
|
-
}, _s = "@devtable/dashboard", Bi = "8.
|
|
1917
|
+
}, _s = "@devtable/dashboard", Bi = "8.59.1", Cs = "Apache-2.0", Ss = {
|
|
1918
1918
|
access: "public",
|
|
1919
1919
|
registry: "https://registry.npmjs.org/"
|
|
1920
1920
|
}, ks = [
|
|
@@ -1979,7 +1979,7 @@ const gu = (e) => {
|
|
|
1979
1979
|
"@tiptap/react": "2.0.1",
|
|
1980
1980
|
"@tiptap/starter-kit": "2.0.1",
|
|
1981
1981
|
"@types/crypto-js": "v4.1.1",
|
|
1982
|
-
"@types/d3-array": "3.0.
|
|
1982
|
+
"@types/d3-array": "3.0.4",
|
|
1983
1983
|
"@types/eventemitter2": "^4.1.0",
|
|
1984
1984
|
"@types/file-saver": "2.0.5",
|
|
1985
1985
|
"@types/lodash": "^4.14.182",
|
|
@@ -2013,7 +2013,7 @@ const gu = (e) => {
|
|
|
2013
2013
|
typescript: "^4.6.3",
|
|
2014
2014
|
"vite-plugin-static-copy": "0.13.1"
|
|
2015
2015
|
}, As = {
|
|
2016
|
-
"@emotion/react": "11.10.
|
|
2016
|
+
"@emotion/react": "11.10.6",
|
|
2017
2017
|
"@mantine/core": "5.9.5",
|
|
2018
2018
|
"@mantine/dates": "5.9.5",
|
|
2019
2019
|
"@mantine/form": "5.9.5",
|
|
@@ -2045,9 +2045,9 @@ const gu = (e) => {
|
|
|
2045
2045
|
axios: "^0.27.2",
|
|
2046
2046
|
"chroma-js": "^2.4.2",
|
|
2047
2047
|
"crypto-js": "^4.1.1",
|
|
2048
|
-
"d3-array": "3.2.
|
|
2048
|
+
"d3-array": "3.2.3",
|
|
2049
2049
|
"d3-regression": "1.2.8",
|
|
2050
|
-
dayjs: "1.11.
|
|
2050
|
+
dayjs: "1.11.7",
|
|
2051
2051
|
echarts: "^5.3.2",
|
|
2052
2052
|
"echarts-for-react": "^3.0.2",
|
|
2053
2053
|
"echarts-gl": "^2.0.9",
|
|
@@ -7678,8 +7678,8 @@ const fg = `
|
|
|
7678
7678
|
{
|
|
7679
7679
|
// 80-20 line stuff
|
|
7680
7680
|
percentage: {
|
|
7681
|
-
x: string; //
|
|
7682
|
-
y: string; //
|
|
7681
|
+
x: string; // 20%
|
|
7682
|
+
y: string; // 80%
|
|
7683
7683
|
};
|
|
7684
7684
|
count: {
|
|
7685
7685
|
left: number; // 2
|
|
@@ -18406,7 +18406,7 @@ function n_({
|
|
|
18406
18406
|
return;
|
|
18407
18407
|
const o = e[a.source], l = e[a.target];
|
|
18408
18408
|
if (o && l && o.parentNode) {
|
|
18409
|
-
const s = e[o.parentNode], c = s.position.x, d = k.get(l, "style.height", 0), p = Number(s.style.width);
|
|
18409
|
+
const s = e[o.parentNode], c = s.position.x, d = Number(k.get(l, "style.height", 0)), p = Number(s.style.width);
|
|
18410
18410
|
l.position.x = c + p + Hw, s._view_level === 0 && l._sub_view_ids.length === 0 && (o.sourcePosition = rt.Left, l.targetPosition = rt.Right, l.position.x *= -1);
|
|
18411
18411
|
const h = l.position.x, g = k.get(i, h, 0);
|
|
18412
18412
|
l.position.y = g, i[h] = g + d + Ol;
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -24,7 +24,7 @@ Check the render method of \``+_+"`."}return""}}function K0(_){{if(_!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+I+":"+E+"."}return""}}var Fs={};function J0(_){{var I=qs();if(!I){var E=typeof _=="string"?_:_.displayName||_.name;E&&(I=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=J0(I);if(Fs[E])return;Fs[E]=!0;var Y="";_&&_._owner&&_._owner!==ni.current&&(Y=" It was passed a child from "+se(_._owner.type)+"."),gt(_),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,Y),gt(null)}}function Rs(_,I){{if(typeof _!="object")return;if(ei(_))for(var E=0;E<_.length;E++){var Y=_[E];ii(Y)&&Ws(Y,I)}else if(ii(_))_._store&&(_._store.validated=!0);else if(_){var ie=S(_);if(typeof ie=="function"&&ie!==_.entries)for(var le=ie.call(_),ee;!(ee=le.next()).done;)ii(ee.value)&&Ws(ee.value,I)}}}function H0(_){{var I=_.type;if(I==null||typeof I=="string")return;var E;if(typeof I=="function")E=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===d||I.$$typeof===g))E=I.propTypes;else return;if(E){var Y=se(I);N0(E,_.props,"prop",Y,_)}else if(I.PropTypes!==void 0&&!ri){ri=!0;var ie=se(I);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ew(_){{for(var I=Object.keys(_.props),E=0;E<I.length;E++){var Y=I[E];if(Y!=="children"&&Y!=="key"){gt(_),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),gt(null);break}}_.ref!==null&&(gt(_),z("Invalid attribute `ref` supplied to `React.Fragment`."),gt(null))}}function Ys(_,I,E,Y,ie,le){{var ee=j(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Te=K0(ie);Te?J+=Te:J+=qs();var fe;_===null?fe="null":ei(_)?fe="array":_!==void 0&&_.$$typeof===t?(fe="<"+(se(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof _,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,J)}var be=Z0(_,I,E,ie,le);if(be==null)return be;if(ee){var $e=I.children;if($e!==void 0)if(Y)if(ei($e)){for(var mt=0;mt<$e.length;mt++)Rs($e[mt],_);Object.freeze&&Object.freeze($e)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Rs($e,_)}return _===i?ew(be):H0(be),be}}function tw(_,I,E){return Ys(_,I,E,!0)}function nw(_,I,E){return Ys(_,I,E,!1)}var rw=nw,iw=tw;xt.Fragment=i,xt.jsx=rw,xt.jsxs=iw}()),xt}(function(e){process.env.NODE_ENV==="production"?e.exports=ro():e.exports=io()})(no);const O=vt.Fragment,n=vt.jsx,p=vt.jsxs;function Si(e,t){m.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),m.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,y.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),m.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=y.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),m.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return y.cloneDeepWith(g,b=>{if(u&&typeof b=="string")return encodeURIComponent(b)})}const f=y.template(s||"")(d({...l,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class ao{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new ao(e)}class hn{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new hn;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 r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fn=m.createContext(null);function Bt(e){const t=m.useContext(fn),r=Z.useCreation(()=>e.configure(t||new hn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(fn.Provider,{value:r,children:e.children})}function Ti(){return m.useContext(fn)}const so={viewPanelInFullScreen:y.noop,inFullScreen:!1},gn=m.createContext(so),Di=m.createContext(null),mn=Di.Provider;function B(){const e=m.useContext(Di);if(!e)throw new Error("Please use ModelContextProvider");return e}class Ae extends m.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return p(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const bn={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},Nt=({value:e,styles:t={}})=>{const r=bi.useEditor({extensions:[vi,mi,X.Link,ui,li,si,pi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),gi,fi,hi,di.configure({types:["heading","paragraph"]}),oi.configure({placeholder:"This is placeholder"}),ci,ai.Color],content:e,editable:!1});m.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=m.useMemo(()=>y.defaultsDeep({},{content:bn},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},oo=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(Nt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),lo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(oo,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),ki=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?W(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&W(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(Qs.DateRangePicker,{label:e,value:s,onChange:o,icon:n(D.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),uo={layoutFrozen:!1,freezeLayout:y.noop,inEditMode:!1},Xe=m.createContext(uo),Ii=m.createContext({panel:null,data:[],loading:!1}),vn=Ii.Provider;function xe(){const e=m.useContext(Ii);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const co={fullScreenPanelID:"",setFullScreenPanelID:y.noop},yn=m.createContext(co);function Mi(){const e=m.useContext(yn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const Ai=m.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),po=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(a.MultiSelect,{label:e,data:t.options,disabled:c,value:r,onChange:i,styles:{root:{minWidth:d,maxWidth:c?d:"unset"},input:{borderColor:"#e9ecef"}},itemComponent:Ai})}),ho=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return m.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:Ai})});function fo({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function go(e){return Us.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const mo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),bo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(mo,{rotate:e?"0":"-90",onClick:i,...s})),vo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),yo=({onClick:e,...t})=>n(vo,{onClick:e,...t}),xo=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),Co=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=xo({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,b]=m.useState((l==null?void 0:l.length)>0),w=S=>{b(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(yi,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:bo,treeIcon:yo,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:yi.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function wo(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const _o=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=m.useMemo(()=>{if(!u)return[];const b=[...u],w=wo(b);return go(w)},[u,l]);m.useEffect(()=>{const{default_selection_count:b}=t;if(!b)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,b).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${b} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(Co,{disabled:h,style:{minWidth:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:b=>i(b,!1),treeData:c,label:e})}),So=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(ho,{...i,...s,config:t});case"multi-select":return n(po,{...i,...s,config:t});case"tree-select":return n(_o,{...i,...s,config:t});case"text-input":return n(fo,{...i,...s,config:t});case"date-range":return n(ki,{...i,...s,config:t});case"checkbox":return n(lo,{...i,...s,config:t});default:return null}}),zi=T.observer(m.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(Ae,{children:n(So,{filter:e,formFieldProps:t})})}))),$i=T.observer(function({view:t}){const r=B(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});m.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),m.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=m.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=m.useMemo(()=>l.filter(h=>y.get(h,"config.required",!1)),[l]),f=m.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,b)=>(w,C)=>{b(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:b})=>n(zi,{filter:h,value:b.value,onChange:g(h,b.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),lw="";function To(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Ei=T.observer(()=>{const{freezeLayout:e}=m.useContext(Xe),[t,r]=m.useState(!1),{panel:i}=xe();return m.useEffect(()=>{e(t)},[t]),To(i.description)?null:p(O,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(Nt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(D.InfoCircle,{size:20})})})]})}),Do=T.observer(({view:e})=>{const t=B(),r=Pe.useModals(),{panel:i}=xe(),{id:s,query:o}=i,{inEditMode:u}=m.useContext(Xe),l=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:d,inFullScreen:c}=m.useContext(gn),f=()=>{t.duplicatePanelByID(s,e.id)},g=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",s])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>t.removePanelByID(s,e.id),confirmProps:{color:"red"},zIndex:320}),b=m.useCallback(()=>{d(s)},[s,d]),w=!c&&e.type!==K.Modal;return n(O,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:l,icon:n(D.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID((o==null?void 0:o.id)??""),icon:n(D.Download,{size:14}),children:"Download Data"}),w&&n(a.Menu.Item,{onClick:b,icon:n(D.ArrowsMaximize,{size:14}),disabled:u,children:"Full Screen"}),u&&p(O,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:g,icon:n(D.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:f,icon:n(D.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:h,icon:n(D.Trash,{size:14}),children:"Delete"})]})]})]})})})}),uw="",ko=T.observer(function(){const{panel:t}=xe(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Oe=(e,t)=>{const[r,i]=m.useState([]);return m.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class st{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=y.get(s,t),l=y.get(o,t);u!==l&&r(u,l)},i)}}class xn{constructor(t,r,i){P(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new st(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new st(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new st(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(y.values(t).map(r=>this.constructInstance(new st(this.attachmentStorage,r.id))))}}class Li{constructor(t){P(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))ae.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ae.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:y.get(i,"fireImmediately",!1)})}}class Io{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new xi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new xi;return this.channels.set(t,i),i}}class Mo{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 r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Io,instanceData:new Li(t.viz.conf)};return this.instances.set(t.id,i),i}}function Pi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Li({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const Ao=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Pi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...y.omit(e,["panel","vizManager","data"])})},zo=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Pi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...y.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Oi=(e,t)=>{const r=Fe.bezier(e),i=Fe.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Gt=e=>{const t=Fe.bezier(e);return function(r){return t(r/100).hex()}},$o={type:"interpolation",displayName:"Red / Green",getColor:Oi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Eo={type:"interpolation",displayName:"Yellow / Blue",getColor:Oi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Lo={type:"interpolation",displayName:"Red",getColor:Gt(["#fff7f1","darkred"]),name:"red",category:"sequential"},Po={type:"interpolation",displayName:"Green",getColor:Gt(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Oo={type:"interpolation",displayName:"Blue",getColor:Gt(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Vo={type:"interpolation",displayName:"Orange",getColor:Gt(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Vi="@devtable/dashboard",Cn="8.58.2",Bi="Apache-2.0",Ni={access:"public",registry:"https://registry.npmjs.org/"},Gi=["dist"],qi="./dist/dashboard.umd.js",Fi="./dist/dashboard.es.js",Wi="./dist/index.d.ts",Ri={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Yi={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},ji={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.7.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Qi={"@emotion/babel-plugin":"11.7.2","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.3","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Ui={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.0","d3-regression":"1.2.8",dayjs:"1.11.6",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},Bo=Object.freeze(Object.defineProperty({__proto__:null,default:{name:Vi,version:Cn,license:Bi,publishConfig:Ni,files:Gi,main:qi,module:Fi,types:Wi,exports:Ri,scripts:Yi,dependencies:ji,devDependencies:Qi,peerDependencies:Ui},dependencies:ji,devDependencies:Qi,exports:Ri,files:Gi,license:Bi,main:qi,module:Fi,name:Vi,peerDependencies:Ui,publishConfig:Ni,scripts:Yi,types:Wi,version:Cn},Symbol.toStringTag,{value:"Module"}));class No{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&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(r,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 Go{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;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 r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class qo{constructor(){P(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,i){var u;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const s=this.migrations.filter(l=>l.version>t.from&&l.version<=t.to),o=y.orderBy(s,"version","asc");if(((u=y.last(o))==null?void 0:u.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((l,d)=>d.handler(l,i),r)}}class ge extends qo{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(i,s)=>({version:t,...r(i,s)}))}async migrate({configData:t,panelModel:r}){const i=await t.getItem(null),s=y.get(i,"version",0),o=this.run({from:s,to:this.VERSION},i,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return y.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:i}]=Z.useBoolean(!0),[s,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=m.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},wn={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"}};oe.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Ie.CanvasRenderer]);function Fo({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:c,zAxis3D:f}=y.defaults({},t,wn),g=m.useMemo(()=>{const w=y.minBy(r,C=>C[l]);return y.get(w,l)},[r,l]),h=m.useMemo(()=>{const w=y.maxBy(r,C=>C[l]);return y.get(w,l)},[r,l]),b={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Me,{echarts:oe,option:b,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function Wo({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=m.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:c,value:r,onChange:i,required:t,sx:u,...l})}const U=m.forwardRef(Wo);function Ro({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),i=e.data,s=y.defaults({},t,wn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(a.Button,{color:"blue",type:"submit",children:[n(D.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class Yo extends ge{constructor(){super(...arguments);P(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const jo={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new Yo,name:"bar-3d",viewRender:Fo,configRender:Ro,createConfig(){return{version:1,config:y.cloneDeep(wn)}}},De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Qo({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return p(a.Stack,{ref:r,children:[p(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:p(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(Ae,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(D.ArrowRight,{size:9})," ",ue(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(D.ArrowRight,{size:9})," ",ue(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(D.ArrowRight,{size:9})," ",ue(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(Qo),Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
27
|
+
Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=J0(I);if(Fs[E])return;Fs[E]=!0;var Y="";_&&_._owner&&_._owner!==ni.current&&(Y=" It was passed a child from "+se(_._owner.type)+"."),gt(_),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,Y),gt(null)}}function Rs(_,I){{if(typeof _!="object")return;if(ei(_))for(var E=0;E<_.length;E++){var Y=_[E];ii(Y)&&Ws(Y,I)}else if(ii(_))_._store&&(_._store.validated=!0);else if(_){var ie=S(_);if(typeof ie=="function"&&ie!==_.entries)for(var le=ie.call(_),ee;!(ee=le.next()).done;)ii(ee.value)&&Ws(ee.value,I)}}}function H0(_){{var I=_.type;if(I==null||typeof I=="string")return;var E;if(typeof I=="function")E=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===d||I.$$typeof===g))E=I.propTypes;else return;if(E){var Y=se(I);N0(E,_.props,"prop",Y,_)}else if(I.PropTypes!==void 0&&!ri){ri=!0;var ie=se(I);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ew(_){{for(var I=Object.keys(_.props),E=0;E<I.length;E++){var Y=I[E];if(Y!=="children"&&Y!=="key"){gt(_),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),gt(null);break}}_.ref!==null&&(gt(_),z("Invalid attribute `ref` supplied to `React.Fragment`."),gt(null))}}function Ys(_,I,E,Y,ie,le){{var ee=j(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Te=K0(ie);Te?J+=Te:J+=qs();var fe;_===null?fe="null":ei(_)?fe="array":_!==void 0&&_.$$typeof===t?(fe="<"+(se(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof _,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,J)}var be=Z0(_,I,E,ie,le);if(be==null)return be;if(ee){var $e=I.children;if($e!==void 0)if(Y)if(ei($e)){for(var mt=0;mt<$e.length;mt++)Rs($e[mt],_);Object.freeze&&Object.freeze($e)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Rs($e,_)}return _===i?ew(be):H0(be),be}}function tw(_,I,E){return Ys(_,I,E,!0)}function nw(_,I,E){return Ys(_,I,E,!1)}var rw=nw,iw=tw;xt.Fragment=i,xt.jsx=rw,xt.jsxs=iw}()),xt}(function(e){process.env.NODE_ENV==="production"?e.exports=ro():e.exports=io()})(no);const O=vt.Fragment,n=vt.jsx,p=vt.jsxs;function Si(e,t){m.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),m.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,y.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),m.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=y.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),m.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return y.cloneDeepWith(g,b=>{if(u&&typeof b=="string")return encodeURIComponent(b)})}const f=y.template(s||"")(d({...l,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class ao{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new ao(e)}class hn{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new hn;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 r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fn=m.createContext(null);function Bt(e){const t=m.useContext(fn),r=Z.useCreation(()=>e.configure(t||new hn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(fn.Provider,{value:r,children:e.children})}function Ti(){return m.useContext(fn)}const so={viewPanelInFullScreen:y.noop,inFullScreen:!1},gn=m.createContext(so),Di=m.createContext(null),mn=Di.Provider;function B(){const e=m.useContext(Di);if(!e)throw new Error("Please use ModelContextProvider");return e}class Ae extends m.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return p(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const bn={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},Nt=({value:e,styles:t={}})=>{const r=bi.useEditor({extensions:[vi,mi,X.Link,ui,li,si,pi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),gi,fi,hi,di.configure({types:["heading","paragraph"]}),oi.configure({placeholder:"This is placeholder"}),ci,ai.Color],content:e,editable:!1});m.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=m.useMemo(()=>y.defaultsDeep({},{content:bn},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},oo=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(Nt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),lo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(oo,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),ki=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?W(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&W(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(Qs.DateRangePicker,{label:e,value:s,onChange:o,icon:n(D.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),uo={layoutFrozen:!1,freezeLayout:y.noop,inEditMode:!1},Xe=m.createContext(uo),Ii=m.createContext({panel:null,data:[],loading:!1}),vn=Ii.Provider;function xe(){const e=m.useContext(Ii);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const co={fullScreenPanelID:"",setFullScreenPanelID:y.noop},yn=m.createContext(co);function Mi(){const e=m.useContext(yn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const Ai=m.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),po=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(a.MultiSelect,{label:e,data:t.options,disabled:c,value:r,onChange:i,styles:{root:{minWidth:d,maxWidth:c?d:"unset"},input:{borderColor:"#e9ecef"}},itemComponent:Ai})}),ho=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return m.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:Ai})});function fo({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function go(e){return Us.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const mo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),bo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(mo,{rotate:e?"0":"-90",onClick:i,...s})),vo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),yo=({onClick:e,...t})=>n(vo,{onClick:e,...t}),xo=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),Co=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=xo({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,b]=m.useState((l==null?void 0:l.length)>0),w=S=>{b(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(yi,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:bo,treeIcon:yo,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:yi.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function wo(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const _o=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=m.useMemo(()=>{if(!u)return[];const b=[...u],w=wo(b);return go(w)},[u,l]);m.useEffect(()=>{const{default_selection_count:b}=t;if(!b)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,b).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${b} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(Co,{disabled:h,style:{minWidth:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:b=>i(b,!1),treeData:c,label:e})}),So=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(ho,{...i,...s,config:t});case"multi-select":return n(po,{...i,...s,config:t});case"tree-select":return n(_o,{...i,...s,config:t});case"text-input":return n(fo,{...i,...s,config:t});case"date-range":return n(ki,{...i,...s,config:t});case"checkbox":return n(lo,{...i,...s,config:t});default:return null}}),zi=T.observer(m.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(Ae,{children:n(So,{filter:e,formFieldProps:t})})}))),$i=T.observer(function({view:t}){const r=B(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});m.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),m.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=m.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=m.useMemo(()=>l.filter(h=>y.get(h,"config.required",!1)),[l]),f=m.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,b)=>(w,C)=>{b(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:b})=>n(zi,{filter:h,value:b.value,onChange:g(h,b.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),lw="";function To(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Ei=T.observer(()=>{const{freezeLayout:e}=m.useContext(Xe),[t,r]=m.useState(!1),{panel:i}=xe();return m.useEffect(()=>{e(t)},[t]),To(i.description)?null:p(O,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(Nt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(D.InfoCircle,{size:20})})})]})}),Do=T.observer(({view:e})=>{const t=B(),r=Pe.useModals(),{panel:i}=xe(),{id:s,query:o}=i,{inEditMode:u}=m.useContext(Xe),l=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:d,inFullScreen:c}=m.useContext(gn),f=()=>{t.duplicatePanelByID(s,e.id)},g=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",s])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>t.removePanelByID(s,e.id),confirmProps:{color:"red"},zIndex:320}),b=m.useCallback(()=>{d(s)},[s,d]),w=!c&&e.type!==K.Modal;return n(O,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:l,icon:n(D.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID((o==null?void 0:o.id)??""),icon:n(D.Download,{size:14}),children:"Download Data"}),w&&n(a.Menu.Item,{onClick:b,icon:n(D.ArrowsMaximize,{size:14}),disabled:u,children:"Full Screen"}),u&&p(O,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:g,icon:n(D.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:f,icon:n(D.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:h,icon:n(D.Trash,{size:14}),children:"Delete"})]})]})]})})})}),uw="",ko=T.observer(function(){const{panel:t}=xe(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Oe=(e,t)=>{const[r,i]=m.useState([]);return m.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class st{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=y.get(s,t),l=y.get(o,t);u!==l&&r(u,l)},i)}}class xn{constructor(t,r,i){P(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new st(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new st(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new st(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(y.values(t).map(r=>this.constructInstance(new st(this.attachmentStorage,r.id))))}}class Li{constructor(t){P(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))ae.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ae.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:y.get(i,"fireImmediately",!1)})}}class Io{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new xi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new xi;return this.channels.set(t,i),i}}class Mo{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 r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Io,instanceData:new Li(t.viz.conf)};return this.instances.set(t.id,i),i}}function Pi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Li({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const Ao=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Pi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...y.omit(e,["panel","vizManager","data"])})},zo=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Pi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...y.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Oi=(e,t)=>{const r=Fe.bezier(e),i=Fe.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Gt=e=>{const t=Fe.bezier(e);return function(r){return t(r/100).hex()}},$o={type:"interpolation",displayName:"Red / Green",getColor:Oi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Eo={type:"interpolation",displayName:"Yellow / Blue",getColor:Oi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Lo={type:"interpolation",displayName:"Red",getColor:Gt(["#fff7f1","darkred"]),name:"red",category:"sequential"},Po={type:"interpolation",displayName:"Green",getColor:Gt(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Oo={type:"interpolation",displayName:"Blue",getColor:Gt(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Vo={type:"interpolation",displayName:"Orange",getColor:Gt(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Vi="@devtable/dashboard",Cn="8.59.1",Bi="Apache-2.0",Ni={access:"public",registry:"https://registry.npmjs.org/"},Gi=["dist"],qi="./dist/dashboard.umd.js",Fi="./dist/dashboard.es.js",Wi="./dist/index.d.ts",Ri={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Yi={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},ji={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.7.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Qi={"@emotion/babel-plugin":"11.7.2","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.4","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Ui={"@emotion/react":"11.10.6","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.3","d3-regression":"1.2.8",dayjs:"1.11.7",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},Bo=Object.freeze(Object.defineProperty({__proto__:null,default:{name:Vi,version:Cn,license:Bi,publishConfig:Ni,files:Gi,main:qi,module:Fi,types:Wi,exports:Ri,scripts:Yi,dependencies:ji,devDependencies:Qi,peerDependencies:Ui},dependencies:ji,devDependencies:Qi,exports:Ri,files:Gi,license:Bi,main:qi,module:Fi,name:Vi,peerDependencies:Ui,publishConfig:Ni,scripts:Yi,types:Wi,version:Cn},Symbol.toStringTag,{value:"Module"}));class No{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&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(r,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 Go{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;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 r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class qo{constructor(){P(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,i){var u;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const s=this.migrations.filter(l=>l.version>t.from&&l.version<=t.to),o=y.orderBy(s,"version","asc");if(((u=y.last(o))==null?void 0:u.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((l,d)=>d.handler(l,i),r)}}class ge extends qo{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(i,s)=>({version:t,...r(i,s)}))}async migrate({configData:t,panelModel:r}){const i=await t.getItem(null),s=y.get(i,"version",0),o=this.run({from:s,to:this.VERSION},i,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return y.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:i}]=Z.useBoolean(!0),[s,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=m.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},wn={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"}};oe.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Ie.CanvasRenderer]);function Fo({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:c,zAxis3D:f}=y.defaults({},t,wn),g=m.useMemo(()=>{const w=y.minBy(r,C=>C[l]);return y.get(w,l)},[r,l]),h=m.useMemo(()=>{const w=y.maxBy(r,C=>C[l]);return y.get(w,l)},[r,l]),b={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Me,{echarts:oe,option:b,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function Wo({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=m.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:c,value:r,onChange:i,required:t,sx:u,...l})}const U=m.forwardRef(Wo);function Ro({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),i=e.data,s=y.defaults({},t,wn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(a.Button,{color:"blue",type:"submit",children:[n(D.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class Yo extends ge{constructor(){super(...arguments);P(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const jo={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new Yo,name:"bar-3d",viewRender:Fo,configRender:Ro,createConfig(){return{version:1,config:y.cloneDeep(wn)}}},De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Qo({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return p(a.Stack,{ref:r,children:[p(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:p(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(Ae,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(D.ArrowRight,{size:9})," ",ue(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(D.ArrowRight,{size:9})," ",ue(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(D.ArrowRight,{size:9})," ",ue(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(Qo),Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
28
28
|
`)},Xi={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:Xo,configRender:Uo,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 Uo(e){return n(O,{})}function Xo(e){return n(a.Text,{children:"Click chart's series"})}const Zo=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],qt=m.forwardRef(({sectionTitle:e,value:t,onChange:r},i)=>{const s=o=>u=>{const l=y.cloneDeep(t);y.set(l,o,u),r(l)};return p(a.Stack,{spacing:0,children:[e&&n(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),p(a.Group,{grow:!0,noWrap:!0,children:[n(a.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:s("width")}),n(a.Select,{label:"Overflow",data:Zo,value:t.overflow,onChange:s("overflow")}),n(a.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),nt=m.forwardRef(({value:e,onChange:t},r)=>{const i=o=>{t({...e,on_axis:o})},s=o=>{t({...e,in_tooltip:o})};return p(a.Stack,{ref:r,spacing:0,children:[n(qt,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:i}),n(qt,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:s})]})}),Re={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function Ze({overflow:e,width:t}){const r={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],i=e==="truncate"?"nowrap":"initial",s={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
29
29
|
max-width: ${t}px;
|
|
30
30
|
word-break: ${r};
|
|
@@ -131,8 +131,8 @@ Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(
|
|
|
131
131
|
{
|
|
132
132
|
// 80-20 line stuff
|
|
133
133
|
percentage: {
|
|
134
|
-
x: string; //
|
|
135
|
-
y: string; //
|
|
134
|
+
x: string; // 20%
|
|
135
|
+
y: string; // 80%
|
|
136
136
|
};
|
|
137
137
|
count: {
|
|
138
138
|
left: number; // 2
|
|
@@ -356,7 +356,7 @@ Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(
|
|
|
356
356
|
SELECT count(*) AS total
|
|
357
357
|
FROM ${r}.${t}
|
|
358
358
|
`}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){v.addDisposer(e,ae.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),v.addDisposer(e,ae.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),_v=v.types.model("DataSourceModel",{id:v.types.string,type:v.types.enumeration("DataSourceType",[ce.HTTP,ce.MySQL,ce.Postgresql]),key:v.types.string,config:v.types.frozen(),tables:v.types.optional(Cv,{}),columns:v.types.optional(yv,{}),tableData:v.types.optional(wv,{}),indexes:v.types.optional(xv,{}),table_schema:v.types.optional(v.types.string,""),table_name:v.types.optional(v.types.string,"")}).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,r){e.table_schema=t,e.table_name=r}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],r=e.tables.data[t][0].table_name;e.setKeywords(t,r)}})).actions(e=>{const t=v.flow(function*(){var r;(r=e.controllers.tables)==null||r.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const i=yield*v.toGenerator(ze.getRequest("POST",e.controllers.tables.signal)("/query",{type:e.type,key:e.key,query:e.tables.sql},{}));e.tables.data=y.groupBy(i,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(i){if(!Qe.isCancel(i)){e.tables.data={};const s=y.get(i,"message","unkown error");e.tables.error=y.get(i,"response.data.detail.message",s),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:v.flow(function*(){var r;(r=e.controllers.columns)==null||r.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*v.toGenerator(ze.getRequest("POST",e.controllers.columns.signal)("/query",{type:e.type,key:e.key,query:e.columns.sql},{})),e.columns.state="idle",e.columns.error=null}catch(i){if(Qe.isCancel(i))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const s=y.get(i,"message","unkown error");e.columns.error=y.get(i,"response.data.detail.message",s),e.columns.state="error"}}}),loadIndexes:v.flow(function*(){var r;(r=e.controllers.indexes)==null||r.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*v.toGenerator(ze.getRequest("POST",e.controllers.indexes.signal)("/query",{type:e.type,key:e.key,query:e.indexes.sql},{})),e.indexes.state="idle",e.indexes.error=null}catch(i){if(Qe.isCancel(i))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const s=y.get(i,"message","unkown error");e.indexes.error=y.get(i,"response.data.detail.message",s),e.indexes.state="error"}}}),loadTableData:v.flow(function*(){var i;(i=e.controllers.tableData)==null||i.abort(),e.controllers.tableData=new AbortController;const r=e.tableData;r.state="loading";try{r.data=yield*v.toGenerator(ze.getRequest("POST",e.controllers.tableData.signal)("/query",{type:e.type,key:e.key,query:r.sql},{}));const[{total:s}]=yield*v.toGenerator(ze.getRequest("POST",e.controllers.tableData.signal)("/query",{type:e.type,key:e.key,query:r.countSql},{}));r.total=Number(s),r.state="idle",r.error=null}catch(s){if(Qe.isCancel(s))r.state="idle",r.error=null;else{r.data=[];const o=y.get(s,"message","unkown error");r.error=y.get(s,"response.data.detail.message",o),r.state="error"}}})}}).actions(e=>({afterCreate(){v.addDisposer(e,ae.reaction(()=>e.columns.sql,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){v.addDisposer(e,ae.reaction(()=>e.indexes.sql,e.loadIndexes,{fireImmediately:!1,delay:500})),v.addDisposer(e,ae.reaction(()=>e.tableData.sql,e.loadTableData,{fireImmediately:!1,delay:0}))}})),Sv=v.types.model("DataSourcesModel",{list:v.types.optional(v.types.array(_v),[])}).views(e=>({find({type:t,key:r}){return e.list.find(i=>i.key===r&&i.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function nn(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function Tv(e){switch(e._type){case"GROUP":case"ACTION":return null;case"global_variables":return["_GLOBAL_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const Dv=v.types.model("EditorModel",{path:v.types.optional(v.types.frozen(),[]),settings_open:v.types.optional(v.types.boolean,!1)}).views(e=>({get navOptions(){const{filters:t,views:r,sqlSnippets:i,queries:s}=v.getRoot(e);return[{label:"Global Variables",value:"_GLOBAL_VARS_",_type:"global_variables",Icon:V.IconVariable},{label:"Mock Context",value:"_MOCK_CONTEXT_",Icon:V.IconCodeDots,_type:"mock_context"},{label:"Filters",value:"_FILTERS_",Icon:V.IconFilter,children:[...t.options,nn("_Add_A_Filter_")],_type:"GROUP"},{label:"SQL Snipepts",value:"_SQL_SNIPPETS_",Icon:V.IconCopy,children:[...i.options,nn("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"Queries",value:"_QUERIES_",Icon:V.IconDatabase,children:[...s.options,nn("_Add_A_QUERY_")],_type:"GROUP"},{label:"Views",value:"_VIEWS_",Icon:V.IconBoxMultiple,children:[...r.editorOptions,nn("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,r){return t.length===0?!1:t[t.length-1]===r.value},isOptionOpened(t){const{path:r}=e;return r.length===0||!t.children||t.children.length===0?!1:r.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t}})).actions(e=>({open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const r=Tv(t);r&&e.setPath(r)}})),kv=v.types.model("MockContextModel",{current:v.types.optional(v.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,r){e.current[t]=r}})),Iv=v.types.model("PanelLayoutModel",{x:v.types.number,y:v.types.maybeNull(v.types.number),w:v.types.number,h:v.types.number,moved:v.types.optional(v.types.boolean,!1),static:v.types.optional(v.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:r,w:i,h:s,moved:o}=e;return{h:s,w:i,x:t,y:r===null?0:r,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:r,y:i,w:s,h:o,moved:u}=t;e.x=r,e.y=i,e.w=s,e.h=o,e.moved=!!u,e.static=!!t.static}})),Mv=v.types.model("PanelStyleBorderModel",{enabled:v.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),Av=v.types.model("PanelStyleModel",{border:Mv}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),zv=v.types.model("PanelVizModel",{type:v.types.string,conf:v.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),$v=v.types.model("VariableModel",{name:v.types.string,size:v.types.string,weight:v.types.string,color:v.types.union(v.types.model({type:v.types.literal("static"),staticColor:v.types.string}),v.types.model({type:v.types.literal("continuous"),valueRange:v.types.array(v.types.number),colorRange:v.types.array(v.types.string)}),v.types.model({type:v.types.literal("piecewise")})),formatter:v.types.model({output:v.types.enumeration("Output",["number","percent"]),average:v.types.optional(v.types.boolean,!1),mantissa:v.types.number,trimMantissa:v.types.optional(v.types.boolean,!1)}),data_field:v.types.string,aggregation:v.types.union(v.types.model({type:v.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:v.types.frozen()}),v.types.model({type:v.types.literal("quantile"),config:v.types.model({p:v.types.number})}))}).views(e=>({get json(){const{name:t,size:r,weight:i,color:s,formatter:o,data_field:u,aggregation:l}=e;return y.cloneDeep({name:t,size:r,color:s,weight:i,formatter:o,data_field:u,aggregation:l})}}));class Ev{constructor(t){P(this,"origin");P(this,"copy");this.origin=t,this.copy=v.clone(t),ae.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!y.isEqual(v.getSnapshot(this.origin),v.getSnapshot(this.copy))}commit(){v.applySnapshot(this.origin,v.getSnapshot(this.copy))}update(t){v.applySnapshot(this.copy,t)}}const Lv=e=>new Ev(e),ss=v.types.model({id:v.types.string,title:v.types.string,description:v.types.string,layout:Iv,queryID:v.types.string,viz:zv,style:Av,variables:v.types.optional(v.types.array($v),[])}).views(e=>({get query(){return v.getParentOfType(e,rn).queries.findByID(e.queryID)},get json(){const{id:t,title:r,description:i,queryID:s}=e;return{id:t,viz:e.viz.json,style:e.style.json,title:r,layout:e.layout.json,queryID:s,variables:e.variables.map(o=>o.json),description:i}}})).actions(e=>({setID(t){e.id=t},setTitle(t){e.title=t},setDescription(t){e.description=t},setQueryID(t){if(v.getParentOfType(e,rn).queries.findByID(t))e.queryID=t;else throw new Error(`Query with id ${t} does not exist`)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)},removeSelf(){v.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,r){v.getRoot(e).views.findByID(t).removePanelID(e.id),v.getRoot(e).views.findByID(r).appendPanelID(e.id),v.getRoot(e).editor.setPath(["_VIEWS_",r,"_PANELS_",e.id])}}));function os(e){return{id:e,layout:{x:0,y:1/0,w:3,h:15},title:e,description:"<p></p>",queryID:"",viz:{type:jn.name,conf:jn.createConfig()},style:{border:{enabled:!0}}}}const ls=v.types.model("PanelsModel",{list:v.types.optional(v.types.array(ss),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(r=>r.id===t)},get idMap(){const t=new Map;return e.list.forEach(r=>{t.set(r.id,r)}),t}})).views(e=>({panelsByIDs(t){const r=[];t.forEach(s=>{const o=e.idMap.get(s);o?r.push(o):console.warn(`Panel is not found, id:${s}`)});const i=r.map(s=>({...s.layout.json,i:s.id}));return{panels:r,layouts:i}}})).views(e=>({editorOptions(t,r){const{panels:i}=e.panelsByIDs(r);i.length!==r.length&&console.warn(`Unfulfilled panels for View[${t}]`);const s=i.map(u=>({label:u.title?u.title:y.capitalize(u.viz.type),value:u.id,_type:"panel",parentID:t})),o="_Add_A_PANEL_";return s.push({label:o,value:o,_type:"ACTION",_action_type:o,parentID:t,Icon:null,children:null}),s}})).actions(e=>({replace(t){e.list=v.castToSnapshot(t)},append(t){e.list.push(t)},remove(t){e.list.splice(t,1)},removeByID(t){const r=e.list.findIndex(i=>i.id===t);r!==-1&&e.list.splice(r,1)},duplicateByID(t){const r=e.list.find(s=>s.id===t);if(!r){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}const i=new Date().getTime().toString();return e.list.push({...r.json,id:i,layout:{...r.layout,y:1/0,moved:!1}}),i},replaceByIndex(t,r){e.list.splice(t,1,r)}})),us=v.types.model("ViewModel_Division",{_name:v.types.literal(K.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})).actions(e=>({})),Pv=()=>us.create({_name:K.Division}),or={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
359
|
-
`)},Ov=v.types.model("CustomModalTitleModel",{enabled:v.types.optional(v.types.boolean,!1),func_content:v.types.optional(v.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:r}=e;return{enabled:t,func_content:r}},get value(){const{enabled:t,func_content:r}=e,i=v.getParent(e,2),s=v.getRoot(e);if(!t)return i.name;try{const o={filters:s.filters.values,context:s.context.current};return new Function(`return ${r}`)()(o)}catch(o){return console.error(o),i.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:r}){e.enabled=t,e.func_content=r}})),ds=v.types.model("ViewModel_Modal",{_name:v.types.literal(K.Modal),width:v.types.string,height:v.types.string,custom_modal_title:v.types.optional(Ov,or)}).views(e=>({get json(){const{_name:t,width:r,height:i,custom_modal_title:s}=e;return{_name:t,width:r,height:i,custom_modal_title:s.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Vv=()=>ds.create({_name:K.Modal,width:"90vw",height:"90vh"}),Bv=v.types.model("ViewModel_Tabs_Tab",{id:v.types.identifier,name:v.types.string,view_id:v.types.string,color:v.types.optional(v.types.string,"")}).views(e=>({get json(){const{id:t,name:r,view_id:i,color:s}=e;return{id:t,name:r,color:s,view_id:i}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t}})),cs=v.types.model("ViewModel_Tabs",{_name:v.types.literal(K.Modal),tabs:v.types.optional(v.types.array(Bv),[]),variant:v.types.optional(v.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:v.types.optional(v.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:v.types.optional(v.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:r,orientation:i,tabs:s,grow:o}=e;return{grow:o,tabs:s.map(u=>u.json),_name:t,variant:r,orientation:i}}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=v.cast(t)},addTab(){const t=ve.randomId(),r={id:t,name:t,view_id:""};e.tabs.push(r)},removeTab(t){e.tabs.splice(t,1)}})),Nv=()=>cs.create({_name:K.Modal,tabs:[]}),ps=v.types.model({id:v.types.identifier,name:v.types.string,type:v.types.enumeration("EViewComponentType",[K.Division,K.Modal,K.Tabs]),config:v.types.union(us,ds,cs),panelIDs:v.types.optional(v.types.array(v.types.string),[])}).views(e=>({get json(){const{id:t,name:r,type:i,config:s}=e;return{id:t,name:r,type:i,config:s.json,panelIDs:e.panelIDs}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case K.Division:e.config=Pv();break;case K.Modal:e.config=Vv();break;case K.Tabs:e.config=Nv();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},removePanelID(t){const r=e.panelIDs.filter(i=>i!==t);e.panelIDs.length=0,e.panelIDs.push(...r)}})).actions(e=>({})),hs=v.types.model("ViewsModel",{current:v.types.optional(v.types.array(ps),[]),visibleViewIDs:v.types.array(v.types.string),idOfVIE:v.types.string}).views(e=>({get json(){return e.current.map(t=>tn(t.json))},get idMap(){const t=new Map;return e.current.forEach(r=>{t.set(r.id,r)}),t},findByID(t){return e.current.find(r=>r.id===t)},get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:r})=>r===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:r})=>t.has(r))},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get editorOptions(){const t=v.getRoot(e).panels;return e.current.map(r=>({label:r.name,value:r.id,_type:"view",children:t.editorOptions(r.id,r.panelIDs)}))}})).actions(e=>({replace(t){e.current.replace(t)},addANewView(t,r,i,s){e.current.push({id:t,name:r,type:i,config:s,panelIDs:[]})},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(i=>i.id===t);r!==-1&&e.current.splice(r,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},appendToVisibles(t){new Set(e.visibleViewIDs.map(i=>i)).has(t)||e.visibleViewIDs.push(t)}})).actions(e=>({addARandomNewView(){const t=new Date().getTime().toString();e.addANewView(t,K.Division,K.Division,{_name:K.Division}),e.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(e.removeByID(e.idOfVIE),e.setIDOfVIE(e.current[0].id))},rmVisibleViewID(t){const r=e.visibleViewIDs.findIndex(i=>i===t);r!==-1&&e.visibleViewIDs.splice(r,1)}}));function lr(e){const t=e.length>0?[e[0].id]:[],r=e.length>0?e[0].id:"";return{current:e.map(s=>{const{_name:o=s.type}=s.config;return{...s,config:{...s.config,_name:o},panelIDs:s.panelIDs}}),visibleViewIDs:t,idOfVIE:r}}const Gv=v.types.model({id:v.types.identifier,name:v.types.string,group:v.types.string,version:v.types.string,datasources:Sv,filters:Za,queries:ns,sqlSnippets:is,views:hs,panels:ls,context:as,mock_context:kv,editor:Dv,origin:v.types.maybe(v.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}},get filtersChanged(){const t="filters.current";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get queriesChanged(){const t="queries.current",r=v.getSnapshot(y.get(e,t)).map(i=>y.pick(i,["id","name","key","type","sql","run_by","pre_process","post_process"]));return!y.isEqual(r,y.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get viewsChanged(){const t="views.current";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!y.isEqual(y.get(e,t),y.get(e.origin,t))},get payloadForSQL(){return{context:e.context.current,mock_context:e.mock_context.current,sqlSnippets:e.sqlSnippets.current,filterValues:e.filters.values}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:r,data:i})=>({id:r,data:i})).reduce((r,i)=>(r[i.id]=i.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data.toJSON(),dataProxy:r.data,len:r.data.length,state:r.state,error:r.error}:{data:[],dataProxy:null,len:0,state:"idle",error:void 0}},getDataStateByID(t){var r;return((r=e.queries.findByID(t))==null?void 0:r.state)??[]},getDataErrorByID(t){var r;return((r=e.queries.findByID(t))==null?void 0:r.error)??[]}})).views(e=>({findQueryUsage(t){const r=e.panels.idMap,i=e.views.current.flatMap(u=>u.panelIDs.map(l=>r.get(l)).filter(l=>(l==null?void 0:l.queryID)===t).map(l=>({type:"panel",id:l.id,label:l.title?l.title:l.viz.type,views:[{id:u.id,label:u.name}]}))),s=e.views.idMap,o=e.filters.current.filter(u=>y.get(u,"config.options_query_id")===t).map(u=>({type:"filter",id:u.id,label:u.label,views:u.visibleInViewsIDs.map(l=>{var d;return{id:l,label:((d=s.get(l))==null?void 0:d.name)??l}})}));return i.concat(o)}})).actions(e=>({duplicatePanelByID(t,r){var s;const i=e.panels.duplicateByID(t);i&&((s=e.views.findByID(r))==null||s.appendPanelID(i))},removePanelByID(t,r){var i;e.panels.removeByID(t),(i=e.views.findByID(r))==null||i.removePanelID(t)},addANewPanel(t){var i;const r=new Date().getTime().toString();e.panels.append(os(r)),(i=e.views.findByID(t))==null||i.appendPanelID(r)}})).actions(e=>({reset(){v.applySnapshot(e.filters.current,e.origin.filters.current),v.applySnapshot(e.queries.current,e.origin.queries.current),v.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),v.applySnapshot(e.views.current,e.origin.views.current),v.applySnapshot(e.panels.list,e.origin.panels.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){v.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{name:r,group:i,version:s,filters:o,views:u,panels:l,definition:{queries:d,sqlSnippets:c,mock_context:f={}}}=t;e.name=r,e.group=i,e.version=s,v.applySnapshot(e.filters.current,o),v.applySnapshot(e.views.current,lr(u).current),v.applySnapshot(e.panels.list,l),v.applySnapshot(e.queries.current,d),v.applySnapshot(e.sqlSnippets.current,c),e.mock_context.current=f}})),rn=v.types.snapshotProcessor(Gv,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=v.castToSnapshot(e.queries.current.map(r=>y.pick(r,["id","key","type","sql"])));return y.defaults({},{queries:{current:t}},e)}});function qv(e,t){t.filters&&v.applySnapshot(e.filters.current,t.filters)}function ur({id:e,name:t,group:r,version:i,filters:s,views:o,panels:u,definition:{queries:l,sqlSnippets:d,mock_context:c={}}},f,g){return rn.create({id:e,name:t,group:r,version:i,datasources:{list:f},filters:Ka(s),queries:{current:l},sqlSnippets:{current:d},context:{current:g},mock_context:{current:c},views:lr(o),panels:{list:u},editor:{}})}function dr(e){return m.useCallback(t=>t.provideValue(me.pluginManager,e.pluginManager).provideValue(me.vizManager,e.vizManager).provideValue(me.colorManager,e.colorManager),[])}const fw="",fs={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}},Fv=T.observer(({saveDashboardChanges:e,headerSlot:t=null})=>{const r=eo.useNavigate(),i=B(),s=()=>{const f=JSON.stringify(i.json,null,2);nv(i.name,f)},o=()=>{r(`/dashboard/${i.id}`)},u=Pe.useModals(),l=()=>{u.openConfirmModal({title:p(a.Group,{position:"left",children:[n(V.IconAlertTriangle,{size:18,color:"red"}),n(a.Text,{children:"There are unsaved changes"})]}),labels:{confirm:"Discard",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:o,zIndex:320,withCloseButton:!1})},d=()=>{u.openConfirmModal({title:p(a.Group,{position:"left",children:[n(V.IconAlertTriangle,{size:18,color:"red"}),n(a.Text,{children:"You are reverting changes"})]}),labels:{confirm:"Confirm",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.reset(),zIndex:320,withCloseButton:!1})},c=i.changed;return n(a.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:p(a.Group,{position:"apart",sx:{height:60,position:"relative"},children:[n(a.Group,{children:n(a.Button,{size:"xs",color:c?"red":"green",leftIcon:n(V.IconArrowLeft,{size:20}),onClick:c?l:o,children:p(a.Group,{spacing:4,children:["End Editing",n(a.Text,{td:"underline",children:i.name})]})})}),t,p(a.Group,{position:"right",children:[n(a.Button,{variant:"filled",size:"xs",disabled:!i.views.VIE,onClick:()=>i.addANewPanel(i.views.idOfVIE),leftIcon:n(V.IconPlaylistAdd,{size:20}),children:"Add a Panel"}),p(a.Group,{spacing:0,sx:fs,children:[n(a.Tooltip,{label:"Download Schema",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",size:"md",onClick:s,children:n(V.IconCode,{size:18})})}),n(a.Tooltip,{label:"Download Data",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",size:"md",onClick:i.queries.downloadAllData,children:n(V.IconDownload,{size:18})})})]}),p(a.Group,{spacing:16,children:[n(a.Tooltip,{label:"Revert Changes",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",size:"md",disabled:!c,onClick:d,children:n(V.IconRecycle,{size:20,color:"red"})})}),n(a.Button,{color:"green",variant:"filled",size:"xs",leftIcon:n(V.IconDeviceFloppy,{size:18}),onClick:e,disabled:!c,children:"Save Changes"})]})]})]})})}),gw="";function Wv(e,t,r){const i=[];return e.filter(s=>"__INTERACTIONS"in s.viz.conf).forEach((s,o)=>{const u=t[s.id];u.data.interactions=y.get(u,"data.interactions",[]);const{__INTERACTIONS:l,__OPERATIONS:d,__TRIGGERS:c}=s.viz.conf;Object.entries(d).forEach(([f,g])=>{const{schemaRef:h,data:b}=g,{config:w}=b;switch(h){case"builtin:op:open-link":let C=w.urlTemplate.substring(0,100);w.urlTemplate.length>=20&&(C+="..."),u.type="interaction",u.data.interactions.push({schemaRef:h,urlTemplate:w.urlTemplate,shortURLTemplate:C});return;case"builtin:op:open_view":i.push({id:`OPERATION--${f}`,source:s.id,target:w.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":u.type="interaction",u.data.interactions.push({schemaRef:h,filters:Object.keys(w.dictionary).map(S=>({key:S,label:r[S]}))});return;case"builtin:op:clear_filter_values":u.type="interaction",u.data.interactions.push({schemaRef:h,filters:w.filter_keys.map(S=>({key:S,label:r[S]}))});return;default:return}})}),i}function Rv(e,t){const r=e.filters.keyLabelMap;return{edges:Wv(e.panels.list,t,r),edgeNodes:[]}}function gs(e,t,r){return e*t+e*r}function Yv(e,t,r){return e*t+(e-1)*r}const an=25,cr=40,ms=25,pr=350,jv=150,Qv=150,bs=150,vs=300,sn=40,ys=25,Uv=300;function Xv(e,t){const r=y.keyBy(t,s=>s.id),i=[];return e.current.forEach((s,o)=>{s.panelIDs.forEach((u,l)=>{const d=gs(l,sn,ys)+cr,c=r[u];if(!c){i.push({id:u,_node_type:"panel",parentNode:s.id,data:{label:`!: ${u}`},position:{x:an,y:d},sourcePosition:ye.Position.Right,targetPosition:ye.Position.Left,style:{width:vs,height:sn}});return}const f=c.title.trim()?`${c.title}`:c.viz.type;i.push({id:c.id,_node_type:"panel",parentNode:s.id,data:{label:f},position:{x:an,y:d},sourcePosition:ye.Position.Right,targetPosition:ye.Position.Left,style:{width:vs,height:sn}})})}),i}const Zv={[K.Division]:"Div",[K.Modal]:"Modal",[K.Tabs]:"Tabs"},Kv=Va;function Jv(e){return e.current.map((r,i)=>{const s=Yv(r.panelIDs.length,sn,ys)+cr+ms;let o=[];return r.type===K.Tabs&&(o=r.config.tabs.map(l=>l.view_id)),{id:r.id,_node_type:"view-root",_view_type:r.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${Zv[r.type]}:${r.name}`},position:{x:0,y:0},sourcePosition:ye.Position.Right,targetPosition:ye.Position.Left,className:"light",style:{backgroundColor:Kv[r.type],width:pr,height:s}}})}function Hv(e){const t=y.keyBy(e,r=>r.id);e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==K.Tabs||r._tab_view_ids.forEach(i=>{t[i].parentNode=r.id})})}function ey(e){const t=Jv(e.views);Hv(t);const r=Xv(e.views,e.panels.list);return[...t,...r]}function ty({nodeMap:e,nodes:t,edges:r}){t.forEach(i=>{i._node_type!=="view-root"||i._view_type!==K.Tabs||(i.sourcePosition=ye.Position.Bottom,i.style.width=pr+an*2,i.style.height=ms+i._tab_view_ids.reduce((s,o)=>{const u=e[o];u.position.y=s,u.position.x=an;const l=u.style.height;return s+l+20},cr))})}function ny({nodeMap:e,nodes:t,edges:r}){r.filter(i=>i.label==="Open View").forEach(i=>{const s=e[i.source],o=e[i.target];if(!s||!o||!s.parentNode)return;const u=e[s.parentNode];u._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+u._view_level,u._sub_view_ids.push(o.id))}),t.sort((i,s)=>i._node_type==="view-root"&&s._node_type==="view-root"?i._view_level-s._view_level:i._node_type!=="view-root"&&s._node_type!=="view-root"?0:i._node_type==="view-root"?-1:1)}function ry({nodeMap:e,nodes:t,edges:r}){const i={};r.forEach(s=>{if(s.label!=="Open View")return;const o=e[s.source],u=e[s.target];if(o&&u&&o.parentNode){const l=e[o.parentNode],d=l.position.x,c=y.get(u,"style.height",0),f=Number(l.style.width);u.position.x=d+f+Uv,l._view_level===0&&u._sub_view_ids.length===0&&(o.sourcePosition=ye.Position.Left,u.targetPosition=ye.Position.Right,u.position.x*=-1);const h=u.position.x,b=y.get(i,h,0);u.position.y=b,i[h]=b+c+bs}})}function iy({nodeMap:e,nodes:t,edges:r}){const i=new Set,s=new Set;r.forEach(u=>{i.add(u.source),s.add(u.target)}),t.filter(u=>u._node_type!=="view-root"||u.id==="Main"||u.parentNode?!1:!i.has(u.id)&&!s.has(u.id)).forEach((u,l)=>{u.position.x=gs(l,pr,Qv),u.position.y=0-jv-bs})}function ay({nodeMap:e,nodes:t,edges:r}){const i={nodeMap:e,nodes:t,edges:r};return iy(i),ny(i),ty(i),ry(i),{nodes:t,edges:r}}function sy(e){const t=ey(e),r=y.keyBy(t,d=>d.id),{edges:i,edgeNodes:s}=Rv(e,r),o=[...t,...s],u=y.keyBy(o,d=>d.id),l={edges:y.uniqBy(i,d=>d.id),nodes:o,nodeMap:u};return ay(l)}const mw="",hr={"builtin:op:open-link":n(a.ThemeIcon,{color:"blue",size:20,radius:"xl",children:n(V.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":n(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n(V.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":n(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n(V.IconCircleOff,{size:14})})};function oy(e){const t=[];return e.forEach(r=>{switch(r.schemaRef){case"builtin:op:open-link":t.push({key:r.urlTemplate,icon:hr[r.schemaRef],text:p(a.Group,{spacing:4,children:[n(a.Text,{children:"Open: "}),n(a.Text,{color:"dimmed",children:r.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":r.filters.forEach(({key:i,label:s})=>{t.push({key:r.schemaRef+i,icon:hr[r.schemaRef],text:n(a.Group,{spacing:4,children:p(a.Text,{children:["Set Filter: ",s]})})})});return;case"builtin:op:clear_filter_values":r.filters.forEach(({key:i,label:s})=>{t.push({key:r.schemaRef+i,icon:hr[r.schemaRef],text:n(a.Group,{spacing:4,children:p(a.Text,{children:["Clear Filter: ",s]})})})});return}}),t}const ly=m.memo(({data:e,isConnectable:t,sourcePosition:r=ye.Position.Right,targetPosition:i=ye.Position.Left,...s})=>{const o=m.useMemo(()=>oy(e.interactions),[e.interactions]);return p(O,{children:[n(ye.Handle,{type:"target",position:i,isConnectable:t}),n(a.Box,{sx:{position:"absolute",top:0,right:0},children:n(D.ChevronsUpRight,{size:12})}),p(a.HoverCard,{shadow:"xl",withinPortal:!0,children:[n(a.HoverCard.Target,{children:n(a.Text,{children:e.label})}),n(a.HoverCard.Dropdown,{children:n(a.List,{spacing:"xs",size:"sm",center:!0,children:o.map(u=>n(a.List.Item,{icon:u.icon,children:u.text},u.key))})})]}),n(ye.Handle,{type:"source",position:r,isConnectable:t})]})}),bw="",uy={interaction:ly},dy=T.observer(()=>{const e=B(),{edges:t,nodes:r}=sy(e);return p(ye,{nodes:r,edges:t,onNodesChange:y.noop,onEdgesChange:y.noop,onConnect:y.noop,className:"interactions-viewer",fitView:!0,nodeTypes:uy,children:[n(ye.MiniMap,{}),n(ye.Controls,{}),n(ye.Background,{})]})}),cy=T.observer(({opened:e,close:t})=>{const{freezeLayout:r}=m.useContext(Xe);return m.useEffect(()=>{r(e)},[e]),n(a.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:t,title:"Interactions",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},styles:{body:{height:"90vh"},modal:{transform:"none !important"}},zIndex:300,children:n(dy,{})})});function py({onClick:e,name:t,active:r,openSettings:i}){return p(a.Box,{sx:{position:"relative"},children:[n(a.UnstyledButton,{sx:s=>({display:"block",width:"100%",padding:s.spacing.xs,borderRadius:0,position:"relative",color:s.black,"&:hover":{backgroundColor:s.colors.gray[0]},backgroundColor:r?s.colors.gray[2]:"transparent"}),children:n(a.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:n(a.Text,{size:"sm",children:t})})}),r&&n(a.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:n(a.ActionIcon,{onClick:i,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:n(V.IconAdjustments,{size:16})})})]})}const hy=T.observer(()=>{const e=B(),t=m.useCallback(i=>()=>e.views.setIDOfVIE(i),[e]),r=i=>{e.editor.open(["_VIEWS_",i])};return p(a.Box,{sx:{position:"relative"},children:[e.views.options.map(i=>n(py,{active:e.views.idOfVIE===i.value,name:i.label,onClick:t(i.value),openSettings:()=>r(i.value)},i.value)),n(a.Divider,{variant:"dashed"}),n(a.Button,{variant:"subtle",rightIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:"Add a View"})]})}),fy=T.observer(()=>{const e=B(),t=()=>{if(!e.queries.firstID){e.editor.open(["_QUERIES_",""]);return}e.editor.open(["_QUERIES_",e.queries.firstID])},r=()=>{if(!e.filters.firstID){e.editor.open(["_FILTERS_",""]);return}e.editor.open(["_FILTERS_",e.filters.firstID])},[i,s]=m.useState(!1),o=()=>s(!0),u=()=>s(!1);return p(a.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:[p(a.Navbar.Section,{children:[p(a.Group,{grow:!0,spacing:0,sx:{...fs,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[n(a.Tooltip,{label:"Filters",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",radius:0,size:"md",onClick:r,children:n(V.IconFilter,{size:20})})}),n(a.Tooltip,{label:"Queries",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",radius:0,size:"md",onClick:t,children:n(V.IconDatabase,{size:20})})}),n(a.Tooltip,{label:"Interactions Viewer",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",radius:0,size:"md",onClick:o,children:n(V.IconLink,{size:20})})})]}),n(cy,{opened:i,close:u})]}),n(a.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:n(a.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Views"})}),n(a.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:n(hy,{})}),n(a.Navbar.Section,{children:n(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n(a.Button,{size:"xs",leftIcon:n(V.IconSettings,{size:20}),onClick:()=>e.editor.open([]),children:"Settings"})})})]})}),gy=T.observer(function({config:t}){return p(O,{children:[n(a.Checkbox,{checked:t.default_value,onChange:r=>t.setDefaultValue(r.currentTarget.checked),label:"Default Checked"}),n(Nn,{label:"Description",value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),my=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],by=T.observer(function({config:t}){return p(O,{children:[p(a.Group,{children:[n(a.Checkbox,{checked:t.required,onChange:r=>t.setRequired(r.currentTarget.checked),label:"Required"}),n(a.Checkbox,{checked:t.clearable,onChange:r=>t.setClearable(r.currentTarget.checked),disabled:t.max_days>0,label:"Clearable"}),n(a.Checkbox,{checked:t.allowSingleDateInRange,onChange:r=>t.setAllowSingleDateInRange(r.currentTarget.checked),label:"Allow choosing 1 day"})]}),n(a.Select,{data:my,label:"Display Format",value:t.inputFormat,onChange:t.setInputFormat}),n(ki,{label:"Default Value",config:t,value:t.default_value,onChange:t.setDefaultValue}),n(a.NumberInput,{label:"Max Days",description:p(a.Group,{position:"apart",children:[n(a.Text,{children:"Set 0 to disable."}),p(a.Group,{spacing:4,children:[n(a.Text,{children:"This feature requires"}),n(a.Text,{color:"blue",children:"Clearable"}),n(a.Text,{children:"to be checked"})]})]}),min:0,value:t.max_days,onChange:t.setMaxDays,hideControls:!0})]})}),fr=T.observer(({value:e,onChange:t})=>{const r=B(),i=m.useMemo(()=>r.queries.options,[r.queries.current]),s=i.length===0;return n(a.Select,{label:"Pick a query",data:i,value:e,onChange:t,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:s,error:s?"You need to add a query in Data Settings":void 0})}),vy=`
|
|
359
|
+
`)},Ov=v.types.model("CustomModalTitleModel",{enabled:v.types.optional(v.types.boolean,!1),func_content:v.types.optional(v.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:r}=e;return{enabled:t,func_content:r}},get value(){const{enabled:t,func_content:r}=e,i=v.getParent(e,2),s=v.getRoot(e);if(!t)return i.name;try{const o={filters:s.filters.values,context:s.context.current};return new Function(`return ${r}`)()(o)}catch(o){return console.error(o),i.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:r}){e.enabled=t,e.func_content=r}})),ds=v.types.model("ViewModel_Modal",{_name:v.types.literal(K.Modal),width:v.types.string,height:v.types.string,custom_modal_title:v.types.optional(Ov,or)}).views(e=>({get json(){const{_name:t,width:r,height:i,custom_modal_title:s}=e;return{_name:t,width:r,height:i,custom_modal_title:s.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Vv=()=>ds.create({_name:K.Modal,width:"90vw",height:"90vh"}),Bv=v.types.model("ViewModel_Tabs_Tab",{id:v.types.identifier,name:v.types.string,view_id:v.types.string,color:v.types.optional(v.types.string,"")}).views(e=>({get json(){const{id:t,name:r,view_id:i,color:s}=e;return{id:t,name:r,color:s,view_id:i}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t}})),cs=v.types.model("ViewModel_Tabs",{_name:v.types.literal(K.Modal),tabs:v.types.optional(v.types.array(Bv),[]),variant:v.types.optional(v.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:v.types.optional(v.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:v.types.optional(v.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:r,orientation:i,tabs:s,grow:o}=e;return{grow:o,tabs:s.map(u=>u.json),_name:t,variant:r,orientation:i}}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=v.cast(t)},addTab(){const t=ve.randomId(),r={id:t,name:t,view_id:""};e.tabs.push(r)},removeTab(t){e.tabs.splice(t,1)}})),Nv=()=>cs.create({_name:K.Modal,tabs:[]}),ps=v.types.model({id:v.types.identifier,name:v.types.string,type:v.types.enumeration("EViewComponentType",[K.Division,K.Modal,K.Tabs]),config:v.types.union(us,ds,cs),panelIDs:v.types.optional(v.types.array(v.types.string),[])}).views(e=>({get json(){const{id:t,name:r,type:i,config:s}=e;return{id:t,name:r,type:i,config:s.json,panelIDs:e.panelIDs}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case K.Division:e.config=Pv();break;case K.Modal:e.config=Vv();break;case K.Tabs:e.config=Nv();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},removePanelID(t){const r=e.panelIDs.filter(i=>i!==t);e.panelIDs.length=0,e.panelIDs.push(...r)}})).actions(e=>({})),hs=v.types.model("ViewsModel",{current:v.types.optional(v.types.array(ps),[]),visibleViewIDs:v.types.array(v.types.string),idOfVIE:v.types.string}).views(e=>({get json(){return e.current.map(t=>tn(t.json))},get idMap(){const t=new Map;return e.current.forEach(r=>{t.set(r.id,r)}),t},findByID(t){return e.current.find(r=>r.id===t)},get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:r})=>r===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:r})=>t.has(r))},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get editorOptions(){const t=v.getRoot(e).panels;return e.current.map(r=>({label:r.name,value:r.id,_type:"view",children:t.editorOptions(r.id,r.panelIDs)}))}})).actions(e=>({replace(t){e.current.replace(t)},addANewView(t,r,i,s){e.current.push({id:t,name:r,type:i,config:s,panelIDs:[]})},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(i=>i.id===t);r!==-1&&e.current.splice(r,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},appendToVisibles(t){new Set(e.visibleViewIDs.map(i=>i)).has(t)||e.visibleViewIDs.push(t)}})).actions(e=>({addARandomNewView(){const t=new Date().getTime().toString();e.addANewView(t,K.Division,K.Division,{_name:K.Division}),e.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(e.removeByID(e.idOfVIE),e.setIDOfVIE(e.current[0].id))},rmVisibleViewID(t){const r=e.visibleViewIDs.findIndex(i=>i===t);r!==-1&&e.visibleViewIDs.splice(r,1)}}));function lr(e){const t=e.length>0?[e[0].id]:[],r=e.length>0?e[0].id:"";return{current:e.map(s=>{const{_name:o=s.type}=s.config;return{...s,config:{...s.config,_name:o},panelIDs:s.panelIDs}}),visibleViewIDs:t,idOfVIE:r}}const Gv=v.types.model({id:v.types.identifier,name:v.types.string,group:v.types.string,version:v.types.string,datasources:Sv,filters:Za,queries:ns,sqlSnippets:is,views:hs,panels:ls,context:as,mock_context:kv,editor:Dv,origin:v.types.maybe(v.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}},get filtersChanged(){const t="filters.current";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get queriesChanged(){const t="queries.current",r=v.getSnapshot(y.get(e,t)).map(i=>y.pick(i,["id","name","key","type","sql","run_by","pre_process","post_process"]));return!y.isEqual(r,y.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get viewsChanged(){const t="views.current";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!y.isEqual(v.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!y.isEqual(y.get(e,t),y.get(e.origin,t))},get payloadForSQL(){return{context:e.context.current,mock_context:e.mock_context.current,sqlSnippets:e.sqlSnippets.current,filterValues:e.filters.values}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:r,data:i})=>({id:r,data:i})).reduce((r,i)=>(r[i.id]=i.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data.toJSON(),dataProxy:r.data,len:r.data.length,state:r.state,error:r.error}:{data:[],dataProxy:null,len:0,state:"idle",error:void 0}},getDataStateByID(t){var r;return((r=e.queries.findByID(t))==null?void 0:r.state)??[]},getDataErrorByID(t){var r;return((r=e.queries.findByID(t))==null?void 0:r.error)??[]}})).views(e=>({findQueryUsage(t){const r=e.panels.idMap,i=e.views.current.flatMap(u=>u.panelIDs.map(l=>r.get(l)).filter(l=>(l==null?void 0:l.queryID)===t).map(l=>({type:"panel",id:l.id,label:l.title?l.title:l.viz.type,views:[{id:u.id,label:u.name}]}))),s=e.views.idMap,o=e.filters.current.filter(u=>y.get(u,"config.options_query_id")===t).map(u=>({type:"filter",id:u.id,label:u.label,views:u.visibleInViewsIDs.map(l=>{var d;return{id:l,label:((d=s.get(l))==null?void 0:d.name)??l}})}));return i.concat(o)}})).actions(e=>({duplicatePanelByID(t,r){var s;const i=e.panels.duplicateByID(t);i&&((s=e.views.findByID(r))==null||s.appendPanelID(i))},removePanelByID(t,r){var i;e.panels.removeByID(t),(i=e.views.findByID(r))==null||i.removePanelID(t)},addANewPanel(t){var i;const r=new Date().getTime().toString();e.panels.append(os(r)),(i=e.views.findByID(t))==null||i.appendPanelID(r)}})).actions(e=>({reset(){v.applySnapshot(e.filters.current,e.origin.filters.current),v.applySnapshot(e.queries.current,e.origin.queries.current),v.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),v.applySnapshot(e.views.current,e.origin.views.current),v.applySnapshot(e.panels.list,e.origin.panels.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){v.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{name:r,group:i,version:s,filters:o,views:u,panels:l,definition:{queries:d,sqlSnippets:c,mock_context:f={}}}=t;e.name=r,e.group=i,e.version=s,v.applySnapshot(e.filters.current,o),v.applySnapshot(e.views.current,lr(u).current),v.applySnapshot(e.panels.list,l),v.applySnapshot(e.queries.current,d),v.applySnapshot(e.sqlSnippets.current,c),e.mock_context.current=f}})),rn=v.types.snapshotProcessor(Gv,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=v.castToSnapshot(e.queries.current.map(r=>y.pick(r,["id","key","type","sql"])));return y.defaults({},{queries:{current:t}},e)}});function qv(e,t){t.filters&&v.applySnapshot(e.filters.current,t.filters)}function ur({id:e,name:t,group:r,version:i,filters:s,views:o,panels:u,definition:{queries:l,sqlSnippets:d,mock_context:c={}}},f,g){return rn.create({id:e,name:t,group:r,version:i,datasources:{list:f},filters:Ka(s),queries:{current:l},sqlSnippets:{current:d},context:{current:g},mock_context:{current:c},views:lr(o),panels:{list:u},editor:{}})}function dr(e){return m.useCallback(t=>t.provideValue(me.pluginManager,e.pluginManager).provideValue(me.vizManager,e.vizManager).provideValue(me.colorManager,e.colorManager),[])}const fw="",fs={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}},Fv=T.observer(({saveDashboardChanges:e,headerSlot:t=null})=>{const r=eo.useNavigate(),i=B(),s=()=>{const f=JSON.stringify(i.json,null,2);nv(i.name,f)},o=()=>{r(`/dashboard/${i.id}`)},u=Pe.useModals(),l=()=>{u.openConfirmModal({title:p(a.Group,{position:"left",children:[n(V.IconAlertTriangle,{size:18,color:"red"}),n(a.Text,{children:"There are unsaved changes"})]}),labels:{confirm:"Discard",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:o,zIndex:320,withCloseButton:!1})},d=()=>{u.openConfirmModal({title:p(a.Group,{position:"left",children:[n(V.IconAlertTriangle,{size:18,color:"red"}),n(a.Text,{children:"You are reverting changes"})]}),labels:{confirm:"Confirm",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.reset(),zIndex:320,withCloseButton:!1})},c=i.changed;return n(a.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:p(a.Group,{position:"apart",sx:{height:60,position:"relative"},children:[n(a.Group,{children:n(a.Button,{size:"xs",color:c?"red":"green",leftIcon:n(V.IconArrowLeft,{size:20}),onClick:c?l:o,children:p(a.Group,{spacing:4,children:["End Editing",n(a.Text,{td:"underline",children:i.name})]})})}),t,p(a.Group,{position:"right",children:[n(a.Button,{variant:"filled",size:"xs",disabled:!i.views.VIE,onClick:()=>i.addANewPanel(i.views.idOfVIE),leftIcon:n(V.IconPlaylistAdd,{size:20}),children:"Add a Panel"}),p(a.Group,{spacing:0,sx:fs,children:[n(a.Tooltip,{label:"Download Schema",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",size:"md",onClick:s,children:n(V.IconCode,{size:18})})}),n(a.Tooltip,{label:"Download Data",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",size:"md",onClick:i.queries.downloadAllData,children:n(V.IconDownload,{size:18})})})]}),p(a.Group,{spacing:16,children:[n(a.Tooltip,{label:"Revert Changes",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",size:"md",disabled:!c,onClick:d,children:n(V.IconRecycle,{size:20,color:"red"})})}),n(a.Button,{color:"green",variant:"filled",size:"xs",leftIcon:n(V.IconDeviceFloppy,{size:18}),onClick:e,disabled:!c,children:"Save Changes"})]})]})]})})}),gw="";function Wv(e,t,r){const i=[];return e.filter(s=>"__INTERACTIONS"in s.viz.conf).forEach((s,o)=>{const u=t[s.id];u.data.interactions=y.get(u,"data.interactions",[]);const{__INTERACTIONS:l,__OPERATIONS:d,__TRIGGERS:c}=s.viz.conf;Object.entries(d).forEach(([f,g])=>{const{schemaRef:h,data:b}=g,{config:w}=b;switch(h){case"builtin:op:open-link":let C=w.urlTemplate.substring(0,100);w.urlTemplate.length>=20&&(C+="..."),u.type="interaction",u.data.interactions.push({schemaRef:h,urlTemplate:w.urlTemplate,shortURLTemplate:C});return;case"builtin:op:open_view":i.push({id:`OPERATION--${f}`,source:s.id,target:w.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":u.type="interaction",u.data.interactions.push({schemaRef:h,filters:Object.keys(w.dictionary).map(S=>({key:S,label:r[S]}))});return;case"builtin:op:clear_filter_values":u.type="interaction",u.data.interactions.push({schemaRef:h,filters:w.filter_keys.map(S=>({key:S,label:r[S]}))});return;default:return}})}),i}function Rv(e,t){const r=e.filters.keyLabelMap;return{edges:Wv(e.panels.list,t,r),edgeNodes:[]}}function gs(e,t,r){return e*t+e*r}function Yv(e,t,r){return e*t+(e-1)*r}const an=25,cr=40,ms=25,pr=350,jv=150,Qv=150,bs=150,vs=300,sn=40,ys=25,Uv=300;function Xv(e,t){const r=y.keyBy(t,s=>s.id),i=[];return e.current.forEach((s,o)=>{s.panelIDs.forEach((u,l)=>{const d=gs(l,sn,ys)+cr,c=r[u];if(!c){i.push({id:u,_node_type:"panel",parentNode:s.id,data:{label:`!: ${u}`},position:{x:an,y:d},sourcePosition:ye.Position.Right,targetPosition:ye.Position.Left,style:{width:vs,height:sn}});return}const f=c.title.trim()?`${c.title}`:c.viz.type;i.push({id:c.id,_node_type:"panel",parentNode:s.id,data:{label:f},position:{x:an,y:d},sourcePosition:ye.Position.Right,targetPosition:ye.Position.Left,style:{width:vs,height:sn}})})}),i}const Zv={[K.Division]:"Div",[K.Modal]:"Modal",[K.Tabs]:"Tabs"},Kv=Va;function Jv(e){return e.current.map((r,i)=>{const s=Yv(r.panelIDs.length,sn,ys)+cr+ms;let o=[];return r.type===K.Tabs&&(o=r.config.tabs.map(l=>l.view_id)),{id:r.id,_node_type:"view-root",_view_type:r.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${Zv[r.type]}:${r.name}`},position:{x:0,y:0},sourcePosition:ye.Position.Right,targetPosition:ye.Position.Left,className:"light",style:{backgroundColor:Kv[r.type],width:pr,height:s}}})}function Hv(e){const t=y.keyBy(e,r=>r.id);e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==K.Tabs||r._tab_view_ids.forEach(i=>{t[i].parentNode=r.id})})}function ey(e){const t=Jv(e.views);Hv(t);const r=Xv(e.views,e.panels.list);return[...t,...r]}function ty({nodeMap:e,nodes:t,edges:r}){t.forEach(i=>{i._node_type!=="view-root"||i._view_type!==K.Tabs||(i.sourcePosition=ye.Position.Bottom,i.style.width=pr+an*2,i.style.height=ms+i._tab_view_ids.reduce((s,o)=>{const u=e[o];u.position.y=s,u.position.x=an;const l=u.style.height;return s+l+20},cr))})}function ny({nodeMap:e,nodes:t,edges:r}){r.filter(i=>i.label==="Open View").forEach(i=>{const s=e[i.source],o=e[i.target];if(!s||!o||!s.parentNode)return;const u=e[s.parentNode];u._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+u._view_level,u._sub_view_ids.push(o.id))}),t.sort((i,s)=>i._node_type==="view-root"&&s._node_type==="view-root"?i._view_level-s._view_level:i._node_type!=="view-root"&&s._node_type!=="view-root"?0:i._node_type==="view-root"?-1:1)}function ry({nodeMap:e,nodes:t,edges:r}){const i={};r.forEach(s=>{if(s.label!=="Open View")return;const o=e[s.source],u=e[s.target];if(o&&u&&o.parentNode){const l=e[o.parentNode],d=l.position.x,c=Number(y.get(u,"style.height",0)),f=Number(l.style.width);u.position.x=d+f+Uv,l._view_level===0&&u._sub_view_ids.length===0&&(o.sourcePosition=ye.Position.Left,u.targetPosition=ye.Position.Right,u.position.x*=-1);const h=u.position.x,b=y.get(i,h,0);u.position.y=b,i[h]=b+c+bs}})}function iy({nodeMap:e,nodes:t,edges:r}){const i=new Set,s=new Set;r.forEach(u=>{i.add(u.source),s.add(u.target)}),t.filter(u=>u._node_type!=="view-root"||u.id==="Main"||u.parentNode?!1:!i.has(u.id)&&!s.has(u.id)).forEach((u,l)=>{u.position.x=gs(l,pr,Qv),u.position.y=0-jv-bs})}function ay({nodeMap:e,nodes:t,edges:r}){const i={nodeMap:e,nodes:t,edges:r};return iy(i),ny(i),ty(i),ry(i),{nodes:t,edges:r}}function sy(e){const t=ey(e),r=y.keyBy(t,d=>d.id),{edges:i,edgeNodes:s}=Rv(e,r),o=[...t,...s],u=y.keyBy(o,d=>d.id),l={edges:y.uniqBy(i,d=>d.id),nodes:o,nodeMap:u};return ay(l)}const mw="",hr={"builtin:op:open-link":n(a.ThemeIcon,{color:"blue",size:20,radius:"xl",children:n(V.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":n(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n(V.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":n(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n(V.IconCircleOff,{size:14})})};function oy(e){const t=[];return e.forEach(r=>{switch(r.schemaRef){case"builtin:op:open-link":t.push({key:r.urlTemplate,icon:hr[r.schemaRef],text:p(a.Group,{spacing:4,children:[n(a.Text,{children:"Open: "}),n(a.Text,{color:"dimmed",children:r.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":r.filters.forEach(({key:i,label:s})=>{t.push({key:r.schemaRef+i,icon:hr[r.schemaRef],text:n(a.Group,{spacing:4,children:p(a.Text,{children:["Set Filter: ",s]})})})});return;case"builtin:op:clear_filter_values":r.filters.forEach(({key:i,label:s})=>{t.push({key:r.schemaRef+i,icon:hr[r.schemaRef],text:n(a.Group,{spacing:4,children:p(a.Text,{children:["Clear Filter: ",s]})})})});return}}),t}const ly=m.memo(({data:e,isConnectable:t,sourcePosition:r=ye.Position.Right,targetPosition:i=ye.Position.Left,...s})=>{const o=m.useMemo(()=>oy(e.interactions),[e.interactions]);return p(O,{children:[n(ye.Handle,{type:"target",position:i,isConnectable:t}),n(a.Box,{sx:{position:"absolute",top:0,right:0},children:n(D.ChevronsUpRight,{size:12})}),p(a.HoverCard,{shadow:"xl",withinPortal:!0,children:[n(a.HoverCard.Target,{children:n(a.Text,{children:e.label})}),n(a.HoverCard.Dropdown,{children:n(a.List,{spacing:"xs",size:"sm",center:!0,children:o.map(u=>n(a.List.Item,{icon:u.icon,children:u.text},u.key))})})]}),n(ye.Handle,{type:"source",position:r,isConnectable:t})]})}),bw="",uy={interaction:ly},dy=T.observer(()=>{const e=B(),{edges:t,nodes:r}=sy(e);return p(ye,{nodes:r,edges:t,onNodesChange:y.noop,onEdgesChange:y.noop,onConnect:y.noop,className:"interactions-viewer",fitView:!0,nodeTypes:uy,children:[n(ye.MiniMap,{}),n(ye.Controls,{}),n(ye.Background,{})]})}),cy=T.observer(({opened:e,close:t})=>{const{freezeLayout:r}=m.useContext(Xe);return m.useEffect(()=>{r(e)},[e]),n(a.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:t,title:"Interactions",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},styles:{body:{height:"90vh"},modal:{transform:"none !important"}},zIndex:300,children:n(dy,{})})});function py({onClick:e,name:t,active:r,openSettings:i}){return p(a.Box,{sx:{position:"relative"},children:[n(a.UnstyledButton,{sx:s=>({display:"block",width:"100%",padding:s.spacing.xs,borderRadius:0,position:"relative",color:s.black,"&:hover":{backgroundColor:s.colors.gray[0]},backgroundColor:r?s.colors.gray[2]:"transparent"}),children:n(a.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:n(a.Text,{size:"sm",children:t})})}),r&&n(a.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:n(a.ActionIcon,{onClick:i,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:n(V.IconAdjustments,{size:16})})})]})}const hy=T.observer(()=>{const e=B(),t=m.useCallback(i=>()=>e.views.setIDOfVIE(i),[e]),r=i=>{e.editor.open(["_VIEWS_",i])};return p(a.Box,{sx:{position:"relative"},children:[e.views.options.map(i=>n(py,{active:e.views.idOfVIE===i.value,name:i.label,onClick:t(i.value),openSettings:()=>r(i.value)},i.value)),n(a.Divider,{variant:"dashed"}),n(a.Button,{variant:"subtle",rightIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:"Add a View"})]})}),fy=T.observer(()=>{const e=B(),t=()=>{if(!e.queries.firstID){e.editor.open(["_QUERIES_",""]);return}e.editor.open(["_QUERIES_",e.queries.firstID])},r=()=>{if(!e.filters.firstID){e.editor.open(["_FILTERS_",""]);return}e.editor.open(["_FILTERS_",e.filters.firstID])},[i,s]=m.useState(!1),o=()=>s(!0),u=()=>s(!1);return p(a.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:[p(a.Navbar.Section,{children:[p(a.Group,{grow:!0,spacing:0,sx:{...fs,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[n(a.Tooltip,{label:"Filters",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",radius:0,size:"md",onClick:r,children:n(V.IconFilter,{size:20})})}),n(a.Tooltip,{label:"Queries",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",radius:0,size:"md",onClick:t,children:n(V.IconDatabase,{size:20})})}),n(a.Tooltip,{label:"Interactions Viewer",withinPortal:!0,children:n(a.ActionIcon,{variant:"default",radius:0,size:"md",onClick:o,children:n(V.IconLink,{size:20})})})]}),n(cy,{opened:i,close:u})]}),n(a.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:n(a.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Views"})}),n(a.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:n(hy,{})}),n(a.Navbar.Section,{children:n(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n(a.Button,{size:"xs",leftIcon:n(V.IconSettings,{size:20}),onClick:()=>e.editor.open([]),children:"Settings"})})})]})}),gy=T.observer(function({config:t}){return p(O,{children:[n(a.Checkbox,{checked:t.default_value,onChange:r=>t.setDefaultValue(r.currentTarget.checked),label:"Default Checked"}),n(Nn,{label:"Description",value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),my=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],by=T.observer(function({config:t}){return p(O,{children:[p(a.Group,{children:[n(a.Checkbox,{checked:t.required,onChange:r=>t.setRequired(r.currentTarget.checked),label:"Required"}),n(a.Checkbox,{checked:t.clearable,onChange:r=>t.setClearable(r.currentTarget.checked),disabled:t.max_days>0,label:"Clearable"}),n(a.Checkbox,{checked:t.allowSingleDateInRange,onChange:r=>t.setAllowSingleDateInRange(r.currentTarget.checked),label:"Allow choosing 1 day"})]}),n(a.Select,{data:my,label:"Display Format",value:t.inputFormat,onChange:t.setInputFormat}),n(ki,{label:"Default Value",config:t,value:t.default_value,onChange:t.setDefaultValue}),n(a.NumberInput,{label:"Max Days",description:p(a.Group,{position:"apart",children:[n(a.Text,{children:"Set 0 to disable."}),p(a.Group,{spacing:4,children:[n(a.Text,{children:"This feature requires"}),n(a.Text,{color:"blue",children:"Clearable"}),n(a.Text,{children:"to be checked"})]})]}),min:0,value:t.max_days,onChange:t.setMaxDays,hideControls:!0})]})}),fr=T.observer(({value:e,onChange:t})=>{const r=B(),i=m.useMemo(()=>r.queries.options,[r.queries.current]),s=i.length===0;return n(a.Select,{label:"Pick a query",data:i,value:e,onChange:t,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:s,error:s?"You need to add a query in Data Settings":void 0})}),vy=`
|
|
360
360
|
// row
|
|
361
361
|
{
|
|
362
362
|
label: string;
|
package/dist/filter/filter.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ interface IFilter {
|
|
|
5
5
|
value: $TSFixMe;
|
|
6
6
|
onChange: (v: $TSFixMe) => void;
|
|
7
7
|
}
|
|
8
|
-
export declare const Filter: React.MemoExoticComponent<React.ForwardRefExoticComponent<
|
|
8
|
+
export declare const Filter: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<IFilter & React.RefAttributes<unknown>, "ref"> & React.RefAttributes<unknown>>>;
|
|
9
9
|
export {};
|
|
@@ -14,5 +14,5 @@ export interface IDashboardModel {
|
|
|
14
14
|
readonly json: IDashboard;
|
|
15
15
|
updateCurrent: (dashboard: IDashboard) => void;
|
|
16
16
|
}
|
|
17
|
-
export declare const Dashboard: React.MemoExoticComponent<React.ForwardRefExoticComponent<
|
|
17
|
+
export declare const Dashboard: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<IDashboardProps & React.RefAttributes<IDashboardModel>, "ref"> & React.RefAttributes<IDashboardModel>>>;
|
|
18
18
|
export {};
|
|
@@ -20,7 +20,7 @@ export declare function getOption(conf: IFunnelConf, data: AnyObject[]): {
|
|
|
20
20
|
position: import("../../../common-echarts-fields/label-position").IEchartsLabelPosition;
|
|
21
21
|
};
|
|
22
22
|
orient: "horizontal" | "vertical";
|
|
23
|
-
funnelAlign: "
|
|
23
|
+
funnelAlign: "center" | "right" | "left";
|
|
24
24
|
data: {
|
|
25
25
|
name: string;
|
|
26
26
|
value: string | number;
|
|
@@ -13,7 +13,7 @@ export declare function getSeries(conf: IFunnelConf, data: AnyObject[]): {
|
|
|
13
13
|
position: import("../../../common-echarts-fields/label-position").IEchartsLabelPosition;
|
|
14
14
|
};
|
|
15
15
|
orient: "horizontal" | "vertical";
|
|
16
|
-
funnelAlign: "
|
|
16
|
+
funnelAlign: "center" | "right" | "left";
|
|
17
17
|
data: SeriesDataType[];
|
|
18
18
|
id: string;
|
|
19
19
|
name: string;
|
|
@@ -68,7 +68,7 @@ export declare function getOption(conf: IParetoChartConf, data: TVizData, _varia
|
|
|
68
68
|
nameGap: number;
|
|
69
69
|
nameTextStyle: {
|
|
70
70
|
fontWeight: string;
|
|
71
|
-
align: "
|
|
71
|
+
align: "center" | "right" | "left";
|
|
72
72
|
};
|
|
73
73
|
position: string;
|
|
74
74
|
axisLine: {
|
|
@@ -86,7 +86,7 @@ export declare function getOption(conf: IParetoChartConf, data: TVizData, _varia
|
|
|
86
86
|
nameGap: number;
|
|
87
87
|
nameTextStyle: {
|
|
88
88
|
fontWeight: string;
|
|
89
|
-
align: "
|
|
89
|
+
align: "center" | "right" | "left";
|
|
90
90
|
};
|
|
91
91
|
position: string;
|
|
92
92
|
axisLine: {
|
|
@@ -5,7 +5,7 @@ export declare function getYAxes(conf: IParetoChartConf, formatters: TParetoForm
|
|
|
5
5
|
nameGap: number;
|
|
6
6
|
nameTextStyle: {
|
|
7
7
|
fontWeight: string;
|
|
8
|
-
align: "
|
|
8
|
+
align: "center" | "right" | "left";
|
|
9
9
|
};
|
|
10
10
|
position: string;
|
|
11
11
|
axisLine: {
|
|
@@ -23,7 +23,7 @@ export declare function getYAxes(conf: IParetoChartConf, formatters: TParetoForm
|
|
|
23
23
|
nameGap: number;
|
|
24
24
|
nameTextStyle: {
|
|
25
25
|
fontWeight: string;
|
|
26
|
-
align: "
|
|
26
|
+
align: "center" | "right" | "left";
|
|
27
27
|
};
|
|
28
28
|
position: string;
|
|
29
29
|
axisLine: {
|
|
@@ -4,7 +4,7 @@ export declare function getLevels(conf: ISunburstConf): {
|
|
|
4
4
|
label: {
|
|
5
5
|
formatter: ({ treePathInfo, name, value }: IEchartsSunburstLabelFormatter) => string | undefined;
|
|
6
6
|
rotate: "0" | "radial" | "tangential";
|
|
7
|
-
align: "
|
|
7
|
+
align: "center" | "right" | "left";
|
|
8
8
|
position: import("../../../common-echarts-fields/label-position").IEchartsLabelPosition;
|
|
9
9
|
padding: number;
|
|
10
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtable/dashboard",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.59.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@tiptap/react": "2.0.1",
|
|
76
76
|
"@tiptap/starter-kit": "2.0.1",
|
|
77
77
|
"@types/crypto-js": "v4.1.1",
|
|
78
|
-
"@types/d3-array": "3.0.
|
|
78
|
+
"@types/d3-array": "3.0.4",
|
|
79
79
|
"@types/eventemitter2": "^4.1.0",
|
|
80
80
|
"@types/file-saver": "2.0.5",
|
|
81
81
|
"@types/lodash": "^4.14.182",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"vite-plugin-static-copy": "0.13.1"
|
|
111
111
|
},
|
|
112
112
|
"peerDependencies": {
|
|
113
|
-
"@emotion/react": "11.10.
|
|
113
|
+
"@emotion/react": "11.10.6",
|
|
114
114
|
"@mantine/core": "5.9.5",
|
|
115
115
|
"@mantine/dates": "5.9.5",
|
|
116
116
|
"@mantine/form": "5.9.5",
|
|
@@ -142,9 +142,9 @@
|
|
|
142
142
|
"axios": "^0.27.2",
|
|
143
143
|
"chroma-js": "^2.4.2",
|
|
144
144
|
"crypto-js": "^4.1.1",
|
|
145
|
-
"d3-array": "3.2.
|
|
145
|
+
"d3-array": "3.2.3",
|
|
146
146
|
"d3-regression": "1.2.8",
|
|
147
|
-
"dayjs": "1.11.
|
|
147
|
+
"dayjs": "1.11.7",
|
|
148
148
|
"echarts": "^5.3.2",
|
|
149
149
|
"echarts-for-react": "^3.0.2",
|
|
150
150
|
"echarts-gl": "^2.0.9",
|