@vuu-ui/vuu-table-extras 0.8.9 → 0.8.10-debug

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/esm/index.js CHANGED
@@ -1,2 +1,4217 @@
1
- var Et=(t,e,o)=>{if(!e.has(t))throw TypeError("Cannot "+o)};var C=(t,e,o)=>(Et(t,e,"read from private field"),o?o.call(t):e.get(t)),P=(t,e,o)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,o)},F=(t,e,o,n)=>(Et(t,e,"write to private field"),n?n.call(t,o):e.set(t,o),o);import{registerComponent as Go}from"@vuu-ui/vuu-utils";var Uo=t=>typeof t=="string",Xo=(t,e)=>Uo(e)?e===""?!0:t.value==="lower"&&e.toLowerCase()!==e?"value must be all lowercase":t.value==="upper"&&e.toUpperCase()!==e?"value must be all uppercase":!0:"value must be a string";Go("vuu-case",Xo,"data-edit-validator",{});import{registerComponent as _o}from"@vuu-ui/vuu-utils";var Yo=t=>typeof t=="string",Jo="value does not match expected pattern",Zo=(t,e)=>{if(typeof t.value!="string")throw Error("Pattern validation rule must provide pattern");if(Yo(e)){if(e==="")return!0;{let{message:o=Jo}=t;return new RegExp(t.value).test(e)||o}}else return"value must be a string"};_o("vuu-pattern",Zo,"data-edit-validator",{});import{DOWN1 as nn,DOWN2 as rn,isTypeDescriptor as sn,metadataKeys as ln,registerComponent as an,UP1 as un,UP2 as cn}from"@vuu-ui/vuu-utils";import mn from"classnames";import{getMovingValueDirection as qo,isTypeDescriptor as jo,isValidNumber as wt}from"@vuu-ui/vuu-utils";import{useEffect as en,useRef as tn}from"react";var on=[void 0,void 0,void 0,void 0];function Dt(t,e,o){var d;let n=tn(),[r,s,i,l]=n.current||on,{type:u}=o,c=jo(u)?(d=u.formatting)==null?void 0:d.decimals:void 0,m=t===r&&wt(e)&&wt(s)&&o===i?qo(e,l,s,c):"";return en(()=>{n.current=[t,e,o,m]}),m}import{jsx as bn,jsxs as hn}from"react/jsx-runtime";var pn=String.fromCharCode(11014),dn=String.fromCharCode(11015),{KEY:fn}=ln,Te="vuuBackgroundCellDeprecated",ie={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},gn=t=>sn(t)&&t.renderer&&"flashStyle"in t.renderer?t.renderer.flashStyle:ie.BackgroundOnly,Cn=({column:t,row:e})=>{let{key:o,type:n,valueFormatter:r}=t,s=e[o],i=gn(n),l=Dt(e[fn],s,t),u=i===ie.ArrowOnly||i===ie.ArrowBackground?l===un||l===cn?pn:l===nn||l===rn?dn:null:null,c=l?" "+l:"",m=mn(Te,c,{[`${Te}-arrowOnly`]:i===ie.ArrowOnly,[`${Te}-arrowBackground`]:i===ie.ArrowBackground});return hn("div",{className:m,tabIndex:-1,children:[bn("div",{className:`${Te}-flasher`,children:u}),r(e[t.key])]})};an("background",Cn,"cell-renderer",{description:"Background Cell renderer for VuuTable",label:"Background Cell (deprecated)",serverDataType:["long","int","double"]});import{isColumnTypeRenderer as xn,isTypeDescriptor as yn,isValidNumber as Rt,registerComponent as vn}from"@vuu-ui/vuu-utils";import Tn from"classnames";import{jsx as ze,jsxs as St}from"react/jsx-runtime";var le="vuuProgressCell",En=({column:t,columnMap:e,row:o})=>{let{type:n}=t,r=o[t.key],s=!1,i=0;if(yn(n)&&xn(n.renderer)){let{associatedField:u}=n.renderer;if(u){let c=o[e[u]];if(typeof Rt(r)&&Rt(c))i=Math.min(Math.round(r/c*100),100),i=Math.min(Math.round(r/c*100),100),s=isFinite(i);else{let m=parseFloat(r);if(Number.isFinite(m)){let d=parseFloat(c);Number.isFinite(d)&&(i=Math.min(Math.round(m/d*100),100),s=isFinite(i))}}}else throw Error("ProgressCell associatedField is required to render")}let l=Tn(le,{});return St("div",{className:l,tabIndex:-1,children:[s?St("span",{className:`${le}-track`,children:[ze("span",{className:`${le}-bg`}),ze("span",{className:`${le}-bar`,style:{"--progress-bar-pct":`-${100-i}%`}})]}):null,ze("span",{className:`${le}-text`,children:`${i} %`})]})};vn("vuu.progress",En,"cell-renderer",{description:"Progress formatter",label:"Progress formatter",serverDataType:["long","int","double"]});import{DOWN1 as Mn,DOWN2 as Hn,isTypeDescriptor as On,metadataKeys as An,registerComponent as Ln,UP1 as Nn,UP2 as kn}from"@vuu-ui/vuu-utils";import Fn from"classnames";import{getMovingValueDirection as wn,isTypeDescriptor as Dn,isValidNumber as Pt}from"@vuu-ui/vuu-utils";import{useEffect as Rn,useRef as Sn}from"react";var Pn=[void 0,void 0,void 0,void 0];function Mt(t,e,o){var d;let n=Sn(),[r,s,i,l]=n.current||Pn,{type:u}=o,c=Dn(u)?(d=u.formatting)==null?void 0:d.decimals:void 0,m=t===r&&Pt(e)&&Pt(s)&&o===i?wn(e,l,s,c):"";return Rn(()=>{n.current=[t,e,o,m]}),m}import{jsx as Bn,jsxs as Wn}from"react/jsx-runtime";var In=String.fromCharCode(11014),Kn=String.fromCharCode(11015),{KEY:zn}=An,Ee="vuuBackgroundCell",ae={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},Vn=t=>On(t)&&t.renderer&&"flashStyle"in t.renderer?t.renderer.flashStyle:ae.BackgroundOnly,$n=({column:t,row:e})=>{let{key:o,type:n,valueFormatter:r}=t,s=e[o],i=Vn(n),l=Mt(e[zn],s,t),u=i===ae.ArrowOnly||i===ae.ArrowBackground?l===Nn||l===kn?In:l===Mn||l===Hn?Kn:null:null,c=l?" "+l:"",m=Fn(Ee,c,{[`${Ee}-arrowOnly`]:i===ae.ArrowOnly,[`${Ee}-arrowBackground`]:i===ae.ArrowBackground});return Wn("div",{className:m,tabIndex:-1,children:[Bn("div",{className:`${Ee}-flasher`,children:u}),r(e[t.key])]})};console.log("register BackgroundCellNext");Ln("background-next",$n,"cell-renderer",{description:"Change background color of cell when value changes",label:"Background Flash",serverDataType:["long","int","double"]});import{List as Qn,ListItem as Gn}from"@vuu-ui/vuu-ui-controls";import{Checkbox as Un}from"@salt-ds/core";import{Switch as Xn}from"@salt-ds/lab";import _n from"classnames";import{useCallback as Yn}from"react";import{jsx as L,jsxs as Ve}from"react/jsx-runtime";var A="vuuColumnList",Ht="vuuColumnListItem",Jn=({className:t,item:e,...o})=>{var n;return Ve(Gn,{...o,className:_n(t,Ht),"data-name":e==null?void 0:e.name,children:[e!=null&&e.isCalculated?L("span",{className:`${A}-icon`,"data-icon":"function"}):L(Xn,{className:`${A}-switch`,checked:e==null?void 0:e.subscribed}),L("span",{className:`${A}-text`,children:(n=e==null?void 0:e.label)!=null?n:e==null?void 0:e.name}),L(Un,{className:`${A}-checkBox`,checked:(e==null?void 0:e.hidden)!==!0,disabled:(e==null?void 0:e.subscribed)!==!0})]})},Ot=({columnItems:t,onChange:e,onMoveListItem:o,...n})=>{let r=Yn(s=>{let i=s.target,l=i.closest(`.${Ht}`),{dataset:{name:u}}=l;if(u){let c=i.closest(`.${A}-switch`),m=i.closest(`.${A}-checkBox`);c?e(u,"subscribed",i.checked):m&&e(u,"hidden",i.checked===!1)}},[e]);return Ve("div",{...n,className:A,children:[L("div",{className:`${A}-header`,children:L("span",{children:"Column Selection"})}),Ve("div",{className:`${A}-colHeadings`,children:[L("span",{children:"Column subscription"}),L("span",{children:"Visibility"})]}),L(Qn,{ListItem:Jn,allowDragDrop:!0,height:"100%",onChange:r,onMoveListItem:o,selectionStrategy:"none",source:t,itemHeight:33})]})};import{getDefaultAlignment as Hs,isCalculatedColumn as Os}from"@vuu-ui/vuu-utils";import{Button as fo,FormField as Ae,FormFieldLabel as Le,ToggleButton as te,ToggleButtonGroup as go}from"@salt-ds/core";import{Dropdown as tr}from"@vuu-ui/vuu-ui-controls";import{FormField as or,FormFieldLabel as nr}from"@salt-ds/core";import Nt from"classnames";import{useMemo as rr}from"react";import{FormField as $e,FormFieldLabel as Be,Input as Zn}from"@salt-ds/core";import{Switch as At}from"@salt-ds/lab";import{getTypeSettingsFromColumn as qn}from"@vuu-ui/vuu-utils";import{useCallback as we,useState as jn}from"react";import{jsx as U,jsxs as De}from"react/jsx-runtime";var er="vuuFormattingSettings",Lt=({column:t,onChange:e})=>{var u;let[o,n]=jn(qn(t)),r=we(c=>{(c.key==="Enter"||c.key==="Tab")&&e(o)},[o,e]),s=we(c=>{let{value:m}=c.target,d=m===""||isNaN(parseInt(m))?void 0:parseInt(m),b={...o,decimals:d};n(b)},[o]),i=we(c=>{let{checked:m}=c.target,d={...o,alignOnDecimals:m};n(d),e(d)},[o,e]),l=we(c=>{let{checked:m}=c.target,d={...o,zeroPad:m};n(d),e(d)},[o,e]);return De("div",{className:er,children:[De($e,{"data-field":"decimals",children:[U(Be,{children:"Number of decimals"}),U(Zn,{className:"vuuInput",onChange:s,onKeyDown:r,value:(u=o.decimals)!=null?u:""})]}),De($e,{labelPlacement:"left",children:[U(Be,{children:"Align on decimals"}),U(At,{checked:o.alignOnDecimals,onChange:i,value:"align-decimals"})]}),De($e,{labelPlacement:"left",children:[U(Be,{children:"Zero pad decimals"}),U(At,{checked:o.zeroPad,onChange:l,value:"zero-pad"})]})]})};import{jsx as ue,jsxs as kt}from"react/jsx-runtime";var We="vuuColumnFormattingPanel",sr=t=>{var e;return(e=t.label)!=null?e:t.name},Ft=({availableRenderers:t,selectedCellRenderer:e,className:o,column:n,onChangeFormatting:r,onChangeRenderer:s,...i})=>{let l=rr(()=>{switch(n.serverDataType){case"double":case"int":case"long":return ue(Lt,{column:n,onChange:r});default:return null}},[n,r]),{serverDataType:u="string"}=n;return kt("div",{...i,className:"vuuColumnSettingsPanel-header",children:[ue("div",{children:"Formatting"}),kt(or,{children:[ue(nr,{children:"Renderer"}),ue(tr,{className:Nt(`${We}-renderer`),itemToString:sr,onSelectionChange:s,selected:e,source:t,width:"100%"})]}),ue("div",{className:Nt(We,o,`${We}-${u}`),children:l})]})};import{getRegisteredCellRenderers as ir,isColumnTypeRenderer as lr,isTypeDescriptor as ar,isValidColumnAlignment as ur,isValidPinLocation as cr,setCalculatedColumnName as mr,updateColumnRenderer as pr,updateColumnType as dr}from"@vuu-ui/vuu-utils";import{useCallback as I,useMemo as fr,useRef as gr,useState as Cr}from"react";var br=[{description:"Default formatter for columns with data type integer",label:"Default Renderer (data type int, long)",name:"default-int"}],hr=[{description:"Default formatter for columns with data type double",label:"Default Renderer (data type double)",name:"default-double"},...ir("double")],It=[{description:"Default formatter for columns with data type string",label:"Default Renderer (data type string)",name:"default-string"}],zt=t=>{switch(t.serverDataType){case"char":case"string":return It;case"int":case"long":return br;case"double":return hr;default:return It}},Kt=(t,e)=>{if(ar(e.type)){let{renderer:n}=e.type;if(lr(n)){let r=t.find(s=>s.name===n.name);if(r)return r}}return zt(e)[0]},xr=t=>{let e=t.closest(".saltFormField");if(e&&e.dataset.field){let{dataset:{field:o}}=e;return o}else throw Error("named form field not found")},yr=(t,e)=>{if(e.name==="::")return e;{let o=t.find(n=>n.name===e.name);if(o)return o;throw Error(`columns does not contain column ${name}`)}},ce=(t,e)=>({...t,columns:t.columns.map(o=>o.name===e.name?e:o)}),Vt=({column:t,onConfigChange:e,onCreateCalculatedColumn:o,tableConfig:n})=>{let[r,s]=Cr(yr(n.columns,t)),i=fr(()=>zt(r),[r]),l=gr(Kt(i,r)),u=I(()=>{e(ce(n,r))},[r,e,n]),c=I(f=>{let h=f.target,v=xr(h),{value:T}=h;switch(v){case"column-label":s(y=>({...y,label:T}));break;case"column-name":s(y=>mr(y,T));break;case"column-width":s(y=>({...y,width:parseInt(T)}));break;case"column-alignment":if(ur(T)){let y={...r,align:T||void 0};s(y),e(ce(n,y))}break;case"column-pin":if(cr(T)){let y={...r,pin:T||void 0};s(y),e(ce(n,y));break}}},[r,e,n]),m=I((f,h)=>{if(h){let v=pr(r,h);l.current=h,s(v),e(ce(n,v))}},[r,e,n]),d=I(f=>{let h=dr(r,f);s(h),e(ce(n,h))},[r,e,n]),b=I(({moveBy:f})=>{let{columns:h}=n,v=h.indexOf(r)+f,T=h[v];T&&(l.current=Kt(i,T),s(T))},[i,r,n]),a=I(()=>{b({moveBy:1})},[b]),p=I(()=>{b({moveBy:-1})},[b]),g=I(f=>{o({...r,...f})},[r,o]);return{availableRenderers:i,selectedCellRenderer:l.current,column:r,navigateNextColumn:a,navigatePrevColumn:p,onChange:c,onChangeFormatting:d,onChangeRenderer:m,onInputCommit:u,onSave:g}};import{Dropdown as Es}from"@vuu-ui/vuu-ui-controls";import{getCalculatedColumnExpression as ws,getCalculatedColumnName as Ds,getCalculatedColumnType as Rs}from"@vuu-ui/vuu-utils";import{Button as st,FormField as it,FormFieldLabel as lt,Input as Ss}from"@salt-ds/core";import{useCallback as Ps,useRef as Ms}from"react";import{autocompletion as Vr,defaultKeymap as $r,EditorState as Br,EditorView as to,ensureSyntaxTree as Wr,keymap as oo,minimalSetup as Qr,startCompletion as no}from"@vuu-ui/vuu-codemirror";import{createEl as ro}from"@vuu-ui/vuu-utils";import{useEffect as Gr,useMemo as Ur,useRef as tt}from"react";import{LanguageSupport as Tr,LRLanguage as Er,styleTags as wr,tags as Se}from"@vuu-ui/vuu-codemirror";import{LRParser as vr}from"@lezer/lr";var Re=vr.deserialize({version:14,states:"&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",stateData:")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",goto:"#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",nodeNames:"\u26A0 ColumnDefinitionExpression Column Number String True False ParenthesizedExpression OpenBrace CloseBrace ArithmeticExpression Divide Times Plus Minus ConditionalExpression If RelationalExpression RelationalOperator AndCondition OrCondition Comma CallExpression Function ArgList",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:".^~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$jz{$o{|$t|}$y}!O%O!O!P%T!P!Q%c!Q![%h!^!_%s!_!`&Q!`!a&V!c!}&d#R#S&d#T#U&u#U#Y&d#Y#Z(Y#Z#]&d#]#^*j#^#c&d#c#d+f#d#h&d#h#i,b#i#o&d~#USl~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOu~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_OS~~$bP;=`<%l#m~$jOW~~$oOX~~$tO[~~$yO]~~%OOe~~%TO^~~%WP!Q![%Z~%`PR~!Q![%Z~%hOZ~~%mQR~!O!P%Z!Q![%h~%xPr~!_!`%{~&QOt~~&VOp~~&[Pq~!_!`&_~&dOs~P&iSnP!Q![&d!c!}&d#R#S&d#T#o&dR&zUnP!Q![&d!c!}&d#R#S&d#T#b&d#b#c'^#c#o&dR'cUnP!Q![&d!c!}&d#R#S&d#T#W&d#W#X'u#X#o&dR'|SvQnP!Q![&d!c!}&d#R#S&d#T#o&d~(_TnP!Q![&d!c!}&d#R#S&d#T#U(n#U#o&d~(sUnP!Q![&d!c!}&d#R#S&d#T#`&d#`#a)V#a#o&d~)[UnP!Q![&d!c!}&d#R#S&d#T#g&d#g#h)n#h#o&d~)sUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y*V#Y#o&d~*^SU~nP!Q![&d!c!}&d#R#S&d#T#o&d~*oUnP!Q![&d!c!}&d#R#S&d#T#Y&d#Y#Z+R#Z#o&d~+YS`~nP!Q![&d!c!}&d#R#S&d#T#o&dR+kUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g+}#g#o&dR,USwQnP!Q![&d!c!}&d#R#S&d#T#o&d~,gUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g,y#g#o&d~-OUnP!Q![&d!c!}&d#R#S&d#T#i&d#i#j-b#j#o&d~-gUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y-y#Y#o&d~.QST~nP!Q![&d!c!}&d#R#S&d#T#o&d",tokenizers:[0,1],topRules:{ColumnDefinitionExpression:[0,1]},tokenPrec:375});var Dr=Er.define({name:"VuuColumnExpression",parser:Re.configure({props:[wr({Function:Se.variableName,String:Se.string,Or:Se.emphasis,Operator:Se.operator})]})}),$t=()=>new Tr(Dr);var Qe=class{constructor(e){switch(this.value=e,typeof e){case"boolean":this.type="booleanLiteralExpression";break;case"number":this.type="numericLiteralExpression";break;default:this.type="stringLiteralExpression"}}toJSON(){return{type:this.type,value:this.value}}},Ge=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},pe,$,Ue=class{constructor(e="unknown"){P(this,pe,[{type:"unknown"},{type:"unknown"}]);P(this,$,void 0);this.type="arithmeticExpression";F(this,$,e)}get op(){return C(this,$)}set op(e){F(this,$,e)}get expressions(){return C(this,pe)}toJSON(){return{type:this.type,op:C(this,$),expressions:C(this,pe)}}};pe=new WeakMap,$=new WeakMap;var J,Xe=class{constructor(e){P(this,J,[]);this.type="callExpression";this.functionName=e}get expressions(){return C(this,J)}get arguments(){return C(this,J)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:C(this,J).map(e=>{var o;return(o=e.toJSON)==null?void 0:o.call(e)})}}};J=new WeakMap;var de,Z,_=class{constructor(){P(this,de,[{type:"unknown"},{type:"unknown"}]);P(this,Z,"unknown");this.type="relationalExpression"}get op(){return C(this,Z)}set op(e){F(this,Z,e)}get expressions(){return C(this,de)}toJSON(){return{type:this.type,op:C(this,Z),expressions:C(this,de)}}};de=new WeakMap,Z=new WeakMap;var fe,q,Y=class{constructor(e){P(this,fe,[{type:"unknown"},{type:"unknown"}]);P(this,q,void 0);this.type="booleanCondition";F(this,q,e)}get op(){return C(this,q)}get expressions(){return C(this,fe)}toJSON(){return{type:this.type,op:C(this,q),expressions:C(this,fe).map(e=>{var o;return(o=e.toJSON)==null?void 0:o.call(e)})}}};fe=new WeakMap,q=new WeakMap;var H,me=class{constructor(e){P(this,H,void 0);this.type="conditionalExpression";F(this,H,[e?new Y(e):new _,{type:"unknown"},{type:"unknown"}])}get expressions(){return C(this,H)}get condition(){return C(this,H)[0]}get truthyExpression(){return C(this,H)[1]}set truthyExpression(e){C(this,H)[1]=e}get falsyExpression(){return C(this,H)[2]}set falsyExpression(e){C(this,H)[2]=e}toJSON(){var e,o,n,r,s;return{type:this.type,condition:(o=(e=this.condition).toJSON)==null?void 0:o.call(e),truthyExpression:this.truthyExpression,falsyExpression:(s=(r=(n=this.falsyExpression)==null?void 0:n.toJSON)==null?void 0:r.call(n))!=null?s:this.falsyExpression}}};H=new WeakMap;var V=t=>t.type==="unknown",Pe=t=>t.type==="arithmeticExpression",Rr=t=>t.type==="callExpression",X=t=>t.type==="conditionalExpression",Sr=t=>t.type==="relationalExpression"||t.type==="booleanCondition";var Pr=t=>t.type==="booleanCondition",Ye=t=>(t==null?void 0:t.type)==="relationalExpression";var S=t=>{if(V(t))return t;if(Ye(t)){let[e,o]=t.expressions;if(w(e))return S(e);if(t.op==="unknown")return t;if(w(o))return S(o)}else if(Sr(t)){let{expressions:e=[]}=t;for(let o of e)if(w(o))return S(o)}else if(X(t)){let{condition:e,truthyExpression:o,falsyExpression:n}=t;if(w(e))return S(e);if(w(o))return S(o);if(w(n))return S(n)}else if(Pe(t)){let{expressions:e=[]}=t;for(let o of e)if(w(o))return S(o)}},Me=(t,e,o)=>{let{expressions:n=[]}=t;if(n.includes(e)){let r=n.indexOf(e);return n.splice(r,1,o),!0}else for(let r of n)if(Me(r,e,o))return!0;return!1},w=t=>V(t)?!0:X(t)?w(t.condition)||w(t.truthyExpression)||w(t.falsyExpression):Ye(t)||Pr(t)?t.op===void 0||t.expressions.some(e=>w(e)):!1,Bt=(t,e)=>{let o=S(t);o?o.expressions?o.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},x,B,_e=class{constructor(){P(this,x,void 0);P(this,B,[])}setCondition(e){if(C(this,x)===void 0)this.addExpression(new me(e));else if(X(C(this,x))){if(w(C(this,x).condition)){let o=e?new Y(e):new _;this.addExpression(o)}else if(V(C(this,x).truthyExpression))C(this,x).truthyExpression=new me(e);else if(w(C(this,x).truthyExpression)){let o=e?new Y(e):new _;this.addExpression(o)}else if(V(C(this,x).falsyExpression))C(this,x).falsyExpression=new me(e);else if(w(C(this,x).falsyExpression)){let o=e?new Y(e):new _;this.addExpression(o)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(C(this,B).length>0){let o=C(this,B).at(-1);o==null||o.arguments.push(e)}else if(C(this,x)===void 0)F(this,x,e);else if(Pe(C(this,x))){let o=S(C(this,x));o&&V(o)&&Me(C(this,x),o,e)}else if(X(C(this,x))&&w(C(this,x))){let o=S(C(this,x));o&&V(o)?Me(C(this,x),o,e):o&&Bt(o,e)}}setFunction(e){let o=new Xe(e);this.addExpression(o),C(this,B).push(o)}setColumn(e){this.addExpression(new Ge(e))}setArithmeticOp(e){let o=e,n=C(this,x);Pe(n)&&(n.op=o)}setRelationalOperator(e){let o=e;if(C(this,x)&&X(C(this,x))){let n=S(C(this,x));Ye(n)?n.op=o:console.error(`no target expression found (op = ${e})`)}}setValue(e){let o=new Qe(e);if(C(this,x)===void 0)F(this,x,o);else if(Pe(C(this,x)))this.addExpression(o);else if(Rr(C(this,x)))C(this,x).arguments.push(o);else if(X(C(this,x)))if(w(C(this,x))){let n=S(C(this,x));n&&V(n)?Me(C(this,x),n,o):n&&Bt(n,o)}else console.log("what do we do with value, in a complete expression")}closeBrace(){C(this,B).pop()}get expression(){return C(this,x)}toJSON(){var e;return(e=C(this,x))==null?void 0:e.toJSON()}};x=new WeakMap,B=new WeakMap;var Wt=(t,e)=>{let o=new _e,n=t.cursor();do{let{name:r,from:s,to:i}=n;switch(r){case"AndCondition":o.setCondition("and");break;case"OrCondition":o.setCondition("or");break;case"RelationalExpression":o.setCondition();break;case"ArithmeticExpression":o.addExpression(new Ue);break;case"Column":{let l=e.substring(s,i);o.setColumn(l)}break;case"Function":{let l=e.substring(s,i);o.setFunction(l)}break;case"Times":case"Divide":case"Plus":case"Minus":{let l=e.substring(s,i);o.setArithmeticOp(l)}break;case"RelationalOperator":{let l=e.substring(s,i);o.setRelationalOperator(l)}break;case"False":case"True":{let l=e.substring(s,i);o.setValue(l==="true")}break;case"String":o.setValue(e.substring(s+1,i-1));break;case"Number":o.setValue(parseFloat(e.substring(s,i)));break;case"CloseBrace":o.closeBrace();break;default:}}while(n.next());return o.toJSON()};var Mr=Re.configure({strict:!0}),Qt=["Number","String"],Je=[...Qt,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],Gt=t=>{try{return Mr.parse(t),!0}catch{return!1}},Ze=t=>{let{lastChild:e}=t;for(;e&&!Je.includes(e.name);)e=e.prevSibling,console.log(e==null?void 0:e.name);return e},Ut=t=>{if((t==null?void 0:t.name)==="RelationalExpression"){let{firstChild:e}=t,o=Ze(t);if((e==null?void 0:e.name)==="Column"&&typeof(o==null?void 0:o.name)=="string"&&Qt.includes(o.name))return!0}return!1};import{HighlightStyle as Hr,syntaxHighlighting as Or,tags as Xt}from"@vuu-ui/vuu-codemirror";var Ar=Hr.define([{tag:Xt.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:Xt.comment,color:"green",fontStyle:"italic"}]),_t=Or(Ar);import{EditorView as Lr}from"@vuu-ui/vuu-codemirror";var Yt=Lr.theme({"&":{border:"solid 1px var(--salt-container-primary-borderColor)",color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-scroller":{fontFamily:"var(--vuuFilterEditor-fontFamily)"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",boxShadow:"var(--vuuFilterEditor-tooltipElevation)","&.cm-tooltip-autocomplete > ul":{fontFamily:"var(--vuuFilterEditor-fontFamily)",fontSize:"var(--vuuFilterEditor-fontSize)",maxHeight:"240px"},"&.cm-tooltip-autocomplete > ul > li":{height:"var(--vuuFilterEditor-suggestion-height)",padding:"0 3px",lineHeight:"var(--vuuFilterEditor-suggestion-height)"},"&.cm-tooltip-autocomplete li[aria-selected]":{background:"var(--vuuFilterEditor-suggestion-selectedBackground)",color:"var(--vuuFilterEditor-suggestion-selectedColor)"},"&.cm-tooltip-autocomplete li .cm-completionDetail":{color:"var(--vuuFilterEditor-suggestion-detailColor)"}}},{dark:!1});import{booleanJoinSuggestions as Nr,getNamedParentNode as Jt,getPreviousNode as kr,getValue as N,syntaxTree as Fr}from"@vuu-ui/vuu-codemirror";import{useCallback as Zt}from"react";var Ir=(t,e)=>e?t.map(o=>{var n;return{...o,apply:typeof o.apply=="function"?o.apply:`${e}${(n=o.apply)!=null?n:o.label}`}}):t,Kr=t=>t===void 0?!1:["Times","Divide","Plus","Minus"].includes(t.name),ge=t=>({apply:()=>{t==null||t()},label:"Done",boost:10}),j=(t,e)=>{var r;let{lastChild:o}=t,{pos:n}=e;for(;o;)if(o.from<n&&Je.includes(o.name)){if(o.name==="ParenthesizedExpression"){let i=(r=o.firstChild)==null?void 0:r.nextSibling;i&&(o=i)}return o}else o=o.prevSibling},qt=(t,e)=>{var o;if(t.name==="ArgList"){let n=t.prevSibling;if(n)return N(n,e)}else if(t.name==="OpenBrace"){let n=(o=t.parent)==null?void 0:o.prevSibling;if((n==null?void 0:n.name)==="Function")return N(n,e)}},jt=(t,e)=>{if(t.name==="RelationalExpression"){let o=Ze(t);if((o==null?void 0:o.name)==="RelationalOperator")return N(o,e)}else{let o=t.prevSibling;if((o==null?void 0:o.name)==="RelationalOperator")return N(o,e)}},et=(t,e)=>{var o;if(t.name==="RelationalExpression"){if(((o=t.firstChild)==null?void 0:o.name)==="Column")return N(t.firstChild,e)}else{let n=t.prevSibling;if((n==null?void 0:n.name)==="Column")return N(n,e);if((n==null?void 0:n.name)==="RelationalOperator")return et(n,e)}},qe=async(t,e,o,n={})=>{let r=await e.getSuggestions(o,n),{startsWith:s=""}=n;return{from:t.pos-s.length,options:r}},je=(t,e,o,n,r)=>{let s=j(t,e);switch(console.log(`conditional expression last child ${s==null?void 0:s.name}`),s==null?void 0:s.name){case"If":return qe(e,o,"expression",{prefix:"( "});case"OpenBrace":return qe(e,o,"expression");case"Condition":return qe(e,o,"expression",{prefix:", "});case"CloseBrace":if(n){let i=[ge(r)];return{from:e.pos,options:i}}}},zr=(t,e)=>{let o=[ge(e)];return{from:t.pos,options:o}},eo=(t,e)=>{let o=Zt(async(n,r,s={})=>{let i=await t.getSuggestions(r,s),{startsWith:l=""}=s;return{from:n.pos-l.length,options:i}},[t]);return Zt(async n=>{var d,b;let{state:r,pos:s}=n,i=(d=n.matchBefore(/\w*/))!=null?d:{from:0,to:0,text:void 0},u=Fr(r).resolveInner(s,-1),c=r.doc.toString(),m=Gt(c);switch(u.name){case"If":return console.log("conditional expression If"),o(n,"expression",{prefix:"( "});case"Condition":{let a=j(u,n);if((a==null?void 0:a.name)==="Column"){let p=kr(a);if((p==null?void 0:p.name)!=="RelationalOperator")return o(n,"condition-operator",{columnName:N(a,r)})}else if((a==null?void 0:a.name)==="RelationalOperator")return o(n,"expression");console.log(`condition last child ${a==null?void 0:a.name}`)}break;case"ConditionalExpression":return je(u,n,t);case"RelationalExpression":{if(Ut(u))return{from:n.pos,options:Nr.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let a=jt(u,r),p=et(u,r);if(a)return o(n,"expression");{let g=await t.getSuggestions("condition-operator",{columnName:p});return{from:n.pos,options:g}}}}break;case"RelationalOperator":return o(n,"expression");case"String":{let a=jt(u,r),p=et(u,r),{from:g,to:f}=u;if(f-g===2&&n.pos===g+1){if(p&&a)return o(n,"columnValue",{columnName:p,operator:a,startsWith:i.text})}else if(f-g>2&&n.pos===f)return o(n,"expression",{prefix:", "})}break;case"ArithmeticExpression":{let a=j(u,n);if((a==null?void 0:a.name)==="Column")return o(n,"expression");if(Kr(a)){let p=a.name;return o(n,"column",{operator:p})}}break;case"OpenBrace":{let a=qt(u,r);return o(n,"expression",{functionName:a})}break;case"ArgList":{let a=qt(u,r),p=j(u,n),g=(p==null?void 0:p.name)==="OpenBrace"?void 0:",",f=await t.getSuggestions("expression",{functionName:a});return f=g?Ir(f,", "):f,(p==null?void 0:p.name)!=="OpenBrace"&&(p==null?void 0:p.name)!=="Comma"&&(f=[{apply:") ",boost:10,label:"Done - no more arguments"}].concat(f)),{from:n.pos,options:f}}case"Equal":if(c.trim()==="=")return o(n,"expression");break;case"ParenthesizedExpression":case"ColumnDefinitionExpression":if(n.pos===0)return o(n,"expression");{let a=j(u,n);if((a==null?void 0:a.name)==="Column"){if(m){let p=[ge(e.current)],g=N(a,r),f=await t.getSuggestions("operator",{columnName:g});return{from:n.pos,options:p.concat(f)}}}else if((a==null?void 0:a.name)==="CallExpression"){if(m)return{from:n.pos,options:[ge(e.current)]}}else if((a==null?void 0:a.name)==="ArithmeticExpression"){if(m){let p=[ge(e.current)],g=j(a,n);if((g==null?void 0:g.name)==="Column"){let f=N(g,r),h=await t.getSuggestions("operator",{columnName:f});p=p.concat(h)}return{from:n.pos,options:p}}}else if((a==null?void 0:a.name)==="ConditionalExpression")return je(a,n,t,m,e.current);break}case"Column":if(await t.isPartialMatch("expression",void 0,i.text))return o(n,"expression",{startsWith:i.text});break;case"Comma":{let a=Jt(u);if((a==null?void 0:a.name)==="ConditionalExpression")return o(n,"expression")}break;case"CloseBrace":{let a=Jt(u);if((a==null?void 0:a.name)==="ConditionalExpression")return je(a,n,t,m,e.current);if((a==null?void 0:a.name)==="ArgList"&&m)return zr(n,e.current)}break;default:((b=u==null?void 0:u.prevSibling)==null?void 0:b.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[o,e,t])};var He=t=>{if(t.current==null)throw Error("EditorView not defined");return t.current},Xr=()=>"vuuSuggestion",_r=()=>console.log("noooop"),Yr=t=>"expressionType"in t,Jr=t=>{if(Yr(t)){let e=ro("div","expression-type-container"),o=ro("span","expression-type",t.expressionType);return e.appendChild(o),e}else return null},so=({onChange:t,onSubmitExpression:e,source:o,suggestionProvider:n})=>{let r=tt(null),s=tt(_r),i=tt(),l=eo(n,s),[u,c]=Ur(()=>{let m=()=>{let g=He(i),f=g.state.doc.toString(),h=Wr(g.state,g.state.doc.length,5e3);if(h){let v=Wt(h,f);return[f,v]}else return["",void 0]},d=()=>{He(i).setState(p())},b=()=>{let[g,f]=m();e==null||e(g,f)},a=g=>oo.of([{key:g,run(){return no(He(i)),!0}}]),p=()=>Br.create({doc:o,extensions:[Qr,Vr({addToOptions:[{render:Jr,position:70}],override:[l],optionClass:Xr}),$t(),oo.of($r),a("ArrowDown"),to.updateListener.of(g=>{let f=He(i);if(g.docChanged){no(f);let h=f.state.doc.toString();t==null||t(h)}}),Yt,_t]});return s.current=()=>{b()},[p,d]},[l,t,e,o]);return Gr(()=>{if(!r.current)throw Error("editor not in dom");return i.current=new to({state:u(),parent:r.current}),()=>{var m;(m=i.current)==null||m.destroy()}},[l,u]),{editorRef:r,clearInput:c}};import{jsx as qr}from"react/jsx-runtime";var Zr="vuuColumnExpressionInput",io=({onChange:t,onSubmitExpression:e,source:o="",suggestionProvider:n})=>{let{editorRef:r}=so({onChange:t,onSubmitExpression:e,source:o,suggestionProvider:n});return qr("div",{className:`${Zr}`,ref:r})};import{AnnotationType as jr,getRelationalOperators as es,numericOperators as ts,stringOperators as os,toSuggestions as ns}from"@vuu-ui/vuu-codemirror";import{getTypeaheadParams as rs,useTypeaheadSuggestions as ss}from"@vuu-ui/vuu-data-react";import{isNumericColumn as nt,isTextColumn as is}from"@vuu-ui/vuu-utils";import{useCallback as ot,useRef as ls}from"react";var ee=[{accepts:"string",description:"Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",example:{expression:'concatenate("example", "-test")',result:'"example-test"'},name:"concatenate",params:{description:"( string, string, [ string* ] )"},type:"string"},{accepts:["string","string"],description:"Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",example:{expression:'contains("Royal Bank of Scotland", "bank")',result:"true"},name:"contains",params:{description:"( string )"},type:"boolean"},{accepts:["string","number"],description:"Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:'left("USD Benchmark Report", 3)',result:'"USD"'},name:"left",params:{count:2,description:"( string, number )"},type:"string"},{accepts:"string",description:"Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",example:{expression:'len("example")',result:"7"},name:"len",params:{description:"(string)"},type:"number"},{accepts:"string",description:"Convert a string value to lowercase. Argument may be a string column or other string expression.",example:{expression:'lower("examPLE")',result:'"example"'},name:"lower",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Convert a string value to uppercase. Argument may be a string column or other string expression.",example:{expression:'upper("example")',result:'"EXAMPLE"'},name:"upper",params:{description:"( string )"},type:"string"},{accepts:["string","number"],description:"Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:"blah",result:"blah"},name:"right",params:{description:"( string )"},type:"string"},{accepts:["string","string","string"],description:"Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",example:{expression:"blah",result:"blah"},name:"replace",params:{description:"( string )"},type:"string"},{accepts:"number",description:"Converts a number to a string.",example:{expression:"blah",result:"blah"},name:"text",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",example:{expression:"blah",result:"blah"},name:"starts",params:{description:"( string )"},type:"boolean"},{accepts:"string",description:"Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",example:{expression:"blah",result:"blah"},name:"ends",params:{description:"( string )"},type:"boolean"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"min",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"max",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"sum",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"round",params:{description:"( string )"},type:"number"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"or",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"and",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",example:{expression:"blah",result:"blah"},name:"if",params:{description:"( filterExpression, expression1, expression 2)"},type:"variable"}];import{createEl as k}from"@vuu-ui/vuu-utils";var lo=({name:t,description:e,example:o,params:n,type:r})=>{let s=k("div","vuuFunctionDoc"),i=k("div","function-heading"),l=k("span","function-name",t),u=k("span","param-list",n.description),c=k("span","function-type",r);i.appendChild(l),i.appendChild(u),i.appendChild(c);let m=k("p",void 0,e);if(s.appendChild(i),s.appendChild(m),o){let d=k("div","example-container","Example:"),b=k("div","example-expression",o.expression),a=k("div","example-result",o.result);d.appendChild(b),d.appendChild(a),s.appendChild(d)}return s};var as=[],W=t=>t.map(e=>{var o;return{...e,apply:((o=e.apply)!=null?o:e.label)+" "}}),us=(t,{functionName:e,operator:o})=>{if(o)return t.filter(nt);if(e){let n=ee.find(r=>r.name===e);if(n)switch(n.accepts){case"string":return t.filter(is);case"number":return t.filter(nt);default:return t}}return t},ao=(t,e)=>us(t,e).map(n=>{var s;let r=(s=n.label)!=null?s:n.name;return{apply:e.prefix?`${e.prefix}${r}`:r,label:r,boost:5,type:"column",expressionType:n.serverDataType}}),cs=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],ms=t=>t===void 0||nt(t)?cs:as,ps=t=>{switch(t.serverDataType){case"string":case"char":return W(os);case"int":case"long":case"double":return W(ts)}},rt=t=>({apply:`${t.name}( `,boost:2,expressionType:t.type,info:()=>lo(t),label:t.name,type:"function"}),ds=t=>{if(t){if(typeof t.accepts=="string")return t.accepts;if(Array.isArray(t.accepts))return t.accepts.every(e=>e==="string")?"string":"any"}return"any"},fs=ee.map(rt),gs=({functionName:t})=>{if(t){let e=ee.find(n=>n.name===t),o=ds(e);if(e)switch(o){case"string":return ee.filter(n=>n.type==="string"||n.type==="variable").map(rt);case"number":return ee.filter(n=>n.type==="number"||n.type==="variable").map(rt);default:}}return fs},Cs={},uo=({columns:t,table:e})=>{let o=ot(l=>l?t.find(u=>u.name===l):void 0,[t]),n=ls(),r=ss(),s=ot(async(l,u=Cs)=>{let{columnName:c,functionName:m,operator:d,prefix:b}=u;switch(l){case"expression":{let a=await W(ao(t,{functionName:m,prefix:b})).concat(gs(u));return n.current=a}case"column":{let a=await ao(t,u);return n.current=W(a)}case"operator":{let a=await ms(o(c));return n.current=W(a)}case"relational-operator":{let a=await es(o(c));return n.current=W(a)}case"condition-operator":{let a=o(c);if(a){let p=await ps(a);if(p)return n.current=W(p)}}break;case"columnValue":if(c&&d){let a=rs(e,c),p=await r(a);return n.current=ns(p,{suffix:""}),n.current.forEach(g=>{g.apply=(f,h,v)=>{let T=new jr,y=v+h.label.length+1;f.dispatch({changes:{from:v,insert:h.label},selection:{anchor:y,head:y},annotations:T.of(h)})}}),n.current}break}return[]},[t,o,r,e]),i=ot(async(l,u,c)=>{let{current:m}=n,d=!1,b=m||await s(l,{columnName:u});if(c&&b)for(let a of b){if(a.label===c)return!1;a.label.startsWith(c)&&(d=!0)}return d},[s]);return{getSuggestions:s,isPartialMatch:i}};import{getCalculatedColumnDetails as co,setCalculatedColumnExpression as bs,setCalculatedColumnName as hs,setCalculatedColumnType as xs}from"@vuu-ui/vuu-utils";import{useCallback as Oe,useRef as ys,useState as vs}from"react";var Ts=t=>{let[e,o,n]=co(t);return n===""?{...t,name:`${e}:${o}:string`}:t},mo=({column:t,onSave:e})=>{let[o,n]=vs(Ts(t)),r=ys(co(o)[1]),s=Oe(c=>{let{value:m}=c.target;n(d=>hs(d,m))},[]),i=Oe(c=>{r.current=c.trim()},[]),l=Oe((c,m)=>{typeof m=="string"&&n(d=>xs(d,m))},[]),u=Oe(()=>{let c=bs(o,r.current);n(c),e(c)},[o,e]);return{column:o,onChangeExpression:i,onChangeName:s,onChangeType:l,onSave:u}};import{jsx as M,jsxs as be}from"react/jsx-runtime";var Ce="vuuColumnExpressionPanel",po=({column:t,onSave:e,tableConfig:o,vuuTable:n})=>{let r=Ms(null),{column:s,onChangeExpression:i,onChangeName:l,onChangeType:u,onSave:c}=mo({column:t,onSave:e}),m=uo({columns:o.columns,table:n}),d=Ps(()=>{requestAnimationFrame(()=>{var b,a;(a=(b=r.current)==null?void 0:b.querySelector("button"))==null||a.focus()})},[]);return be("div",{className:Ce,children:[M("div",{className:"vuuColumnSettingsPanel-header",children:M("span",{children:"Calculation"})}),be(it,{"data-field":"column-name",children:[M(lt,{children:"Column Name"}),M(Ss,{className:"vuuInput",onChange:l,value:Ds(s)})]}),be(it,{"data-field":"column-expression",children:[M(lt,{children:"Expression"}),M(io,{onChange:i,onSubmitExpression:d,source:ws(s),suggestionProvider:m})]}),be(it,{"data-field":"type",children:[M(lt,{children:"Column type"}),M(Es,{className:`${Ce}-type`,onSelectionChange:u,ref:r,selected:Rs(s)||null,source:["double","long","string"],width:"100%"})]}),be("div",{className:"vuuColumnSettingsPanel-buttonBar","data-align":"right",children:[M(st,{className:`${Ce}-buttonCancel`,tabIndex:-1,children:"cancel"}),M(st,{className:`${Ce}-buttonApply`,tabIndex:-1,children:"apply"}),M(st,{className:`${Ce}-buttonSave`,onClick:c,variant:"cta",children:"save"})]})]})};import{VuuInput as Co}from"@vuu-ui/vuu-ui-controls";import{jsx as E,jsxs as K}from"react/jsx-runtime";var he="vuuColumnSettingsPanel",Cm=({column:t,onConfigChange:e,onCreateCalculatedColumn:o,tableConfig:n,vuuTable:r})=>{let s=t.name==="::",{availableRenderers:i,selectedCellRenderer:l,column:u,navigateNextColumn:c,navigatePrevColumn:m,onChange:d,onChangeFormatting:b,onChangeRenderer:a,onInputCommit:p,onSave:g}=Vt({column:t,onConfigChange:e,onCreateCalculatedColumn:o,tableConfig:n}),{serverDataType:f,align:h=Hs(f),name:v,label:T=v,pin:y,width:R}=u;return K("div",{className:he,children:[E("div",{className:`${he}-header`,children:E("span",{children:v})}),K(Ae,{"data-field":"column-label",children:[E(Le,{children:"Column Label"}),E(Co,{className:"vuuInput",onChange:d,onCommit:p,value:T})]}),K(Ae,{"data-field":"column-width",children:[E(Le,{children:"Column Width"}),E(Co,{className:"vuuInput",onChange:d,value:R,onCommit:p})]}),K(Ae,{"data-field":"column-alignment",children:[E(Le,{children:"Alignment"}),K(go,{className:"vuuToggleButtonGroup",onChange:d,value:h,children:[E(te,{"data-icon":"align-left",className:"vuuIconToggleButton",value:"left"}),E(te,{"data-icon":"align-right",className:"vuuIconToggleButton",value:"right"})]})]}),K(Ae,{"data-field":"column-pin",children:[E(Le,{children:"Pin Column"}),K(go,{className:"vuuToggleButtonGroup",onChange:d,value:y!=null?y:"",children:[E(te,{className:"vuuIconToggleButton","data-icon":"cross-circle",value:""}),E(te,{className:"vuuIconToggleButton","data-icon":"pin-left",value:"left"}),E(te,{className:"vuuIconToggleButton","data-icon":"pin-float",value:"floating"}),E(te,{className:"vuuIconToggleButton","data-icon":"pin-right",value:"right"})]})]}),E(Ft,{availableRenderers:i,selectedCellRenderer:l,column:u,onChangeFormatting:b,onChangeRenderer:a}),Os(u.name)?E(po,{column:u,onSave:g,tableConfig:n,vuuTable:r}):K("div",{className:`${he}-buttonBar`,"data-align":s?"right":void 0,children:[E(fo,{className:`${he}-buttonNavPrev`,variant:"secondary","data-icon":"arrow-left",onClick:m,children:"PREVIOUS"}),E(fo,{className:`${he}-buttonNavNext`,variant:"secondary","data-icon":"arrow-right",onClick:c,children:"NEXT"})]})]})};import{useEffect as As,useState as bo}from"react";import Ls from"classnames";import{jsx as oe,jsxs as Ns}from"react/jsx-runtime";var xe="vuuDatasourceStats",at=new Intl.NumberFormat,Sm=({className:t,dataSource:e})=>{let[o,n]=bo(e.range),[r,s]=bo(e.size);As(()=>{s(e.size),e.on("resize",s),e.on("range",n)},[e]);let i=Ls(xe,t),l=at.format(o.from),u=at.format(o.to-1),c=at.format(r);return Ns("div",{className:i,children:[oe("span",{className:`${xe}-label`,children:"Row count"}),oe("span",{className:`${xe}-range`,children:l}),oe("span",{children:"-"}),oe("span",{className:`${xe}-range`,children:u}),oe("span",{children:"of"}),oe("span",{className:`${xe}-size`,children:c})]})};import{Button as Vl,FormField as bt,FormFieldLabel as ht,Input as $l,ToggleButton as re,ToggleButtonGroup as Bl}from"@salt-ds/core";import{useLayoutEffectSkipFirst as Ol}from"@vuu-ui/vuu-layout";import{useCallback as km,useRef as Fm}from"react";import{jsx as zm}from"react/jsx-runtime";import{isNumericColumn as Bm}from"@vuu-ui/vuu-utils";import{removeColumnFromFilter as Gm}from"@vuu-ui/vuu-utils";import{addGroupColumn as Xm,addSortColumn as _m,AggregationType as ks,setAggregations as Ym,setSortColumn as Jm}from"@vuu-ui/vuu-utils";var{Average:Zm,Count:qm,Distinct:jm,High:ep,Low:tp,Sum:op}=ks;import{ContextMenuProvider as bb}from"@vuu-ui/vuu-popups";import{Button as xb,useIdMemo as yb}from"@salt-ds/core";import{buildColumnMap as jd,getColumnStyle as ef,isGroupColumn as tf,metadataKeys as pi,notHidden as of,visibleColumnAtIndex as nf}from"@vuu-ui/vuu-utils";import{useCallback as lf,useMemo as af}from"react";import{isGroupColumn as vo,isJsonColumn as Js,isJsonGroup as Zs,metadataKeys as qs,notHidden as js,RowSelected as ei}from"@vuu-ui/vuu-utils";import ti from"classnames";import{memo as oi,useCallback as To}from"react";import{getColumnStyle as Fs,metadataKeys as Is}from"@vuu-ui/vuu-utils";import{EditableLabel as Ks}from"@vuu-ui/vuu-ui-controls";import zs from"classnames";import{memo as Vs,useCallback as $s,useRef as Bs,useState as ho}from"react";import{jsx as Ne}from"react/jsx-runtime";var{KEY:xo}=Is,ut=Vs(({className:t,column:e,columnMap:o,onClick:n,row:r})=>{let s=Bs(null),{align:i,CellRenderer:l,key:u,pin:c,editable:m,resizing:d,valueFormatter:b}=e,[a,p]=ho(!1),g=b(r[u]),[f,h]=ho(g),v=()=>{var O;(O=s.current)==null||O.focus()},T=O=>{O.key==="Enter"&&p(!0)},y=$s(O=>{n==null||n(O,e)},[e,n]),R=()=>{p(!0)},se=(O="",vt="",Wo=!0,Qo=!1)=>{var Tt;p(!1),Qo?h(O):vt!==O&&h(vt),Wo===!1&&((Tt=s.current)==null||Tt.focus())},Ke=zs(t,{vuuAlignRight:i==="right",vuuPinFloating:c==="floating",vuuPinLeft:c==="left",vuuPinRight:c==="right","vuuTableCell-resizing":d})||void 0,yt=Fs(e);return m?Ne("div",{className:Ke,"data-editable":!0,role:"cell",style:yt,onKeyDown:T,children:Ne(Ks,{editing:a,value:f,onChange:h,onMouseDownCapture:v,onEnterEditMode:R,onExitEditMode:se,onKeyDown:T,ref:s,tabIndex:0},"title")}):Ne("div",{className:Ke,role:"cell",style:yt,onClick:y,children:l?Ne(l,{column:e,columnMap:o,row:r}):g})},Ws);ut.displayName="TableCell";function Ws(t,e){return t.column===e.column&&t.onClick===e.onClick&&t.row[xo]===e.row[xo]&&t.row[t.column.key]===e.row[e.column.key]}import{getColumnStyle as Qs,getGroupValueAndOffset as Gs,metadataKeys as Us}from"@vuu-ui/vuu-utils";import{useCallback as Xs}from"react";import{jsx as ct,jsxs as Ys}from"react/jsx-runtime";var{IS_LEAF:_s}=Us,yo=({column:t,onClick:e,row:o})=>{let{columns:n}=t,[r,s]=Gs(n,o),i=Xs(m=>{e==null||e(m,t)},[t,e]),l=Qs(t),u=o[_s],c=Array(s).fill(0).map((m,d)=>ct("span",{className:"vuuTableGroupCell-spacer"},d));return Ys("div",{className:"vuuTableGroupCell vuuPinLeft",onClick:u?void 0:i,role:"cell",style:l,children:[c,u?null:ct("span",{className:"vuuTableGroupCell-toggle","data-icon":"triangle-right"}),ct("span",{children:r})]})};import{jsx as wo,jsxs as ui}from"react/jsx-runtime";var{IDX:ni,IS_EXPANDED:ri,SELECTED:si}=qs,{True:Eo,First:ii,Last:li}=ei,ne="vuuTableRow",ai=oi(function({columnMap:e,columns:o,offset:n,onClick:r,onToggleGroup:s,virtualColSpan:i=0,row:l}){let{[ni]:u,[ri]:c,[si]:m}=l,d=ti(ne,{[`${ne}-even`]:u%2===0,[`${ne}-expanded`]:c,[`${ne}-selected`]:m&Eo,[`${ne}-selectedStart`]:m&ii,[`${ne}-selectedEnd`]:m&li}),b=To(p=>{let g=p.shiftKey,f=p.ctrlKey||p.metaKey;r==null||r(l,g,f)},[r,l]),a=To((p,g)=>{(vo(g)||Zs(g,l))&&(p.stopPropagation(),s==null||s(l,g))},[s,l]);return ui("div",{"aria-selected":m&Eo?!0:void 0,"aria-rowindex":u,className:d,onClick:b,role:"row",style:{transform:`translate3d(0px, ${n}px, 0px)`},children:[i>0?wo("div",{role:"cell",style:{width:i}}):null,o.filter(js).map(p=>{let g=vo(p),f=Js(p);return wo(g?yo:ut,{column:p,columnMap:e,onClick:g||f?a:void 0,row:l},p.name)})]})});import Xp from"classnames";import{useRef as Jp}from"react";import{useCallback as $p,useRef as Bp}from"react";import{jsx as td,jsxs as od}from"react/jsx-runtime";import Od from"classnames";import{useCallback as kd,useRef as Fd}from"react";import ld from"classnames";import{jsx as cd,jsxs as md}from"react/jsx-runtime";import{useContextMenu as Bd}from"@vuu-ui/vuu-popups";import{useContextMenu as hd}from"@vuu-ui/vuu-popups";import yd from"classnames";import{useCallback as Ed}from"react";import{jsx as Rd}from"react/jsx-runtime";import{jsx as Gd,jsxs as Ud}from"react/jsx-runtime";import{jsx as gf,jsxs as Cf}from"react/jsx-runtime";var{RENDER_IDX:df}=pi;import{useContextMenu as kC}from"@vuu-ui/vuu-popups";import{applySort as IC,buildColumnMap as KC,isJsonGroup as zC,metadataKeys as Si,moveItemDeprecated as VC}from"@vuu-ui/vuu-utils";import{useCallback as WC,useEffect as QC,useMemo as GC,useRef as UC,useState as XC}from"react";import{isVuuFeatureAction as xf,isVuuFeatureInvocation as yf}from"@vuu-ui/vuu-data-react";import{getFullRange as Tf,metadataKeys as di,WindowRange as Ef}from"@vuu-ui/vuu-utils";import{useCallback as Df,useEffect as Rf,useMemo as Sf,useRef as Pf,useState as Mf}from"react";var{SELECTED:Hf}=di;import{useDragDropNext as Lf}from"@vuu-ui/vuu-ui-controls";import{useCallback as Ff,useRef as If}from"react";import{withinRange as Qf}from"@vuu-ui/vuu-utils";import{useCallback as Yf,useEffect as Jf,useLayoutEffect as Zf,useMemo as qf,useRef as jf}from"react";function fi(t,...e){let o=new Set(t);for(let n of e)for(let r of n)o.add(r);return o}var Do="ArrowUp",Ro="ArrowDown",So="ArrowLeft",Po="ArrowRight";var Mo="Home",Ho="End",Oo="PageUp",Ao="PageDown";var gi=new Set(["Enter","Delete"," "]),Ci=new Set(["Tab"]),bi=new Set(["ArrowRight","ArrowLeft"]),hi=new Set([Mo,Ho,Oo,Ao,Ro,So,Po,Do]),xi=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),zf=fi(gi,hi,bi,xi,Ci);import{isValidNumber as dg}from"@vuu-ui/vuu-utils";import{useCallback as Cg,useMemo as bg,useRef as hg,useState as xg}from"react";import{useCallback as ig,useEffect as lg,useRef as ag}from"react";var yi=new Map,vi=(t,e,o)=>{switch(o){case"height":return e.height;case"clientHeight":return t.clientHeight;case"clientWidth":return t.clientWidth;case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(t.scrollHeight);case"scrollWidth":return Math.ceil(t.scrollWidth);case"width":return e.width;default:return 0}},ug=new ResizeObserver(t=>{for(let e of t){let{target:o,borderBoxSize:n,contentBoxSize:r}=e,s=yi.get(o);if(s){let[{blockSize:i,inlineSize:l}]=n,[{blockSize:u,inlineSize:c}]=r,{onResize:m,measurements:d}=s,b=!1;for(let[a,p]of Object.entries(d)){let g=vi(o,{height:i,width:l,contentHeight:u,contentWidth:c},a);g!==p&&(b=!0,d[a]=g)}b&&m&&m(d)}}});import{deselectItem as wg,isRowSelected as Dg,metadataKeys as Ti,selectItem as Rg}from"@vuu-ui/vuu-utils";import{useCallback as Pg,useRef as Mg}from"react";var{IDX:Hg}=Ti;import{applyFilterToColumns as Lg,applyGroupByToColumns as Ng,applySortToColumns as kg,findColumn as Fg,getCellRenderer as Ig,getColumnName as Kg,getTableHeadings as zg,getValueFormatter as Vg,isFilteredColumn as $g,isGroupColumn as Bg,isPinned as Wg,isTypeDescriptor as Qg,metadataKeys as Ei,updateColumn as Gg,sortPinnedColumns as Ug,stripFilterFromColumns as Xg,moveItemDeprecated as _g,getDefaultAlignment as Yg}from"@vuu-ui/vuu-utils";import{useReducer as qg}from"react";var jg=Ei.count;import{useCallback as oC,useRef as nC}from"react";import{useCallback as iC,useMemo as lC,useRef as aC}from"react";import{actualRowPositioning as cC,virtualRowPositioning as fC}from"@vuu-ui/vuu-utils";import{getColumnsInViewport as bC,itemsChanged as hC}from"@vuu-ui/vuu-utils";import{useCallback as vC,useEffect as TC,useMemo as EC,useRef as wC,useState as DC}from"react";var{KEY:ib,IS_EXPANDED:lb,IS_LEAF:ab}=Si;import Db from"classnames";import{isDataLoading as Mb}from"@vuu-ui/vuu-utils";import{jsx as Ob,jsxs as Ab}from"react/jsx-runtime";import Mi from"classnames";import{isJsonAttribute as Hi,metadataKeys as Oi,registerComponent as Ai}from"@vuu-ui/vuu-utils";import{jsx as mt,jsxs as Ii}from"react/jsx-runtime";var ye="vuuJsonCell",{IS_EXPANDED:Li,KEY:Ni}=Oi,ki=t=>{let e=t.lastIndexOf("|");return e===-1?"":t.slice(e+1)},Fi=({column:t,row:e})=>{let{key:o}=t,n=e[o],r=!1;Hi(n)&&(n=n.slice(0,-1),r=!0);let s=ki(e[Ni]),i=Mi({[`${ye}-name`]:s===n,[`${ye}-value`]:s!==n,[`${ye}-group`]:r});if(r){let l=e[Li]?"minus-box":"plus-box";return Ii("span",{className:i,children:[mt("span",{className:`${ye}-value`,children:n}),mt("span",{className:`${ye}-toggle`,"data-icon":l})]})}else return n?mt("span",{className:i,children:n}):null};Ai("json",Fi,"cell-renderer",{description:"JSON formatter",label:"JSON formatter",serverDataType:"json"});import rx from"classnames";import{useRef as ix}from"react";import{useCallback as oh,useRef as nh}from"react";import{jsx as ih}from"react/jsx-runtime";import{useCallback as ch,useRef as mh,useState as ph}from"react";import{getColumnStyle as Ki}from"@vuu-ui/vuu-utils";import zi from"classnames";import{useMemo as Vi}from"react";var Q=(t,e,o)=>Vi(()=>{let n=zi(e,{vuuPinFloating:t.pin==="floating",vuuPinLeft:t.pin==="left",vuuPinRight:t.pin==="right",vuuEndPin:o&&t.endPin,[`${e}-editable`]:t.editable,[`${e}-right`]:t.align==="right"}),r=Ki(t);return{className:n,style:r}},[t,e,o]);import wh from"classnames";import{useCallback as Ph}from"react";import{jsx as Oh,jsxs as Ah}from"react/jsx-runtime";import{jsx as Vh,jsxs as $h}from"react/jsx-runtime";import{jsx as _h,jsxs as Yh}from"react/jsx-runtime";import{jsx as dx,jsxs as fx}from"react/jsx-runtime";import{createElement as px}from"react";import hx from"classnames";import{useCallback as yx,useRef as vx,useState as Tx}from"react";import{OverflowContainer as Sx,useLayoutEffectSkipFirst as Px}from"@vuu-ui/vuu-layout";import{jsx as Ax,jsxs as Lx}from"react/jsx-runtime";import{createElement as Ox}from"react";import{useCallback as ly,useRef as ay}from"react";import{useContextMenu as zx}from"@vuu-ui/vuu-popups";import $x from"classnames";import{useCallback as Gx,useRef as Ux,useState as Xx}from"react";import{jsx as Jx}from"react/jsx-runtime";import dy from"classnames";import{jsx as hy,jsxs as xy}from"react/jsx-runtime";import{ContextMenuProvider as $E}from"@vuu-ui/vuu-popups";import{isGroupColumn as WE,metadataKeys as fl,notHidden as QE}from"@vuu-ui/vuu-utils";import UE from"classnames";import{useRef as JE}from"react";import{isGroupColumn as Ko,isJsonColumn as qi,isJsonGroup as ji,metadataKeys as el,notHidden as tl,RowSelected as ol}from"@vuu-ui/vuu-utils";import nl from"classnames";import{memo as rl,useCallback as zo}from"react";import{metadataKeys as Bi}from"@vuu-ui/vuu-utils";import{useCallback as Wi}from"react";import{jsx as ko}from"react/jsx-runtime";var{IDX:Qi}=Bi,Gi="vuuTableNextCell",Fo=({column:t,columnMap:e,onDataEdited:o,row:n})=>{let{className:r,style:s}=Q(t,Gi),{CellRenderer:i,name:l,valueFormatter:u}=t,c=e[l],m=Wi(d=>(o==null||o(n[Qi],l,d),!0),[l,o,n]);return ko("div",{className:r,role:"cell",style:s,children:i?ko(i,{column:t,columnMap:e,onCommit:m,row:n}):u(n[c])})};import{getGroupValueAndOffset as Ui,metadataKeys as Xi}from"@vuu-ui/vuu-utils";import{useCallback as _i}from"react";import Yi from"classnames";import{jsx as ft,jsxs as Zi}from"react/jsx-runtime";var{IS_LEAF:Ji}=Xi,dt="vuuTableNextGroupCell",Io=({column:t,onClick:e,row:o})=>{let{columns:n}=t,[r,s]=Ui(n,o),{className:i,style:l}=Q(t,dt),u=_i(d=>{e==null||e(d,t)},[t,e]),c=o[Ji],m=Array(s).fill(0).map((d,b)=>ft("span",{className:`${dt}-spacer`},b));return Zi("div",{className:Yi(i,"vuuTableNextCell"),role:"cell",style:l,onClick:c?void 0:u,children:[m,c?null:ft("span",{className:`${dt}-toggle`,"data-icon":"triangle-right"}),ft("span",{children:r})]})};import{jsx as gt}from"react/jsx-runtime";import{createElement as al}from"react";var{IDX:sl,IS_EXPANDED:il,SELECTED:ll}=el,z="vuuTableNextRow",Vo=rl(({className:t,columnMap:e,columns:o,row:n,offset:r,onClick:s,onDataEdited:i,onToggleGroup:l,zebraStripes:u=!1,...c})=>{let{[sl]:m,[il]:d,[ll]:b}=n,a=zo(y=>{let R=y.shiftKey,se=y.ctrlKey||y.metaKey;s==null||s(n,R,se)},[s,n]),{True:p,First:g,Last:f}=ol,h=nl(z,t,{[`${z}-even`]:u&&m%2===0,[`${z}-expanded`]:d,[`${z}-selected`]:b&p,[`${z}-selectedStart`]:b&g,[`${z}-selectedEnd`]:b&f}),v={transform:`translate3d(0px, ${r}px, 0px)`},T=zo((y,R)=>{(Ko(R)||ji(R,n))&&(y.stopPropagation(),l==null||l(n,R))},[l,n]);return al("div",{...c,"aria-rowindex":n[0],key:`row-${n[0]}`,role:"row",className:h,onClick:a,style:v},gt("span",{className:`${z}-selectionDecorator vuuStickyLeft`}),o.filter(tl).map(y=>{let R=Ko(y),se=qi(y);return gt(R?Io:Fo,{column:y,columnMap:e,onClick:R||se?T:void 0,onDataEdited:i,row:n},y.key)}),gt("span",{className:`${z}-selectionDecorator vuuStickyRight`}))});Vo.displayName="Row";import{useLayoutEffectSkipFirst as ZT}from"@vuu-ui/vuu-layout";import{useDragDropNext as eE}from"@vuu-ui/vuu-ui-controls";import{useCallback as dv,useEffect as fv,useMemo as gv,useRef as Cv}from"react";import{applySort as nE,buildColumnMap as rE,isGroupColumn as sE,isJsonGroup as iE,isValidNumber as lE,metadataKeys as pl,updateColumn as aE,visibleColumnAtIndex as uE}from"@vuu-ui/vuu-utils";import{useCallback as fE,useEffect as gE,useMemo as CE,useState as bE}from"react";var ke=(t,e)=>{switch(e.type){case"col-size":return{...t,columns:t.columns.map(o=>o.name===e.column.name?{...o,width:e.width}:o)};case"column-prop":return{...t,columns:t.columns.map(o=>o.name===e.column.name?{...o,[e.property]:e.value}:o)};default:return t}};import{isVuuFeatureAction as Sv,isVuuFeatureInvocation as Pv}from"@vuu-ui/vuu-data-react/src";import{getFullRange as Hv,NULL_RANGE as Ov}from"@vuu-ui/vuu-utils";import{useCallback as Lv,useEffect as Nv,useMemo as kv,useRef as Fv,useState as Iv}from"react";import{metadataKeys as ul,WindowRange as Tv}from"@vuu-ui/vuu-utils";var{SELECTED:Ev}=ul;import{useMemo as $v,useRef as Bv}from"react";import{buildColumnMap as Gv}from"@vuu-ui/vuu-utils";import{useCallback as _v}from"react";import{useContextMenu as Jv}from"@vuu-ui/vuu-popups";import{isCharacterKey as eT}from"@vuu-ui/vuu-utils";import{useCallback as nT}from"react";import{applyFilterToColumns as lT,applyGroupByToColumns as aT,applySortToColumns as uT,getCellRenderer as cT,getTableHeadings as mT,getValueFormatter as pT,hasValidationRules as dT,isFilteredColumn as fT,isGroupColumn as gT,isPinned as CT,isTypeDescriptor as bT,logger as cl,metadataKeys as ml,moveItem as hT,sortPinnedColumns as xT,stripFilterFromColumns as yT,subscribedOnly as vT}from"@vuu-ui/vuu-utils";import{buildValidationChecker as ET}from"@vuu-ui/vuu-ui-controls";import{useReducer as RT}from"react";var{info:ST}=cl("useTableModel");var PT=ml.count;import{useCallback as OT,useRef as AT}from"react";import{useCallback as kT,useEffect as FT,useRef as IT}from"react";var{KEY:AE,IS_EXPANDED:LE,IS_LEAF:NE}=pl;import{MeasuredContainer as tw,useId as ow}from"@vuu-ui/vuu-layout";import{jsx as lw,jsxs as uw}from"react/jsx-runtime";import{createElement as aw}from"react";var{IDX:rw,RENDER_IDX:sw}=fl;import{Dropdown as gl}from"@vuu-ui/vuu-ui-controls";import{isColumnTypeRenderer as Cl,isTypeDescriptor as bl,registerComponent as hl}from"@vuu-ui/vuu-utils";import{useCallback as xl,useState as yl}from"react";import{jsx as wl}from"react/jsx-runtime";var vl="vuuTableDropdownCell",Tl=["Enter"," "],El=({column:t,columnMap:e,row:o})=>{var u,c,m;let n=bl(t.type)&&Cl((u=t.type)==null?void 0:u.renderer)?(m=(c=t.type)==null?void 0:c.renderer)==null?void 0:m.values:[],r=e[t.name],[s,i]=yl(o[r]),l=xl((d,b)=>{b&&i(b)},[]);return wl(gl,{className:vl,onSelectionChange:l,openKeys:Tl,selected:s,source:n,width:t.width-17})};hl("dropdown-cell",El,"cell-renderer",{});import{registerComponent as Dl}from"@vuu-ui/vuu-utils";import{Input as Rl}from"@salt-ds/core";import{useEditableText as Sl}from"@vuu-ui/vuu-ui-controls";import Pl from"classnames";import{jsx as Ct}from"react/jsx-runtime";var Fe="vuuTableInputCell",Ml=()=>(console.warn("onCommit handler has not been provided to InputCell cell renderer"),!0),Hl=({column:t,columnMap:e,onCommit:o=Ml,row:n})=>{let r=e[t.name],{align:s="left",clientSideEditValidationCheck:i,valueFormatter:l}=t,{warningMessage:u,...c}=Sl({initialValue:l(n[r]),onCommit:o,clientSideEditValidationCheck:i}),m=u&&s==="left"?Ct("span",{className:`${Fe}-icon`,"data-icon":"error"}):void 0,d=u&&s==="right"?Ct("span",{className:`${Fe}-icon`,"data-icon":"error"}):void 0;return Ct(Rl,{...c,className:Pl(Fe,{[`${Fe}-error`]:u!==void 0}),endAdornment:m,startAdornment:d})};Dl("input-cell",Hl,"cell-renderer",{});import{addColumnToSubscribedColumns as Al,isCalculatedColumn as Ll,moveItem as Nl,subscribedOnly as kl}from"@vuu-ui/vuu-utils";import{useCallback as Ie,useMemo as Fl,useState as Il}from"react";var Kl=(t,e)=>{let o=[];for(let{name:n}of t){let r=e.find(s=>s.name===n);r&&o.push(r)}return o},zl=(t,e)=>t.map(({name:o,serverDataType:n})=>{let r=e.find(s=>s.name===o);return{hidden:r==null?void 0:r.hidden,isCalculated:Ll(o),label:r==null?void 0:r.label,name:o,serverDataType:n,subscribed:r!==void 0}}),Bo=({availableColumns:t,onConfigChange:e,onDataSourceConfigChange:o,tableConfig:n})=>{let[{availableColumns:r,tableConfig:s},i]=Il({availableColumns:t,tableConfig:n}),l=Fl(()=>zl(r,s.columns),[r,s.columns]),u=Ie((a,p)=>{i(g=>{let f=Nl(g.availableColumns,a,p),h=Kl(f,s.columns);return{availableColumns:f,tableConfig:{...g.tableConfig,columns:h}}})},[s.columns]),c=Ie((a,p,g)=>{let f=l.find(h=>h.name===a);if(p==="subscribed")if(f!=null&&f.subscribed){let h=s.columns.filter(v=>v.name!==a).map(v=>v.name);i(v=>({...v,tableConfig:{...s,columns:s.columns.filter(kl(h))}})),o({columns:h})}else{let h={...s,columns:Al(s.columns,r,a)};i(T=>({...T,tableConfig:h}));let v=h.columns.map(T=>T.name);o({columns:v})}else if(f!=null&&f.subscribed){let h=s.columns.find(v=>v.name===a);if(h){let v=ke(s,{type:"column-prop",property:p,column:h,value:g});i(T=>({...T,tableConfig:v}))}}},[r,l,o,s]),m=Ie(a=>{let{value:p}=a.target,g=p==="0"?void 0:p==="1"?"capitalize":"uppercase";i(f=>({...f,tableConfig:{...f.tableConfig,columnFormatHeader:g}}))},[]),d=Ie(a=>{let{ariaChecked:p,value:g}=a.target;i(f=>({...f,tableConfig:{...f.tableConfig,[g]:p!=="true"}}))},[]);Ol(()=>{e==null||e(s)},[e,s]);let b=s.columnFormatHeader===void 0?0:s.columnFormatHeader==="capitalize"?1:2;return{columnItems:l,columnLabelsValue:b,onChangeColumnLabels:m,onChangeTableAttribute:d,onColumnChange:c,onMoveListItem:u,tableConfig:s}};import{jsx as D,jsxs as G}from"react/jsx-runtime";var xt="vuuTableSettingsPanel",lD=({availableColumns:t,onAddCalculatedColumn:e,onConfigChange:o,onDataSourceConfigChange:n,tableConfig:r,...s})=>{let{columnItems:i,columnLabelsValue:l,onChangeColumnLabels:u,onChangeTableAttribute:c,onColumnChange:m,onMoveListItem:d,tableConfig:b}=Bo({availableColumns:t,onConfigChange:o,onDataSourceConfigChange:n,tableConfig:r});return G("div",{...s,className:xt,children:[G(bt,{children:[D(ht,{children:"Column Labels"}),G(Bl,{className:"vuuToggleButtonGroup",onChange:u,value:l,children:[D(re,{className:"vuuIconToggleButton","data-icon":"text-strikethrough",value:0}),D(re,{className:"vuuIconToggleButton","data-icon":"text-Tt",value:1}),D(re,{className:"vuuIconToggleButton","data-icon":"text-T",value:2})]})]}),G(bt,{children:[D(ht,{children:"Grid separators"}),G("div",{className:"saltToggleButtonGroup vuuToggleButtonGroup saltToggleButtonGroup-horizontal vuuGridSeparators",children:[D(re,{className:"vuuIconToggleButton","data-icon":"row-striping",selected:b.zebraStripes,onChange:c,value:"zebraStripes"}),D(re,{className:"vuuIconToggleButton","data-icon":"row-lines",selected:b.rowSeparators,onChange:c,value:"rowSeparators"}),D(re,{className:"vuuIconToggleButton","data-icon":"col-lines",selected:b.columnSeparators,onChange:c,value:"columnSeparators"})]})]}),G(bt,{children:[D(ht,{children:"Default Column Width"}),D($l,{className:"vuuInput"})]}),D(Ot,{columnItems:i,onChange:m,onMoveListItem:d}),G("div",{className:`${xt}-calculatedButtonbar`,children:[D(Vl,{"data-icon":"plus",onClick:e}),D("span",{className:`${xt}-calculatedLabel`,children:"Add calculated column"})]})]})};import{useLayoutProviderDispatch as Wl}from"@vuu-ui/vuu-layout";import{getCalculatedColumnType as Ql}from"@vuu-ui/vuu-utils";import{useCallback as ve,useRef as Gl,useState as Ul}from"react";var dl=({availableColumns:t,onAvailableColumnsChange:e,onConfigChange:o,onCreateCalculatedColumn:n,onDataSourceConfigChange:r,tableConfig:s})=>{let i=Wl(),l=Gl(),[u,c]=Ul(t),m=ve((p,g,f)=>{i({type:"set-props",path:"#context-panel",props:{expanded:!0,content:{type:p,props:f},title:g}})},[i]),d=ve(p=>{let g=u.concat({name:p.name,serverDataType:Ql(p)});c(g),e==null||e(g),requestAnimationFrame(()=>{var f;(f=l.current)==null||f.call(l)}),n(p)},[u,e,n]),b=ve(p=>{m("ColumnSettings","Column Settings",{column:p.column,onConfigChange:o,onCreateCalculatedColumn:d,tableConfig:s,vuuTable:p.vuuTable})},[d,o,m,s]),a=ve(()=>{b({column:{name:"::",serverDataType:"string"},type:"columnSettings",vuuTable:{module:"SIMUL",table:"instruments"}})},[b]);return l.current=ve(()=>{m("TableSettings","DataGrid Settings",{availableColumns:u!=null?u:s.columns.map(({name:p,serverDataType:g})=>({name:p,serverDataType:g})),onAddCalculatedColumn:a,onConfigChange:o,onDataSourceConfigChange:r,tableConfig:s})},[u,a,o,r,m,s]),{showColumnSettingsPanel:b,showTableSettingsPanel:l.current}};export{$n as BackgroundCell,Xo as CaseValidator,io as ColumnExpressionInput,po as ColumnExpressionPanel,Ft as ColumnFormattingPanel,Ot as ColumnList,Je as ColumnNamedTerms,Cm as ColumnSettingsPanel,Sm as DataSourceStats,Lt as NumericFormattingSettings,Zo as PatternValidator,lD as TableSettingsPanel,$t as columnExpressionLanguageSupport,Gt as isCompleteExpression,Ut as isCompleteRelationalExpression,Ze as lastNamedChild,so as useColumnExpressionEditor,uo as useColumnExpressionSuggestionProvider,dl as useTableAndColumnSettings,Bo as useTableSettings,Wt as walkTree};
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
17
+ return value;
18
+ };
19
+
20
+ // src/cell-edit-validators/CaseValidator.ts
21
+ import { registerComponent } from "@vuu-ui/vuu-utils";
22
+ var isString = (value) => typeof value === "string";
23
+ var CaseValidator = (rule, value) => {
24
+ if (isString(value)) {
25
+ if (value === "") {
26
+ return true;
27
+ } else if (rule.value === "lower" && value.toLowerCase() !== value) {
28
+ return "value must be all lowercase";
29
+ } else if (rule.value === "upper" && value.toUpperCase() !== value) {
30
+ return "value must be all uppercase";
31
+ } else {
32
+ return true;
33
+ }
34
+ } else {
35
+ return "value must be a string";
36
+ }
37
+ };
38
+ registerComponent("vuu-case", CaseValidator, "data-edit-validator", {});
39
+
40
+ // src/cell-edit-validators/PatternValidator.ts
41
+ import { registerComponent as registerComponent2 } from "@vuu-ui/vuu-utils";
42
+ var isString2 = (value) => typeof value === "string";
43
+ var defaultMessage = "value does not match expected pattern";
44
+ var PatternValidator = (rule, value) => {
45
+ if (typeof rule.value !== "string") {
46
+ throw Error("Pattern validation rule must provide pattern");
47
+ }
48
+ if (isString2(value)) {
49
+ if (value === "") {
50
+ return true;
51
+ } else {
52
+ const { message = defaultMessage } = rule;
53
+ const pattern = new RegExp(rule.value);
54
+ return pattern.test(value) || message;
55
+ }
56
+ } else {
57
+ return "value must be a string";
58
+ }
59
+ };
60
+ registerComponent2("vuu-pattern", PatternValidator, "data-edit-validator", {});
61
+
62
+ // src/cell-renderers/background-cell/BackgroundCell.tsx
63
+ import {
64
+ DOWN1,
65
+ DOWN2,
66
+ isTypeDescriptor as isTypeDescriptor2,
67
+ metadataKeys,
68
+ registerComponent as registerComponent3,
69
+ UP1,
70
+ UP2
71
+ } from "@vuu-ui/vuu-utils";
72
+ import cx from "classnames";
73
+
74
+ // src/cell-renderers/background-cell/useDirection.ts
75
+ import {
76
+ getMovingValueDirection,
77
+ isTypeDescriptor,
78
+ isValidNumber
79
+ } from "@vuu-ui/vuu-utils";
80
+ import { useEffect, useRef } from "react";
81
+ var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
82
+ function useDirection(key, value, column) {
83
+ var _a;
84
+ const ref = useRef();
85
+ const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
86
+ const { type: dataType } = column;
87
+ const decimals = isTypeDescriptor(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
88
+ const direction = key === prevKey && isValidNumber(value) && isValidNumber(prevValue) && column === prevColumn ? getMovingValueDirection(value, prevDirection, prevValue, decimals) : "";
89
+ useEffect(() => {
90
+ ref.current = [key, value, column, direction];
91
+ });
92
+ return direction;
93
+ }
94
+
95
+ // src/cell-renderers/background-cell/BackgroundCell.tsx
96
+ import { jsx, jsxs } from "react/jsx-runtime";
97
+ var CHAR_ARROW_UP = String.fromCharCode(11014);
98
+ var CHAR_ARROW_DOWN = String.fromCharCode(11015);
99
+ var { KEY } = metadataKeys;
100
+ var classBase = "vuuBackgroundCellDeprecated";
101
+ var FlashStyle = {
102
+ ArrowOnly: "arrow",
103
+ BackgroundOnly: "bg-only",
104
+ ArrowBackground: "arrow-bg"
105
+ };
106
+ var getFlashStyle = (colType) => {
107
+ if (isTypeDescriptor2(colType) && colType.renderer) {
108
+ if ("flashStyle" in colType.renderer) {
109
+ return colType.renderer["flashStyle"];
110
+ }
111
+ }
112
+ return FlashStyle.BackgroundOnly;
113
+ };
114
+ var BackgroundCell = ({ column, row }) => {
115
+ const { key, type, valueFormatter } = column;
116
+ const value = row[key];
117
+ const flashStyle = getFlashStyle(type);
118
+ const direction = useDirection(row[KEY], value, column);
119
+ const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === UP1 || direction === UP2 ? CHAR_ARROW_UP : direction === DOWN1 || direction === DOWN2 ? CHAR_ARROW_DOWN : null : null;
120
+ const dirClass = direction ? ` ` + direction : "";
121
+ const className = cx(classBase, dirClass, {
122
+ [`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
123
+ [`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
124
+ });
125
+ return /* @__PURE__ */ jsxs("div", { className, tabIndex: -1, children: [
126
+ /* @__PURE__ */ jsx("div", { className: `${classBase}-flasher`, children: arrow }),
127
+ valueFormatter(row[column.key])
128
+ ] });
129
+ };
130
+ registerComponent3("background", BackgroundCell, "cell-renderer", {
131
+ description: "Background Cell renderer for VuuTable",
132
+ label: "Background Cell (deprecated)",
133
+ serverDataType: ["long", "int", "double"]
134
+ });
135
+
136
+ // src/cell-renderers/progress-cell/ProgressCell.tsx
137
+ import {
138
+ isColumnTypeRenderer,
139
+ isTypeDescriptor as isTypeDescriptor3,
140
+ isValidNumber as isValidNumber2,
141
+ registerComponent as registerComponent4
142
+ } from "@vuu-ui/vuu-utils";
143
+ import cx2 from "classnames";
144
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
145
+ var classBase2 = "vuuProgressCell";
146
+ var ProgressCell = ({ column, columnMap, row }) => {
147
+ const { type } = column;
148
+ const value = row[column.key];
149
+ let showProgress = false;
150
+ let percentage = 0;
151
+ if (isTypeDescriptor3(type) && isColumnTypeRenderer(type.renderer)) {
152
+ const { associatedField } = type.renderer;
153
+ if (associatedField) {
154
+ const associatedValue = row[columnMap[associatedField]];
155
+ if (typeof isValidNumber2(value) && isValidNumber2(associatedValue)) {
156
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
157
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
158
+ showProgress = isFinite(percentage);
159
+ } else {
160
+ const floatValue = parseFloat(value);
161
+ if (Number.isFinite(floatValue)) {
162
+ const floatOtherValue = parseFloat(associatedValue);
163
+ if (Number.isFinite(floatOtherValue)) {
164
+ percentage = Math.min(
165
+ Math.round(floatValue / floatOtherValue * 100),
166
+ 100
167
+ );
168
+ showProgress = isFinite(percentage);
169
+ }
170
+ }
171
+ }
172
+ } else {
173
+ throw Error("ProgressCell associatedField is required to render");
174
+ }
175
+ }
176
+ const className = cx2(classBase2, {});
177
+ return /* @__PURE__ */ jsxs2("div", { className, tabIndex: -1, children: [
178
+ showProgress ? /* @__PURE__ */ jsxs2("span", { className: `${classBase2}-track`, children: [
179
+ /* @__PURE__ */ jsx2("span", { className: `${classBase2}-bg` }),
180
+ /* @__PURE__ */ jsx2(
181
+ "span",
182
+ {
183
+ className: `${classBase2}-bar`,
184
+ style: { "--progress-bar-pct": `-${100 - percentage}%` }
185
+ }
186
+ )
187
+ ] }) : null,
188
+ /* @__PURE__ */ jsx2("span", { className: `${classBase2}-text`, children: `${percentage} %` })
189
+ ] });
190
+ };
191
+ registerComponent4("vuu.progress", ProgressCell, "cell-renderer", {
192
+ description: "Progress formatter",
193
+ label: "Progress formatter",
194
+ serverDataType: ["long", "int", "double"]
195
+ });
196
+
197
+ // src/cell-renderers-next/background-cell/BackgroundCell.tsx
198
+ import {
199
+ DOWN1 as DOWN12,
200
+ DOWN2 as DOWN22,
201
+ isTypeDescriptor as isTypeDescriptor5,
202
+ metadataKeys as metadataKeys2,
203
+ registerComponent as registerComponent5,
204
+ UP1 as UP12,
205
+ UP2 as UP22
206
+ } from "@vuu-ui/vuu-utils";
207
+ import cx3 from "classnames";
208
+
209
+ // src/cell-renderers-next/background-cell/useDirection.ts
210
+ import {
211
+ getMovingValueDirection as getMovingValueDirection2,
212
+ isTypeDescriptor as isTypeDescriptor4,
213
+ isValidNumber as isValidNumber3
214
+ } from "@vuu-ui/vuu-utils";
215
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
216
+ var INITIAL_VALUE2 = [void 0, void 0, void 0, void 0];
217
+ function useDirection2(key, value, column) {
218
+ var _a;
219
+ const ref = useRef2();
220
+ const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE2;
221
+ const { type: dataType } = column;
222
+ const decimals = isTypeDescriptor4(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
223
+ const direction = key === prevKey && isValidNumber3(value) && isValidNumber3(prevValue) && column === prevColumn ? getMovingValueDirection2(value, prevDirection, prevValue, decimals) : "";
224
+ useEffect2(() => {
225
+ ref.current = [key, value, column, direction];
226
+ });
227
+ return direction;
228
+ }
229
+
230
+ // src/cell-renderers-next/background-cell/BackgroundCell.tsx
231
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
232
+ var CHAR_ARROW_UP2 = String.fromCharCode(11014);
233
+ var CHAR_ARROW_DOWN2 = String.fromCharCode(11015);
234
+ var { KEY: KEY2 } = metadataKeys2;
235
+ var classBase3 = "vuuBackgroundCell";
236
+ var FlashStyle2 = {
237
+ ArrowOnly: "arrow",
238
+ BackgroundOnly: "bg-only",
239
+ ArrowBackground: "arrow-bg"
240
+ };
241
+ var getFlashStyle2 = (colType) => {
242
+ if (isTypeDescriptor5(colType) && colType.renderer) {
243
+ if ("flashStyle" in colType.renderer) {
244
+ return colType.renderer["flashStyle"];
245
+ }
246
+ }
247
+ return FlashStyle2.BackgroundOnly;
248
+ };
249
+ var BackgroundCell2 = ({ column, row }) => {
250
+ const { key, type, valueFormatter } = column;
251
+ const value = row[key];
252
+ const flashStyle = getFlashStyle2(type);
253
+ const direction = useDirection2(row[KEY2], value, column);
254
+ const arrow = flashStyle === FlashStyle2.ArrowOnly || flashStyle === FlashStyle2.ArrowBackground ? direction === UP12 || direction === UP22 ? CHAR_ARROW_UP2 : direction === DOWN12 || direction === DOWN22 ? CHAR_ARROW_DOWN2 : null : null;
255
+ const dirClass = direction ? ` ` + direction : "";
256
+ const className = cx3(classBase3, dirClass, {
257
+ [`${classBase3}-arrowOnly`]: flashStyle === FlashStyle2.ArrowOnly,
258
+ [`${classBase3}-arrowBackground`]: flashStyle === FlashStyle2.ArrowBackground
259
+ });
260
+ return /* @__PURE__ */ jsxs3("div", { className, tabIndex: -1, children: [
261
+ /* @__PURE__ */ jsx3("div", { className: `${classBase3}-flasher`, children: arrow }),
262
+ valueFormatter(row[column.key])
263
+ ] });
264
+ };
265
+ console.log("register BackgroundCellNext");
266
+ registerComponent5("background-next", BackgroundCell2, "cell-renderer", {
267
+ description: "Change background color of cell when value changes",
268
+ label: "Background Flash",
269
+ serverDataType: ["long", "int", "double"]
270
+ });
271
+
272
+ // src/column-list/ColumnList.tsx
273
+ import {
274
+ List,
275
+ ListItem
276
+ } from "@vuu-ui/vuu-ui-controls";
277
+ import { Checkbox } from "@salt-ds/core";
278
+ import { Switch } from "@salt-ds/lab";
279
+ import cx4 from "classnames";
280
+ import { useCallback } from "react";
281
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
282
+ var classBase4 = "vuuColumnList";
283
+ var classBaseListItem = "vuuColumnListItem";
284
+ var ColumnListItem = ({
285
+ className: classNameProp,
286
+ item,
287
+ ...listItemProps
288
+ }) => {
289
+ var _a;
290
+ return /* @__PURE__ */ jsxs4(
291
+ ListItem,
292
+ {
293
+ ...listItemProps,
294
+ className: cx4(classNameProp, classBaseListItem),
295
+ "data-name": item == null ? void 0 : item.name,
296
+ children: [
297
+ (item == null ? void 0 : item.isCalculated) ? /* @__PURE__ */ jsx4("span", { className: `${classBase4}-icon`, "data-icon": "function" }) : /* @__PURE__ */ jsx4(Switch, { className: `${classBase4}-switch`, checked: item == null ? void 0 : item.subscribed }),
298
+ /* @__PURE__ */ jsx4("span", { className: `${classBase4}-text`, children: (_a = item == null ? void 0 : item.label) != null ? _a : item == null ? void 0 : item.name }),
299
+ /* @__PURE__ */ jsx4(
300
+ Checkbox,
301
+ {
302
+ className: `${classBase4}-checkBox`,
303
+ checked: (item == null ? void 0 : item.hidden) !== true,
304
+ disabled: (item == null ? void 0 : item.subscribed) !== true
305
+ }
306
+ )
307
+ ]
308
+ }
309
+ );
310
+ };
311
+ var ColumnList = ({
312
+ columnItems,
313
+ onChange,
314
+ onMoveListItem,
315
+ ...htmlAttributes
316
+ }) => {
317
+ const handleChange = useCallback(
318
+ (evt) => {
319
+ const input = evt.target;
320
+ const listItem = input.closest(`.${classBaseListItem}`);
321
+ const {
322
+ dataset: { name: name2 }
323
+ } = listItem;
324
+ if (name2) {
325
+ const saltSwitch = input.closest(`.${classBase4}-switch`);
326
+ const saltCheckbox = input.closest(
327
+ `.${classBase4}-checkBox`
328
+ );
329
+ if (saltSwitch) {
330
+ onChange(name2, "subscribed", input.checked);
331
+ } else if (saltCheckbox) {
332
+ onChange(name2, "hidden", input.checked === false);
333
+ }
334
+ }
335
+ },
336
+ [onChange]
337
+ );
338
+ return /* @__PURE__ */ jsxs4("div", { ...htmlAttributes, className: classBase4, children: [
339
+ /* @__PURE__ */ jsx4("div", { className: `${classBase4}-header`, children: /* @__PURE__ */ jsx4("span", { children: "Column Selection" }) }),
340
+ /* @__PURE__ */ jsxs4("div", { className: `${classBase4}-colHeadings`, children: [
341
+ /* @__PURE__ */ jsx4("span", { children: "Column subscription" }),
342
+ /* @__PURE__ */ jsx4("span", { children: "Visibility" })
343
+ ] }),
344
+ /* @__PURE__ */ jsx4(
345
+ List,
346
+ {
347
+ ListItem: ColumnListItem,
348
+ allowDragDrop: true,
349
+ height: "100%",
350
+ onChange: handleChange,
351
+ onMoveListItem,
352
+ selectionStrategy: "none",
353
+ source: columnItems,
354
+ itemHeight: 33
355
+ }
356
+ )
357
+ ] });
358
+ };
359
+
360
+ // src/column-settings/ColumnSettingsPanel.tsx
361
+ import { getDefaultAlignment, isCalculatedColumn } from "@vuu-ui/vuu-utils";
362
+ import {
363
+ Button as Button2,
364
+ FormField as FormField4,
365
+ FormFieldLabel as FormFieldLabel4,
366
+ ToggleButton,
367
+ ToggleButtonGroup
368
+ } from "@salt-ds/core";
369
+
370
+ // src/column-formatting-settings/ColumnFormattingPanel.tsx
371
+ import { Dropdown } from "@vuu-ui/vuu-ui-controls";
372
+ import { FormField as FormField2, FormFieldLabel as FormFieldLabel2 } from "@salt-ds/core";
373
+ import cx5 from "classnames";
374
+ import { useMemo } from "react";
375
+
376
+ // src/column-formatting-settings/NumericFormattingSettings.tsx
377
+ import { FormField, FormFieldLabel, Input } from "@salt-ds/core";
378
+ import { Switch as Switch2 } from "@salt-ds/lab";
379
+ import { getTypeSettingsFromColumn } from "@vuu-ui/vuu-utils";
380
+ import {
381
+ useCallback as useCallback2,
382
+ useState
383
+ } from "react";
384
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
385
+ var classBase5 = "vuuFormattingSettings";
386
+ var NumericFormattingSettings = ({
387
+ column,
388
+ onChange
389
+ }) => {
390
+ var _a;
391
+ const [formattingSettings, setFormattingSettings] = useState(
392
+ getTypeSettingsFromColumn(column)
393
+ );
394
+ const handleInputKeyDown = useCallback2(
395
+ (evt) => {
396
+ if (evt.key === "Enter" || evt.key === "Tab") {
397
+ onChange(formattingSettings);
398
+ }
399
+ },
400
+ [formattingSettings, onChange]
401
+ );
402
+ const handleChangeDecimals = useCallback2(
403
+ (evt) => {
404
+ const { value } = evt.target;
405
+ const numericValue = value === "" ? void 0 : isNaN(parseInt(value)) ? void 0 : parseInt(value);
406
+ const newFormattingSettings = {
407
+ ...formattingSettings,
408
+ decimals: numericValue
409
+ };
410
+ setFormattingSettings(newFormattingSettings);
411
+ },
412
+ [formattingSettings]
413
+ );
414
+ const handleChangeAlignDecimals = useCallback2(
415
+ (evt) => {
416
+ const { checked } = evt.target;
417
+ const newFormattingSettings = {
418
+ ...formattingSettings,
419
+ alignOnDecimals: checked
420
+ };
421
+ setFormattingSettings(newFormattingSettings);
422
+ onChange(newFormattingSettings);
423
+ },
424
+ [formattingSettings, onChange]
425
+ );
426
+ const handleChangeZeroPad = useCallback2(
427
+ (evt) => {
428
+ const { checked } = evt.target;
429
+ const newFormattingSettings = {
430
+ ...formattingSettings,
431
+ zeroPad: checked
432
+ };
433
+ setFormattingSettings(newFormattingSettings);
434
+ onChange(newFormattingSettings);
435
+ },
436
+ [formattingSettings, onChange]
437
+ );
438
+ return /* @__PURE__ */ jsxs5("div", { className: classBase5, children: [
439
+ /* @__PURE__ */ jsxs5(FormField, { "data-field": "decimals", children: [
440
+ /* @__PURE__ */ jsx5(FormFieldLabel, { children: "Number of decimals" }),
441
+ /* @__PURE__ */ jsx5(
442
+ Input,
443
+ {
444
+ className: "vuuInput",
445
+ onChange: handleChangeDecimals,
446
+ onKeyDown: handleInputKeyDown,
447
+ value: (_a = formattingSettings.decimals) != null ? _a : ""
448
+ }
449
+ )
450
+ ] }),
451
+ /* @__PURE__ */ jsxs5(FormField, { labelPlacement: "left", children: [
452
+ /* @__PURE__ */ jsx5(FormFieldLabel, { children: "Align on decimals" }),
453
+ /* @__PURE__ */ jsx5(
454
+ Switch2,
455
+ {
456
+ checked: formattingSettings.alignOnDecimals,
457
+ onChange: handleChangeAlignDecimals,
458
+ value: "align-decimals"
459
+ }
460
+ )
461
+ ] }),
462
+ /* @__PURE__ */ jsxs5(FormField, { labelPlacement: "left", children: [
463
+ /* @__PURE__ */ jsx5(FormFieldLabel, { children: "Zero pad decimals" }),
464
+ /* @__PURE__ */ jsx5(
465
+ Switch2,
466
+ {
467
+ checked: formattingSettings.zeroPad,
468
+ onChange: handleChangeZeroPad,
469
+ value: "zero-pad"
470
+ }
471
+ )
472
+ ] })
473
+ ] });
474
+ };
475
+
476
+ // src/column-formatting-settings/ColumnFormattingPanel.tsx
477
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
478
+ var classBase6 = "vuuColumnFormattingPanel";
479
+ var itemToString = (item) => {
480
+ var _a;
481
+ return (_a = item.label) != null ? _a : item.name;
482
+ };
483
+ var ColumnFormattingPanel = ({
484
+ availableRenderers,
485
+ selectedCellRenderer,
486
+ className,
487
+ column,
488
+ onChangeFormatting,
489
+ onChangeRenderer,
490
+ ...htmlAttributes
491
+ }) => {
492
+ const content = useMemo(() => {
493
+ switch (column.serverDataType) {
494
+ case "double":
495
+ case "int":
496
+ case "long":
497
+ return /* @__PURE__ */ jsx6(
498
+ NumericFormattingSettings,
499
+ {
500
+ column,
501
+ onChange: onChangeFormatting
502
+ }
503
+ );
504
+ default:
505
+ return null;
506
+ }
507
+ }, [column, onChangeFormatting]);
508
+ const { serverDataType = "string" } = column;
509
+ return /* @__PURE__ */ jsxs6("div", { ...htmlAttributes, className: `vuuColumnSettingsPanel-header`, children: [
510
+ /* @__PURE__ */ jsx6("div", { children: "Formatting" }),
511
+ /* @__PURE__ */ jsxs6(FormField2, { children: [
512
+ /* @__PURE__ */ jsx6(FormFieldLabel2, { children: "Renderer" }),
513
+ /* @__PURE__ */ jsx6(
514
+ Dropdown,
515
+ {
516
+ className: cx5(`${classBase6}-renderer`),
517
+ itemToString,
518
+ onSelectionChange: onChangeRenderer,
519
+ selected: selectedCellRenderer,
520
+ source: availableRenderers,
521
+ width: "100%"
522
+ }
523
+ )
524
+ ] }),
525
+ /* @__PURE__ */ jsx6(
526
+ "div",
527
+ {
528
+ className: cx5(classBase6, className, `${classBase6}-${serverDataType}`),
529
+ children: content
530
+ }
531
+ )
532
+ ] });
533
+ };
534
+
535
+ // src/column-settings/useColumnSettings.ts
536
+ import {
537
+ getRegisteredCellRenderers,
538
+ isColumnTypeRenderer as isColumnTypeRenderer2,
539
+ isTypeDescriptor as isTypeDescriptor6,
540
+ isValidColumnAlignment,
541
+ isValidPinLocation,
542
+ setCalculatedColumnName,
543
+ updateColumnRenderer,
544
+ updateColumnType
545
+ } from "@vuu-ui/vuu-utils";
546
+ import {
547
+ useCallback as useCallback3,
548
+ useMemo as useMemo2,
549
+ useRef as useRef3,
550
+ useState as useState2
551
+ } from "react";
552
+ var integerCellRenderers = [
553
+ {
554
+ description: "Default formatter for columns with data type integer",
555
+ label: "Default Renderer (data type int, long)",
556
+ name: "default-int"
557
+ }
558
+ ];
559
+ var doubleCellRenderers = [
560
+ {
561
+ description: "Default formatter for columns with data type double",
562
+ label: "Default Renderer (data type double)",
563
+ name: "default-double"
564
+ },
565
+ ...getRegisteredCellRenderers("double")
566
+ ];
567
+ var stringCellRenderers = [
568
+ {
569
+ description: "Default formatter for columns with data type string",
570
+ label: "Default Renderer (data type string)",
571
+ name: "default-string"
572
+ }
573
+ ];
574
+ var getAvailableCellRenderers = (column) => {
575
+ switch (column.serverDataType) {
576
+ case "char":
577
+ case "string":
578
+ return stringCellRenderers;
579
+ case "int":
580
+ case "long":
581
+ return integerCellRenderers;
582
+ case "double":
583
+ return doubleCellRenderers;
584
+ default:
585
+ return stringCellRenderers;
586
+ }
587
+ };
588
+ var getCellRendererDescriptor = (availableRenderers, column) => {
589
+ if (isTypeDescriptor6(column.type)) {
590
+ const { renderer } = column.type;
591
+ if (isColumnTypeRenderer2(renderer)) {
592
+ const cellRenderer = availableRenderers.find(
593
+ (r) => r.name === renderer.name
594
+ );
595
+ if (cellRenderer) {
596
+ return cellRenderer;
597
+ }
598
+ }
599
+ }
600
+ const typedAvailableRenderers = getAvailableCellRenderers(column);
601
+ return typedAvailableRenderers[0];
602
+ };
603
+ var getFieldName = (input) => {
604
+ const saltFormField = input.closest(".saltFormField");
605
+ if (saltFormField && saltFormField.dataset.field) {
606
+ const {
607
+ dataset: { field }
608
+ } = saltFormField;
609
+ return field;
610
+ } else {
611
+ throw Error("named form field not found");
612
+ }
613
+ };
614
+ var getColumn = (columns, column) => {
615
+ if (column.name === "::") {
616
+ return column;
617
+ } else {
618
+ const col = columns.find((col2) => col2.name === column.name);
619
+ if (col) {
620
+ return col;
621
+ }
622
+ throw Error(`columns does not contain column ${name}`);
623
+ }
624
+ };
625
+ var replaceColumn = (tableConfig, column) => ({
626
+ ...tableConfig,
627
+ columns: tableConfig.columns.map(
628
+ (col) => col.name === column.name ? column : col
629
+ )
630
+ });
631
+ var useColumnSettings = ({
632
+ column: columnProp,
633
+ onConfigChange,
634
+ onCreateCalculatedColumn,
635
+ tableConfig
636
+ }) => {
637
+ const [column, setColumn] = useState2(
638
+ getColumn(tableConfig.columns, columnProp)
639
+ );
640
+ const availableRenderers = useMemo2(() => {
641
+ return getAvailableCellRenderers(column);
642
+ }, [column]);
643
+ const selectedCellRendererRef = useRef3(
644
+ getCellRendererDescriptor(availableRenderers, column)
645
+ );
646
+ const handleInputCommit = useCallback3(() => {
647
+ onConfigChange(replaceColumn(tableConfig, column));
648
+ }, [column, onConfigChange, tableConfig]);
649
+ const handleChange = useCallback3(
650
+ (evt) => {
651
+ const input = evt.target;
652
+ const fieldName = getFieldName(input);
653
+ const { value } = input;
654
+ switch (fieldName) {
655
+ case "column-label":
656
+ setColumn((state) => ({ ...state, label: value }));
657
+ break;
658
+ case "column-name":
659
+ setColumn((state) => setCalculatedColumnName(state, value));
660
+ break;
661
+ case "column-width":
662
+ setColumn((state) => ({ ...state, width: parseInt(value) }));
663
+ break;
664
+ case "column-alignment":
665
+ if (isValidColumnAlignment(value)) {
666
+ const newColumn = {
667
+ ...column,
668
+ align: value || void 0
669
+ };
670
+ setColumn(newColumn);
671
+ onConfigChange(replaceColumn(tableConfig, newColumn));
672
+ }
673
+ break;
674
+ case "column-pin":
675
+ if (isValidPinLocation(value)) {
676
+ const newColumn = {
677
+ ...column,
678
+ pin: value || void 0
679
+ };
680
+ setColumn(newColumn);
681
+ onConfigChange(replaceColumn(tableConfig, newColumn));
682
+ break;
683
+ }
684
+ }
685
+ },
686
+ [column, onConfigChange, tableConfig]
687
+ );
688
+ const handleChangeRenderer = useCallback3(
689
+ (evt, cellRenderer) => {
690
+ if (cellRenderer) {
691
+ const newColumn = updateColumnRenderer(
692
+ column,
693
+ cellRenderer
694
+ );
695
+ selectedCellRendererRef.current = cellRenderer;
696
+ setColumn(newColumn);
697
+ onConfigChange(replaceColumn(tableConfig, newColumn));
698
+ }
699
+ },
700
+ [column, onConfigChange, tableConfig]
701
+ );
702
+ const handleChangeFormatting = useCallback3(
703
+ (formatting) => {
704
+ const newColumn = updateColumnType(column, formatting);
705
+ setColumn(newColumn);
706
+ onConfigChange(replaceColumn(tableConfig, newColumn));
707
+ },
708
+ [column, onConfigChange, tableConfig]
709
+ );
710
+ const navigateColumn = useCallback3(
711
+ ({ moveBy }) => {
712
+ const { columns } = tableConfig;
713
+ const index = columns.indexOf(column) + moveBy;
714
+ const newColumn = columns[index];
715
+ if (newColumn) {
716
+ selectedCellRendererRef.current = getCellRendererDescriptor(
717
+ availableRenderers,
718
+ newColumn
719
+ );
720
+ setColumn(newColumn);
721
+ }
722
+ },
723
+ [availableRenderers, column, tableConfig]
724
+ );
725
+ const navigateNextColumn = useCallback3(() => {
726
+ navigateColumn({ moveBy: 1 });
727
+ }, [navigateColumn]);
728
+ const navigatePrevColumn = useCallback3(() => {
729
+ navigateColumn({ moveBy: -1 });
730
+ }, [navigateColumn]);
731
+ const handleSaveCalculatedColumn = useCallback3(
732
+ (calculatedColumn) => {
733
+ onCreateCalculatedColumn({
734
+ ...column,
735
+ ...calculatedColumn
736
+ });
737
+ },
738
+ [column, onCreateCalculatedColumn]
739
+ );
740
+ return {
741
+ availableRenderers,
742
+ selectedCellRenderer: selectedCellRendererRef.current,
743
+ column,
744
+ navigateNextColumn,
745
+ navigatePrevColumn,
746
+ onChange: handleChange,
747
+ onChangeFormatting: handleChangeFormatting,
748
+ onChangeRenderer: handleChangeRenderer,
749
+ onInputCommit: handleInputCommit,
750
+ onSave: handleSaveCalculatedColumn
751
+ };
752
+ };
753
+
754
+ // src/column-expression-panel/ColumnExpressionPanel.tsx
755
+ import { Dropdown as Dropdown2 } from "@vuu-ui/vuu-ui-controls";
756
+ import {
757
+ getCalculatedColumnExpression,
758
+ getCalculatedColumnName,
759
+ getCalculatedColumnType
760
+ } from "@vuu-ui/vuu-utils";
761
+ import { Button, FormField as FormField3, FormFieldLabel as FormFieldLabel3, Input as Input2 } from "@salt-ds/core";
762
+ import { useCallback as useCallback7, useRef as useRef7 } from "react";
763
+
764
+ // src/column-expression-input/useColumnExpressionEditor.ts
765
+ import {
766
+ autocompletion,
767
+ defaultKeymap,
768
+ EditorState as EditorState2,
769
+ EditorView as EditorView2,
770
+ ensureSyntaxTree,
771
+ keymap,
772
+ minimalSetup,
773
+ startCompletion
774
+ } from "@vuu-ui/vuu-codemirror";
775
+ import { createEl } from "@vuu-ui/vuu-utils";
776
+ import { useEffect as useEffect3, useMemo as useMemo3, useRef as useRef4 } from "react";
777
+
778
+ // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
779
+ import {
780
+ LanguageSupport,
781
+ LRLanguage,
782
+ styleTags,
783
+ tags as tag
784
+ } from "@vuu-ui/vuu-codemirror";
785
+
786
+ // src/column-expression-input/column-language-parser/generated/column-parser.js
787
+ import { LRParser } from "@lezer/lr";
788
+ var parser = LRParser.deserialize({
789
+ version: 14,
790
+ states: "&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",
791
+ stateData: ")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",
792
+ goto: "#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",
793
+ nodeNames: "\u26A0 ColumnDefinitionExpression Column Number String True False ParenthesizedExpression OpenBrace CloseBrace ArithmeticExpression Divide Times Plus Minus ConditionalExpression If RelationalExpression RelationalOperator AndCondition OrCondition Comma CallExpression Function ArgList",
794
+ maxTerm: 39,
795
+ skippedNodes: [0],
796
+ repeatNodeCount: 1,
797
+ tokenData: ".^~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$jz{$o{|$t|}$y}!O%O!O!P%T!P!Q%c!Q![%h!^!_%s!_!`&Q!`!a&V!c!}&d#R#S&d#T#U&u#U#Y&d#Y#Z(Y#Z#]&d#]#^*j#^#c&d#c#d+f#d#h&d#h#i,b#i#o&d~#USl~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOu~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_OS~~$bP;=`<%l#m~$jOW~~$oOX~~$tO[~~$yO]~~%OOe~~%TO^~~%WP!Q![%Z~%`PR~!Q![%Z~%hOZ~~%mQR~!O!P%Z!Q![%h~%xPr~!_!`%{~&QOt~~&VOp~~&[Pq~!_!`&_~&dOs~P&iSnP!Q![&d!c!}&d#R#S&d#T#o&dR&zUnP!Q![&d!c!}&d#R#S&d#T#b&d#b#c'^#c#o&dR'cUnP!Q![&d!c!}&d#R#S&d#T#W&d#W#X'u#X#o&dR'|SvQnP!Q![&d!c!}&d#R#S&d#T#o&d~(_TnP!Q![&d!c!}&d#R#S&d#T#U(n#U#o&d~(sUnP!Q![&d!c!}&d#R#S&d#T#`&d#`#a)V#a#o&d~)[UnP!Q![&d!c!}&d#R#S&d#T#g&d#g#h)n#h#o&d~)sUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y*V#Y#o&d~*^SU~nP!Q![&d!c!}&d#R#S&d#T#o&d~*oUnP!Q![&d!c!}&d#R#S&d#T#Y&d#Y#Z+R#Z#o&d~+YS`~nP!Q![&d!c!}&d#R#S&d#T#o&dR+kUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g+}#g#o&dR,USwQnP!Q![&d!c!}&d#R#S&d#T#o&d~,gUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g,y#g#o&d~-OUnP!Q![&d!c!}&d#R#S&d#T#i&d#i#j-b#j#o&d~-gUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y-y#Y#o&d~.QST~nP!Q![&d!c!}&d#R#S&d#T#o&d",
798
+ tokenizers: [0, 1],
799
+ topRules: { "ColumnDefinitionExpression": [0, 1] },
800
+ tokenPrec: 375
801
+ });
802
+
803
+ // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
804
+ var columnExpressionLanguage = LRLanguage.define({
805
+ name: "VuuColumnExpression",
806
+ parser: parser.configure({
807
+ props: [
808
+ styleTags({
809
+ Function: tag.variableName,
810
+ String: tag.string,
811
+ Or: tag.emphasis,
812
+ Operator: tag.operator
813
+ })
814
+ ]
815
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
816
+ })
817
+ });
818
+ var columnExpressionLanguageSupport = () => {
819
+ return new LanguageSupport(
820
+ columnExpressionLanguage
821
+ /*, [exampleCompletion]*/
822
+ );
823
+ };
824
+
825
+ // src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.ts
826
+ var LiteralExpressionImpl = class {
827
+ constructor(value) {
828
+ this.value = value;
829
+ switch (typeof value) {
830
+ case "boolean":
831
+ this.type = "booleanLiteralExpression";
832
+ break;
833
+ case "number":
834
+ this.type = "numericLiteralExpression";
835
+ break;
836
+ default:
837
+ this.type = "stringLiteralExpression";
838
+ }
839
+ }
840
+ toJSON() {
841
+ return {
842
+ type: this.type,
843
+ value: this.value
844
+ };
845
+ }
846
+ };
847
+ var ColumnExpressionImpl = class {
848
+ constructor(columnName) {
849
+ this.type = "colExpression";
850
+ this.column = columnName;
851
+ }
852
+ toJSON() {
853
+ return {
854
+ type: this.type,
855
+ column: this.column
856
+ };
857
+ }
858
+ };
859
+ var _expressions, _op;
860
+ var ArithmeticExpressionImpl = class {
861
+ constructor(op = "unknown") {
862
+ __privateAdd(this, _expressions, [
863
+ { type: "unknown" },
864
+ { type: "unknown" }
865
+ ]);
866
+ __privateAdd(this, _op, void 0);
867
+ this.type = "arithmeticExpression";
868
+ __privateSet(this, _op, op);
869
+ }
870
+ get op() {
871
+ return __privateGet(this, _op);
872
+ }
873
+ set op(op) {
874
+ __privateSet(this, _op, op);
875
+ }
876
+ get expressions() {
877
+ return __privateGet(this, _expressions);
878
+ }
879
+ toJSON() {
880
+ return {
881
+ type: this.type,
882
+ op: __privateGet(this, _op),
883
+ expressions: __privateGet(this, _expressions)
884
+ };
885
+ }
886
+ };
887
+ _expressions = new WeakMap();
888
+ _op = new WeakMap();
889
+ var _expressions2;
890
+ var CallExpressionImpl = class {
891
+ constructor(functionName) {
892
+ __privateAdd(this, _expressions2, []);
893
+ this.type = "callExpression";
894
+ this.functionName = functionName;
895
+ }
896
+ get expressions() {
897
+ return __privateGet(this, _expressions2);
898
+ }
899
+ get arguments() {
900
+ return __privateGet(this, _expressions2);
901
+ }
902
+ toJSON() {
903
+ return {
904
+ type: this.type,
905
+ functionName: this.functionName,
906
+ arguments: __privateGet(this, _expressions2).map((e) => {
907
+ var _a;
908
+ return (_a = e.toJSON) == null ? void 0 : _a.call(e);
909
+ })
910
+ };
911
+ }
912
+ };
913
+ _expressions2 = new WeakMap();
914
+ var _expressions3, _op2;
915
+ var RelationalExpressionImpl = class {
916
+ constructor() {
917
+ __privateAdd(this, _expressions3, [
918
+ { type: "unknown" },
919
+ { type: "unknown" }
920
+ ]);
921
+ __privateAdd(this, _op2, "unknown");
922
+ this.type = "relationalExpression";
923
+ }
924
+ get op() {
925
+ return __privateGet(this, _op2);
926
+ }
927
+ set op(op) {
928
+ __privateSet(this, _op2, op);
929
+ }
930
+ get expressions() {
931
+ return __privateGet(this, _expressions3);
932
+ }
933
+ toJSON() {
934
+ return {
935
+ type: this.type,
936
+ op: __privateGet(this, _op2),
937
+ expressions: __privateGet(this, _expressions3)
938
+ };
939
+ }
940
+ };
941
+ _expressions3 = new WeakMap();
942
+ _op2 = new WeakMap();
943
+ var _expressions4, _op3;
944
+ var BooleanConditionImp = class {
945
+ constructor(booleanOperator) {
946
+ __privateAdd(this, _expressions4, [
947
+ { type: "unknown" },
948
+ { type: "unknown" }
949
+ ]);
950
+ __privateAdd(this, _op3, void 0);
951
+ this.type = "booleanCondition";
952
+ __privateSet(this, _op3, booleanOperator);
953
+ }
954
+ get op() {
955
+ return __privateGet(this, _op3);
956
+ }
957
+ get expressions() {
958
+ return __privateGet(this, _expressions4);
959
+ }
960
+ toJSON() {
961
+ return {
962
+ type: this.type,
963
+ op: __privateGet(this, _op3),
964
+ expressions: __privateGet(this, _expressions4).map((e) => {
965
+ var _a;
966
+ return (_a = e.toJSON) == null ? void 0 : _a.call(e);
967
+ })
968
+ };
969
+ }
970
+ };
971
+ _expressions4 = new WeakMap();
972
+ _op3 = new WeakMap();
973
+ var _expressions5;
974
+ var ConditionalExpressionImpl = class {
975
+ constructor(booleanOperator) {
976
+ __privateAdd(this, _expressions5, void 0);
977
+ this.type = "conditionalExpression";
978
+ __privateSet(this, _expressions5, [
979
+ booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
980
+ { type: "unknown" },
981
+ { type: "unknown" }
982
+ ]);
983
+ }
984
+ get expressions() {
985
+ return __privateGet(this, _expressions5);
986
+ }
987
+ get condition() {
988
+ return __privateGet(this, _expressions5)[0];
989
+ }
990
+ get truthyExpression() {
991
+ return __privateGet(this, _expressions5)[1];
992
+ }
993
+ set truthyExpression(expression) {
994
+ __privateGet(this, _expressions5)[1] = expression;
995
+ }
996
+ get falsyExpression() {
997
+ return __privateGet(this, _expressions5)[2];
998
+ }
999
+ set falsyExpression(expression) {
1000
+ __privateGet(this, _expressions5)[2] = expression;
1001
+ }
1002
+ toJSON() {
1003
+ var _a, _b, _c, _d, _e;
1004
+ return {
1005
+ type: this.type,
1006
+ condition: (_b = (_a = this.condition).toJSON) == null ? void 0 : _b.call(_a),
1007
+ truthyExpression: this.truthyExpression,
1008
+ falsyExpression: (_e = (_d = (_c = this.falsyExpression) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c)) != null ? _e : this.falsyExpression
1009
+ };
1010
+ }
1011
+ };
1012
+ _expressions5 = new WeakMap();
1013
+ var isUnknown = (e) => e.type === "unknown";
1014
+ var isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
1015
+ var isCallExpression = (expression) => expression.type === "callExpression";
1016
+ var isConditionalExpression = (expression) => expression.type === "conditionalExpression";
1017
+ var isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
1018
+ var isBooleanCondition = (expression) => expression.type === "booleanCondition";
1019
+ var isRelationalExpression = (expression) => (expression == null ? void 0 : expression.type) === "relationalExpression";
1020
+ var firstIncompleteExpression = (expression) => {
1021
+ if (isUnknown(expression)) {
1022
+ return expression;
1023
+ } else if (isRelationalExpression(expression)) {
1024
+ const [operand1, operand2] = expression.expressions;
1025
+ if (expressionIsIncomplete(operand1)) {
1026
+ return firstIncompleteExpression(operand1);
1027
+ } else if (expression.op === "unknown") {
1028
+ return expression;
1029
+ } else if (expressionIsIncomplete(operand2)) {
1030
+ return firstIncompleteExpression(operand2);
1031
+ }
1032
+ } else if (isCondition(expression)) {
1033
+ const { expressions = [] } = expression;
1034
+ for (const e of expressions) {
1035
+ if (expressionIsIncomplete(e)) {
1036
+ return firstIncompleteExpression(e);
1037
+ }
1038
+ }
1039
+ } else if (isConditionalExpression(expression)) {
1040
+ const { condition, truthyExpression, falsyExpression } = expression;
1041
+ if (expressionIsIncomplete(condition)) {
1042
+ return firstIncompleteExpression(condition);
1043
+ } else if (expressionIsIncomplete(truthyExpression)) {
1044
+ return firstIncompleteExpression(truthyExpression);
1045
+ } else if (expressionIsIncomplete(falsyExpression)) {
1046
+ return firstIncompleteExpression(falsyExpression);
1047
+ }
1048
+ } else if (isArithmeticExpression(expression)) {
1049
+ const { expressions = [] } = expression;
1050
+ for (const e of expressions) {
1051
+ if (expressionIsIncomplete(e)) {
1052
+ return firstIncompleteExpression(e);
1053
+ }
1054
+ }
1055
+ }
1056
+ };
1057
+ var replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
1058
+ const { expressions = [] } = incompleteExpression;
1059
+ if (expressions.includes(unknownExpression)) {
1060
+ const pos = expressions.indexOf(unknownExpression);
1061
+ expressions.splice(pos, 1, expression);
1062
+ return true;
1063
+ } else {
1064
+ for (const e of expressions) {
1065
+ if (replaceUnknownExpression(e, unknownExpression, expression)) {
1066
+ return true;
1067
+ }
1068
+ }
1069
+ }
1070
+ return false;
1071
+ };
1072
+ var expressionIsIncomplete = (expression) => {
1073
+ if (isUnknown(expression)) {
1074
+ return true;
1075
+ } else if (isConditionalExpression(expression)) {
1076
+ return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
1077
+ } else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
1078
+ return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
1079
+ }
1080
+ return false;
1081
+ };
1082
+ var addExpression = (expression, subExpression) => {
1083
+ const targetExpression = firstIncompleteExpression(expression);
1084
+ if (targetExpression) {
1085
+ if (targetExpression.expressions) {
1086
+ targetExpression.expressions.push(subExpression);
1087
+ } else {
1088
+ console.warn("don't know how to treat targetExpression");
1089
+ }
1090
+ } else {
1091
+ console.error("no target expression found");
1092
+ }
1093
+ };
1094
+ var _expression, _callStack;
1095
+ var ColumnExpression = class {
1096
+ constructor() {
1097
+ __privateAdd(this, _expression, void 0);
1098
+ __privateAdd(this, _callStack, []);
1099
+ }
1100
+ setCondition(booleanOperator) {
1101
+ if (__privateGet(this, _expression) === void 0) {
1102
+ this.addExpression(new ConditionalExpressionImpl(booleanOperator));
1103
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
1104
+ if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
1105
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
1106
+ this.addExpression(condition);
1107
+ } else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
1108
+ __privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
1109
+ booleanOperator
1110
+ );
1111
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
1112
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
1113
+ this.addExpression(condition);
1114
+ } else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
1115
+ __privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
1116
+ booleanOperator
1117
+ );
1118
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
1119
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
1120
+ this.addExpression(condition);
1121
+ }
1122
+ } else {
1123
+ console.error("setCondition called unexpectedly");
1124
+ }
1125
+ }
1126
+ addExpression(expression) {
1127
+ if (__privateGet(this, _callStack).length > 0) {
1128
+ const currentCallExpression = __privateGet(this, _callStack).at(-1);
1129
+ currentCallExpression == null ? void 0 : currentCallExpression.arguments.push(expression);
1130
+ } else if (__privateGet(this, _expression) === void 0) {
1131
+ __privateSet(this, _expression, expression);
1132
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
1133
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1134
+ if (targetExpression && isUnknown(targetExpression)) {
1135
+ replaceUnknownExpression(
1136
+ __privateGet(this, _expression),
1137
+ targetExpression,
1138
+ expression
1139
+ );
1140
+ }
1141
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
1142
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
1143
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1144
+ if (targetExpression && isUnknown(targetExpression)) {
1145
+ replaceUnknownExpression(
1146
+ __privateGet(this, _expression),
1147
+ targetExpression,
1148
+ expression
1149
+ );
1150
+ } else if (targetExpression) {
1151
+ addExpression(targetExpression, expression);
1152
+ }
1153
+ }
1154
+ }
1155
+ }
1156
+ setFunction(functionName) {
1157
+ const callExpression = new CallExpressionImpl(functionName);
1158
+ this.addExpression(callExpression);
1159
+ __privateGet(this, _callStack).push(callExpression);
1160
+ }
1161
+ setColumn(columnName) {
1162
+ this.addExpression(new ColumnExpressionImpl(columnName));
1163
+ }
1164
+ setArithmeticOp(value) {
1165
+ const op = value;
1166
+ const expression = __privateGet(this, _expression);
1167
+ if (isArithmeticExpression(expression)) {
1168
+ expression.op = op;
1169
+ }
1170
+ }
1171
+ setRelationalOperator(value) {
1172
+ const op = value;
1173
+ if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
1174
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1175
+ if (isRelationalExpression(targetExpression)) {
1176
+ targetExpression.op = op;
1177
+ } else {
1178
+ console.error(`no target expression found (op = ${value})`);
1179
+ }
1180
+ }
1181
+ }
1182
+ setValue(value) {
1183
+ const literalExpression = new LiteralExpressionImpl(value);
1184
+ if (__privateGet(this, _expression) === void 0) {
1185
+ __privateSet(this, _expression, literalExpression);
1186
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
1187
+ this.addExpression(literalExpression);
1188
+ } else if (isCallExpression(__privateGet(this, _expression))) {
1189
+ __privateGet(this, _expression).arguments.push(literalExpression);
1190
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
1191
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
1192
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1193
+ if (targetExpression && isUnknown(targetExpression)) {
1194
+ replaceUnknownExpression(
1195
+ __privateGet(this, _expression),
1196
+ targetExpression,
1197
+ literalExpression
1198
+ );
1199
+ } else if (targetExpression) {
1200
+ addExpression(targetExpression, literalExpression);
1201
+ }
1202
+ } else {
1203
+ console.log("what do we do with value, in a complete expression");
1204
+ }
1205
+ }
1206
+ }
1207
+ closeBrace() {
1208
+ __privateGet(this, _callStack).pop();
1209
+ }
1210
+ get expression() {
1211
+ return __privateGet(this, _expression);
1212
+ }
1213
+ toJSON() {
1214
+ var _a;
1215
+ return (_a = __privateGet(this, _expression)) == null ? void 0 : _a.toJSON();
1216
+ }
1217
+ };
1218
+ _expression = new WeakMap();
1219
+ _callStack = new WeakMap();
1220
+ var walkTree = (tree, source) => {
1221
+ const columnExpression = new ColumnExpression();
1222
+ const cursor = tree.cursor();
1223
+ do {
1224
+ const { name: name2, from, to } = cursor;
1225
+ switch (name2) {
1226
+ case "AndCondition":
1227
+ columnExpression.setCondition("and");
1228
+ break;
1229
+ case "OrCondition":
1230
+ columnExpression.setCondition("or");
1231
+ break;
1232
+ case "RelationalExpression":
1233
+ columnExpression.setCondition();
1234
+ break;
1235
+ case "ArithmeticExpression":
1236
+ columnExpression.addExpression(new ArithmeticExpressionImpl());
1237
+ break;
1238
+ case "Column":
1239
+ {
1240
+ const columnName = source.substring(from, to);
1241
+ columnExpression.setColumn(columnName);
1242
+ }
1243
+ break;
1244
+ case "Function":
1245
+ {
1246
+ const functionName = source.substring(from, to);
1247
+ columnExpression.setFunction(functionName);
1248
+ }
1249
+ break;
1250
+ case "Times":
1251
+ case "Divide":
1252
+ case "Plus":
1253
+ case "Minus":
1254
+ {
1255
+ const op = source.substring(from, to);
1256
+ columnExpression.setArithmeticOp(op);
1257
+ }
1258
+ break;
1259
+ case "RelationalOperator":
1260
+ {
1261
+ const op = source.substring(from, to);
1262
+ columnExpression.setRelationalOperator(op);
1263
+ }
1264
+ break;
1265
+ case "False":
1266
+ case "True":
1267
+ {
1268
+ const value = source.substring(from, to);
1269
+ columnExpression.setValue(value === "true" ? true : false);
1270
+ }
1271
+ break;
1272
+ case "String":
1273
+ columnExpression.setValue(source.substring(from + 1, to - 1));
1274
+ break;
1275
+ case "Number":
1276
+ columnExpression.setValue(parseFloat(source.substring(from, to)));
1277
+ break;
1278
+ case "CloseBrace":
1279
+ columnExpression.closeBrace();
1280
+ break;
1281
+ default:
1282
+ }
1283
+ } while (cursor.next());
1284
+ return columnExpression.toJSON();
1285
+ };
1286
+
1287
+ // src/column-expression-input/column-language-parser/column-expression-parse-utils.ts
1288
+ var strictParser = parser.configure({ strict: true });
1289
+ var RelationalOperands = ["Number", "String"];
1290
+ var ColumnNamedTerms = [
1291
+ ...RelationalOperands,
1292
+ "AndCondition",
1293
+ "ArithmeticExpression",
1294
+ "BooleanOperator",
1295
+ "RelationalOperatorOperator",
1296
+ "CallExpression",
1297
+ "CloseBrace",
1298
+ "Column",
1299
+ "Comma",
1300
+ "ConditionalExpression",
1301
+ "Divide",
1302
+ "Equal",
1303
+ "If",
1304
+ "Minus",
1305
+ "OpenBrace",
1306
+ "OrCondition",
1307
+ "ParenthesizedExpression",
1308
+ "Plus",
1309
+ "RelationalExpression",
1310
+ "RelationalOperator",
1311
+ "Times"
1312
+ ];
1313
+ var isCompleteExpression = (src) => {
1314
+ try {
1315
+ strictParser.parse(src);
1316
+ return true;
1317
+ } catch (err) {
1318
+ return false;
1319
+ }
1320
+ };
1321
+ var lastNamedChild = (node) => {
1322
+ let { lastChild } = node;
1323
+ while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
1324
+ lastChild = lastChild.prevSibling;
1325
+ console.log(lastChild == null ? void 0 : lastChild.name);
1326
+ }
1327
+ return lastChild;
1328
+ };
1329
+ var isCompleteRelationalExpression = (node) => {
1330
+ if ((node == null ? void 0 : node.name) === "RelationalExpression") {
1331
+ const { firstChild } = node;
1332
+ const lastChild = lastNamedChild(node);
1333
+ if ((firstChild == null ? void 0 : firstChild.name) === "Column" && typeof (lastChild == null ? void 0 : lastChild.name) === "string" && RelationalOperands.includes(lastChild.name)) {
1334
+ return true;
1335
+ }
1336
+ }
1337
+ return false;
1338
+ };
1339
+
1340
+ // src/column-expression-input/highlighting.ts
1341
+ import {
1342
+ HighlightStyle,
1343
+ syntaxHighlighting,
1344
+ tags
1345
+ } from "@vuu-ui/vuu-codemirror";
1346
+ var myHighlightStyle = HighlightStyle.define([
1347
+ { tag: tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
1348
+ { tag: tags.comment, color: "green", fontStyle: "italic" }
1349
+ ]);
1350
+ var vuuHighlighting = syntaxHighlighting(myHighlightStyle);
1351
+
1352
+ // src/column-expression-input/theme.ts
1353
+ import { EditorView } from "@vuu-ui/vuu-codemirror";
1354
+ var vuuTheme = EditorView.theme(
1355
+ {
1356
+ "&": {
1357
+ border: "solid 1px var(--salt-container-primary-borderColor)",
1358
+ color: "var(--vuuFilterEditor-color)",
1359
+ backgroundColor: "var(--vuuFilterEditor-background)"
1360
+ },
1361
+ ".cm-content": {
1362
+ caretColor: "var(--vuuFilterEditor-cursorColor)"
1363
+ },
1364
+ "&.cm-focused .cm-cursor": {
1365
+ borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
1366
+ },
1367
+ "&.cm-focused .cm-selectionBackground, ::selection": {
1368
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
1369
+ },
1370
+ ".cm-selectionBackground, ::selection": {
1371
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
1372
+ },
1373
+ ".cm-scroller": {
1374
+ fontFamily: "var(--vuuFilterEditor-fontFamily)"
1375
+ },
1376
+ ".cm-tooltip": {
1377
+ background: "var(--vuuFilterEditor-tooltipBackground)",
1378
+ border: "var(--vuuFilterEditor-tooltipBorder)",
1379
+ boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
1380
+ "&.cm-tooltip-autocomplete > ul": {
1381
+ fontFamily: "var(--vuuFilterEditor-fontFamily)",
1382
+ fontSize: "var(--vuuFilterEditor-fontSize)",
1383
+ maxHeight: "240px"
1384
+ },
1385
+ "&.cm-tooltip-autocomplete > ul > li": {
1386
+ height: "var(--vuuFilterEditor-suggestion-height)",
1387
+ padding: "0 3px",
1388
+ lineHeight: "var(--vuuFilterEditor-suggestion-height)"
1389
+ },
1390
+ "&.cm-tooltip-autocomplete li[aria-selected]": {
1391
+ background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
1392
+ color: "var(--vuuFilterEditor-suggestion-selectedColor)"
1393
+ },
1394
+ "&.cm-tooltip-autocomplete li .cm-completionDetail": {
1395
+ color: "var(--vuuFilterEditor-suggestion-detailColor)"
1396
+ }
1397
+ }
1398
+ },
1399
+ { dark: false }
1400
+ );
1401
+
1402
+ // src/column-expression-input/useColumnAutoComplete.ts
1403
+ import {
1404
+ booleanJoinSuggestions,
1405
+ getNamedParentNode,
1406
+ getPreviousNode,
1407
+ getValue,
1408
+ syntaxTree
1409
+ } from "@vuu-ui/vuu-codemirror";
1410
+ import { useCallback as useCallback4 } from "react";
1411
+ var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
1412
+ var _a;
1413
+ return {
1414
+ ...completion,
1415
+ apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
1416
+ };
1417
+ }) : completions;
1418
+ var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
1419
+ var completionDone = (onSubmit) => ({
1420
+ apply: () => {
1421
+ onSubmit == null ? void 0 : onSubmit();
1422
+ },
1423
+ label: "Done",
1424
+ boost: 10
1425
+ });
1426
+ var getLastChild = (node, context) => {
1427
+ var _a;
1428
+ let { lastChild: childNode } = node;
1429
+ const { pos } = context;
1430
+ while (childNode) {
1431
+ const isBeforeCursor = childNode.from < pos;
1432
+ if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
1433
+ if (childNode.name === "ParenthesizedExpression") {
1434
+ const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
1435
+ if (expression) {
1436
+ childNode = expression;
1437
+ }
1438
+ }
1439
+ return childNode;
1440
+ } else {
1441
+ childNode = childNode.prevSibling;
1442
+ }
1443
+ }
1444
+ };
1445
+ var getFunctionName = (node, state) => {
1446
+ var _a;
1447
+ if (node.name === "ArgList") {
1448
+ const functionNode = node.prevSibling;
1449
+ if (functionNode) {
1450
+ return getValue(functionNode, state);
1451
+ }
1452
+ } else if (node.name === "OpenBrace") {
1453
+ const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
1454
+ if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
1455
+ return getValue(maybeFunction, state);
1456
+ }
1457
+ }
1458
+ };
1459
+ var getRelationalOperator = (node, state) => {
1460
+ if (node.name === "RelationalExpression") {
1461
+ const lastNode = lastNamedChild(node);
1462
+ if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
1463
+ return getValue(lastNode, state);
1464
+ }
1465
+ } else {
1466
+ const prevNode = node.prevSibling;
1467
+ if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
1468
+ return getValue(prevNode, state);
1469
+ }
1470
+ }
1471
+ };
1472
+ var getColumnName = (node, state) => {
1473
+ var _a;
1474
+ if (node.name === "RelationalExpression") {
1475
+ if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
1476
+ return getValue(node.firstChild, state);
1477
+ }
1478
+ } else {
1479
+ const prevNode = node.prevSibling;
1480
+ if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
1481
+ return getValue(prevNode, state);
1482
+ } else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
1483
+ return getColumnName(prevNode, state);
1484
+ }
1485
+ }
1486
+ };
1487
+ var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
1488
+ const options = await suggestionProvider.getSuggestions(
1489
+ suggestionType,
1490
+ optionalArgs
1491
+ );
1492
+ const { startsWith = "" } = optionalArgs;
1493
+ return { from: context.pos - startsWith.length, options };
1494
+ };
1495
+ var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
1496
+ const lastChild = getLastChild(node, context);
1497
+ console.log(`conditional expression last child ${lastChild == null ? void 0 : lastChild.name}`);
1498
+ switch (lastChild == null ? void 0 : lastChild.name) {
1499
+ case "If":
1500
+ return makeSuggestions(context, suggestionProvider, "expression", {
1501
+ prefix: "( "
1502
+ });
1503
+ case "OpenBrace":
1504
+ return makeSuggestions(context, suggestionProvider, "expression");
1505
+ case "Condition":
1506
+ return makeSuggestions(context, suggestionProvider, "expression", {
1507
+ prefix: ", "
1508
+ });
1509
+ case "CloseBrace":
1510
+ if (maybeComplete) {
1511
+ const options = [completionDone(onSubmit)];
1512
+ return { from: context.pos, options };
1513
+ }
1514
+ }
1515
+ };
1516
+ var promptToSave = (context, onSubmit) => {
1517
+ const options = [completionDone(onSubmit)];
1518
+ return { from: context.pos, options };
1519
+ };
1520
+ var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
1521
+ const makeSuggestions2 = useCallback4(
1522
+ async (context, suggestionType, optionalArgs = {}) => {
1523
+ const options = await suggestionProvider.getSuggestions(
1524
+ suggestionType,
1525
+ optionalArgs
1526
+ );
1527
+ const { startsWith = "" } = optionalArgs;
1528
+ return { from: context.pos - startsWith.length, options };
1529
+ },
1530
+ [suggestionProvider]
1531
+ );
1532
+ return useCallback4(
1533
+ async (context) => {
1534
+ var _a, _b;
1535
+ const { state, pos } = context;
1536
+ const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
1537
+ from: 0,
1538
+ to: 0,
1539
+ text: void 0
1540
+ };
1541
+ const tree = syntaxTree(state);
1542
+ const nodeBefore = tree.resolveInner(pos, -1);
1543
+ const text = state.doc.toString();
1544
+ const maybeComplete = isCompleteExpression(text);
1545
+ switch (nodeBefore.name) {
1546
+ case "If": {
1547
+ console.log(`conditional expression If`);
1548
+ return makeSuggestions2(context, "expression", { prefix: "( " });
1549
+ }
1550
+ case "Condition":
1551
+ {
1552
+ const lastChild = getLastChild(nodeBefore, context);
1553
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1554
+ const prevChild = getPreviousNode(lastChild);
1555
+ if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
1556
+ return makeSuggestions2(context, "condition-operator", {
1557
+ columnName: getValue(lastChild, state)
1558
+ });
1559
+ }
1560
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
1561
+ return makeSuggestions2(context, "expression");
1562
+ }
1563
+ console.log(`condition last child ${lastChild == null ? void 0 : lastChild.name}`);
1564
+ }
1565
+ break;
1566
+ case "ConditionalExpression":
1567
+ return handleConditionalExpression(
1568
+ nodeBefore,
1569
+ context,
1570
+ suggestionProvider
1571
+ );
1572
+ case "RelationalExpression":
1573
+ {
1574
+ if (isCompleteRelationalExpression(nodeBefore)) {
1575
+ return {
1576
+ from: context.pos,
1577
+ options: booleanJoinSuggestions.concat({
1578
+ label: ", <truthy expression>, <falsy expression>",
1579
+ apply: ", "
1580
+ })
1581
+ };
1582
+ } else {
1583
+ const operator = getRelationalOperator(nodeBefore, state);
1584
+ const columnName = getColumnName(nodeBefore, state);
1585
+ if (!operator) {
1586
+ const options = await suggestionProvider.getSuggestions(
1587
+ "condition-operator",
1588
+ {
1589
+ columnName
1590
+ }
1591
+ );
1592
+ return { from: context.pos, options };
1593
+ } else {
1594
+ return makeSuggestions2(context, "expression");
1595
+ }
1596
+ }
1597
+ }
1598
+ break;
1599
+ case "RelationalOperator":
1600
+ return makeSuggestions2(context, "expression");
1601
+ case "String":
1602
+ {
1603
+ const operator = getRelationalOperator(
1604
+ nodeBefore,
1605
+ state
1606
+ );
1607
+ const columnName = getColumnName(nodeBefore, state);
1608
+ const { from, to } = nodeBefore;
1609
+ if (to - from === 2 && context.pos === from + 1) {
1610
+ if (columnName && operator) {
1611
+ return makeSuggestions2(context, "columnValue", {
1612
+ columnName,
1613
+ operator,
1614
+ startsWith: word.text
1615
+ });
1616
+ }
1617
+ } else if (to - from > 2 && context.pos === to) {
1618
+ return makeSuggestions2(context, "expression", {
1619
+ prefix: ", "
1620
+ });
1621
+ }
1622
+ }
1623
+ break;
1624
+ case "ArithmeticExpression":
1625
+ {
1626
+ const lastChild = getLastChild(nodeBefore, context);
1627
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1628
+ return makeSuggestions2(context, "expression");
1629
+ } else if (isOperator(lastChild)) {
1630
+ const operator = lastChild.name;
1631
+ return makeSuggestions2(context, "column", { operator });
1632
+ }
1633
+ }
1634
+ break;
1635
+ case "OpenBrace":
1636
+ {
1637
+ const functionName = getFunctionName(nodeBefore, state);
1638
+ return makeSuggestions2(context, "expression", { functionName });
1639
+ }
1640
+ break;
1641
+ case "ArgList": {
1642
+ const functionName = getFunctionName(nodeBefore, state);
1643
+ const lastArgument = getLastChild(nodeBefore, context);
1644
+ const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" ? void 0 : ",";
1645
+ let options = await suggestionProvider.getSuggestions("expression", {
1646
+ functionName
1647
+ });
1648
+ options = prefix ? applyPrefix(options, ", ") : options;
1649
+ if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
1650
+ options = [
1651
+ {
1652
+ apply: ") ",
1653
+ boost: 10,
1654
+ label: "Done - no more arguments"
1655
+ }
1656
+ ].concat(options);
1657
+ }
1658
+ return { from: context.pos, options };
1659
+ }
1660
+ case "Equal":
1661
+ if (text.trim() === "=") {
1662
+ return makeSuggestions2(context, "expression");
1663
+ }
1664
+ break;
1665
+ case "ParenthesizedExpression":
1666
+ case "ColumnDefinitionExpression":
1667
+ if (context.pos === 0) {
1668
+ return makeSuggestions2(context, "expression");
1669
+ } else {
1670
+ const lastChild = getLastChild(nodeBefore, context);
1671
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1672
+ if (maybeComplete) {
1673
+ const options = [
1674
+ completionDone(onSubmit.current)
1675
+ ];
1676
+ const columnName = getValue(lastChild, state);
1677
+ const columnOptions = await suggestionProvider.getSuggestions("operator", {
1678
+ columnName
1679
+ });
1680
+ return {
1681
+ from: context.pos,
1682
+ options: options.concat(columnOptions)
1683
+ };
1684
+ }
1685
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
1686
+ if (maybeComplete) {
1687
+ return {
1688
+ from: context.pos,
1689
+ options: [completionDone(onSubmit.current)]
1690
+ };
1691
+ }
1692
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
1693
+ if (maybeComplete) {
1694
+ let options = [completionDone(onSubmit.current)];
1695
+ const lastExpressionChild = getLastChild(lastChild, context);
1696
+ if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
1697
+ const columnName = getValue(lastExpressionChild, state);
1698
+ const suggestions = await suggestionProvider.getSuggestions(
1699
+ "operator",
1700
+ { columnName }
1701
+ );
1702
+ options = options.concat(suggestions);
1703
+ }
1704
+ return {
1705
+ from: context.pos,
1706
+ options
1707
+ };
1708
+ }
1709
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
1710
+ return handleConditionalExpression(
1711
+ lastChild,
1712
+ context,
1713
+ suggestionProvider,
1714
+ maybeComplete,
1715
+ onSubmit.current
1716
+ );
1717
+ }
1718
+ break;
1719
+ }
1720
+ case "Column":
1721
+ {
1722
+ const isPartialMatch = await suggestionProvider.isPartialMatch(
1723
+ "expression",
1724
+ void 0,
1725
+ word.text
1726
+ );
1727
+ if (isPartialMatch) {
1728
+ return makeSuggestions2(context, "expression", {
1729
+ startsWith: word.text
1730
+ });
1731
+ }
1732
+ }
1733
+ break;
1734
+ case "Comma":
1735
+ {
1736
+ const parentNode = getNamedParentNode(nodeBefore);
1737
+ if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1738
+ return makeSuggestions2(context, "expression");
1739
+ }
1740
+ }
1741
+ break;
1742
+ case "CloseBrace":
1743
+ {
1744
+ const parentNode = getNamedParentNode(nodeBefore);
1745
+ if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1746
+ return handleConditionalExpression(
1747
+ parentNode,
1748
+ context,
1749
+ suggestionProvider,
1750
+ maybeComplete,
1751
+ onSubmit.current
1752
+ );
1753
+ } else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
1754
+ if (maybeComplete) {
1755
+ return promptToSave(context, onSubmit.current);
1756
+ }
1757
+ }
1758
+ }
1759
+ break;
1760
+ default: {
1761
+ if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
1762
+ console.log("looks like we ight be a or|and operator");
1763
+ }
1764
+ }
1765
+ }
1766
+ },
1767
+ [makeSuggestions2, onSubmit, suggestionProvider]
1768
+ );
1769
+ };
1770
+
1771
+ // src/column-expression-input/useColumnExpressionEditor.ts
1772
+ var getView = (ref) => {
1773
+ if (ref.current == void 0) {
1774
+ throw Error("EditorView not defined");
1775
+ }
1776
+ return ref.current;
1777
+ };
1778
+ var getOptionClass = () => {
1779
+ return "vuuSuggestion";
1780
+ };
1781
+ var noop = () => console.log("noooop");
1782
+ var hasExpressionType = (completion) => "expressionType" in completion;
1783
+ var injectOptionContent = (completion) => {
1784
+ if (hasExpressionType(completion)) {
1785
+ const div = createEl("div", "expression-type-container");
1786
+ const span = createEl("span", "expression-type", completion.expressionType);
1787
+ div.appendChild(span);
1788
+ return div;
1789
+ } else {
1790
+ return null;
1791
+ }
1792
+ };
1793
+ var useColumnExpressionEditor = ({
1794
+ onChange,
1795
+ onSubmitExpression,
1796
+ source,
1797
+ suggestionProvider
1798
+ }) => {
1799
+ const editorRef = useRef4(null);
1800
+ const onSubmitRef = useRef4(noop);
1801
+ const viewRef = useRef4();
1802
+ const completionFn = useColumnAutoComplete(suggestionProvider, onSubmitRef);
1803
+ const [createState, clearInput] = useMemo3(() => {
1804
+ const parseExpression = () => {
1805
+ const view = getView(viewRef);
1806
+ const source2 = view.state.doc.toString();
1807
+ const tree = ensureSyntaxTree(view.state, view.state.doc.length, 5e3);
1808
+ if (tree) {
1809
+ const expression = walkTree(tree, source2);
1810
+ return [source2, expression];
1811
+ } else {
1812
+ return ["", void 0];
1813
+ }
1814
+ };
1815
+ const clearInput2 = () => {
1816
+ getView(viewRef).setState(createState2());
1817
+ };
1818
+ const submitExpression = () => {
1819
+ const [source2, expression] = parseExpression();
1820
+ onSubmitExpression == null ? void 0 : onSubmitExpression(source2, expression);
1821
+ };
1822
+ const showSuggestions = (key) => {
1823
+ return keymap.of([
1824
+ {
1825
+ key,
1826
+ run() {
1827
+ startCompletion(getView(viewRef));
1828
+ return true;
1829
+ }
1830
+ }
1831
+ ]);
1832
+ };
1833
+ const createState2 = () => EditorState2.create({
1834
+ doc: source,
1835
+ extensions: [
1836
+ minimalSetup,
1837
+ autocompletion({
1838
+ addToOptions: [
1839
+ {
1840
+ render: injectOptionContent,
1841
+ position: 70
1842
+ }
1843
+ ],
1844
+ override: [completionFn],
1845
+ optionClass: getOptionClass
1846
+ }),
1847
+ columnExpressionLanguageSupport(),
1848
+ keymap.of(defaultKeymap),
1849
+ showSuggestions("ArrowDown"),
1850
+ EditorView2.updateListener.of((v) => {
1851
+ const view = getView(viewRef);
1852
+ if (v.docChanged) {
1853
+ startCompletion(view);
1854
+ const source2 = view.state.doc.toString();
1855
+ onChange == null ? void 0 : onChange(source2);
1856
+ }
1857
+ }),
1858
+ // Enforces single line view
1859
+ // EditorState.transactionFilter.of((tr) =>
1860
+ // tr.newDoc.lines > 1 ? [] : tr
1861
+ // ),
1862
+ vuuTheme,
1863
+ vuuHighlighting
1864
+ ]
1865
+ });
1866
+ onSubmitRef.current = () => {
1867
+ submitExpression();
1868
+ };
1869
+ return [createState2, clearInput2];
1870
+ }, [completionFn, onChange, onSubmitExpression, source]);
1871
+ useEffect3(() => {
1872
+ if (!editorRef.current) {
1873
+ throw Error("editor not in dom");
1874
+ }
1875
+ viewRef.current = new EditorView2({
1876
+ state: createState(),
1877
+ parent: editorRef.current
1878
+ });
1879
+ return () => {
1880
+ var _a;
1881
+ (_a = viewRef.current) == null ? void 0 : _a.destroy();
1882
+ };
1883
+ }, [completionFn, createState]);
1884
+ return { editorRef, clearInput };
1885
+ };
1886
+
1887
+ // src/column-expression-input/ColumnExpressionInput.tsx
1888
+ import { jsx as jsx7 } from "react/jsx-runtime";
1889
+ var classBase7 = "vuuColumnExpressionInput";
1890
+ var ColumnExpressionInput = ({
1891
+ onChange,
1892
+ onSubmitExpression,
1893
+ source = "",
1894
+ suggestionProvider
1895
+ }) => {
1896
+ const { editorRef } = useColumnExpressionEditor({
1897
+ onChange,
1898
+ onSubmitExpression,
1899
+ source,
1900
+ suggestionProvider
1901
+ });
1902
+ return /* @__PURE__ */ jsx7("div", { className: `${classBase7}`, ref: editorRef });
1903
+ };
1904
+
1905
+ // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
1906
+ import {
1907
+ AnnotationType,
1908
+ getRelationalOperators,
1909
+ numericOperators,
1910
+ stringOperators,
1911
+ toSuggestions
1912
+ } from "@vuu-ui/vuu-codemirror";
1913
+ import {
1914
+ getTypeaheadParams,
1915
+ useTypeaheadSuggestions
1916
+ } from "@vuu-ui/vuu-data-react";
1917
+ import { isNumericColumn, isTextColumn } from "@vuu-ui/vuu-utils";
1918
+ import { useCallback as useCallback5, useRef as useRef5 } from "react";
1919
+
1920
+ // src/column-expression-input/column-function-descriptors.ts
1921
+ var columnFunctionDescriptors = [
1922
+ /**
1923
+ * concatenate()
1924
+ */
1925
+ {
1926
+ accepts: "string",
1927
+ description: "Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",
1928
+ example: {
1929
+ expression: 'concatenate("example", "-test")',
1930
+ result: '"example-test"'
1931
+ },
1932
+ name: "concatenate",
1933
+ params: {
1934
+ description: "( string, string, [ string* ] )"
1935
+ },
1936
+ type: "string"
1937
+ },
1938
+ /**
1939
+ * contains()
1940
+ */
1941
+ {
1942
+ accepts: ["string", "string"],
1943
+ description: "Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",
1944
+ example: {
1945
+ expression: 'contains("Royal Bank of Scotland", "bank")',
1946
+ result: "true"
1947
+ },
1948
+ name: "contains",
1949
+ params: {
1950
+ description: "( string )"
1951
+ },
1952
+ type: "boolean"
1953
+ },
1954
+ /**
1955
+ * left()
1956
+ */
1957
+ {
1958
+ accepts: ["string", "number"],
1959
+ description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
1960
+ example: {
1961
+ expression: 'left("USD Benchmark Report", 3)',
1962
+ result: '"USD"'
1963
+ },
1964
+ name: "left",
1965
+ params: {
1966
+ count: 2,
1967
+ description: "( string, number )"
1968
+ },
1969
+ type: "string"
1970
+ },
1971
+ /**
1972
+ * len()
1973
+ */
1974
+ {
1975
+ accepts: "string",
1976
+ description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
1977
+ example: {
1978
+ expression: 'len("example")',
1979
+ result: "7"
1980
+ },
1981
+ name: "len",
1982
+ params: {
1983
+ description: "(string)"
1984
+ },
1985
+ type: "number"
1986
+ },
1987
+ /**
1988
+ * lower()
1989
+ */
1990
+ {
1991
+ accepts: "string",
1992
+ description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
1993
+ example: {
1994
+ expression: 'lower("examPLE")',
1995
+ result: '"example"'
1996
+ },
1997
+ name: "lower",
1998
+ params: {
1999
+ description: "( string )"
2000
+ },
2001
+ type: "string"
2002
+ },
2003
+ /**
2004
+ * upper()
2005
+ */
2006
+ {
2007
+ accepts: "string",
2008
+ description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
2009
+ example: {
2010
+ expression: 'upper("example")',
2011
+ result: '"EXAMPLE"'
2012
+ },
2013
+ name: "upper",
2014
+ params: {
2015
+ description: "( string )"
2016
+ },
2017
+ type: "string"
2018
+ },
2019
+ /**
2020
+ * right()
2021
+ */
2022
+ {
2023
+ accepts: ["string", "number"],
2024
+ description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
2025
+ example: {
2026
+ expression: "blah",
2027
+ result: "blah"
2028
+ },
2029
+ name: "right",
2030
+ params: {
2031
+ description: "( string )"
2032
+ },
2033
+ type: "string"
2034
+ },
2035
+ /**
2036
+ * replace()
2037
+ */
2038
+ {
2039
+ accepts: ["string", "string", "string"],
2040
+ description: "Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",
2041
+ example: {
2042
+ expression: "blah",
2043
+ result: "blah"
2044
+ },
2045
+ name: "replace",
2046
+ params: {
2047
+ description: "( string )"
2048
+ },
2049
+ type: "string"
2050
+ },
2051
+ /**
2052
+ * text()
2053
+ */
2054
+ {
2055
+ accepts: "number",
2056
+ description: "Converts a number to a string.",
2057
+ example: {
2058
+ expression: "blah",
2059
+ result: "blah"
2060
+ },
2061
+ name: "text",
2062
+ params: {
2063
+ description: "( string )"
2064
+ },
2065
+ type: "string"
2066
+ },
2067
+ /**
2068
+ * starts()
2069
+ */
2070
+ {
2071
+ accepts: "string",
2072
+ description: "Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",
2073
+ example: {
2074
+ expression: "blah",
2075
+ result: "blah"
2076
+ },
2077
+ name: "starts",
2078
+ params: {
2079
+ description: "( string )"
2080
+ },
2081
+ type: "boolean"
2082
+ },
2083
+ /**
2084
+ * starts()
2085
+ */
2086
+ {
2087
+ accepts: "string",
2088
+ description: "Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",
2089
+ example: {
2090
+ expression: "blah",
2091
+ result: "blah"
2092
+ },
2093
+ name: "ends",
2094
+ params: {
2095
+ description: "( string )"
2096
+ },
2097
+ type: "boolean"
2098
+ },
2099
+ {
2100
+ accepts: "number",
2101
+ description: "blah",
2102
+ example: {
2103
+ expression: "blah",
2104
+ result: "blah"
2105
+ },
2106
+ name: "min",
2107
+ params: {
2108
+ description: "( string )"
2109
+ },
2110
+ type: "number"
2111
+ },
2112
+ {
2113
+ accepts: "number",
2114
+ description: "blah",
2115
+ example: {
2116
+ expression: "blah",
2117
+ result: "blah"
2118
+ },
2119
+ name: "max",
2120
+ params: {
2121
+ description: "( string )"
2122
+ },
2123
+ type: "number"
2124
+ },
2125
+ {
2126
+ accepts: "number",
2127
+ description: "blah",
2128
+ example: {
2129
+ expression: "blah",
2130
+ result: "blah"
2131
+ },
2132
+ name: "sum",
2133
+ params: {
2134
+ description: "( string )"
2135
+ },
2136
+ type: "number"
2137
+ },
2138
+ {
2139
+ accepts: "number",
2140
+ description: "blah",
2141
+ example: {
2142
+ expression: "blah",
2143
+ result: "blah"
2144
+ },
2145
+ name: "round",
2146
+ params: {
2147
+ description: "( string )"
2148
+ },
2149
+ type: "number"
2150
+ },
2151
+ {
2152
+ accepts: "any",
2153
+ description: "blah",
2154
+ example: {
2155
+ expression: "blah",
2156
+ result: "blah"
2157
+ },
2158
+ name: "or",
2159
+ params: {
2160
+ description: "( string )"
2161
+ },
2162
+ type: "boolean"
2163
+ },
2164
+ {
2165
+ accepts: "any",
2166
+ description: "blah",
2167
+ example: {
2168
+ expression: "blah",
2169
+ result: "blah"
2170
+ },
2171
+ name: "and",
2172
+ params: {
2173
+ description: "( string )"
2174
+ },
2175
+ type: "boolean"
2176
+ },
2177
+ {
2178
+ accepts: "any",
2179
+ description: "Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",
2180
+ example: {
2181
+ expression: "blah",
2182
+ result: "blah"
2183
+ },
2184
+ name: "if",
2185
+ params: {
2186
+ description: "( filterExpression, expression1, expression 2)"
2187
+ },
2188
+ type: "variable"
2189
+ }
2190
+ ];
2191
+
2192
+ // src/column-expression-input/functionDocInfo.ts
2193
+ import { createEl as createEl2 } from "@vuu-ui/vuu-utils";
2194
+ var functionDocInfo = ({
2195
+ name: name2,
2196
+ description,
2197
+ example,
2198
+ params,
2199
+ type
2200
+ }) => {
2201
+ const rootElement = createEl2("div", "vuuFunctionDoc");
2202
+ const headingElement = createEl2("div", "function-heading");
2203
+ const nameElement = createEl2("span", "function-name", name2);
2204
+ const paramElement = createEl2("span", "param-list", params.description);
2205
+ const typeElement = createEl2("span", "function-type", type);
2206
+ headingElement.appendChild(nameElement);
2207
+ headingElement.appendChild(paramElement);
2208
+ headingElement.appendChild(typeElement);
2209
+ const child2 = createEl2("p", void 0, description);
2210
+ rootElement.appendChild(headingElement);
2211
+ rootElement.appendChild(child2);
2212
+ if (example) {
2213
+ const exampleElement = createEl2("div", "example-container", "Example:");
2214
+ const expressionElement = createEl2(
2215
+ "div",
2216
+ "example-expression",
2217
+ example.expression
2218
+ );
2219
+ const resultElement = createEl2("div", "example-result", example.result);
2220
+ exampleElement.appendChild(expressionElement);
2221
+ exampleElement.appendChild(resultElement);
2222
+ rootElement.appendChild(exampleElement);
2223
+ }
2224
+ return rootElement;
2225
+ };
2226
+
2227
+ // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
2228
+ var NO_OPERATORS = [];
2229
+ var withApplySpace = (suggestions) => suggestions.map((suggestion) => {
2230
+ var _a;
2231
+ return {
2232
+ ...suggestion,
2233
+ apply: ((_a = suggestion.apply) != null ? _a : suggestion.label) + " "
2234
+ };
2235
+ });
2236
+ var getValidColumns = (columns, { functionName, operator }) => {
2237
+ if (operator) {
2238
+ return columns.filter(isNumericColumn);
2239
+ } else if (functionName) {
2240
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
2241
+ if (fn) {
2242
+ switch (fn.accepts) {
2243
+ case "string":
2244
+ return columns.filter(isTextColumn);
2245
+ case "number":
2246
+ return columns.filter(isNumericColumn);
2247
+ default:
2248
+ return columns;
2249
+ }
2250
+ }
2251
+ }
2252
+ return columns;
2253
+ };
2254
+ var getColumns = (columns, options) => {
2255
+ const validColumns = getValidColumns(columns, options);
2256
+ return validColumns.map((column) => {
2257
+ var _a;
2258
+ const label = (_a = column.label) != null ? _a : column.name;
2259
+ return {
2260
+ apply: options.prefix ? `${options.prefix}${label}` : label,
2261
+ label,
2262
+ boost: 5,
2263
+ type: "column",
2264
+ expressionType: column.serverDataType
2265
+ };
2266
+ });
2267
+ };
2268
+ var arithmeticOperators = [
2269
+ { apply: "* ", boost: 2, label: "*", type: "operator" },
2270
+ { apply: "/ ", boost: 2, label: "/", type: "operator" },
2271
+ { apply: "+ ", boost: 2, label: "+", type: "operator" },
2272
+ { apply: "- ", boost: 2, label: "-", type: "operator" }
2273
+ ];
2274
+ var getOperators = (column) => {
2275
+ if (column === void 0 || isNumericColumn(column)) {
2276
+ return arithmeticOperators;
2277
+ } else {
2278
+ return NO_OPERATORS;
2279
+ }
2280
+ };
2281
+ var getConditionOperators = (column) => {
2282
+ switch (column.serverDataType) {
2283
+ case "string":
2284
+ case "char":
2285
+ return withApplySpace(
2286
+ stringOperators
2287
+ /*, startsWith*/
2288
+ );
2289
+ case "int":
2290
+ case "long":
2291
+ case "double":
2292
+ return withApplySpace(numericOperators);
2293
+ }
2294
+ };
2295
+ var toFunctionCompletion = (functionDescriptor) => ({
2296
+ apply: `${functionDescriptor.name}( `,
2297
+ boost: 2,
2298
+ expressionType: functionDescriptor.type,
2299
+ info: () => functionDocInfo(functionDescriptor),
2300
+ label: functionDescriptor.name,
2301
+ type: "function"
2302
+ });
2303
+ var getAcceptedTypes = (fn) => {
2304
+ if (fn) {
2305
+ if (typeof fn.accepts === "string") {
2306
+ return fn.accepts;
2307
+ } else if (Array.isArray(fn.accepts)) {
2308
+ if (fn.accepts.every((s) => s === "string")) {
2309
+ return "string";
2310
+ } else {
2311
+ return "any";
2312
+ }
2313
+ }
2314
+ }
2315
+ return "any";
2316
+ };
2317
+ var functions = columnFunctionDescriptors.map(toFunctionCompletion);
2318
+ var getFunctions = ({ functionName }) => {
2319
+ if (functionName) {
2320
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
2321
+ const acceptedTypes = getAcceptedTypes(fn);
2322
+ if (fn) {
2323
+ switch (acceptedTypes) {
2324
+ case "string":
2325
+ return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
2326
+ case "number":
2327
+ return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
2328
+ default:
2329
+ }
2330
+ }
2331
+ }
2332
+ return functions;
2333
+ };
2334
+ var NONE = {};
2335
+ var useColumnExpressionSuggestionProvider = ({
2336
+ columns,
2337
+ table
2338
+ }) => {
2339
+ const findColumn2 = useCallback5(
2340
+ (name2) => name2 ? columns.find((col) => col.name === name2) : void 0,
2341
+ [columns]
2342
+ );
2343
+ const latestSuggestionsRef = useRef5();
2344
+ const getTypeaheadSuggestions = useTypeaheadSuggestions();
2345
+ const getSuggestions = useCallback5(
2346
+ async (suggestionType, options = NONE) => {
2347
+ const { columnName, functionName, operator, prefix } = options;
2348
+ switch (suggestionType) {
2349
+ case "expression": {
2350
+ const suggestions = await withApplySpace(
2351
+ getColumns(columns, { functionName, prefix })
2352
+ ).concat(getFunctions(options));
2353
+ return latestSuggestionsRef.current = suggestions;
2354
+ }
2355
+ case "column": {
2356
+ const suggestions = await getColumns(columns, options);
2357
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2358
+ }
2359
+ case "operator": {
2360
+ const suggestions = await getOperators(findColumn2(columnName));
2361
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2362
+ }
2363
+ case "relational-operator": {
2364
+ const suggestions = await getRelationalOperators(
2365
+ findColumn2(columnName)
2366
+ );
2367
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2368
+ }
2369
+ case "condition-operator":
2370
+ {
2371
+ const column = findColumn2(columnName);
2372
+ if (column) {
2373
+ const suggestions = await getConditionOperators(column);
2374
+ if (suggestions) {
2375
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2376
+ }
2377
+ }
2378
+ }
2379
+ break;
2380
+ case "columnValue":
2381
+ if (columnName && operator) {
2382
+ const params = getTypeaheadParams(
2383
+ table,
2384
+ columnName
2385
+ /*, startsWith*/
2386
+ );
2387
+ const suggestions = await getTypeaheadSuggestions(params);
2388
+ latestSuggestionsRef.current = toSuggestions(suggestions, {
2389
+ suffix: ""
2390
+ });
2391
+ latestSuggestionsRef.current.forEach((suggestion) => {
2392
+ suggestion.apply = (view, completion, from) => {
2393
+ const annotation = new AnnotationType();
2394
+ const cursorPos = from + completion.label.length + 1;
2395
+ view.dispatch({
2396
+ changes: { from, insert: completion.label },
2397
+ selection: { anchor: cursorPos, head: cursorPos },
2398
+ annotations: annotation.of(completion)
2399
+ });
2400
+ };
2401
+ });
2402
+ return latestSuggestionsRef.current;
2403
+ }
2404
+ break;
2405
+ }
2406
+ return [];
2407
+ },
2408
+ [columns, findColumn2, getTypeaheadSuggestions, table]
2409
+ );
2410
+ const isPartialMatch = useCallback5(
2411
+ async (valueType, columnName, pattern) => {
2412
+ const { current: latestSuggestions } = latestSuggestionsRef;
2413
+ let maybe = false;
2414
+ const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
2415
+ if (pattern && suggestions) {
2416
+ for (const option of suggestions) {
2417
+ if (option.label === pattern) {
2418
+ return false;
2419
+ } else if (option.label.startsWith(pattern)) {
2420
+ maybe = true;
2421
+ }
2422
+ }
2423
+ }
2424
+ return maybe;
2425
+ },
2426
+ [getSuggestions]
2427
+ );
2428
+ return {
2429
+ getSuggestions,
2430
+ isPartialMatch
2431
+ };
2432
+ };
2433
+
2434
+ // src/column-expression-panel/useColumnExpression.ts
2435
+ import {
2436
+ getCalculatedColumnDetails,
2437
+ setCalculatedColumnExpression,
2438
+ setCalculatedColumnName as setCalculatedColumnName2,
2439
+ setCalculatedColumnType
2440
+ } from "@vuu-ui/vuu-utils";
2441
+ import { useCallback as useCallback6, useRef as useRef6, useState as useState3 } from "react";
2442
+ var applyDefaults = (column) => {
2443
+ const [name2, expression, type] = getCalculatedColumnDetails(column);
2444
+ if (type === "") {
2445
+ return {
2446
+ ...column,
2447
+ name: `${name2}:${expression}:string`
2448
+ };
2449
+ } else {
2450
+ return column;
2451
+ }
2452
+ };
2453
+ var useColumnExpression = ({
2454
+ column: columnProp,
2455
+ onSave: onSaveProp
2456
+ }) => {
2457
+ const [column, setColumn] = useState3(
2458
+ applyDefaults(columnProp)
2459
+ );
2460
+ const expressionRef = useRef6(getCalculatedColumnDetails(column)[1]);
2461
+ const onChangeName = useCallback6((evt) => {
2462
+ const { value } = evt.target;
2463
+ setColumn((state) => setCalculatedColumnName2(state, value));
2464
+ }, []);
2465
+ const onChangeExpression = useCallback6((value) => {
2466
+ expressionRef.current = value.trim();
2467
+ }, []);
2468
+ const onChangeType = useCallback6((evt, value) => {
2469
+ if (typeof value === "string") {
2470
+ setColumn((state) => setCalculatedColumnType(state, value));
2471
+ }
2472
+ }, []);
2473
+ const onSave = useCallback6(() => {
2474
+ const newColumn = setCalculatedColumnExpression(
2475
+ column,
2476
+ expressionRef.current
2477
+ );
2478
+ setColumn(newColumn);
2479
+ onSaveProp(newColumn);
2480
+ }, [column, onSaveProp]);
2481
+ return {
2482
+ column,
2483
+ onChangeExpression,
2484
+ onChangeName,
2485
+ onChangeType,
2486
+ onSave
2487
+ };
2488
+ };
2489
+
2490
+ // src/column-expression-panel/ColumnExpressionPanel.tsx
2491
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
2492
+ var classBase8 = "vuuColumnExpressionPanel";
2493
+ var ColumnExpressionPanel = ({
2494
+ column: columnProp,
2495
+ onSave: onSaveProp,
2496
+ tableConfig,
2497
+ vuuTable
2498
+ }) => {
2499
+ const typeRef = useRef7(null);
2500
+ const { column, onChangeExpression, onChangeName, onChangeType, onSave } = useColumnExpression({ column: columnProp, onSave: onSaveProp });
2501
+ const suggestionProvider = useColumnExpressionSuggestionProvider({
2502
+ columns: tableConfig.columns,
2503
+ table: vuuTable
2504
+ });
2505
+ const handleSubmitExpression = useCallback7(() => {
2506
+ requestAnimationFrame(() => {
2507
+ var _a, _b;
2508
+ (_b = (_a = typeRef.current) == null ? void 0 : _a.querySelector("button")) == null ? void 0 : _b.focus();
2509
+ });
2510
+ }, []);
2511
+ return /* @__PURE__ */ jsxs7("div", { className: classBase8, children: [
2512
+ /* @__PURE__ */ jsx8("div", { className: "vuuColumnSettingsPanel-header", children: /* @__PURE__ */ jsx8("span", { children: "Calculation" }) }),
2513
+ /* @__PURE__ */ jsxs7(FormField3, { "data-field": "column-name", children: [
2514
+ /* @__PURE__ */ jsx8(FormFieldLabel3, { children: "Column Name" }),
2515
+ /* @__PURE__ */ jsx8(
2516
+ Input2,
2517
+ {
2518
+ className: "vuuInput",
2519
+ onChange: onChangeName,
2520
+ value: getCalculatedColumnName(column)
2521
+ }
2522
+ )
2523
+ ] }),
2524
+ /* @__PURE__ */ jsxs7(FormField3, { "data-field": "column-expression", children: [
2525
+ /* @__PURE__ */ jsx8(FormFieldLabel3, { children: "Expression" }),
2526
+ /* @__PURE__ */ jsx8(
2527
+ ColumnExpressionInput,
2528
+ {
2529
+ onChange: onChangeExpression,
2530
+ onSubmitExpression: handleSubmitExpression,
2531
+ source: getCalculatedColumnExpression(column),
2532
+ suggestionProvider
2533
+ }
2534
+ )
2535
+ ] }),
2536
+ /* @__PURE__ */ jsxs7(FormField3, { "data-field": "type", children: [
2537
+ /* @__PURE__ */ jsx8(FormFieldLabel3, { children: "Column type" }),
2538
+ /* @__PURE__ */ jsx8(
2539
+ Dropdown2,
2540
+ {
2541
+ className: `${classBase8}-type`,
2542
+ onSelectionChange: onChangeType,
2543
+ ref: typeRef,
2544
+ selected: getCalculatedColumnType(column) || null,
2545
+ source: ["double", "long", "string"],
2546
+ width: "100%"
2547
+ }
2548
+ )
2549
+ ] }),
2550
+ /* @__PURE__ */ jsxs7("div", { className: "vuuColumnSettingsPanel-buttonBar", "data-align": "right", children: [
2551
+ /* @__PURE__ */ jsx8(Button, { className: `${classBase8}-buttonCancel`, tabIndex: -1, children: "cancel" }),
2552
+ /* @__PURE__ */ jsx8(Button, { className: `${classBase8}-buttonApply`, tabIndex: -1, children: "apply" }),
2553
+ /* @__PURE__ */ jsx8(
2554
+ Button,
2555
+ {
2556
+ className: `${classBase8}-buttonSave`,
2557
+ onClick: onSave,
2558
+ variant: "cta",
2559
+ children: "save"
2560
+ }
2561
+ )
2562
+ ] })
2563
+ ] });
2564
+ };
2565
+
2566
+ // src/column-settings/ColumnSettingsPanel.tsx
2567
+ import { VuuInput } from "@vuu-ui/vuu-ui-controls";
2568
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2569
+ var classBase9 = "vuuColumnSettingsPanel";
2570
+ var ColumnSettingsPanel = ({
2571
+ column: columnProp,
2572
+ onConfigChange,
2573
+ onCreateCalculatedColumn,
2574
+ tableConfig,
2575
+ vuuTable
2576
+ }) => {
2577
+ const isNewCalculatedColumn = columnProp.name === "::";
2578
+ const {
2579
+ availableRenderers,
2580
+ selectedCellRenderer,
2581
+ column,
2582
+ navigateNextColumn,
2583
+ navigatePrevColumn,
2584
+ onChange,
2585
+ onChangeFormatting,
2586
+ onChangeRenderer,
2587
+ onInputCommit,
2588
+ onSave
2589
+ } = useColumnSettings({
2590
+ column: columnProp,
2591
+ onConfigChange,
2592
+ onCreateCalculatedColumn,
2593
+ tableConfig
2594
+ });
2595
+ const {
2596
+ serverDataType,
2597
+ align = getDefaultAlignment(serverDataType),
2598
+ name: name2,
2599
+ label = name2,
2600
+ pin,
2601
+ width
2602
+ } = column;
2603
+ return /* @__PURE__ */ jsxs8("div", { className: classBase9, children: [
2604
+ /* @__PURE__ */ jsx9("div", { className: `${classBase9}-header`, children: /* @__PURE__ */ jsx9("span", { children: name2 }) }),
2605
+ /* @__PURE__ */ jsxs8(FormField4, { "data-field": "column-label", children: [
2606
+ /* @__PURE__ */ jsx9(FormFieldLabel4, { children: "Column Label" }),
2607
+ /* @__PURE__ */ jsx9(
2608
+ VuuInput,
2609
+ {
2610
+ className: "vuuInput",
2611
+ onChange,
2612
+ onCommit: onInputCommit,
2613
+ value: label
2614
+ }
2615
+ )
2616
+ ] }),
2617
+ /* @__PURE__ */ jsxs8(FormField4, { "data-field": "column-width", children: [
2618
+ /* @__PURE__ */ jsx9(FormFieldLabel4, { children: "Column Width" }),
2619
+ /* @__PURE__ */ jsx9(
2620
+ VuuInput,
2621
+ {
2622
+ className: "vuuInput",
2623
+ onChange,
2624
+ value: width,
2625
+ onCommit: onInputCommit
2626
+ }
2627
+ )
2628
+ ] }),
2629
+ /* @__PURE__ */ jsxs8(FormField4, { "data-field": "column-alignment", children: [
2630
+ /* @__PURE__ */ jsx9(FormFieldLabel4, { children: "Alignment" }),
2631
+ /* @__PURE__ */ jsxs8(
2632
+ ToggleButtonGroup,
2633
+ {
2634
+ className: "vuuToggleButtonGroup",
2635
+ onChange,
2636
+ value: align,
2637
+ children: [
2638
+ /* @__PURE__ */ jsx9(
2639
+ ToggleButton,
2640
+ {
2641
+ "data-icon": "align-left",
2642
+ className: "vuuIconToggleButton",
2643
+ value: "left"
2644
+ }
2645
+ ),
2646
+ /* @__PURE__ */ jsx9(
2647
+ ToggleButton,
2648
+ {
2649
+ "data-icon": "align-right",
2650
+ className: "vuuIconToggleButton",
2651
+ value: "right"
2652
+ }
2653
+ )
2654
+ ]
2655
+ }
2656
+ )
2657
+ ] }),
2658
+ /* @__PURE__ */ jsxs8(FormField4, { "data-field": "column-pin", children: [
2659
+ /* @__PURE__ */ jsx9(FormFieldLabel4, { children: "Pin Column" }),
2660
+ /* @__PURE__ */ jsxs8(
2661
+ ToggleButtonGroup,
2662
+ {
2663
+ className: "vuuToggleButtonGroup",
2664
+ onChange,
2665
+ value: pin != null ? pin : "",
2666
+ children: [
2667
+ /* @__PURE__ */ jsx9(
2668
+ ToggleButton,
2669
+ {
2670
+ className: "vuuIconToggleButton",
2671
+ "data-icon": "cross-circle",
2672
+ value: ""
2673
+ }
2674
+ ),
2675
+ /* @__PURE__ */ jsx9(
2676
+ ToggleButton,
2677
+ {
2678
+ className: "vuuIconToggleButton",
2679
+ "data-icon": "pin-left",
2680
+ value: "left"
2681
+ }
2682
+ ),
2683
+ /* @__PURE__ */ jsx9(
2684
+ ToggleButton,
2685
+ {
2686
+ className: "vuuIconToggleButton",
2687
+ "data-icon": "pin-float",
2688
+ value: "floating"
2689
+ }
2690
+ ),
2691
+ /* @__PURE__ */ jsx9(
2692
+ ToggleButton,
2693
+ {
2694
+ className: "vuuIconToggleButton",
2695
+ "data-icon": "pin-right",
2696
+ value: "right"
2697
+ }
2698
+ )
2699
+ ]
2700
+ }
2701
+ )
2702
+ ] }),
2703
+ /* @__PURE__ */ jsx9(
2704
+ ColumnFormattingPanel,
2705
+ {
2706
+ availableRenderers,
2707
+ selectedCellRenderer,
2708
+ column,
2709
+ onChangeFormatting,
2710
+ onChangeRenderer
2711
+ }
2712
+ ),
2713
+ isCalculatedColumn(column.name) ? /* @__PURE__ */ jsx9(
2714
+ ColumnExpressionPanel,
2715
+ {
2716
+ column,
2717
+ onSave,
2718
+ tableConfig,
2719
+ vuuTable
2720
+ }
2721
+ ) : /* @__PURE__ */ jsxs8(
2722
+ "div",
2723
+ {
2724
+ className: `${classBase9}-buttonBar`,
2725
+ "data-align": isNewCalculatedColumn ? "right" : void 0,
2726
+ children: [
2727
+ /* @__PURE__ */ jsx9(
2728
+ Button2,
2729
+ {
2730
+ className: `${classBase9}-buttonNavPrev`,
2731
+ variant: "secondary",
2732
+ "data-icon": "arrow-left",
2733
+ onClick: navigatePrevColumn,
2734
+ children: "PREVIOUS"
2735
+ }
2736
+ ),
2737
+ /* @__PURE__ */ jsx9(
2738
+ Button2,
2739
+ {
2740
+ className: `${classBase9}-buttonNavNext`,
2741
+ variant: "secondary",
2742
+ "data-icon": "arrow-right",
2743
+ onClick: navigateNextColumn,
2744
+ children: "NEXT"
2745
+ }
2746
+ )
2747
+ ]
2748
+ }
2749
+ )
2750
+ ] });
2751
+ };
2752
+
2753
+ // src/datasource-stats/DatasourceStats.tsx
2754
+ import { useEffect as useEffect4, useState as useState4 } from "react";
2755
+ import cx6 from "classnames";
2756
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
2757
+ var classBase10 = "vuuDatasourceStats";
2758
+ var numberFormatter = new Intl.NumberFormat();
2759
+ var DataSourceStats = ({
2760
+ className: classNameProp,
2761
+ dataSource
2762
+ }) => {
2763
+ const [range, setRange] = useState4(dataSource.range);
2764
+ const [size, setSize] = useState4(dataSource.size);
2765
+ useEffect4(() => {
2766
+ setSize(dataSource.size);
2767
+ dataSource.on("resize", setSize);
2768
+ dataSource.on("range", setRange);
2769
+ }, [dataSource]);
2770
+ const className = cx6(classBase10, classNameProp);
2771
+ const from = numberFormatter.format(range.from);
2772
+ const to = numberFormatter.format(range.to - 1);
2773
+ const value = numberFormatter.format(size);
2774
+ return /* @__PURE__ */ jsxs9("div", { className, children: [
2775
+ /* @__PURE__ */ jsx10("span", { className: `${classBase10}-label`, children: "Row count" }),
2776
+ /* @__PURE__ */ jsx10("span", { className: `${classBase10}-range`, children: from }),
2777
+ /* @__PURE__ */ jsx10("span", { children: "-" }),
2778
+ /* @__PURE__ */ jsx10("span", { className: `${classBase10}-range`, children: to }),
2779
+ /* @__PURE__ */ jsx10("span", { children: "of" }),
2780
+ /* @__PURE__ */ jsx10("span", { className: `${classBase10}-size`, children: value })
2781
+ ] });
2782
+ };
2783
+
2784
+ // src/table-settings/TableSettingsPanel.tsx
2785
+ import {
2786
+ Button as Button4,
2787
+ FormField as FormField5,
2788
+ FormFieldLabel as FormFieldLabel5,
2789
+ Input as Input4,
2790
+ ToggleButton as ToggleButton2,
2791
+ ToggleButtonGroup as ToggleButtonGroup2
2792
+ } from "@salt-ds/core";
2793
+
2794
+ // src/table-settings/useTableSettings.ts
2795
+ import { useLayoutEffectSkipFirst as useLayoutEffectSkipFirst3 } from "@vuu-ui/vuu-layout";
2796
+
2797
+ // ../vuu-table/src/table/ColumnResizer.tsx
2798
+ import { useCallback as useCallback8, useRef as useRef8 } from "react";
2799
+ import { jsx as jsx11 } from "react/jsx-runtime";
2800
+
2801
+ // ../vuu-table/src/table/context-menu/buildContextMenuDescriptors.ts
2802
+ import { isNumericColumn as isNumericColumn2 } from "@vuu-ui/vuu-utils";
2803
+
2804
+ // ../vuu-table/src/table/context-menu/useTableContextMenu.ts
2805
+ import { removeColumnFromFilter } from "@vuu-ui/vuu-utils";
2806
+ import {
2807
+ addGroupColumn,
2808
+ addSortColumn,
2809
+ AggregationType,
2810
+ setAggregations,
2811
+ setSortColumn
2812
+ } from "@vuu-ui/vuu-utils";
2813
+ var { Average, Count, Distinct, High, Low, Sum } = AggregationType;
2814
+
2815
+ // ../vuu-table/src/table/Table.tsx
2816
+ import { ContextMenuProvider } from "@vuu-ui/vuu-popups";
2817
+ import { Button as Button3, useIdMemo } from "@salt-ds/core";
2818
+
2819
+ // ../vuu-table/src/table/RowBasedTable.tsx
2820
+ import {
2821
+ buildColumnMap,
2822
+ getColumnStyle as getColumnStyle3,
2823
+ isGroupColumn as isGroupColumn2,
2824
+ metadataKeys as metadataKeys6,
2825
+ notHidden as notHidden2,
2826
+ visibleColumnAtIndex
2827
+ } from "@vuu-ui/vuu-utils";
2828
+ import { useCallback as useCallback15, useMemo as useMemo4 } from "react";
2829
+
2830
+ // ../vuu-table/src/table/TableRow.tsx
2831
+ import {
2832
+ isGroupColumn,
2833
+ isJsonColumn,
2834
+ isJsonGroup,
2835
+ metadataKeys as metadataKeys5,
2836
+ notHidden,
2837
+ RowSelected
2838
+ } from "@vuu-ui/vuu-utils";
2839
+ import cx8 from "classnames";
2840
+ import { memo as memo2, useCallback as useCallback11 } from "react";
2841
+
2842
+ // ../vuu-table/src/table/TableCell.tsx
2843
+ import { getColumnStyle, metadataKeys as metadataKeys3 } from "@vuu-ui/vuu-utils";
2844
+ import { EditableLabel } from "@vuu-ui/vuu-ui-controls";
2845
+ import cx7 from "classnames";
2846
+ import {
2847
+ memo,
2848
+ useCallback as useCallback9,
2849
+ useRef as useRef9,
2850
+ useState as useState5
2851
+ } from "react";
2852
+ import { jsx as jsx12 } from "react/jsx-runtime";
2853
+ var { KEY: KEY3 } = metadataKeys3;
2854
+ var TableCell = memo(
2855
+ ({
2856
+ className: classNameProp,
2857
+ column,
2858
+ columnMap,
2859
+ onClick,
2860
+ row
2861
+ }) => {
2862
+ const labelFieldRef = useRef9(null);
2863
+ const {
2864
+ align,
2865
+ CellRenderer,
2866
+ key,
2867
+ pin,
2868
+ editable,
2869
+ resizing,
2870
+ valueFormatter
2871
+ } = column;
2872
+ const [editing, setEditing] = useState5(false);
2873
+ const value = valueFormatter(row[key]);
2874
+ const [editableValue, setEditableValue] = useState5(value);
2875
+ const handleTitleMouseDown = () => {
2876
+ var _a;
2877
+ (_a = labelFieldRef.current) == null ? void 0 : _a.focus();
2878
+ };
2879
+ const handleTitleKeyDown = (evt) => {
2880
+ if (evt.key === "Enter") {
2881
+ setEditing(true);
2882
+ }
2883
+ };
2884
+ const handleClick = useCallback9(
2885
+ (evt) => {
2886
+ onClick == null ? void 0 : onClick(evt, column);
2887
+ },
2888
+ [column, onClick]
2889
+ );
2890
+ const handleEnterEditMode = () => {
2891
+ setEditing(true);
2892
+ };
2893
+ const handleExitEditMode = (originalValue = "", finalValue = "", allowDeactivation = true, editCancelled = false) => {
2894
+ var _a;
2895
+ setEditing(false);
2896
+ if (editCancelled) {
2897
+ setEditableValue(originalValue);
2898
+ } else if (finalValue !== originalValue) {
2899
+ setEditableValue(finalValue);
2900
+ }
2901
+ if (allowDeactivation === false) {
2902
+ (_a = labelFieldRef.current) == null ? void 0 : _a.focus();
2903
+ }
2904
+ };
2905
+ const className = cx7(classNameProp, {
2906
+ vuuAlignRight: align === "right",
2907
+ vuuPinFloating: pin === "floating",
2908
+ vuuPinLeft: pin === "left",
2909
+ vuuPinRight: pin === "right",
2910
+ "vuuTableCell-resizing": resizing
2911
+ }) || void 0;
2912
+ const style = getColumnStyle(column);
2913
+ return editable ? /* @__PURE__ */ jsx12(
2914
+ "div",
2915
+ {
2916
+ className,
2917
+ "data-editable": true,
2918
+ role: "cell",
2919
+ style,
2920
+ onKeyDown: handleTitleKeyDown,
2921
+ children: /* @__PURE__ */ jsx12(
2922
+ EditableLabel,
2923
+ {
2924
+ editing,
2925
+ value: editableValue,
2926
+ onChange: setEditableValue,
2927
+ onMouseDownCapture: handleTitleMouseDown,
2928
+ onEnterEditMode: handleEnterEditMode,
2929
+ onExitEditMode: handleExitEditMode,
2930
+ onKeyDown: handleTitleKeyDown,
2931
+ ref: labelFieldRef,
2932
+ tabIndex: 0
2933
+ },
2934
+ "title"
2935
+ )
2936
+ }
2937
+ ) : /* @__PURE__ */ jsx12(
2938
+ "div",
2939
+ {
2940
+ className,
2941
+ role: "cell",
2942
+ style,
2943
+ onClick: handleClick,
2944
+ children: CellRenderer ? /* @__PURE__ */ jsx12(CellRenderer, { column, columnMap, row }) : value
2945
+ }
2946
+ );
2947
+ },
2948
+ cellValuesAreEqual
2949
+ );
2950
+ TableCell.displayName = "TableCell";
2951
+ function cellValuesAreEqual(prev, next) {
2952
+ return prev.column === next.column && prev.onClick === next.onClick && prev.row[KEY3] === next.row[KEY3] && prev.row[prev.column.key] === next.row[next.column.key];
2953
+ }
2954
+
2955
+ // ../vuu-table/src/table/TableGroupCell.tsx
2956
+ import {
2957
+ getColumnStyle as getColumnStyle2,
2958
+ getGroupValueAndOffset,
2959
+ metadataKeys as metadataKeys4
2960
+ } from "@vuu-ui/vuu-utils";
2961
+ import { useCallback as useCallback10 } from "react";
2962
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2963
+ var { IS_LEAF } = metadataKeys4;
2964
+ var TableGroupCell = ({ column, onClick, row }) => {
2965
+ const { columns } = column;
2966
+ const [value, offset] = getGroupValueAndOffset(columns, row);
2967
+ const handleClick = useCallback10(
2968
+ (evt) => {
2969
+ onClick == null ? void 0 : onClick(evt, column);
2970
+ },
2971
+ [column, onClick]
2972
+ );
2973
+ const style = getColumnStyle2(column);
2974
+ const isLeaf = row[IS_LEAF];
2975
+ const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ jsx13("span", { className: "vuuTableGroupCell-spacer" }, i));
2976
+ return /* @__PURE__ */ jsxs10(
2977
+ "div",
2978
+ {
2979
+ className: "vuuTableGroupCell vuuPinLeft",
2980
+ onClick: isLeaf ? void 0 : handleClick,
2981
+ role: "cell",
2982
+ style,
2983
+ children: [
2984
+ spacers,
2985
+ isLeaf ? null : /* @__PURE__ */ jsx13("span", { className: "vuuTableGroupCell-toggle", "data-icon": "triangle-right" }),
2986
+ /* @__PURE__ */ jsx13("span", { children: value })
2987
+ ]
2988
+ }
2989
+ );
2990
+ };
2991
+
2992
+ // ../vuu-table/src/table/TableRow.tsx
2993
+ import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
2994
+ var { IDX, IS_EXPANDED, SELECTED } = metadataKeys5;
2995
+ var { True, First, Last } = RowSelected;
2996
+ var classBase11 = "vuuTableRow";
2997
+ var TableRow = memo2(function Row({
2998
+ columnMap,
2999
+ columns,
3000
+ offset,
3001
+ onClick,
3002
+ onToggleGroup,
3003
+ virtualColSpan = 0,
3004
+ row
3005
+ }) {
3006
+ const {
3007
+ [IDX]: rowIndex,
3008
+ [IS_EXPANDED]: isExpanded,
3009
+ [SELECTED]: selectionStatus
3010
+ } = row;
3011
+ const className = cx8(classBase11, {
3012
+ [`${classBase11}-even`]: rowIndex % 2 === 0,
3013
+ [`${classBase11}-expanded`]: isExpanded,
3014
+ [`${classBase11}-selected`]: selectionStatus & True,
3015
+ [`${classBase11}-selectedStart`]: selectionStatus & First,
3016
+ [`${classBase11}-selectedEnd`]: selectionStatus & Last
3017
+ });
3018
+ const handleRowClick = useCallback11(
3019
+ (evt) => {
3020
+ const rangeSelect = evt.shiftKey;
3021
+ const keepExistingSelection = evt.ctrlKey || evt.metaKey;
3022
+ onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
3023
+ },
3024
+ [onClick, row]
3025
+ );
3026
+ const handleGroupCellClick = useCallback11(
3027
+ (evt, column) => {
3028
+ if (isGroupColumn(column) || isJsonGroup(column, row)) {
3029
+ evt.stopPropagation();
3030
+ onToggleGroup == null ? void 0 : onToggleGroup(row, column);
3031
+ }
3032
+ },
3033
+ [onToggleGroup, row]
3034
+ );
3035
+ return /* @__PURE__ */ jsxs11(
3036
+ "div",
3037
+ {
3038
+ "aria-selected": selectionStatus & True ? true : void 0,
3039
+ "aria-rowindex": rowIndex,
3040
+ className,
3041
+ onClick: handleRowClick,
3042
+ role: "row",
3043
+ style: {
3044
+ transform: `translate3d(0px, ${offset}px, 0px)`
3045
+ },
3046
+ children: [
3047
+ virtualColSpan > 0 ? /* @__PURE__ */ jsx14("div", { role: "cell", style: { width: virtualColSpan } }) : null,
3048
+ columns.filter(notHidden).map((column) => {
3049
+ const isGroup = isGroupColumn(column);
3050
+ const isJsonCell = isJsonColumn(column);
3051
+ const Cell = isGroup ? TableGroupCell : TableCell;
3052
+ return /* @__PURE__ */ jsx14(
3053
+ Cell,
3054
+ {
3055
+ column,
3056
+ columnMap,
3057
+ onClick: isGroup || isJsonCell ? handleGroupCellClick : void 0,
3058
+ row
3059
+ },
3060
+ column.name
3061
+ );
3062
+ })
3063
+ ]
3064
+ }
3065
+ );
3066
+ });
3067
+
3068
+ // ../vuu-table/src/table/TableGroupHeaderCell.tsx
3069
+ import cx9 from "classnames";
3070
+ import { useRef as useRef11 } from "react";
3071
+
3072
+ // ../vuu-table/src/table/useTableColumnResize.tsx
3073
+ import { useCallback as useCallback12, useRef as useRef10 } from "react";
3074
+
3075
+ // ../vuu-table/src/table/TableGroupHeaderCell.tsx
3076
+ import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
3077
+
3078
+ // ../vuu-table/src/table/TableHeaderCell.tsx
3079
+ import cx12 from "classnames";
3080
+ import { useCallback as useCallback14, useRef as useRef12 } from "react";
3081
+
3082
+ // ../vuu-table/src/table/SortIndicator.tsx
3083
+ import cx10 from "classnames";
3084
+ import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
3085
+
3086
+ // ../vuu-table/src/table/TableHeaderCell.tsx
3087
+ import { useContextMenu as useContextMenu2 } from "@vuu-ui/vuu-popups";
3088
+
3089
+ // ../vuu-table/src/table/filter-indicator.tsx
3090
+ import { useContextMenu } from "@vuu-ui/vuu-popups";
3091
+ import cx11 from "classnames";
3092
+ import { useCallback as useCallback13 } from "react";
3093
+ import { jsx as jsx17 } from "react/jsx-runtime";
3094
+
3095
+ // ../vuu-table/src/table/TableHeaderCell.tsx
3096
+ import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
3097
+
3098
+ // ../vuu-table/src/table/RowBasedTable.tsx
3099
+ import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
3100
+ var { RENDER_IDX } = metadataKeys6;
3101
+
3102
+ // ../vuu-table/src/table/useTable.ts
3103
+ import { useContextMenu as usePopupContextMenu } from "@vuu-ui/vuu-popups";
3104
+ import {
3105
+ applySort,
3106
+ buildColumnMap as buildColumnMap2,
3107
+ isJsonGroup as isJsonGroup2,
3108
+ metadataKeys as metadataKeys10,
3109
+ moveItemDeprecated as moveItemDeprecated2
3110
+ } from "@vuu-ui/vuu-utils";
3111
+ import {
3112
+ useCallback as useCallback25,
3113
+ useEffect as useEffect9,
3114
+ useMemo as useMemo10,
3115
+ useRef as useRef22,
3116
+ useState as useState9
3117
+ } from "react";
3118
+
3119
+ // ../vuu-table/src/table/useDataSource.ts
3120
+ import {
3121
+ isVuuFeatureAction,
3122
+ isVuuFeatureInvocation
3123
+ } from "@vuu-ui/vuu-data-react";
3124
+ import { getFullRange, metadataKeys as metadataKeys7, WindowRange } from "@vuu-ui/vuu-utils";
3125
+ import { useCallback as useCallback16, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef13, useState as useState6 } from "react";
3126
+ var { SELECTED: SELECTED2 } = metadataKeys7;
3127
+
3128
+ // ../vuu-table/src/table/useDraggableColumn.ts
3129
+ import { useDragDropNext as useDragDrop } from "@vuu-ui/vuu-ui-controls";
3130
+ import { useCallback as useCallback17, useRef as useRef14 } from "react";
3131
+
3132
+ // ../vuu-table/src/table/useKeyboardNavigation.ts
3133
+ import { withinRange } from "@vuu-ui/vuu-utils";
3134
+ import {
3135
+ useCallback as useCallback18,
3136
+ useEffect as useEffect6,
3137
+ useLayoutEffect,
3138
+ useMemo as useMemo6,
3139
+ useRef as useRef15
3140
+ } from "react";
3141
+
3142
+ // ../vuu-table/src/table/keyUtils.ts
3143
+ function union(set1, ...sets) {
3144
+ const result = new Set(set1);
3145
+ for (let set of sets) {
3146
+ for (let element of set) {
3147
+ result.add(element);
3148
+ }
3149
+ }
3150
+ return result;
3151
+ }
3152
+ var ArrowUp = "ArrowUp";
3153
+ var ArrowDown = "ArrowDown";
3154
+ var ArrowLeft = "ArrowLeft";
3155
+ var ArrowRight = "ArrowRight";
3156
+ var Home = "Home";
3157
+ var End = "End";
3158
+ var PageUp = "PageUp";
3159
+ var PageDown = "PageDown";
3160
+ var actionKeys = /* @__PURE__ */ new Set(["Enter", "Delete", " "]);
3161
+ var focusKeys = /* @__PURE__ */ new Set(["Tab"]);
3162
+ var arrowLeftRightKeys = /* @__PURE__ */ new Set(["ArrowRight", "ArrowLeft"]);
3163
+ var navigationKeys = /* @__PURE__ */ new Set([
3164
+ Home,
3165
+ End,
3166
+ PageUp,
3167
+ PageDown,
3168
+ ArrowDown,
3169
+ ArrowLeft,
3170
+ ArrowRight,
3171
+ ArrowUp
3172
+ ]);
3173
+ var functionKeys = /* @__PURE__ */ new Set([
3174
+ "F1",
3175
+ "F2",
3176
+ "F3",
3177
+ "F4",
3178
+ "F5",
3179
+ "F6",
3180
+ "F7",
3181
+ "F8",
3182
+ "F9",
3183
+ "F10",
3184
+ "F11",
3185
+ "F12"
3186
+ ]);
3187
+ var specialKeys = union(
3188
+ actionKeys,
3189
+ navigationKeys,
3190
+ arrowLeftRightKeys,
3191
+ functionKeys,
3192
+ focusKeys
3193
+ );
3194
+
3195
+ // ../vuu-table/src/table/useMeasuredContainer.ts
3196
+ import { isValidNumber as isValidNumber4 } from "@vuu-ui/vuu-utils";
3197
+ import { useCallback as useCallback20, useMemo as useMemo7, useRef as useRef17, useState as useState7 } from "react";
3198
+
3199
+ // ../vuu-table/src/table/useResizeObserver.ts
3200
+ import { useCallback as useCallback19, useEffect as useEffect7, useRef as useRef16 } from "react";
3201
+ var observedMap = /* @__PURE__ */ new Map();
3202
+ var getTargetSize = (element, size, dimension) => {
3203
+ switch (dimension) {
3204
+ case "height":
3205
+ return size.height;
3206
+ case "clientHeight":
3207
+ return element.clientHeight;
3208
+ case "clientWidth":
3209
+ return element.clientWidth;
3210
+ case "contentHeight":
3211
+ return size.contentHeight;
3212
+ case "contentWidth":
3213
+ return size.contentWidth;
3214
+ case "scrollHeight":
3215
+ return Math.ceil(element.scrollHeight);
3216
+ case "scrollWidth":
3217
+ return Math.ceil(element.scrollWidth);
3218
+ case "width":
3219
+ return size.width;
3220
+ default:
3221
+ return 0;
3222
+ }
3223
+ };
3224
+ var resizeObserver = new ResizeObserver((entries) => {
3225
+ for (const entry of entries) {
3226
+ const { target, borderBoxSize, contentBoxSize } = entry;
3227
+ const observedTarget = observedMap.get(target);
3228
+ if (observedTarget) {
3229
+ const [{ blockSize: height, inlineSize: width }] = borderBoxSize;
3230
+ const [{ blockSize: contentHeight, inlineSize: contentWidth }] = contentBoxSize;
3231
+ const { onResize, measurements } = observedTarget;
3232
+ let sizeChanged = false;
3233
+ for (const [dimension, size] of Object.entries(measurements)) {
3234
+ const newSize = getTargetSize(
3235
+ target,
3236
+ { height, width, contentHeight, contentWidth },
3237
+ dimension
3238
+ );
3239
+ if (newSize !== size) {
3240
+ sizeChanged = true;
3241
+ measurements[dimension] = newSize;
3242
+ }
3243
+ }
3244
+ if (sizeChanged) {
3245
+ onResize && onResize(measurements);
3246
+ }
3247
+ }
3248
+ }
3249
+ });
3250
+
3251
+ // ../vuu-table/src/table/useSelection.ts
3252
+ import {
3253
+ deselectItem,
3254
+ isRowSelected,
3255
+ metadataKeys as metadataKeys8,
3256
+ selectItem
3257
+ } from "@vuu-ui/vuu-utils";
3258
+ import { useCallback as useCallback21, useRef as useRef18 } from "react";
3259
+ var { IDX: IDX2 } = metadataKeys8;
3260
+
3261
+ // ../vuu-table/src/table/useTableModel.ts
3262
+ import {
3263
+ applyFilterToColumns,
3264
+ applyGroupByToColumns,
3265
+ applySortToColumns,
3266
+ findColumn,
3267
+ getCellRenderer,
3268
+ getColumnName as getColumnName2,
3269
+ getTableHeadings,
3270
+ getValueFormatter,
3271
+ isFilteredColumn,
3272
+ isGroupColumn as isGroupColumn3,
3273
+ isPinned,
3274
+ isTypeDescriptor as isTypeDescriptor7,
3275
+ metadataKeys as metadataKeys9,
3276
+ updateColumn,
3277
+ sortPinnedColumns,
3278
+ stripFilterFromColumns,
3279
+ moveItemDeprecated,
3280
+ getDefaultAlignment as getDefaultAlignment2
3281
+ } from "@vuu-ui/vuu-utils";
3282
+ import { useReducer } from "react";
3283
+ var KEY_OFFSET = metadataKeys9.count;
3284
+
3285
+ // ../vuu-table/src/table/useTableScroll.ts
3286
+ import { useCallback as useCallback22, useRef as useRef19 } from "react";
3287
+
3288
+ // ../vuu-table/src/table-next/useTableViewport.ts
3289
+ import { useCallback as useCallback23, useMemo as useMemo8, useRef as useRef20 } from "react";
3290
+ import {
3291
+ actualRowPositioning,
3292
+ virtualRowPositioning
3293
+ } from "@vuu-ui/vuu-utils";
3294
+
3295
+ // ../vuu-table/src/table/useVirtualViewport.ts
3296
+ import {
3297
+ getColumnsInViewport,
3298
+ itemsChanged
3299
+ } from "@vuu-ui/vuu-utils";
3300
+ import { useCallback as useCallback24, useEffect as useEffect8, useMemo as useMemo9, useRef as useRef21, useState as useState8 } from "react";
3301
+
3302
+ // ../vuu-table/src/table/useTable.ts
3303
+ var { KEY: KEY4, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = metadataKeys10;
3304
+
3305
+ // ../vuu-table/src/table/Table.tsx
3306
+ import cx13 from "classnames";
3307
+ import { isDataLoading } from "@vuu-ui/vuu-utils";
3308
+ import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
3309
+
3310
+ // ../vuu-table/src/table/cell-renderers/json-cell/JsonCell.tsx
3311
+ import cx14 from "classnames";
3312
+ import {
3313
+ isJsonAttribute,
3314
+ metadataKeys as metadataKeys11,
3315
+ registerComponent as registerComponent6
3316
+ } from "@vuu-ui/vuu-utils";
3317
+ import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
3318
+ var classBase12 = "vuuJsonCell";
3319
+ var { IS_EXPANDED: IS_EXPANDED3, KEY: KEY5 } = metadataKeys11;
3320
+ var localKey = (key) => {
3321
+ const pos = key.lastIndexOf("|");
3322
+ if (pos === -1) {
3323
+ return "";
3324
+ } else {
3325
+ return key.slice(pos + 1);
3326
+ }
3327
+ };
3328
+ var JsonCell = ({ column, row }) => {
3329
+ const {
3330
+ key: columnKey
3331
+ /*, type, valueFormatter */
3332
+ } = column;
3333
+ let value = row[columnKey];
3334
+ let isToggle = false;
3335
+ if (isJsonAttribute(value)) {
3336
+ value = value.slice(0, -1);
3337
+ isToggle = true;
3338
+ }
3339
+ const rowKey = localKey(row[KEY5]);
3340
+ const className = cx14({
3341
+ [`${classBase12}-name`]: rowKey === value,
3342
+ [`${classBase12}-value`]: rowKey !== value,
3343
+ [`${classBase12}-group`]: isToggle
3344
+ });
3345
+ if (isToggle) {
3346
+ const toggleIcon = row[IS_EXPANDED3] ? "minus-box" : "plus-box";
3347
+ return /* @__PURE__ */ jsxs17("span", { className, children: [
3348
+ /* @__PURE__ */ jsx21("span", { className: `${classBase12}-value`, children: value }),
3349
+ /* @__PURE__ */ jsx21("span", { className: `${classBase12}-toggle`, "data-icon": toggleIcon })
3350
+ ] });
3351
+ } else if (value) {
3352
+ return /* @__PURE__ */ jsx21("span", { className, children: value });
3353
+ } else {
3354
+ return null;
3355
+ }
3356
+ };
3357
+ registerComponent6("json", JsonCell, "cell-renderer", {
3358
+ description: "JSON formatter",
3359
+ label: "JSON formatter",
3360
+ serverDataType: "json"
3361
+ });
3362
+
3363
+ // ../vuu-table/src/table-next/header-cell/GroupHeaderCell.tsx
3364
+ import cx17 from "classnames";
3365
+ import { useRef as useRef25 } from "react";
3366
+
3367
+ // ../vuu-table/src/table-next/column-resizing/ColumnResizer.tsx
3368
+ import { useCallback as useCallback26, useRef as useRef23 } from "react";
3369
+ import { jsx as jsx22 } from "react/jsx-runtime";
3370
+
3371
+ // ../vuu-table/src/table-next/column-resizing/useTableColumnResize.tsx
3372
+ import { useCallback as useCallback27, useRef as useRef24, useState as useState10 } from "react";
3373
+
3374
+ // ../vuu-table/src/table-next/useCell.ts
3375
+ import { getColumnStyle as getColumnStyle4 } from "@vuu-ui/vuu-utils";
3376
+ import cx15 from "classnames";
3377
+ import { useMemo as useMemo11 } from "react";
3378
+ var useCell = (column, classBase19, isHeader) => (
3379
+ // TODO measure perf without the memo, might not be worth the cost
3380
+ useMemo11(() => {
3381
+ const className = cx15(classBase19, {
3382
+ vuuPinFloating: column.pin === "floating",
3383
+ vuuPinLeft: column.pin === "left",
3384
+ vuuPinRight: column.pin === "right",
3385
+ vuuEndPin: isHeader && column.endPin,
3386
+ // [`${classBase}-resizing`]: column.resizing,
3387
+ [`${classBase19}-editable`]: column.editable,
3388
+ [`${classBase19}-right`]: column.align === "right"
3389
+ });
3390
+ const style = getColumnStyle4(column);
3391
+ return {
3392
+ className,
3393
+ style
3394
+ };
3395
+ }, [column, classBase19, isHeader])
3396
+ );
3397
+
3398
+ // ../vuu-table/src/table-next/column-header-pill/ColumnHeaderPill.tsx
3399
+ import cx16 from "classnames";
3400
+ import { useCallback as useCallback28 } from "react";
3401
+ import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
3402
+
3403
+ // ../vuu-table/src/table-next/column-header-pill/GroupColumnPill.tsx
3404
+ import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
3405
+
3406
+ // ../vuu-table/src/table-next/column-header-pill/SortIndicator.tsx
3407
+ import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
3408
+
3409
+ // ../vuu-table/src/table-next/header-cell/GroupHeaderCell.tsx
3410
+ import { jsx as jsx26, jsxs as jsxs21 } from "react/jsx-runtime";
3411
+ import { createElement } from "react";
3412
+
3413
+ // ../vuu-table/src/table-next/header-cell/GroupHeaderCellNext.tsx
3414
+ import cx18 from "classnames";
3415
+ import { useCallback as useCallback29, useRef as useRef26, useState as useState11 } from "react";
3416
+ import {
3417
+ OverflowContainer,
3418
+ useLayoutEffectSkipFirst
3419
+ } from "@vuu-ui/vuu-layout";
3420
+ import { jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
3421
+ import { createElement as createElement2 } from "react";
3422
+
3423
+ // ../vuu-table/src/table-next/header-cell/HeaderCell.tsx
3424
+ import { useCallback as useCallback31, useRef as useRef28 } from "react";
3425
+
3426
+ // ../vuu-table/src/table-next/column-menu/ColumnMenu.tsx
3427
+ import { useContextMenu as useContextMenu3 } from "@vuu-ui/vuu-popups";
3428
+ import cx19 from "classnames";
3429
+ import {
3430
+ useCallback as useCallback30,
3431
+ useRef as useRef27,
3432
+ useState as useState12
3433
+ } from "react";
3434
+ import { jsx as jsx28 } from "react/jsx-runtime";
3435
+
3436
+ // ../vuu-table/src/table-next/header-cell/HeaderCell.tsx
3437
+ import cx20 from "classnames";
3438
+ import { jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
3439
+
3440
+ // ../vuu-table/src/table-next/TableNext.tsx
3441
+ import { ContextMenuProvider as ContextMenuProvider2 } from "@vuu-ui/vuu-popups";
3442
+ import { isGroupColumn as isGroupColumn7, metadataKeys as metadataKeys18, notHidden as notHidden4 } from "@vuu-ui/vuu-utils";
3443
+ import cx23 from "classnames";
3444
+ import { useRef as useRef34 } from "react";
3445
+
3446
+ // ../vuu-table/src/table-next/Row.tsx
3447
+ import {
3448
+ isGroupColumn as isGroupColumn4,
3449
+ isJsonColumn as isJsonColumn2,
3450
+ isJsonGroup as isJsonGroup3,
3451
+ metadataKeys as metadataKeys14,
3452
+ notHidden as notHidden3,
3453
+ RowSelected as RowSelected2
3454
+ } from "@vuu-ui/vuu-utils";
3455
+ import cx22 from "classnames";
3456
+ import { memo as memo3, useCallback as useCallback34 } from "react";
3457
+
3458
+ // ../vuu-table/src/table-next/table-cell/TableCell.tsx
3459
+ import { metadataKeys as metadataKeys12 } from "@vuu-ui/vuu-utils";
3460
+ import { useCallback as useCallback32 } from "react";
3461
+ import { jsx as jsx30 } from "react/jsx-runtime";
3462
+ var { IDX: IDX3 } = metadataKeys12;
3463
+ var classBase13 = "vuuTableNextCell";
3464
+ var TableCell2 = ({
3465
+ column,
3466
+ columnMap,
3467
+ onDataEdited,
3468
+ row
3469
+ }) => {
3470
+ const { className, style } = useCell(column, classBase13);
3471
+ const { CellRenderer, name: name2, valueFormatter } = column;
3472
+ const dataIdx = columnMap[name2];
3473
+ const handleDataItemEdited = useCallback32(
3474
+ (value) => {
3475
+ onDataEdited == null ? void 0 : onDataEdited(row[IDX3], name2, value);
3476
+ return true;
3477
+ },
3478
+ [name2, onDataEdited, row]
3479
+ );
3480
+ return /* @__PURE__ */ jsx30("div", { className, role: "cell", style, children: CellRenderer ? /* @__PURE__ */ jsx30(
3481
+ CellRenderer,
3482
+ {
3483
+ column,
3484
+ columnMap,
3485
+ onCommit: handleDataItemEdited,
3486
+ row
3487
+ }
3488
+ ) : valueFormatter(row[dataIdx]) });
3489
+ };
3490
+
3491
+ // ../vuu-table/src/table-next/table-cell/TableGroupCell.tsx
3492
+ import { getGroupValueAndOffset as getGroupValueAndOffset2, metadataKeys as metadataKeys13 } from "@vuu-ui/vuu-utils";
3493
+ import { useCallback as useCallback33 } from "react";
3494
+ import cx21 from "classnames";
3495
+ import { jsx as jsx31, jsxs as jsxs24 } from "react/jsx-runtime";
3496
+ var { IS_LEAF: IS_LEAF3 } = metadataKeys13;
3497
+ var classBase14 = "vuuTableNextGroupCell";
3498
+ var TableGroupCell2 = ({ column, onClick, row }) => {
3499
+ const { columns } = column;
3500
+ const [value, offset] = getGroupValueAndOffset2(columns, row);
3501
+ const { className, style } = useCell(column, classBase14);
3502
+ const handleClick = useCallback33(
3503
+ (evt) => {
3504
+ onClick == null ? void 0 : onClick(evt, column);
3505
+ },
3506
+ [column, onClick]
3507
+ );
3508
+ const isLeaf = row[IS_LEAF3];
3509
+ const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ jsx31("span", { className: `${classBase14}-spacer` }, i));
3510
+ return /* @__PURE__ */ jsxs24(
3511
+ "div",
3512
+ {
3513
+ className: cx21(className, "vuuTableNextCell"),
3514
+ role: "cell",
3515
+ style,
3516
+ onClick: isLeaf ? void 0 : handleClick,
3517
+ children: [
3518
+ spacers,
3519
+ isLeaf ? null : /* @__PURE__ */ jsx31("span", { className: `${classBase14}-toggle`, "data-icon": "triangle-right" }),
3520
+ /* @__PURE__ */ jsx31("span", { children: value })
3521
+ ]
3522
+ }
3523
+ );
3524
+ };
3525
+
3526
+ // ../vuu-table/src/table-next/Row.tsx
3527
+ import { jsx as jsx32 } from "react/jsx-runtime";
3528
+ import { createElement as createElement3 } from "react";
3529
+ var { IDX: IDX4, IS_EXPANDED: IS_EXPANDED4, SELECTED: SELECTED3 } = metadataKeys14;
3530
+ var classBase15 = "vuuTableNextRow";
3531
+ var Row2 = memo3(
3532
+ ({
3533
+ className: classNameProp,
3534
+ columnMap,
3535
+ columns,
3536
+ row,
3537
+ offset,
3538
+ onClick,
3539
+ onDataEdited,
3540
+ onToggleGroup,
3541
+ zebraStripes = false,
3542
+ ...htmlAttributes
3543
+ }) => {
3544
+ const {
3545
+ [IDX4]: rowIndex,
3546
+ [IS_EXPANDED4]: isExpanded,
3547
+ [SELECTED3]: selectionStatus
3548
+ } = row;
3549
+ const handleRowClick = useCallback34(
3550
+ (evt) => {
3551
+ const rangeSelect = evt.shiftKey;
3552
+ const keepExistingSelection = evt.ctrlKey || evt.metaKey;
3553
+ onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
3554
+ },
3555
+ [onClick, row]
3556
+ );
3557
+ const { True: True2, First: First2, Last: Last2 } = RowSelected2;
3558
+ const className = cx22(classBase15, classNameProp, {
3559
+ [`${classBase15}-even`]: zebraStripes && rowIndex % 2 === 0,
3560
+ [`${classBase15}-expanded`]: isExpanded,
3561
+ [`${classBase15}-selected`]: selectionStatus & True2,
3562
+ [`${classBase15}-selectedStart`]: selectionStatus & First2,
3563
+ [`${classBase15}-selectedEnd`]: selectionStatus & Last2
3564
+ });
3565
+ const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
3566
+ const handleGroupCellClick = useCallback34(
3567
+ (evt, column) => {
3568
+ if (isGroupColumn4(column) || isJsonGroup3(column, row)) {
3569
+ evt.stopPropagation();
3570
+ onToggleGroup == null ? void 0 : onToggleGroup(row, column);
3571
+ }
3572
+ },
3573
+ [onToggleGroup, row]
3574
+ );
3575
+ return /* @__PURE__ */ createElement3(
3576
+ "div",
3577
+ {
3578
+ ...htmlAttributes,
3579
+ "aria-rowindex": row[0],
3580
+ key: `row-${row[0]}`,
3581
+ role: "row",
3582
+ className,
3583
+ onClick: handleRowClick,
3584
+ style
3585
+ },
3586
+ /* @__PURE__ */ jsx32("span", { className: `${classBase15}-selectionDecorator vuuStickyLeft` }),
3587
+ columns.filter(notHidden3).map((column) => {
3588
+ const isGroup = isGroupColumn4(column);
3589
+ const isJsonCell = isJsonColumn2(column);
3590
+ const Cell = isGroup ? TableGroupCell2 : TableCell2;
3591
+ return /* @__PURE__ */ jsx32(
3592
+ Cell,
3593
+ {
3594
+ column,
3595
+ columnMap,
3596
+ onClick: isGroup || isJsonCell ? handleGroupCellClick : void 0,
3597
+ onDataEdited,
3598
+ row
3599
+ },
3600
+ column.key
3601
+ );
3602
+ }),
3603
+ /* @__PURE__ */ jsx32("span", { className: `${classBase15}-selectionDecorator vuuStickyRight` })
3604
+ );
3605
+ }
3606
+ );
3607
+ Row2.displayName = "Row";
3608
+
3609
+ // ../vuu-table/src/table-next/useTableNext.ts
3610
+ import { useLayoutEffectSkipFirst as useLayoutEffectSkipFirst2 } from "@vuu-ui/vuu-layout";
3611
+ import { useDragDropNext as useDragDrop2 } from "@vuu-ui/vuu-ui-controls";
3612
+
3613
+ // ../vuu-table/src/table-next/useKeyboardNavigation.ts
3614
+ import {
3615
+ useCallback as useCallback35,
3616
+ useEffect as useEffect10,
3617
+ useMemo as useMemo12,
3618
+ useRef as useRef29
3619
+ } from "react";
3620
+
3621
+ // ../vuu-table/src/table-next/useTableNext.ts
3622
+ import {
3623
+ applySort as applySort2,
3624
+ buildColumnMap as buildColumnMap4,
3625
+ isGroupColumn as isGroupColumn6,
3626
+ isJsonGroup as isJsonGroup4,
3627
+ isValidNumber as isValidNumber5,
3628
+ metadataKeys as metadataKeys17,
3629
+ updateColumn as updateColumn2,
3630
+ visibleColumnAtIndex as visibleColumnAtIndex2
3631
+ } from "@vuu-ui/vuu-utils";
3632
+ import {
3633
+ useCallback as useCallback41,
3634
+ useEffect as useEffect13,
3635
+ useMemo as useMemo15,
3636
+ useState as useState14
3637
+ } from "react";
3638
+
3639
+ // ../vuu-table/src/table-next/table-config.ts
3640
+ var updateTableConfig = (config, action) => {
3641
+ switch (action.type) {
3642
+ case "col-size":
3643
+ return {
3644
+ ...config,
3645
+ columns: config.columns.map(
3646
+ (col) => col.name === action.column.name ? { ...col, width: action.width } : col
3647
+ )
3648
+ };
3649
+ case "column-prop":
3650
+ return {
3651
+ ...config,
3652
+ columns: config.columns.map(
3653
+ (col) => col.name === action.column.name ? { ...col, [action.property]: action.value } : col
3654
+ )
3655
+ };
3656
+ default:
3657
+ return config;
3658
+ }
3659
+ };
3660
+
3661
+ // ../vuu-table/src/table-next/useDataSource.ts
3662
+ import {
3663
+ isVuuFeatureAction as isVuuFeatureAction2,
3664
+ isVuuFeatureInvocation as isVuuFeatureInvocation2
3665
+ } from "@vuu-ui/vuu-data-react/src";
3666
+ import { getFullRange as getFullRange2, NULL_RANGE } from "@vuu-ui/vuu-utils";
3667
+ import { useCallback as useCallback36, useEffect as useEffect11, useMemo as useMemo13, useRef as useRef30, useState as useState13 } from "react";
3668
+
3669
+ // ../vuu-table/src/table-next/moving-window.ts
3670
+ import { metadataKeys as metadataKeys15, WindowRange as WindowRange2 } from "@vuu-ui/vuu-utils";
3671
+ var { SELECTED: SELECTED4 } = metadataKeys15;
3672
+
3673
+ // ../vuu-table/src/table-next/useInitialValue.ts
3674
+ import { useMemo as useMemo14, useRef as useRef31 } from "react";
3675
+
3676
+ // ../vuu-table/src/table-next/useTableContextMenu.ts
3677
+ import { buildColumnMap as buildColumnMap3 } from "@vuu-ui/vuu-utils";
3678
+ import { useCallback as useCallback37 } from "react";
3679
+ import { useContextMenu as usePopupContextMenu2 } from "@vuu-ui/vuu-popups";
3680
+
3681
+ // ../vuu-table/src/table-next/useCellEditing.ts
3682
+ import { isCharacterKey } from "@vuu-ui/vuu-utils";
3683
+ import { useCallback as useCallback38 } from "react";
3684
+
3685
+ // ../vuu-table/src/table-next/useTableModel.ts
3686
+ import {
3687
+ applyFilterToColumns as applyFilterToColumns2,
3688
+ applyGroupByToColumns as applyGroupByToColumns2,
3689
+ applySortToColumns as applySortToColumns2,
3690
+ getCellRenderer as getCellRenderer2,
3691
+ getTableHeadings as getTableHeadings2,
3692
+ getValueFormatter as getValueFormatter2,
3693
+ hasValidationRules,
3694
+ isFilteredColumn as isFilteredColumn2,
3695
+ isGroupColumn as isGroupColumn5,
3696
+ isPinned as isPinned2,
3697
+ isTypeDescriptor as isTypeDescriptor8,
3698
+ logger,
3699
+ metadataKeys as metadataKeys16,
3700
+ moveItem,
3701
+ sortPinnedColumns as sortPinnedColumns2,
3702
+ stripFilterFromColumns as stripFilterFromColumns2,
3703
+ subscribedOnly
3704
+ } from "@vuu-ui/vuu-utils";
3705
+ import { buildValidationChecker } from "@vuu-ui/vuu-ui-controls";
3706
+ import { useReducer as useReducer2 } from "react";
3707
+ var { info } = logger("useTableModel");
3708
+ var KEY_OFFSET2 = metadataKeys16.count;
3709
+
3710
+ // ../vuu-table/src/table-next/useTableScroll.ts
3711
+ import { useCallback as useCallback39, useRef as useRef32 } from "react";
3712
+
3713
+ // ../vuu-table/src/table-next/useVirtualViewport.ts
3714
+ import { useCallback as useCallback40, useEffect as useEffect12, useRef as useRef33 } from "react";
3715
+
3716
+ // ../vuu-table/src/table-next/useTableNext.ts
3717
+ var { KEY: KEY6, IS_EXPANDED: IS_EXPANDED5, IS_LEAF: IS_LEAF4 } = metadataKeys17;
3718
+
3719
+ // ../vuu-table/src/table-next/TableNext.tsx
3720
+ import { MeasuredContainer, useId } from "@vuu-ui/vuu-layout";
3721
+ import { jsx as jsx33, jsxs as jsxs25 } from "react/jsx-runtime";
3722
+ import { createElement as createElement4 } from "react";
3723
+ var { IDX: IDX5, RENDER_IDX: RENDER_IDX2 } = metadataKeys18;
3724
+
3725
+ // ../vuu-table/src/table-next/cell-renderers/dropdown-cell/DropdownCell.tsx
3726
+ import {
3727
+ Dropdown as Dropdown3
3728
+ } from "@vuu-ui/vuu-ui-controls";
3729
+ import {
3730
+ isColumnTypeRenderer as isColumnTypeRenderer3,
3731
+ isTypeDescriptor as isTypeDescriptor9,
3732
+ registerComponent as registerComponent7
3733
+ } from "@vuu-ui/vuu-utils";
3734
+ import { useCallback as useCallback42, useState as useState15 } from "react";
3735
+ import { jsx as jsx34 } from "react/jsx-runtime";
3736
+ var classBase16 = "vuuTableDropdownCell";
3737
+ var openKeys = ["Enter", " "];
3738
+ var DropdownCell = ({ column, columnMap, row }) => {
3739
+ var _a, _b, _c;
3740
+ const values = isTypeDescriptor9(column.type) && isColumnTypeRenderer3((_a = column.type) == null ? void 0 : _a.renderer) ? (_c = (_b = column.type) == null ? void 0 : _b.renderer) == null ? void 0 : _c.values : [];
3741
+ const dataIdx = columnMap[column.name];
3742
+ const [value, setValue] = useState15(row[dataIdx]);
3743
+ const handleSelectionChange = useCallback42(
3744
+ (evt, selectedItem) => {
3745
+ if (selectedItem) {
3746
+ setValue(selectedItem);
3747
+ }
3748
+ },
3749
+ []
3750
+ );
3751
+ return /* @__PURE__ */ jsx34(
3752
+ Dropdown3,
3753
+ {
3754
+ className: classBase16,
3755
+ onSelectionChange: handleSelectionChange,
3756
+ openKeys,
3757
+ selected: value,
3758
+ source: values,
3759
+ width: column.width - 17
3760
+ }
3761
+ );
3762
+ };
3763
+ registerComponent7("dropdown-cell", DropdownCell, "cell-renderer", {});
3764
+
3765
+ // ../vuu-table/src/table-next/cell-renderers/input-cell/InputCell.tsx
3766
+ import { registerComponent as registerComponent8 } from "@vuu-ui/vuu-utils";
3767
+ import { Input as Input3 } from "@salt-ds/core";
3768
+ import { useEditableText } from "@vuu-ui/vuu-ui-controls";
3769
+ import cx24 from "classnames";
3770
+ import { jsx as jsx35 } from "react/jsx-runtime";
3771
+ var classBase17 = "vuuTableInputCell";
3772
+ var WarnCommit = () => {
3773
+ console.warn(
3774
+ "onCommit handler has not been provided to InputCell cell renderer"
3775
+ );
3776
+ return true;
3777
+ };
3778
+ var InputCell = ({
3779
+ column,
3780
+ columnMap,
3781
+ onCommit = WarnCommit,
3782
+ row
3783
+ }) => {
3784
+ const dataIdx = columnMap[column.name];
3785
+ const {
3786
+ align = "left",
3787
+ clientSideEditValidationCheck,
3788
+ valueFormatter
3789
+ } = column;
3790
+ const { warningMessage, ...editProps } = useEditableText({
3791
+ initialValue: valueFormatter(row[dataIdx]),
3792
+ onCommit,
3793
+ clientSideEditValidationCheck
3794
+ });
3795
+ const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ jsx35("span", { className: `${classBase17}-icon`, "data-icon": "error" }) : void 0;
3796
+ const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ jsx35("span", { className: `${classBase17}-icon`, "data-icon": "error" }) : void 0;
3797
+ return /* @__PURE__ */ jsx35(
3798
+ Input3,
3799
+ {
3800
+ ...editProps,
3801
+ className: cx24(classBase17, {
3802
+ [`${classBase17}-error`]: warningMessage !== void 0
3803
+ }),
3804
+ endAdornment,
3805
+ startAdornment
3806
+ }
3807
+ );
3808
+ };
3809
+ registerComponent8("input-cell", InputCell, "cell-renderer", {});
3810
+
3811
+ // src/table-settings/useTableSettings.ts
3812
+ import {
3813
+ addColumnToSubscribedColumns,
3814
+ isCalculatedColumn as isCalculatedColumn2,
3815
+ moveItem as moveItem2,
3816
+ subscribedOnly as subscribedOnly2
3817
+ } from "@vuu-ui/vuu-utils";
3818
+ import {
3819
+ useCallback as useCallback43,
3820
+ useMemo as useMemo16,
3821
+ useState as useState16
3822
+ } from "react";
3823
+ var sortOrderFromAvailableColumns = (availableColumns, columns) => {
3824
+ const sortedColumns = [];
3825
+ for (const { name: name2 } of availableColumns) {
3826
+ const column = columns.find((col) => col.name === name2);
3827
+ if (column) {
3828
+ sortedColumns.push(column);
3829
+ }
3830
+ }
3831
+ return sortedColumns;
3832
+ };
3833
+ var buildColumnItems = (availableColumns, configuredColumns) => {
3834
+ return availableColumns.map(({ name: name2, serverDataType }) => {
3835
+ const configuredColumn = configuredColumns.find((col) => col.name === name2);
3836
+ return {
3837
+ hidden: configuredColumn == null ? void 0 : configuredColumn.hidden,
3838
+ isCalculated: isCalculatedColumn2(name2),
3839
+ label: configuredColumn == null ? void 0 : configuredColumn.label,
3840
+ name: name2,
3841
+ serverDataType,
3842
+ subscribed: configuredColumn !== void 0
3843
+ };
3844
+ });
3845
+ };
3846
+ var useTableSettings = ({
3847
+ availableColumns: availableColumnsProp,
3848
+ onConfigChange,
3849
+ onDataSourceConfigChange,
3850
+ tableConfig: tableConfigProp
3851
+ }) => {
3852
+ const [{ availableColumns, tableConfig }, setColumnState] = useState16({
3853
+ availableColumns: availableColumnsProp,
3854
+ tableConfig: tableConfigProp
3855
+ });
3856
+ const columnItems = useMemo16(
3857
+ () => buildColumnItems(availableColumns, tableConfig.columns),
3858
+ [availableColumns, tableConfig.columns]
3859
+ );
3860
+ const handleMoveListItem = useCallback43(
3861
+ (fromIndex, toIndex) => {
3862
+ setColumnState((state) => {
3863
+ const newAvailableColumns = moveItem2(
3864
+ state.availableColumns,
3865
+ fromIndex,
3866
+ toIndex
3867
+ );
3868
+ const newColumns = sortOrderFromAvailableColumns(
3869
+ newAvailableColumns,
3870
+ tableConfig.columns
3871
+ );
3872
+ return {
3873
+ availableColumns: newAvailableColumns,
3874
+ tableConfig: {
3875
+ ...state.tableConfig,
3876
+ columns: newColumns
3877
+ }
3878
+ };
3879
+ });
3880
+ },
3881
+ [tableConfig.columns]
3882
+ );
3883
+ const handleColumnChange = useCallback43(
3884
+ (name2, property, value) => {
3885
+ const columnItem = columnItems.find((col) => col.name === name2);
3886
+ if (property === "subscribed") {
3887
+ if (columnItem == null ? void 0 : columnItem.subscribed) {
3888
+ const subscribedColumns = tableConfig.columns.filter((col) => col.name !== name2).map((col) => col.name);
3889
+ setColumnState((state) => ({
3890
+ ...state,
3891
+ tableConfig: {
3892
+ ...tableConfig,
3893
+ columns: tableConfig.columns.filter(
3894
+ subscribedOnly2(subscribedColumns)
3895
+ )
3896
+ }
3897
+ }));
3898
+ onDataSourceConfigChange({
3899
+ columns: subscribedColumns
3900
+ });
3901
+ } else {
3902
+ const newConfig = {
3903
+ ...tableConfig,
3904
+ columns: addColumnToSubscribedColumns(
3905
+ tableConfig.columns,
3906
+ availableColumns,
3907
+ name2
3908
+ )
3909
+ };
3910
+ setColumnState((state) => ({
3911
+ ...state,
3912
+ tableConfig: newConfig
3913
+ }));
3914
+ const subscribedColumns = newConfig.columns.map((col) => col.name);
3915
+ onDataSourceConfigChange({
3916
+ columns: subscribedColumns
3917
+ });
3918
+ }
3919
+ } else if (columnItem == null ? void 0 : columnItem.subscribed) {
3920
+ const column = tableConfig.columns.find((col) => col.name === name2);
3921
+ if (column) {
3922
+ const newConfig = updateTableConfig(tableConfig, {
3923
+ type: "column-prop",
3924
+ property,
3925
+ column,
3926
+ value
3927
+ });
3928
+ setColumnState((state) => ({
3929
+ ...state,
3930
+ tableConfig: newConfig
3931
+ }));
3932
+ }
3933
+ }
3934
+ },
3935
+ [availableColumns, columnItems, onDataSourceConfigChange, tableConfig]
3936
+ );
3937
+ const handleChangeColumnLabels = useCallback43((evt) => {
3938
+ const { value } = evt.target;
3939
+ const columnFormatHeader = value === "0" ? void 0 : value === "1" ? "capitalize" : "uppercase";
3940
+ setColumnState((state) => ({
3941
+ ...state,
3942
+ tableConfig: {
3943
+ ...state.tableConfig,
3944
+ columnFormatHeader
3945
+ }
3946
+ }));
3947
+ }, []);
3948
+ const handleChangeTableAttribute = useCallback43(
3949
+ (evt) => {
3950
+ const { ariaChecked, value } = evt.target;
3951
+ setColumnState((state) => ({
3952
+ ...state,
3953
+ tableConfig: {
3954
+ ...state.tableConfig,
3955
+ [value]: ariaChecked !== "true"
3956
+ }
3957
+ }));
3958
+ },
3959
+ []
3960
+ );
3961
+ useLayoutEffectSkipFirst3(() => {
3962
+ onConfigChange == null ? void 0 : onConfigChange(tableConfig);
3963
+ }, [onConfigChange, tableConfig]);
3964
+ const columnLabelsValue = tableConfig.columnFormatHeader === void 0 ? 0 : tableConfig.columnFormatHeader === "capitalize" ? 1 : 2;
3965
+ return {
3966
+ columnItems,
3967
+ columnLabelsValue,
3968
+ onChangeColumnLabels: handleChangeColumnLabels,
3969
+ onChangeTableAttribute: handleChangeTableAttribute,
3970
+ onColumnChange: handleColumnChange,
3971
+ onMoveListItem: handleMoveListItem,
3972
+ tableConfig
3973
+ };
3974
+ };
3975
+
3976
+ // src/table-settings/TableSettingsPanel.tsx
3977
+ import { jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
3978
+ var classBase18 = "vuuTableSettingsPanel";
3979
+ var TableSettingsPanel = ({
3980
+ availableColumns,
3981
+ onAddCalculatedColumn,
3982
+ onConfigChange,
3983
+ onDataSourceConfigChange,
3984
+ tableConfig: tableConfigProp,
3985
+ ...htmlAttributes
3986
+ }) => {
3987
+ const {
3988
+ columnItems,
3989
+ columnLabelsValue,
3990
+ onChangeColumnLabels,
3991
+ onChangeTableAttribute,
3992
+ onColumnChange,
3993
+ onMoveListItem,
3994
+ tableConfig
3995
+ } = useTableSettings({
3996
+ availableColumns,
3997
+ onConfigChange,
3998
+ onDataSourceConfigChange,
3999
+ tableConfig: tableConfigProp
4000
+ });
4001
+ return /* @__PURE__ */ jsxs26("div", { ...htmlAttributes, className: classBase18, children: [
4002
+ /* @__PURE__ */ jsxs26(FormField5, { children: [
4003
+ /* @__PURE__ */ jsx36(FormFieldLabel5, { children: "Column Labels" }),
4004
+ /* @__PURE__ */ jsxs26(
4005
+ ToggleButtonGroup2,
4006
+ {
4007
+ className: "vuuToggleButtonGroup",
4008
+ onChange: onChangeColumnLabels,
4009
+ value: columnLabelsValue,
4010
+ children: [
4011
+ /* @__PURE__ */ jsx36(
4012
+ ToggleButton2,
4013
+ {
4014
+ className: "vuuIconToggleButton",
4015
+ "data-icon": "text-strikethrough",
4016
+ value: 0
4017
+ }
4018
+ ),
4019
+ /* @__PURE__ */ jsx36(
4020
+ ToggleButton2,
4021
+ {
4022
+ className: "vuuIconToggleButton",
4023
+ "data-icon": "text-Tt",
4024
+ value: 1
4025
+ }
4026
+ ),
4027
+ /* @__PURE__ */ jsx36(
4028
+ ToggleButton2,
4029
+ {
4030
+ className: "vuuIconToggleButton",
4031
+ "data-icon": "text-T",
4032
+ value: 2
4033
+ }
4034
+ )
4035
+ ]
4036
+ }
4037
+ )
4038
+ ] }),
4039
+ /* @__PURE__ */ jsxs26(FormField5, { children: [
4040
+ /* @__PURE__ */ jsx36(FormFieldLabel5, { children: "Grid separators" }),
4041
+ /* @__PURE__ */ jsxs26("div", { className: "saltToggleButtonGroup vuuToggleButtonGroup saltToggleButtonGroup-horizontal vuuGridSeparators", children: [
4042
+ /* @__PURE__ */ jsx36(
4043
+ ToggleButton2,
4044
+ {
4045
+ className: "vuuIconToggleButton",
4046
+ "data-icon": "row-striping",
4047
+ selected: tableConfig.zebraStripes,
4048
+ onChange: onChangeTableAttribute,
4049
+ value: "zebraStripes"
4050
+ }
4051
+ ),
4052
+ /* @__PURE__ */ jsx36(
4053
+ ToggleButton2,
4054
+ {
4055
+ className: "vuuIconToggleButton",
4056
+ "data-icon": "row-lines",
4057
+ selected: tableConfig.rowSeparators,
4058
+ onChange: onChangeTableAttribute,
4059
+ value: "rowSeparators"
4060
+ }
4061
+ ),
4062
+ /* @__PURE__ */ jsx36(
4063
+ ToggleButton2,
4064
+ {
4065
+ className: "vuuIconToggleButton",
4066
+ "data-icon": "col-lines",
4067
+ selected: tableConfig.columnSeparators,
4068
+ onChange: onChangeTableAttribute,
4069
+ value: "columnSeparators"
4070
+ }
4071
+ )
4072
+ ] })
4073
+ ] }),
4074
+ /* @__PURE__ */ jsxs26(FormField5, { children: [
4075
+ /* @__PURE__ */ jsx36(FormFieldLabel5, { children: "Default Column Width" }),
4076
+ /* @__PURE__ */ jsx36(Input4, { className: "vuuInput" })
4077
+ ] }),
4078
+ /* @__PURE__ */ jsx36(
4079
+ ColumnList,
4080
+ {
4081
+ columnItems,
4082
+ onChange: onColumnChange,
4083
+ onMoveListItem
4084
+ }
4085
+ ),
4086
+ /* @__PURE__ */ jsxs26("div", { className: `${classBase18}-calculatedButtonbar`, children: [
4087
+ /* @__PURE__ */ jsx36(Button4, { "data-icon": "plus", onClick: onAddCalculatedColumn }),
4088
+ /* @__PURE__ */ jsx36("span", { className: `${classBase18}-calculatedLabel`, children: "Add calculated column" })
4089
+ ] })
4090
+ ] });
4091
+ };
4092
+
4093
+ // src/useTableAndColumnSettings.ts
4094
+ import { useLayoutProviderDispatch } from "@vuu-ui/vuu-layout";
4095
+ import { getCalculatedColumnType as getCalculatedColumnType2 } from "@vuu-ui/vuu-utils";
4096
+ import { useCallback as useCallback44, useRef as useRef35, useState as useState17 } from "react";
4097
+ var useTableAndColumnSettings = ({
4098
+ availableColumns: availableColumnsProps,
4099
+ onAvailableColumnsChange,
4100
+ onConfigChange,
4101
+ onCreateCalculatedColumn,
4102
+ onDataSourceConfigChange,
4103
+ tableConfig
4104
+ }) => {
4105
+ const dispatchLayoutAction = useLayoutProviderDispatch();
4106
+ const showTableSettingsRef = useRef35();
4107
+ const [availableColumns, setAvailableColumns] = useState17(
4108
+ availableColumnsProps
4109
+ );
4110
+ const showContextPanel = useCallback44(
4111
+ (componentType, title, props) => {
4112
+ dispatchLayoutAction({
4113
+ type: "set-props",
4114
+ path: "#context-panel",
4115
+ props: {
4116
+ expanded: true,
4117
+ content: {
4118
+ type: componentType,
4119
+ props
4120
+ },
4121
+ title
4122
+ }
4123
+ });
4124
+ },
4125
+ [dispatchLayoutAction]
4126
+ );
4127
+ const handleCreateCalculatedColumn = useCallback44(
4128
+ (column) => {
4129
+ const newAvailableColumns = availableColumns.concat({
4130
+ name: column.name,
4131
+ serverDataType: getCalculatedColumnType2(column)
4132
+ });
4133
+ setAvailableColumns(newAvailableColumns);
4134
+ onAvailableColumnsChange == null ? void 0 : onAvailableColumnsChange(newAvailableColumns);
4135
+ requestAnimationFrame(() => {
4136
+ var _a;
4137
+ (_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
4138
+ });
4139
+ onCreateCalculatedColumn(column);
4140
+ },
4141
+ [availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
4142
+ );
4143
+ const showColumnSettingsPanel = useCallback44(
4144
+ (action) => {
4145
+ showContextPanel("ColumnSettings", "Column Settings", {
4146
+ column: action.column,
4147
+ onConfigChange,
4148
+ onCreateCalculatedColumn: handleCreateCalculatedColumn,
4149
+ tableConfig,
4150
+ vuuTable: action.vuuTable
4151
+ });
4152
+ },
4153
+ [
4154
+ handleCreateCalculatedColumn,
4155
+ onConfigChange,
4156
+ showContextPanel,
4157
+ tableConfig
4158
+ ]
4159
+ );
4160
+ const handleAddCalculatedColumn = useCallback44(() => {
4161
+ showColumnSettingsPanel({
4162
+ column: {
4163
+ name: "::",
4164
+ serverDataType: "string"
4165
+ },
4166
+ type: "columnSettings",
4167
+ vuuTable: { module: "SIMUL", table: "instruments" }
4168
+ });
4169
+ }, [showColumnSettingsPanel]);
4170
+ showTableSettingsRef.current = useCallback44(() => {
4171
+ showContextPanel("TableSettings", "DataGrid Settings", {
4172
+ availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name: name2, serverDataType }) => ({
4173
+ name: name2,
4174
+ serverDataType
4175
+ })),
4176
+ onAddCalculatedColumn: handleAddCalculatedColumn,
4177
+ onConfigChange,
4178
+ onDataSourceConfigChange,
4179
+ tableConfig
4180
+ });
4181
+ }, [
4182
+ availableColumns,
4183
+ handleAddCalculatedColumn,
4184
+ onConfigChange,
4185
+ onDataSourceConfigChange,
4186
+ showContextPanel,
4187
+ tableConfig
4188
+ ]);
4189
+ return {
4190
+ showColumnSettingsPanel,
4191
+ showTableSettingsPanel: showTableSettingsRef.current
4192
+ };
4193
+ };
4194
+ export {
4195
+ BackgroundCell2 as BackgroundCell,
4196
+ CaseValidator,
4197
+ ColumnExpressionInput,
4198
+ ColumnExpressionPanel,
4199
+ ColumnFormattingPanel,
4200
+ ColumnList,
4201
+ ColumnNamedTerms,
4202
+ ColumnSettingsPanel,
4203
+ DataSourceStats,
4204
+ NumericFormattingSettings,
4205
+ PatternValidator,
4206
+ TableSettingsPanel,
4207
+ columnExpressionLanguageSupport,
4208
+ isCompleteExpression,
4209
+ isCompleteRelationalExpression,
4210
+ lastNamedChild,
4211
+ useColumnExpressionEditor,
4212
+ useColumnExpressionSuggestionProvider,
4213
+ useTableAndColumnSettings,
4214
+ useTableSettings,
4215
+ walkTree
4216
+ };
2
4217
  //# sourceMappingURL=index.js.map