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