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