@perses-dev/table-plugin 0.14.0-beta.2 → 0.14.0-beta.3
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/__mf/js/{Table.cede74c3.js → Table.883f03c1.js} +5 -5
- package/__mf/js/async/{1186.76f7a9c4.js → 1186.3fefcd60.js} +1 -1
- package/__mf/js/async/{1522.f490bae9.js → 1522.c8ff8404.js} +5 -5
- package/__mf/js/async/{1616.e459f6f7.js → 1616.d4ad9369.js} +1 -1
- package/__mf/js/async/{2035.e9f08b1d.js → 2035.663a1725.js} +1 -1
- package/__mf/js/async/{2043.ddbebd72.js → 2043.ae4e8288.js} +2 -2
- package/__mf/js/async/{2251.2ab11c45.js → 2251.703b76a3.js} +3 -3
- package/__mf/js/async/{2465.b442bc56.js → 2465.c6931b55.js} +1 -1
- package/__mf/js/async/3473.9be85ef6.js +3 -0
- package/__mf/js/async/3632.d2625bb5.js +50 -0
- package/__mf/js/async/{392.3b464b91.js → 392.024e73d1.js} +2 -2
- package/__mf/js/async/{3923.7b9985ff.js → 3923.f1e47988.js} +1 -1
- package/__mf/js/async/{4077.dfd731dd.js → 4077.35af801d.js} +1 -1
- package/__mf/js/async/{4121.ed15fe74.js → 4121.3e6205ed.js} +2 -2
- package/__mf/js/async/{4496.487e4f10.js → 4496.8a39283e.js} +1 -1
- package/__mf/js/async/{5002.fc50985b.js → 5002.a5034462.js} +1 -1
- package/__mf/js/async/{5054.a0d861ae.js → 5054.4f6b6a33.js} +1 -1
- package/__mf/js/async/{5071.1e325f38.js → 5071.2b02adb9.js} +1 -1
- package/__mf/js/async/{5153.8a046a40.js → 5153.3b8e2090.js} +1 -1
- package/__mf/js/async/5587.640f7c54.js +1 -0
- package/__mf/js/async/{5741.ef0c5df4.js → 5741.bb4c3f82.js} +2 -2
- package/__mf/js/async/{6274.db89316a.js → 6274.6ad02cf0.js} +2 -2
- package/__mf/js/async/{7192.7e6af5a2.js → 7192.6dcfeaf1.js} +1 -1
- package/__mf/js/async/{7534.63c81960.js → 7534.0a3652dc.js} +1 -1
- package/__mf/js/async/{7862.cbf7b286.js → 7862.34ec88a2.js} +2 -2
- package/__mf/js/async/7968.896cda02.js +1 -0
- package/__mf/js/async/{7978.4553ce86.js → 7978.0d69549d.js} +1 -1
- package/__mf/js/async/8356.48ae65db.js +1 -0
- package/__mf/js/async/{8470.f35cd609.js → 8470.2e8f4245.js} +2 -2
- package/__mf/js/async/{873.fc45c2c6.js → 873.135cb93a.js} +1 -1
- package/__mf/js/async/{8985.6cc7edf9.js → 8985.aea09972.js} +1 -1
- package/__mf/js/async/9207.c9620800.js +1 -0
- package/__mf/js/async/{9235.78a103e9.js → 9235.7db37058.js} +1 -1
- package/__mf/js/async/{9321.ddbe25a2.js → 9321.66058a34.js} +1 -1
- package/__mf/js/async/{941.96941f4e.js → 941.a3308dc6.js} +2 -2
- package/__mf/js/async/{9588.039ce076.js → 9588.5e925b9b.js} +1 -1
- package/__mf/js/async/{__federation_expose_Table.e7708af8.js → __federation_expose_Table.ff543cd8.js} +1 -1
- package/__mf/js/async/{lib-router.e968bcc8.js → lib-router.1c17d6cf.js} +2 -2
- package/__mf/js/{main.7815ee7c.js → main.b5301832.js} +5 -5
- package/lib/components/ColumnsEditor/DataLinkEditorDialog.d.ts.map +1 -1
- package/lib/test/mock-query-results.d.ts.map +1 -1
- package/mf-manifest.json +50 -50
- package/mf-stats.json +50 -50
- package/package.json +6 -6
- package/__mf/js/async/2650.b874a7cd.js +0 -3
- package/__mf/js/async/5587.c9c77660.js +0 -1
- package/__mf/js/async/7968.f91456c8.js +0 -1
- package/__mf/js/async/8356.d5d8a6a3.js +0 -1
- package/__mf/js/async/9148.1ff77cf0.js +0 -1
- package/__mf/js/async/9207.ca6ac0b2.js +0 -1
- /package/__mf/js/async/{1522.f490bae9.js.LICENSE.txt → 1522.c8ff8404.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2043.ddbebd72.js.LICENSE.txt → 2043.ae4e8288.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2251.2ab11c45.js.LICENSE.txt → 2251.703b76a3.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.3b464b91.js.LICENSE.txt → 392.024e73d1.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4121.ed15fe74.js.LICENSE.txt → 4121.3e6205ed.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5741.ef0c5df4.js.LICENSE.txt → 5741.bb4c3f82.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6274.db89316a.js.LICENSE.txt → 6274.6ad02cf0.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7862.cbf7b286.js.LICENSE.txt → 7862.34ec88a2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8470.f35cd609.js.LICENSE.txt → 8470.2e8f4245.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.96941f4e.js.LICENSE.txt → 941.a3308dc6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.e968bcc8.js.LICENSE.txt → lib-router.1c17d6cf.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.chunk_Table_0_14_0_beta_2=self.chunk_Table_0_14_0_beta_2||[]).push([["2669"],{54042(e,t,n){var l;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((l=n(1448))&&l.__esModule?l:{default:l}).default)("M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z","Download")},42524(e,t,n){var l;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((l=n(1448))&&l.__esModule?l:{default:l}).default)("M19,13H5V11H19V13Z","Minus")},38019(e,t,n){n.r(t),n.d(t,{Table:()=>el});var l=n(62540),i=n(54381),o=n(315),r=n(93648),a=n(97653),s=n(88091),d=n(47095),u=n(65211),c=n(6227),h=n(7013),p=n(80255),g=n(86067),x=n(86742),f=n(70451),m=n.n(f);function v(e){let t=e.trim();if(""===t)return;let n=Number(t);return Number.isNaN(n)?void 0:n}function b(e,t){for(let l of t)if(function(e,t){var n,l,i,o,r,a,s;switch(e.kind){case"Value":return(null==(n=e.spec)?void 0:n.value)===String(t);case"Range":{if(Number.isNaN(Number(t)))return!1;let n=Number(t);if((null==(l=e.spec)?void 0:l.min)!==void 0&&(null==(i=e.spec)?void 0:i.max)!==void 0)return n>=+e.spec.min&&n<=+e.spec.max;if((null==(o=e.spec)?void 0:o.min)!==void 0)return n>=+e.spec.min;if((null==(r=e.spec)?void 0:r.max)!==void 0)return n<=+e.spec.max;return!1}case"Regex":if(!(null==(a=e.spec)?void 0:a.expr))return!1;try{return new RegExp(e.spec.expr).test(String(t))}catch{return!1}case"Misc":switch(null==(s=e.spec)?void 0:s.value){case"empty":return""===t;case"null":return null==t;case"NaN":return Number.isNaN(t);case"true":return!0===t;case"false":return!1===t;default:return!1}default:return!1}}(l.condition,e)){let t;if("Misc"===l.condition.kind){var n;switch(null==(n=l.condition.spec)?void 0:n.value){case"null":t="null";break;case"NaN":t="NaN"}}return function(e,t,n){let l=t.text||n||String(e);return{text:`${t.prefix??""}${l}${t.suffix??""}`,textColor:t.textColor,backgroundColor:t.backgroundColor}}(e,l,t)}}function j(e){let{cell:t,onChange:n,onDelete:c,...h}=e;return(0,l.jsxs)(i.A,{container:!0,spacing:2,...h,children:[(0,l.jsx)(i.A,{size:{xs:5},children:(0,l.jsxs)(o.A,{direction:"row",gap:1,width:"100%",children:[(0,l.jsxs)(r.A,{select:!0,label:"Type",value:t.condition.kind,onChange:e=>n({...t,condition:{kind:e.target.value}}),required:!0,sx:{width:"120px"},children:[(0,l.jsx)(a.A,{value:"Value",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Value"}),"Value"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches an exact text value"})]})}),(0,l.jsx)(a.A,{value:"Range",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Range"}),"Range"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches against a numerical range"})]})}),(0,l.jsx)(a.A,{value:"Regex",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Regex"}),"Regex"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches against a regular expression"})]})}),(0,l.jsx)(a.A,{value:"Misc",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Misc"}),"Misc"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches against empty, null and NaN values"})]})})]}),function(e,t){var n,l,i,d,u;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"small";return"Value"===e.kind?m().createElement(r.A,{label:"Value",placeholder:"Exact value",value:(null==(n=e.spec)?void 0:n.value)??"",onChange:n=>t({...e,spec:{value:n.target.value}}),fullWidth:!0,size:c}):"Range"===e.kind?m().createElement(o.A,{gap:1,direction:"row"},[m().createElement(r.A,{key:"min",label:"From",placeholder:"Start of range",value:(null==(l=e.spec)?void 0:l.min)??"",onChange:n=>{let l=v(n.target.value);t({...e,spec:{...e.spec,min:l}})},type:"number",slotProps:{htmlInput:{step:"any"}},fullWidth:!0,size:c}),m().createElement(r.A,{key:"max",label:"To",placeholder:"End of range (inclusive)",value:(null==(i=e.spec)?void 0:i.max)??"",onChange:n=>{let l=v(n.target.value);t({...e,spec:{...e.spec,max:l}})},type:"number",slotProps:{htmlInput:{step:"any"}},fullWidth:!0,size:c})]):"Regex"===e.kind?m().createElement(r.A,{label:"Regular Expression",placeholder:"JavaScript regular expression",value:(null==(d=e.spec)?void 0:d.expr)??"",onChange:n=>t({...e,spec:{expr:n.target.value}}),fullWidth:!0,size:c}):"Misc"===e.kind?m().createElement(r.A,{select:!0,label:"Value",value:(null==(u=e.spec)?void 0:u.value)??"",onChange:n=>t({...e,spec:{value:n.target.value}}),fullWidth:!0,size:c},[{value:"empty",label:"Empty",caption:"Matches empty string"},{value:"null",label:"Null",caption:"Matches null or undefined"},{value:"NaN",label:"NaN",caption:"Matches Not a Number value"},{value:"true",label:"True",caption:"Matches true boolean"},{value:"false",label:"False",caption:"Matches false boolean"}].map(e=>m().createElement(a.A,{key:e.value,value:e.value},m().createElement(o.A,{key:"stack"},[m().createElement(s.A,{key:"title"},e.label),m().createElement(s.A,{key:"caption",variant:"caption"},e.caption)])))):null}(t.condition,e=>n({...t,condition:e}),"small")]})}),(0,l.jsx)(i.A,{size:{xs:4},children:(0,l.jsxs)(o.A,{spacing:1,children:[(0,l.jsx)(r.A,{label:"Display text",value:t.text,onChange:e=>n({...t,text:e.target.value}),fullWidth:!0,size:"small"}),(0,l.jsxs)(o.A,{direction:"row",spacing:1,children:[(0,l.jsx)(r.A,{label:"Prefix",placeholder:"$",value:t.prefix??"",onChange:e=>n({...t,prefix:e.target.value}),size:"small"}),(0,l.jsx)(r.A,{label:"Suffix",placeholder:"%",value:t.suffix??"",onChange:e=>n({...t,suffix:e.target.value}),size:"small"})]})]})}),(0,l.jsx)(i.A,{size:{xs:1},children:(0,l.jsx)(o.A,{direction:"row",justifyContent:"center",gap:1,children:t.textColor?(0,l.jsx)(p.OptionsColorPicker,{label:"Text Color",color:t.textColor??"#000",onColorChange:e=>n({...t,textColor:e}),onClear:()=>n({...t,textColor:void 0})}):(0,l.jsx)(d.A,{onClick:()=>n({...t,textColor:"#000"}),children:(0,l.jsx)(x.default,{})})})}),(0,l.jsx)(i.A,{size:{xs:1},children:(0,l.jsx)(o.A,{direction:"row",justifyContent:"center",children:t.backgroundColor?(0,l.jsx)(p.OptionsColorPicker,{label:"Background Color",color:t.backgroundColor??"#fff",onColorChange:e=>n({...t,backgroundColor:e}),onClear:()=>n({...t,backgroundColor:void 0})}):(0,l.jsx)(d.A,{onClick:()=>n({...t,backgroundColor:"#000"}),children:(0,l.jsx)(x.default,{})})})}),(0,l.jsx)(i.A,{size:{xs:1},textAlign:"end",children:(0,l.jsx)(u.A,{title:"Remove cell settings",placement:"top",children:(0,l.jsx)(d.A,{size:"small",sx:{marginLeft:"auto"},onClick:c,children:(0,l.jsx)(g.default,{})},"delete-cell-button")})})]})}function C(e){let{cellSettings:t=[],onChange:n,addButtonText:r="Add Conditional Format"}=e;return(0,l.jsxs)(o.A,{spacing:3,sx:{mt:2},children:[(0,l.jsxs)(i.A,{container:!0,spacing:3,children:[(0,l.jsx)(i.A,{size:{xs:5},children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Condition"})}),(0,l.jsx)(i.A,{size:{xs:4},children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Display Text"})}),(0,l.jsx)(i.A,{size:{xs:1},textAlign:"center",children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Color"})}),(0,l.jsx)(i.A,{size:{xs:1},textAlign:"center",children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Background"})}),(0,l.jsx)(i.A,{size:{xs:1}})]}),(0,l.jsx)(o.A,{gap:1.5,divider:(0,l.jsx)(c.A,{flexItem:!0,orientation:"horizontal"}),children:t.map((e,i)=>(0,l.jsx)(j,{cell:e,onChange:e=>{let l;(l=[...t])[i]=e,n(l)},onDelete:()=>{let e;(e=[...t]).splice(i,1),n(e.length>0?e:void 0)}},i))}),(0,l.jsx)(h.A,{variant:"outlined",startIcon:(0,l.jsx)(x.default,{}),sx:{marginTop:1},onClick:()=>{let e=[...t];e.push({condition:{kind:"Value",spec:{value:""}}}),n(e)},children:r})]})}function y(e){let{cellSettings:t,onChange:n}=e;return(0,l.jsx)(C,{cellSettings:t,onChange:e=>n(e||[])})}var A=n(68003),S=n(12138),k=n(26659),w=n(42524);let E=e=>{let{onChange:t,column:n,column:{dataLink:i}}=e;if(!i)return(0,l.jsxs)(o.A,{sx:{width:"100%",alignItems:"center"},direction:"row",children:[(0,l.jsx)(s.A,{flex:1,variant:"subtitle1",mb:2,fontStyle:"italic",children:"No link defined"}),(0,l.jsx)(d.A,{style:{width:"fit-content",height:"fit-content"},onClick:()=>t({...n,dataLink:{url:"",openNewTab:!0,title:""}}),children:(0,l.jsx)(x.default,{})})]});let{url:r,openNewTab:a,title:u}=i;return(0,l.jsxs)(o.A,{sx:{width:"100%",alignItems:"center"},direction:"row",children:[(0,l.jsx)(p.LinkEditorForm,{mode:"inline",url:{label:"Url",onChange:e=>{t({...n,dataLink:{...i,url:e}})},value:r,placeholder:"URL",error:{hasError:!1,helperText:""}},name:{label:"Name",onChange:e=>{t({...n,dataLink:{...i,title:e}})},value:u??"",placeholder:"Name"},newTabOpen:{label:"Open in new tab",onChange:e=>{t({...n,dataLink:{...i,openNewTab:e}})},value:a}}),(0,l.jsx)(d.A,{style:{width:"fit-content",height:"fit-content"},onClick:()=>{t({...n,dataLink:void 0})},children:(0,l.jsx)(w.default,{})})]})};var O=n(25742),M=n(25632),z=n.n(M);function R(e,t){let n=e.createInitialOptions()??{};return z()({},n,t??{})}function T(e){let{kind:t,spec:n,onChange:i}=e,{data:r,isLoading:a,isError:d,error:u}=(0,k.usePlugin)("Panel",t),c=(0,f.useMemo)(()=>r?R(r,n):n,[r,n]),h=(0,f.useRef)(i);if(h.current=i,(0,f.useEffect)(()=>{r&&(null==n||"object"==typeof n&&0===Object.keys(n).length)&&h.current(R(r,n))},[r,t,n]),a)return(0,l.jsxs)(o.A,{direction:"row",alignItems:"center",spacing:1,sx:{py:1},children:[(0,l.jsx)(O.A,{size:22}),(0,l.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"Loading panel settings…"})]});if(d||!r)return(0,l.jsx)(s.A,{variant:"body2",color:"error",children:(null==u?void 0:u.message)??"Could not load panel plugin."});let p=r.panelOptionsEditorComponents??[];return 0===p.length?(0,l.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"This visualization has no editable settings."}):(0,l.jsx)(o.A,{spacing:2.5,sx:{width:"100%",py:1},children:(0,l.jsx)(k.OptionsEditorTabs,{tabs:p.map(e=>{let t=e.content;return{label:e.label,content:(0,l.jsx)(t,{value:c,onChange:e=>{i(e)}})}})})})}let N={unit:"decimal",shortValues:!0};function D(e){var t,n;let{column:i,onChange:a,defaultEnableSorting:d=!1,...u}=e,[c,g]=(0,f.useState)(void 0===i.width||"auto"===i.width?100:i.width),x=i.enableSorting??d;return(0,l.jsxs)(o.A,{...u,children:[(0,l.jsxs)(p.OptionsEditorGrid,{children:[(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsxs)(p.OptionsEditorGroup,{title:"Column",children:[(0,l.jsx)(p.OptionsEditorControl,{label:"Name*",control:(0,l.jsx)(r.A,{value:i.name,onChange:e=>a({...i,name:e.target.value}),required:!0})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Header",control:(0,l.jsx)(r.A,{value:i.header??"",onChange:e=>a({...i,header:e.target.value?e.target.value:void 0})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Header Tooltip",control:(0,l.jsx)(r.A,{value:i.headerDescription??"",onChange:e=>a({...i,headerDescription:e.target.value?e.target.value:void 0})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Cell Tooltip",control:(0,l.jsx)(r.A,{value:i.cellDescription??"",onChange:e=>a({...i,cellDescription:e.target.value?e.target.value:void 0})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Enable sorting",control:(0,l.jsx)(A.A,{checked:x,onChange:e=>(function(e){if(e===d){let{enableSorting:e,...t}=i;a(t);return}a({...i,enableSorting:e})})(e.target.checked)})}),void 0===i.enableSorting&&(0,l.jsx)(s.A,{variant:"caption",color:"text.secondary",children:"Inherits from General Settings"}),x&&(0,l.jsx)(p.OptionsEditorControl,{label:"Default Sort",control:(0,l.jsx)(p.SortSelectorButtons,{size:"medium",value:i.sort,sx:{margin:.5},onChange:e=>a({...i,sort:e})})})]})}),(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsxs)(p.OptionsEditorGroup,{title:"Visual",children:[(0,l.jsx)(p.OptionsEditorControl,{label:"Show column",control:(0,l.jsx)(A.A,{checked:!i.hide,onChange:e=>a({...i,hide:!e.target.checked})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Cell display",control:(0,l.jsxs)(o.A,{spacing:1,children:[(0,l.jsxs)(S.A,{"aria-label":"Cell display",size:"small",children:[(0,l.jsx)(h.A,{variant:i.plugin?"outlined":"contained",onClick:()=>a({...i,plugin:void 0}),children:"Text"}),(0,l.jsx)(h.A,{variant:i.plugin?"contained":"outlined",onClick:()=>a({...i,plugin:{kind:"GaugeChart",spec:{}}}),children:"Visualization"})]}),(0,l.jsx)(s.A,{variant:"caption",color:"text.secondary",sx:{maxWidth:360},children:"Visualizations reuse panel settings (thresholds, units, colors). Text mode uses value formatting below."})]})}),i.plugin?(0,l.jsx)(p.OptionsEditorControl,{label:"Visualization type",control:(0,l.jsx)(k.PluginKindSelect,{pluginTypes:["Panel"],size:"small",value:{type:"Panel",kind:i.plugin.kind},onChange:e=>a({...i,plugin:{kind:e.kind,spec:{}}})})}):(0,l.jsx)(p.FormatControls,{value:i.format??N,onChange:e=>a({...i,format:e})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Alignment",control:(0,l.jsx)(p.AlignSelector,{size:"small",value:i.align??"left",onChange:e=>a({...i,align:e})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Custom width",control:(0,l.jsx)(A.A,{checked:void 0!==i.width&&"auto"!==i.width,onChange:e=>a({...i,width:e.target.checked?c:"auto"})})}),void 0!==i.width&&"auto"!==i.width&&(0,l.jsx)(p.OptionsEditorControl,{label:"Width",control:(0,l.jsx)(r.A,{type:"number",value:c,slotProps:{htmlInput:{min:1}},onChange:e=>{g(+e.target.value),a({...i,width:+e.target.value})}})})]})}),(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsx)(p.OptionsEditorGroup,{title:"Link",children:(0,l.jsx)(E,{column:i,onChange:a})})})]}),(null==(t=i.plugin)?void 0:t.kind)==="GaugeChart"&&(0,l.jsx)(o.A,{sx:{px:8,mt:4,width:"100%"},spacing:2,children:(0,l.jsx)(p.OptionsEditorGroup,{title:"Visualization settings",children:(0,l.jsx)(T,{kind:"GaugeChart",spec:i.plugin.spec,onChange:e=>a({...i,plugin:{kind:"GaugeChart",spec:e}})})})}),(0,l.jsx)(o.A,{sx:{px:8,mt:3*((null==(n=i.plugin)?void 0:n.kind)==="GaugeChart")},children:(0,l.jsx)(p.OptionsEditorGroup,{title:"Conditional Cell Format",children:(0,l.jsx)(C,{cellSettings:i.cellSettings,onChange:e=>a({...i,cellSettings:e})})})})]})}var V=n(87275),I=n(11061),L=n(78536),F=n(1355);function $(e){let{column:t,isCollapsed:n,onChange:i,onCollapse:r,onDelete:a,onMoveUp:h,onMoveDown:x,defaultEnableSorting:f}=e;return(0,l.jsxs)(p.DragAndDropElement,{data:t,children:[(0,l.jsxs)(o.A,{direction:"row",alignItems:"center",borderBottom:1,borderColor:e=>e.palette.divider,justifyContent:"space-between",gap:4,children:[(0,l.jsxs)(o.A,{direction:"row",gap:1,children:[(0,l.jsx)(d.A,{"data-testid":`column-toggle#${t.name}`,size:"small",onClick:()=>r(!n),children:n?(0,l.jsx)(I.default,{}):(0,l.jsx)(V.default,{})}),(0,l.jsxs)(s.A,{variant:"overline",component:"h4",sx:{textTransform:"none"},children:["COLUMN:"," ",t.header?(0,l.jsxs)("span",{children:[(0,l.jsx)("strong",{children:t.header})," (",t.name,")"]}):(0,l.jsx)("strong",{children:t.name})]})]}),(0,l.jsxs)(o.A,{direction:"row",gap:1,children:[n&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(u.A,{title:t.hide?"Show column":"Hide column",placement:"top",children:(0,l.jsx)(d.A,{size:"small",sx:{marginLeft:"auto"},onClick:function(){i({...t,hide:!t.hide})},children:t.hide?(0,l.jsx)(L.default,{}):(0,l.jsx)(F.default,{})},"hide-column")}),(0,l.jsx)(c.A,{flexItem:!0,orientation:"vertical",variant:"middle"})]}),(0,l.jsx)(u.A,{title:"Remove column settings",placement:"top",children:(0,l.jsx)(d.A,{size:"small",sx:{marginLeft:"auto"},onClick:a,children:(0,l.jsx)(g.default,{})},"delete-column-button")}),(0,l.jsx)(u.A,{title:"Reorder column settings",placement:"top",children:(0,l.jsx)(p.DragButton,{onMoveUp:h,onMoveDown:x,menuSx:{".MuiPaper-root":{backgroundColor:e=>e.palette.background.lighter}}},"reorder-column-button")})]})]}),!n&&(0,l.jsx)("div",{children:(0,l.jsx)(D,{column:t,onChange:i,defaultEnableSorting:f})})]})}function _(e){let{columnSettings:t,onChange:n,defaultEnableSorting:i}=e,[r,a]=(0,f.useState)(t.map(()=>!0));return(0,p.useDragAndDropMonitor)({elements:t,accessKey:"name",onChange:n}),(0,l.jsxs)(o.A,{spacing:1,children:[t.map((e,o)=>(0,l.jsx)($,{column:e,isCollapsed:r[o]??!0,defaultEnableSorting:i,onChange:e=>{let l;(l=[...t])[o]=e,n(l)},onDelete:()=>{let e;(e=[...t]).splice(o,1),n(e),a(e=>(e.splice(o,1),[...e]))},onCollapse:e=>{a(t=>(t[o]=e,[...t]))},onMoveUp:()=>n((0,p.handleMoveUp)(e,t)),onMoveDown:()=>n((0,p.handleMoveDown)(e,t))},o)),(0,l.jsx)(h.A,{variant:"contained",startIcon:(0,l.jsx)(x.default,{}),sx:{marginTop:1},onClick:function(){let e=`column_${Object.keys(t).length}`,l=[...t];l.push({name:e}),n(l),a(e=>(e.push(!1),[...e]))},children:"Add Column Settings"})]})}var H=n(69181),P=n(85180);function W(e){let{kind:t,spec:n,queryResults:i}=e,{ref:o,width:r=1,height:a=1}=(0,P.default)();return(0,l.jsx)("div",{ref:o,style:{height:"100%"},children:(0,l.jsx)(p.ErrorBoundary,{FallbackComponent:p.ErrorAlert,children:(0,l.jsx)(H.PanelPluginLoader,{kind:t,contentDimensions:{width:r,height:a},spec:n,queryResults:i})})})}var G=n(74628),B=n(56599),U=n(20231);function K(e){return(e.columnSettings??[]).some(e=>e.plugin)?"range":"instant"}function q(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{forExport:l=!1}=n,i=K(t);return e.flatMap((e,t)=>{var n;return((null==(n=e.data)?void 0:n.series)??[]).map(n=>({data:e,ts:n,queryIndex:t}))}).map(n=>{let o,{data:r,ts:a,queryIndex:s}=n,d=a.values[a.values.length-1];if(void 0===d)return{...a.labels};let u=1===e.length?"value":`value #${s+1}`,c=1===e.length?a.labels:Object.entries(a.labels??{}).reduce((e,t)=>{let[n,l]=t;return n&&(e[`${n} #${s+1}`]=l),e},{});if(l)o=d[1];else{var h;o=(null==(h=(t.columnSettings??[]).find(e=>e.name===u))?void 0:h.plugin)?{...r,data:{...r.data,series:r.data.series.filter(e=>e===a)}}:d[1]}return"instant"===i?{timestamp:d[0],[u]:o,...c}:{[u]:o,...c}})}function Q(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=Number(e);if(Number.isFinite(t))return t}}function Z(e){return"object"==typeof e&&null!==e&&void 0!==e.definition&&void 0!==e.data}function J(e){if(Z(e)){var t,n;let l=null==(t=e.data)?void 0:t.series,i=null==l?void 0:l[0];if(!(null==i||null==(n=i.values)?void 0:n.length))return;let o=k.CalculationsMap["last-number"];if("function"!=typeof o)return;let r=o(i.values);return"number"==typeof r?r:void 0}return Q(e)}function X(e){let{value:t,range:n,fillColor:i,format:o}=e;if(void 0===t)return(0,l.jsx)(l.Fragment,{});let r=0;return void 0!==n&&(r=n.max===n.min?100:(t-n.min)/(n.max-n.min)*100),r=Math.max(0,Math.min(100,r)),(0,l.jsxs)(G.A,{sx:{display:"flex",alignItems:"center",width:"100%",gap:1},children:[(0,l.jsx)(G.A,{sx:{flexGrow:1,borderRadius:1,backgroundColor:"rgba(127,127,127,0.20)",height:24,overflow:"hidden"},children:(0,l.jsx)(G.A,{sx:{width:`${r}%`,height:"100%",backgroundColor:i??"success.main",borderRadius:1}})}),(0,l.jsx)(s.A,{variant:"body2",sx:{minWidth:52,textAlign:"right"},children:o?(0,p.formatValue)(t,o):t.toFixed(2)})]})}function Y(e){let{allValues:t,selectedValues:n,onFilterChange:i,theme:o}=e,[r,a]=(0,f.useState)(""),s=[...new Set(t)].filter(e=>null!==e).toSorted(),d=r?s.filter(e=>String(e.formatted).toLowerCase().includes(r.toLowerCase())):s;return 0===s.length?(0,l.jsx)("div",{"data-filter-dropdown":!0,style:{width:200,padding:10,backgroundColor:o.palette.background.paper,border:`1px solid ${o.palette.divider}`,borderRadius:4,boxShadow:o.shadows[4]},children:(0,l.jsx)("div",{style:{color:o.palette.text.secondary,fontSize:14},children:"No values found"})}):(0,l.jsxs)("div",{"data-filter-dropdown":!0,style:{width:200,padding:10,backgroundColor:o.palette.background.paper,border:`1px solid ${o.palette.divider}`,borderRadius:4,boxShadow:o.shadows[4],maxHeight:250,overflowY:"auto"},children:[(0,l.jsx)("input",{type:"text",placeholder:"Search...",value:r,onChange:e=>a(e.target.value),style:{width:"100%",padding:"6px 8px",marginBottom:8,fontSize:13,border:`1px solid ${o.palette.divider}`,borderRadius:4,backgroundColor:o.palette.background.default,color:o.palette.text.primary,boxSizing:"border-box"}}),(0,l.jsx)("div",{style:{marginBottom:8,fontSize:14,fontWeight:"bold"},children:(0,l.jsxs)("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[(0,l.jsx)("input",{type:"checkbox",checked:n.length===s.length&&s.length>0,onChange:e=>i(e.target.checked?s.map(e=>e.original):[]),style:{marginRight:8}}),(0,l.jsxs)("span",{style:{color:o.palette.text.primary},children:["Select All (",s.length,")"]})]})}),(0,l.jsx)("hr",{style:{margin:"8px 0",border:"none",borderTop:`1px solid ${o.palette.divider}`}}),d.map((e,t)=>(0,l.jsx)("div",{style:{marginBottom:4},children:(0,l.jsxs)(G.A,{component:"label",sx:{display:"flex",alignItems:"center",cursor:"pointer",padding:"2px 0",borderRadius:"2px","&:hover":{backgroundColor:o.palette.action.hover}},children:[(0,l.jsx)("input",{type:"checkbox",checked:n.includes(e.original),onChange:t=>{t.target.checked?i([...n,e.original]):i(n.filter(t=>t!==e.original))},style:{marginRight:8}}),(0,l.jsx)("span",{style:{fontSize:14,color:o.palette.text.primary},children:null==e||""===e.formatted?"(empty)":String(e.formatted)})]})},`value-${t}`))]})}function ee(e,t,n,i){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];for(let a of t)if(a.name===e){if(a.hide)return;let{name:e,header:t,headerDescription:s,enableSorting:d,width:u,align:c,dataLink:h}=a;return{accessorKey:e,header:t??e,headerDescription:s,enableSorting:d??r,width:u,align:c,dataLink:h?{...h,url:(0,k.replaceVariablesInString)(h.url,n)}:void 0,...function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=e.plugin;return void 0!==i?{cell:o=>{let r=o.getValue();if("GaugeChart"===i.kind){var a;let o=J(r),s=function(e,t,n){let l=b(e,t);if(null==n?void 0:n.length){let t=b(e,n);t&&(l=t)}return(null==l?void 0:l.backgroundColor)??(null==l?void 0:l.textColor)}(o,n,e.cellSettings);return(0,l.jsx)(X,{value:o,range:t,fillColor:s,format:(null==(a=i.spec)?void 0:a.format)??e.format})}let s=Z(r)?r:function(e,t){let n=Q(e);if(void 0===n)return;let l=Date.now();return{definition:{kind:"TimeSeriesQuery",spec:{plugin:{kind:"PrometheusTimeSeriesQuery",spec:{query:""}}}},data:{timeRange:{start:new Date(l),end:new Date(l)},stepMs:1,series:[{name:t,values:[[l,n]],labels:{}}]}}}(r,e.name);return s?(0,l.jsx)(W,{kind:i.kind,spec:i.spec,queryResults:[s]}):(0,l.jsx)(l.Fragment,{})},cellDescription:e.cellDescription?()=>`${e.cellDescription}`:()=>""}:{cell:t=>{let n=t.getValue();return"number"==typeof n&&e.format?(0,p.formatValue)(n,e.format):n},cellDescription:e.cellDescription?()=>`${e.cellDescription}`:void 0}}(a,i[e],o)}}return{accessorKey:e,header:e,enableSorting:r}}function et(e){let{label:t,defaultValue:n,value:i,onChange:o}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.OptionsEditorControl,{label:`Auto Columns ${t}`,control:(0,l.jsx)(A.A,{checked:void 0===i||"auto"===i,onChange:function(e,t){if(t)return o("auto");o(n)}})}),void 0!==i&&"auto"!==i&&(0,l.jsx)(p.OptionsEditorControl,{label:`Default Columns ${t}`,control:(0,l.jsx)(r.A,{type:"number",value:i??n,slotProps:{input:{inputProps:{min:1,step:1}}},onChange:e=>o(parseInt(e.target.value))})})]})}var en=n(54042);let el={PanelComponent:function(e){var t,n;let{contentDimensions:i,spec:o,queryResults:r}=e,a=(0,B.A)(),d=(0,k.useAllVariableValues)(),u=(null==(t=o.selection)?void 0:t.enabled)??!1,{selectionMap:c,setSelection:h,clearSelection:g}=(0,p.useSelection)(),x=o.actions?o.actions:void 0,m=(null==x?void 0:x.enabled)&&x.displayWithItem?x.actionsList:[],{getItemActionButtons:v,confirmDialog:j,actionButtons:C}=(0,H.useSelectionItemActions)({actions:m,variableState:d}),y=(0,f.useRef)([]),A=(0,f.useRef)(null),S=(0,f.useRef)(null),w=(0,f.useRef)([]),E=(0,f.useMemo)(()=>{let e={};return c.forEach((t,n)=>{e[n]=!0}),e},[c]),O=(0,f.useCallback)(e=>{let t=[];for(let[n,l]of Object.entries(e))if(l){let e=parseInt(n,10);void 0!==y.current[e]&&t.push({id:n,item:y.current[e]})}0===t.length?g():h(t)},[h,g]),M=(0,f.useMemo)(()=>q(r,o),[r,o]),z=(0,f.useMemo)(()=>(0,p.transformData)(M,o.transforms??[]),[M,o.transforms]),R=(0,f.useMemo)(()=>{let e=[];for(let t of z)for(let n of Object.keys(t))e.includes(n)||e.push(n);for(let t of o.columnSettings??[])e.includes(t.name)||e.push(t.name);return e},[z,o.columnSettings]),T=(0,f.useMemo)(()=>{let e={},t=null==o?void 0:o.columnSettings;if(t)for(let n=0;n<t.length;n++){let{name:l,format:i}=t[n]||{};l&&i&&(e[l]=i)}return e},[o]),N=(0,f.useMemo)(()=>{let e={};for(let t of R){let n=null==T?void 0:T[t];e[t]=[];let l=new Map;for(let i of z){let o=i[t];""!==o&&null!=o&&(l.get(String(o))||("string"==typeof o||"number"==typeof o)&&(e[t].push({original:o,formatted:n&&"number"==typeof o?(0,p.formatValue)(o,n):o}),l.set(String(o),!0)))}}return e},[z,R,T]),D=(0,f.useMemo)(()=>{let e={};for(let t of R){let n=1/0,l=-1/0;for(let e of z){let i=J(e[t]);void 0!==i&&(n=Math.min(n,i),l=Math.max(l,i))}n!==1/0&&l!==-1/0&&(e[t]={min:n,max:l})}return e},[z,R]),V=(0,f.useMemo)(()=>{let e=[],t=new Set;for(let n of o.columnSettings??[]){if(t.has(n.name))continue;let l=ee(n.name,o.columnSettings??[],d,D,o.cellSettings??[],o.enableSorting??!1);void 0!==l&&(e.push(l),t.add(n.name))}if(!o.defaultColumnHidden){for(let n of R)if(!t.has(n)){let t=ee(n,o.columnSettings??[],d,D,o.cellSettings??[],o.enableSorting??!1);void 0!==t&&e.push(t)}}return e},[R,o.columnSettings,o.defaultColumnHidden,o.enableSorting,d,D,o.cellSettings]),[I,L]=(0,f.useState)([]),F=(0,f.useMemo)(()=>o.enableFiltering&&0!==I.length?z.filter(e=>I.every(t=>{let n=e[t.id],l=t.value;return!l||0===l.length||l.includes(n)})):z,[z,I,o.enableFiltering]),$=(0,f.useMemo)(()=>{var e,t,n;if(void 0===o.cellSettings&&!(null==(e=o.columnSettings)?void 0:e.some(e=>void 0!==e.cellSettings)))return{};let l={},i=0;for(let e of F){for(let[r,a]of Object.entries({...R.reduce((e,t)=>(e[t]=void 0,e),{}),...e})){let e=b(a,o.cellSettings??[]),s=null==(t=o.columnSettings)?void 0:t.find(e=>e.name===r);if(null==s||null==(n=s.cellSettings)?void 0:n.length){let t=b(a,s.cellSettings);t&&(e=t)}e&&(l[`${i}_${r}`]=e)}i++}return l},[F,R,o.cellSettings,o.columnSettings]),[_,P]=(0,f.useState)((null==(n=o.columnSettings)?void 0:n.filter(e=>void 0!==e.sort).map(e=>({id:e.name,desc:"desc"===e.sort})))??[]),[W,K]=(0,f.useState)({}),[Q,Z]=(0,f.useState)(null),X=()=>{K({}),Z(null)};(0,f.useEffect)(()=>{if(!Q)return;let e=e=>{let t=e.target;t.closest("[data-filter-dropdown]")||t.closest("button")||X()},t=setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[Q]),y.current=F;let[et,en]=(0,f.useState)(o.pagination?{pageIndex:0,pageSize:10}:void 0);return((0,f.useEffect)(()=>{o.pagination&&!et?en({pageIndex:0,pageSize:10}):!o.pagination&&et&&en(void 0)},[o.pagination,et]),(0,f.useEffect)(()=>{var e;if(!o.enableFiltering)return;let t=null==(e=A.current)?void 0:e.querySelector(".MuiTableContainer-root"),n=S.current;if(!t||!n)return;let l=()=>{n.style.transform=`translateX(-${t.scrollLeft}px)`,Z(e=>null===e?e:null),K(e=>0===Object.keys(e).length?e:{})};return l(),t.addEventListener("scroll",l,{passive:!0}),()=>{t.removeEventListener("scroll",l)}},[o.enableFiltering,V,i]),(0,f.useEffect)(()=>{var e;if(!o.enableFiltering)return;let t=null==(e=A.current)?void 0:e.querySelector(".MuiTableContainer-root");if(!t)return;let n=t.querySelector("thead tr");if(!n)return;let l=()=>{let e=t.querySelectorAll("thead tr th");V.forEach((t,n)=>{let l=e[n],i=w.current[n];if(!l||!i)return;let o=`${l.getBoundingClientRect().width}px`;i.style.width=o,i.style.minWidth=o,i.style.maxWidth=o})};l();let i=new ResizeObserver(l);return n&&i.observe(n),()=>{i.disconnect()}},[o.enableFiltering,V,i,u,C]),void 0===i)?null:(null==z?void 0:z.length)?(0,l.jsxs)("div",{ref:A,style:{display:"contents"},children:[j,o.enableFiltering&&(0,l.jsx)("div",{style:{overflow:"hidden",background:a.palette.background.default,borderBottom:`1px solid ${a.palette.divider}`,width:i.width,boxSizing:"border-box"},children:(0,l.jsx)("div",{ref:S,style:{display:"flex",width:"max-content",willChange:"transform"},children:V.map((e,t)=>{var n;let i,r=(n=e.accessorKey,(i=I.find(e=>e.id===n))?i.value:[]),s=e.width||o.defaultColumnWidth,d=W[e.accessorKey];return(0,l.jsxs)("div",{ref:e=>{w.current[t]=e},style:{padding:"8px",borderRight:t<V.length-1?`1px solid ${a.palette.divider}`:"none",width:s,minWidth:s,maxWidth:s,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",flex:"none"},children:[(0,l.jsx)("span",{style:{marginRight:8,fontSize:"12px",color:a.palette.text.secondary,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.length?`${r.length} items`:"All"}),(0,l.jsx)("button",{onClick:t=>{var n;n=e.accessorKey,(t.preventDefault(),t.stopPropagation(),Q===n)?X():(K({...W,[n]:t.currentTarget}),Z(n))},style:{border:`1px solid ${a.palette.divider}`,background:a.palette.background.paper,cursor:"pointer",fontSize:"12px",color:r.length?a.palette.primary.main:a.palette.text.secondary,padding:"4px 8px",borderRadius:"4px",minWidth:"20px",height:"24px",flexShrink:0,transition:"all 0.2s ease"},onMouseEnter:e=>{e.currentTarget.style.background=a.palette.action.hover},onMouseLeave:e=>{e.currentTarget.style.background=a.palette.background.paper},type:"button",children:"▼"}),Q===e.accessorKey&&d&&(0,U.createPortal)((0,l.jsx)("div",{style:{position:"fixed",top:d.getBoundingClientRect().bottom+4,left:d.getBoundingClientRect().left,zIndex:a.zIndex.modal},children:(0,l.jsx)(Y,{allValues:N[e.accessorKey]||[],selectedValues:r,onFilterChange:t=>{var n;let l;return n=e.accessorKey,l=I.filter(e=>e.id!==n),void(t.length>0&&l.push({id:n,value:t}),L(l))},theme:a})}),document.body)]},`column-${e.accessorKey}`)})})}),(0,l.jsx)(p.Table,{data:F,columns:V,cellConfigs:$,height:o.enableFiltering?i.height-40:i.height,width:i.width,density:o.density,defaultColumnWidth:o.defaultColumnWidth,defaultColumnHeight:o.defaultColumnHeight,sorting:_,onSortingChange:P,pagination:et,onPaginationChange:en,checkboxSelection:u,rowSelection:E,onRowSelectionChange:O,getItemActions:e=>{let{id:t,data:n}=e;return v({id:t,data:n})},hasItemActions:C&&C.length>0})]}):(0,l.jsx)(G.A,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,l.jsx)(s.A,{children:"No data"})})},supportedQueryTypes:["TimeSeriesQuery"],queryOptions:function(e){return{mode:K(e)}},panelOptionsEditorComponents:[{label:"General Settings",content:function(e){let{onChange:t,value:n}=e;return(0,l.jsx)(p.OptionsEditorGrid,{children:(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsxs)(p.OptionsEditorGroup,{title:"Display",children:[(0,l.jsx)(p.DensitySelector,{value:n.density,onChange:function(e){t({...n,density:e})}}),(0,l.jsx)(p.OptionsEditorControl,{label:"Pagination",control:(0,l.jsx)(A.A,{checked:!!n.pagination,onChange:function(e,l){t({...n,pagination:l})}})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Columns Hidden by Default",control:(0,l.jsx)(A.A,{checked:!!n.defaultColumnHidden,onChange:function(e,l){t({...n,defaultColumnHidden:l})}})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Enable Column Filtering",control:(0,l.jsx)(A.A,{checked:!!n.enableFiltering,onChange:function(e,l){t({...n,enableFiltering:l})}})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Enable Sorting",control:(0,l.jsx)(A.A,{checked:!!n.enableSorting,onChange:function(e,l){var i;t({...n,enableSorting:l,columnSettings:null==(i=n.columnSettings)?void 0:i.map(e=>{let{enableSorting:t,...n}=e;return n})})}})}),(0,l.jsx)(et,{label:"Width",defaultValue:p.DEFAULT_COLUMN_WIDTH,value:n.defaultColumnWidth,onChange:function(e){t({...n,defaultColumnWidth:e})}}),(0,l.jsx)(et,{label:"Height",defaultValue:p.DEFAULT_COLUMN_HEIGHT,value:n.defaultColumnHeight,onChange:function(e){t({...n,defaultColumnHeight:e})}})]})})})}},{label:"Column Settings",content:function(e){let{onChange:t,value:n}=e;return(0,l.jsx)(_,{columnSettings:n.columnSettings??[],onChange:function(e){t({...n,columnSettings:e})},defaultEnableSorting:n.enableSorting})}},{label:"Cell Settings",content:function(e){let{onChange:t,value:n}=e;return(0,l.jsx)(y,{cellSettings:n.cellSettings??[],onChange:function(e){t({...n,cellSettings:e})}})}},{label:"Transforms",content:function(e){let{value:t,onChange:n}=e;return(0,l.jsx)(p.TransformsEditor,{value:t.transforms??[],onChange:function(e){n({...t,transforms:e})}})}},{label:"Item Actions",content:function(e){let{value:t,onChange:n}=e;return(0,l.jsx)(k.ItemSelectionActionsEditor,{actionOptions:t.actions,onChangeActions:function(e){n({...t,actions:e})},selectionOptions:t.selection,onChangeSelection:function(e){n({...t,selection:e})}})}}],createInitialOptions:function(){return{density:"standard",enableFiltering:!0}},actions:[{component:e=>{let{queryResults:t,spec:n,definition:i}=e,o=(0,f.useMemo)(()=>(function(e,t){let n=q(e,t,{forExport:!0}),l=(0,p.transformData)(n,t.transforms??[]),i=[];for(let e of l)for(let t of Object.keys(e))i.includes(t)||i.push(t);let o=t.columnSettings??[],r=[],a=new Set;for(let e of o)!a.has(e.name)&&(a.add(e.name),e.hide||r.push({key:e.name,header:e.header??e.name}));if(!t.defaultColumnHidden)for(let e of i)a.has(e)||r.push({key:e,header:e});return{data:l,columns:r}})(t,n),[t,n]),r=o.data.length>0&&o.columns.length>0,a=(0,f.useCallback)(()=>{if(r)try{var e,t;let n=(null==i||null==(t=i.spec)||null==(e=t.display)?void 0:e.name)||"Table Data",{data:l,columns:r}=o,a=r.map(e=>(0,k.escapeCsvValue)(e.header)).join(","),s=l.map(e=>r.map(t=>(0,k.escapeCsvValue)(e[t.key])).join(",")),d=[a,...s].join("\n")+"\n",u=new Blob([d],{type:"text/csv;charset=utf-8"}),c=(0,k.sanitizeFilename)(n),h=`${c}_data.csv`,p=URL.createObjectURL(u);try{let e=document.createElement("a");e.href=p,e.download=h,document.body.appendChild(e),e.click(),document.body.removeChild(e)}finally{URL.revokeObjectURL(p)}}catch(e){console.error("Table CSV export failed:",e)}},[r,o,i]);return r?(0,l.jsx)(p.InfoTooltip,{description:"Export as CSV",children:(0,l.jsx)(d.A,{size:"small",onClick:a,"aria-label":"Export table data as CSV",children:(0,l.jsx)(en.default,{fontSize:"inherit"})})}):null},location:"header"}]}}}]);
|
|
1
|
+
"use strict";(self.chunk_Table_0_14_0_beta_3=self.chunk_Table_0_14_0_beta_3||[]).push([["2669"],{54042(e,t,n){var l;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((l=n(1448))&&l.__esModule?l:{default:l}).default)("M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z","Download")},42524(e,t,n){var l;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((l=n(1448))&&l.__esModule?l:{default:l}).default)("M19,13H5V11H19V13Z","Minus")},38019(e,t,n){n.r(t),n.d(t,{Table:()=>el});var l=n(62540),i=n(54381),o=n(315),r=n(93648),a=n(97653),s=n(88091),d=n(47095),u=n(65211),c=n(6227),h=n(7013),p=n(32794),g=n(86067),x=n(86742),f=n(70451),m=n.n(f);function v(e){let t=e.trim();if(""===t)return;let n=Number(t);return Number.isNaN(n)?void 0:n}function b(e,t){for(let l of t)if(function(e,t){var n,l,i,o,r,a,s;switch(e.kind){case"Value":return(null==(n=e.spec)?void 0:n.value)===String(t);case"Range":{if(Number.isNaN(Number(t)))return!1;let n=Number(t);if((null==(l=e.spec)?void 0:l.min)!==void 0&&(null==(i=e.spec)?void 0:i.max)!==void 0)return n>=+e.spec.min&&n<=+e.spec.max;if((null==(o=e.spec)?void 0:o.min)!==void 0)return n>=+e.spec.min;if((null==(r=e.spec)?void 0:r.max)!==void 0)return n<=+e.spec.max;return!1}case"Regex":if(!(null==(a=e.spec)?void 0:a.expr))return!1;try{return new RegExp(e.spec.expr).test(String(t))}catch{return!1}case"Misc":switch(null==(s=e.spec)?void 0:s.value){case"empty":return""===t;case"null":return null==t;case"NaN":return Number.isNaN(t);case"true":return!0===t;case"false":return!1===t;default:return!1}default:return!1}}(l.condition,e)){let t;if("Misc"===l.condition.kind){var n;switch(null==(n=l.condition.spec)?void 0:n.value){case"null":t="null";break;case"NaN":t="NaN"}}return function(e,t,n){let l=t.text||n||String(e);return{text:`${t.prefix??""}${l}${t.suffix??""}`,textColor:t.textColor,backgroundColor:t.backgroundColor}}(e,l,t)}}function j(e){let{cell:t,onChange:n,onDelete:c,...h}=e;return(0,l.jsxs)(i.A,{container:!0,spacing:2,...h,children:[(0,l.jsx)(i.A,{size:{xs:5},children:(0,l.jsxs)(o.A,{direction:"row",gap:1,width:"100%",children:[(0,l.jsxs)(r.A,{select:!0,label:"Type",value:t.condition.kind,onChange:e=>n({...t,condition:{kind:e.target.value}}),required:!0,sx:{width:"120px"},children:[(0,l.jsx)(a.A,{value:"Value",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Value"}),"Value"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches an exact text value"})]})}),(0,l.jsx)(a.A,{value:"Range",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Range"}),"Range"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches against a numerical range"})]})}),(0,l.jsx)(a.A,{value:"Regex",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Regex"}),"Regex"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches against a regular expression"})]})}),(0,l.jsx)(a.A,{value:"Misc",children:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(s.A,{children:"Misc"}),"Misc"!==t.condition.kind&&(0,l.jsx)(s.A,{variant:"caption",children:"Matches against empty, null and NaN values"})]})})]}),function(e,t){var n,l,i,d,u;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"small";return"Value"===e.kind?m().createElement(r.A,{label:"Value",placeholder:"Exact value",value:(null==(n=e.spec)?void 0:n.value)??"",onChange:n=>t({...e,spec:{value:n.target.value}}),fullWidth:!0,size:c}):"Range"===e.kind?m().createElement(o.A,{gap:1,direction:"row"},[m().createElement(r.A,{key:"min",label:"From",placeholder:"Start of range",value:(null==(l=e.spec)?void 0:l.min)??"",onChange:n=>{let l=v(n.target.value);t({...e,spec:{...e.spec,min:l}})},type:"number",slotProps:{htmlInput:{step:"any"}},fullWidth:!0,size:c}),m().createElement(r.A,{key:"max",label:"To",placeholder:"End of range (inclusive)",value:(null==(i=e.spec)?void 0:i.max)??"",onChange:n=>{let l=v(n.target.value);t({...e,spec:{...e.spec,max:l}})},type:"number",slotProps:{htmlInput:{step:"any"}},fullWidth:!0,size:c})]):"Regex"===e.kind?m().createElement(r.A,{label:"Regular Expression",placeholder:"JavaScript regular expression",value:(null==(d=e.spec)?void 0:d.expr)??"",onChange:n=>t({...e,spec:{expr:n.target.value}}),fullWidth:!0,size:c}):"Misc"===e.kind?m().createElement(r.A,{select:!0,label:"Value",value:(null==(u=e.spec)?void 0:u.value)??"",onChange:n=>t({...e,spec:{value:n.target.value}}),fullWidth:!0,size:c},[{value:"empty",label:"Empty",caption:"Matches empty string"},{value:"null",label:"Null",caption:"Matches null or undefined"},{value:"NaN",label:"NaN",caption:"Matches Not a Number value"},{value:"true",label:"True",caption:"Matches true boolean"},{value:"false",label:"False",caption:"Matches false boolean"}].map(e=>m().createElement(a.A,{key:e.value,value:e.value},m().createElement(o.A,{key:"stack"},[m().createElement(s.A,{key:"title"},e.label),m().createElement(s.A,{key:"caption",variant:"caption"},e.caption)])))):null}(t.condition,e=>n({...t,condition:e}),"small")]})}),(0,l.jsx)(i.A,{size:{xs:4},children:(0,l.jsxs)(o.A,{spacing:1,children:[(0,l.jsx)(r.A,{label:"Display text",value:t.text,onChange:e=>n({...t,text:e.target.value}),fullWidth:!0,size:"small"}),(0,l.jsxs)(o.A,{direction:"row",spacing:1,children:[(0,l.jsx)(r.A,{label:"Prefix",placeholder:"$",value:t.prefix??"",onChange:e=>n({...t,prefix:e.target.value}),size:"small"}),(0,l.jsx)(r.A,{label:"Suffix",placeholder:"%",value:t.suffix??"",onChange:e=>n({...t,suffix:e.target.value}),size:"small"})]})]})}),(0,l.jsx)(i.A,{size:{xs:1},children:(0,l.jsx)(o.A,{direction:"row",justifyContent:"center",gap:1,children:t.textColor?(0,l.jsx)(p.OptionsColorPicker,{label:"Text Color",color:t.textColor??"#000",onColorChange:e=>n({...t,textColor:e}),onClear:()=>n({...t,textColor:void 0})}):(0,l.jsx)(d.A,{onClick:()=>n({...t,textColor:"#000"}),children:(0,l.jsx)(x.default,{})})})}),(0,l.jsx)(i.A,{size:{xs:1},children:(0,l.jsx)(o.A,{direction:"row",justifyContent:"center",children:t.backgroundColor?(0,l.jsx)(p.OptionsColorPicker,{label:"Background Color",color:t.backgroundColor??"#fff",onColorChange:e=>n({...t,backgroundColor:e}),onClear:()=>n({...t,backgroundColor:void 0})}):(0,l.jsx)(d.A,{onClick:()=>n({...t,backgroundColor:"#000"}),children:(0,l.jsx)(x.default,{})})})}),(0,l.jsx)(i.A,{size:{xs:1},textAlign:"end",children:(0,l.jsx)(u.A,{title:"Remove cell settings",placement:"top",children:(0,l.jsx)(d.A,{size:"small",sx:{marginLeft:"auto"},onClick:c,children:(0,l.jsx)(g.default,{})},"delete-cell-button")})})]})}function C(e){let{cellSettings:t=[],onChange:n,addButtonText:r="Add Conditional Format"}=e;return(0,l.jsxs)(o.A,{spacing:3,sx:{mt:2},children:[(0,l.jsxs)(i.A,{container:!0,spacing:3,children:[(0,l.jsx)(i.A,{size:{xs:5},children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Condition"})}),(0,l.jsx)(i.A,{size:{xs:4},children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Display Text"})}),(0,l.jsx)(i.A,{size:{xs:1},textAlign:"center",children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Color"})}),(0,l.jsx)(i.A,{size:{xs:1},textAlign:"center",children:(0,l.jsx)(s.A,{variant:"subtitle1",children:"Background"})}),(0,l.jsx)(i.A,{size:{xs:1}})]}),(0,l.jsx)(o.A,{gap:1.5,divider:(0,l.jsx)(c.A,{flexItem:!0,orientation:"horizontal"}),children:t.map((e,i)=>(0,l.jsx)(j,{cell:e,onChange:e=>{let l;(l=[...t])[i]=e,n(l)},onDelete:()=>{let e;(e=[...t]).splice(i,1),n(e.length>0?e:void 0)}},i))}),(0,l.jsx)(h.A,{variant:"outlined",startIcon:(0,l.jsx)(x.default,{}),sx:{marginTop:1},onClick:()=>{let e=[...t];e.push({condition:{kind:"Value",spec:{value:""}}}),n(e)},children:r})]})}function y(e){let{cellSettings:t,onChange:n}=e;return(0,l.jsx)(C,{cellSettings:t,onChange:e=>n(e||[])})}var A=n(68003),S=n(12138),k=n(23724),w=n(42524);let E=e=>{let{onChange:t,column:n,column:{dataLink:i}}=e;if(!i)return(0,l.jsxs)(o.A,{sx:{width:"100%",alignItems:"center"},direction:"row",children:[(0,l.jsx)(s.A,{flex:1,variant:"subtitle1",mb:2,fontStyle:"italic",children:"No link defined"}),(0,l.jsx)(d.A,{style:{width:"fit-content",height:"fit-content"},onClick:()=>t({...n,dataLink:{url:"",openNewTab:!0,title:""}}),children:(0,l.jsx)(x.default,{})})]});let{url:r,openNewTab:a,title:u}=i;return(0,l.jsxs)(o.A,{sx:{width:"100%",alignItems:"center"},direction:"row",children:[(0,l.jsx)(p.LinkEditorForm,{mode:"inline",url:{label:"Url",onChange:e=>{t({...n,dataLink:{...i,url:e}})},value:r,placeholder:"URL",error:{hasError:!1,helperText:""}},name:{label:"Name",onChange:e=>{t({...n,dataLink:{...i,title:e}})},value:u??"",placeholder:"Name"},newTabOpen:{label:"Open in new tab",onChange:e=>{t({...n,dataLink:{...i,openNewTab:e}})},value:a}}),(0,l.jsx)(d.A,{style:{width:"fit-content",height:"fit-content"},onClick:()=>{t({...n,dataLink:void 0})},children:(0,l.jsx)(w.default,{})})]})};var O=n(25742),M=n(25632),z=n.n(M);function R(e,t){let n=e.createInitialOptions()??{};return z()({},n,t??{})}function T(e){let{kind:t,spec:n,onChange:i}=e,{data:r,isLoading:a,isError:d,error:u}=(0,k.usePlugin)("Panel",t),c=(0,f.useMemo)(()=>r?R(r,n):n,[r,n]),h=(0,f.useRef)(i);if(h.current=i,(0,f.useEffect)(()=>{r&&(null==n||"object"==typeof n&&0===Object.keys(n).length)&&h.current(R(r,n))},[r,t,n]),a)return(0,l.jsxs)(o.A,{direction:"row",alignItems:"center",spacing:1,sx:{py:1},children:[(0,l.jsx)(O.A,{size:22}),(0,l.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"Loading panel settings…"})]});if(d||!r)return(0,l.jsx)(s.A,{variant:"body2",color:"error",children:(null==u?void 0:u.message)??"Could not load panel plugin."});let p=r.panelOptionsEditorComponents??[];return 0===p.length?(0,l.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"This visualization has no editable settings."}):(0,l.jsx)(o.A,{spacing:2.5,sx:{width:"100%",py:1},children:(0,l.jsx)(k.OptionsEditorTabs,{tabs:p.map(e=>{let t=e.content;return{label:e.label,content:(0,l.jsx)(t,{value:c,onChange:e=>{i(e)}})}})})})}let N={unit:"decimal",shortValues:!0};function D(e){var t,n;let{column:i,onChange:a,defaultEnableSorting:d=!1,...u}=e,[c,g]=(0,f.useState)(void 0===i.width||"auto"===i.width?100:i.width),x=i.enableSorting??d;return(0,l.jsxs)(o.A,{...u,children:[(0,l.jsxs)(p.OptionsEditorGrid,{children:[(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsxs)(p.OptionsEditorGroup,{title:"Column",children:[(0,l.jsx)(p.OptionsEditorControl,{label:"Name*",control:(0,l.jsx)(r.A,{value:i.name,onChange:e=>a({...i,name:e.target.value}),required:!0})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Header",control:(0,l.jsx)(r.A,{value:i.header??"",onChange:e=>a({...i,header:e.target.value?e.target.value:void 0})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Header Tooltip",control:(0,l.jsx)(r.A,{value:i.headerDescription??"",onChange:e=>a({...i,headerDescription:e.target.value?e.target.value:void 0})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Cell Tooltip",control:(0,l.jsx)(r.A,{value:i.cellDescription??"",onChange:e=>a({...i,cellDescription:e.target.value?e.target.value:void 0})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Enable sorting",control:(0,l.jsx)(A.A,{checked:x,onChange:e=>(function(e){if(e===d){let{enableSorting:e,...t}=i;a(t);return}a({...i,enableSorting:e})})(e.target.checked)})}),void 0===i.enableSorting&&(0,l.jsx)(s.A,{variant:"caption",color:"text.secondary",children:"Inherits from General Settings"}),x&&(0,l.jsx)(p.OptionsEditorControl,{label:"Default Sort",control:(0,l.jsx)(p.SortSelectorButtons,{size:"medium",value:i.sort,sx:{margin:.5},onChange:e=>a({...i,sort:e})})})]})}),(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsxs)(p.OptionsEditorGroup,{title:"Visual",children:[(0,l.jsx)(p.OptionsEditorControl,{label:"Show column",control:(0,l.jsx)(A.A,{checked:!i.hide,onChange:e=>a({...i,hide:!e.target.checked})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Cell display",control:(0,l.jsxs)(o.A,{spacing:1,children:[(0,l.jsxs)(S.A,{"aria-label":"Cell display",size:"small",children:[(0,l.jsx)(h.A,{variant:i.plugin?"outlined":"contained",onClick:()=>a({...i,plugin:void 0}),children:"Text"}),(0,l.jsx)(h.A,{variant:i.plugin?"contained":"outlined",onClick:()=>a({...i,plugin:{kind:"GaugeChart",spec:{}}}),children:"Visualization"})]}),(0,l.jsx)(s.A,{variant:"caption",color:"text.secondary",sx:{maxWidth:360},children:"Visualizations reuse panel settings (thresholds, units, colors). Text mode uses value formatting below."})]})}),i.plugin?(0,l.jsx)(p.OptionsEditorControl,{label:"Visualization type",control:(0,l.jsx)(k.PluginKindSelect,{pluginTypes:["Panel"],size:"small",value:{type:"Panel",kind:i.plugin.kind},onChange:e=>a({...i,plugin:{kind:e.kind,spec:{}}})})}):(0,l.jsx)(p.FormatControls,{value:i.format??N,onChange:e=>a({...i,format:e})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Alignment",control:(0,l.jsx)(p.AlignSelector,{size:"small",value:i.align??"left",onChange:e=>a({...i,align:e})})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Custom width",control:(0,l.jsx)(A.A,{checked:void 0!==i.width&&"auto"!==i.width,onChange:e=>a({...i,width:e.target.checked?c:"auto"})})}),void 0!==i.width&&"auto"!==i.width&&(0,l.jsx)(p.OptionsEditorControl,{label:"Width",control:(0,l.jsx)(r.A,{type:"number",value:c,slotProps:{htmlInput:{min:1}},onChange:e=>{g(+e.target.value),a({...i,width:+e.target.value})}})})]})}),(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsx)(p.OptionsEditorGroup,{title:"Link",children:(0,l.jsx)(E,{column:i,onChange:a})})})]}),(null==(t=i.plugin)?void 0:t.kind)==="GaugeChart"&&(0,l.jsx)(o.A,{sx:{px:8,mt:4,width:"100%"},spacing:2,children:(0,l.jsx)(p.OptionsEditorGroup,{title:"Visualization settings",children:(0,l.jsx)(T,{kind:"GaugeChart",spec:i.plugin.spec,onChange:e=>a({...i,plugin:{kind:"GaugeChart",spec:e}})})})}),(0,l.jsx)(o.A,{sx:{px:8,mt:3*((null==(n=i.plugin)?void 0:n.kind)==="GaugeChart")},children:(0,l.jsx)(p.OptionsEditorGroup,{title:"Conditional Cell Format",children:(0,l.jsx)(C,{cellSettings:i.cellSettings,onChange:e=>a({...i,cellSettings:e})})})})]})}var V=n(87275),I=n(11061),L=n(78536),F=n(1355);function $(e){let{column:t,isCollapsed:n,onChange:i,onCollapse:r,onDelete:a,onMoveUp:h,onMoveDown:x,defaultEnableSorting:f}=e;return(0,l.jsxs)(p.DragAndDropElement,{data:t,children:[(0,l.jsxs)(o.A,{direction:"row",alignItems:"center",borderBottom:1,borderColor:e=>e.palette.divider,justifyContent:"space-between",gap:4,children:[(0,l.jsxs)(o.A,{direction:"row",gap:1,children:[(0,l.jsx)(d.A,{"data-testid":`column-toggle#${t.name}`,size:"small",onClick:()=>r(!n),children:n?(0,l.jsx)(I.default,{}):(0,l.jsx)(V.default,{})}),(0,l.jsxs)(s.A,{variant:"overline",component:"h4",sx:{textTransform:"none"},children:["COLUMN:"," ",t.header?(0,l.jsxs)("span",{children:[(0,l.jsx)("strong",{children:t.header})," (",t.name,")"]}):(0,l.jsx)("strong",{children:t.name})]})]}),(0,l.jsxs)(o.A,{direction:"row",gap:1,children:[n&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(u.A,{title:t.hide?"Show column":"Hide column",placement:"top",children:(0,l.jsx)(d.A,{size:"small",sx:{marginLeft:"auto"},onClick:function(){i({...t,hide:!t.hide})},children:t.hide?(0,l.jsx)(L.default,{}):(0,l.jsx)(F.default,{})},"hide-column")}),(0,l.jsx)(c.A,{flexItem:!0,orientation:"vertical",variant:"middle"})]}),(0,l.jsx)(u.A,{title:"Remove column settings",placement:"top",children:(0,l.jsx)(d.A,{size:"small",sx:{marginLeft:"auto"},onClick:a,children:(0,l.jsx)(g.default,{})},"delete-column-button")}),(0,l.jsx)(u.A,{title:"Reorder column settings",placement:"top",children:(0,l.jsx)(p.DragButton,{onMoveUp:h,onMoveDown:x,menuSx:{".MuiPaper-root":{backgroundColor:e=>e.palette.background.lighter}}},"reorder-column-button")})]})]}),!n&&(0,l.jsx)("div",{children:(0,l.jsx)(D,{column:t,onChange:i,defaultEnableSorting:f})})]})}function _(e){let{columnSettings:t,onChange:n,defaultEnableSorting:i}=e,[r,a]=(0,f.useState)(t.map(()=>!0));return(0,p.useDragAndDropMonitor)({elements:t,accessKey:"name",onChange:n}),(0,l.jsxs)(o.A,{spacing:1,children:[t.map((e,o)=>(0,l.jsx)($,{column:e,isCollapsed:r[o]??!0,defaultEnableSorting:i,onChange:e=>{let l;(l=[...t])[o]=e,n(l)},onDelete:()=>{let e;(e=[...t]).splice(o,1),n(e),a(e=>(e.splice(o,1),[...e]))},onCollapse:e=>{a(t=>(t[o]=e,[...t]))},onMoveUp:()=>n((0,p.handleMoveUp)(e,t)),onMoveDown:()=>n((0,p.handleMoveDown)(e,t))},o)),(0,l.jsx)(h.A,{variant:"contained",startIcon:(0,l.jsx)(x.default,{}),sx:{marginTop:1},onClick:function(){let e=`column_${Object.keys(t).length}`,l=[...t];l.push({name:e}),n(l),a(e=>(e.push(!1),[...e]))},children:"Add Column Settings"})]})}var H=n(46244),P=n(85180);function W(e){let{kind:t,spec:n,queryResults:i}=e,{ref:o,width:r=1,height:a=1}=(0,P.default)();return(0,l.jsx)("div",{ref:o,style:{height:"100%"},children:(0,l.jsx)(p.ErrorBoundary,{FallbackComponent:p.ErrorAlert,children:(0,l.jsx)(H.PanelPluginLoader,{kind:t,contentDimensions:{width:r,height:a},spec:n,queryResults:i})})})}var G=n(74628),B=n(56599),U=n(20231);function K(e){return(e.columnSettings??[]).some(e=>e.plugin)?"range":"instant"}function q(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{forExport:l=!1}=n,i=K(t);return e.flatMap((e,t)=>{var n;return((null==(n=e.data)?void 0:n.series)??[]).map(n=>({data:e,ts:n,queryIndex:t}))}).map(n=>{let o,{data:r,ts:a,queryIndex:s}=n,d=a.values[a.values.length-1];if(void 0===d)return{...a.labels};let u=1===e.length?"value":`value #${s+1}`,c=1===e.length?a.labels:Object.entries(a.labels??{}).reduce((e,t)=>{let[n,l]=t;return n&&(e[`${n} #${s+1}`]=l),e},{});if(l)o=d[1];else{var h;o=(null==(h=(t.columnSettings??[]).find(e=>e.name===u))?void 0:h.plugin)?{...r,data:{...r.data,series:r.data.series.filter(e=>e===a)}}:d[1]}return"instant"===i?{timestamp:d[0],[u]:o,...c}:{[u]:o,...c}})}function Q(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=Number(e);if(Number.isFinite(t))return t}}function Z(e){return"object"==typeof e&&null!==e&&void 0!==e.definition&&void 0!==e.data}function J(e){if(Z(e)){var t,n;let l=null==(t=e.data)?void 0:t.series,i=null==l?void 0:l[0];if(!(null==i||null==(n=i.values)?void 0:n.length))return;let o=k.CalculationsMap["last-number"];if("function"!=typeof o)return;let r=o(i.values);return"number"==typeof r?r:void 0}return Q(e)}function X(e){let{value:t,range:n,fillColor:i,format:o}=e;if(void 0===t)return(0,l.jsx)(l.Fragment,{});let r=0;return void 0!==n&&(r=n.max===n.min?100:(t-n.min)/(n.max-n.min)*100),r=Math.max(0,Math.min(100,r)),(0,l.jsxs)(G.A,{sx:{display:"flex",alignItems:"center",width:"100%",gap:1},children:[(0,l.jsx)(G.A,{sx:{flexGrow:1,borderRadius:1,backgroundColor:"rgba(127,127,127,0.20)",height:24,overflow:"hidden"},children:(0,l.jsx)(G.A,{sx:{width:`${r}%`,height:"100%",backgroundColor:i??"success.main",borderRadius:1}})}),(0,l.jsx)(s.A,{variant:"body2",sx:{minWidth:52,textAlign:"right"},children:o?(0,p.formatValue)(t,o):t.toFixed(2)})]})}function Y(e){let{allValues:t,selectedValues:n,onFilterChange:i,theme:o}=e,[r,a]=(0,f.useState)(""),s=[...new Set(t)].filter(e=>null!==e).toSorted(),d=r?s.filter(e=>String(e.formatted).toLowerCase().includes(r.toLowerCase())):s;return 0===s.length?(0,l.jsx)("div",{"data-filter-dropdown":!0,style:{width:200,padding:10,backgroundColor:o.palette.background.paper,border:`1px solid ${o.palette.divider}`,borderRadius:4,boxShadow:o.shadows[4]},children:(0,l.jsx)("div",{style:{color:o.palette.text.secondary,fontSize:14},children:"No values found"})}):(0,l.jsxs)("div",{"data-filter-dropdown":!0,style:{width:200,padding:10,backgroundColor:o.palette.background.paper,border:`1px solid ${o.palette.divider}`,borderRadius:4,boxShadow:o.shadows[4],maxHeight:250,overflowY:"auto"},children:[(0,l.jsx)("input",{type:"text",placeholder:"Search...",value:r,onChange:e=>a(e.target.value),style:{width:"100%",padding:"6px 8px",marginBottom:8,fontSize:13,border:`1px solid ${o.palette.divider}`,borderRadius:4,backgroundColor:o.palette.background.default,color:o.palette.text.primary,boxSizing:"border-box"}}),(0,l.jsx)("div",{style:{marginBottom:8,fontSize:14,fontWeight:"bold"},children:(0,l.jsxs)("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[(0,l.jsx)("input",{type:"checkbox",checked:n.length===s.length&&s.length>0,onChange:e=>i(e.target.checked?s.map(e=>e.original):[]),style:{marginRight:8}}),(0,l.jsxs)("span",{style:{color:o.palette.text.primary},children:["Select All (",s.length,")"]})]})}),(0,l.jsx)("hr",{style:{margin:"8px 0",border:"none",borderTop:`1px solid ${o.palette.divider}`}}),d.map((e,t)=>(0,l.jsx)("div",{style:{marginBottom:4},children:(0,l.jsxs)(G.A,{component:"label",sx:{display:"flex",alignItems:"center",cursor:"pointer",padding:"2px 0",borderRadius:"2px","&:hover":{backgroundColor:o.palette.action.hover}},children:[(0,l.jsx)("input",{type:"checkbox",checked:n.includes(e.original),onChange:t=>{t.target.checked?i([...n,e.original]):i(n.filter(t=>t!==e.original))},style:{marginRight:8}}),(0,l.jsx)("span",{style:{fontSize:14,color:o.palette.text.primary},children:null==e||""===e.formatted?"(empty)":String(e.formatted)})]})},`value-${t}`))]})}function ee(e,t,n,i){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];for(let a of t)if(a.name===e){if(a.hide)return;let{name:e,header:t,headerDescription:s,enableSorting:d,width:u,align:c,dataLink:h}=a;return{accessorKey:e,header:t??e,headerDescription:s,enableSorting:d??r,width:u,align:c,dataLink:h?{...h,url:(0,k.replaceVariablesInString)(h.url,n)}:void 0,...function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=e.plugin;return void 0!==i?{cell:o=>{let r=o.getValue();if("GaugeChart"===i.kind){var a;let o=J(r),s=function(e,t,n){let l=b(e,t);if(null==n?void 0:n.length){let t=b(e,n);t&&(l=t)}return(null==l?void 0:l.backgroundColor)??(null==l?void 0:l.textColor)}(o,n,e.cellSettings);return(0,l.jsx)(X,{value:o,range:t,fillColor:s,format:(null==(a=i.spec)?void 0:a.format)??e.format})}let s=Z(r)?r:function(e,t){let n=Q(e);if(void 0===n)return;let l=Date.now();return{definition:{kind:"TimeSeriesQuery",spec:{plugin:{kind:"PrometheusTimeSeriesQuery",spec:{query:""}}}},data:{timeRange:{start:new Date(l),end:new Date(l)},stepMs:1,series:[{name:t,values:[[l,n]],labels:{}}]}}}(r,e.name);return s?(0,l.jsx)(W,{kind:i.kind,spec:i.spec,queryResults:[s]}):(0,l.jsx)(l.Fragment,{})},cellDescription:e.cellDescription?()=>`${e.cellDescription}`:()=>""}:{cell:t=>{let n=t.getValue();return"number"==typeof n&&e.format?(0,p.formatValue)(n,e.format):n},cellDescription:e.cellDescription?()=>`${e.cellDescription}`:void 0}}(a,i[e],o)}}return{accessorKey:e,header:e,enableSorting:r}}function et(e){let{label:t,defaultValue:n,value:i,onChange:o}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.OptionsEditorControl,{label:`Auto Columns ${t}`,control:(0,l.jsx)(A.A,{checked:void 0===i||"auto"===i,onChange:function(e,t){if(t)return o("auto");o(n)}})}),void 0!==i&&"auto"!==i&&(0,l.jsx)(p.OptionsEditorControl,{label:`Default Columns ${t}`,control:(0,l.jsx)(r.A,{type:"number",value:i??n,slotProps:{input:{inputProps:{min:1,step:1}}},onChange:e=>o(parseInt(e.target.value))})})]})}var en=n(54042);let el={PanelComponent:function(e){var t,n;let{contentDimensions:i,spec:o,queryResults:r}=e,a=(0,B.A)(),d=(0,k.useAllVariableValues)(),u=(null==(t=o.selection)?void 0:t.enabled)??!1,{selectionMap:c,setSelection:h,clearSelection:g}=(0,p.useSelection)(),x=o.actions?o.actions:void 0,m=(null==x?void 0:x.enabled)&&x.displayWithItem?x.actionsList:[],{getItemActionButtons:v,confirmDialog:j,actionButtons:C}=(0,H.useSelectionItemActions)({actions:m,variableState:d}),y=(0,f.useRef)([]),A=(0,f.useRef)(null),S=(0,f.useRef)(null),w=(0,f.useRef)([]),E=(0,f.useMemo)(()=>{let e={};return c.forEach((t,n)=>{e[n]=!0}),e},[c]),O=(0,f.useCallback)(e=>{let t=[];for(let[n,l]of Object.entries(e))if(l){let e=parseInt(n,10);void 0!==y.current[e]&&t.push({id:n,item:y.current[e]})}0===t.length?g():h(t)},[h,g]),M=(0,f.useMemo)(()=>q(r,o),[r,o]),z=(0,f.useMemo)(()=>(0,p.transformData)(M,o.transforms??[]),[M,o.transforms]),R=(0,f.useMemo)(()=>{let e=[];for(let t of z)for(let n of Object.keys(t))e.includes(n)||e.push(n);for(let t of o.columnSettings??[])e.includes(t.name)||e.push(t.name);return e},[z,o.columnSettings]),T=(0,f.useMemo)(()=>{let e={},t=null==o?void 0:o.columnSettings;if(t)for(let n=0;n<t.length;n++){let{name:l,format:i}=t[n]||{};l&&i&&(e[l]=i)}return e},[o]),N=(0,f.useMemo)(()=>{let e={};for(let t of R){let n=null==T?void 0:T[t];e[t]=[];let l=new Map;for(let i of z){let o=i[t];""!==o&&null!=o&&(l.get(String(o))||("string"==typeof o||"number"==typeof o)&&(e[t].push({original:o,formatted:n&&"number"==typeof o?(0,p.formatValue)(o,n):o}),l.set(String(o),!0)))}}return e},[z,R,T]),D=(0,f.useMemo)(()=>{let e={};for(let t of R){let n=1/0,l=-1/0;for(let e of z){let i=J(e[t]);void 0!==i&&(n=Math.min(n,i),l=Math.max(l,i))}n!==1/0&&l!==-1/0&&(e[t]={min:n,max:l})}return e},[z,R]),V=(0,f.useMemo)(()=>{let e=[],t=new Set;for(let n of o.columnSettings??[]){if(t.has(n.name))continue;let l=ee(n.name,o.columnSettings??[],d,D,o.cellSettings??[],o.enableSorting??!1);void 0!==l&&(e.push(l),t.add(n.name))}if(!o.defaultColumnHidden){for(let n of R)if(!t.has(n)){let t=ee(n,o.columnSettings??[],d,D,o.cellSettings??[],o.enableSorting??!1);void 0!==t&&e.push(t)}}return e},[R,o.columnSettings,o.defaultColumnHidden,o.enableSorting,d,D,o.cellSettings]),[I,L]=(0,f.useState)([]),F=(0,f.useMemo)(()=>o.enableFiltering&&0!==I.length?z.filter(e=>I.every(t=>{let n=e[t.id],l=t.value;return!l||0===l.length||l.includes(n)})):z,[z,I,o.enableFiltering]),$=(0,f.useMemo)(()=>{var e,t,n;if(void 0===o.cellSettings&&!(null==(e=o.columnSettings)?void 0:e.some(e=>void 0!==e.cellSettings)))return{};let l={},i=0;for(let e of F){for(let[r,a]of Object.entries({...R.reduce((e,t)=>(e[t]=void 0,e),{}),...e})){let e=b(a,o.cellSettings??[]),s=null==(t=o.columnSettings)?void 0:t.find(e=>e.name===r);if(null==s||null==(n=s.cellSettings)?void 0:n.length){let t=b(a,s.cellSettings);t&&(e=t)}e&&(l[`${i}_${r}`]=e)}i++}return l},[F,R,o.cellSettings,o.columnSettings]),[_,P]=(0,f.useState)((null==(n=o.columnSettings)?void 0:n.filter(e=>void 0!==e.sort).map(e=>({id:e.name,desc:"desc"===e.sort})))??[]),[W,K]=(0,f.useState)({}),[Q,Z]=(0,f.useState)(null),X=()=>{K({}),Z(null)};(0,f.useEffect)(()=>{if(!Q)return;let e=e=>{let t=e.target;t.closest("[data-filter-dropdown]")||t.closest("button")||X()},t=setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[Q]),y.current=F;let[et,en]=(0,f.useState)(o.pagination?{pageIndex:0,pageSize:10}:void 0);return((0,f.useEffect)(()=>{o.pagination&&!et?en({pageIndex:0,pageSize:10}):!o.pagination&&et&&en(void 0)},[o.pagination,et]),(0,f.useEffect)(()=>{var e;if(!o.enableFiltering)return;let t=null==(e=A.current)?void 0:e.querySelector(".MuiTableContainer-root"),n=S.current;if(!t||!n)return;let l=()=>{n.style.transform=`translateX(-${t.scrollLeft}px)`,Z(e=>null===e?e:null),K(e=>0===Object.keys(e).length?e:{})};return l(),t.addEventListener("scroll",l,{passive:!0}),()=>{t.removeEventListener("scroll",l)}},[o.enableFiltering,V,i]),(0,f.useEffect)(()=>{var e;if(!o.enableFiltering)return;let t=null==(e=A.current)?void 0:e.querySelector(".MuiTableContainer-root");if(!t)return;let n=t.querySelector("thead tr");if(!n)return;let l=()=>{let e=t.querySelectorAll("thead tr th");V.forEach((t,n)=>{let l=e[n],i=w.current[n];if(!l||!i)return;let o=`${l.getBoundingClientRect().width}px`;i.style.width=o,i.style.minWidth=o,i.style.maxWidth=o})};l();let i=new ResizeObserver(l);return n&&i.observe(n),()=>{i.disconnect()}},[o.enableFiltering,V,i,u,C]),void 0===i)?null:(null==z?void 0:z.length)?(0,l.jsxs)("div",{ref:A,style:{display:"contents"},children:[j,o.enableFiltering&&(0,l.jsx)("div",{style:{overflow:"hidden",background:a.palette.background.default,borderBottom:`1px solid ${a.palette.divider}`,width:i.width,boxSizing:"border-box"},children:(0,l.jsx)("div",{ref:S,style:{display:"flex",width:"max-content",willChange:"transform"},children:V.map((e,t)=>{var n;let i,r=(n=e.accessorKey,(i=I.find(e=>e.id===n))?i.value:[]),s=e.width||o.defaultColumnWidth,d=W[e.accessorKey];return(0,l.jsxs)("div",{ref:e=>{w.current[t]=e},style:{padding:"8px",borderRight:t<V.length-1?`1px solid ${a.palette.divider}`:"none",width:s,minWidth:s,maxWidth:s,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",flex:"none"},children:[(0,l.jsx)("span",{style:{marginRight:8,fontSize:"12px",color:a.palette.text.secondary,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.length?`${r.length} items`:"All"}),(0,l.jsx)("button",{onClick:t=>{var n;n=e.accessorKey,(t.preventDefault(),t.stopPropagation(),Q===n)?X():(K({...W,[n]:t.currentTarget}),Z(n))},style:{border:`1px solid ${a.palette.divider}`,background:a.palette.background.paper,cursor:"pointer",fontSize:"12px",color:r.length?a.palette.primary.main:a.palette.text.secondary,padding:"4px 8px",borderRadius:"4px",minWidth:"20px",height:"24px",flexShrink:0,transition:"all 0.2s ease"},onMouseEnter:e=>{e.currentTarget.style.background=a.palette.action.hover},onMouseLeave:e=>{e.currentTarget.style.background=a.palette.background.paper},type:"button",children:"▼"}),Q===e.accessorKey&&d&&(0,U.createPortal)((0,l.jsx)("div",{style:{position:"fixed",top:d.getBoundingClientRect().bottom+4,left:d.getBoundingClientRect().left,zIndex:a.zIndex.modal},children:(0,l.jsx)(Y,{allValues:N[e.accessorKey]||[],selectedValues:r,onFilterChange:t=>{var n;let l;return n=e.accessorKey,l=I.filter(e=>e.id!==n),void(t.length>0&&l.push({id:n,value:t}),L(l))},theme:a})}),document.body)]},`column-${e.accessorKey}`)})})}),(0,l.jsx)(p.Table,{data:F,columns:V,cellConfigs:$,height:o.enableFiltering?i.height-40:i.height,width:i.width,density:o.density,defaultColumnWidth:o.defaultColumnWidth,defaultColumnHeight:o.defaultColumnHeight,sorting:_,onSortingChange:P,pagination:et,onPaginationChange:en,checkboxSelection:u,rowSelection:E,onRowSelectionChange:O,getItemActions:e=>{let{id:t,data:n}=e;return v({id:t,data:n})},hasItemActions:C&&C.length>0})]}):(0,l.jsx)(G.A,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,l.jsx)(s.A,{children:"No data"})})},supportedQueryTypes:["TimeSeriesQuery"],queryOptions:function(e){return{mode:K(e)}},panelOptionsEditorComponents:[{label:"General Settings",content:function(e){let{onChange:t,value:n}=e;return(0,l.jsx)(p.OptionsEditorGrid,{children:(0,l.jsx)(p.OptionsEditorColumn,{children:(0,l.jsxs)(p.OptionsEditorGroup,{title:"Display",children:[(0,l.jsx)(p.DensitySelector,{value:n.density,onChange:function(e){t({...n,density:e})}}),(0,l.jsx)(p.OptionsEditorControl,{label:"Pagination",control:(0,l.jsx)(A.A,{checked:!!n.pagination,onChange:function(e,l){t({...n,pagination:l})}})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Columns Hidden by Default",control:(0,l.jsx)(A.A,{checked:!!n.defaultColumnHidden,onChange:function(e,l){t({...n,defaultColumnHidden:l})}})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Enable Column Filtering",control:(0,l.jsx)(A.A,{checked:!!n.enableFiltering,onChange:function(e,l){t({...n,enableFiltering:l})}})}),(0,l.jsx)(p.OptionsEditorControl,{label:"Enable Sorting",control:(0,l.jsx)(A.A,{checked:!!n.enableSorting,onChange:function(e,l){var i;t({...n,enableSorting:l,columnSettings:null==(i=n.columnSettings)?void 0:i.map(e=>{let{enableSorting:t,...n}=e;return n})})}})}),(0,l.jsx)(et,{label:"Width",defaultValue:p.DEFAULT_COLUMN_WIDTH,value:n.defaultColumnWidth,onChange:function(e){t({...n,defaultColumnWidth:e})}}),(0,l.jsx)(et,{label:"Height",defaultValue:p.DEFAULT_COLUMN_HEIGHT,value:n.defaultColumnHeight,onChange:function(e){t({...n,defaultColumnHeight:e})}})]})})})}},{label:"Column Settings",content:function(e){let{onChange:t,value:n}=e;return(0,l.jsx)(_,{columnSettings:n.columnSettings??[],onChange:function(e){t({...n,columnSettings:e})},defaultEnableSorting:n.enableSorting})}},{label:"Cell Settings",content:function(e){let{onChange:t,value:n}=e;return(0,l.jsx)(y,{cellSettings:n.cellSettings??[],onChange:function(e){t({...n,cellSettings:e})}})}},{label:"Transforms",content:function(e){let{value:t,onChange:n}=e;return(0,l.jsx)(p.TransformsEditor,{value:t.transforms??[],onChange:function(e){n({...t,transforms:e})}})}},{label:"Item Actions",content:function(e){let{value:t,onChange:n}=e;return(0,l.jsx)(k.ItemSelectionActionsEditor,{actionOptions:t.actions,onChangeActions:function(e){n({...t,actions:e})},selectionOptions:t.selection,onChangeSelection:function(e){n({...t,selection:e})}})}}],createInitialOptions:function(){return{density:"standard",enableFiltering:!0}},actions:[{component:e=>{let{queryResults:t,spec:n,definition:i}=e,o=(0,f.useMemo)(()=>(function(e,t){let n=q(e,t,{forExport:!0}),l=(0,p.transformData)(n,t.transforms??[]),i=[];for(let e of l)for(let t of Object.keys(e))i.includes(t)||i.push(t);let o=t.columnSettings??[],r=[],a=new Set;for(let e of o)!a.has(e.name)&&(a.add(e.name),e.hide||r.push({key:e.name,header:e.header??e.name}));if(!t.defaultColumnHidden)for(let e of i)a.has(e)||r.push({key:e,header:e});return{data:l,columns:r}})(t,n),[t,n]),r=o.data.length>0&&o.columns.length>0,a=(0,f.useCallback)(()=>{if(r)try{var e,t;let n=(null==i||null==(t=i.spec)||null==(e=t.display)?void 0:e.name)||"Table Data",{data:l,columns:r}=o,a=r.map(e=>(0,k.escapeCsvValue)(e.header)).join(","),s=l.map(e=>r.map(t=>(0,k.escapeCsvValue)(e[t.key])).join(",")),d=[a,...s].join("\n")+"\n",u=new Blob([d],{type:"text/csv;charset=utf-8"}),c=(0,k.sanitizeFilename)(n),h=`${c}_data.csv`,p=URL.createObjectURL(u);try{let e=document.createElement("a");e.href=p,e.download=h,document.body.appendChild(e),e.click(),document.body.removeChild(e)}finally{URL.revokeObjectURL(p)}}catch(e){console.error("Table CSV export failed:",e)}},[r,o,i]);return r?(0,l.jsx)(p.InfoTooltip,{description:"Export as CSV",children:(0,l.jsx)(d.A,{size:"small",onClick:a,"aria-label":"Export table data as CSV",children:(0,l.jsx)(en.default,{fontSize:"inherit"})})}):null},location:"header"}]}}}]);
|