@vuu-ui/vuu-table-extras 0.8.25 → 0.8.26-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,3568 @@
1
- var Et=(t,e,o)=>{if(!e.has(t))throw TypeError("Cannot "+o)};var f=(t,e,o)=>(Et(t,e,"read from private field"),o?o.call(t):e.get(t)),D=(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)},I=(t,e,o,n)=>(Et(t,e,"write to private field"),n?n.call(t,o):e.set(t,o),o);import{registerComponent as Po}from"@vuu-ui/vuu-utils";var Fo=t=>typeof t=="string",Bo=(t,e)=>Fo(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";Po("vuu-case",Bo,"data-edit-validator",{});import{registerComponent as Lo}from"@vuu-ui/vuu-utils";var Do=t=>typeof t=="string",Ro="value does not match expected pattern",No=(t,e)=>{if(typeof t.value!="string")throw Error("Pattern validation rule must provide pattern");if(Do(e)){if(e==="")return!0;{let{message:o=Ro}=t;return new RegExp(t.value).test(e)||o}}else return"value must be a string"};Lo("vuu-pattern",No,"data-edit-validator",{});import{dataAndColumnUnchanged as $o,DOWN1 as Ao,DOWN2 as zo,isTypeDescriptor as Zo,metadataKeys as Xo,registerComponent as Uo,UP1 as Wo,UP2 as Yo}from"@vuu-ui/vuu-utils";import Go from"clsx";import{memo as qo}from"react";import{getMovingValueDirection as Ho,isTypeDescriptor as Vo,isValidNumber as wt}from"@vuu-ui/vuu-utils";import{useEffect as Mo,useRef as Qo}from"react";var Io=[void 0,void 0,void 0,void 0];function Ot(t,e,o){var g;let n=Qo(),[s,r,a,l]=n.current||Io,{type:u}=o,m=Vo(u)?(g=u.formatting)==null?void 0:g.decimals:void 0,d=t===s&&wt(e)&&wt(r)&&o===a?Ho(e,l,r,m):"";return Mo(()=>{n.current=[t,e,o,d]}),d}import{jsx as tn,jsxs as on}from"react/jsx-runtime";var _o="\u2B06",Jo="\u2B07",{KEY:Ko}=Xo,de="vuuBackgroundCell",G={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},jo=t=>Zo(t)&&t.renderer&&"flashStyle"in t.renderer?t.renderer.flashStyle:G.BackgroundOnly,en=qo(function({column:e,columnMap:o,row:n}){let{name:s,type:r,valueFormatter:a}=e,l=o[s],u=n[l],m=jo(r),d=Ot(n[Ko],u,e),g=m===G.ArrowOnly||m===G.ArrowBackground?d===Wo||d===Yo?_o:d===Ao||d===zo?Jo:null:null,p=d?" "+d:"",i=Go(de,p,{[`${de}-backgroundOnly`]:m===G.BackgroundOnly,[`${de}-arrowOnly`]:m===G.ArrowOnly,[`${de}-arrowBackground`]:m===G.ArrowBackground});return on("div",{className:i,tabIndex:-1,children:[tn("div",{className:`${de}-arrow`,children:g}),a(n[l])]})},$o);Uo("vuu.price-move-background",en,"cell-renderer",{description:"Change background color of cell when value changes",configEditor:"BackgroundCellConfigurationEditor",label:"Background Flash",serverDataType:["long","int","double"]});import{Dropdown as nn}from"@vuu-ui/vuu-ui-controls";import{registerConfigurationEditor as rn}from"@vuu-ui/vuu-utils";import{FormField as sn,FormFieldLabel as an}from"@salt-ds/core";import{useCallback as ln,useState as un}from"react";import{jsx as St,jsxs as dn}from"react/jsx-runtime";var pn="vuuBackgroundCellConfiguration",Ze=[{label:"Background Only",value:"bg-only"},{label:"Background and Arrow",value:"arrow-bg"},{label:"Arrow Only",value:"arrow"}],[Tt]=Ze,cn=t=>{let{flashStyle:e}=t.type.renderer;return Ze.find(o=>o.value===e)||Tt},mn=({column:t,onChangeRendering:e})=>{let[o,n]=un(cn(t)),s=ln((r,a)=>{var u;n(a);let l=t.type.renderer;e({...l,flashStyle:(u=a==null?void 0:a.value)!=null?u:Tt.value})},[t.type,e]);return dn(sn,{children:[St(an,{children:"Flash Style"}),St(nn,{className:`${pn}-flashStyle`,onSelectionChange:s,selected:o,source:Ze,width:"100%"})]})};rn("BackgroundCellConfigurationEditor",mn);import{getSelectedOption as gn,useLookupValues as fn}from"@vuu-ui/vuu-data-react";import{Dropdown as Cn,WarnCommit as vn}from"@vuu-ui/vuu-ui-controls";import{dataColumnAndKeyUnchanged as xn,dispatchCustomEvent as hn,registerComponent as bn}from"@vuu-ui/vuu-utils";import{memo as yn,useCallback as En,useMemo as wn,useRef as On}from"react";import{jsx as Pn}from"react/jsx-runtime";var Sn="vuuTableDropdownCell",Tn=["Enter"," "],kn=yn(function({column:e,columnMap:o,onCommit:n=vn,row:s}){let r=o[e.name],a=s[r],{values:l}=fn(e,a),u=On(null);wn(()=>{u.current=gn(l,a)},[a,l]);let m=En((d,g)=>{g&&n(g.value).then(p=>{p===!0&&d&&hn(d.target,"vuu-commit")})},[n]);return Pn(Cn,{className:Sn,onSelectionChange:m,openKeys:Tn,selected:u.current,source:l,width:e.width-17})},xn);bn("dropdown-cell",kn,"cell-renderer",{userCanAssign:!1});import{useLookupValues as Fn}from"@vuu-ui/vuu-data-react";import{dataAndColumnUnchanged as Bn,registerComponent as Ln}from"@vuu-ui/vuu-utils";import{memo as Dn}from"react";import{jsx as Nn}from"react/jsx-runtime";var Rn=Dn(function({column:e,columnMap:o,row:n}){let s=o[e.name],r=n[s],{initialValue:a}=Fn(e,r);return Nn("span",{children:a==null?void 0:a.label})},Bn);Ln("lookup-cell",Rn,"cell-renderer",{userCanAssign:!1});import{registerComponent as Hn}from"@vuu-ui/vuu-utils";import kt from"clsx";import{jsx as Pt,jsxs as Qn}from"react/jsx-runtime";var ge="vuuPctProgressCell",Vn=t=>t>=0&&t<=1?t*100:t>2?0:t>1?100:0,Mn=({column:t,columnMap:e,row:o})=>{let n=o[e[t.name]],s=Vn(n),r=kt(ge,{});return Qn("div",{className:kt(r,{[`${ge}-zero`]:s===0,[`${ge}-complete`]:s>=100}),tabIndex:-1,children:[Pt("span",{className:`${ge}-progressBar`,style:{"--progress-bar-pct":`${s}%`}}),Pt("span",{className:`${ge}-text`,children:`${s.toFixed(2)} %`})]})};Hn("vuu.pct-progress",Mn,"cell-renderer",{description:"Percentage formatter",label:"Percentage formatter",serverDataType:"double"});import{isColumnTypeRenderer as In,isTypeDescriptor as $n,isValidNumber as Ft,registerComponent as An}from"@vuu-ui/vuu-utils";import zn from"clsx";import{jsx as Xe,jsxs as Bt}from"react/jsx-runtime";var fe="vuuProgressCell",Zn=({column:t,columnMap:e,row:o})=>{let{name:n,type:s}=t,r=o[e[n]],a=!1,l=0;if($n(s)&&In(s.renderer)){let{associatedField:m}=s.renderer;if(m){let d=o[e[m]];if(Ft(r)&&Ft(d))l=Math.min(Math.round(r/d*100),100),l=Math.min(Math.round(r/d*100),100),a=isFinite(l);else{let g=parseFloat(r);if(Number.isFinite(g)){let p=parseFloat(d);Number.isFinite(p)&&(l=Math.min(Math.round(g/p*100),100),a=isFinite(l))}}}else throw Error("ProgressCell associatedField is required to render")}let u=zn(fe,{});return Bt("div",{className:u,tabIndex:-1,children:[a?Bt("span",{className:`${fe}-track`,children:[Xe("span",{className:`${fe}-bg`}),Xe("span",{className:`${fe}-bar`,style:{"--progress-bar-pct":`-${100-l}%`}})]}):null,Xe("span",{className:`${fe}-text`,children:`${l} %`})]})};An("vuu.progress",Zn,"cell-renderer",{description:"Progress formatter",label:"Progress formatter",serverDataType:["long","int","double"],userCanAssign:!1});import{List as Xn,ListItem as Un}from"@vuu-ui/vuu-ui-controls";import{Checkbox as Wn,Switch as Yn}from"@salt-ds/core";import Gn from"clsx";import{useCallback as Lt}from"react";import{getColumnLabel as qn}from"@vuu-ui/vuu-utils";import{jsx as N,jsxs as Ue}from"react/jsx-runtime";var R="vuuColumnList",Dt="vuuColumnListItem",_n=({className:t,item:e,...o})=>Ue(Un,{...o,className:Gn(t,Dt),"data-name":e==null?void 0:e.name,children:[N("span",{className:`${R}-icon`,"data-icon":"draggable"}),e!=null&&e.isCalculated?N("span",{className:`${R}-icon`,"data-icon":"function"}):N(Yn,{className:`${R}-switch`,checked:e==null?void 0:e.subscribed}),N("span",{className:`${R}-text`,children:qn(e)}),N(Wn,{className:`${R}-checkBox`,checked:(e==null?void 0:e.hidden)!==!0,disabled:(e==null?void 0:e.subscribed)!==!0})]}),Rt=({columnItems:t,onChange:e,onMoveListItem:o,onNavigateToColumn:n,...s})=>{let r=Lt(l=>{let u=l.target,m=u.closest(`.${Dt}`),{dataset:{name:d}}=m;if(d){let g=u.closest(`.${R}-switch`),p=u.closest(`.${R}-checkBox`);g?e(d,"subscribed",u.checked):p&&e(d,"hidden",u.checked===!1)}},[e]),a=Lt(l=>{let u=l.target;if(u.classList.contains("vuuColumnList-text")){let m=u.closest(".vuuListItem");m!=null&&m.dataset.name&&(n==null||n(m.dataset.name))}},[]);return Ue("div",{...s,className:R,children:[N("div",{className:`${R}-header`,children:N("span",{children:"Column Selection"})}),Ue("div",{className:`${R}-colHeadings`,children:[N("span",{children:"Column subscription"}),N("span",{children:"Visibility"})]}),N(Xn,{ListItem:_n,allowDragDrop:!0,height:"auto",onChange:r,onClick:a,onMoveListItem:o,selectionStrategy:"none",source:t,itemHeight:33})]})};import{Icon as ae,VuuInput as wo}from"@vuu-ui/vuu-ui-controls";import{getCalculatedColumnName as ii,getDefaultAlignment as ai,isCalculatedColumn as li}from"@vuu-ui/vuu-utils";import{Button as Me,FormField as Qe,FormFieldLabel as Ie,ToggleButton as le,ToggleButtonGroup as Oo}from"@salt-ds/core";import ui from"clsx";import{Dropdown as os}from"@vuu-ui/vuu-ui-controls";import{getCalculatedColumnExpression as ns,getCalculatedColumnName as rs,getCalculatedColumnType as ss}from"@vuu-ui/vuu-utils";import{FormField as ut,FormFieldLabel as pt,Input as is}from"@salt-ds/core";import{useCallback as as,useRef as no}from"react";import{memo as kr}from"react";import{autocompletion as Cr,defaultKeymap as vr,EditorState as Yt,EditorView as Gt,ensureSyntaxTree as xr,keymap as qt,minimalSetup as hr,startCompletion as _t}from"@vuu-ui/vuu-codemirror";import{createEl as Jt}from"@vuu-ui/vuu-utils";import{useCallback as br,useEffect as yr,useMemo as Er,useRef as rt}from"react";import{LanguageSupport as Kn,LRLanguage as jn,styleTags as er,tags as Ce}from"@vuu-ui/vuu-codemirror";import{LRParser as Jn}from"@lezer/lr";var ke=Jn.deserialize({version:14,states:"&xOVQPOOO!fQPO'#C^OVQPO'#CcQ!pQPOOO#bQPO'#CkO#gQPO'#CrOOQO'#Cy'#CyO#lQPO,58}OVQPO,59QOVQPO,59QOOQO'#Cn'#CnOVQPO,59XOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO$bQPO1G.lO%ZQPO1G.sO!pQPO'#CmO%qQQO1G.qO%|QQO'#C{OOQO'#C{'#C{O&wQPO,59`OVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO'RQPO1G.zOOQO1G.z1G.zO'ZQQO'#C^O'eQQO1G.sO'{QQO1G.uOOQO1G.v1G.vO(WQPO<<GwO(_QPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(iQQO1G.lO(yQPOG22}OOQOLD(iLD(iO)QQPO,59QO)QQPO,59QO)QQPO,59X",stateData:")n~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXpQXqQXrQXsQXtQXuQXeQX~OjQXXQX~PnOZWO[WO]XO^XOpYOqYOrYOsYOtYOuYO~OW[O~OW]O~OX_O~P!pO]Yi^YipYiqYirYisYitYiuYieYi~OZWO[WOjYiXYi~P#sOpaiqairaisaitaiuaieai~OZWO[WO]XO^XOjaiXai~P$rOejOvhOwiO~OZmX[mX]mX^mXeoXpmXqmXrmXsmXtmXumXvoXwoX~OXmOekO~P!pOXuOekO~OvQXwQX~PnOZzO[zO]{O^{Ovaiwai~P$rOwiOecivci~OevO~P!pOXiaeia~P!pOZzO[zOvYiwYi~P#sOXyO~P!pORUOSUOTUOUUOWQO`SOnnO~O`UTn~",goto:"$epPPqPPPPqPPqPPPPqP!S!g!r!rPq!w#Y#]PPP#cP$[oUOQWXZ[]hijkvz{|hUOQWXZ]jkvz{|Ve[hi[ZRVgrsxR|cVf[hioTOQWXZ[]hijkvz{|R^TQlgRtlQROQVQS`WzQaXQbZUc[hiQg]Qo|QrjQskQw{RxvQd[QphRqi",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:393});var tr=jn.define({name:"VuuColumnExpression",parser:ke.configure({props:[er({Column:Ce.attributeValue,Function:Ce.variableName,String:Ce.string,Or:Ce.emphasis,Operator:Ce.operator})]})}),Nt=()=>new Kn(tr);var We=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}}},Ye=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},xe,Z,Ge=class{constructor(e="unknown"){D(this,xe,[{type:"unknown"},{type:"unknown"}]);D(this,Z,void 0);this.type="arithmeticExpression";I(this,Z,e)}get op(){return f(this,Z)}set op(e){I(this,Z,e)}get expressions(){return f(this,xe)}toJSON(){return{type:this.type,op:f(this,Z),expressions:f(this,xe)}}};xe=new WeakMap,Z=new WeakMap;var K,qe=class{constructor(e){D(this,K,[]);this.type="callExpression";this.functionName=e}get expressions(){return f(this,K)}get arguments(){return f(this,K)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:f(this,K).map(e=>{var o;return(o=e.toJSON)==null?void 0:o.call(e)})}}};K=new WeakMap;var he,j,_=class{constructor(){D(this,he,[{type:"unknown"},{type:"unknown"}]);D(this,j,"unknown");this.type="relationalExpression"}get op(){return f(this,j)}set op(e){I(this,j,e)}get expressions(){return f(this,he)}toJSON(){return{type:this.type,op:f(this,j),expressions:f(this,he)}}};he=new WeakMap,j=new WeakMap;var be,ee,J=class{constructor(e){D(this,be,[{type:"unknown"},{type:"unknown"}]);D(this,ee,void 0);this.type="booleanCondition";I(this,ee,e)}get op(){return f(this,ee)}get expressions(){return f(this,be)}toJSON(){return{type:this.type,op:f(this,ee),expressions:f(this,be).map(e=>{var o;return(o=e.toJSON)==null?void 0:o.call(e)})}}};be=new WeakMap,ee=new WeakMap;var H,ve=class{constructor(e){D(this,H,void 0);this.type="conditionalExpression";I(this,H,[e?new J(e):new _,{type:"unknown"},{type:"unknown"}])}get expressions(){return f(this,H)}get condition(){return f(this,H)[0]}get truthyExpression(){return f(this,H)[1]}set truthyExpression(e){f(this,H)[1]=e}get falsyExpression(){return f(this,H)[2]}set falsyExpression(e){f(this,H)[2]=e}toJSON(){var e,o,n,s,r;return{type:this.type,condition:(o=(e=this.condition).toJSON)==null?void 0:o.call(e),truthyExpression:this.truthyExpression,falsyExpression:(r=(s=(n=this.falsyExpression)==null?void 0:n.toJSON)==null?void 0:s.call(n))!=null?r:this.falsyExpression}}};H=new WeakMap;var z=t=>t.type==="unknown",Pe=t=>t.type==="arithmeticExpression",or=t=>t.type==="callExpression",q=t=>t.type==="conditionalExpression",nr=t=>t.type==="relationalExpression"||t.type==="booleanCondition";var rr=t=>t.type==="booleanCondition",Je=t=>(t==null?void 0:t.type)==="relationalExpression";var F=t=>{if(z(t))return t;if(Je(t)){let[e,o]=t.expressions;if(k(e))return F(e);if(t.op==="unknown")return t;if(k(o))return F(o)}else if(nr(t)){let{expressions:e=[]}=t;for(let o of e)if(k(o))return F(o)}else if(q(t)){let{condition:e,truthyExpression:o,falsyExpression:n}=t;if(k(e))return F(e);if(k(o))return F(o);if(k(n))return F(n)}else if(Pe(t)){let{expressions:e=[]}=t;for(let o of e)if(k(o))return F(o)}},Fe=(t,e,o)=>{let{expressions:n=[]}=t;if(n.includes(e)){let s=n.indexOf(e);return n.splice(s,1,o),!0}else for(let s of n)if(Fe(s,e,o))return!0;return!1},k=t=>z(t)?!0:q(t)?k(t.condition)||k(t.truthyExpression)||k(t.falsyExpression):Je(t)||rr(t)?t.op===void 0||t.expressions.some(e=>k(e)):!1,Ht=(t,e)=>{let o=F(t);o?o.expressions?o.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},b,X,_e=class{constructor(){D(this,b,void 0);D(this,X,[])}setCondition(e){if(f(this,b)===void 0)this.addExpression(new ve(e));else if(q(f(this,b))){if(k(f(this,b).condition)){let o=e?new J(e):new _;this.addExpression(o)}else if(z(f(this,b).truthyExpression))f(this,b).truthyExpression=new ve(e);else if(k(f(this,b).truthyExpression)){let o=e?new J(e):new _;this.addExpression(o)}else if(z(f(this,b).falsyExpression))f(this,b).falsyExpression=new ve(e);else if(k(f(this,b).falsyExpression)){let o=e?new J(e):new _;this.addExpression(o)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(f(this,X).length>0){let o=f(this,X).at(-1);o==null||o.arguments.push(e)}else if(f(this,b)===void 0)I(this,b,e);else if(Pe(f(this,b))){let o=F(f(this,b));o&&z(o)&&Fe(f(this,b),o,e)}else if(q(f(this,b))&&k(f(this,b))){let o=F(f(this,b));o&&z(o)?Fe(f(this,b),o,e):o&&Ht(o,e)}}setFunction(e){let o=new qe(e);this.addExpression(o),f(this,X).push(o)}setColumn(e){this.addExpression(new Ye(e))}setArithmeticOp(e){let o=e,n=f(this,b);Pe(n)&&(n.op=o)}setRelationalOperator(e){let o=e;if(f(this,b)&&q(f(this,b))){let n=F(f(this,b));Je(n)?n.op=o:console.error(`no target expression found (op = ${e})`)}}setValue(e){let o=new We(e);if(f(this,b)===void 0)I(this,b,o);else if(Pe(f(this,b)))this.addExpression(o);else if(or(f(this,b)))f(this,b).arguments.push(o);else if(q(f(this,b)))if(k(f(this,b))){let n=F(f(this,b));n&&z(n)?Fe(f(this,b),n,o):n&&Ht(n,o)}else console.log("what do we do with value, in a complete expression")}closeBrace(){f(this,X).pop()}get expression(){return f(this,b)}toJSON(){var e;return(e=f(this,b))==null?void 0:e.toJSON()}};b=new WeakMap,X=new WeakMap;var Vt=(t,e)=>{let o=new _e,n=t.cursor();do{let{name:s,from:r,to:a}=n;switch(s){case"AndCondition":o.setCondition("and");break;case"OrCondition":o.setCondition("or");break;case"RelationalExpression":o.setCondition();break;case"ArithmeticExpression":o.addExpression(new Ge);break;case"Column":{let l=e.substring(r,a);o.setColumn(l)}break;case"Function":{let l=e.substring(r,a);o.setFunction(l)}break;case"Times":case"Divide":case"Plus":case"Minus":{let l=e.substring(r,a);o.setArithmeticOp(l)}break;case"RelationalOperator":{let l=e.substring(r,a);o.setRelationalOperator(l)}break;case"False":case"True":{let l=e.substring(r,a);o.setValue(l==="true")}break;case"String":o.setValue(e.substring(r+1,a-1));break;case"Number":o.setValue(parseFloat(e.substring(r,a)));break;case"CloseBrace":o.closeBrace();break;default:}}while(n.next());return o.toJSON()};var sr=ke.configure({strict:!0}),Mt=["Number","String"],Ke=[...Mt,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],Qt=t=>{try{return sr.parse(t),!0}catch{return!1}},je=t=>{let{lastChild:e}=t;for(;e&&!Ke.includes(e.name);)e=e.prevSibling,console.log(e==null?void 0:e.name);return e},It=t=>{if((t==null?void 0:t.name)==="RelationalExpression"){let{firstChild:e}=t,o=je(t);if((e==null?void 0:e.name)==="Column"&&typeof(o==null?void 0:o.name)=="string"&&Mt.includes(o.name))return!0}return!1};import{HighlightStyle as ir,syntaxHighlighting as ar,tags as et}from"@vuu-ui/vuu-codemirror";var lr=ir.define([{tag:et.attributeValue,color:"var(--vuuFilterEditor-variableColor);font-weight: bold"},{tag:et.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:et.comment,color:"green",fontStyle:"italic"}]),$t=ar(lr);import{EditorView as ur}from"@vuu-ui/vuu-codemirror";var At=ur.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-completionLabel":{color:"var(--vuu-color-gray-50)"},".cm-completionMatchedText":{color:"var(--vuu-color-gray-80)",fontWeight:700,textDecoration:"none"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",borderRadius:"4px",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 pr,getNamedParentNode as zt,getPreviousNode as cr,getValue as V,syntaxTree as mr}from"@vuu-ui/vuu-codemirror";import{useCallback as Zt}from"react";var dr=(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,gr=t=>t===void 0?!1:["Times","Divide","Plus","Minus"].includes(t.name),ye=t=>({apply:()=>{t==null||t()},label:"Done",boost:10}),te=(t,e)=>{var s;let{lastChild:o}=t,{pos:n}=e;for(;o;)if(o.from<n&&Ke.includes(o.name)){if(o.name==="ParenthesizedExpression"){let a=(s=o.firstChild)==null?void 0:s.nextSibling;a&&(o=a)}return o}else o=o.prevSibling},Xt=(t,e)=>{var o;if(t.name==="ArgList"){let n=t.prevSibling;if(n)return V(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 V(n,e)}},Ut=(t,e)=>{if(t.name==="RelationalExpression"){let o=je(t);if((o==null?void 0:o.name)==="RelationalOperator")return V(o,e)}else{let o=t.prevSibling;if((o==null?void 0:o.name)==="RelationalOperator")return V(o,e)}},nt=(t,e)=>{var o;if(t.name==="RelationalExpression"){if(((o=t.firstChild)==null?void 0:o.name)==="Column")return V(t.firstChild,e)}else{let n=t.prevSibling;if((n==null?void 0:n.name)==="Column")return V(n,e);if((n==null?void 0:n.name)==="RelationalOperator")return nt(n,e)}},tt=async(t,e,o,n={})=>{let s=await e.getSuggestions(o,n),{startsWith:r=""}=n;return{from:t.pos-r.length,options:s}},ot=(t,e,o,n,s)=>{let r=te(t,e);switch(r==null?void 0:r.name){case"If":return tt(e,o,"expression",{prefix:"( "});case"OpenBrace":return tt(e,o,"expression");case"Condition":return tt(e,o,"expression",{prefix:", "});case"CloseBrace":if(n){let a=[ye(s)];return{from:e.pos,options:a}}}},fr=(t,e)=>{let o=[ye(e)];return{from:t.pos,options:o}},Wt=(t,e)=>{let o=Zt(async(n,s,r={})=>{let a=await t.getSuggestions(s,r),{startsWith:l=""}=r;return{from:n.pos-l.length,options:a}},[t]);return Zt(async n=>{var g,p;let{state:s,pos:r}=n,a=(g=n.matchBefore(/\w*/))!=null?g:{from:0,to:0,text:void 0},u=mr(s).resolveInner(r,-1),m=s.doc.toString(),d=Qt(m);switch(u.name){case"If":return o(n,"expression",{prefix:"( "});case"Condition":{let i=te(u,n);if((i==null?void 0:i.name)==="Column"){let c=cr(i);if((c==null?void 0:c.name)!=="RelationalOperator")return o(n,"condition-operator",{columnName:V(i,s)})}else if((i==null?void 0:i.name)==="RelationalOperator")return o(n,"expression")}break;case"ConditionalExpression":return ot(u,n,t);case"RelationalExpression":{if(It(u))return{from:n.pos,options:pr.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let i=Ut(u,s),c=nt(u,s);if(i)return o(n,"expression");{let C=await t.getSuggestions("condition-operator",{columnName:c});return{from:n.pos,options:C}}}}break;case"RelationalOperator":return o(n,"expression");case"String":{let i=Ut(u,s),c=nt(u,s),{from:C,to:v}=u;if(v-C===2&&n.pos===C+1){if(c&&i)return o(n,"columnValue",{columnName:c,operator:i,startsWith:a.text})}else if(v-C>2&&n.pos===v)return o(n,"expression",{prefix:", "})}break;case"ArithmeticExpression":{let i=te(u,n);if((i==null?void 0:i.name)==="Column")return o(n,"expression");if(gr(i)){let c=i.name;return o(n,"column",{operator:c})}}break;case"OpenBrace":{let i=Xt(u,s);return o(n,"expression",{functionName:i})}break;case"ArgList":{let i=Xt(u,s),c=te(u,n),C=(c==null?void 0:c.name)==="OpenBrace"||(c==null?void 0:c.name)==="Comma"?void 0:",",v=await t.getSuggestions("expression",{functionName:i});return v=C?dr(v,", "):v,(c==null?void 0:c.name)!=="OpenBrace"&&(c==null?void 0:c.name)!=="Comma"&&(v=[{apply:") ",boost:10,label:"Done - no more arguments"}].concat(v)),{from:n.pos,options:v}}case"Equal":if(m.trim()==="=")return o(n,"expression");break;case"ParenthesizedExpression":case"ColumnDefinitionExpression":if(n.pos===0)return o(n,"expression");{let i=te(u,n);if((i==null?void 0:i.name)==="Column"){if(d){let c=[ye(e.current)],C=V(i,s),v=await t.getSuggestions("operator",{columnName:C});return{from:n.pos,options:c.concat(v)}}}else if((i==null?void 0:i.name)==="CallExpression"){if(d)return{from:n.pos,options:[ye(e.current)]}}else if((i==null?void 0:i.name)==="ArithmeticExpression"){if(d){let c=[ye(e.current)],C=te(i,n);if((C==null?void 0:C.name)==="Column"){let v=V(C,s),x=await t.getSuggestions("operator",{columnName:v});c=c.concat(x)}return{from:n.pos,options:c}}}else if((i==null?void 0:i.name)==="ConditionalExpression")return ot(i,n,t,d,e.current);break}case"Column":if(await t.isPartialMatch("expression",void 0,a.text))return o(n,"expression",{startsWith:a.text});break;case"Comma":{let i=zt(u);if((i==null?void 0:i.name)==="ConditionalExpression")return o(n,"expression")}break;case"CloseBrace":{let i=zt(u);if((i==null?void 0:i.name)==="ConditionalExpression")return ot(i,n,t,d,e.current);if((i==null?void 0:i.name)==="ArgList"&&d)return fr(n,e.current)}break;default:((p=u==null?void 0:u.prevSibling)==null?void 0:p.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[o,e,t])};var Be=t=>{if(t.current==null)throw Error("EditorView not defined");return t.current},wr=()=>"vuuSuggestion",Or=()=>console.log("noooop"),Sr=t=>"expressionType"in t,Tr=t=>{if(Sr(t)){let e=Jt("div","expression-type-container"),o=Jt("span","expression-type",t.expressionType);return e.appendChild(o),e}else return null},Kt=({onChange:t,onSubmitExpression:e,source:o,suggestionProvider:n})=>{let s=rt(null),r=rt(Or),a=rt(),l=Wt(n,r),[u,m,d]=Er(()=>{let p=()=>{let x=Be(a),h=x.state.doc.toString(),w=xr(x.state,x.state.doc.length,5e3);if(w){let T=Vt(w,h);return[h,T]}else return["",void 0]},i=()=>{Be(a).setState(v())},c=()=>{let[x,h]=p();e==null||e(x,h)},C=x=>qt.of([{key:x,run(){return _t(Be(a)),!0}}]),v=()=>Yt.create({doc:o,extensions:[hr,Cr({addToOptions:[{render:Tr,position:70}],override:[l],optionClass:wr}),Nt(),qt.of(vr),C("ArrowDown"),Gt.updateListener.of(x=>{let h=Be(a);if(x.docChanged){_t(h);let w=h.state.doc.toString();t==null||t(w)}}),Yt.transactionFilter.of(x=>x.newDoc.lines>1?[]:x),At,$t]});return r.current=()=>{c()},[v,i,c]},[l,t,e,o]);yr(()=>{if(!s.current)throw Error("editor not in dom");return a.current=new Gt({state:u(),parent:s.current}),()=>{var p;(p=a.current)==null||p.destroy()}},[l,u]);let g=br(()=>{d()},[d]);return{editorRef:s,clearInput:m,onBlur:g}};import{jsx as Fr}from"react/jsx-runtime";var Pr="vuuColumnExpressionInput",st=kr(({onChange:t,onSubmitExpression:e,source:o="",suggestionProvider:n})=>{let{editorRef:s,onBlur:r}=Kt({onChange:t,onSubmitExpression:e,source:o,suggestionProvider:n});return Fr("div",{className:`${Pr}`,onBlur:r,ref:s})},(t,e)=>t.source===e.source);st.displayName="ColumnExpressionInput";import{AnnotationType as Br,getRelationalOperators as Lr,numericOperators as Dr,stringOperators as Rr,toSuggestions as Nr}from"@vuu-ui/vuu-codemirror";import{getTypeaheadParams as Hr,useTypeaheadSuggestions as Vr}from"@vuu-ui/vuu-data-react";import{isNumericColumn as at,isTextColumn as Mr}from"@vuu-ui/vuu-utils";import{useCallback as it,useRef as Qr}from"react";var oe=[{accepts:["boolean"],description:"Applies boolean and operator across supplied parameters to returns a single boolean result",example:{expression:'and(ccy="EUR",quantity=0)',result:"true | false"},name:"and",params:{description:"( boolean, [ boolean* ] )"},type:"boolean"},{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:["boolean"],description:"Applies boolean or operator across supplied parameters to returns a single boolean result",example:{expression:'or(status="cancelled",quantity=0)',result:"true | false"},name:"or",params:{description:"( boolean, [ boolean* ] )"},type:"boolean"},{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 M}from"@vuu-ui/vuu-utils";var jt=({name:t,description:e,example:o,params:n,type:s})=>{let r=M("div","vuuFunctionDoc"),a=M("div","function-heading"),l=M("span","function-name",t),u=M("span","param-list",n.description),m=M("span","function-type",s);a.appendChild(l),a.appendChild(u),a.appendChild(m);let d=M("p",void 0,e);if(r.appendChild(a),r.appendChild(d),o){let g=M("div","example-container"),p=M("div","example-expression",o.expression),i=M("div","example-result",o.result);g.appendChild(p),r.appendChild(g),r.appendChild(i)}return r};var Ir=[],U=t=>t.map(e=>{var o;return{...e,apply:((o=e.apply)!=null?o:e.label)+" "}}),$r=(t,{functionName:e,operator:o})=>{if(o)return t.filter(at);if(e){let n=oe.find(s=>s.name===e);if(n)switch(n.accepts){case"string":return t.filter(Mr);case"number":return t.filter(at);default:return t}}return t},eo=(t,e)=>$r(t,e).map(n=>{var r;let s=(r=n.label)!=null?r:n.name;return{apply:e.prefix?`${e.prefix}${n.name}`:n.name,label:s,boost:5,type:"column",expressionType:n.serverDataType}}),Ar=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],zr=t=>t===void 0||at(t)?Ar:Ir,Zr=t=>{switch(t.serverDataType){case"string":case"char":return U(Rr);case"int":case"long":case"double":return U(Dr)}},lt=t=>({apply:`${t.name}( `,boost:2,expressionType:t.type,info:()=>jt(t),label:t.name,type:"function"}),Xr=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"},Ur=oe.map(lt),Wr=({functionName:t})=>{if(t){let e=oe.find(n=>n.name===t),o=Xr(e);if(e)switch(o){case"string":return oe.filter(n=>n.type==="string"||n.type==="variable").map(lt);case"number":return oe.filter(n=>n.type==="number"||n.type==="variable").map(lt);default:}}return Ur},Yr={},to=({columns:t,table:e})=>{let o=it(l=>l?t.find(u=>u.name===l):void 0,[t]),n=Qr(),s=Vr(),r=it(async(l,u=Yr)=>{let{columnName:m,functionName:d,operator:g,prefix:p}=u;switch(l){case"expression":{let i=await U(eo(t,{functionName:d,prefix:p})).concat(Wr(u));return n.current=i}case"column":{let i=await eo(t,u);return n.current=U(i)}case"operator":{let i=await zr(o(m));return n.current=U(i)}case"relational-operator":{let i=await Lr(o(m));return n.current=U(i)}case"condition-operator":{let i=o(m);if(i){let c=await Zr(i);if(c)return n.current=U(c)}}break;case"columnValue":if(m&&g){let i=Hr(e,m),c=await s(i);return n.current=Nr(c,{suffix:""}),n.current.forEach(C=>{C.apply=(v,x,h)=>{let w=new Br,T=h+x.label.length+1;v.dispatch({changes:{from:h,insert:x.label},selection:{anchor:T,head:T},annotations:w.of(x)})}}),n.current}break}return[]},[t,o,s,e]),a=it(async(l,u,m)=>{let{current:d}=n,g=!1,p=d||await r(l,{columnName:u});if(m&&p)for(let i of p){if(i.label===m)return!1;i.label.startsWith(m)&&(g=!0)}return g},[r]);return{getSuggestions:r,isPartialMatch:a}};import{getCalculatedColumnDetails as Gr,isVuuColumnDataType as qr,setCalculatedColumnExpression as _r,setCalculatedColumnName as Jr,setCalculatedColumnType as Kr}from"@vuu-ui/vuu-utils";import{useCallback as Le,useRef as jr,useState as es}from"react";var ts=t=>{let[e,o,n]=Gr(t);return n===""?{...t,name:`${e}:string:${o}`}:t},oo=({column:t,onChangeName:e,onChangeServerDataType:o})=>{let[n,s]=es(ts(t)),r=jr(t),a=Le(d=>{r.current=d,s(d)},[]),l=Le(d=>{let{value:g}=d.target,p=Jr(n,g);a(p),e==null||e(p.name)},[n,e,a]),u=Le(d=>{let g=d.trim(),{current:p}=r,i=_r(p,g);a(i),e==null||e(i.name)},[e,a]),m=Le((d,g)=>{if(qr(g)){let p=Kr(n,g);a(p),e==null||e(p.name),o==null||o(g)}},[n,e,o,a]);return{column:n,onChangeExpression:u,onChangeName:l,onChangeServerDataType:m}};import{jsx as $,jsxs as De}from"react/jsx-runtime";var ro="vuuColumnExpressionPanel",so=({column:t,onChangeName:e,onChangeServerDataType:o,tableConfig:n,vuuTable:s})=>{let r=no(null),{column:a,onChangeExpression:l,onChangeName:u,onChangeServerDataType:m}=oo({column:t,onChangeName:e,onChangeServerDataType:o}),d=no(ns(a)),g=to({columns:n.columns,table:s}),p=as(()=>{var i,c;r.current&&((c=(i=r.current)==null?void 0:i.querySelector("button"))==null||c.focus())},[]);return De("div",{className:ro,children:[$("div",{className:"vuuColumnSettingsPanel-header",children:$("span",{children:"Calculation"})}),De(ut,{"data-field":"column-name",children:[$(pt,{children:"Column Name"}),$(is,{className:"vuuInput",onChange:u,value:rs(a)})]}),De(ut,{"data-field":"column-expression",children:[$(pt,{children:"Expression"}),$(st,{onChange:l,onSubmitExpression:p,source:d.current,suggestionProvider:g})]}),De(ut,{"data-field":"type",children:[$(pt,{children:"Column type"}),$(os,{className:`${ro}-type`,onSelectionChange:m,ref:r,selected:ss(a)||null,source:["double","long","string","boolean"],width:"100%"})]})]})};import{Dropdown as Rs}from"@vuu-ui/vuu-ui-controls";import{getCellRendererOptions as Ns,getConfigurationEditor as Hs,isColumnTypeRenderer as go,isTypeDescriptor as fo}from"@vuu-ui/vuu-utils";import{FormField as Vs,FormFieldLabel as Ms}from"@salt-ds/core";import Co from"clsx";import{useCallback as Qs,useMemo as ft}from"react";import{FormField as ct,FormFieldLabel as mt,Input as ls,Switch as io}from"@salt-ds/core";import{getTypeFormattingFromColumn as us}from"@vuu-ui/vuu-utils";import{useCallback as Re,useState as ps}from"react";import{jsx as ne,jsxs as Ne}from"react/jsx-runtime";var cs="vuuFormattingSettings",He=({column:t,onChangeFormatting:e})=>{var u,m,d;let[o,n]=ps(us(t)),s=Re(g=>{(g.key==="Enter"||g.key==="Tab")&&e(o)},[o,e]),r=Re(g=>{let{value:p}=g.target,i=p===""||isNaN(parseInt(p))?void 0:parseInt(p),c={...o,decimals:i};n(c)},[o]),a=Re(g=>{let{checked:p}=g.target,i={...o,alignOnDecimals:p};n(i),e(i)},[o,e]),l=Re(g=>{let{checked:p}=g.target,i={...o,zeroPad:p};n(i),e(i)},[o,e]);return Ne("div",{className:cs,children:[Ne(ct,{"data-field":"decimals",children:[ne(mt,{children:"Number of decimals"}),ne(ls,{className:"vuuInput",onChange:r,onKeyDown:s,value:(u=o.decimals)!=null?u:""})]}),Ne(ct,{labelPlacement:"left",children:[ne(mt,{children:"Align on decimals"}),ne(io,{checked:(m=o.alignOnDecimals)!=null?m:!1,onChange:a,value:"align-decimals"})]}),Ne(ct,{labelPlacement:"left",children:[ne(mt,{children:"Zero pad decimals"}),ne(io,{checked:(d=o.zeroPad)!=null?d:!1,onChange:l,value:"zero-pad"})]})]})};import{useCallback as Os}from"react";import{FormField as Ss,FormFieldLabel as Ts,ToggleButton as ks,ToggleButtonGroup as Ps}from"@salt-ds/core";import{isDateTimeColumn as Fs,isTypeDescriptor as Bs}from"@vuu-ui/vuu-utils";import{useCallback as dt,useMemo as ms,useState as ds}from"react";import{Dropdown as gs}from"@vuu-ui/vuu-ui-controls";import{defaultPatternsByType as ao,fallbackDateTimePattern as fs,getTypeFormattingFromColumn as Cs,supportedDateTimePatterns as vs}from"@vuu-ui/vuu-utils";import{FormField as lo,FormFieldLabel as uo,ToggleButton as xs,ToggleButtonGroup as hs}from"@salt-ds/core";import{Fragment as ws,jsx as Ee,jsxs as gt}from"react/jsx-runtime";var po=({column:t,onChangeFormatting:e})=>{var d,g;let o=Cs(t),{pattern:n=fs}=o,s=ms(()=>Es(n),[n]),[r,a]=ds({time:(d=n.time)!=null?d:ao.time,date:(g=n.date)!=null?g:ao.date}),l=dt(p=>e({...o,pattern:p}),[e,o]),u=dt(p=>(i,c)=>{let C={...n!=null?n:{},[p]:c};a(v=>{var x,h;return{time:(x=C.time)!=null?x:v.time,date:(h=C.date)!=null?h:v.date}}),l(C)},[l,n]),m=dt(p=>{var c,C,v,x;let i=p.currentTarget.value;switch(i){case"time":return l({[i]:(c=n[i])!=null?c:r[i]});case"date":return l({[i]:(C=n[i])!=null?C:r[i]});case"both":return l({time:(v=n.time)!=null?v:r.time,date:(x=n.date)!=null?x:r.date})}},[l,n,r]);return gt(ws,{children:[gt(lo,{labelPlacement:"top",children:[Ee(uo,{children:"Display"}),Ee(hs,{className:"vuuToggleButtonGroup",onChange:m,value:s,"data-variant":"primary",children:ys.map(p=>Ee(xs,{value:p,children:p.toUpperCase()},p))})]}),["date","time"].filter(p=>!!n[p]).map(p=>gt(lo,{labelPlacement:"top",children:[Ee(uo,{children:`${bs[p]} pattern`}),Ee(gs,{onSelectionChange:u(p),selected:n[p],source:vs[p],width:"100%"})]},p))]})},bs={date:"Date",time:"Time"},ys=["date","time","both"];function Es(t){return t.time?t.date?"both":"time":"date"}import{jsx as we,jsxs as co}from"react/jsx-runtime";var Ls="vuuLongColumnFormattingSettings",mo=t=>{let{column:e,onChangeColumnType:o}=t,n=Bs(e.type)?e.type.name:e.type,s=Os(r=>{let a=r.currentTarget.value;o(a)},[o]);return co("div",{className:Ls,children:[co(Ss,{children:[we(Ts,{children:"Type inferred as"}),we(Ps,{className:"vuuToggleButtonGroup",onChange:s,value:n!=null?n:"number",children:Ds.map(r=>we(ks,{value:r,children:r.toUpperCase()},r))})]}),Fs(e)?we(po,{...t,column:e}):we(He,{...t})]})},Ds=["number","date/time"];import{jsx as re,jsxs as vt}from"react/jsx-runtime";var Ct="vuuColumnFormattingPanel",Is=t=>{var e;return(e=t.label)!=null?e:t.name},vo=({availableRenderers:t,className:e,column:o,onChangeFormatting:n,onChangeColumnType:s,onChangeRendering:r,...a})=>{let l=ft(()=>$s({column:o,onChangeFormatting:n,onChangeColumnType:s}),[o,s,n]);console.log({formattingSettingsComponent:l});let u=ft(()=>{let{type:p}=o;if(fo(p)&&go(p.renderer)){let i=Ns(p.renderer.name);return Hs(i==null?void 0:i.configEditor)}},[o]),m=ft(()=>{let{type:p}=o,[i]=t,c=fo(p)&&go(p.renderer)?p.renderer.name:void 0,C=t.find(v=>v.name===c);return C!=null?C:i},[t,o]),d=Qs((p,i)=>{let c={name:i.name};r==null||r(c)},[r]),{serverDataType:g="string"}=o;return vt("div",{...a,className:"vuuColumnSettingsPanel-header",children:[re("div",{children:"Formatting"}),vt(Vs,{children:[re(Ms,{children:`Renderer (data type ${o.serverDataType})`}),re(Rs,{className:Co(`${Ct}-renderer`),itemToString:Is,onSelectionChange:d,selected:m,source:t,width:"100%"})]}),vt("div",{className:Co(Ct,e,`${Ct}-${g}`),children:[l,u?re(u,{column:o,onChangeRendering:r}):null]})]})};function $s(t){let{column:e}=t;switch(e.serverDataType){case"double":case"int":return re(He,{...t});case"long":return re(mo,{...t});default:return null}}import As from"clsx";import{getCalculatedColumnDetails as zs,isCalculatedColumn as Zs}from"@vuu-ui/vuu-utils";import{jsx as W,jsxs as Xs}from"react/jsx-runtime";var se="vuuColumnNameLabel",xo=({column:t,onClick:e})=>{if(Zs(t.name)){let[o,n,s]=zs(t),r=o||"name",a="=expression",l=r==="name"?`${se}-placeholder`:void 0,u=s===""?`${se}-placeholder`:void 0;return Xs("div",{className:As(se,`${se}-calculated`),onClick:e,children:[W("span",{className:l,children:r}),W("span",{children:":"}),W("span",{children:n||"string"}),W("span",{children:":"}),W("span",{className:u,children:a}),W("span",{className:`${se}-edit`,"data-icon":"edit"})]})}else return W("div",{className:se,children:t.name})};import{getRegisteredCellRenderers as Ve,isValidColumnAlignment as Us,isValidPinLocation as Ws,setCalculatedColumnName as Ys,updateColumnRenderProps as Gs,updateColumnFormatting as qs,updateColumnType as _s,queryClosest as Js}from"@vuu-ui/vuu-utils";import{useCallback as P,useEffect as Ks,useMemo as js,useRef as ei,useState as ho}from"react";var ti=[{description:"Default formatter for columns with data type integer",label:"Default Renderer (int, long)",name:"default-int"}],oi=[{description:"Default formatter for columns with data type double",label:"Default Renderer (double)",name:"default-double"}],bo=[{description:"Default formatter for columns with data type string",label:"Default Renderer (string)",name:"default-string"}],ni=[],ri=t=>{switch(t.serverDataType){case"char":case"string":return bo.concat(Ve("string"));case"int":case"long":return ti.concat(Ve("int"));case"double":return oi.concat(Ve("double"));case"boolean":return ni.concat(Ve("boolean"));default:return bo}},yo=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")},si=(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}`)}},ie=(t,e)=>({...t,columns:t.columns.map(o=>o.name===e.name?e:o)}),Eo=({column:t,onCancelCreateColumn:e,onConfigChange:o,onCreateCalculatedColumn:n,tableConfig:s})=>{let[r,a]=ho(si(s.columns,t)),l=ei(r),[u,m]=ho(r.name==="::"),d=P(()=>{l.current=r,m(!0)},[r]);Ks(()=>{a(t),m(t.name==="::")},[t]);let g=js(()=>ri(r),[r]),p=P(()=>{o(ie(s,r))},[r,o,s]),i=P(O=>{let E=Js(O.target,"button");if(E){let me=yo(E),{value:B}=E;switch(me){case"column-alignment":if(Us(B)){let L={...r,align:B||void 0};a(L),o(ie(s,L))}break;case"column-pin":if(Ws(B)){let L={...r,pin:B||void 0};a(L),o(ie(s,L));break}}}},[r,o,s]),c=P(O=>{let E=O.target,me=yo(E),{value:B}=E;switch(me){case"column-label":a(L=>({...L,label:B}));break;case"column-name":a(L=>Ys(L,B));break;case"column-width":a(L=>({...L,width:parseInt(B)}));break}},[]),C=P(O=>{a(E=>({...E,name:O}))},[]),v=P(O=>{let E=qs(r,O);a(E),o(ie(s,E))},[r,o,s]),x=P(O=>{let E=_s(r,O);a(E),o(ie(s,E))},[r,o,s]),h=P(O=>{a(E=>({...E,serverDataType:O}))},[]),w=P(O=>{if(O){let E=Gs(r,O);a(E),o(ie(s,E))}},[r,o,s]),T=P(({moveBy:O})=>{let{columns:E}=s,me=E.indexOf(r)+O,B=E[me];B&&a(B)},[r,s]),Te=P(()=>{T({moveBy:1})},[T]),$e=P(()=>{T({moveBy:-1})},[T]),Ae=P(()=>{n(r)},[r,n]),ze=P(()=>{t.name==="::"?e():(l.current!==void 0&&l.current!==r&&a(l.current),m(!1))},[r,t.name,e]);return{availableRenderers:g,editCalculatedColumn:u,column:r,navigateNextColumn:Te,navigatePrevColumn:$e,onCancel:ze,onChange:c,onChangeCalculatedColumnName:C,onChangeFormatting:v,onChangeRendering:w,onChangeServerDataType:h,onChangeToggleButton:i,onChangeType:x,onEditCalculatedColumn:d,onInputCommit:p,onSave:Ae}};import{jsx as y,jsxs as Q}from"react/jsx-runtime";var A="vuuColumnSettingsPanel",pi=t=>{let{name:e,label:o}=t;return li(e)?o!=null?o:ii(t):o!=null?o:e},cc=({column:t,onCancelCreateColumn:e,onConfigChange:o,onCreateCalculatedColumn:n,tableConfig:s,vuuTable:r})=>{let a=t.name==="::",{availableRenderers:l,editCalculatedColumn:u,column:m,navigateNextColumn:d,navigatePrevColumn:g,onCancel:p,onChange:i,onChangeCalculatedColumnName:c,onChangeFormatting:C,onChangeRendering:v,onChangeServerDataType:x,onChangeToggleButton:h,onChangeType:w,onEditCalculatedColumn:T,onInputCommit:Te,onSave:$e}=Eo({column:t,onCancelCreateColumn:e,onConfigChange:o,onCreateCalculatedColumn:n,tableConfig:s}),{serverDataType:Ae,align:ze=ai(Ae),pin:O,width:E}=m;return Q("div",{className:ui(A,{[`${A}-editing`]:u}),children:[y("div",{className:`${A}-header`,children:y(xo,{column:m,onClick:T})}),u?y(so,{column:m,onChangeName:c,onChangeServerDataType:x,tableConfig:s,vuuTable:r}):null,Q(Qe,{"data-field":"column-label",children:[y(Ie,{children:"Column Label"}),y(wo,{className:"vuuInput",onChange:i,onCommit:Te,value:pi(m)})]}),Q(Qe,{"data-field":"column-width",children:[y(Ie,{children:"Column Width"}),y(wo,{className:"vuuInput",onChange:i,value:E,onCommit:Te})]}),Q(Qe,{"data-field":"column-alignment",children:[y(Ie,{children:"Alignment"}),Q(Oo,{onChange:h,value:ze,children:[y(le,{value:"left",children:y(ae,{name:"align-left",size:16})}),y(le,{value:"right",children:y(ae,{name:"align-right",size:16})})]})]}),Q(Qe,{"data-field":"column-pin",children:[y(Ie,{children:"Pin Column"}),Q(Oo,{onChange:h,value:O!=null?O:"",children:[y(le,{value:"",children:y(ae,{name:"cross-circle",size:16})}),y(le,{value:"left",children:y(ae,{name:"pin-left",size:16})}),y(le,{value:"floating",children:y(ae,{name:"pin-float",size:16})}),y(le,{value:"right",children:y(ae,{name:"pin-right",size:16})})]})]}),y(vo,{availableRenderers:l,column:m,onChangeFormatting:C,onChangeRendering:v,onChangeColumnType:w}),u?Q("div",{className:"vuuColumnSettingsPanel-buttonBar","data-align":"right",children:[y(Me,{className:`${A}-buttonCancel`,onClick:p,tabIndex:-1,children:"cancel"}),y(Me,{className:`${A}-buttonSave`,onClick:$e,variant:"cta",children:"save"})]}):Q("div",{className:`${A}-buttonBar`,"data-align":a?"right":void 0,children:[y(Me,{className:`${A}-buttonNavPrev`,variant:"secondary","data-icon":"arrow-left",onClick:g,children:"PREVIOUS"}),y(Me,{className:`${A}-buttonNavNext`,variant:"secondary","data-icon":"arrow-right",onClick:d,children:"NEXT"})]})]})};import ci from"clsx";import{useEffect as mi,useState as So}from"react";import{jsx as ue,jsxs as di}from"react/jsx-runtime";var Oe="vuuDatasourceStats",xt=new Intl.NumberFormat,Ec=({className:t,dataSource:e})=>{let[o,n]=So(e.range),[s,r]=So(e.size);mi(()=>(r(e.size),e.on("resize",r),e.on("range",n),()=>{e.removeListener("resize",r),e.removeListener("range",n)}),[e]);let a=ci(Oe,t),l=xt.format(o.from+1),u=xt.format(Math.min(o.to,s)),m=xt.format(s);return di("div",{className:a,children:[ue("span",{className:`${Oe}-label`,children:"Row count"}),ue("span",{className:`${Oe}-range`,children:l}),ue("span",{children:"-"}),ue("span",{className:`${Oe}-range`,children:u}),ue("span",{children:"of"}),ue("span",{className:`${Oe}-size`,children:m})]})};import{Button as Oi,FormField as ht,FormFieldLabel as bt,ToggleButton as pe,ToggleButtonGroup as Si}from"@salt-ds/core";import{updateTableConfig as gi}from"@vuu-ui/vuu-table";import{addColumnToSubscribedColumns as fi,queryClosest as To,isCalculatedColumn as Ci,moveItem as vi,subscribedOnly as xi,useLayoutEffectSkipFirst as hi}from"@vuu-ui/vuu-utils";import{useCallback as Se,useMemo as bi,useState as yi}from"react";var Ei=(t,e)=>{let o=[];for(let{name:n}of t){let s=e.find(r=>r.name===n);s&&o.push(s)}return o},wi=(t,e)=>t.map(({name:o,serverDataType:n})=>{let s=e.find(r=>r.name===o);return{hidden:s==null?void 0:s.hidden,isCalculated:Ci(o),label:s==null?void 0:s.label,name:o,serverDataType:n,subscribed:s!==void 0}}),ko=({availableColumns:t,onConfigChange:e,onDataSourceConfigChange:o,tableConfig:n})=>{let[{availableColumns:s,tableConfig:r},a]=yi({availableColumns:t,tableConfig:n}),l=bi(()=>wi(s,r.columns),[s,r.columns]),u=Se((c,C)=>{a(v=>{let x=vi(v.availableColumns,c,C),h=Ei(x,r.columns);return{availableColumns:x,tableConfig:{...v.tableConfig,columns:h}}})},[r.columns]),m=Se((c,C,v)=>{let x=l.find(h=>h.name===c);if(C==="subscribed")if(x!=null&&x.subscribed){let h=r.columns.filter(w=>w.name!==c).map(w=>w.name);a(w=>({...w,tableConfig:{...r,columns:r.columns.filter(xi(h))}})),o({columns:h})}else{let h={...r,columns:fi(r.columns,s,c)};a(T=>({...T,tableConfig:h}));let w=h.columns.map(T=>T.name);o({columns:w})}else if(x!=null&&x.subscribed){let h=r.columns.find(w=>w.name===c);if(h){let w=gi(r,{type:"column-prop",property:C,column:h,value:v});a(T=>({...T,tableConfig:w}))}}},[s,l,o,r]),d=Se(c=>{let C=To(c.target,"button");if(C){let v=parseInt(C.value),x=v===0?void 0:v===1?"capitalize":"uppercase";a(h=>({...h,tableConfig:{...h.tableConfig,columnFormatHeader:x}}))}},[]),g=Se(c=>{let C=To(c.target,"button"),{ariaPressed:v,value:x}=C;console.log({ariaPressed:v,value:x,button:C}),a(h=>({...h,tableConfig:{...h.tableConfig,[x]:v!=="true"}}))},[]),p=Se((c,C)=>{let v=parseInt(C);isNaN(v)||a(x=>({...x,tableConfig:{...x.tableConfig,columnDefaultWidth:v}})),console.log({value:C})},[]);hi(()=>{e==null||e(r)},[e,r]);let i=r.columnFormatHeader===void 0?0:r.columnFormatHeader==="capitalize"?1:2;return{columnItems:l,columnLabelsValue:i,onChangeColumnLabels:d,onChangeTableAttribute:g,onColumnChange:m,onCommitColumnWidth:p,onMoveListItem:u,tableConfig:r}};import{Icon as ce}from"@vuu-ui/vuu-ui-controls";import{VuuInput as Ti}from"@vuu-ui/vuu-ui-controls";import{jsx as S,jsxs as Y}from"react/jsx-runtime";var yt="vuuTableSettingsPanel",Ac=({availableColumns:t,onAddCalculatedColumn:e,onConfigChange:o,onDataSourceConfigChange:n,onNavigateToColumn:s,tableConfig:r})=>{var c,C,v;let{columnItems:a,columnLabelsValue:l,onChangeColumnLabels:u,onChangeTableAttribute:m,onColumnChange:d,onCommitColumnWidth:g,onMoveListItem:p,tableConfig:i}=ko({availableColumns:t,onConfigChange:o,onDataSourceConfigChange:n,tableConfig:r});return Y("div",{className:yt,children:[Y(ht,{children:[S(bt,{children:"Column Labels"}),Y(Si,{className:"vuuToggleButtonGroup",onChange:u,value:l,children:[S(pe,{className:"vuuIconToggleButton",value:0,children:S(ce,{name:"text-strikethrough",size:48})}),S(pe,{className:"vuuIconToggleButton",value:1,children:S(ce,{name:"text-Tt",size:48})}),S(pe,{className:"vuuIconToggleButton",value:2,children:S(ce,{name:"text-T",size:48})})]})]}),Y(ht,{children:[S(bt,{children:"Grid separators"}),Y("div",{className:"saltToggleButtonGroup vuuStateButtonGroup saltToggleButtonGroup-horizontal",children:[S(pe,{selected:(c=i.zebraStripes)!=null?c:!1,onChange:m,value:"zebraStripes",children:S(ce,{name:"row-striping",size:16})}),S(pe,{selected:(C=i.rowSeparators)!=null?C:!1,onChange:m,value:"rowSeparators",children:S(ce,{name:"row-lines",size:16})}),S(pe,{selected:(v=i.columnSeparators)!=null?v:!1,onChange:m,value:"columnSeparators",children:S(ce,{name:"col-lines",size:16})})]})]}),Y(ht,{children:[S(bt,{children:"Default Column Width"}),S(Ti,{className:"vuuInput",onCommit:g})]}),S(Rt,{columnItems:a,onChange:d,onMoveListItem:p,onNavigateToColumn:s}),Y("div",{className:`${yt}-calculatedButtonbar`,children:[S(Oi,{"data-icon":"plus",onClick:e}),S("span",{className:`${yt}-calculatedLabel`,children:"Add calculated column"})]})]})};export{en as BackgroundCell,mn as BackgroundCellConfigurationEditor,He as BaseNumericFormattingSettings,Bo as CaseValidator,st as ColumnExpressionInput,so as ColumnExpressionPanel,vo as ColumnFormattingPanel,Rt as ColumnList,Ke as ColumnNamedTerms,cc as ColumnSettingsPanel,Ec as DataSourceStats,po as DateTimeFormattingSettings,kn as DropdownCell,Rn as LookupCell,No as PatternValidator,Mn as PctProgressCell,Ac as TableSettingsPanel,Nt as columnExpressionLanguageSupport,Qt as isCompleteExpression,It as isCompleteRelationalExpression,je as lastNamedChild,Kt as useColumnExpressionEditor,to as useColumnExpressionSuggestionProvider,ko as useTableSettings,Vt 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
+ dataAndColumnUnchanged,
65
+ DOWN1,
66
+ DOWN2,
67
+ isTypeDescriptor as isTypeDescriptor2,
68
+ metadataKeys,
69
+ registerComponent as registerComponent3,
70
+ UP1,
71
+ UP2
72
+ } from "@vuu-ui/vuu-utils";
73
+ import cx from "clsx";
74
+ import { memo } from "react";
75
+
76
+ // src/cell-renderers/background-cell/useDirection.ts
77
+ import {
78
+ getMovingValueDirection,
79
+ isTypeDescriptor,
80
+ isValidNumber
81
+ } from "@vuu-ui/vuu-utils";
82
+ import { useEffect, useRef } from "react";
83
+ var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
84
+ function useDirection(key, value, column) {
85
+ var _a;
86
+ const ref = useRef();
87
+ const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
88
+ const { type: dataType } = column;
89
+ const decimals = isTypeDescriptor(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
90
+ const direction = key === prevKey && isValidNumber(value) && isValidNumber(prevValue) && column === prevColumn ? getMovingValueDirection(value, prevDirection, prevValue, decimals) : "";
91
+ useEffect(() => {
92
+ ref.current = [key, value, column, direction];
93
+ });
94
+ return direction;
95
+ }
96
+
97
+ // src/cell-renderers/background-cell/BackgroundCell.tsx
98
+ import { jsx, jsxs } from "react/jsx-runtime";
99
+ var CHAR_ARROW_UP = String.fromCharCode(11014);
100
+ var CHAR_ARROW_DOWN = String.fromCharCode(11015);
101
+ var { KEY } = metadataKeys;
102
+ var classBase = "vuuBackgroundCell";
103
+ var FlashStyle = {
104
+ ArrowOnly: "arrow",
105
+ BackgroundOnly: "bg-only",
106
+ ArrowBackground: "arrow-bg"
107
+ };
108
+ var getFlashStyle = (colType) => {
109
+ if (isTypeDescriptor2(colType) && colType.renderer) {
110
+ if ("flashStyle" in colType.renderer) {
111
+ return colType.renderer["flashStyle"];
112
+ }
113
+ }
114
+ return FlashStyle.BackgroundOnly;
115
+ };
116
+ var BackgroundCell = memo(
117
+ function BackgroundCell2({
118
+ column,
119
+ columnMap,
120
+ row
121
+ }) {
122
+ const { name: name2, type, valueFormatter } = column;
123
+ const dataIdx = columnMap[name2];
124
+ const value = row[dataIdx];
125
+ const flashStyle = getFlashStyle(type);
126
+ const direction = useDirection(row[KEY], value, column);
127
+ const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === UP1 || direction === UP2 ? CHAR_ARROW_UP : direction === DOWN1 || direction === DOWN2 ? CHAR_ARROW_DOWN : null : null;
128
+ const dirClass = direction ? ` ` + direction : "";
129
+ const className = cx(classBase, dirClass, {
130
+ [`${classBase}-backgroundOnly`]: flashStyle === FlashStyle.BackgroundOnly,
131
+ [`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
132
+ [`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
133
+ });
134
+ return /* @__PURE__ */ jsxs("div", { className, tabIndex: -1, children: [
135
+ /* @__PURE__ */ jsx("div", { className: `${classBase}-arrow`, children: arrow }),
136
+ valueFormatter(row[dataIdx])
137
+ ] });
138
+ },
139
+ dataAndColumnUnchanged
140
+ );
141
+ registerComponent3(
142
+ "vuu.price-move-background",
143
+ BackgroundCell,
144
+ "cell-renderer",
145
+ {
146
+ description: "Change background color of cell when value changes",
147
+ configEditor: "BackgroundCellConfigurationEditor",
148
+ label: "Background Flash",
149
+ serverDataType: ["long", "int", "double"]
150
+ }
151
+ );
152
+
153
+ // src/cell-renderers/background-cell/BackgroundCellConfigurationEditor.tsx
154
+ import { Dropdown } from "@vuu-ui/vuu-ui-controls";
155
+ import {
156
+ registerConfigurationEditor
157
+ } from "@vuu-ui/vuu-utils";
158
+ import { FormField, FormFieldLabel } from "@salt-ds/core";
159
+ import { useCallback, useState } from "react";
160
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
161
+ var classBase2 = "vuuBackgroundCellConfiguration";
162
+ var flashOptions = [
163
+ { label: "Background Only", value: "bg-only" },
164
+ { label: "Background and Arrow", value: "arrow-bg" },
165
+ { label: "Arrow Only", value: "arrow" }
166
+ ];
167
+ var [defaultFlashOption] = flashOptions;
168
+ var valueFromColumn = (column) => {
169
+ const { flashStyle } = column.type.renderer;
170
+ return flashOptions.find((o) => o.value === flashStyle) || defaultFlashOption;
171
+ };
172
+ var BackgroundCellConfigurationEditor = ({
173
+ column,
174
+ onChangeRendering
175
+ }) => {
176
+ const [flashStyle, setFlashStyle] = useState(
177
+ valueFromColumn(column)
178
+ );
179
+ const handleSelectionChange = useCallback(
180
+ (_, flashOption) => {
181
+ var _a;
182
+ setFlashStyle(flashOption);
183
+ const renderProps = column.type.renderer;
184
+ onChangeRendering({
185
+ ...renderProps,
186
+ flashStyle: (_a = flashOption == null ? void 0 : flashOption.value) != null ? _a : defaultFlashOption.value
187
+ });
188
+ },
189
+ [column.type, onChangeRendering]
190
+ );
191
+ return /* @__PURE__ */ jsxs2(FormField, { children: [
192
+ /* @__PURE__ */ jsx2(FormFieldLabel, { children: "Flash Style" }),
193
+ /* @__PURE__ */ jsx2(
194
+ Dropdown,
195
+ {
196
+ className: `${classBase2}-flashStyle`,
197
+ onSelectionChange: handleSelectionChange,
198
+ selected: flashStyle,
199
+ source: flashOptions,
200
+ width: "100%"
201
+ }
202
+ )
203
+ ] });
204
+ };
205
+ registerConfigurationEditor(
206
+ "BackgroundCellConfigurationEditor",
207
+ BackgroundCellConfigurationEditor
208
+ );
209
+
210
+ // src/cell-renderers/dropdown-cell/DropdownCell.tsx
211
+ import { getSelectedOption, useLookupValues } from "@vuu-ui/vuu-data-react";
212
+ import {
213
+ Dropdown as Dropdown2,
214
+ WarnCommit
215
+ } from "@vuu-ui/vuu-ui-controls";
216
+ import {
217
+ dataColumnAndKeyUnchanged,
218
+ dispatchCustomEvent,
219
+ registerComponent as registerComponent4
220
+ } from "@vuu-ui/vuu-utils";
221
+ import { memo as memo2, useCallback as useCallback2, useMemo, useRef as useRef2 } from "react";
222
+ import { jsx as jsx3 } from "react/jsx-runtime";
223
+ var classBase3 = "vuuTableDropdownCell";
224
+ var openKeys = ["Enter", " "];
225
+ var DropdownCell = memo2(
226
+ function DropdownCell2({
227
+ column,
228
+ columnMap,
229
+ onCommit = WarnCommit,
230
+ row
231
+ }) {
232
+ const dataIdx = columnMap[column.name];
233
+ const dataValue = row[dataIdx];
234
+ const { values } = useLookupValues(column, dataValue);
235
+ const valueRef = useRef2(null);
236
+ useMemo(() => {
237
+ valueRef.current = getSelectedOption(values, dataValue);
238
+ }, [dataValue, values]);
239
+ const handleSelectionChange = useCallback2(
240
+ (evt, selectedOption) => {
241
+ if (selectedOption) {
242
+ onCommit(selectedOption.value).then((response) => {
243
+ if (response === true && evt) {
244
+ dispatchCustomEvent(evt.target, "vuu-commit");
245
+ }
246
+ });
247
+ }
248
+ },
249
+ [onCommit]
250
+ );
251
+ return /* @__PURE__ */ jsx3(
252
+ Dropdown2,
253
+ {
254
+ className: classBase3,
255
+ onSelectionChange: handleSelectionChange,
256
+ openKeys,
257
+ selected: valueRef.current,
258
+ source: values,
259
+ width: column.width - 17
260
+ }
261
+ );
262
+ },
263
+ dataColumnAndKeyUnchanged
264
+ );
265
+ registerComponent4("dropdown-cell", DropdownCell, "cell-renderer", {
266
+ userCanAssign: false
267
+ });
268
+
269
+ // src/cell-renderers/lookup-cell/LookupCell.tsx
270
+ import { useLookupValues as useLookupValues2 } from "@vuu-ui/vuu-data-react";
271
+ import { dataAndColumnUnchanged as dataAndColumnUnchanged2, registerComponent as registerComponent5 } from "@vuu-ui/vuu-utils";
272
+ import { memo as memo3 } from "react";
273
+ import { jsx as jsx4 } from "react/jsx-runtime";
274
+ var LookupCell = memo3(
275
+ function LookupCell2({
276
+ column,
277
+ columnMap,
278
+ row
279
+ }) {
280
+ const dataIdx = columnMap[column.name];
281
+ const dataValue = row[dataIdx];
282
+ const { initialValue: value } = useLookupValues2(column, dataValue);
283
+ return /* @__PURE__ */ jsx4("span", { children: value == null ? void 0 : value.label });
284
+ },
285
+ dataAndColumnUnchanged2
286
+ );
287
+ registerComponent5("lookup-cell", LookupCell, "cell-renderer", {
288
+ userCanAssign: false
289
+ });
290
+
291
+ // src/cell-renderers/pct-progress-cell/PctProgressCell.tsx
292
+ import { registerComponent as registerComponent6 } from "@vuu-ui/vuu-utils";
293
+ import cx2 from "clsx";
294
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
295
+ var classBase4 = "vuuPctProgressCell";
296
+ var getPercentageValue = (value) => {
297
+ if (value >= 0 && value <= 1) {
298
+ return value * 100;
299
+ } else if (value > 2) {
300
+ return 0;
301
+ } else if (value > 1) {
302
+ return 100;
303
+ } else {
304
+ return 0;
305
+ }
306
+ };
307
+ var PctProgressCell = ({ column, columnMap, row }) => {
308
+ const value = row[columnMap[column.name]];
309
+ const percentageValue = getPercentageValue(value);
310
+ const className = cx2(classBase4, {});
311
+ return /* @__PURE__ */ jsxs3(
312
+ "div",
313
+ {
314
+ className: cx2(className, {
315
+ [`${classBase4}-zero`]: percentageValue === 0,
316
+ [`${classBase4}-complete`]: percentageValue >= 100
317
+ }),
318
+ tabIndex: -1,
319
+ children: [
320
+ /* @__PURE__ */ jsx5(
321
+ "span",
322
+ {
323
+ className: `${classBase4}-progressBar`,
324
+ style: { "--progress-bar-pct": `${percentageValue}%` }
325
+ }
326
+ ),
327
+ /* @__PURE__ */ jsx5("span", { className: `${classBase4}-text`, children: `${percentageValue.toFixed(
328
+ 2
329
+ )} %` })
330
+ ]
331
+ }
332
+ );
333
+ };
334
+ registerComponent6("vuu.pct-progress", PctProgressCell, "cell-renderer", {
335
+ description: "Percentage formatter",
336
+ label: "Percentage formatter",
337
+ serverDataType: "double"
338
+ });
339
+
340
+ // src/cell-renderers/progress-cell/ProgressCell.tsx
341
+ import {
342
+ isColumnTypeRenderer,
343
+ isTypeDescriptor as isTypeDescriptor3,
344
+ isValidNumber as isValidNumber2,
345
+ registerComponent as registerComponent7
346
+ } from "@vuu-ui/vuu-utils";
347
+ import cx3 from "clsx";
348
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
349
+ var classBase5 = "vuuProgressCell";
350
+ var ProgressCell = ({ column, columnMap, row }) => {
351
+ const { name: name2, type } = column;
352
+ const value = row[columnMap[name2]];
353
+ let showProgress = false;
354
+ let percentage = 0;
355
+ if (isTypeDescriptor3(type) && isColumnTypeRenderer(type.renderer)) {
356
+ const { associatedField } = type.renderer;
357
+ if (associatedField) {
358
+ const associatedValue = row[columnMap[associatedField]];
359
+ if (isValidNumber2(value) && isValidNumber2(associatedValue)) {
360
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
361
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
362
+ showProgress = isFinite(percentage);
363
+ } else {
364
+ const floatValue = parseFloat(value);
365
+ if (Number.isFinite(floatValue)) {
366
+ const floatOtherValue = parseFloat(associatedValue);
367
+ if (Number.isFinite(floatOtherValue)) {
368
+ percentage = Math.min(
369
+ Math.round(floatValue / floatOtherValue * 100),
370
+ 100
371
+ );
372
+ showProgress = isFinite(percentage);
373
+ }
374
+ }
375
+ }
376
+ } else {
377
+ throw Error("ProgressCell associatedField is required to render");
378
+ }
379
+ }
380
+ const className = cx3(classBase5, {});
381
+ return /* @__PURE__ */ jsxs4("div", { className, tabIndex: -1, children: [
382
+ showProgress ? /* @__PURE__ */ jsxs4("span", { className: `${classBase5}-track`, children: [
383
+ /* @__PURE__ */ jsx6("span", { className: `${classBase5}-bg` }),
384
+ /* @__PURE__ */ jsx6(
385
+ "span",
386
+ {
387
+ className: `${classBase5}-bar`,
388
+ style: { "--progress-bar-pct": `-${100 - percentage}%` }
389
+ }
390
+ )
391
+ ] }) : null,
392
+ /* @__PURE__ */ jsx6("span", { className: `${classBase5}-text`, children: `${percentage} %` })
393
+ ] });
394
+ };
395
+ registerComponent7("vuu.progress", ProgressCell, "cell-renderer", {
396
+ description: "Progress formatter",
397
+ label: "Progress formatter",
398
+ serverDataType: ["long", "int", "double"],
399
+ // Not until we provide settings for associaetd field
400
+ userCanAssign: false
401
+ });
402
+
403
+ // src/column-list/ColumnList.tsx
404
+ import {
405
+ Icon,
406
+ List,
407
+ ListItem
408
+ } from "@vuu-ui/vuu-ui-controls";
409
+ import { Checkbox, Switch } from "@salt-ds/core";
410
+ import cx4 from "clsx";
411
+ import {
412
+ useCallback as useCallback3
413
+ } from "react";
414
+ import { getColumnLabel, queryClosest } from "@vuu-ui/vuu-utils";
415
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
416
+ var classBase6 = "vuuColumnList";
417
+ var classBaseListItem = "vuuColumnListItem";
418
+ var ColumnListItem = ({
419
+ className: classNameProp,
420
+ item,
421
+ ...listItemProps
422
+ }) => {
423
+ return /* @__PURE__ */ jsxs5(
424
+ ListItem,
425
+ {
426
+ ...listItemProps,
427
+ className: cx4(classNameProp, classBaseListItem),
428
+ "data-name": item == null ? void 0 : item.name,
429
+ children: [
430
+ /* @__PURE__ */ jsx7(Icon, { name: "draggable", size: 16 }),
431
+ (item == null ? void 0 : item.isCalculated) ? /* @__PURE__ */ jsx7(Icon, { name: "function" }) : /* @__PURE__ */ jsx7(
432
+ Checkbox,
433
+ {
434
+ className: `${classBase6}-checkBox`,
435
+ checked: item == null ? void 0 : item.subscribed
436
+ }
437
+ ),
438
+ /* @__PURE__ */ jsx7("span", { className: `${classBase6}-text`, children: getColumnLabel(item) }),
439
+ /* @__PURE__ */ jsx7(
440
+ Switch,
441
+ {
442
+ className: `${classBase6}-switch`,
443
+ checked: (item == null ? void 0 : item.hidden) !== true,
444
+ disabled: (item == null ? void 0 : item.subscribed) !== true
445
+ }
446
+ )
447
+ ]
448
+ }
449
+ );
450
+ };
451
+ var ColumnList = ({
452
+ columnItems,
453
+ onChange,
454
+ onMoveListItem,
455
+ onNavigateToColumn,
456
+ ...htmlAttributes
457
+ }) => {
458
+ const handleChange = useCallback3(
459
+ ({ target }) => {
460
+ const input = target;
461
+ const listItem = queryClosest(target, `.${classBaseListItem}`);
462
+ const {
463
+ dataset: { name: name2 }
464
+ } = listItem;
465
+ if (name2) {
466
+ const saltCheckbox = queryClosest(target, `.${classBase6}-checkBox`);
467
+ const saltSwitch = queryClosest(target, `.${classBase6}-switch`);
468
+ if (saltCheckbox) {
469
+ onChange(name2, "subscribed", input.checked);
470
+ } else if (saltSwitch) {
471
+ onChange(name2, "hidden", input.checked === false);
472
+ }
473
+ }
474
+ },
475
+ [onChange]
476
+ );
477
+ const handleClick = useCallback3((evt) => {
478
+ const targetEl = evt.target;
479
+ if (targetEl.classList.contains("vuuColumnList-text")) {
480
+ const listItemEl = targetEl.closest(".vuuListItem");
481
+ if (listItemEl == null ? void 0 : listItemEl.dataset.name) {
482
+ onNavigateToColumn == null ? void 0 : onNavigateToColumn(listItemEl.dataset.name);
483
+ }
484
+ }
485
+ }, []);
486
+ return /* @__PURE__ */ jsxs5("div", { ...htmlAttributes, className: classBase6, children: [
487
+ /* @__PURE__ */ jsx7("div", { className: `${classBase6}-header`, children: /* @__PURE__ */ jsx7("span", { children: "Column Selection" }) }),
488
+ /* @__PURE__ */ jsxs5("div", { className: `${classBase6}-colHeadings`, children: [
489
+ /* @__PURE__ */ jsx7("span", { children: "Column subscription" }),
490
+ /* @__PURE__ */ jsx7("span", { children: "Visibility" })
491
+ ] }),
492
+ /* @__PURE__ */ jsx7(
493
+ List,
494
+ {
495
+ ListItem: ColumnListItem,
496
+ allowDragDrop: true,
497
+ height: "auto",
498
+ onChange: handleChange,
499
+ onClick: handleClick,
500
+ onMoveListItem,
501
+ selectionStrategy: "none",
502
+ source: columnItems,
503
+ itemHeight: 33
504
+ }
505
+ )
506
+ ] });
507
+ };
508
+
509
+ // src/column-settings/ColumnSettingsPanel.tsx
510
+ import { Icon as Icon2, VuuInput } from "@vuu-ui/vuu-ui-controls";
511
+ import {
512
+ getCalculatedColumnName as getCalculatedColumnName2,
513
+ getDefaultAlignment,
514
+ isCalculatedColumn as isCalculatedColumn2
515
+ } from "@vuu-ui/vuu-utils";
516
+ import {
517
+ Button,
518
+ FormField as FormField7,
519
+ FormFieldLabel as FormFieldLabel7,
520
+ ToggleButton as ToggleButton3,
521
+ ToggleButtonGroup as ToggleButtonGroup3
522
+ } from "@salt-ds/core";
523
+ import cx7 from "clsx";
524
+
525
+ // src/column-expression-panel/ColumnExpressionPanel.tsx
526
+ import { Dropdown as Dropdown3 } from "@vuu-ui/vuu-ui-controls";
527
+ import {
528
+ getCalculatedColumnExpression,
529
+ getCalculatedColumnName,
530
+ getCalculatedColumnType
531
+ } from "@vuu-ui/vuu-utils";
532
+ import { FormField as FormField2, FormFieldLabel as FormFieldLabel2, Input } from "@salt-ds/core";
533
+ import { useCallback as useCallback8, useRef as useRef6 } from "react";
534
+
535
+ // src/column-expression-input/ColumnExpressionInput.tsx
536
+ import { memo as memo4 } from "react";
537
+
538
+ // src/column-expression-input/useColumnExpressionEditor.ts
539
+ import {
540
+ autocompletion,
541
+ defaultKeymap,
542
+ EditorState as EditorState2,
543
+ EditorView as EditorView2,
544
+ ensureSyntaxTree,
545
+ keymap,
546
+ minimalSetup,
547
+ startCompletion
548
+ } from "@vuu-ui/vuu-codemirror";
549
+ import { createEl } from "@vuu-ui/vuu-utils";
550
+ import {
551
+ useCallback as useCallback5,
552
+ useEffect as useEffect2,
553
+ useMemo as useMemo2,
554
+ useRef as useRef3
555
+ } from "react";
556
+
557
+ // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
558
+ import {
559
+ LanguageSupport,
560
+ LRLanguage,
561
+ styleTags,
562
+ tags as tag
563
+ } from "@vuu-ui/vuu-codemirror";
564
+
565
+ // src/column-expression-input/column-language-parser/generated/column-parser.js
566
+ import { LRParser } from "@lezer/lr";
567
+ var parser = LRParser.deserialize({
568
+ version: 14,
569
+ states: "&xOVQPOOO!fQPO'#C^OVQPO'#CcQ!pQPOOO#bQPO'#CkO#gQPO'#CrOOQO'#Cy'#CyO#lQPO,58}OVQPO,59QOVQPO,59QOOQO'#Cn'#CnOVQPO,59XOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO$bQPO1G.lO%ZQPO1G.sO!pQPO'#CmO%qQQO1G.qO%|QQO'#C{OOQO'#C{'#C{O&wQPO,59`OVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO'RQPO1G.zOOQO1G.z1G.zO'ZQQO'#C^O'eQQO1G.sO'{QQO1G.uOOQO1G.v1G.vO(WQPO<<GwO(_QPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(iQQO1G.lO(yQPOG22}OOQOLD(iLD(iO)QQPO,59QO)QQPO,59QO)QQPO,59X",
570
+ stateData: ")n~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXpQXqQXrQXsQXtQXuQXeQX~OjQXXQX~PnOZWO[WO]XO^XOpYOqYOrYOsYOtYOuYO~OW[O~OW]O~OX_O~P!pO]Yi^YipYiqYirYisYitYiuYieYi~OZWO[WOjYiXYi~P#sOpaiqairaisaitaiuaieai~OZWO[WO]XO^XOjaiXai~P$rOejOvhOwiO~OZmX[mX]mX^mXeoXpmXqmXrmXsmXtmXumXvoXwoX~OXmOekO~P!pOXuOekO~OvQXwQX~PnOZzO[zO]{O^{Ovaiwai~P$rOwiOecivci~OevO~P!pOXiaeia~P!pOZzO[zOvYiwYi~P#sOXyO~P!pORUOSUOTUOUUOWQO`SOnnO~O`UTn~",
571
+ goto: "$epPPqPPPPqPPqPPPPqP!S!g!r!rPq!w#Y#]PPP#cP$[oUOQWXZ[]hijkvz{|hUOQWXZ]jkvz{|Ve[hi[ZRVgrsxR|cVf[hioTOQWXZ[]hijkvz{|R^TQlgRtlQROQVQS`WzQaXQbZUc[hiQg]Qo|QrjQskQw{RxvQd[QphRqi",
572
+ 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",
573
+ maxTerm: 39,
574
+ skippedNodes: [0],
575
+ repeatNodeCount: 1,
576
+ 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",
577
+ tokenizers: [0, 1],
578
+ topRules: { "ColumnDefinitionExpression": [0, 1] },
579
+ tokenPrec: 393
580
+ });
581
+
582
+ // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
583
+ var columnExpressionLanguage = LRLanguage.define({
584
+ name: "VuuColumnExpression",
585
+ parser: parser.configure({
586
+ props: [
587
+ styleTags({
588
+ Column: tag.attributeValue,
589
+ Function: tag.variableName,
590
+ String: tag.string,
591
+ Or: tag.emphasis,
592
+ Operator: tag.operator
593
+ })
594
+ ]
595
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
+ })
597
+ });
598
+ var columnExpressionLanguageSupport = () => {
599
+ return new LanguageSupport(
600
+ columnExpressionLanguage
601
+ /*, [exampleCompletion]*/
602
+ );
603
+ };
604
+
605
+ // src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.ts
606
+ var LiteralExpressionImpl = class {
607
+ constructor(value) {
608
+ this.value = value;
609
+ switch (typeof value) {
610
+ case "boolean":
611
+ this.type = "booleanLiteralExpression";
612
+ break;
613
+ case "number":
614
+ this.type = "numericLiteralExpression";
615
+ break;
616
+ default:
617
+ this.type = "stringLiteralExpression";
618
+ }
619
+ }
620
+ toJSON() {
621
+ return {
622
+ type: this.type,
623
+ value: this.value
624
+ };
625
+ }
626
+ };
627
+ var ColumnExpressionImpl = class {
628
+ constructor(columnName) {
629
+ this.type = "colExpression";
630
+ this.column = columnName;
631
+ }
632
+ toJSON() {
633
+ return {
634
+ type: this.type,
635
+ column: this.column
636
+ };
637
+ }
638
+ };
639
+ var _expressions, _op;
640
+ var ArithmeticExpressionImpl = class {
641
+ constructor(op = "unknown") {
642
+ __privateAdd(this, _expressions, [
643
+ { type: "unknown" },
644
+ { type: "unknown" }
645
+ ]);
646
+ __privateAdd(this, _op, void 0);
647
+ this.type = "arithmeticExpression";
648
+ __privateSet(this, _op, op);
649
+ }
650
+ get op() {
651
+ return __privateGet(this, _op);
652
+ }
653
+ set op(op) {
654
+ __privateSet(this, _op, op);
655
+ }
656
+ get expressions() {
657
+ return __privateGet(this, _expressions);
658
+ }
659
+ toJSON() {
660
+ return {
661
+ type: this.type,
662
+ op: __privateGet(this, _op),
663
+ expressions: __privateGet(this, _expressions)
664
+ };
665
+ }
666
+ };
667
+ _expressions = new WeakMap();
668
+ _op = new WeakMap();
669
+ var _expressions2;
670
+ var CallExpressionImpl = class {
671
+ constructor(functionName) {
672
+ __privateAdd(this, _expressions2, []);
673
+ this.type = "callExpression";
674
+ this.functionName = functionName;
675
+ }
676
+ get expressions() {
677
+ return __privateGet(this, _expressions2);
678
+ }
679
+ get arguments() {
680
+ return __privateGet(this, _expressions2);
681
+ }
682
+ toJSON() {
683
+ return {
684
+ type: this.type,
685
+ functionName: this.functionName,
686
+ arguments: __privateGet(this, _expressions2).map((e) => {
687
+ var _a;
688
+ return (_a = e.toJSON) == null ? void 0 : _a.call(e);
689
+ })
690
+ };
691
+ }
692
+ };
693
+ _expressions2 = new WeakMap();
694
+ var _expressions3, _op2;
695
+ var RelationalExpressionImpl = class {
696
+ constructor() {
697
+ __privateAdd(this, _expressions3, [
698
+ { type: "unknown" },
699
+ { type: "unknown" }
700
+ ]);
701
+ __privateAdd(this, _op2, "unknown");
702
+ this.type = "relationalExpression";
703
+ }
704
+ get op() {
705
+ return __privateGet(this, _op2);
706
+ }
707
+ set op(op) {
708
+ __privateSet(this, _op2, op);
709
+ }
710
+ get expressions() {
711
+ return __privateGet(this, _expressions3);
712
+ }
713
+ toJSON() {
714
+ return {
715
+ type: this.type,
716
+ op: __privateGet(this, _op2),
717
+ expressions: __privateGet(this, _expressions3)
718
+ };
719
+ }
720
+ };
721
+ _expressions3 = new WeakMap();
722
+ _op2 = new WeakMap();
723
+ var _expressions4, _op3;
724
+ var BooleanConditionImp = class {
725
+ constructor(booleanOperator) {
726
+ __privateAdd(this, _expressions4, [
727
+ { type: "unknown" },
728
+ { type: "unknown" }
729
+ ]);
730
+ __privateAdd(this, _op3, void 0);
731
+ this.type = "booleanCondition";
732
+ __privateSet(this, _op3, booleanOperator);
733
+ }
734
+ get op() {
735
+ return __privateGet(this, _op3);
736
+ }
737
+ get expressions() {
738
+ return __privateGet(this, _expressions4);
739
+ }
740
+ toJSON() {
741
+ return {
742
+ type: this.type,
743
+ op: __privateGet(this, _op3),
744
+ expressions: __privateGet(this, _expressions4).map((e) => {
745
+ var _a;
746
+ return (_a = e.toJSON) == null ? void 0 : _a.call(e);
747
+ })
748
+ };
749
+ }
750
+ };
751
+ _expressions4 = new WeakMap();
752
+ _op3 = new WeakMap();
753
+ var _expressions5;
754
+ var ConditionalExpressionImpl = class {
755
+ constructor(booleanOperator) {
756
+ __privateAdd(this, _expressions5, void 0);
757
+ this.type = "conditionalExpression";
758
+ __privateSet(this, _expressions5, [
759
+ booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
760
+ { type: "unknown" },
761
+ { type: "unknown" }
762
+ ]);
763
+ }
764
+ get expressions() {
765
+ return __privateGet(this, _expressions5);
766
+ }
767
+ get condition() {
768
+ return __privateGet(this, _expressions5)[0];
769
+ }
770
+ get truthyExpression() {
771
+ return __privateGet(this, _expressions5)[1];
772
+ }
773
+ set truthyExpression(expression) {
774
+ __privateGet(this, _expressions5)[1] = expression;
775
+ }
776
+ get falsyExpression() {
777
+ return __privateGet(this, _expressions5)[2];
778
+ }
779
+ set falsyExpression(expression) {
780
+ __privateGet(this, _expressions5)[2] = expression;
781
+ }
782
+ toJSON() {
783
+ var _a, _b, _c, _d, _e;
784
+ return {
785
+ type: this.type,
786
+ condition: (_b = (_a = this.condition).toJSON) == null ? void 0 : _b.call(_a),
787
+ truthyExpression: this.truthyExpression,
788
+ falsyExpression: (_e = (_d = (_c = this.falsyExpression) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c)) != null ? _e : this.falsyExpression
789
+ };
790
+ }
791
+ };
792
+ _expressions5 = new WeakMap();
793
+ var isUnknown = (e) => e.type === "unknown";
794
+ var isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
795
+ var isCallExpression = (expression) => expression.type === "callExpression";
796
+ var isConditionalExpression = (expression) => expression.type === "conditionalExpression";
797
+ var isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
798
+ var isBooleanCondition = (expression) => expression.type === "booleanCondition";
799
+ var isRelationalExpression = (expression) => (expression == null ? void 0 : expression.type) === "relationalExpression";
800
+ var firstIncompleteExpression = (expression) => {
801
+ if (isUnknown(expression)) {
802
+ return expression;
803
+ } else if (isRelationalExpression(expression)) {
804
+ const [operand1, operand2] = expression.expressions;
805
+ if (expressionIsIncomplete(operand1)) {
806
+ return firstIncompleteExpression(operand1);
807
+ } else if (expression.op === "unknown") {
808
+ return expression;
809
+ } else if (expressionIsIncomplete(operand2)) {
810
+ return firstIncompleteExpression(operand2);
811
+ }
812
+ } else if (isCondition(expression)) {
813
+ const { expressions = [] } = expression;
814
+ for (const e of expressions) {
815
+ if (expressionIsIncomplete(e)) {
816
+ return firstIncompleteExpression(e);
817
+ }
818
+ }
819
+ } else if (isConditionalExpression(expression)) {
820
+ const { condition, truthyExpression, falsyExpression } = expression;
821
+ if (expressionIsIncomplete(condition)) {
822
+ return firstIncompleteExpression(condition);
823
+ } else if (expressionIsIncomplete(truthyExpression)) {
824
+ return firstIncompleteExpression(truthyExpression);
825
+ } else if (expressionIsIncomplete(falsyExpression)) {
826
+ return firstIncompleteExpression(falsyExpression);
827
+ }
828
+ } else if (isArithmeticExpression(expression)) {
829
+ const { expressions = [] } = expression;
830
+ for (const e of expressions) {
831
+ if (expressionIsIncomplete(e)) {
832
+ return firstIncompleteExpression(e);
833
+ }
834
+ }
835
+ }
836
+ };
837
+ var replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
838
+ const { expressions = [] } = incompleteExpression;
839
+ if (expressions.includes(unknownExpression)) {
840
+ const pos = expressions.indexOf(unknownExpression);
841
+ expressions.splice(pos, 1, expression);
842
+ return true;
843
+ } else {
844
+ for (const e of expressions) {
845
+ if (replaceUnknownExpression(e, unknownExpression, expression)) {
846
+ return true;
847
+ }
848
+ }
849
+ }
850
+ return false;
851
+ };
852
+ var expressionIsIncomplete = (expression) => {
853
+ if (isUnknown(expression)) {
854
+ return true;
855
+ } else if (isConditionalExpression(expression)) {
856
+ return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
857
+ } else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
858
+ return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
859
+ }
860
+ return false;
861
+ };
862
+ var addExpression = (expression, subExpression) => {
863
+ const targetExpression = firstIncompleteExpression(expression);
864
+ if (targetExpression) {
865
+ if (targetExpression.expressions) {
866
+ targetExpression.expressions.push(subExpression);
867
+ } else {
868
+ console.warn("don't know how to treat targetExpression");
869
+ }
870
+ } else {
871
+ console.error("no target expression found");
872
+ }
873
+ };
874
+ var _expression, _callStack;
875
+ var ColumnExpression = class {
876
+ constructor() {
877
+ __privateAdd(this, _expression, void 0);
878
+ __privateAdd(this, _callStack, []);
879
+ }
880
+ setCondition(booleanOperator) {
881
+ if (__privateGet(this, _expression) === void 0) {
882
+ this.addExpression(new ConditionalExpressionImpl(booleanOperator));
883
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
884
+ if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
885
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
886
+ this.addExpression(condition);
887
+ } else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
888
+ __privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
889
+ booleanOperator
890
+ );
891
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
892
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
893
+ this.addExpression(condition);
894
+ } else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
895
+ __privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
896
+ booleanOperator
897
+ );
898
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
899
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
900
+ this.addExpression(condition);
901
+ }
902
+ } else {
903
+ console.error("setCondition called unexpectedly");
904
+ }
905
+ }
906
+ addExpression(expression) {
907
+ if (__privateGet(this, _callStack).length > 0) {
908
+ const currentCallExpression = __privateGet(this, _callStack).at(-1);
909
+ currentCallExpression == null ? void 0 : currentCallExpression.arguments.push(expression);
910
+ } else if (__privateGet(this, _expression) === void 0) {
911
+ __privateSet(this, _expression, expression);
912
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
913
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
914
+ if (targetExpression && isUnknown(targetExpression)) {
915
+ replaceUnknownExpression(
916
+ __privateGet(this, _expression),
917
+ targetExpression,
918
+ expression
919
+ );
920
+ }
921
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
922
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
923
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
924
+ if (targetExpression && isUnknown(targetExpression)) {
925
+ replaceUnknownExpression(
926
+ __privateGet(this, _expression),
927
+ targetExpression,
928
+ expression
929
+ );
930
+ } else if (targetExpression) {
931
+ addExpression(targetExpression, expression);
932
+ }
933
+ }
934
+ }
935
+ }
936
+ setFunction(functionName) {
937
+ const callExpression = new CallExpressionImpl(functionName);
938
+ this.addExpression(callExpression);
939
+ __privateGet(this, _callStack).push(callExpression);
940
+ }
941
+ setColumn(columnName) {
942
+ this.addExpression(new ColumnExpressionImpl(columnName));
943
+ }
944
+ setArithmeticOp(value) {
945
+ const op = value;
946
+ const expression = __privateGet(this, _expression);
947
+ if (isArithmeticExpression(expression)) {
948
+ expression.op = op;
949
+ }
950
+ }
951
+ setRelationalOperator(value) {
952
+ const op = value;
953
+ if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
954
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
955
+ if (isRelationalExpression(targetExpression)) {
956
+ targetExpression.op = op;
957
+ } else {
958
+ console.error(`no target expression found (op = ${value})`);
959
+ }
960
+ }
961
+ }
962
+ setValue(value) {
963
+ const literalExpression = new LiteralExpressionImpl(value);
964
+ if (__privateGet(this, _expression) === void 0) {
965
+ __privateSet(this, _expression, literalExpression);
966
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
967
+ this.addExpression(literalExpression);
968
+ } else if (isCallExpression(__privateGet(this, _expression))) {
969
+ __privateGet(this, _expression).arguments.push(literalExpression);
970
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
971
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
972
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
973
+ if (targetExpression && isUnknown(targetExpression)) {
974
+ replaceUnknownExpression(
975
+ __privateGet(this, _expression),
976
+ targetExpression,
977
+ literalExpression
978
+ );
979
+ } else if (targetExpression) {
980
+ addExpression(targetExpression, literalExpression);
981
+ }
982
+ } else {
983
+ console.log("what do we do with value, in a complete expression");
984
+ }
985
+ }
986
+ }
987
+ closeBrace() {
988
+ __privateGet(this, _callStack).pop();
989
+ }
990
+ get expression() {
991
+ return __privateGet(this, _expression);
992
+ }
993
+ toJSON() {
994
+ var _a;
995
+ return (_a = __privateGet(this, _expression)) == null ? void 0 : _a.toJSON();
996
+ }
997
+ };
998
+ _expression = new WeakMap();
999
+ _callStack = new WeakMap();
1000
+ var walkTree = (tree, source) => {
1001
+ const columnExpression = new ColumnExpression();
1002
+ const cursor = tree.cursor();
1003
+ do {
1004
+ const { name: name2, from, to } = cursor;
1005
+ switch (name2) {
1006
+ case "AndCondition":
1007
+ columnExpression.setCondition("and");
1008
+ break;
1009
+ case "OrCondition":
1010
+ columnExpression.setCondition("or");
1011
+ break;
1012
+ case "RelationalExpression":
1013
+ columnExpression.setCondition();
1014
+ break;
1015
+ case "ArithmeticExpression":
1016
+ columnExpression.addExpression(new ArithmeticExpressionImpl());
1017
+ break;
1018
+ case "Column":
1019
+ {
1020
+ const columnName = source.substring(from, to);
1021
+ columnExpression.setColumn(columnName);
1022
+ }
1023
+ break;
1024
+ case "Function":
1025
+ {
1026
+ const functionName = source.substring(from, to);
1027
+ columnExpression.setFunction(functionName);
1028
+ }
1029
+ break;
1030
+ case "Times":
1031
+ case "Divide":
1032
+ case "Plus":
1033
+ case "Minus":
1034
+ {
1035
+ const op = source.substring(from, to);
1036
+ columnExpression.setArithmeticOp(op);
1037
+ }
1038
+ break;
1039
+ case "RelationalOperator":
1040
+ {
1041
+ const op = source.substring(from, to);
1042
+ columnExpression.setRelationalOperator(op);
1043
+ }
1044
+ break;
1045
+ case "False":
1046
+ case "True":
1047
+ {
1048
+ const value = source.substring(from, to);
1049
+ columnExpression.setValue(value === "true" ? true : false);
1050
+ }
1051
+ break;
1052
+ case "String":
1053
+ columnExpression.setValue(source.substring(from + 1, to - 1));
1054
+ break;
1055
+ case "Number":
1056
+ columnExpression.setValue(parseFloat(source.substring(from, to)));
1057
+ break;
1058
+ case "CloseBrace":
1059
+ columnExpression.closeBrace();
1060
+ break;
1061
+ default:
1062
+ }
1063
+ } while (cursor.next());
1064
+ return columnExpression.toJSON();
1065
+ };
1066
+
1067
+ // src/column-expression-input/column-language-parser/column-expression-parse-utils.ts
1068
+ var strictParser = parser.configure({ strict: true });
1069
+ var RelationalOperands = ["Number", "String"];
1070
+ var ColumnNamedTerms = [
1071
+ ...RelationalOperands,
1072
+ "AndCondition",
1073
+ "ArithmeticExpression",
1074
+ "BooleanOperator",
1075
+ "RelationalOperatorOperator",
1076
+ "CallExpression",
1077
+ "CloseBrace",
1078
+ "Column",
1079
+ "Comma",
1080
+ "ConditionalExpression",
1081
+ "Divide",
1082
+ "Equal",
1083
+ "If",
1084
+ "Minus",
1085
+ "OpenBrace",
1086
+ "OrCondition",
1087
+ "ParenthesizedExpression",
1088
+ "Plus",
1089
+ "RelationalExpression",
1090
+ "RelationalOperator",
1091
+ "Times"
1092
+ ];
1093
+ var isCompleteExpression = (src) => {
1094
+ try {
1095
+ strictParser.parse(src);
1096
+ return true;
1097
+ } catch (err) {
1098
+ return false;
1099
+ }
1100
+ };
1101
+ var lastNamedChild = (node) => {
1102
+ let { lastChild } = node;
1103
+ while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
1104
+ lastChild = lastChild.prevSibling;
1105
+ console.log(lastChild == null ? void 0 : lastChild.name);
1106
+ }
1107
+ return lastChild;
1108
+ };
1109
+ var isCompleteRelationalExpression = (node) => {
1110
+ if ((node == null ? void 0 : node.name) === "RelationalExpression") {
1111
+ const { firstChild } = node;
1112
+ const lastChild = lastNamedChild(node);
1113
+ if ((firstChild == null ? void 0 : firstChild.name) === "Column" && typeof (lastChild == null ? void 0 : lastChild.name) === "string" && RelationalOperands.includes(lastChild.name)) {
1114
+ return true;
1115
+ }
1116
+ }
1117
+ return false;
1118
+ };
1119
+
1120
+ // src/column-expression-input/highlighting.ts
1121
+ import {
1122
+ HighlightStyle,
1123
+ syntaxHighlighting,
1124
+ tags
1125
+ } from "@vuu-ui/vuu-codemirror";
1126
+ var myHighlightStyle = HighlightStyle.define([
1127
+ {
1128
+ tag: tags.attributeValue,
1129
+ color: "var(--vuuFilterEditor-variableColor);font-weight: bold"
1130
+ },
1131
+ { tag: tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
1132
+ { tag: tags.comment, color: "green", fontStyle: "italic" }
1133
+ ]);
1134
+ var vuuHighlighting = syntaxHighlighting(myHighlightStyle);
1135
+
1136
+ // src/column-expression-input/theme.ts
1137
+ import { EditorView } from "@vuu-ui/vuu-codemirror";
1138
+ var vuuTheme = EditorView.theme(
1139
+ {
1140
+ "&": {
1141
+ border: "solid 1px var(--salt-container-primary-borderColor)",
1142
+ color: "var(--vuuFilterEditor-color)",
1143
+ backgroundColor: "var(--vuuFilterEditor-background)"
1144
+ },
1145
+ ".cm-content": {
1146
+ caretColor: "var(--vuuFilterEditor-cursorColor)"
1147
+ },
1148
+ "&.cm-focused .cm-cursor": {
1149
+ borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
1150
+ },
1151
+ "&.cm-focused .cm-selectionBackground, ::selection": {
1152
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
1153
+ },
1154
+ ".cm-selectionBackground, ::selection": {
1155
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
1156
+ },
1157
+ ".cm-scroller": {
1158
+ fontFamily: "var(--vuuFilterEditor-fontFamily)"
1159
+ },
1160
+ ".cm-completionLabel": {
1161
+ color: "var(--vuu-color-gray-50)"
1162
+ },
1163
+ ".cm-completionMatchedText": {
1164
+ color: "var(--vuu-color-gray-80)",
1165
+ fontWeight: 700,
1166
+ textDecoration: "none"
1167
+ },
1168
+ ".cm-tooltip": {
1169
+ background: "var(--vuuFilterEditor-tooltipBackground)",
1170
+ border: "var(--vuuFilterEditor-tooltipBorder)",
1171
+ borderRadius: "4px",
1172
+ boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
1173
+ "&.cm-tooltip-autocomplete > ul": {
1174
+ fontFamily: "var(--vuuFilterEditor-fontFamily)",
1175
+ fontSize: "var(--vuuFilterEditor-fontSize)",
1176
+ maxHeight: "240px"
1177
+ },
1178
+ "&.cm-tooltip-autocomplete > ul > li": {
1179
+ height: "var(--vuuFilterEditor-suggestion-height)",
1180
+ padding: "0 3px",
1181
+ lineHeight: "var(--vuuFilterEditor-suggestion-height)"
1182
+ },
1183
+ "&.cm-tooltip-autocomplete li[aria-selected]": {
1184
+ background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
1185
+ color: "var(--vuuFilterEditor-suggestion-selectedColor)"
1186
+ },
1187
+ "&.cm-tooltip-autocomplete li .cm-completionDetail": {
1188
+ color: "var(--vuuFilterEditor-suggestion-detailColor)"
1189
+ }
1190
+ }
1191
+ },
1192
+ { dark: false }
1193
+ );
1194
+
1195
+ // src/column-expression-input/useColumnAutoComplete.ts
1196
+ import {
1197
+ booleanJoinSuggestions,
1198
+ getNamedParentNode,
1199
+ getPreviousNode,
1200
+ getValue,
1201
+ syntaxTree
1202
+ } from "@vuu-ui/vuu-codemirror";
1203
+ import { useCallback as useCallback4 } from "react";
1204
+ var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
1205
+ var _a;
1206
+ return {
1207
+ ...completion,
1208
+ apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
1209
+ };
1210
+ }) : completions;
1211
+ var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
1212
+ var completionDone = (onSubmit) => ({
1213
+ apply: () => {
1214
+ onSubmit == null ? void 0 : onSubmit();
1215
+ },
1216
+ label: "Done",
1217
+ boost: 10
1218
+ });
1219
+ var getLastChild = (node, context) => {
1220
+ var _a;
1221
+ let { lastChild: childNode } = node;
1222
+ const { pos } = context;
1223
+ while (childNode) {
1224
+ const isBeforeCursor = childNode.from < pos;
1225
+ if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
1226
+ if (childNode.name === "ParenthesizedExpression") {
1227
+ const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
1228
+ if (expression) {
1229
+ childNode = expression;
1230
+ }
1231
+ }
1232
+ return childNode;
1233
+ } else {
1234
+ childNode = childNode.prevSibling;
1235
+ }
1236
+ }
1237
+ };
1238
+ var getFunctionName = (node, state) => {
1239
+ var _a;
1240
+ if (node.name === "ArgList") {
1241
+ const functionNode = node.prevSibling;
1242
+ if (functionNode) {
1243
+ return getValue(functionNode, state);
1244
+ }
1245
+ } else if (node.name === "OpenBrace") {
1246
+ const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
1247
+ if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
1248
+ return getValue(maybeFunction, state);
1249
+ }
1250
+ }
1251
+ };
1252
+ var getRelationalOperator = (node, state) => {
1253
+ if (node.name === "RelationalExpression") {
1254
+ const lastNode = lastNamedChild(node);
1255
+ if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
1256
+ return getValue(lastNode, state);
1257
+ }
1258
+ } else {
1259
+ const prevNode = node.prevSibling;
1260
+ if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
1261
+ return getValue(prevNode, state);
1262
+ }
1263
+ }
1264
+ };
1265
+ var getColumnName = (node, state) => {
1266
+ var _a;
1267
+ if (node.name === "RelationalExpression") {
1268
+ if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
1269
+ return getValue(node.firstChild, state);
1270
+ }
1271
+ } else {
1272
+ const prevNode = node.prevSibling;
1273
+ if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
1274
+ return getValue(prevNode, state);
1275
+ } else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
1276
+ return getColumnName(prevNode, state);
1277
+ }
1278
+ }
1279
+ };
1280
+ var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
1281
+ const options = await suggestionProvider.getSuggestions(
1282
+ suggestionType,
1283
+ optionalArgs
1284
+ );
1285
+ const { startsWith = "" } = optionalArgs;
1286
+ return { from: context.pos - startsWith.length, options };
1287
+ };
1288
+ var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
1289
+ const lastChild = getLastChild(node, context);
1290
+ switch (lastChild == null ? void 0 : lastChild.name) {
1291
+ case "If":
1292
+ return makeSuggestions(context, suggestionProvider, "expression", {
1293
+ prefix: "( "
1294
+ });
1295
+ case "OpenBrace":
1296
+ return makeSuggestions(context, suggestionProvider, "expression");
1297
+ case "Condition":
1298
+ return makeSuggestions(context, suggestionProvider, "expression", {
1299
+ prefix: ", "
1300
+ });
1301
+ case "CloseBrace":
1302
+ if (maybeComplete) {
1303
+ const options = [completionDone(onSubmit)];
1304
+ return { from: context.pos, options };
1305
+ }
1306
+ }
1307
+ };
1308
+ var promptToSave = (context, onSubmit) => {
1309
+ const options = [completionDone(onSubmit)];
1310
+ return { from: context.pos, options };
1311
+ };
1312
+ var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
1313
+ const makeSuggestions2 = useCallback4(
1314
+ async (context, suggestionType, optionalArgs = {}) => {
1315
+ const options = await suggestionProvider.getSuggestions(
1316
+ suggestionType,
1317
+ optionalArgs
1318
+ );
1319
+ const { startsWith = "" } = optionalArgs;
1320
+ return { from: context.pos - startsWith.length, options };
1321
+ },
1322
+ [suggestionProvider]
1323
+ );
1324
+ return useCallback4(
1325
+ async (context) => {
1326
+ var _a, _b;
1327
+ const { state, pos } = context;
1328
+ const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
1329
+ from: 0,
1330
+ to: 0,
1331
+ text: void 0
1332
+ };
1333
+ const tree = syntaxTree(state);
1334
+ const nodeBefore = tree.resolveInner(pos, -1);
1335
+ const text = state.doc.toString();
1336
+ const maybeComplete = isCompleteExpression(text);
1337
+ switch (nodeBefore.name) {
1338
+ case "If": {
1339
+ return makeSuggestions2(context, "expression", { prefix: "( " });
1340
+ }
1341
+ case "Condition":
1342
+ {
1343
+ const lastChild = getLastChild(nodeBefore, context);
1344
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1345
+ const prevChild = getPreviousNode(lastChild);
1346
+ if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
1347
+ return makeSuggestions2(context, "condition-operator", {
1348
+ columnName: getValue(lastChild, state)
1349
+ });
1350
+ }
1351
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
1352
+ return makeSuggestions2(context, "expression");
1353
+ }
1354
+ }
1355
+ break;
1356
+ case "ConditionalExpression":
1357
+ return handleConditionalExpression(
1358
+ nodeBefore,
1359
+ context,
1360
+ suggestionProvider
1361
+ );
1362
+ case "RelationalExpression":
1363
+ {
1364
+ if (isCompleteRelationalExpression(nodeBefore)) {
1365
+ return {
1366
+ from: context.pos,
1367
+ options: booleanJoinSuggestions.concat({
1368
+ label: ", <truthy expression>, <falsy expression>",
1369
+ apply: ", "
1370
+ })
1371
+ };
1372
+ } else {
1373
+ const operator = getRelationalOperator(nodeBefore, state);
1374
+ const columnName = getColumnName(nodeBefore, state);
1375
+ if (!operator) {
1376
+ const options = await suggestionProvider.getSuggestions(
1377
+ "condition-operator",
1378
+ {
1379
+ columnName
1380
+ }
1381
+ );
1382
+ return { from: context.pos, options };
1383
+ } else {
1384
+ return makeSuggestions2(context, "expression");
1385
+ }
1386
+ }
1387
+ }
1388
+ break;
1389
+ case "RelationalOperator":
1390
+ return makeSuggestions2(context, "expression");
1391
+ case "String":
1392
+ {
1393
+ const operator = getRelationalOperator(
1394
+ nodeBefore,
1395
+ state
1396
+ );
1397
+ const columnName = getColumnName(nodeBefore, state);
1398
+ const { from, to } = nodeBefore;
1399
+ if (to - from === 2 && context.pos === from + 1) {
1400
+ if (columnName && operator) {
1401
+ return makeSuggestions2(context, "columnValue", {
1402
+ columnName,
1403
+ operator,
1404
+ startsWith: word.text
1405
+ });
1406
+ }
1407
+ } else if (to - from > 2 && context.pos === to) {
1408
+ return makeSuggestions2(context, "expression", {
1409
+ prefix: ", "
1410
+ });
1411
+ }
1412
+ }
1413
+ break;
1414
+ case "ArithmeticExpression":
1415
+ {
1416
+ const lastChild = getLastChild(nodeBefore, context);
1417
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1418
+ return makeSuggestions2(context, "expression");
1419
+ } else if (isOperator(lastChild)) {
1420
+ const operator = lastChild.name;
1421
+ return makeSuggestions2(context, "column", { operator });
1422
+ }
1423
+ }
1424
+ break;
1425
+ case "OpenBrace":
1426
+ {
1427
+ const functionName = getFunctionName(nodeBefore, state);
1428
+ return makeSuggestions2(context, "expression", { functionName });
1429
+ }
1430
+ break;
1431
+ case "ArgList": {
1432
+ const functionName = getFunctionName(nodeBefore, state);
1433
+ const lastArgument = getLastChild(nodeBefore, context);
1434
+ const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" || (lastArgument == null ? void 0 : lastArgument.name) === "Comma" ? void 0 : ",";
1435
+ let options = await suggestionProvider.getSuggestions("expression", {
1436
+ functionName
1437
+ });
1438
+ options = prefix ? applyPrefix(options, ", ") : options;
1439
+ if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
1440
+ options = [
1441
+ {
1442
+ apply: ") ",
1443
+ boost: 10,
1444
+ label: "Done - no more arguments"
1445
+ }
1446
+ ].concat(options);
1447
+ }
1448
+ return { from: context.pos, options };
1449
+ }
1450
+ case "Equal":
1451
+ if (text.trim() === "=") {
1452
+ return makeSuggestions2(context, "expression");
1453
+ }
1454
+ break;
1455
+ case "ParenthesizedExpression":
1456
+ case "ColumnDefinitionExpression":
1457
+ if (context.pos === 0) {
1458
+ return makeSuggestions2(context, "expression");
1459
+ } else {
1460
+ const lastChild = getLastChild(nodeBefore, context);
1461
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1462
+ if (maybeComplete) {
1463
+ const options = [
1464
+ completionDone(onSubmit.current)
1465
+ ];
1466
+ const columnName = getValue(lastChild, state);
1467
+ const columnOptions = await suggestionProvider.getSuggestions("operator", {
1468
+ columnName
1469
+ });
1470
+ return {
1471
+ from: context.pos,
1472
+ options: options.concat(columnOptions)
1473
+ };
1474
+ }
1475
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
1476
+ if (maybeComplete) {
1477
+ return {
1478
+ from: context.pos,
1479
+ options: [completionDone(onSubmit.current)]
1480
+ };
1481
+ }
1482
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
1483
+ if (maybeComplete) {
1484
+ let options = [completionDone(onSubmit.current)];
1485
+ const lastExpressionChild = getLastChild(lastChild, context);
1486
+ if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
1487
+ const columnName = getValue(lastExpressionChild, state);
1488
+ const suggestions = await suggestionProvider.getSuggestions(
1489
+ "operator",
1490
+ { columnName }
1491
+ );
1492
+ options = options.concat(suggestions);
1493
+ }
1494
+ return {
1495
+ from: context.pos,
1496
+ options
1497
+ };
1498
+ }
1499
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
1500
+ return handleConditionalExpression(
1501
+ lastChild,
1502
+ context,
1503
+ suggestionProvider,
1504
+ maybeComplete,
1505
+ onSubmit.current
1506
+ );
1507
+ }
1508
+ break;
1509
+ }
1510
+ case "Column":
1511
+ {
1512
+ const isPartialMatch = await suggestionProvider.isPartialMatch(
1513
+ "expression",
1514
+ void 0,
1515
+ word.text
1516
+ );
1517
+ if (isPartialMatch) {
1518
+ return makeSuggestions2(context, "expression", {
1519
+ startsWith: word.text
1520
+ });
1521
+ }
1522
+ }
1523
+ break;
1524
+ case "Comma":
1525
+ {
1526
+ const parentNode = getNamedParentNode(nodeBefore);
1527
+ if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1528
+ return makeSuggestions2(context, "expression");
1529
+ }
1530
+ }
1531
+ break;
1532
+ case "CloseBrace":
1533
+ {
1534
+ const parentNode = getNamedParentNode(nodeBefore);
1535
+ if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1536
+ return handleConditionalExpression(
1537
+ parentNode,
1538
+ context,
1539
+ suggestionProvider,
1540
+ maybeComplete,
1541
+ onSubmit.current
1542
+ );
1543
+ } else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
1544
+ if (maybeComplete) {
1545
+ return promptToSave(context, onSubmit.current);
1546
+ }
1547
+ }
1548
+ }
1549
+ break;
1550
+ default: {
1551
+ if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
1552
+ console.log("looks like we ight be a or|and operator");
1553
+ }
1554
+ }
1555
+ }
1556
+ },
1557
+ [makeSuggestions2, onSubmit, suggestionProvider]
1558
+ );
1559
+ };
1560
+
1561
+ // src/column-expression-input/useColumnExpressionEditor.ts
1562
+ var getView = (ref) => {
1563
+ if (ref.current == void 0) {
1564
+ throw Error("EditorView not defined");
1565
+ }
1566
+ return ref.current;
1567
+ };
1568
+ var getOptionClass = () => {
1569
+ return "vuuSuggestion";
1570
+ };
1571
+ var noop = () => console.log("noooop");
1572
+ var hasExpressionType = (completion) => "expressionType" in completion;
1573
+ var injectOptionContent = (completion) => {
1574
+ if (hasExpressionType(completion)) {
1575
+ const div = createEl("div", "expression-type-container");
1576
+ const span = createEl("span", "expression-type", completion.expressionType);
1577
+ div.appendChild(span);
1578
+ return div;
1579
+ } else {
1580
+ return null;
1581
+ }
1582
+ };
1583
+ var useColumnExpressionEditor = ({
1584
+ onChange,
1585
+ onSubmitExpression,
1586
+ source,
1587
+ suggestionProvider
1588
+ }) => {
1589
+ const editorRef = useRef3(null);
1590
+ const onSubmitRef = useRef3(noop);
1591
+ const viewRef = useRef3();
1592
+ const completionFn = useColumnAutoComplete(suggestionProvider, onSubmitRef);
1593
+ const [createState, clearInput, submit] = useMemo2(() => {
1594
+ const parseExpression = () => {
1595
+ const view = getView(viewRef);
1596
+ const source2 = view.state.doc.toString();
1597
+ const tree = ensureSyntaxTree(view.state, view.state.doc.length, 5e3);
1598
+ if (tree) {
1599
+ const expression = walkTree(tree, source2);
1600
+ return [source2, expression];
1601
+ } else {
1602
+ return ["", void 0];
1603
+ }
1604
+ };
1605
+ const clearInput2 = () => {
1606
+ getView(viewRef).setState(createState2());
1607
+ };
1608
+ const submitExpression = () => {
1609
+ const [source2, expression] = parseExpression();
1610
+ onSubmitExpression == null ? void 0 : onSubmitExpression(source2, expression);
1611
+ };
1612
+ const showSuggestions = (key) => {
1613
+ return keymap.of([
1614
+ {
1615
+ key,
1616
+ run() {
1617
+ startCompletion(getView(viewRef));
1618
+ return true;
1619
+ }
1620
+ }
1621
+ ]);
1622
+ };
1623
+ const createState2 = () => EditorState2.create({
1624
+ doc: source,
1625
+ extensions: [
1626
+ minimalSetup,
1627
+ autocompletion({
1628
+ addToOptions: [
1629
+ {
1630
+ render: injectOptionContent,
1631
+ position: 70
1632
+ }
1633
+ ],
1634
+ override: [completionFn],
1635
+ optionClass: getOptionClass
1636
+ }),
1637
+ columnExpressionLanguageSupport(),
1638
+ keymap.of(defaultKeymap),
1639
+ showSuggestions("ArrowDown"),
1640
+ EditorView2.updateListener.of((v) => {
1641
+ const view = getView(viewRef);
1642
+ if (v.docChanged) {
1643
+ startCompletion(view);
1644
+ const source2 = view.state.doc.toString();
1645
+ onChange == null ? void 0 : onChange(source2);
1646
+ }
1647
+ }),
1648
+ // Enforces single line view
1649
+ EditorState2.transactionFilter.of(
1650
+ (tr) => tr.newDoc.lines > 1 ? [] : tr
1651
+ ),
1652
+ vuuTheme,
1653
+ vuuHighlighting
1654
+ ]
1655
+ });
1656
+ onSubmitRef.current = () => {
1657
+ submitExpression();
1658
+ };
1659
+ return [createState2, clearInput2, submitExpression];
1660
+ }, [completionFn, onChange, onSubmitExpression, source]);
1661
+ useEffect2(() => {
1662
+ if (!editorRef.current) {
1663
+ throw Error("editor not in dom");
1664
+ }
1665
+ viewRef.current = new EditorView2({
1666
+ state: createState(),
1667
+ parent: editorRef.current
1668
+ });
1669
+ return () => {
1670
+ var _a;
1671
+ (_a = viewRef.current) == null ? void 0 : _a.destroy();
1672
+ };
1673
+ }, [completionFn, createState]);
1674
+ const handleBlur = useCallback5(() => {
1675
+ submit();
1676
+ }, [submit]);
1677
+ return { editorRef, clearInput, onBlur: handleBlur };
1678
+ };
1679
+
1680
+ // src/column-expression-input/ColumnExpressionInput.tsx
1681
+ import { jsx as jsx8 } from "react/jsx-runtime";
1682
+ var classBase7 = "vuuColumnExpressionInput";
1683
+ var ColumnExpressionInput = memo4(
1684
+ ({
1685
+ onChange,
1686
+ onSubmitExpression,
1687
+ source = "",
1688
+ suggestionProvider
1689
+ }) => {
1690
+ const { editorRef, onBlur } = useColumnExpressionEditor({
1691
+ onChange,
1692
+ onSubmitExpression,
1693
+ source,
1694
+ suggestionProvider
1695
+ });
1696
+ return /* @__PURE__ */ jsx8("div", { className: `${classBase7}`, onBlur, ref: editorRef });
1697
+ },
1698
+ (prevProps, newProps) => {
1699
+ return prevProps.source === newProps.source;
1700
+ }
1701
+ );
1702
+ ColumnExpressionInput.displayName = "ColumnExpressionInput";
1703
+
1704
+ // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
1705
+ import {
1706
+ AnnotationType,
1707
+ getRelationalOperators,
1708
+ numericOperators,
1709
+ stringOperators,
1710
+ toSuggestions
1711
+ } from "@vuu-ui/vuu-codemirror";
1712
+ import {
1713
+ getTypeaheadParams,
1714
+ useTypeaheadSuggestions
1715
+ } from "@vuu-ui/vuu-data-react";
1716
+ import { isNumericColumn, isTextColumn } from "@vuu-ui/vuu-utils";
1717
+ import { useCallback as useCallback6, useRef as useRef4 } from "react";
1718
+
1719
+ // src/column-expression-input/column-function-descriptors.ts
1720
+ var columnFunctionDescriptors = [
1721
+ /**
1722
+ * and
1723
+ */
1724
+ {
1725
+ accepts: ["boolean"],
1726
+ description: "Applies boolean and operator across supplied parameters to returns a single boolean result",
1727
+ example: {
1728
+ expression: 'and(ccy="EUR",quantity=0)',
1729
+ result: "true | false"
1730
+ },
1731
+ name: "and",
1732
+ params: {
1733
+ description: "( boolean, [ boolean* ] )"
1734
+ },
1735
+ type: "boolean"
1736
+ },
1737
+ /**
1738
+ * concatenate()
1739
+ */
1740
+ {
1741
+ accepts: "string",
1742
+ 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.",
1743
+ example: {
1744
+ expression: 'concatenate("example", "-test")',
1745
+ result: '"example-test"'
1746
+ },
1747
+ name: "concatenate",
1748
+ params: {
1749
+ description: "( string, string, [ string* ] )"
1750
+ },
1751
+ type: "string"
1752
+ },
1753
+ /**
1754
+ * contains()
1755
+ */
1756
+ {
1757
+ accepts: ["string", "string"],
1758
+ 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>",
1759
+ example: {
1760
+ expression: 'contains("Royal Bank of Scotland", "bank")',
1761
+ result: "true"
1762
+ },
1763
+ name: "contains",
1764
+ params: {
1765
+ description: "( string )"
1766
+ },
1767
+ type: "boolean"
1768
+ },
1769
+ /**
1770
+ * left()
1771
+ */
1772
+ {
1773
+ accepts: ["string", "number"],
1774
+ description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
1775
+ example: {
1776
+ expression: 'left("USD Benchmark Report", 3)',
1777
+ result: '"USD"'
1778
+ },
1779
+ name: "left",
1780
+ params: {
1781
+ count: 2,
1782
+ description: "( string, number )"
1783
+ },
1784
+ type: "string"
1785
+ },
1786
+ /**
1787
+ * len()
1788
+ */
1789
+ {
1790
+ accepts: "string",
1791
+ description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
1792
+ example: {
1793
+ expression: 'len("example")',
1794
+ result: "7"
1795
+ },
1796
+ name: "len",
1797
+ params: {
1798
+ description: "(string)"
1799
+ },
1800
+ type: "number"
1801
+ },
1802
+ /**
1803
+ * lower()
1804
+ */
1805
+ {
1806
+ accepts: "string",
1807
+ description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
1808
+ example: {
1809
+ expression: 'lower("examPLE")',
1810
+ result: '"example"'
1811
+ },
1812
+ name: "lower",
1813
+ params: {
1814
+ description: "( string )"
1815
+ },
1816
+ type: "string"
1817
+ },
1818
+ /**
1819
+ * or
1820
+ */
1821
+ {
1822
+ accepts: ["boolean"],
1823
+ description: "Applies boolean or operator across supplied parameters to returns a single boolean result",
1824
+ example: {
1825
+ expression: 'or(status="cancelled",quantity=0)',
1826
+ result: "true | false"
1827
+ },
1828
+ name: "or",
1829
+ params: {
1830
+ description: "( boolean, [ boolean* ] )"
1831
+ },
1832
+ type: "boolean"
1833
+ },
1834
+ /**
1835
+ * upper()
1836
+ */
1837
+ {
1838
+ accepts: "string",
1839
+ description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
1840
+ example: {
1841
+ expression: 'upper("example")',
1842
+ result: '"EXAMPLE"'
1843
+ },
1844
+ name: "upper",
1845
+ params: {
1846
+ description: "( string )"
1847
+ },
1848
+ type: "string"
1849
+ },
1850
+ /**
1851
+ * right()
1852
+ */
1853
+ {
1854
+ accepts: ["string", "number"],
1855
+ description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
1856
+ example: {
1857
+ expression: "blah",
1858
+ result: "blah"
1859
+ },
1860
+ name: "right",
1861
+ params: {
1862
+ description: "( string )"
1863
+ },
1864
+ type: "string"
1865
+ },
1866
+ /**
1867
+ * replace()
1868
+ */
1869
+ {
1870
+ accepts: ["string", "string", "string"],
1871
+ 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>",
1872
+ example: {
1873
+ expression: "blah",
1874
+ result: "blah"
1875
+ },
1876
+ name: "replace",
1877
+ params: {
1878
+ description: "( string )"
1879
+ },
1880
+ type: "string"
1881
+ },
1882
+ /**
1883
+ * text()
1884
+ */
1885
+ {
1886
+ accepts: "number",
1887
+ description: "Converts a number to a string.",
1888
+ example: {
1889
+ expression: "blah",
1890
+ result: "blah"
1891
+ },
1892
+ name: "text",
1893
+ params: {
1894
+ description: "( string )"
1895
+ },
1896
+ type: "string"
1897
+ },
1898
+ /**
1899
+ * starts()
1900
+ */
1901
+ {
1902
+ accepts: "string",
1903
+ 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>.",
1904
+ example: {
1905
+ expression: "blah",
1906
+ result: "blah"
1907
+ },
1908
+ name: "starts",
1909
+ params: {
1910
+ description: "( string )"
1911
+ },
1912
+ type: "boolean"
1913
+ },
1914
+ /**
1915
+ * starts()
1916
+ */
1917
+ {
1918
+ accepts: "string",
1919
+ 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>.",
1920
+ example: {
1921
+ expression: "blah",
1922
+ result: "blah"
1923
+ },
1924
+ name: "ends",
1925
+ params: {
1926
+ description: "( string )"
1927
+ },
1928
+ type: "boolean"
1929
+ },
1930
+ {
1931
+ accepts: "number",
1932
+ description: "blah",
1933
+ example: {
1934
+ expression: "blah",
1935
+ result: "blah"
1936
+ },
1937
+ name: "min",
1938
+ params: {
1939
+ description: "( string )"
1940
+ },
1941
+ type: "number"
1942
+ },
1943
+ {
1944
+ accepts: "number",
1945
+ description: "blah",
1946
+ example: {
1947
+ expression: "blah",
1948
+ result: "blah"
1949
+ },
1950
+ name: "max",
1951
+ params: {
1952
+ description: "( string )"
1953
+ },
1954
+ type: "number"
1955
+ },
1956
+ {
1957
+ accepts: "number",
1958
+ description: "blah",
1959
+ example: {
1960
+ expression: "blah",
1961
+ result: "blah"
1962
+ },
1963
+ name: "sum",
1964
+ params: {
1965
+ description: "( string )"
1966
+ },
1967
+ type: "number"
1968
+ },
1969
+ {
1970
+ accepts: "number",
1971
+ description: "blah",
1972
+ example: {
1973
+ expression: "blah",
1974
+ result: "blah"
1975
+ },
1976
+ name: "round",
1977
+ params: {
1978
+ description: "( string )"
1979
+ },
1980
+ type: "number"
1981
+ },
1982
+ {
1983
+ accepts: "any",
1984
+ description: "blah",
1985
+ example: {
1986
+ expression: "blah",
1987
+ result: "blah"
1988
+ },
1989
+ name: "or",
1990
+ params: {
1991
+ description: "( string )"
1992
+ },
1993
+ type: "boolean"
1994
+ },
1995
+ {
1996
+ accepts: "any",
1997
+ description: "blah",
1998
+ example: {
1999
+ expression: "blah",
2000
+ result: "blah"
2001
+ },
2002
+ name: "and",
2003
+ params: {
2004
+ description: "( string )"
2005
+ },
2006
+ type: "boolean"
2007
+ },
2008
+ {
2009
+ accepts: "any",
2010
+ 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>. ",
2011
+ example: {
2012
+ expression: "blah",
2013
+ result: "blah"
2014
+ },
2015
+ name: "if",
2016
+ params: {
2017
+ description: "( filterExpression, expression1, expression 2)"
2018
+ },
2019
+ type: "variable"
2020
+ }
2021
+ ];
2022
+
2023
+ // src/column-expression-input/functionDocInfo.ts
2024
+ import { createEl as createEl2 } from "@vuu-ui/vuu-utils";
2025
+ var functionDocInfo = ({
2026
+ name: name2,
2027
+ description,
2028
+ example,
2029
+ params,
2030
+ type
2031
+ }) => {
2032
+ const rootElement = createEl2("div", "vuuFunctionDoc");
2033
+ const headingElement = createEl2("div", "function-heading");
2034
+ const nameElement = createEl2("span", "function-name", name2);
2035
+ const paramElement = createEl2("span", "param-list", params.description);
2036
+ const typeElement = createEl2("span", "function-type", type);
2037
+ headingElement.appendChild(nameElement);
2038
+ headingElement.appendChild(paramElement);
2039
+ headingElement.appendChild(typeElement);
2040
+ const child2 = createEl2("p", void 0, description);
2041
+ rootElement.appendChild(headingElement);
2042
+ rootElement.appendChild(child2);
2043
+ if (example) {
2044
+ const exampleElement = createEl2("div", "example-container");
2045
+ const expressionElement = createEl2(
2046
+ "div",
2047
+ "example-expression",
2048
+ example.expression
2049
+ );
2050
+ const resultElement = createEl2("div", "example-result", example.result);
2051
+ exampleElement.appendChild(expressionElement);
2052
+ rootElement.appendChild(exampleElement);
2053
+ rootElement.appendChild(resultElement);
2054
+ }
2055
+ return rootElement;
2056
+ };
2057
+
2058
+ // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
2059
+ var NO_OPERATORS = [];
2060
+ var withApplySpace = (suggestions) => suggestions.map((suggestion) => {
2061
+ var _a;
2062
+ return {
2063
+ ...suggestion,
2064
+ apply: ((_a = suggestion.apply) != null ? _a : suggestion.label) + " "
2065
+ };
2066
+ });
2067
+ var getValidColumns = (columns, { functionName, operator }) => {
2068
+ if (operator) {
2069
+ return columns.filter(isNumericColumn);
2070
+ } else if (functionName) {
2071
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
2072
+ if (fn) {
2073
+ switch (fn.accepts) {
2074
+ case "string":
2075
+ return columns.filter(isTextColumn);
2076
+ case "number":
2077
+ return columns.filter(isNumericColumn);
2078
+ default:
2079
+ return columns;
2080
+ }
2081
+ }
2082
+ }
2083
+ return columns;
2084
+ };
2085
+ var getColumns = (columns, options) => {
2086
+ const validColumns = getValidColumns(columns, options);
2087
+ return validColumns.map((column) => {
2088
+ var _a;
2089
+ const label = (_a = column.label) != null ? _a : column.name;
2090
+ return {
2091
+ apply: options.prefix ? `${options.prefix}${column.name}` : column.name,
2092
+ label,
2093
+ boost: 5,
2094
+ type: "column",
2095
+ expressionType: column.serverDataType
2096
+ };
2097
+ });
2098
+ };
2099
+ var arithmeticOperators = [
2100
+ { apply: "* ", boost: 2, label: "*", type: "operator" },
2101
+ { apply: "/ ", boost: 2, label: "/", type: "operator" },
2102
+ { apply: "+ ", boost: 2, label: "+", type: "operator" },
2103
+ { apply: "- ", boost: 2, label: "-", type: "operator" }
2104
+ ];
2105
+ var getOperators = (column) => {
2106
+ if (column === void 0 || isNumericColumn(column)) {
2107
+ return arithmeticOperators;
2108
+ } else {
2109
+ return NO_OPERATORS;
2110
+ }
2111
+ };
2112
+ var getConditionOperators = (column) => {
2113
+ switch (column.serverDataType) {
2114
+ case "string":
2115
+ case "char":
2116
+ return withApplySpace(
2117
+ stringOperators
2118
+ /*, startsWith*/
2119
+ );
2120
+ case "int":
2121
+ case "long":
2122
+ case "double":
2123
+ return withApplySpace(numericOperators);
2124
+ }
2125
+ };
2126
+ var toFunctionCompletion = (functionDescriptor) => ({
2127
+ apply: `${functionDescriptor.name}( `,
2128
+ boost: 2,
2129
+ expressionType: functionDescriptor.type,
2130
+ info: () => functionDocInfo(functionDescriptor),
2131
+ label: functionDescriptor.name,
2132
+ type: "function"
2133
+ });
2134
+ var getAcceptedTypes = (fn) => {
2135
+ if (fn) {
2136
+ if (typeof fn.accepts === "string") {
2137
+ return fn.accepts;
2138
+ } else if (Array.isArray(fn.accepts)) {
2139
+ if (fn.accepts.every((s) => s === "string")) {
2140
+ return "string";
2141
+ } else {
2142
+ return "any";
2143
+ }
2144
+ }
2145
+ }
2146
+ return "any";
2147
+ };
2148
+ var functions = columnFunctionDescriptors.map(toFunctionCompletion);
2149
+ var getFunctions = ({ functionName }) => {
2150
+ if (functionName) {
2151
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
2152
+ const acceptedTypes = getAcceptedTypes(fn);
2153
+ if (fn) {
2154
+ switch (acceptedTypes) {
2155
+ case "string":
2156
+ return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
2157
+ case "number":
2158
+ return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
2159
+ default:
2160
+ }
2161
+ }
2162
+ }
2163
+ return functions;
2164
+ };
2165
+ var NONE = {};
2166
+ var useColumnExpressionSuggestionProvider = ({
2167
+ columns,
2168
+ table
2169
+ }) => {
2170
+ const findColumn = useCallback6(
2171
+ (name2) => name2 ? columns.find((col) => col.name === name2) : void 0,
2172
+ [columns]
2173
+ );
2174
+ const latestSuggestionsRef = useRef4();
2175
+ const getTypeaheadSuggestions = useTypeaheadSuggestions();
2176
+ const getSuggestions = useCallback6(
2177
+ async (suggestionType, options = NONE) => {
2178
+ const { columnName, functionName, operator, prefix } = options;
2179
+ switch (suggestionType) {
2180
+ case "expression": {
2181
+ const suggestions = await withApplySpace(
2182
+ getColumns(columns, { functionName, prefix })
2183
+ ).concat(getFunctions(options));
2184
+ return latestSuggestionsRef.current = suggestions;
2185
+ }
2186
+ case "column": {
2187
+ const suggestions = await getColumns(columns, options);
2188
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2189
+ }
2190
+ case "operator": {
2191
+ const suggestions = await getOperators(findColumn(columnName));
2192
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2193
+ }
2194
+ case "relational-operator": {
2195
+ const suggestions = await getRelationalOperators(
2196
+ findColumn(columnName)
2197
+ );
2198
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2199
+ }
2200
+ case "condition-operator":
2201
+ {
2202
+ const column = findColumn(columnName);
2203
+ if (column) {
2204
+ const suggestions = await getConditionOperators(column);
2205
+ if (suggestions) {
2206
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
2207
+ }
2208
+ }
2209
+ }
2210
+ break;
2211
+ case "columnValue":
2212
+ if (columnName && operator) {
2213
+ const params = getTypeaheadParams(
2214
+ table,
2215
+ columnName
2216
+ /*, startsWith*/
2217
+ );
2218
+ const suggestions = await getTypeaheadSuggestions(params);
2219
+ latestSuggestionsRef.current = toSuggestions(suggestions, {
2220
+ suffix: ""
2221
+ });
2222
+ latestSuggestionsRef.current.forEach((suggestion) => {
2223
+ suggestion.apply = (view, completion, from) => {
2224
+ const annotation = new AnnotationType();
2225
+ const cursorPos = from + completion.label.length + 1;
2226
+ view.dispatch({
2227
+ changes: { from, insert: completion.label },
2228
+ selection: { anchor: cursorPos, head: cursorPos },
2229
+ annotations: annotation.of(completion)
2230
+ });
2231
+ };
2232
+ });
2233
+ return latestSuggestionsRef.current;
2234
+ }
2235
+ break;
2236
+ }
2237
+ return [];
2238
+ },
2239
+ [columns, findColumn, getTypeaheadSuggestions, table]
2240
+ );
2241
+ const isPartialMatch = useCallback6(
2242
+ async (valueType, columnName, pattern) => {
2243
+ const { current: latestSuggestions } = latestSuggestionsRef;
2244
+ let maybe = false;
2245
+ const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
2246
+ if (pattern && suggestions) {
2247
+ for (const option of suggestions) {
2248
+ if (option.label === pattern) {
2249
+ return false;
2250
+ } else if (option.label.startsWith(pattern)) {
2251
+ maybe = true;
2252
+ }
2253
+ }
2254
+ }
2255
+ return maybe;
2256
+ },
2257
+ [getSuggestions]
2258
+ );
2259
+ return {
2260
+ getSuggestions,
2261
+ isPartialMatch
2262
+ };
2263
+ };
2264
+
2265
+ // src/column-expression-panel/useColumnExpression.ts
2266
+ import {
2267
+ getCalculatedColumnDetails,
2268
+ isVuuColumnDataType,
2269
+ setCalculatedColumnExpression,
2270
+ setCalculatedColumnName,
2271
+ setCalculatedColumnType
2272
+ } from "@vuu-ui/vuu-utils";
2273
+ import { useCallback as useCallback7, useRef as useRef5, useState as useState2 } from "react";
2274
+ var applyDefaults = (column) => {
2275
+ const [name2, expression, type] = getCalculatedColumnDetails(column);
2276
+ if (type === "") {
2277
+ return {
2278
+ ...column,
2279
+ name: `${name2}:string:${expression}`
2280
+ };
2281
+ } else {
2282
+ return column;
2283
+ }
2284
+ };
2285
+ var useColumnExpression = ({
2286
+ column: columnProp,
2287
+ onChangeName: onChangeNameProp,
2288
+ onChangeServerDataType: onChangeServerDataTypeProp
2289
+ }) => {
2290
+ const [column, _setColumn] = useState2(
2291
+ applyDefaults(columnProp)
2292
+ );
2293
+ const columnRef = useRef5(columnProp);
2294
+ const setColumn = useCallback7((column2) => {
2295
+ columnRef.current = column2;
2296
+ _setColumn(column2);
2297
+ }, []);
2298
+ const onChangeName = useCallback7(
2299
+ (evt) => {
2300
+ const { value } = evt.target;
2301
+ const newColumn = setCalculatedColumnName(column, value);
2302
+ setColumn(newColumn);
2303
+ onChangeNameProp == null ? void 0 : onChangeNameProp(newColumn.name);
2304
+ },
2305
+ [column, onChangeNameProp, setColumn]
2306
+ );
2307
+ const onChangeExpression = useCallback7(
2308
+ (value) => {
2309
+ const expression = value.trim();
2310
+ const { current: column2 } = columnRef;
2311
+ const newColumn = setCalculatedColumnExpression(column2, expression);
2312
+ setColumn(newColumn);
2313
+ onChangeNameProp == null ? void 0 : onChangeNameProp(newColumn.name);
2314
+ },
2315
+ [onChangeNameProp, setColumn]
2316
+ );
2317
+ const onChangeServerDataType = useCallback7(
2318
+ (evt, value) => {
2319
+ if (isVuuColumnDataType(value)) {
2320
+ const newColumn = setCalculatedColumnType(column, value);
2321
+ setColumn(newColumn);
2322
+ onChangeNameProp == null ? void 0 : onChangeNameProp(newColumn.name);
2323
+ onChangeServerDataTypeProp == null ? void 0 : onChangeServerDataTypeProp(value);
2324
+ }
2325
+ },
2326
+ [column, onChangeNameProp, onChangeServerDataTypeProp, setColumn]
2327
+ );
2328
+ return {
2329
+ column,
2330
+ onChangeExpression,
2331
+ onChangeName,
2332
+ onChangeServerDataType
2333
+ };
2334
+ };
2335
+
2336
+ // src/column-expression-panel/ColumnExpressionPanel.tsx
2337
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
2338
+ var classBase8 = "vuuColumnExpressionPanel";
2339
+ var ColumnExpressionPanel = ({
2340
+ column: columnProp,
2341
+ onChangeName: onChangeNameProp,
2342
+ onChangeServerDataType: onChangeServerDataTypeProp,
2343
+ tableConfig,
2344
+ vuuTable
2345
+ }) => {
2346
+ const typeRef = useRef6(null);
2347
+ const { column, onChangeExpression, onChangeName, onChangeServerDataType } = useColumnExpression({
2348
+ column: columnProp,
2349
+ onChangeName: onChangeNameProp,
2350
+ onChangeServerDataType: onChangeServerDataTypeProp
2351
+ });
2352
+ const initialExpressionRef = useRef6(
2353
+ getCalculatedColumnExpression(column)
2354
+ );
2355
+ const suggestionProvider = useColumnExpressionSuggestionProvider({
2356
+ columns: tableConfig.columns,
2357
+ table: vuuTable
2358
+ });
2359
+ const handleSubmitExpression = useCallback8(() => {
2360
+ var _a, _b;
2361
+ if (typeRef.current) {
2362
+ (_b = (_a = typeRef.current) == null ? void 0 : _a.querySelector("button")) == null ? void 0 : _b.focus();
2363
+ }
2364
+ }, []);
2365
+ return /* @__PURE__ */ jsxs6("div", { className: classBase8, children: [
2366
+ /* @__PURE__ */ jsx9("div", { className: "vuuColumnSettingsPanel-header", children: /* @__PURE__ */ jsx9("span", { children: "Calculation" }) }),
2367
+ /* @__PURE__ */ jsxs6(FormField2, { "data-field": "column-name", children: [
2368
+ /* @__PURE__ */ jsx9(FormFieldLabel2, { children: "Column Name" }),
2369
+ /* @__PURE__ */ jsx9(
2370
+ Input,
2371
+ {
2372
+ className: "vuuInput",
2373
+ onChange: onChangeName,
2374
+ value: getCalculatedColumnName(column)
2375
+ }
2376
+ )
2377
+ ] }),
2378
+ /* @__PURE__ */ jsxs6(FormField2, { "data-field": "column-expression", children: [
2379
+ /* @__PURE__ */ jsx9(FormFieldLabel2, { children: "Expression" }),
2380
+ /* @__PURE__ */ jsx9(
2381
+ ColumnExpressionInput,
2382
+ {
2383
+ onChange: onChangeExpression,
2384
+ onSubmitExpression: handleSubmitExpression,
2385
+ source: initialExpressionRef.current,
2386
+ suggestionProvider
2387
+ }
2388
+ )
2389
+ ] }),
2390
+ /* @__PURE__ */ jsxs6(FormField2, { "data-field": "type", children: [
2391
+ /* @__PURE__ */ jsx9(FormFieldLabel2, { children: "Column type" }),
2392
+ /* @__PURE__ */ jsx9(
2393
+ Dropdown3,
2394
+ {
2395
+ className: `${classBase8}-type`,
2396
+ onSelectionChange: onChangeServerDataType,
2397
+ ref: typeRef,
2398
+ selected: getCalculatedColumnType(column) || null,
2399
+ source: ["double", "long", "string", "boolean"],
2400
+ width: "100%"
2401
+ }
2402
+ )
2403
+ ] })
2404
+ ] });
2405
+ };
2406
+
2407
+ // src/column-formatting-settings/ColumnFormattingPanel.tsx
2408
+ import { Dropdown as Dropdown5 } from "@vuu-ui/vuu-ui-controls";
2409
+ import {
2410
+ getCellRendererOptions,
2411
+ getConfigurationEditor,
2412
+ isColumnTypeRenderer as isColumnTypeRenderer2,
2413
+ isTypeDescriptor as isTypeDescriptor5
2414
+ } from "@vuu-ui/vuu-utils";
2415
+ import { FormField as FormField6, FormFieldLabel as FormFieldLabel6 } from "@salt-ds/core";
2416
+ import cx5 from "clsx";
2417
+ import { useCallback as useCallback12, useMemo as useMemo4 } from "react";
2418
+
2419
+ // src/column-formatting-settings/BaseNumericFormattingSettings.tsx
2420
+ import { FormField as FormField3, FormFieldLabel as FormFieldLabel3, Input as Input2, Switch as Switch2 } from "@salt-ds/core";
2421
+ import { getTypeFormattingFromColumn } from "@vuu-ui/vuu-utils";
2422
+ import {
2423
+ useCallback as useCallback9,
2424
+ useState as useState3
2425
+ } from "react";
2426
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
2427
+ var classBase9 = "vuuFormattingSettings";
2428
+ var BaseNumericFormattingSettings = ({
2429
+ column,
2430
+ onChangeFormatting: onChange
2431
+ }) => {
2432
+ var _a, _b, _c;
2433
+ const [formattingSettings, setFormattingSettings] = useState3(getTypeFormattingFromColumn(column));
2434
+ const handleInputKeyDown = useCallback9(
2435
+ (evt) => {
2436
+ if (evt.key === "Enter" || evt.key === "Tab") {
2437
+ onChange(formattingSettings);
2438
+ }
2439
+ },
2440
+ [formattingSettings, onChange]
2441
+ );
2442
+ const handleChangeDecimals = useCallback9(
2443
+ (evt) => {
2444
+ const { value } = evt.target;
2445
+ const numericValue = value === "" ? void 0 : isNaN(parseInt(value)) ? void 0 : parseInt(value);
2446
+ const newFormattingSettings = {
2447
+ ...formattingSettings,
2448
+ decimals: numericValue
2449
+ };
2450
+ setFormattingSettings(newFormattingSettings);
2451
+ },
2452
+ [formattingSettings]
2453
+ );
2454
+ const handleChangeAlignDecimals = useCallback9(
2455
+ (evt) => {
2456
+ const { checked } = evt.target;
2457
+ const newFormattingSettings = {
2458
+ ...formattingSettings,
2459
+ alignOnDecimals: checked
2460
+ };
2461
+ setFormattingSettings(newFormattingSettings);
2462
+ onChange(newFormattingSettings);
2463
+ },
2464
+ [formattingSettings, onChange]
2465
+ );
2466
+ const handleChangeZeroPad = useCallback9(
2467
+ (evt) => {
2468
+ const { checked } = evt.target;
2469
+ const newFormattingSettings = {
2470
+ ...formattingSettings,
2471
+ zeroPad: checked
2472
+ };
2473
+ setFormattingSettings(newFormattingSettings);
2474
+ onChange(newFormattingSettings);
2475
+ },
2476
+ [formattingSettings, onChange]
2477
+ );
2478
+ return /* @__PURE__ */ jsxs7("div", { className: classBase9, children: [
2479
+ /* @__PURE__ */ jsxs7(FormField3, { "data-field": "decimals", children: [
2480
+ /* @__PURE__ */ jsx10(FormFieldLabel3, { children: "Number of decimals" }),
2481
+ /* @__PURE__ */ jsx10(
2482
+ Input2,
2483
+ {
2484
+ className: "vuuInput",
2485
+ onChange: handleChangeDecimals,
2486
+ onKeyDown: handleInputKeyDown,
2487
+ value: (_a = formattingSettings.decimals) != null ? _a : ""
2488
+ }
2489
+ )
2490
+ ] }),
2491
+ /* @__PURE__ */ jsxs7(FormField3, { labelPlacement: "left", children: [
2492
+ /* @__PURE__ */ jsx10(FormFieldLabel3, { children: "Align on decimals" }),
2493
+ /* @__PURE__ */ jsx10(
2494
+ Switch2,
2495
+ {
2496
+ checked: (_b = formattingSettings.alignOnDecimals) != null ? _b : false,
2497
+ onChange: handleChangeAlignDecimals,
2498
+ value: "align-decimals"
2499
+ }
2500
+ )
2501
+ ] }),
2502
+ /* @__PURE__ */ jsxs7(FormField3, { labelPlacement: "left", children: [
2503
+ /* @__PURE__ */ jsx10(FormFieldLabel3, { children: "Zero pad decimals" }),
2504
+ /* @__PURE__ */ jsx10(
2505
+ Switch2,
2506
+ {
2507
+ checked: (_c = formattingSettings.zeroPad) != null ? _c : false,
2508
+ onChange: handleChangeZeroPad,
2509
+ value: "zero-pad"
2510
+ }
2511
+ )
2512
+ ] })
2513
+ ] });
2514
+ };
2515
+
2516
+ // src/column-formatting-settings/LongTypeFormattingSettings.tsx
2517
+ import { useCallback as useCallback11 } from "react";
2518
+ import {
2519
+ FormField as FormField5,
2520
+ FormFieldLabel as FormFieldLabel5,
2521
+ ToggleButton as ToggleButton2,
2522
+ ToggleButtonGroup as ToggleButtonGroup2
2523
+ } from "@salt-ds/core";
2524
+ import { isDateTimeColumn, isTypeDescriptor as isTypeDescriptor4 } from "@vuu-ui/vuu-utils";
2525
+
2526
+ // src/column-formatting-settings/DateTimeFormattingSettings.tsx
2527
+ import { useCallback as useCallback10, useMemo as useMemo3, useState as useState4 } from "react";
2528
+ import { Dropdown as Dropdown4 } from "@vuu-ui/vuu-ui-controls";
2529
+ import {
2530
+ defaultPatternsByType,
2531
+ fallbackDateTimePattern,
2532
+ getTypeFormattingFromColumn as getTypeFormattingFromColumn2,
2533
+ supportedDateTimePatterns
2534
+ } from "@vuu-ui/vuu-utils";
2535
+ import {
2536
+ FormField as FormField4,
2537
+ FormFieldLabel as FormFieldLabel4,
2538
+ ToggleButton,
2539
+ ToggleButtonGroup
2540
+ } from "@salt-ds/core";
2541
+ import { Fragment, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
2542
+ var DateTimeFormattingSettings = ({ column, onChangeFormatting: onChange }) => {
2543
+ var _a, _b;
2544
+ const formatting = getTypeFormattingFromColumn2(column);
2545
+ const { pattern = fallbackDateTimePattern } = formatting;
2546
+ const toggleValue = useMemo3(() => getToggleValue(pattern), [pattern]);
2547
+ const [fallbackState, setFallbackState] = useState4(
2548
+ {
2549
+ time: (_a = pattern.time) != null ? _a : defaultPatternsByType.time,
2550
+ date: (_b = pattern.date) != null ? _b : defaultPatternsByType.date
2551
+ }
2552
+ );
2553
+ const onPatternChange = useCallback10(
2554
+ (pattern2) => onChange({ ...formatting, pattern: pattern2 }),
2555
+ [onChange, formatting]
2556
+ );
2557
+ const onDropdownChange = useCallback10(
2558
+ (key) => (_, p) => {
2559
+ const updatedPattern = { ...pattern != null ? pattern : {}, [key]: p };
2560
+ setFallbackState((s) => {
2561
+ var _a2, _b2;
2562
+ return {
2563
+ time: (_a2 = updatedPattern.time) != null ? _a2 : s.time,
2564
+ date: (_b2 = updatedPattern.date) != null ? _b2 : s.date
2565
+ };
2566
+ });
2567
+ onPatternChange(updatedPattern);
2568
+ },
2569
+ [onPatternChange, pattern]
2570
+ );
2571
+ const onToggleChange = useCallback10(
2572
+ (evnt) => {
2573
+ var _a2, _b2, _c, _d;
2574
+ const value = evnt.currentTarget.value;
2575
+ switch (value) {
2576
+ case "time":
2577
+ return onPatternChange({
2578
+ [value]: (_a2 = pattern[value]) != null ? _a2 : fallbackState[value]
2579
+ });
2580
+ case "date":
2581
+ return onPatternChange({
2582
+ [value]: (_b2 = pattern[value]) != null ? _b2 : fallbackState[value]
2583
+ });
2584
+ case "both":
2585
+ return onPatternChange({
2586
+ time: (_c = pattern.time) != null ? _c : fallbackState.time,
2587
+ date: (_d = pattern.date) != null ? _d : fallbackState.date
2588
+ });
2589
+ }
2590
+ },
2591
+ [onPatternChange, pattern, fallbackState]
2592
+ );
2593
+ return /* @__PURE__ */ jsxs8(Fragment, { children: [
2594
+ /* @__PURE__ */ jsxs8(FormField4, { labelPlacement: "top", children: [
2595
+ /* @__PURE__ */ jsx11(FormFieldLabel4, { children: "Display" }),
2596
+ /* @__PURE__ */ jsx11(
2597
+ ToggleButtonGroup,
2598
+ {
2599
+ className: "vuuToggleButtonGroup",
2600
+ onChange: onToggleChange,
2601
+ value: toggleValue,
2602
+ "data-variant": "primary",
2603
+ children: toggleValues.map((v) => /* @__PURE__ */ jsx11(ToggleButton, { value: v, children: v.toUpperCase() }, v))
2604
+ }
2605
+ )
2606
+ ] }),
2607
+ ["date", "time"].filter((v) => !!pattern[v]).map((v) => /* @__PURE__ */ jsxs8(FormField4, { labelPlacement: "top", children: [
2608
+ /* @__PURE__ */ jsx11(FormFieldLabel4, { children: `${labelByType[v]} pattern` }),
2609
+ /* @__PURE__ */ jsx11(
2610
+ Dropdown4,
2611
+ {
2612
+ onSelectionChange: onDropdownChange(v),
2613
+ selected: pattern[v],
2614
+ source: supportedDateTimePatterns[v],
2615
+ width: "100%"
2616
+ }
2617
+ )
2618
+ ] }, v))
2619
+ ] });
2620
+ };
2621
+ var labelByType = { date: "Date", time: "Time" };
2622
+ var toggleValues = ["date", "time", "both"];
2623
+ function getToggleValue(pattern) {
2624
+ return !pattern.time ? "date" : !pattern.date ? "time" : "both";
2625
+ }
2626
+
2627
+ // src/column-formatting-settings/LongTypeFormattingSettings.tsx
2628
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
2629
+ var classBase10 = "vuuLongColumnFormattingSettings";
2630
+ var LongTypeFormattingSettings = (props) => {
2631
+ const { column, onChangeColumnType: onChangeType } = props;
2632
+ const type = isTypeDescriptor4(column.type) ? column.type.name : column.type;
2633
+ const handleToggleChange = useCallback11(
2634
+ (event) => {
2635
+ const value = event.currentTarget.value;
2636
+ onChangeType(value);
2637
+ },
2638
+ [onChangeType]
2639
+ );
2640
+ return /* @__PURE__ */ jsxs9("div", { className: classBase10, children: [
2641
+ /* @__PURE__ */ jsxs9(FormField5, { children: [
2642
+ /* @__PURE__ */ jsx12(FormFieldLabel5, { children: "Type inferred as" }),
2643
+ /* @__PURE__ */ jsx12(
2644
+ ToggleButtonGroup2,
2645
+ {
2646
+ className: "vuuToggleButtonGroup",
2647
+ onChange: handleToggleChange,
2648
+ value: type != null ? type : "number",
2649
+ children: toggleValues2.map((v) => /* @__PURE__ */ jsx12(ToggleButton2, { value: v, children: v.toUpperCase() }, v))
2650
+ }
2651
+ )
2652
+ ] }),
2653
+ isDateTimeColumn(column) ? /* @__PURE__ */ jsx12(DateTimeFormattingSettings, { ...props, column }) : /* @__PURE__ */ jsx12(BaseNumericFormattingSettings, { ...props })
2654
+ ] });
2655
+ };
2656
+ var toggleValues2 = ["number", "date/time"];
2657
+
2658
+ // src/column-formatting-settings/ColumnFormattingPanel.tsx
2659
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2660
+ var classBase11 = "vuuColumnFormattingPanel";
2661
+ var itemToString = (item) => {
2662
+ var _a;
2663
+ return (_a = item.label) != null ? _a : item.name;
2664
+ };
2665
+ var ColumnFormattingPanel = ({
2666
+ availableRenderers,
2667
+ className,
2668
+ column,
2669
+ onChangeFormatting,
2670
+ onChangeColumnType,
2671
+ onChangeRendering,
2672
+ ...htmlAttributes
2673
+ }) => {
2674
+ const formattingSettingsComponent = useMemo4(
2675
+ () => getFormattingSettingsComponent({
2676
+ column,
2677
+ onChangeFormatting,
2678
+ onChangeColumnType
2679
+ }),
2680
+ [column, onChangeColumnType, onChangeFormatting]
2681
+ );
2682
+ console.log({ formattingSettingsComponent });
2683
+ const ConfigEditor = useMemo4(() => {
2684
+ const { type } = column;
2685
+ if (isTypeDescriptor5(type) && isColumnTypeRenderer2(type.renderer)) {
2686
+ const cellRendererOptions = getCellRendererOptions(type.renderer.name);
2687
+ return getConfigurationEditor(cellRendererOptions == null ? void 0 : cellRendererOptions.configEditor);
2688
+ }
2689
+ return void 0;
2690
+ }, [column]);
2691
+ const selectedCellRenderer = useMemo4(() => {
2692
+ const { type } = column;
2693
+ const [defaultRenderer] = availableRenderers;
2694
+ const rendererName = isTypeDescriptor5(type) && isColumnTypeRenderer2(type.renderer) ? type.renderer.name : void 0;
2695
+ const configuredRenderer = availableRenderers.find(
2696
+ (renderer) => renderer.name === rendererName
2697
+ );
2698
+ return configuredRenderer != null ? configuredRenderer : defaultRenderer;
2699
+ }, [availableRenderers, column]);
2700
+ const handleChangeRenderer = useCallback12(
2701
+ (_, cellRendererDescriptor) => {
2702
+ const renderProps = {
2703
+ name: cellRendererDescriptor.name
2704
+ };
2705
+ onChangeRendering == null ? void 0 : onChangeRendering(renderProps);
2706
+ },
2707
+ [onChangeRendering]
2708
+ );
2709
+ const { serverDataType = "string" } = column;
2710
+ return /* @__PURE__ */ jsxs10("div", { ...htmlAttributes, className: `vuuColumnSettingsPanel-header`, children: [
2711
+ /* @__PURE__ */ jsx13("div", { children: "Formatting" }),
2712
+ /* @__PURE__ */ jsxs10(FormField6, { children: [
2713
+ /* @__PURE__ */ jsx13(FormFieldLabel6, { children: `Renderer (data type ${column.serverDataType})` }),
2714
+ /* @__PURE__ */ jsx13(
2715
+ Dropdown5,
2716
+ {
2717
+ className: cx5(`${classBase11}-renderer`),
2718
+ itemToString,
2719
+ onSelectionChange: handleChangeRenderer,
2720
+ selected: selectedCellRenderer,
2721
+ source: availableRenderers,
2722
+ width: "100%"
2723
+ }
2724
+ )
2725
+ ] }),
2726
+ /* @__PURE__ */ jsxs10(
2727
+ "div",
2728
+ {
2729
+ className: cx5(classBase11, className, `${classBase11}-${serverDataType}`),
2730
+ children: [
2731
+ formattingSettingsComponent,
2732
+ ConfigEditor ? /* @__PURE__ */ jsx13(
2733
+ ConfigEditor,
2734
+ {
2735
+ column,
2736
+ onChangeRendering
2737
+ }
2738
+ ) : null
2739
+ ]
2740
+ }
2741
+ )
2742
+ ] });
2743
+ };
2744
+ function getFormattingSettingsComponent(props) {
2745
+ const { column } = props;
2746
+ switch (column.serverDataType) {
2747
+ case "double":
2748
+ case "int":
2749
+ return /* @__PURE__ */ jsx13(BaseNumericFormattingSettings, { ...props });
2750
+ case "long":
2751
+ return /* @__PURE__ */ jsx13(LongTypeFormattingSettings, { ...props });
2752
+ default:
2753
+ return null;
2754
+ }
2755
+ }
2756
+
2757
+ // src/column-settings/ColumnNameLabel.tsx
2758
+ import cx6 from "clsx";
2759
+ import {
2760
+ getCalculatedColumnDetails as getCalculatedColumnDetails2,
2761
+ isCalculatedColumn
2762
+ } from "@vuu-ui/vuu-utils";
2763
+ import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
2764
+ var classBase12 = "vuuColumnNameLabel";
2765
+ var ColumnNameLabel = ({ column, onClick }) => {
2766
+ if (isCalculatedColumn(column.name)) {
2767
+ const [name2, type, expression] = getCalculatedColumnDetails2(column);
2768
+ const displayName = name2 || "name";
2769
+ const displayExpression = "=expression";
2770
+ const nameClass = displayName === "name" ? `${classBase12}-placeholder` : void 0;
2771
+ const expressionClass = expression === "" ? `${classBase12}-placeholder` : void 0;
2772
+ return /* @__PURE__ */ jsxs11(
2773
+ "div",
2774
+ {
2775
+ className: cx6(classBase12, `${classBase12}-calculated`),
2776
+ onClick,
2777
+ children: [
2778
+ /* @__PURE__ */ jsx14("span", { className: nameClass, children: displayName }),
2779
+ /* @__PURE__ */ jsx14("span", { children: ":" }),
2780
+ /* @__PURE__ */ jsx14("span", { children: type || "string" }),
2781
+ /* @__PURE__ */ jsx14("span", { children: ":" }),
2782
+ /* @__PURE__ */ jsx14("span", { className: expressionClass, children: displayExpression }),
2783
+ /* @__PURE__ */ jsx14("span", { className: `${classBase12}-edit`, "data-icon": "edit" })
2784
+ ]
2785
+ }
2786
+ );
2787
+ } else {
2788
+ return /* @__PURE__ */ jsx14("div", { className: classBase12, children: column.name });
2789
+ }
2790
+ };
2791
+
2792
+ // src/column-settings/useColumnSettings.ts
2793
+ import {
2794
+ getRegisteredCellRenderers,
2795
+ isValidColumnAlignment,
2796
+ isValidPinLocation,
2797
+ setCalculatedColumnName as setCalculatedColumnName2,
2798
+ updateColumnRenderProps,
2799
+ updateColumnFormatting,
2800
+ updateColumnType,
2801
+ queryClosest as queryClosest2
2802
+ } from "@vuu-ui/vuu-utils";
2803
+ import {
2804
+ useCallback as useCallback13,
2805
+ useEffect as useEffect3,
2806
+ useMemo as useMemo5,
2807
+ useRef as useRef7,
2808
+ useState as useState5
2809
+ } from "react";
2810
+ var integerCellRenderers = [
2811
+ {
2812
+ description: "Default formatter for columns with data type integer",
2813
+ label: "Default Renderer (int, long)",
2814
+ name: "default-int"
2815
+ }
2816
+ ];
2817
+ var doubleCellRenderers = [
2818
+ {
2819
+ description: "Default formatter for columns with data type double",
2820
+ label: "Default Renderer (double)",
2821
+ name: "default-double"
2822
+ }
2823
+ ];
2824
+ var stringCellRenderers = [
2825
+ {
2826
+ description: "Default formatter for columns with data type string",
2827
+ label: "Default Renderer (string)",
2828
+ name: "default-string"
2829
+ }
2830
+ ];
2831
+ var booleanCellRenderers = [];
2832
+ var getAvailableCellRenderers = (column) => {
2833
+ switch (column.serverDataType) {
2834
+ case "char":
2835
+ case "string":
2836
+ return stringCellRenderers.concat(getRegisteredCellRenderers("string"));
2837
+ case "int":
2838
+ case "long":
2839
+ return integerCellRenderers.concat(getRegisteredCellRenderers("int"));
2840
+ case "double":
2841
+ return doubleCellRenderers.concat(getRegisteredCellRenderers("double"));
2842
+ case "boolean":
2843
+ return booleanCellRenderers.concat(getRegisteredCellRenderers("boolean"));
2844
+ default:
2845
+ return stringCellRenderers;
2846
+ }
2847
+ };
2848
+ var getFieldName = (input) => {
2849
+ const saltFormField = input.closest(".saltFormField");
2850
+ if (saltFormField && saltFormField.dataset.field) {
2851
+ const {
2852
+ dataset: { field }
2853
+ } = saltFormField;
2854
+ return field;
2855
+ } else {
2856
+ throw Error("named form field not found");
2857
+ }
2858
+ };
2859
+ var getColumn = (columns, column) => {
2860
+ if (column.name === "::") {
2861
+ return column;
2862
+ } else {
2863
+ const col = columns.find((col2) => col2.name === column.name);
2864
+ if (col) {
2865
+ return col;
2866
+ }
2867
+ throw Error(`columns does not contain column ${name}`);
2868
+ }
2869
+ };
2870
+ var replaceColumn = (tableConfig, column) => ({
2871
+ ...tableConfig,
2872
+ columns: tableConfig.columns.map(
2873
+ (col) => col.name === column.name ? column : col
2874
+ )
2875
+ });
2876
+ var useColumnSettings = ({
2877
+ column: columnProp,
2878
+ onCancelCreateColumn,
2879
+ onConfigChange,
2880
+ onCreateCalculatedColumn,
2881
+ tableConfig
2882
+ }) => {
2883
+ const [column, setColumn] = useState5(
2884
+ getColumn(tableConfig.columns, columnProp)
2885
+ );
2886
+ const columnRef = useRef7(column);
2887
+ const [inEditMode, setEditMode] = useState5(column.name === "::");
2888
+ const handleEditCalculatedcolumn = useCallback13(() => {
2889
+ columnRef.current = column;
2890
+ setEditMode(true);
2891
+ }, [column]);
2892
+ useEffect3(() => {
2893
+ setColumn(columnProp);
2894
+ setEditMode(columnProp.name === "::");
2895
+ }, [columnProp]);
2896
+ const availableRenderers = useMemo5(() => {
2897
+ return getAvailableCellRenderers(column);
2898
+ }, [column]);
2899
+ const handleInputCommit = useCallback13(() => {
2900
+ onConfigChange(replaceColumn(tableConfig, column));
2901
+ }, [column, onConfigChange, tableConfig]);
2902
+ const handleChangeToggleButton = useCallback13(
2903
+ (evt) => {
2904
+ const button = queryClosest2(evt.target, "button");
2905
+ if (button) {
2906
+ const fieldName = getFieldName(button);
2907
+ const { value } = button;
2908
+ switch (fieldName) {
2909
+ case "column-alignment":
2910
+ if (isValidColumnAlignment(value)) {
2911
+ const newColumn = {
2912
+ ...column,
2913
+ align: value || void 0
2914
+ };
2915
+ setColumn(newColumn);
2916
+ onConfigChange(replaceColumn(tableConfig, newColumn));
2917
+ }
2918
+ break;
2919
+ case "column-pin":
2920
+ if (isValidPinLocation(value)) {
2921
+ const newColumn = {
2922
+ ...column,
2923
+ pin: value || void 0
2924
+ };
2925
+ setColumn(newColumn);
2926
+ onConfigChange(replaceColumn(tableConfig, newColumn));
2927
+ break;
2928
+ }
2929
+ }
2930
+ }
2931
+ },
2932
+ [column, onConfigChange, tableConfig]
2933
+ );
2934
+ const handleChange = useCallback13((evt) => {
2935
+ const input = evt.target;
2936
+ const fieldName = getFieldName(input);
2937
+ const { value } = input;
2938
+ switch (fieldName) {
2939
+ case "column-label":
2940
+ setColumn((state) => ({ ...state, label: value }));
2941
+ break;
2942
+ case "column-name":
2943
+ setColumn((state) => setCalculatedColumnName2(state, value));
2944
+ break;
2945
+ case "column-width":
2946
+ setColumn((state) => ({ ...state, width: parseInt(value) }));
2947
+ break;
2948
+ }
2949
+ }, []);
2950
+ const handleChangeCalculatedColumnName = useCallback13((name2) => {
2951
+ setColumn((state) => ({ ...state, name: name2 }));
2952
+ }, []);
2953
+ const handleChangeFormatting = useCallback13(
2954
+ (formatting) => {
2955
+ const newColumn = updateColumnFormatting(column, formatting);
2956
+ setColumn(newColumn);
2957
+ onConfigChange(replaceColumn(tableConfig, newColumn));
2958
+ },
2959
+ [column, onConfigChange, tableConfig]
2960
+ );
2961
+ const handleChangeType = useCallback13(
2962
+ (type) => {
2963
+ const updatedColumn = updateColumnType(column, type);
2964
+ setColumn(updatedColumn);
2965
+ onConfigChange(replaceColumn(tableConfig, updatedColumn));
2966
+ },
2967
+ [column, onConfigChange, tableConfig]
2968
+ );
2969
+ const handleChangeServerDataType = useCallback13(
2970
+ (serverDataType) => {
2971
+ setColumn((col) => ({ ...col, serverDataType }));
2972
+ },
2973
+ []
2974
+ );
2975
+ const handleChangeRendering = useCallback13(
2976
+ (renderProps) => {
2977
+ if (renderProps) {
2978
+ const newColumn = updateColumnRenderProps(
2979
+ column,
2980
+ renderProps
2981
+ );
2982
+ setColumn(newColumn);
2983
+ onConfigChange(replaceColumn(tableConfig, newColumn));
2984
+ }
2985
+ },
2986
+ [column, onConfigChange, tableConfig]
2987
+ );
2988
+ const navigateColumn = useCallback13(
2989
+ ({ moveBy }) => {
2990
+ const { columns } = tableConfig;
2991
+ const index = columns.indexOf(column) + moveBy;
2992
+ const newColumn = columns[index];
2993
+ if (newColumn) {
2994
+ setColumn(newColumn);
2995
+ }
2996
+ },
2997
+ [column, tableConfig]
2998
+ );
2999
+ const navigateNextColumn = useCallback13(() => {
3000
+ navigateColumn({ moveBy: 1 });
3001
+ }, [navigateColumn]);
3002
+ const navigatePrevColumn = useCallback13(() => {
3003
+ navigateColumn({ moveBy: -1 });
3004
+ }, [navigateColumn]);
3005
+ const handleSaveCalculatedColumn = useCallback13(() => {
3006
+ onCreateCalculatedColumn(column);
3007
+ }, [column, onCreateCalculatedColumn]);
3008
+ const handleCancelEdit = useCallback13(() => {
3009
+ if (columnProp.name === "::") {
3010
+ onCancelCreateColumn();
3011
+ } else {
3012
+ if (columnRef.current !== void 0 && columnRef.current !== column) {
3013
+ setColumn(columnRef.current);
3014
+ }
3015
+ setEditMode(false);
3016
+ }
3017
+ }, [column, columnProp.name, onCancelCreateColumn]);
3018
+ return {
3019
+ availableRenderers,
3020
+ editCalculatedColumn: inEditMode,
3021
+ column,
3022
+ navigateNextColumn,
3023
+ navigatePrevColumn,
3024
+ onCancel: handleCancelEdit,
3025
+ onChange: handleChange,
3026
+ onChangeCalculatedColumnName: handleChangeCalculatedColumnName,
3027
+ onChangeFormatting: handleChangeFormatting,
3028
+ onChangeRendering: handleChangeRendering,
3029
+ onChangeServerDataType: handleChangeServerDataType,
3030
+ onChangeToggleButton: handleChangeToggleButton,
3031
+ onChangeType: handleChangeType,
3032
+ onEditCalculatedColumn: handleEditCalculatedcolumn,
3033
+ onInputCommit: handleInputCommit,
3034
+ onSave: handleSaveCalculatedColumn
3035
+ };
3036
+ };
3037
+
3038
+ // src/column-settings/ColumnSettingsPanel.tsx
3039
+ import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
3040
+ var classBase13 = "vuuColumnSettingsPanel";
3041
+ var getColumnLabel2 = (column) => {
3042
+ const { name: name2, label } = column;
3043
+ if (isCalculatedColumn2(name2)) {
3044
+ return label != null ? label : getCalculatedColumnName2(column);
3045
+ } else {
3046
+ return label != null ? label : name2;
3047
+ }
3048
+ };
3049
+ var ColumnSettingsPanel = ({
3050
+ column: columnProp,
3051
+ onCancelCreateColumn,
3052
+ onConfigChange,
3053
+ onCreateCalculatedColumn,
3054
+ tableConfig,
3055
+ vuuTable
3056
+ }) => {
3057
+ const isNewCalculatedColumn = columnProp.name === "::";
3058
+ const {
3059
+ availableRenderers,
3060
+ editCalculatedColumn,
3061
+ column,
3062
+ navigateNextColumn,
3063
+ navigatePrevColumn,
3064
+ onCancel,
3065
+ onChange,
3066
+ onChangeCalculatedColumnName,
3067
+ onChangeFormatting,
3068
+ onChangeRendering,
3069
+ onChangeServerDataType,
3070
+ onChangeToggleButton,
3071
+ onChangeType,
3072
+ onEditCalculatedColumn,
3073
+ onInputCommit,
3074
+ onSave
3075
+ } = useColumnSettings({
3076
+ column: columnProp,
3077
+ onCancelCreateColumn,
3078
+ onConfigChange,
3079
+ onCreateCalculatedColumn,
3080
+ tableConfig
3081
+ });
3082
+ const {
3083
+ serverDataType,
3084
+ align = getDefaultAlignment(serverDataType),
3085
+ pin,
3086
+ width
3087
+ } = column;
3088
+ return /* @__PURE__ */ jsxs12(
3089
+ "div",
3090
+ {
3091
+ className: cx7(classBase13, {
3092
+ [`${classBase13}-editing`]: editCalculatedColumn
3093
+ }),
3094
+ children: [
3095
+ /* @__PURE__ */ jsx15("div", { className: `${classBase13}-header`, children: /* @__PURE__ */ jsx15(ColumnNameLabel, { column, onClick: onEditCalculatedColumn }) }),
3096
+ editCalculatedColumn ? /* @__PURE__ */ jsx15(
3097
+ ColumnExpressionPanel,
3098
+ {
3099
+ column,
3100
+ onChangeName: onChangeCalculatedColumnName,
3101
+ onChangeServerDataType,
3102
+ tableConfig,
3103
+ vuuTable
3104
+ }
3105
+ ) : null,
3106
+ /* @__PURE__ */ jsxs12(FormField7, { "data-field": "column-label", children: [
3107
+ /* @__PURE__ */ jsx15(FormFieldLabel7, { children: "Column Label" }),
3108
+ /* @__PURE__ */ jsx15(
3109
+ VuuInput,
3110
+ {
3111
+ className: "vuuInput",
3112
+ onChange,
3113
+ onCommit: onInputCommit,
3114
+ value: getColumnLabel2(column)
3115
+ }
3116
+ )
3117
+ ] }),
3118
+ /* @__PURE__ */ jsxs12(FormField7, { "data-field": "column-width", children: [
3119
+ /* @__PURE__ */ jsx15(FormFieldLabel7, { children: "Column Width" }),
3120
+ /* @__PURE__ */ jsx15(
3121
+ VuuInput,
3122
+ {
3123
+ className: "vuuInput",
3124
+ onChange,
3125
+ value: width,
3126
+ onCommit: onInputCommit
3127
+ }
3128
+ )
3129
+ ] }),
3130
+ /* @__PURE__ */ jsxs12(FormField7, { "data-field": "column-alignment", children: [
3131
+ /* @__PURE__ */ jsx15(FormFieldLabel7, { children: "Alignment" }),
3132
+ /* @__PURE__ */ jsxs12(ToggleButtonGroup3, { onChange: onChangeToggleButton, value: align, children: [
3133
+ /* @__PURE__ */ jsx15(ToggleButton3, { value: "left", children: /* @__PURE__ */ jsx15(Icon2, { name: "align-left", size: 16 }) }),
3134
+ /* @__PURE__ */ jsx15(ToggleButton3, { value: "right", children: /* @__PURE__ */ jsx15(Icon2, { name: "align-right", size: 16 }) })
3135
+ ] })
3136
+ ] }),
3137
+ /* @__PURE__ */ jsxs12(FormField7, { "data-field": "column-pin", children: [
3138
+ /* @__PURE__ */ jsx15(FormFieldLabel7, { children: "Pin Column" }),
3139
+ /* @__PURE__ */ jsxs12(ToggleButtonGroup3, { onChange: onChangeToggleButton, value: pin != null ? pin : "", children: [
3140
+ /* @__PURE__ */ jsx15(ToggleButton3, { value: "", children: /* @__PURE__ */ jsx15(Icon2, { name: "cross-circle", size: 16 }) }),
3141
+ /* @__PURE__ */ jsx15(ToggleButton3, { value: "left", children: /* @__PURE__ */ jsx15(Icon2, { name: "pin-left", size: 16 }) }),
3142
+ /* @__PURE__ */ jsx15(ToggleButton3, { value: "floating", children: /* @__PURE__ */ jsx15(Icon2, { name: "pin-float", size: 16 }) }),
3143
+ /* @__PURE__ */ jsx15(ToggleButton3, { value: "right", children: /* @__PURE__ */ jsx15(Icon2, { name: "pin-right", size: 16 }) })
3144
+ ] })
3145
+ ] }),
3146
+ /* @__PURE__ */ jsx15(
3147
+ ColumnFormattingPanel,
3148
+ {
3149
+ availableRenderers,
3150
+ column,
3151
+ onChangeFormatting,
3152
+ onChangeRendering,
3153
+ onChangeColumnType: onChangeType
3154
+ }
3155
+ ),
3156
+ editCalculatedColumn ? /* @__PURE__ */ jsxs12("div", { className: "vuuColumnSettingsPanel-buttonBar", "data-align": "right", children: [
3157
+ /* @__PURE__ */ jsx15(
3158
+ Button,
3159
+ {
3160
+ className: `${classBase13}-buttonCancel`,
3161
+ onClick: onCancel,
3162
+ tabIndex: -1,
3163
+ children: "cancel"
3164
+ }
3165
+ ),
3166
+ /* @__PURE__ */ jsx15(
3167
+ Button,
3168
+ {
3169
+ className: `${classBase13}-buttonSave`,
3170
+ onClick: onSave,
3171
+ variant: "cta",
3172
+ children: "save"
3173
+ }
3174
+ )
3175
+ ] }) : /* @__PURE__ */ jsxs12(
3176
+ "div",
3177
+ {
3178
+ className: `${classBase13}-buttonBar`,
3179
+ "data-align": isNewCalculatedColumn ? "right" : void 0,
3180
+ children: [
3181
+ /* @__PURE__ */ jsx15(
3182
+ Button,
3183
+ {
3184
+ className: `${classBase13}-buttonNavPrev`,
3185
+ variant: "secondary",
3186
+ "data-icon": "arrow-left",
3187
+ onClick: navigatePrevColumn,
3188
+ children: "PREVIOUS"
3189
+ }
3190
+ ),
3191
+ /* @__PURE__ */ jsx15(
3192
+ Button,
3193
+ {
3194
+ className: `${classBase13}-buttonNavNext`,
3195
+ variant: "secondary",
3196
+ "data-icon": "arrow-right",
3197
+ onClick: navigateNextColumn,
3198
+ children: "NEXT"
3199
+ }
3200
+ )
3201
+ ]
3202
+ }
3203
+ )
3204
+ ]
3205
+ }
3206
+ );
3207
+ };
3208
+
3209
+ // src/datasource-stats/DatasourceStats.tsx
3210
+ import cx8 from "clsx";
3211
+ import { useEffect as useEffect4, useState as useState6 } from "react";
3212
+ import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
3213
+ var classBase14 = "vuuDatasourceStats";
3214
+ var numberFormatter = new Intl.NumberFormat();
3215
+ var DataSourceStats = ({
3216
+ className: classNameProp,
3217
+ dataSource
3218
+ }) => {
3219
+ const [range, setRange] = useState6(dataSource.range);
3220
+ const [size, setSize] = useState6(dataSource.size);
3221
+ useEffect4(() => {
3222
+ setSize(dataSource.size);
3223
+ dataSource.on("resize", setSize);
3224
+ dataSource.on("range", setRange);
3225
+ return () => {
3226
+ dataSource.removeListener("resize", setSize);
3227
+ dataSource.removeListener("range", setRange);
3228
+ };
3229
+ }, [dataSource]);
3230
+ const className = cx8(classBase14, classNameProp);
3231
+ const from = numberFormatter.format(range.from + 1);
3232
+ const to = numberFormatter.format(Math.min(range.to, size));
3233
+ const value = numberFormatter.format(size);
3234
+ return /* @__PURE__ */ jsxs13("div", { className, children: [
3235
+ /* @__PURE__ */ jsx16("span", { className: `${classBase14}-label`, children: "Row count" }),
3236
+ /* @__PURE__ */ jsx16("span", { className: `${classBase14}-range`, children: from }),
3237
+ /* @__PURE__ */ jsx16("span", { children: "-" }),
3238
+ /* @__PURE__ */ jsx16("span", { className: `${classBase14}-range`, children: to }),
3239
+ /* @__PURE__ */ jsx16("span", { children: "of" }),
3240
+ /* @__PURE__ */ jsx16("span", { className: `${classBase14}-size`, children: value })
3241
+ ] });
3242
+ };
3243
+
3244
+ // src/table-settings/TableSettingsPanel.tsx
3245
+ import {
3246
+ Button as Button2,
3247
+ FormField as FormField8,
3248
+ FormFieldLabel as FormFieldLabel8,
3249
+ ToggleButton as ToggleButton4,
3250
+ ToggleButtonGroup as ToggleButtonGroup4
3251
+ } from "@salt-ds/core";
3252
+
3253
+ // src/table-settings/useTableSettings.ts
3254
+ import { updateTableConfig } from "@vuu-ui/vuu-table";
3255
+ import {
3256
+ addColumnToSubscribedColumns,
3257
+ queryClosest as queryClosest3,
3258
+ isCalculatedColumn as isCalculatedColumn3,
3259
+ moveItem,
3260
+ subscribedOnly,
3261
+ useLayoutEffectSkipFirst
3262
+ } from "@vuu-ui/vuu-utils";
3263
+ import {
3264
+ useCallback as useCallback14,
3265
+ useMemo as useMemo6,
3266
+ useState as useState7
3267
+ } from "react";
3268
+ var sortOrderFromAvailableColumns = (availableColumns, columns) => {
3269
+ const sortedColumns = [];
3270
+ for (const { name: name2 } of availableColumns) {
3271
+ const column = columns.find((col) => col.name === name2);
3272
+ if (column) {
3273
+ sortedColumns.push(column);
3274
+ }
3275
+ }
3276
+ return sortedColumns;
3277
+ };
3278
+ var buildColumnItems = (availableColumns, configuredColumns) => {
3279
+ return availableColumns.map(({ name: name2, serverDataType }) => {
3280
+ const configuredColumn = configuredColumns.find((col) => col.name === name2);
3281
+ return {
3282
+ hidden: configuredColumn == null ? void 0 : configuredColumn.hidden,
3283
+ isCalculated: isCalculatedColumn3(name2),
3284
+ label: configuredColumn == null ? void 0 : configuredColumn.label,
3285
+ name: name2,
3286
+ serverDataType,
3287
+ subscribed: configuredColumn !== void 0
3288
+ };
3289
+ });
3290
+ };
3291
+ var useTableSettings = ({
3292
+ availableColumns: availableColumnsProp,
3293
+ onConfigChange,
3294
+ onDataSourceConfigChange,
3295
+ tableConfig: tableConfigProp
3296
+ }) => {
3297
+ const [{ availableColumns, tableConfig }, setColumnState] = useState7({
3298
+ availableColumns: availableColumnsProp,
3299
+ tableConfig: tableConfigProp
3300
+ });
3301
+ const columnItems = useMemo6(
3302
+ () => buildColumnItems(availableColumns, tableConfig.columns),
3303
+ [availableColumns, tableConfig.columns]
3304
+ );
3305
+ const handleMoveListItem = useCallback14(
3306
+ (fromIndex, toIndex) => {
3307
+ setColumnState((state) => {
3308
+ const newAvailableColumns = moveItem(
3309
+ state.availableColumns,
3310
+ fromIndex,
3311
+ toIndex
3312
+ );
3313
+ const newColumns = sortOrderFromAvailableColumns(
3314
+ newAvailableColumns,
3315
+ tableConfig.columns
3316
+ );
3317
+ return {
3318
+ availableColumns: newAvailableColumns,
3319
+ tableConfig: {
3320
+ ...state.tableConfig,
3321
+ columns: newColumns
3322
+ }
3323
+ };
3324
+ });
3325
+ },
3326
+ [tableConfig.columns]
3327
+ );
3328
+ const handleColumnChange = useCallback14(
3329
+ (name2, property, value) => {
3330
+ const columnItem = columnItems.find((col) => col.name === name2);
3331
+ if (property === "subscribed") {
3332
+ if (columnItem == null ? void 0 : columnItem.subscribed) {
3333
+ const subscribedColumns = tableConfig.columns.filter((col) => col.name !== name2).map((col) => col.name);
3334
+ setColumnState((state) => ({
3335
+ ...state,
3336
+ tableConfig: {
3337
+ ...tableConfig,
3338
+ columns: tableConfig.columns.filter(
3339
+ subscribedOnly(subscribedColumns)
3340
+ )
3341
+ }
3342
+ }));
3343
+ onDataSourceConfigChange({
3344
+ columns: subscribedColumns
3345
+ });
3346
+ } else {
3347
+ const newConfig = {
3348
+ ...tableConfig,
3349
+ columns: addColumnToSubscribedColumns(
3350
+ tableConfig.columns,
3351
+ availableColumns,
3352
+ name2
3353
+ )
3354
+ };
3355
+ setColumnState((state) => ({
3356
+ ...state,
3357
+ tableConfig: newConfig
3358
+ }));
3359
+ const subscribedColumns = newConfig.columns.map((col) => col.name);
3360
+ onDataSourceConfigChange({
3361
+ columns: subscribedColumns
3362
+ });
3363
+ }
3364
+ } else if (columnItem == null ? void 0 : columnItem.subscribed) {
3365
+ const column = tableConfig.columns.find((col) => col.name === name2);
3366
+ if (column) {
3367
+ const newConfig = updateTableConfig(tableConfig, {
3368
+ type: "column-prop",
3369
+ property,
3370
+ column,
3371
+ value
3372
+ });
3373
+ setColumnState((state) => ({
3374
+ ...state,
3375
+ tableConfig: newConfig
3376
+ }));
3377
+ }
3378
+ }
3379
+ },
3380
+ [availableColumns, columnItems, onDataSourceConfigChange, tableConfig]
3381
+ );
3382
+ const handleChangeColumnLabels = useCallback14((evt) => {
3383
+ const button = queryClosest3(evt.target, "button");
3384
+ if (button) {
3385
+ const value = parseInt(button.value);
3386
+ const columnFormatHeader = value === 0 ? void 0 : value === 1 ? "capitalize" : "uppercase";
3387
+ setColumnState((state) => ({
3388
+ ...state,
3389
+ tableConfig: {
3390
+ ...state.tableConfig,
3391
+ columnFormatHeader
3392
+ }
3393
+ }));
3394
+ }
3395
+ }, []);
3396
+ const handleChangeTableAttribute = useCallback14(
3397
+ (evt) => {
3398
+ const button = queryClosest3(evt.target, "button");
3399
+ const { ariaPressed, value } = button;
3400
+ console.log({ ariaPressed, value, button });
3401
+ setColumnState((state) => ({
3402
+ ...state,
3403
+ tableConfig: {
3404
+ ...state.tableConfig,
3405
+ [value]: ariaPressed !== "true"
3406
+ }
3407
+ }));
3408
+ },
3409
+ []
3410
+ );
3411
+ const handleCommitColumnWidth = useCallback14((_, value) => {
3412
+ const columnDefaultWidth = parseInt(value);
3413
+ if (!isNaN(columnDefaultWidth)) {
3414
+ setColumnState((state) => ({
3415
+ ...state,
3416
+ tableConfig: {
3417
+ ...state.tableConfig,
3418
+ columnDefaultWidth
3419
+ }
3420
+ }));
3421
+ }
3422
+ console.log({ value });
3423
+ }, []);
3424
+ useLayoutEffectSkipFirst(() => {
3425
+ onConfigChange == null ? void 0 : onConfigChange(tableConfig);
3426
+ }, [onConfigChange, tableConfig]);
3427
+ const columnLabelsValue = tableConfig.columnFormatHeader === void 0 ? 0 : tableConfig.columnFormatHeader === "capitalize" ? 1 : 2;
3428
+ return {
3429
+ columnItems,
3430
+ columnLabelsValue,
3431
+ onChangeColumnLabels: handleChangeColumnLabels,
3432
+ onChangeTableAttribute: handleChangeTableAttribute,
3433
+ onColumnChange: handleColumnChange,
3434
+ onCommitColumnWidth: handleCommitColumnWidth,
3435
+ onMoveListItem: handleMoveListItem,
3436
+ tableConfig
3437
+ };
3438
+ };
3439
+
3440
+ // src/table-settings/TableSettingsPanel.tsx
3441
+ import { Icon as Icon3 } from "@vuu-ui/vuu-ui-controls";
3442
+ import { VuuInput as VuuInput2 } from "@vuu-ui/vuu-ui-controls";
3443
+ import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
3444
+ var classBase15 = "vuuTableSettingsPanel";
3445
+ var TableSettingsPanel = ({
3446
+ allowColumnLabelCase = true,
3447
+ allowColumnDefaultWidth = true,
3448
+ allowGridRowStyling = true,
3449
+ availableColumns,
3450
+ onAddCalculatedColumn,
3451
+ onConfigChange,
3452
+ onDataSourceConfigChange,
3453
+ onNavigateToColumn,
3454
+ tableConfig: tableConfigProp
3455
+ }) => {
3456
+ var _a, _b, _c;
3457
+ const {
3458
+ columnItems,
3459
+ columnLabelsValue,
3460
+ onChangeColumnLabels,
3461
+ onChangeTableAttribute,
3462
+ onColumnChange,
3463
+ onCommitColumnWidth,
3464
+ onMoveListItem,
3465
+ tableConfig
3466
+ } = useTableSettings({
3467
+ availableColumns,
3468
+ onConfigChange,
3469
+ onDataSourceConfigChange,
3470
+ tableConfig: tableConfigProp
3471
+ });
3472
+ return /* @__PURE__ */ jsxs14("div", { className: classBase15, children: [
3473
+ allowColumnLabelCase || allowColumnDefaultWidth || allowGridRowStyling ? /* @__PURE__ */ jsx17("div", { className: `${classBase15}-header`, children: /* @__PURE__ */ jsx17("span", { children: "Column Settings" }) }) : null,
3474
+ allowColumnLabelCase ? /* @__PURE__ */ jsxs14(FormField8, { children: [
3475
+ /* @__PURE__ */ jsx17(FormFieldLabel8, { children: "Column Labels" }),
3476
+ /* @__PURE__ */ jsxs14(
3477
+ ToggleButtonGroup4,
3478
+ {
3479
+ className: "vuuToggleButtonGroup",
3480
+ onChange: onChangeColumnLabels,
3481
+ value: columnLabelsValue,
3482
+ children: [
3483
+ /* @__PURE__ */ jsx17(ToggleButton4, { className: "vuuIconToggleButton", value: 0, children: /* @__PURE__ */ jsx17(Icon3, { name: "text-strikethrough", size: 48 }) }),
3484
+ /* @__PURE__ */ jsx17(ToggleButton4, { className: "vuuIconToggleButton", value: 1, children: /* @__PURE__ */ jsx17(Icon3, { name: "text-Tt", size: 48 }) }),
3485
+ /* @__PURE__ */ jsx17(ToggleButton4, { className: "vuuIconToggleButton", value: 2, children: /* @__PURE__ */ jsx17(Icon3, { name: "text-T", size: 48 }) })
3486
+ ]
3487
+ }
3488
+ )
3489
+ ] }) : null,
3490
+ allowGridRowStyling ? /* @__PURE__ */ jsxs14(FormField8, { children: [
3491
+ /* @__PURE__ */ jsx17(FormFieldLabel8, { children: "Grid separators" }),
3492
+ /* @__PURE__ */ jsxs14("div", { className: "saltToggleButtonGroup vuuStateButtonGroup saltToggleButtonGroup-horizontal", children: [
3493
+ /* @__PURE__ */ jsx17(
3494
+ ToggleButton4,
3495
+ {
3496
+ selected: (_a = tableConfig.zebraStripes) != null ? _a : false,
3497
+ onChange: onChangeTableAttribute,
3498
+ value: "zebraStripes",
3499
+ children: /* @__PURE__ */ jsx17(Icon3, { name: "row-striping", size: 16 })
3500
+ }
3501
+ ),
3502
+ /* @__PURE__ */ jsx17(
3503
+ ToggleButton4,
3504
+ {
3505
+ selected: (_b = tableConfig.rowSeparators) != null ? _b : false,
3506
+ onChange: onChangeTableAttribute,
3507
+ value: "rowSeparators",
3508
+ children: /* @__PURE__ */ jsx17(Icon3, { name: "row-lines", size: 16 })
3509
+ }
3510
+ ),
3511
+ /* @__PURE__ */ jsx17(
3512
+ ToggleButton4,
3513
+ {
3514
+ selected: (_c = tableConfig.columnSeparators) != null ? _c : false,
3515
+ onChange: onChangeTableAttribute,
3516
+ value: "columnSeparators",
3517
+ children: /* @__PURE__ */ jsx17(Icon3, { name: "col-lines", size: 16 })
3518
+ }
3519
+ )
3520
+ ] })
3521
+ ] }) : null,
3522
+ allowColumnDefaultWidth ? /* @__PURE__ */ jsxs14(FormField8, { children: [
3523
+ /* @__PURE__ */ jsx17(FormFieldLabel8, { children: "Default Column Width" }),
3524
+ /* @__PURE__ */ jsx17(VuuInput2, { className: "vuuInput", onCommit: onCommitColumnWidth })
3525
+ ] }) : null,
3526
+ /* @__PURE__ */ jsx17(
3527
+ ColumnList,
3528
+ {
3529
+ columnItems,
3530
+ onChange: onColumnChange,
3531
+ onMoveListItem,
3532
+ onNavigateToColumn
3533
+ }
3534
+ ),
3535
+ /* @__PURE__ */ jsxs14("div", { className: `${classBase15}-calculatedButtonbar`, children: [
3536
+ /* @__PURE__ */ jsx17(Button2, { "data-icon": "plus", onClick: onAddCalculatedColumn }),
3537
+ /* @__PURE__ */ jsx17("span", { className: `${classBase15}-calculatedLabel`, children: "Add calculated column" })
3538
+ ] })
3539
+ ] });
3540
+ };
3541
+ export {
3542
+ BackgroundCell,
3543
+ BackgroundCellConfigurationEditor,
3544
+ BaseNumericFormattingSettings,
3545
+ CaseValidator,
3546
+ ColumnExpressionInput,
3547
+ ColumnExpressionPanel,
3548
+ ColumnFormattingPanel,
3549
+ ColumnList,
3550
+ ColumnNamedTerms,
3551
+ ColumnSettingsPanel,
3552
+ DataSourceStats,
3553
+ DateTimeFormattingSettings,
3554
+ DropdownCell,
3555
+ LookupCell,
3556
+ PatternValidator,
3557
+ PctProgressCell,
3558
+ TableSettingsPanel,
3559
+ columnExpressionLanguageSupport,
3560
+ isCompleteExpression,
3561
+ isCompleteRelationalExpression,
3562
+ lastNamedChild,
3563
+ useColumnExpressionEditor,
3564
+ useColumnExpressionSuggestionProvider,
3565
+ useTableSettings,
3566
+ walkTree
3567
+ };
2
3568
  //# sourceMappingURL=index.js.map