@vuu-ui/vuu-table-extras 0.8.31 → 0.8.32-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 +3463 -1
- package/cjs/index.js.map +2 -2
- package/esm/index.js +3580 -1
- package/esm/index.js.map +2 -2
- package/index.css +602 -1
- package/index.css.map +1 -1
- package/package.json +12 -12
- package/LICENSE +0 -201
package/cjs/index.js
CHANGED
|
@@ -1,2 +1,3464 @@
|
|
|
1
|
-
"use strict";var ln=Object.create;var it=Object.defineProperty;var un=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var cn=Object.getPrototypeOf,mn=Object.prototype.hasOwnProperty;var dn=(t,e)=>{for(var o in e)it(t,o,{get:e[o],enumerable:!0})},so=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of pn(e))!mn.call(t,s)&&s!==o&&it(t,s,{get:()=>e[s],enumerable:!(n=un(e,s))||n.enumerable});return t};var ue=(t,e,o)=>(o=t!=null?ln(cn(t)):{},so(e||!t||!t.__esModule?it(o,"default",{value:t,enumerable:!0}):o,t)),gn=t=>so(it({},"__esModule",{value:!0}),t);var io=(t,e,o)=>{if(!e.has(t))throw TypeError("Cannot "+o)};var f=(t,e,o)=>(io(t,e,"read from private field"),o?o.call(t):e.get(t)),U=(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)},pe=(t,e,o,n)=>(io(t,e,"write to private field"),n?n.call(t,o):e.set(t,o),o);var hr={};dn(hr,{BackgroundCell:()=>fo,BackgroundCellConfigurationEditor:()=>ho,BaseNumericFormattingSettings:()=>ot,CaseValidator:()=>lo,ColumnExpressionInput:()=>yt,ColumnExpressionPanel:()=>Kt,ColumnFormattingPanel:()=>oo,ColumnList:()=>Rt,ColumnNamedTerms:()=>xt,ColumnSettingsPanel:()=>gr,DataSourceStats:()=>fr,DateTimeFormattingSettings:()=>jt,DropdownCell:()=>bo,LookupCell:()=>Oo,PatternValidator:()=>po,PctProgressCell:()=>ko,TableSettingsPanel:()=>xr,columnExpressionLanguageSupport:()=>Nt,isCompleteExpression:()=>zt,isCompleteRelationalExpression:()=>Zt,lastNamedChild:()=>ht,useColumnExpressionEditor:()=>qt,useColumnExpressionSuggestionProvider:()=>Jt,useTableSettings:()=>ro,walkTree:()=>$t});module.exports=gn(hr);var ao=require("@vuu-ui/vuu-utils"),fn=t=>typeof t=="string",lo=(t,e)=>fn(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";(0,ao.registerComponent)("vuu-case",lo,"data-edit-validator",{});var uo=require("@vuu-ui/vuu-utils"),Cn=t=>typeof t=="string",vn="value does not match expected pattern",po=(t,e)=>{if(typeof t.value!="string")throw Error("Pattern validation rule must provide pattern");if(Cn(e)){if(e==="")return!0;{let{message:o=vn}=t;return new RegExp(t.value).test(e)||o}}else return"value must be a string"};(0,uo.registerComponent)("vuu-pattern",po,"data-edit-validator",{});var R=require("@vuu-ui/vuu-utils"),mo=ue(require("clsx"),1),go=require("react");var ve=require("@vuu-ui/vuu-utils"),at=require("react"),xn=[void 0,void 0,void 0,void 0];function co(t,e,o){var g;let n=(0,at.useRef)(),[s,r,a,l]=n.current||xn,{type:p}=o,m=(0,ve.isTypeDescriptor)(p)?(g=p.formatting)==null?void 0:g.decimals:void 0,d=t===s&&(0,ve.isValidNumber)(e)&&(0,ve.isValidNumber)(r)&&o===a?(0,ve.getMovingValueDirection)(e,l,r,m):"";return(0,at.useEffect)(()=>{n.current=[t,e,o,d]}),d}var lt=require("react/jsx-runtime"),hn="\u2B06",bn="\u2B07",{KEY:yn}=R.metadataKeys,Ue="vuuBackgroundCell",Te={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},En=t=>(0,R.isTypeDescriptor)(t)&&t.renderer&&"flashStyle"in t.renderer?t.renderer.flashStyle:Te.BackgroundOnly,fo=(0,go.memo)(function({column:e,columnMap:o,row:n}){let{name:s,type:r,valueFormatter:a}=e,l=o[s],p=n[l],m=En(r),d=co(n[yn],p,e),g=m===Te.ArrowOnly||m===Te.ArrowBackground?d===R.UP1||d===R.UP2?hn:d===R.DOWN1||d===R.DOWN2?bn:null:null,u=d?" "+d:"",i=(0,mo.default)(Ue,u,{[`${Ue}-backgroundOnly`]:m===Te.BackgroundOnly,[`${Ue}-arrowOnly`]:m===Te.ArrowOnly,[`${Ue}-arrowBackground`]:m===Te.ArrowBackground});return(0,lt.jsxs)("div",{className:i,tabIndex:-1,children:[(0,lt.jsx)("div",{className:`${Ue}-arrow`,children:g}),a(n[l])]})},R.dataAndColumnUnchanged);(0,R.registerComponent)("vuu.price-move-background",fo,"cell-renderer",{description:"Change background color of cell when value changes",configEditor:"BackgroundCellConfigurationEditor",label:"Background Flash",serverDataType:["long","int","double"]});var Co=require("@vuu-ui/vuu-ui-controls"),vo=require("@vuu-ui/vuu-utils"),ut=require("@salt-ds/core"),pt=require("react");var We=require("react/jsx-runtime"),wn="vuuBackgroundCellConfiguration",Bt=[{label:"Background Only",value:"bg-only"},{label:"Background and Arrow",value:"arrow-bg"},{label:"Arrow Only",value:"arrow"}],[xo]=Bt,On=t=>{let{flashStyle:e}=t.type.renderer;return Bt.find(o=>o.value===e)||xo},ho=({column:t,onChangeRendering:e})=>{let[o,n]=(0,pt.useState)(On(t)),s=(0,pt.useCallback)((r,a)=>{var p;n(a);let l=t.type.renderer;e({...l,flashStyle:(p=a==null?void 0:a.value)!=null?p:xo.value})},[t.type,e]);return(0,We.jsxs)(ut.FormField,{children:[(0,We.jsx)(ut.FormFieldLabel,{children:"Flash Style"}),(0,We.jsx)(Co.Dropdown,{className:`${wn}-flashStyle`,onSelectionChange:s,selected:o,source:Bt,width:"100%"})]})};(0,vo.registerConfigurationEditor)("BackgroundCellConfigurationEditor",ho);var ct=require("@vuu-ui/vuu-data-react"),mt=require("@vuu-ui/vuu-ui-controls"),ke=require("@vuu-ui/vuu-utils"),ce=require("react");var yo=require("react/jsx-runtime"),Sn="vuuTableDropdownCell",Tn=["Enter"," "],bo=(0,ce.memo)(function({column:e,columnMap:o,onCommit:n=mt.WarnCommit,row:s}){let r=o[e.name],a=s[r],{values:l}=(0,ct.useLookupValues)(e,a),p=(0,ce.useRef)(null);(0,ce.useMemo)(()=>{p.current=(0,ct.getSelectedOption)(l,a)},[a,l]);let m=(0,ce.useCallback)((d,g)=>{g&&n(g.value).then(u=>{u===!0&&d&&(0,ke.dispatchCustomEvent)(d.target,"vuu-commit")})},[n]);return(0,yo.jsx)(mt.Dropdown,{className:Sn,onSelectionChange:m,openKeys:Tn,selected:p.current,source:l,width:e.width-17})},ke.dataColumnAndKeyUnchanged);(0,ke.registerComponent)("dropdown-cell",bo,"cell-renderer",{userCanAssign:!1});var Eo=require("@vuu-ui/vuu-data-react"),dt=require("@vuu-ui/vuu-utils"),wo=require("react"),So=require("react/jsx-runtime"),Oo=(0,wo.memo)(function({column:e,columnMap:o,row:n}){let s=o[e.name],r=n[s],{initialValue:a}=(0,Eo.useLookupValues)(e,r);return(0,So.jsx)("span",{children:a==null?void 0:a.label})},dt.dataAndColumnUnchanged);(0,dt.registerComponent)("lookup-cell",Oo,"cell-renderer",{userCanAssign:!1});var To=require("@vuu-ui/vuu-utils"),Lt=ue(require("clsx"),1);var Ge=require("react/jsx-runtime"),Ye="vuuPctProgressCell",kn=t=>t>=0&&t<=1?t*100:t>2?0:t>1?100:0,ko=({column:t,columnMap:e,row:o})=>{let n=o[e[t.name]],s=kn(n),r=(0,Lt.default)(Ye,{});return(0,Ge.jsxs)("div",{className:(0,Lt.default)(r,{[`${Ye}-zero`]:s===0,[`${Ye}-complete`]:s>=100}),tabIndex:-1,children:[(0,Ge.jsx)("span",{className:`${Ye}-progressBar`,style:{"--progress-bar-pct":`${s}%`}}),(0,Ge.jsx)("span",{className:`${Ye}-text`,children:`${s.toFixed(2)} %`})]})};(0,To.registerComponent)("vuu.pct-progress",ko,"cell-renderer",{description:"Percentage formatter",label:"Percentage formatter",serverDataType:"double"});var re=require("@vuu-ui/vuu-utils"),Po=ue(require("clsx"),1);var xe=require("react/jsx-runtime"),qe="vuuProgressCell",Pn=({column:t,columnMap:e,row:o})=>{let{name:n,type:s}=t,r=o[e[n]],a=!1,l=0;if((0,re.isTypeDescriptor)(s)&&(0,re.isColumnTypeRenderer)(s.renderer)){let{associatedField:m}=s.renderer;if(m){let d=o[e[m]];if((0,re.isValidNumber)(r)&&(0,re.isValidNumber)(d))l=Math.min(Math.round(r/d*100),100),l=Math.min(Math.round(r/d*100),100),a=isFinite(l);else{let g=parseFloat(r);if(Number.isFinite(g)){let u=parseFloat(d);Number.isFinite(u)&&(l=Math.min(Math.round(g/u*100),100),a=isFinite(l))}}}else throw Error("ProgressCell associatedField is required to render")}let p=(0,Po.default)(qe,{});return(0,xe.jsxs)("div",{className:p,tabIndex:-1,children:[a?(0,xe.jsxs)("span",{className:`${qe}-track`,children:[(0,xe.jsx)("span",{className:`${qe}-bg`}),(0,xe.jsx)("span",{className:`${qe}-bar`,style:{"--progress-bar-pct":`-${100-l}%`}})]}):null,(0,xe.jsx)("span",{className:`${qe}-text`,children:`${l} %`})]})};(0,re.registerComponent)("vuu.progress",Pn,"cell-renderer",{description:"Progress formatter",label:"Progress formatter",serverDataType:["long","int","double"],userCanAssign:!1});var he=require("@vuu-ui/vuu-ui-controls"),gt=require("@salt-ds/core"),Fo=ue(require("clsx"),1),Dt=require("react"),Pe=require("@vuu-ui/vuu-utils");var H=require("react/jsx-runtime"),me="vuuColumnList",Bo="vuuColumnListItem",Fn=({className:t,item:e,...o})=>(0,H.jsxs)(he.ListItem,{...o,className:(0,Fo.default)(t,Bo),"data-name":e==null?void 0:e.name,children:[(0,H.jsx)(he.Icon,{name:"draggable",size:16}),e!=null&&e.isCalculated?(0,H.jsx)(he.Icon,{name:"function"}):(0,H.jsx)(gt.Checkbox,{className:`${me}-checkBox`,checked:e==null?void 0:e.subscribed}),(0,H.jsx)("span",{className:`${me}-text`,children:(0,Pe.getColumnLabel)(e)}),(0,H.jsx)(gt.Switch,{className:`${me}-switch`,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=(0,Dt.useCallback)(({target:l})=>{let p=l,m=(0,Pe.queryClosest)(l,`.${Bo}`);if(m){let{dataset:{name:d}}=m;if(d){let g=(0,Pe.queryClosest)(l,`.${me}-checkBox`),u=(0,Pe.queryClosest)(l,`.${me}-switch`);g?e(d,"subscribed",p.checked):u&&e(d,"hidden",p.checked===!1)}}},[e]),a=(0,Dt.useCallback)(l=>{let p=l.target;if(p.classList.contains("vuuColumnList-text")){let m=p.closest(".vuuListItem");m!=null&&m.dataset.name&&(n==null||n(m.dataset.name))}},[]);return(0,H.jsxs)("div",{...s,className:me,children:[(0,H.jsx)("div",{className:`${me}-header`,children:(0,H.jsx)("span",{children:"Column Selection"})}),(0,H.jsxs)("div",{className:`${me}-colHeadings`,children:[(0,H.jsx)("span",{children:"Column subscription"}),(0,H.jsx)("span",{children:"Visibility"})]}),(0,H.jsx)(he.List,{ListItem:Fn,allowDragDrop:!0,height:"auto",onChange:r,onClick:a,onMoveListItem:o,selectionStrategy:"none",source:t,itemHeight:33})]})};var oe=require("@vuu-ui/vuu-ui-controls"),Ze=require("@vuu-ui/vuu-utils"),O=require("@salt-ds/core"),nn=ue(require("clsx"),1);var Wo=require("@vuu-ui/vuu-ui-controls"),Me=require("@vuu-ui/vuu-utils"),K=require("@salt-ds/core"),tt=require("react");var Ao=require("react");var P=require("@vuu-ui/vuu-codemirror"),Gt=require("@vuu-ui/vuu-utils"),G=require("react");var M=require("@vuu-ui/vuu-codemirror");var Lo=require("@lezer/lr"),ft=Lo.LRParser.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 Bn=M.LRLanguage.define({name:"VuuColumnExpression",parser:ft.configure({props:[(0,M.styleTags)({Column:M.tags.attributeValue,Function:M.tags.variableName,String:M.tags.string,Or:M.tags.emphasis,Operator:M.tags.operator})]})}),Nt=()=>new M.LanguageSupport(Bn);var Ht=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}}},Vt=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},Je,ye,Qt=class{constructor(e="unknown"){U(this,Je,[{type:"unknown"},{type:"unknown"}]);U(this,ye,void 0);this.type="arithmeticExpression";pe(this,ye,e)}get op(){return f(this,ye)}set op(e){pe(this,ye,e)}get expressions(){return f(this,Je)}toJSON(){return{type:this.type,op:f(this,ye),expressions:f(this,Je)}}};Je=new WeakMap,ye=new WeakMap;var De,It=class{constructor(e){U(this,De,[]);this.type="callExpression";this.functionName=e}get expressions(){return f(this,De)}get arguments(){return f(this,De)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:f(this,De).map(e=>{var o;return(o=e.toJSON)==null?void 0:o.call(e)})}}};De=new WeakMap;var Ke,Re,Be=class{constructor(){U(this,Ke,[{type:"unknown"},{type:"unknown"}]);U(this,Re,"unknown");this.type="relationalExpression"}get op(){return f(this,Re)}set op(e){pe(this,Re,e)}get expressions(){return f(this,Ke)}toJSON(){return{type:this.type,op:f(this,Re),expressions:f(this,Ke)}}};Ke=new WeakMap,Re=new WeakMap;var je,Ne,Le=class{constructor(e){U(this,je,[{type:"unknown"},{type:"unknown"}]);U(this,Ne,void 0);this.type="booleanCondition";pe(this,Ne,e)}get op(){return f(this,Ne)}get expressions(){return f(this,je)}toJSON(){return{type:this.type,op:f(this,Ne),expressions:f(this,je).map(e=>{var o;return(o=e.toJSON)==null?void 0:o.call(e)})}}};je=new WeakMap,Ne=new WeakMap;var Y,_e=class{constructor(e){U(this,Y,void 0);this.type="conditionalExpression";pe(this,Y,[e?new Le(e):new Be,{type:"unknown"},{type:"unknown"}])}get expressions(){return f(this,Y)}get condition(){return f(this,Y)[0]}get truthyExpression(){return f(this,Y)[1]}set truthyExpression(e){f(this,Y)[1]=e}get falsyExpression(){return f(this,Y)[2]}set falsyExpression(e){f(this,Y)[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}}};Y=new WeakMap;var be=t=>t.type==="unknown",Ct=t=>t.type==="arithmeticExpression",Ln=t=>t.type==="callExpression",Fe=t=>t.type==="conditionalExpression",Dn=t=>t.type==="relationalExpression"||t.type==="booleanCondition";var Rn=t=>t.type==="booleanCondition",At=t=>(t==null?void 0:t.type)==="relationalExpression";var A=t=>{if(be(t))return t;if(At(t)){let[e,o]=t.expressions;if(N(e))return A(e);if(t.op==="unknown")return t;if(N(o))return A(o)}else if(Dn(t)){let{expressions:e=[]}=t;for(let o of e)if(N(o))return A(o)}else if(Fe(t)){let{condition:e,truthyExpression:o,falsyExpression:n}=t;if(N(e))return A(e);if(N(o))return A(o);if(N(n))return A(n)}else if(Ct(t)){let{expressions:e=[]}=t;for(let o of e)if(N(o))return A(o)}},vt=(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(vt(s,e,o))return!0;return!1},N=t=>be(t)?!0:Fe(t)?N(t.condition)||N(t.truthyExpression)||N(t.falsyExpression):At(t)||Rn(t)?t.op===void 0||t.expressions.some(e=>N(e)):!1,Do=(t,e)=>{let o=A(t);o?o.expressions?o.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},y,Ee,Mt=class{constructor(){U(this,y,void 0);U(this,Ee,[])}setCondition(e){if(f(this,y)===void 0)this.addExpression(new _e(e));else if(Fe(f(this,y))){if(N(f(this,y).condition)){let o=e?new Le(e):new Be;this.addExpression(o)}else if(be(f(this,y).truthyExpression))f(this,y).truthyExpression=new _e(e);else if(N(f(this,y).truthyExpression)){let o=e?new Le(e):new Be;this.addExpression(o)}else if(be(f(this,y).falsyExpression))f(this,y).falsyExpression=new _e(e);else if(N(f(this,y).falsyExpression)){let o=e?new Le(e):new Be;this.addExpression(o)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(f(this,Ee).length>0){let o=f(this,Ee).at(-1);o==null||o.arguments.push(e)}else if(f(this,y)===void 0)pe(this,y,e);else if(Ct(f(this,y))){let o=A(f(this,y));o&&be(o)&&vt(f(this,y),o,e)}else if(Fe(f(this,y))&&N(f(this,y))){let o=A(f(this,y));o&&be(o)?vt(f(this,y),o,e):o&&Do(o,e)}}setFunction(e){let o=new It(e);this.addExpression(o),f(this,Ee).push(o)}setColumn(e){this.addExpression(new Vt(e))}setArithmeticOp(e){let o=e,n=f(this,y);Ct(n)&&(n.op=o)}setRelationalOperator(e){let o=e;if(f(this,y)&&Fe(f(this,y))){let n=A(f(this,y));At(n)?n.op=o:console.error(`no target expression found (op = ${e})`)}}setValue(e){let o=new Ht(e);if(f(this,y)===void 0)pe(this,y,o);else if(Ct(f(this,y)))this.addExpression(o);else if(Ln(f(this,y)))f(this,y).arguments.push(o);else if(Fe(f(this,y)))if(N(f(this,y))){let n=A(f(this,y));n&&be(n)?vt(f(this,y),n,o):n&&Do(n,o)}else console.log("what do we do with value, in a complete expression")}closeBrace(){f(this,Ee).pop()}get expression(){return f(this,y)}toJSON(){var e;return(e=f(this,y))==null?void 0:e.toJSON()}};y=new WeakMap,Ee=new WeakMap;var $t=(t,e)=>{let o=new Mt,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 Qt);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 Nn=ft.configure({strict:!0}),Ro=["Number","String"],xt=[...Ro,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],zt=t=>{try{return Nn.parse(t),!0}catch{return!1}},ht=t=>{let{lastChild:e}=t;for(;e&&!xt.includes(e.name);)e=e.prevSibling,console.log(e==null?void 0:e.name);return e},Zt=t=>{if((t==null?void 0:t.name)==="RelationalExpression"){let{firstChild:e}=t,o=ht(t);if((e==null?void 0:e.name)==="Column"&&typeof(o==null?void 0:o.name)=="string"&&Ro.includes(o.name))return!0}return!1};var de=require("@vuu-ui/vuu-codemirror"),Hn=de.HighlightStyle.define([{tag:de.tags.attributeValue,color:"var(--vuuFilterEditor-variableColor);font-weight: bold"},{tag:de.tags.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:de.tags.comment,color:"green",fontStyle:"italic"}]),No=(0,de.syntaxHighlighting)(Hn);var Ho=require("@vuu-ui/vuu-codemirror"),Vo=Ho.EditorView.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});var F=require("@vuu-ui/vuu-codemirror"),Wt=require("react");var Vn=(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,Qn=t=>t===void 0?!1:["Times","Divide","Plus","Minus"].includes(t.name),et=t=>({apply:()=>{t==null||t()},label:"Done",boost:10}),He=(t,e)=>{var s;let{lastChild:o}=t,{pos:n}=e;for(;o;)if(o.from<n&&xt.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},Qo=(t,e)=>{var o;if(t.name==="ArgList"){let n=t.prevSibling;if(n)return(0,F.getValue)(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(0,F.getValue)(n,e)}},Io=(t,e)=>{if(t.name==="RelationalExpression"){let o=ht(t);if((o==null?void 0:o.name)==="RelationalOperator")return(0,F.getValue)(o,e)}else{let o=t.prevSibling;if((o==null?void 0:o.name)==="RelationalOperator")return(0,F.getValue)(o,e)}},Yt=(t,e)=>{var o;if(t.name==="RelationalExpression"){if(((o=t.firstChild)==null?void 0:o.name)==="Column")return(0,F.getValue)(t.firstChild,e)}else{let n=t.prevSibling;if((n==null?void 0:n.name)==="Column")return(0,F.getValue)(n,e);if((n==null?void 0:n.name)==="RelationalOperator")return Yt(n,e)}},Xt=async(t,e,o,n={})=>{let s=await e.getSuggestions(o,n),{startsWith:r=""}=n;return{from:t.pos-r.length,options:s}},Ut=(t,e,o,n,s)=>{let r=He(t,e);switch(r==null?void 0:r.name){case"If":return Xt(e,o,"expression",{prefix:"( "});case"OpenBrace":return Xt(e,o,"expression");case"Condition":return Xt(e,o,"expression",{prefix:", "});case"CloseBrace":if(n){let a=[et(s)];return{from:e.pos,options:a}}}},In=(t,e)=>{let o=[et(e)];return{from:t.pos,options:o}},Mo=(t,e)=>{let o=(0,Wt.useCallback)(async(n,s,r={})=>{let a=await t.getSuggestions(s,r),{startsWith:l=""}=r;return{from:n.pos-l.length,options:a}},[t]);return(0,Wt.useCallback)(async n=>{var g,u;let{state:s,pos:r}=n,a=(g=n.matchBefore(/\w*/))!=null?g:{from:0,to:0,text:void 0},p=(0,F.syntaxTree)(s).resolveInner(r,-1),m=s.doc.toString(),d=zt(m);switch(p.name){case"If":return o(n,"expression",{prefix:"( "});case"Condition":{let i=He(p,n);if((i==null?void 0:i.name)==="Column"){let c=(0,F.getPreviousNode)(i);if((c==null?void 0:c.name)!=="RelationalOperator")return o(n,"condition-operator",{columnName:(0,F.getValue)(i,s)})}else if((i==null?void 0:i.name)==="RelationalOperator")return o(n,"expression")}break;case"ConditionalExpression":return Ut(p,n,t);case"RelationalExpression":{if(Zt(p))return{from:n.pos,options:F.booleanJoinSuggestions.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let i=Io(p,s),c=Yt(p,s);if(i)return o(n,"expression");{let C=await t.getSuggestions("condition-operator",{columnName:c});return{from:n.pos,options:C}}}}break;case"RelationalOperator":return o(n,"expression");case"String":{let i=Io(p,s),c=Yt(p,s),{from:C,to:v}=p;if(v-C===2&&n.pos===C+1){if(c&&i)return o(n,"columnValue",{columnName:c,operator:i,startsWith:a.text})}else if(v-C>2&&n.pos===v)return o(n,"expression",{prefix:", "})}break;case"ArithmeticExpression":{let i=He(p,n);if((i==null?void 0:i.name)==="Column")return o(n,"expression");if(Qn(i)){let c=i.name;return o(n,"column",{operator:c})}}break;case"OpenBrace":{let i=Qo(p,s);return o(n,"expression",{functionName:i})}break;case"ArgList":{let i=Qo(p,s),c=He(p,n),C=(c==null?void 0:c.name)==="OpenBrace"||(c==null?void 0:c.name)==="Comma"?void 0:",",v=await t.getSuggestions("expression",{functionName:i});return v=C?Vn(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=He(p,n);if((i==null?void 0:i.name)==="Column"){if(d){let c=[et(e.current)],C=(0,F.getValue)(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:[et(e.current)]}}else if((i==null?void 0:i.name)==="ArithmeticExpression"){if(d){let c=[et(e.current)],C=He(i,n);if((C==null?void 0:C.name)==="Column"){let v=(0,F.getValue)(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 Ut(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=(0,F.getNamedParentNode)(p);if((i==null?void 0:i.name)==="ConditionalExpression")return o(n,"expression")}break;case"CloseBrace":{let i=(0,F.getNamedParentNode)(p);if((i==null?void 0:i.name)==="ConditionalExpression")return Ut(i,n,t,d,e.current);if((i==null?void 0:i.name)==="ArgList"&&d)return In(n,e.current)}break;default:((u=p==null?void 0:p.prevSibling)==null?void 0:u.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[o,e,t])};var bt=t=>{if(t.current==null)throw Error("EditorView not defined");return t.current},Mn=()=>"vuuSuggestion",An=()=>console.log("noooop"),$n=t=>"expressionType"in t,zn=t=>{if($n(t)){let e=(0,Gt.createEl)("div","expression-type-container"),o=(0,Gt.createEl)("span","expression-type",t.expressionType);return e.appendChild(o),e}else return null},qt=({onChange:t,onSubmitExpression:e,source:o,suggestionProvider:n})=>{let s=(0,G.useRef)(null),r=(0,G.useRef)(An),a=(0,G.useRef)(),l=Mo(n,r),[p,m,d]=(0,G.useMemo)(()=>{let u=()=>{let x=bt(a),h=x.state.doc.toString(),w=(0,P.ensureSyntaxTree)(x.state,x.state.doc.length,5e3);if(w){let D=$t(w,h);return[h,D]}else return["",void 0]},i=()=>{bt(a).setState(v())},c=()=>{let[x,h]=u();e==null||e(x,h)},C=x=>P.keymap.of([{key:x,run(){return(0,P.startCompletion)(bt(a)),!0}}]),v=()=>P.EditorState.create({doc:o,extensions:[P.minimalSetup,(0,P.autocompletion)({addToOptions:[{render:zn,position:70}],override:[l],optionClass:Mn}),Nt(),P.keymap.of(P.defaultKeymap),C("ArrowDown"),P.EditorView.updateListener.of(x=>{let h=bt(a);if(x.docChanged){(0,P.startCompletion)(h);let w=h.state.doc.toString();t==null||t(w)}}),P.EditorState.transactionFilter.of(x=>x.newDoc.lines>1?[]:x),Vo,No]});return r.current=()=>{c()},[v,i,c]},[l,t,e,o]);(0,G.useEffect)(()=>{if(!s.current)throw Error("editor not in dom");return a.current=new P.EditorView({state:p(),parent:s.current}),()=>{var u;(u=a.current)==null||u.destroy()}},[l,p]);let g=(0,G.useCallback)(()=>{d()},[d]);return{editorRef:s,clearInput:m,onBlur:g}};var $o=require("react/jsx-runtime"),Zn="vuuColumnExpressionInput",yt=(0,Ao.memo)(({onChange:t,onSubmitExpression:e,source:o="",suggestionProvider:n})=>{let{editorRef:s,onBlur:r}=qt({onChange:t,onSubmitExpression:e,source:o,suggestionProvider:n});return(0,$o.jsx)("div",{className:`${Zn}`,onBlur:r,ref:s})},(t,e)=>t.source===e.source);yt.displayName="ColumnExpressionInput";var _=require("@vuu-ui/vuu-codemirror"),Et=require("@vuu-ui/vuu-data-react"),Ie=require("@vuu-ui/vuu-utils"),Qe=require("react");var Ve=[{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"}];var q=require("@vuu-ui/vuu-utils"),zo=({name:t,description:e,example:o,params:n,type:s})=>{let r=(0,q.createEl)("div","vuuFunctionDoc"),a=(0,q.createEl)("div","function-heading"),l=(0,q.createEl)("span","function-name",t),p=(0,q.createEl)("span","param-list",n.description),m=(0,q.createEl)("span","function-type",s);a.appendChild(l),a.appendChild(p),a.appendChild(m);let d=(0,q.createEl)("p",void 0,e);if(r.appendChild(a),r.appendChild(d),o){let g=(0,q.createEl)("div","example-container"),u=(0,q.createEl)("div","example-expression",o.expression),i=(0,q.createEl)("div","example-result",o.result);g.appendChild(u),r.appendChild(g),r.appendChild(i)}return r};var Xn=[],we=t=>t.map(e=>{var o;return{...e,apply:((o=e.apply)!=null?o:e.label)+" "}}),Un=(t,{functionName:e,operator:o})=>{if(o)return t.filter(Ie.isNumericColumn);if(e){let n=Ve.find(s=>s.name===e);if(n)switch(n.accepts){case"string":return t.filter(Ie.isTextColumn);case"number":return t.filter(Ie.isNumericColumn);default:return t}}return t},Zo=(t,e)=>Un(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}}),Wn=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],Yn=t=>t===void 0||(0,Ie.isNumericColumn)(t)?Wn:Xn,Gn=t=>{switch(t.serverDataType){case"string":case"char":return we(_.stringOperators);case"int":case"long":case"double":return we(_.numericOperators)}},_t=t=>({apply:`${t.name}( `,boost:2,expressionType:t.type,info:()=>zo(t),label:t.name,type:"function"}),qn=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"},_n=Ve.map(_t),Jn=({functionName:t})=>{if(t){let e=Ve.find(n=>n.name===t),o=qn(e);if(e)switch(o){case"string":return Ve.filter(n=>n.type==="string"||n.type==="variable").map(_t);case"number":return Ve.filter(n=>n.type==="number"||n.type==="variable").map(_t);default:}}return _n},Kn={},Jt=({columns:t,table:e})=>{let o=(0,Qe.useCallback)(l=>l?t.find(p=>p.name===l):void 0,[t]),n=(0,Qe.useRef)(),s=(0,Et.useTypeaheadSuggestions)(),r=(0,Qe.useCallback)(async(l,p=Kn)=>{let{columnName:m,functionName:d,operator:g,prefix:u}=p;switch(l){case"expression":{let i=await we(Zo(t,{functionName:d,prefix:u})).concat(Jn(p));return n.current=i}case"column":{let i=await Zo(t,p);return n.current=we(i)}case"operator":{let i=await Yn(o(m));return n.current=we(i)}case"relational-operator":{let i=await(0,_.getRelationalOperators)(o(m));return n.current=we(i)}case"condition-operator":{let i=o(m);if(i){let c=await Gn(i);if(c)return n.current=we(c)}}break;case"columnValue":if(m&&g){let i=(0,Et.getTypeaheadParams)(e,m),c=await s(i);return n.current=(0,_.toSuggestions)(c,{suffix:""}),n.current.forEach(C=>{C.apply=(v,x,h)=>{let w=new _.AnnotationType,D=h+x.label.length+1;v.dispatch({changes:{from:h,insert:x.label},selection:{anchor:D,head:D},annotations:w.of(x)})}}),n.current}break}return[]},[t,o,s,e]),a=(0,Qe.useCallback)(async(l,p,m)=>{let{current:d}=n,g=!1,u=d||await r(l,{columnName:p});if(m&&u)for(let i of u){if(i.label===m)return!1;i.label.startsWith(m)&&(g=!0)}return g},[r]);return{getSuggestions:r,isPartialMatch:a}};var J=require("@vuu-ui/vuu-utils"),se=require("react"),jn=t=>{let[e,o,n]=(0,J.getCalculatedColumnDetails)(t);return n===""?{...t,name:`${e}:string:${o}`}:t},Xo=({column:t,onChangeName:e,onChangeServerDataType:o})=>{let[n,s]=(0,se.useState)(jn(t)),r=(0,se.useRef)(t),a=(0,se.useCallback)(d=>{r.current=d,s(d)},[]),l=(0,se.useCallback)(d=>{let{value:g}=d.target,u=(0,J.setCalculatedColumnName)(n,g);a(u),e==null||e(u.name)},[n,e,a]),p=(0,se.useCallback)(d=>{let g=d.trim(),{current:u}=r,i=(0,J.setCalculatedColumnExpression)(u,g);a(i),e==null||e(i.name)},[e,a]),m=(0,se.useCallback)((d,g)=>{if((0,J.isVuuColumnDataType)(g)){let u=(0,J.setCalculatedColumnType)(n,g);a(u),e==null||e(u.name),o==null||o(g)}},[n,e,o,a]);return{column:n,onChangeExpression:p,onChangeName:l,onChangeServerDataType:m}};var V=require("react/jsx-runtime"),Uo="vuuColumnExpressionPanel",Kt=({column:t,onChangeName:e,onChangeServerDataType:o,tableConfig:n,vuuTable:s})=>{let r=(0,tt.useRef)(null),{column:a,onChangeExpression:l,onChangeName:p,onChangeServerDataType:m}=Xo({column:t,onChangeName:e,onChangeServerDataType:o}),d=(0,tt.useRef)((0,Me.getCalculatedColumnExpression)(a)),g=Jt({columns:n.columns,table:s}),u=(0,tt.useCallback)(()=>{var i,c;r.current&&((c=(i=r.current)==null?void 0:i.querySelector("button"))==null||c.focus())},[]);return(0,V.jsxs)("div",{className:Uo,children:[(0,V.jsx)("div",{className:"vuuColumnSettingsPanel-header",children:(0,V.jsx)("span",{children:"Calculation"})}),(0,V.jsxs)(K.FormField,{"data-field":"column-name",children:[(0,V.jsx)(K.FormFieldLabel,{children:"Column Name"}),(0,V.jsx)(K.Input,{className:"vuuInput",onChange:p,value:(0,Me.getCalculatedColumnName)(a)})]}),(0,V.jsxs)(K.FormField,{"data-field":"column-expression",children:[(0,V.jsx)(K.FormFieldLabel,{children:"Expression"}),(0,V.jsx)(yt,{onChange:l,onSubmitExpression:u,source:d.current,suggestionProvider:g})]}),(0,V.jsxs)(K.FormField,{"data-field":"type",children:[(0,V.jsx)(K.FormFieldLabel,{children:"Column type"}),(0,V.jsx)(Wo.Dropdown,{className:`${Uo}-type`,onSelectionChange:m,ref:r,selected:(0,Me.getCalculatedColumnType)(a)||null,source:["double","long","string","boolean"],width:"100%"})]})]})};var Jo=require("@vuu-ui/vuu-ui-controls"),ee=require("@vuu-ui/vuu-utils"),Ot=require("@salt-ds/core"),to=ue(require("clsx"),1),Ae=require("react");var Q=require("@salt-ds/core"),Yo=require("@vuu-ui/vuu-utils"),Oe=require("react"),$=require("react/jsx-runtime"),er="vuuFormattingSettings",ot=({column:t,onChangeFormatting:e})=>{var p,m,d;let[o,n]=(0,Oe.useState)((0,Yo.getTypeFormattingFromColumn)(t)),s=(0,Oe.useCallback)(g=>{(g.key==="Enter"||g.key==="Tab")&&e(o)},[o,e]),r=(0,Oe.useCallback)(g=>{let{value:u}=g.target,i=u===""||isNaN(parseInt(u))?void 0:parseInt(u),c={...o,decimals:i};n(c)},[o]),a=(0,Oe.useCallback)(g=>{let{checked:u}=g.target,i={...o,alignOnDecimals:u};n(i),e(i)},[o,e]),l=(0,Oe.useCallback)(g=>{let{checked:u}=g.target,i={...o,zeroPad:u};n(i),e(i)},[o,e]);return(0,$.jsxs)("div",{className:er,children:[(0,$.jsxs)(Q.FormField,{"data-field":"decimals",children:[(0,$.jsx)(Q.FormFieldLabel,{children:"Number of decimals"}),(0,$.jsx)(Q.Input,{className:"vuuInput",onChange:r,onKeyDown:s,value:(p=o.decimals)!=null?p:""})]}),(0,$.jsxs)(Q.FormField,{labelPlacement:"left",children:[(0,$.jsx)(Q.FormFieldLabel,{children:"Align on decimals"}),(0,$.jsx)(Q.Switch,{checked:(m=o.alignOnDecimals)!=null?m:!1,onChange:a,value:"align-decimals"})]}),(0,$.jsxs)(Q.FormField,{labelPlacement:"left",children:[(0,$.jsx)(Q.FormFieldLabel,{children:"Zero pad decimals"}),(0,$.jsx)(Q.Switch,{checked:(d=o.zeroPad)!=null?d:!1,onChange:l,value:"zero-pad"})]})]})};var qo=require("react"),fe=require("@salt-ds/core"),wt=require("@vuu-ui/vuu-utils");var ge=require("react"),Go=require("@vuu-ui/vuu-ui-controls"),ie=require("@vuu-ui/vuu-utils"),j=require("@salt-ds/core"),z=require("react/jsx-runtime"),jt=({column:t,onChangeFormatting:e})=>{var d,g;let o=(0,ie.getTypeFormattingFromColumn)(t),{pattern:n=ie.fallbackDateTimePattern}=o,s=(0,ge.useMemo)(()=>nr(n),[n]),[r,a]=(0,ge.useState)({time:(d=n.time)!=null?d:ie.defaultPatternsByType.time,date:(g=n.date)!=null?g:ie.defaultPatternsByType.date}),l=(0,ge.useCallback)(u=>e({...o,pattern:u}),[e,o]),p=(0,ge.useCallback)(u=>(i,c)=>{let C={...n!=null?n:{},[u]:c};a(v=>{var x,h;return{time:(x=C.time)!=null?x:v.time,date:(h=C.date)!=null?h:v.date}}),l(C)},[l,n]),m=(0,ge.useCallback)(u=>{var c,C,v,x;let i=u.currentTarget.value;switch(i){case"time":return l({[i]:(c=n[i])!=null?c:r[i]});case"date":return l({[i]:(C=n[i])!=null?C:r[i]});case"both":return l({time:(v=n.time)!=null?v:r.time,date:(x=n.date)!=null?x:r.date})}},[l,n,r]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(j.FormField,{labelPlacement:"top",children:[(0,z.jsx)(j.FormFieldLabel,{children:"Display"}),(0,z.jsx)(j.ToggleButtonGroup,{className:"vuuToggleButtonGroup",onChange:m,value:s,"data-variant":"primary",children:or.map(u=>(0,z.jsx)(j.ToggleButton,{value:u,children:u.toUpperCase()},u))})]}),["date","time"].filter(u=>!!n[u]).map(u=>(0,z.jsxs)(j.FormField,{labelPlacement:"top",children:[(0,z.jsx)(j.FormFieldLabel,{children:`${tr[u]} pattern`}),(0,z.jsx)(Go.Dropdown,{onSelectionChange:p(u),selected:n[u],source:ie.supportedDateTimePatterns[u],width:"100%"})]},u))]})},tr={date:"Date",time:"Time"},or=["date","time","both"];function nr(t){return t.time?t.date?"both":"time":"date"}var ae=require("react/jsx-runtime"),rr="vuuLongColumnFormattingSettings",_o=t=>{let{column:e,onChangeColumnType:o}=t,n=(0,wt.isTypeDescriptor)(e.type)?e.type.name:e.type,s=(0,qo.useCallback)(r=>{let a=r.currentTarget.value;o(a)},[o]);return(0,ae.jsxs)("div",{className:rr,children:[(0,ae.jsxs)(fe.FormField,{children:[(0,ae.jsx)(fe.FormFieldLabel,{children:"Type inferred as"}),(0,ae.jsx)(fe.ToggleButtonGroup,{className:"vuuToggleButtonGroup",onChange:s,value:n!=null?n:"number",children:sr.map(r=>(0,ae.jsx)(fe.ToggleButton,{value:r,children:r.toUpperCase()},r))})]}),(0,wt.isDateTimeColumn)(e)?(0,ae.jsx)(jt,{...t,column:e}):(0,ae.jsx)(ot,{...t})]})},sr=["number","date/time"];var W=require("react/jsx-runtime"),eo="vuuColumnFormattingPanel",ir=t=>{var e;return(e=t.label)!=null?e:t.name},oo=({availableRenderers:t,className:e,column:o,onChangeFormatting:n,onChangeColumnType:s,onChangeRendering:r,...a})=>{let l=(0,Ae.useMemo)(()=>ar({column:o,onChangeFormatting:n,onChangeColumnType:s}),[o,s,n]);console.log({formattingSettingsComponent:l});let p=(0,Ae.useMemo)(()=>{let{type:u}=o;if((0,ee.isTypeDescriptor)(u)&&(0,ee.isColumnTypeRenderer)(u.renderer)){let i=(0,ee.getCellRendererOptions)(u.renderer.name);return(0,ee.getConfigurationEditor)(i==null?void 0:i.configEditor)}},[o]),m=(0,Ae.useMemo)(()=>{let{type:u}=o,[i]=t,c=(0,ee.isTypeDescriptor)(u)&&(0,ee.isColumnTypeRenderer)(u.renderer)?u.renderer.name:void 0,C=t.find(v=>v.name===c);return C!=null?C:i},[t,o]),d=(0,Ae.useCallback)((u,i)=>{let c={name:i.name};r==null||r(c)},[r]),{serverDataType:g="string"}=o;return(0,W.jsxs)("div",{...a,className:"vuuColumnSettingsPanel-header",children:[(0,W.jsx)("div",{children:"Formatting"}),(0,W.jsxs)(Ot.FormField,{children:[(0,W.jsx)(Ot.FormFieldLabel,{children:`Renderer (data type ${o.serverDataType})`}),(0,W.jsx)(Jo.Dropdown,{className:(0,to.default)(`${eo}-renderer`),itemToString:ir,onSelectionChange:d,selected:m,source:t,width:"100%"})]}),(0,W.jsxs)("div",{className:(0,to.default)(eo,e,`${eo}-${g}`),children:[l,p?(0,W.jsx)(p,{column:o,onChangeRendering:r}):null]})]})};function ar(t){let{column:e}=t;switch(e.serverDataType){case"double":case"int":return(0,W.jsx)(ot,{...t});case"long":return(0,W.jsx)(_o,{...t});default:return null}}var Ko=ue(require("clsx"),1),St=require("@vuu-ui/vuu-utils");var te=require("react/jsx-runtime"),$e="vuuColumnNameLabel",jo=({column:t,onClick:e})=>{if((0,St.isCalculatedColumn)(t.name)){let[o,n,s]=(0,St.getCalculatedColumnDetails)(t),r=o||"name",a="=expression",l=r==="name"?`${$e}-placeholder`:void 0,p=s===""?`${$e}-placeholder`:void 0;return(0,te.jsxs)("div",{className:(0,Ko.default)($e,`${$e}-calculated`),onClick:e,children:[(0,te.jsx)("span",{className:l,children:r}),(0,te.jsx)("span",{children:":"}),(0,te.jsx)("span",{children:n||"string"}),(0,te.jsx)("span",{children:":"}),(0,te.jsx)("span",{className:p,children:a}),(0,te.jsx)("span",{className:`${$e}-edit`,"data-icon":"edit"})]})}else return(0,te.jsx)("div",{className:$e,children:t.name})};var B=require("@vuu-ui/vuu-utils"),T=require("react"),lr=[{description:"Default formatter for columns with data type integer",label:"Default Renderer (int, long)",name:"default-int"}],ur=[{description:"Default formatter for columns with data type double",label:"Default Renderer (double)",name:"default-double"}],en=[{description:"Default formatter for columns with data type string",label:"Default Renderer (string)",name:"default-string"}],pr=[],cr=t=>{switch(t.serverDataType){case"char":case"string":return en.concat((0,B.getRegisteredCellRenderers)("string"));case"int":case"long":return lr.concat((0,B.getRegisteredCellRenderers)("int"));case"double":return ur.concat((0,B.getRegisteredCellRenderers)("double"));case"boolean":return pr.concat((0,B.getRegisteredCellRenderers)("boolean"));default:return en}},tn=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")},mr=(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}`)}},ze=(t,e)=>({...t,columns:t.columns.map(o=>o.name===e.name?e:o)}),on=({column:t,onCancelCreateColumn:e,onConfigChange:o,onCreateCalculatedColumn:n,tableConfig:s})=>{let[r,a]=(0,T.useState)(mr(s.columns,t)),l=(0,T.useRef)(r),[p,m]=(0,T.useState)(r.name==="::"),d=(0,T.useCallback)(()=>{l.current=r,m(!0)},[r]);(0,T.useEffect)(()=>{a(t),m(t.name==="::")},[t]);let g=(0,T.useMemo)(()=>cr(r),[r]),u=(0,T.useCallback)(()=>{o(ze(s,r))},[r,o,s]),i=(0,T.useCallback)(k=>{let S=(0,B.queryClosest)(k.target,"button");if(S){let Xe=tn(S),{value:Z}=S;switch(Xe){case"column-alignment":if((0,B.isValidColumnAlignment)(Z)){let X={...r,align:Z||void 0};a(X),o(ze(s,X))}break;case"column-pin":if((0,B.isValidPinLocation)(Z)){let X={...r,pin:Z||void 0};a(X),o(ze(s,X));break}}}},[r,o,s]),c=(0,T.useCallback)(k=>{let S=k.target,Xe=tn(S),{value:Z}=S;switch(Xe){case"column-label":a(X=>({...X,label:Z}));break;case"column-name":a(X=>(0,B.setCalculatedColumnName)(X,Z));break;case"column-width":a(X=>({...X,width:parseInt(Z)}));break}},[]),C=(0,T.useCallback)(k=>{a(S=>({...S,name:k}))},[]),v=(0,T.useCallback)(k=>{let S=(0,B.updateColumnFormatting)(r,k);a(S),o(ze(s,S))},[r,o,s]),x=(0,T.useCallback)(k=>{let S=(0,B.updateColumnType)(r,k);a(S),o(ze(s,S))},[r,o,s]),h=(0,T.useCallback)(k=>{a(S=>({...S,serverDataType:k}))},[]),w=(0,T.useCallback)(k=>{if(k){let S=(0,B.updateColumnRenderProps)(r,k);a(S),o(ze(s,S))}},[r,o,s]),D=(0,T.useCallback)(({moveBy:k})=>{let{columns:S}=s,Xe=S.indexOf(r)+k,Z=S[Xe];Z&&a(Z)},[r,s]),st=(0,T.useCallback)(()=>{D({moveBy:1})},[D]),kt=(0,T.useCallback)(()=>{D({moveBy:-1})},[D]),Pt=(0,T.useCallback)(()=>{n(r)},[r,n]),Ft=(0,T.useCallback)(()=>{t.name==="::"?e():(l.current!==void 0&&l.current!==r&&a(l.current),m(!1))},[r,t.name,e]);return{availableRenderers:g,editCalculatedColumn:p,column:r,navigateNextColumn:st,navigatePrevColumn:kt,onCancel:Ft,onChange:c,onChangeCalculatedColumnName:C,onChangeFormatting:v,onChangeRendering:w,onChangeServerDataType:h,onChangeToggleButton:i,onChangeType:x,onEditCalculatedColumn:d,onInputCommit:u,onSave:Pt}};var b=require("react/jsx-runtime"),Ce="vuuColumnSettingsPanel",dr=t=>{let{name:e,label:o}=t;return(0,Ze.isCalculatedColumn)(e)?o!=null?o:(0,Ze.getCalculatedColumnName)(t):o!=null?o:e},gr=({column:t,onCancelCreateColumn:e,onConfigChange:o,onCreateCalculatedColumn:n,tableConfig:s,vuuTable:r})=>{let a=t.name==="::",{availableRenderers:l,editCalculatedColumn:p,column:m,navigateNextColumn:d,navigatePrevColumn:g,onCancel:u,onChange:i,onChangeCalculatedColumnName:c,onChangeFormatting:C,onChangeRendering:v,onChangeServerDataType:x,onChangeToggleButton:h,onChangeType:w,onEditCalculatedColumn:D,onInputCommit:st,onSave:kt}=on({column:t,onCancelCreateColumn:e,onConfigChange:o,onCreateCalculatedColumn:n,tableConfig:s}),{serverDataType:Pt,align:Ft=(0,Ze.getDefaultAlignment)(Pt),pin:k,width:S}=m;return(0,b.jsxs)("div",{className:(0,nn.default)(Ce,{[`${Ce}-editing`]:p}),children:[(0,b.jsx)("div",{className:`${Ce}-header`,children:(0,b.jsx)(jo,{column:m,onClick:D})}),p?(0,b.jsx)(Kt,{column:m,onChangeName:c,onChangeServerDataType:x,tableConfig:s,vuuTable:r}):null,(0,b.jsxs)(O.FormField,{"data-field":"column-label",children:[(0,b.jsx)(O.FormFieldLabel,{children:"Column Label"}),(0,b.jsx)(oe.VuuInput,{className:"vuuInput","data-embedded":!0,onChange:i,onCommit:st,value:dr(m)})]}),(0,b.jsxs)(O.FormField,{"data-field":"column-width",children:[(0,b.jsx)(O.FormFieldLabel,{children:"Column Width"}),(0,b.jsx)(oe.VuuInput,{className:"vuuInput","data-embedded":!0,onChange:i,value:S,onCommit:st})]}),(0,b.jsxs)(O.FormField,{"data-field":"column-alignment",children:[(0,b.jsx)(O.FormFieldLabel,{children:"Alignment"}),(0,b.jsxs)(O.ToggleButtonGroup,{onChange:h,value:Ft,children:[(0,b.jsx)(O.ToggleButton,{value:"left",children:(0,b.jsx)(oe.Icon,{name:"align-left",size:16})}),(0,b.jsx)(O.ToggleButton,{value:"right",children:(0,b.jsx)(oe.Icon,{name:"align-right",size:16})})]})]}),(0,b.jsxs)(O.FormField,{"data-field":"column-pin",children:[(0,b.jsx)(O.FormFieldLabel,{children:"Pin Column"}),(0,b.jsxs)(O.ToggleButtonGroup,{onChange:h,value:k!=null?k:"",children:[(0,b.jsx)(O.ToggleButton,{value:"left",children:(0,b.jsx)(oe.Icon,{name:"pin-left",size:16})}),(0,b.jsx)(O.ToggleButton,{value:"floating",children:(0,b.jsx)(oe.Icon,{name:"pin-float",size:16})}),(0,b.jsx)(O.ToggleButton,{value:"right",children:(0,b.jsx)(oe.Icon,{name:"pin-right",size:16})}),(0,b.jsx)(O.ToggleButton,{value:"",children:(0,b.jsx)(oe.Icon,{name:"cross-circle",size:16})})]})]}),(0,b.jsx)(oo,{availableRenderers:l,column:m,onChangeFormatting:C,onChangeRendering:v,onChangeColumnType:w}),p?(0,b.jsxs)("div",{className:"vuuColumnSettingsPanel-buttonBar","data-align":"right",children:[(0,b.jsx)(O.Button,{className:`${Ce}-buttonCancel`,onClick:u,tabIndex:-1,children:"cancel"}),(0,b.jsx)(O.Button,{className:`${Ce}-buttonSave`,onClick:kt,variant:"cta",children:"save"})]}):(0,b.jsxs)("div",{className:`${Ce}-buttonBar`,"data-align":a?"right":void 0,children:[(0,b.jsx)(O.Button,{className:`${Ce}-buttonNavPrev`,variant:"secondary","data-icon":"arrow-left",onClick:g,children:"PREVIOUS"}),(0,b.jsx)(O.Button,{className:`${Ce}-buttonNavNext`,variant:"secondary","data-icon":"arrow-right",onClick:d,children:"NEXT"})]})]})};var rn=ue(require("clsx"),1),rt=require("react");var le=require("react/jsx-runtime"),nt="vuuDatasourceStats",no=new Intl.NumberFormat,fr=({className:t,dataSource:e})=>{let[o,n]=(0,rt.useState)(e.range),[s,r]=(0,rt.useState)(e.size);(0,rt.useEffect)(()=>(r(e.size),e.on("resize",r),e.on("range",n),()=>{e.removeListener("resize",r),e.removeListener("range",n)}),[e]);let a=(0,rn.default)(nt,t),l=no.format(o.from+1),p=no.format(Math.min(o.to,s)),m=no.format(s);return(0,le.jsxs)("div",{className:a,children:[(0,le.jsx)("span",{className:`${nt}-label`,children:"Row count"}),(0,le.jsx)("span",{className:`${nt}-range`,children:l}),(0,le.jsx)("span",{children:"-"}),(0,le.jsx)("span",{className:`${nt}-range`,children:p}),(0,le.jsx)("span",{children:"of"}),(0,le.jsx)("span",{className:`${nt}-size`,children:m})]})};var L=require("@salt-ds/core");var sn=require("@vuu-ui/vuu-table"),I=require("@vuu-ui/vuu-utils"),ne=require("react"),Cr=(t,e)=>{let o=[];for(let{name:n}of t){let s=e.find(r=>r.name===n);s&&o.push(s)}return o},vr=(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:(0,I.isCalculatedColumn)(o),label:s==null?void 0:s.label,name:o,serverDataType:n,subscribed:s!==void 0}}),ro=({availableColumns:t,onConfigChange:e,onDataSourceConfigChange:o,tableConfig:n})=>{let[{availableColumns:s,tableConfig:r},a]=(0,ne.useState)({availableColumns:t,tableConfig:n}),l=(0,ne.useMemo)(()=>vr(s,r.columns),[s,r.columns]),p=(0,ne.useCallback)((c,C)=>{a(v=>{let x=(0,I.moveItem)(v.availableColumns,c,C),h=Cr(x,r.columns);return{availableColumns:x,tableConfig:{...v.tableConfig,columns:h}}})},[r.columns]),m=(0,ne.useCallback)((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((0,I.subscribedOnly)(h))}})),o({columns:h})}else{let h={...r,columns:(0,I.addColumnToSubscribedColumns)(r.columns,s,c)};a(D=>({...D,tableConfig:h}));let w=h.columns.map(D=>D.name);o({columns:w})}else if(x!=null&&x.subscribed){let h=r.columns.find(w=>w.name===c);if(h){let w=(0,sn.updateTableConfig)(r,{type:"column-prop",property:C,column:h,value:v});a(D=>({...D,tableConfig:w}))}}},[s,l,o,r]),d=(0,ne.useCallback)(c=>{let C=(0,I.queryClosest)(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=(0,ne.useCallback)(c=>{let C=(0,I.queryClosest)(c.target,"button");if(C){let{ariaPressed:v,value:x}=C;console.log({ariaPressed:v,value:x,button:C}),a(h=>({...h,tableConfig:{...h.tableConfig,[x]:v!=="true"}}))}},[]),u=(0,ne.useCallback)((c,C)=>{let v=parseInt(C);isNaN(v)||a(x=>({...x,tableConfig:{...x.tableConfig,columnDefaultWidth:v}})),console.log({value:C})},[]);(0,I.useLayoutEffectSkipFirst)(()=>{e==null||e(r)},[e,r]);let i=r.columnFormatHeader===void 0?0:r.columnFormatHeader==="capitalize"?1:2;return{columnItems:l,columnLabelsValue:i,onChangeColumnLabels:d,onChangeTableAttribute:g,onColumnChange:m,onCommitColumnWidth:u,onMoveListItem:p,tableConfig:r}};var Se=require("@vuu-ui/vuu-ui-controls"),an=require("@vuu-ui/vuu-ui-controls");var E=require("react/jsx-runtime"),Tt="vuuTableSettingsPanel",xr=({allowColumnLabelCase:t=!0,allowColumnDefaultWidth:e=!0,allowGridRowStyling:o=!0,availableColumns:n,onAddCalculatedColumn:s,onConfigChange:r,onDataSourceConfigChange:a,onNavigateToColumn:l,tableConfig:p})=>{var x,h,w;let{columnItems:m,columnLabelsValue:d,onChangeColumnLabels:g,onChangeTableAttribute:u,onColumnChange:i,onCommitColumnWidth:c,onMoveListItem:C,tableConfig:v}=ro({availableColumns:n,onConfigChange:r,onDataSourceConfigChange:a,tableConfig:p});return(0,E.jsxs)("div",{className:Tt,children:[t||e||o?(0,E.jsx)("div",{className:`${Tt}-header`,children:(0,E.jsx)("span",{children:"Column Settings"})}):null,e?(0,E.jsxs)(L.FormField,{children:[(0,E.jsx)(L.FormFieldLabel,{children:"Column Width"}),(0,E.jsx)(an.VuuInput,{className:"vuuInput","data-embedded":!0,onCommit:c})]}):null,t?(0,E.jsxs)(L.FormField,{children:[(0,E.jsx)(L.FormFieldLabel,{children:"Column Labels"}),(0,E.jsxs)(L.ToggleButtonGroup,{className:"vuuToggleButtonGroup",onChange:g,value:d,children:[(0,E.jsx)(L.ToggleButton,{className:"vuuIconToggleButton",value:0,children:(0,E.jsx)(Se.Icon,{name:"text-strikethrough",size:48})}),(0,E.jsx)(L.ToggleButton,{className:"vuuIconToggleButton",value:1,children:(0,E.jsx)(Se.Icon,{name:"text-Tt",size:48})}),(0,E.jsx)(L.ToggleButton,{className:"vuuIconToggleButton",value:2,children:(0,E.jsx)(Se.Icon,{name:"text-T",size:48})})]})]}):null,o?(0,E.jsxs)(L.FormField,{children:[(0,E.jsx)(L.FormFieldLabel,{children:"Grid separators"}),(0,E.jsxs)("div",{className:"saltToggleButtonGroup vuuStateButtonGroup saltToggleButtonGroup-horizontal",children:[(0,E.jsx)(L.ToggleButton,{selected:(x=v.zebraStripes)!=null?x:!1,onChange:u,value:"zebraStripes",children:(0,E.jsx)(Se.Icon,{name:"row-striping",size:16})}),(0,E.jsx)(L.ToggleButton,{selected:(h=v.rowSeparators)!=null?h:!1,onChange:u,value:"rowSeparators",children:(0,E.jsx)(Se.Icon,{name:"row-lines",size:16})}),(0,E.jsx)(L.ToggleButton,{selected:(w=v.columnSeparators)!=null?w:!1,onChange:u,value:"columnSeparators",children:(0,E.jsx)(Se.Icon,{name:"col-lines",size:16})})]})]}):null,(0,E.jsx)(Rt,{columnItems:m,onChange:i,onMoveListItem:C,onNavigateToColumn:l}),(0,E.jsxs)("div",{className:`${Tt}-calculatedButtonbar`,children:[(0,E.jsx)(L.Button,{"data-icon":"plus",onClick:s}),(0,E.jsx)("span",{className:`${Tt}-calculatedLabel`,children:"Add calculated column"})]})]})};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name2 in all)
|
|
10
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __accessCheck = (obj, member, msg) => {
|
|
30
|
+
if (!member.has(obj))
|
|
31
|
+
throw TypeError("Cannot " + msg);
|
|
32
|
+
};
|
|
33
|
+
var __privateGet = (obj, member, getter) => {
|
|
34
|
+
__accessCheck(obj, member, "read from private field");
|
|
35
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
36
|
+
};
|
|
37
|
+
var __privateAdd = (obj, member, value) => {
|
|
38
|
+
if (member.has(obj))
|
|
39
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
40
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
41
|
+
};
|
|
42
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
43
|
+
__accessCheck(obj, member, "write to private field");
|
|
44
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
45
|
+
return value;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/index.ts
|
|
49
|
+
var src_exports = {};
|
|
50
|
+
__export(src_exports, {
|
|
51
|
+
BackgroundCell: () => BackgroundCell,
|
|
52
|
+
BackgroundCellConfigurationEditor: () => BackgroundCellConfigurationEditor,
|
|
53
|
+
BaseNumericFormattingSettings: () => BaseNumericFormattingSettings,
|
|
54
|
+
CaseValidator: () => CaseValidator,
|
|
55
|
+
ColumnExpressionInput: () => ColumnExpressionInput,
|
|
56
|
+
ColumnExpressionPanel: () => ColumnExpressionPanel,
|
|
57
|
+
ColumnFormattingPanel: () => ColumnFormattingPanel,
|
|
58
|
+
ColumnList: () => ColumnList,
|
|
59
|
+
ColumnNamedTerms: () => ColumnNamedTerms,
|
|
60
|
+
ColumnSettingsPanel: () => ColumnSettingsPanel,
|
|
61
|
+
DataSourceStats: () => DataSourceStats,
|
|
62
|
+
DateTimeFormattingSettings: () => DateTimeFormattingSettings,
|
|
63
|
+
DropdownCell: () => DropdownCell,
|
|
64
|
+
LookupCell: () => LookupCell,
|
|
65
|
+
PatternValidator: () => PatternValidator,
|
|
66
|
+
PctProgressCell: () => PctProgressCell,
|
|
67
|
+
TableSettingsPanel: () => TableSettingsPanel,
|
|
68
|
+
columnExpressionLanguageSupport: () => columnExpressionLanguageSupport,
|
|
69
|
+
isCompleteExpression: () => isCompleteExpression,
|
|
70
|
+
isCompleteRelationalExpression: () => isCompleteRelationalExpression,
|
|
71
|
+
lastNamedChild: () => lastNamedChild,
|
|
72
|
+
useColumnExpressionEditor: () => useColumnExpressionEditor,
|
|
73
|
+
useColumnExpressionSuggestionProvider: () => useColumnExpressionSuggestionProvider,
|
|
74
|
+
useTableSettings: () => useTableSettings,
|
|
75
|
+
walkTree: () => walkTree
|
|
76
|
+
});
|
|
77
|
+
module.exports = __toCommonJS(src_exports);
|
|
78
|
+
|
|
79
|
+
// src/cell-edit-validators/CaseValidator.ts
|
|
80
|
+
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
81
|
+
var isString = (value) => typeof value === "string";
|
|
82
|
+
var CaseValidator = (rule, value) => {
|
|
83
|
+
if (isString(value)) {
|
|
84
|
+
if (value === "") {
|
|
85
|
+
return true;
|
|
86
|
+
} else if (rule.value === "lower" && value.toLowerCase() !== value) {
|
|
87
|
+
return "value must be all lowercase";
|
|
88
|
+
} else if (rule.value === "upper" && value.toUpperCase() !== value) {
|
|
89
|
+
return "value must be all uppercase";
|
|
90
|
+
} else {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
return "value must be a string";
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
(0, import_vuu_utils.registerComponent)("vuu-case", CaseValidator, "data-edit-validator", {});
|
|
98
|
+
|
|
99
|
+
// src/cell-edit-validators/PatternValidator.ts
|
|
100
|
+
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
101
|
+
var isString2 = (value) => typeof value === "string";
|
|
102
|
+
var defaultMessage = "value does not match expected pattern";
|
|
103
|
+
var PatternValidator = (rule, value) => {
|
|
104
|
+
if (typeof rule.value !== "string") {
|
|
105
|
+
throw Error("Pattern validation rule must provide pattern");
|
|
106
|
+
}
|
|
107
|
+
if (isString2(value)) {
|
|
108
|
+
if (value === "") {
|
|
109
|
+
return true;
|
|
110
|
+
} else {
|
|
111
|
+
const { message = defaultMessage } = rule;
|
|
112
|
+
const pattern = new RegExp(rule.value);
|
|
113
|
+
return pattern.test(value) || message;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
return "value must be a string";
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
(0, import_vuu_utils2.registerComponent)("vuu-pattern", PatternValidator, "data-edit-validator", {});
|
|
120
|
+
|
|
121
|
+
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
122
|
+
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
123
|
+
var import_clsx = __toESM(require("clsx"), 1);
|
|
124
|
+
var import_react2 = require("react");
|
|
125
|
+
|
|
126
|
+
// src/cell-renderers/background-cell/useDirection.ts
|
|
127
|
+
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
128
|
+
var import_react = require("react");
|
|
129
|
+
var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
|
|
130
|
+
function useDirection(key, value, column) {
|
|
131
|
+
var _a;
|
|
132
|
+
const ref = (0, import_react.useRef)();
|
|
133
|
+
const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
|
|
134
|
+
const { type: dataType } = column;
|
|
135
|
+
const decimals = (0, import_vuu_utils3.isTypeDescriptor)(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
|
|
136
|
+
const direction = key === prevKey && (0, import_vuu_utils3.isValidNumber)(value) && (0, import_vuu_utils3.isValidNumber)(prevValue) && column === prevColumn ? (0, import_vuu_utils3.getMovingValueDirection)(value, prevDirection, prevValue, decimals) : "";
|
|
137
|
+
(0, import_react.useEffect)(() => {
|
|
138
|
+
ref.current = [key, value, column, direction];
|
|
139
|
+
});
|
|
140
|
+
return direction;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
144
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
145
|
+
var CHAR_ARROW_UP = String.fromCharCode(11014);
|
|
146
|
+
var CHAR_ARROW_DOWN = String.fromCharCode(11015);
|
|
147
|
+
var { KEY } = import_vuu_utils4.metadataKeys;
|
|
148
|
+
var classBase = "vuuBackgroundCell";
|
|
149
|
+
var FlashStyle = {
|
|
150
|
+
ArrowOnly: "arrow",
|
|
151
|
+
BackgroundOnly: "bg-only",
|
|
152
|
+
ArrowBackground: "arrow-bg"
|
|
153
|
+
};
|
|
154
|
+
var getFlashStyle = (colType) => {
|
|
155
|
+
if ((0, import_vuu_utils4.isTypeDescriptor)(colType) && colType.renderer) {
|
|
156
|
+
if ("flashStyle" in colType.renderer) {
|
|
157
|
+
return colType.renderer["flashStyle"];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return FlashStyle.BackgroundOnly;
|
|
161
|
+
};
|
|
162
|
+
var BackgroundCell = (0, import_react2.memo)(
|
|
163
|
+
function BackgroundCell2({
|
|
164
|
+
column,
|
|
165
|
+
columnMap,
|
|
166
|
+
row
|
|
167
|
+
}) {
|
|
168
|
+
const { name: name2, type, valueFormatter } = column;
|
|
169
|
+
const dataIdx = columnMap[name2];
|
|
170
|
+
const value = row[dataIdx];
|
|
171
|
+
const flashStyle = getFlashStyle(type);
|
|
172
|
+
const direction = useDirection(row[KEY], value, column);
|
|
173
|
+
const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === import_vuu_utils4.UP1 || direction === import_vuu_utils4.UP2 ? CHAR_ARROW_UP : direction === import_vuu_utils4.DOWN1 || direction === import_vuu_utils4.DOWN2 ? CHAR_ARROW_DOWN : null : null;
|
|
174
|
+
const dirClass = direction ? ` ` + direction : "";
|
|
175
|
+
const className = (0, import_clsx.default)(classBase, dirClass, {
|
|
176
|
+
[`${classBase}-backgroundOnly`]: flashStyle === FlashStyle.BackgroundOnly,
|
|
177
|
+
[`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
|
|
178
|
+
[`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
|
|
179
|
+
});
|
|
180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className, tabIndex: -1, children: [
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${classBase}-arrow`, children: arrow }),
|
|
182
|
+
valueFormatter(row[dataIdx])
|
|
183
|
+
] });
|
|
184
|
+
},
|
|
185
|
+
import_vuu_utils4.dataAndColumnUnchanged
|
|
186
|
+
);
|
|
187
|
+
(0, import_vuu_utils4.registerComponent)(
|
|
188
|
+
"vuu.price-move-background",
|
|
189
|
+
BackgroundCell,
|
|
190
|
+
"cell-renderer",
|
|
191
|
+
{
|
|
192
|
+
description: "Change background color of cell when value changes",
|
|
193
|
+
configEditor: "BackgroundCellConfigurationEditor",
|
|
194
|
+
label: "Background Flash",
|
|
195
|
+
serverDataType: ["long", "int", "double"]
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// src/cell-renderers/background-cell/BackgroundCellConfigurationEditor.tsx
|
|
200
|
+
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
201
|
+
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
202
|
+
var import_core = require("@salt-ds/core");
|
|
203
|
+
var import_react3 = require("react");
|
|
204
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
205
|
+
var classBase2 = "vuuBackgroundCellConfiguration";
|
|
206
|
+
var flashOptions = [
|
|
207
|
+
{ label: "Background Only", value: "bg-only" },
|
|
208
|
+
{ label: "Background and Arrow", value: "arrow-bg" },
|
|
209
|
+
{ label: "Arrow Only", value: "arrow" }
|
|
210
|
+
];
|
|
211
|
+
var [defaultFlashOption] = flashOptions;
|
|
212
|
+
var valueFromColumn = (column) => {
|
|
213
|
+
const { flashStyle } = column.type.renderer;
|
|
214
|
+
return flashOptions.find((o) => o.value === flashStyle) || defaultFlashOption;
|
|
215
|
+
};
|
|
216
|
+
var BackgroundCellConfigurationEditor = ({
|
|
217
|
+
column,
|
|
218
|
+
onChangeRendering
|
|
219
|
+
}) => {
|
|
220
|
+
const [flashStyle, setFlashStyle] = (0, import_react3.useState)(
|
|
221
|
+
valueFromColumn(column)
|
|
222
|
+
);
|
|
223
|
+
const handleSelectionChange = (0, import_react3.useCallback)(
|
|
224
|
+
(_, flashOption) => {
|
|
225
|
+
var _a;
|
|
226
|
+
setFlashStyle(flashOption);
|
|
227
|
+
const renderProps = column.type.renderer;
|
|
228
|
+
onChangeRendering({
|
|
229
|
+
...renderProps,
|
|
230
|
+
flashStyle: (_a = flashOption == null ? void 0 : flashOption.value) != null ? _a : defaultFlashOption.value
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
[column.type, onChangeRendering]
|
|
234
|
+
);
|
|
235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core.FormField, { children: [
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core.FormFieldLabel, { children: "Flash Style" }),
|
|
237
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
238
|
+
import_vuu_ui_controls.Dropdown,
|
|
239
|
+
{
|
|
240
|
+
className: `${classBase2}-flashStyle`,
|
|
241
|
+
onSelectionChange: handleSelectionChange,
|
|
242
|
+
selected: flashStyle,
|
|
243
|
+
source: flashOptions,
|
|
244
|
+
width: "100%"
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
] });
|
|
248
|
+
};
|
|
249
|
+
(0, import_vuu_utils5.registerConfigurationEditor)(
|
|
250
|
+
"BackgroundCellConfigurationEditor",
|
|
251
|
+
BackgroundCellConfigurationEditor
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
// src/cell-renderers/dropdown-cell/DropdownCell.tsx
|
|
255
|
+
var import_vuu_data_react = require("@vuu-ui/vuu-data-react");
|
|
256
|
+
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
257
|
+
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
258
|
+
var import_react4 = require("react");
|
|
259
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
260
|
+
var classBase3 = "vuuTableDropdownCell";
|
|
261
|
+
var openKeys = ["Enter", " "];
|
|
262
|
+
var DropdownCell = (0, import_react4.memo)(
|
|
263
|
+
function DropdownCell2({
|
|
264
|
+
column,
|
|
265
|
+
columnMap,
|
|
266
|
+
onCommit = import_vuu_ui_controls2.WarnCommit,
|
|
267
|
+
row
|
|
268
|
+
}) {
|
|
269
|
+
const dataIdx = columnMap[column.name];
|
|
270
|
+
const dataValue = row[dataIdx];
|
|
271
|
+
const { values } = (0, import_vuu_data_react.useLookupValues)(column, dataValue);
|
|
272
|
+
const valueRef = (0, import_react4.useRef)(null);
|
|
273
|
+
(0, import_react4.useMemo)(() => {
|
|
274
|
+
valueRef.current = (0, import_vuu_data_react.getSelectedOption)(values, dataValue);
|
|
275
|
+
}, [dataValue, values]);
|
|
276
|
+
const handleSelectionChange = (0, import_react4.useCallback)(
|
|
277
|
+
(evt, selectedOption) => {
|
|
278
|
+
if (selectedOption) {
|
|
279
|
+
onCommit(selectedOption.value).then((response) => {
|
|
280
|
+
if (response === true && evt) {
|
|
281
|
+
(0, import_vuu_utils6.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
[onCommit]
|
|
287
|
+
);
|
|
288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
289
|
+
import_vuu_ui_controls2.Dropdown,
|
|
290
|
+
{
|
|
291
|
+
className: classBase3,
|
|
292
|
+
onSelectionChange: handleSelectionChange,
|
|
293
|
+
openKeys,
|
|
294
|
+
selected: valueRef.current,
|
|
295
|
+
source: values,
|
|
296
|
+
width: column.width - 17
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
import_vuu_utils6.dataColumnAndKeyUnchanged
|
|
301
|
+
);
|
|
302
|
+
(0, import_vuu_utils6.registerComponent)("dropdown-cell", DropdownCell, "cell-renderer", {
|
|
303
|
+
userCanAssign: false
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// src/cell-renderers/lookup-cell/LookupCell.tsx
|
|
307
|
+
var import_vuu_data_react2 = require("@vuu-ui/vuu-data-react");
|
|
308
|
+
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
309
|
+
var import_react5 = require("react");
|
|
310
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
311
|
+
var LookupCell = (0, import_react5.memo)(
|
|
312
|
+
function LookupCell2({
|
|
313
|
+
column,
|
|
314
|
+
columnMap,
|
|
315
|
+
row
|
|
316
|
+
}) {
|
|
317
|
+
const dataIdx = columnMap[column.name];
|
|
318
|
+
const dataValue = row[dataIdx];
|
|
319
|
+
const { initialValue: value } = (0, import_vuu_data_react2.useLookupValues)(column, dataValue);
|
|
320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: value == null ? void 0 : value.label });
|
|
321
|
+
},
|
|
322
|
+
import_vuu_utils7.dataAndColumnUnchanged
|
|
323
|
+
);
|
|
324
|
+
(0, import_vuu_utils7.registerComponent)("lookup-cell", LookupCell, "cell-renderer", {
|
|
325
|
+
userCanAssign: false
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// src/cell-renderers/pct-progress-cell/PctProgressCell.tsx
|
|
329
|
+
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
330
|
+
var import_clsx2 = __toESM(require("clsx"), 1);
|
|
331
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
332
|
+
var classBase4 = "vuuPctProgressCell";
|
|
333
|
+
var getPercentageValue = (value) => {
|
|
334
|
+
if (value >= 0 && value <= 1) {
|
|
335
|
+
return value * 100;
|
|
336
|
+
} else if (value > 2) {
|
|
337
|
+
return 0;
|
|
338
|
+
} else if (value > 1) {
|
|
339
|
+
return 100;
|
|
340
|
+
} else {
|
|
341
|
+
return 0;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
var PctProgressCell = ({ column, columnMap, row }) => {
|
|
345
|
+
const value = row[columnMap[column.name]];
|
|
346
|
+
const percentageValue = getPercentageValue(value);
|
|
347
|
+
const className = (0, import_clsx2.default)(classBase4, {});
|
|
348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
349
|
+
"div",
|
|
350
|
+
{
|
|
351
|
+
className: (0, import_clsx2.default)(className, {
|
|
352
|
+
[`${classBase4}-zero`]: percentageValue === 0,
|
|
353
|
+
[`${classBase4}-complete`]: percentageValue >= 100
|
|
354
|
+
}),
|
|
355
|
+
tabIndex: -1,
|
|
356
|
+
children: [
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
358
|
+
"span",
|
|
359
|
+
{
|
|
360
|
+
className: `${classBase4}-progressBar`,
|
|
361
|
+
style: { "--progress-bar-pct": `${percentageValue}%` }
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `${classBase4}-text`, children: `${percentageValue.toFixed(
|
|
365
|
+
2
|
|
366
|
+
)} %` })
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
};
|
|
371
|
+
(0, import_vuu_utils8.registerComponent)("vuu.pct-progress", PctProgressCell, "cell-renderer", {
|
|
372
|
+
description: "Percentage formatter",
|
|
373
|
+
label: "Percentage formatter",
|
|
374
|
+
serverDataType: "double"
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// src/cell-renderers/progress-cell/ProgressCell.tsx
|
|
378
|
+
var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
|
|
379
|
+
var import_clsx3 = __toESM(require("clsx"), 1);
|
|
380
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
381
|
+
var classBase5 = "vuuProgressCell";
|
|
382
|
+
var ProgressCell = ({ column, columnMap, row }) => {
|
|
383
|
+
const { name: name2, type } = column;
|
|
384
|
+
const value = row[columnMap[name2]];
|
|
385
|
+
let showProgress = false;
|
|
386
|
+
let percentage = 0;
|
|
387
|
+
if ((0, import_vuu_utils9.isTypeDescriptor)(type) && (0, import_vuu_utils9.isColumnTypeRenderer)(type.renderer)) {
|
|
388
|
+
const { associatedField } = type.renderer;
|
|
389
|
+
if (associatedField) {
|
|
390
|
+
const associatedValue = row[columnMap[associatedField]];
|
|
391
|
+
if ((0, import_vuu_utils9.isValidNumber)(value) && (0, import_vuu_utils9.isValidNumber)(associatedValue)) {
|
|
392
|
+
percentage = Math.min(Math.round(value / associatedValue * 100), 100);
|
|
393
|
+
percentage = Math.min(Math.round(value / associatedValue * 100), 100);
|
|
394
|
+
showProgress = isFinite(percentage);
|
|
395
|
+
} else {
|
|
396
|
+
const floatValue = parseFloat(value);
|
|
397
|
+
if (Number.isFinite(floatValue)) {
|
|
398
|
+
const floatOtherValue = parseFloat(associatedValue);
|
|
399
|
+
if (Number.isFinite(floatOtherValue)) {
|
|
400
|
+
percentage = Math.min(
|
|
401
|
+
Math.round(floatValue / floatOtherValue * 100),
|
|
402
|
+
100
|
|
403
|
+
);
|
|
404
|
+
showProgress = isFinite(percentage);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
throw Error("ProgressCell associatedField is required to render");
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const className = (0, import_clsx3.default)(classBase5, {});
|
|
413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className, tabIndex: -1, children: [
|
|
414
|
+
showProgress ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: `${classBase5}-track`, children: [
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `${classBase5}-bg` }),
|
|
416
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
417
|
+
"span",
|
|
418
|
+
{
|
|
419
|
+
className: `${classBase5}-bar`,
|
|
420
|
+
style: { "--progress-bar-pct": `-${100 - percentage}%` }
|
|
421
|
+
}
|
|
422
|
+
)
|
|
423
|
+
] }) : null,
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `${classBase5}-text`, children: `${percentage} %` })
|
|
425
|
+
] });
|
|
426
|
+
};
|
|
427
|
+
(0, import_vuu_utils9.registerComponent)("vuu.progress", ProgressCell, "cell-renderer", {
|
|
428
|
+
description: "Progress formatter",
|
|
429
|
+
label: "Progress formatter",
|
|
430
|
+
serverDataType: ["long", "int", "double"],
|
|
431
|
+
// Not until we provide settings for associaetd field
|
|
432
|
+
userCanAssign: false
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// src/column-list/ColumnList.tsx
|
|
436
|
+
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
437
|
+
var import_core2 = require("@salt-ds/core");
|
|
438
|
+
var import_clsx4 = __toESM(require("clsx"), 1);
|
|
439
|
+
var import_react6 = require("react");
|
|
440
|
+
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
441
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
442
|
+
var classBase6 = "vuuColumnList";
|
|
443
|
+
var classBaseListItem = "vuuColumnListItem";
|
|
444
|
+
var ColumnListItem = ({
|
|
445
|
+
className: classNameProp,
|
|
446
|
+
item,
|
|
447
|
+
...listItemProps
|
|
448
|
+
}) => {
|
|
449
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
450
|
+
import_vuu_ui_controls3.ListItem,
|
|
451
|
+
{
|
|
452
|
+
...listItemProps,
|
|
453
|
+
className: (0, import_clsx4.default)(classNameProp, classBaseListItem),
|
|
454
|
+
"data-name": item == null ? void 0 : item.name,
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_vuu_ui_controls3.Icon, { name: "draggable", size: 16 }),
|
|
457
|
+
(item == null ? void 0 : item.isCalculated) ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_vuu_ui_controls3.Icon, { name: "function" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
458
|
+
import_core2.Checkbox,
|
|
459
|
+
{
|
|
460
|
+
className: `${classBase6}-checkBox`,
|
|
461
|
+
checked: item == null ? void 0 : item.subscribed
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `${classBase6}-text`, children: (0, import_vuu_utils10.getColumnLabel)(item) }),
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
466
|
+
import_core2.Switch,
|
|
467
|
+
{
|
|
468
|
+
className: `${classBase6}-switch`,
|
|
469
|
+
checked: (item == null ? void 0 : item.hidden) !== true,
|
|
470
|
+
disabled: (item == null ? void 0 : item.subscribed) !== true
|
|
471
|
+
}
|
|
472
|
+
)
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
};
|
|
477
|
+
var ColumnList = ({
|
|
478
|
+
columnItems,
|
|
479
|
+
onChange,
|
|
480
|
+
onMoveListItem,
|
|
481
|
+
onNavigateToColumn,
|
|
482
|
+
...htmlAttributes
|
|
483
|
+
}) => {
|
|
484
|
+
const handleChange = (0, import_react6.useCallback)(
|
|
485
|
+
({ target }) => {
|
|
486
|
+
const input = target;
|
|
487
|
+
const listItem = (0, import_vuu_utils10.queryClosest)(target, `.${classBaseListItem}`);
|
|
488
|
+
if (listItem) {
|
|
489
|
+
const {
|
|
490
|
+
dataset: { name: name2 }
|
|
491
|
+
} = listItem;
|
|
492
|
+
if (name2) {
|
|
493
|
+
const saltCheckbox = (0, import_vuu_utils10.queryClosest)(target, `.${classBase6}-checkBox`);
|
|
494
|
+
const saltSwitch = (0, import_vuu_utils10.queryClosest)(target, `.${classBase6}-switch`);
|
|
495
|
+
if (saltCheckbox) {
|
|
496
|
+
onChange(name2, "subscribed", input.checked);
|
|
497
|
+
} else if (saltSwitch) {
|
|
498
|
+
onChange(name2, "hidden", input.checked === false);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
[onChange]
|
|
504
|
+
);
|
|
505
|
+
const handleClick = (0, import_react6.useCallback)((evt) => {
|
|
506
|
+
const targetEl = evt.target;
|
|
507
|
+
if (targetEl.classList.contains("vuuColumnList-text")) {
|
|
508
|
+
const listItemEl = targetEl.closest(".vuuListItem");
|
|
509
|
+
if (listItemEl == null ? void 0 : listItemEl.dataset.name) {
|
|
510
|
+
onNavigateToColumn == null ? void 0 : onNavigateToColumn(listItemEl.dataset.name);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}, []);
|
|
514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { ...htmlAttributes, className: classBase6, children: [
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `${classBase6}-header`, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Column Selection" }) }),
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `${classBase6}-colHeadings`, children: [
|
|
517
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Column subscription" }),
|
|
518
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Visibility" })
|
|
519
|
+
] }),
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
521
|
+
import_vuu_ui_controls3.List,
|
|
522
|
+
{
|
|
523
|
+
ListItem: ColumnListItem,
|
|
524
|
+
allowDragDrop: true,
|
|
525
|
+
height: "auto",
|
|
526
|
+
onChange: handleChange,
|
|
527
|
+
onClick: handleClick,
|
|
528
|
+
onMoveListItem,
|
|
529
|
+
selectionStrategy: "none",
|
|
530
|
+
source: columnItems,
|
|
531
|
+
itemHeight: 33
|
|
532
|
+
}
|
|
533
|
+
)
|
|
534
|
+
] });
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// src/column-settings/ColumnSettingsPanel.tsx
|
|
538
|
+
var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
|
|
539
|
+
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
540
|
+
var import_core8 = require("@salt-ds/core");
|
|
541
|
+
var import_clsx7 = __toESM(require("clsx"), 1);
|
|
542
|
+
|
|
543
|
+
// src/column-expression-panel/ColumnExpressionPanel.tsx
|
|
544
|
+
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
545
|
+
var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
|
|
546
|
+
var import_core3 = require("@salt-ds/core");
|
|
547
|
+
var import_react12 = require("react");
|
|
548
|
+
|
|
549
|
+
// src/column-expression-input/ColumnExpressionInput.tsx
|
|
550
|
+
var import_react9 = require("react");
|
|
551
|
+
|
|
552
|
+
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
553
|
+
var import_vuu_codemirror5 = require("@vuu-ui/vuu-codemirror");
|
|
554
|
+
var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
|
|
555
|
+
var import_react8 = require("react");
|
|
556
|
+
|
|
557
|
+
// src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
|
|
558
|
+
var import_vuu_codemirror = require("@vuu-ui/vuu-codemirror");
|
|
559
|
+
|
|
560
|
+
// src/column-expression-input/column-language-parser/generated/column-parser.js
|
|
561
|
+
var import_lr = require("@lezer/lr");
|
|
562
|
+
var parser = import_lr.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 = import_vuu_codemirror.LRLanguage.define({
|
|
579
|
+
name: "VuuColumnExpression",
|
|
580
|
+
parser: parser.configure({
|
|
581
|
+
props: [
|
|
582
|
+
(0, import_vuu_codemirror.styleTags)({
|
|
583
|
+
Column: import_vuu_codemirror.tags.attributeValue,
|
|
584
|
+
Function: import_vuu_codemirror.tags.variableName,
|
|
585
|
+
String: import_vuu_codemirror.tags.string,
|
|
586
|
+
Or: import_vuu_codemirror.tags.emphasis,
|
|
587
|
+
Operator: import_vuu_codemirror.tags.operator
|
|
588
|
+
})
|
|
589
|
+
]
|
|
590
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
591
|
+
})
|
|
592
|
+
});
|
|
593
|
+
var columnExpressionLanguageSupport = () => {
|
|
594
|
+
return new import_vuu_codemirror.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
|
+
var import_vuu_codemirror2 = require("@vuu-ui/vuu-codemirror");
|
|
1117
|
+
var myHighlightStyle = import_vuu_codemirror2.HighlightStyle.define([
|
|
1118
|
+
{
|
|
1119
|
+
tag: import_vuu_codemirror2.tags.attributeValue,
|
|
1120
|
+
color: "var(--vuuFilterEditor-variableColor);font-weight: bold"
|
|
1121
|
+
},
|
|
1122
|
+
{ tag: import_vuu_codemirror2.tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
|
|
1123
|
+
{ tag: import_vuu_codemirror2.tags.comment, color: "green", fontStyle: "italic" }
|
|
1124
|
+
]);
|
|
1125
|
+
var vuuHighlighting = (0, import_vuu_codemirror2.syntaxHighlighting)(myHighlightStyle);
|
|
1126
|
+
|
|
1127
|
+
// src/column-expression-input/theme.ts
|
|
1128
|
+
var import_vuu_codemirror3 = require("@vuu-ui/vuu-codemirror");
|
|
1129
|
+
var vuuTheme = import_vuu_codemirror3.EditorView.theme(
|
|
1130
|
+
{
|
|
1131
|
+
"&": {
|
|
1132
|
+
border: "solid 1px var(--salt-container-primary-borderColor)",
|
|
1133
|
+
color: "var(--vuuFilterEditor-color)",
|
|
1134
|
+
backgroundColor: "var(--vuuFilterEditor-background)"
|
|
1135
|
+
},
|
|
1136
|
+
".cm-content": {
|
|
1137
|
+
caretColor: "var(--vuuFilterEditor-cursorColor)"
|
|
1138
|
+
},
|
|
1139
|
+
"&.cm-focused .cm-cursor": {
|
|
1140
|
+
borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
|
|
1141
|
+
},
|
|
1142
|
+
"&.cm-focused .cm-selectionBackground, ::selection": {
|
|
1143
|
+
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
1144
|
+
},
|
|
1145
|
+
".cm-selectionBackground, ::selection": {
|
|
1146
|
+
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
1147
|
+
},
|
|
1148
|
+
".cm-scroller": {
|
|
1149
|
+
fontFamily: "var(--vuuFilterEditor-fontFamily)"
|
|
1150
|
+
},
|
|
1151
|
+
".cm-completionLabel": {
|
|
1152
|
+
color: "var(--vuu-color-gray-50)"
|
|
1153
|
+
},
|
|
1154
|
+
".cm-completionMatchedText": {
|
|
1155
|
+
color: "var(--vuu-color-gray-80)",
|
|
1156
|
+
fontWeight: 700,
|
|
1157
|
+
textDecoration: "none"
|
|
1158
|
+
},
|
|
1159
|
+
".cm-tooltip": {
|
|
1160
|
+
background: "var(--vuuFilterEditor-tooltipBackground)",
|
|
1161
|
+
border: "var(--vuuFilterEditor-tooltipBorder)",
|
|
1162
|
+
borderRadius: "4px",
|
|
1163
|
+
boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
|
|
1164
|
+
"&.cm-tooltip-autocomplete > ul": {
|
|
1165
|
+
fontFamily: "var(--vuuFilterEditor-fontFamily)",
|
|
1166
|
+
fontSize: "var(--vuuFilterEditor-fontSize)",
|
|
1167
|
+
maxHeight: "240px"
|
|
1168
|
+
},
|
|
1169
|
+
"&.cm-tooltip-autocomplete > ul > li": {
|
|
1170
|
+
height: "var(--vuuFilterEditor-suggestion-height)",
|
|
1171
|
+
padding: "0 3px",
|
|
1172
|
+
lineHeight: "var(--vuuFilterEditor-suggestion-height)"
|
|
1173
|
+
},
|
|
1174
|
+
"&.cm-tooltip-autocomplete li[aria-selected]": {
|
|
1175
|
+
background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
|
|
1176
|
+
color: "var(--vuuFilterEditor-suggestion-selectedColor)"
|
|
1177
|
+
},
|
|
1178
|
+
"&.cm-tooltip-autocomplete li .cm-completionDetail": {
|
|
1179
|
+
color: "var(--vuuFilterEditor-suggestion-detailColor)"
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
},
|
|
1183
|
+
{ dark: false }
|
|
1184
|
+
);
|
|
1185
|
+
|
|
1186
|
+
// src/column-expression-input/useColumnAutoComplete.ts
|
|
1187
|
+
var import_vuu_codemirror4 = require("@vuu-ui/vuu-codemirror");
|
|
1188
|
+
var import_react7 = require("react");
|
|
1189
|
+
var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
|
|
1190
|
+
var _a;
|
|
1191
|
+
return {
|
|
1192
|
+
...completion,
|
|
1193
|
+
apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
|
|
1194
|
+
};
|
|
1195
|
+
}) : completions;
|
|
1196
|
+
var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
|
|
1197
|
+
var completionDone = (onSubmit) => ({
|
|
1198
|
+
apply: () => {
|
|
1199
|
+
onSubmit == null ? void 0 : onSubmit();
|
|
1200
|
+
},
|
|
1201
|
+
label: "Done",
|
|
1202
|
+
boost: 10
|
|
1203
|
+
});
|
|
1204
|
+
var getLastChild = (node, context) => {
|
|
1205
|
+
var _a;
|
|
1206
|
+
let { lastChild: childNode } = node;
|
|
1207
|
+
const { pos } = context;
|
|
1208
|
+
while (childNode) {
|
|
1209
|
+
const isBeforeCursor = childNode.from < pos;
|
|
1210
|
+
if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
|
|
1211
|
+
if (childNode.name === "ParenthesizedExpression") {
|
|
1212
|
+
const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
|
|
1213
|
+
if (expression) {
|
|
1214
|
+
childNode = expression;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
return childNode;
|
|
1218
|
+
} else {
|
|
1219
|
+
childNode = childNode.prevSibling;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
var getFunctionName = (node, state) => {
|
|
1224
|
+
var _a;
|
|
1225
|
+
if (node.name === "ArgList") {
|
|
1226
|
+
const functionNode = node.prevSibling;
|
|
1227
|
+
if (functionNode) {
|
|
1228
|
+
return (0, import_vuu_codemirror4.getValue)(functionNode, state);
|
|
1229
|
+
}
|
|
1230
|
+
} else if (node.name === "OpenBrace") {
|
|
1231
|
+
const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
|
|
1232
|
+
if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
|
|
1233
|
+
return (0, import_vuu_codemirror4.getValue)(maybeFunction, state);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
var getRelationalOperator = (node, state) => {
|
|
1238
|
+
if (node.name === "RelationalExpression") {
|
|
1239
|
+
const lastNode = lastNamedChild(node);
|
|
1240
|
+
if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
|
|
1241
|
+
return (0, import_vuu_codemirror4.getValue)(lastNode, state);
|
|
1242
|
+
}
|
|
1243
|
+
} else {
|
|
1244
|
+
const prevNode = node.prevSibling;
|
|
1245
|
+
if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
1246
|
+
return (0, import_vuu_codemirror4.getValue)(prevNode, state);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
var getColumnName = (node, state) => {
|
|
1251
|
+
var _a;
|
|
1252
|
+
if (node.name === "RelationalExpression") {
|
|
1253
|
+
if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
|
|
1254
|
+
return (0, import_vuu_codemirror4.getValue)(node.firstChild, state);
|
|
1255
|
+
}
|
|
1256
|
+
} else {
|
|
1257
|
+
const prevNode = node.prevSibling;
|
|
1258
|
+
if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
|
|
1259
|
+
return (0, import_vuu_codemirror4.getValue)(prevNode, state);
|
|
1260
|
+
} else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
1261
|
+
return getColumnName(prevNode, state);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
|
|
1266
|
+
const options = await suggestionProvider.getSuggestions(
|
|
1267
|
+
suggestionType,
|
|
1268
|
+
optionalArgs
|
|
1269
|
+
);
|
|
1270
|
+
const { startsWith = "" } = optionalArgs;
|
|
1271
|
+
return { from: context.pos - startsWith.length, options };
|
|
1272
|
+
};
|
|
1273
|
+
var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
|
|
1274
|
+
const lastChild = getLastChild(node, context);
|
|
1275
|
+
switch (lastChild == null ? void 0 : lastChild.name) {
|
|
1276
|
+
case "If":
|
|
1277
|
+
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
1278
|
+
prefix: "( "
|
|
1279
|
+
});
|
|
1280
|
+
case "OpenBrace":
|
|
1281
|
+
return makeSuggestions(context, suggestionProvider, "expression");
|
|
1282
|
+
case "Condition":
|
|
1283
|
+
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
1284
|
+
prefix: ", "
|
|
1285
|
+
});
|
|
1286
|
+
case "CloseBrace":
|
|
1287
|
+
if (maybeComplete) {
|
|
1288
|
+
const options = [completionDone(onSubmit)];
|
|
1289
|
+
return { from: context.pos, options };
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
var promptToSave = (context, onSubmit) => {
|
|
1294
|
+
const options = [completionDone(onSubmit)];
|
|
1295
|
+
return { from: context.pos, options };
|
|
1296
|
+
};
|
|
1297
|
+
var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
|
|
1298
|
+
const makeSuggestions2 = (0, import_react7.useCallback)(
|
|
1299
|
+
async (context, suggestionType, optionalArgs = {}) => {
|
|
1300
|
+
const options = await suggestionProvider.getSuggestions(
|
|
1301
|
+
suggestionType,
|
|
1302
|
+
optionalArgs
|
|
1303
|
+
);
|
|
1304
|
+
const { startsWith = "" } = optionalArgs;
|
|
1305
|
+
return { from: context.pos - startsWith.length, options };
|
|
1306
|
+
},
|
|
1307
|
+
[suggestionProvider]
|
|
1308
|
+
);
|
|
1309
|
+
return (0, import_react7.useCallback)(
|
|
1310
|
+
async (context) => {
|
|
1311
|
+
var _a, _b;
|
|
1312
|
+
const { state, pos } = context;
|
|
1313
|
+
const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
|
|
1314
|
+
from: 0,
|
|
1315
|
+
to: 0,
|
|
1316
|
+
text: void 0
|
|
1317
|
+
};
|
|
1318
|
+
const tree = (0, import_vuu_codemirror4.syntaxTree)(state);
|
|
1319
|
+
const nodeBefore = tree.resolveInner(pos, -1);
|
|
1320
|
+
const text = state.doc.toString();
|
|
1321
|
+
const maybeComplete = isCompleteExpression(text);
|
|
1322
|
+
switch (nodeBefore.name) {
|
|
1323
|
+
case "If": {
|
|
1324
|
+
return makeSuggestions2(context, "expression", { prefix: "( " });
|
|
1325
|
+
}
|
|
1326
|
+
case "Condition":
|
|
1327
|
+
{
|
|
1328
|
+
const lastChild = getLastChild(nodeBefore, context);
|
|
1329
|
+
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1330
|
+
const prevChild = (0, import_vuu_codemirror4.getPreviousNode)(lastChild);
|
|
1331
|
+
if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
|
|
1332
|
+
return makeSuggestions2(context, "condition-operator", {
|
|
1333
|
+
columnName: (0, import_vuu_codemirror4.getValue)(lastChild, state)
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
|
|
1337
|
+
return makeSuggestions2(context, "expression");
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
break;
|
|
1341
|
+
case "ConditionalExpression":
|
|
1342
|
+
return handleConditionalExpression(
|
|
1343
|
+
nodeBefore,
|
|
1344
|
+
context,
|
|
1345
|
+
suggestionProvider
|
|
1346
|
+
);
|
|
1347
|
+
case "RelationalExpression":
|
|
1348
|
+
{
|
|
1349
|
+
if (isCompleteRelationalExpression(nodeBefore)) {
|
|
1350
|
+
return {
|
|
1351
|
+
from: context.pos,
|
|
1352
|
+
options: import_vuu_codemirror4.booleanJoinSuggestions.concat({
|
|
1353
|
+
label: ", <truthy expression>, <falsy expression>",
|
|
1354
|
+
apply: ", "
|
|
1355
|
+
})
|
|
1356
|
+
};
|
|
1357
|
+
} else {
|
|
1358
|
+
const operator = getRelationalOperator(nodeBefore, state);
|
|
1359
|
+
const columnName = getColumnName(nodeBefore, state);
|
|
1360
|
+
if (!operator) {
|
|
1361
|
+
const options = await suggestionProvider.getSuggestions(
|
|
1362
|
+
"condition-operator",
|
|
1363
|
+
{
|
|
1364
|
+
columnName
|
|
1365
|
+
}
|
|
1366
|
+
);
|
|
1367
|
+
return { from: context.pos, options };
|
|
1368
|
+
} else {
|
|
1369
|
+
return makeSuggestions2(context, "expression");
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
break;
|
|
1374
|
+
case "RelationalOperator":
|
|
1375
|
+
return makeSuggestions2(context, "expression");
|
|
1376
|
+
case "String":
|
|
1377
|
+
{
|
|
1378
|
+
const operator = getRelationalOperator(
|
|
1379
|
+
nodeBefore,
|
|
1380
|
+
state
|
|
1381
|
+
);
|
|
1382
|
+
const columnName = getColumnName(nodeBefore, state);
|
|
1383
|
+
const { from, to } = nodeBefore;
|
|
1384
|
+
if (to - from === 2 && context.pos === from + 1) {
|
|
1385
|
+
if (columnName && operator) {
|
|
1386
|
+
return makeSuggestions2(context, "columnValue", {
|
|
1387
|
+
columnName,
|
|
1388
|
+
operator,
|
|
1389
|
+
startsWith: word.text
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
} else if (to - from > 2 && context.pos === to) {
|
|
1393
|
+
return makeSuggestions2(context, "expression", {
|
|
1394
|
+
prefix: ", "
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
break;
|
|
1399
|
+
case "ArithmeticExpression":
|
|
1400
|
+
{
|
|
1401
|
+
const lastChild = getLastChild(nodeBefore, context);
|
|
1402
|
+
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1403
|
+
return makeSuggestions2(context, "expression");
|
|
1404
|
+
} else if (isOperator(lastChild)) {
|
|
1405
|
+
const operator = lastChild.name;
|
|
1406
|
+
return makeSuggestions2(context, "column", { operator });
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
break;
|
|
1410
|
+
case "OpenBrace":
|
|
1411
|
+
{
|
|
1412
|
+
const functionName = getFunctionName(nodeBefore, state);
|
|
1413
|
+
return makeSuggestions2(context, "expression", { functionName });
|
|
1414
|
+
}
|
|
1415
|
+
break;
|
|
1416
|
+
case "ArgList": {
|
|
1417
|
+
const functionName = getFunctionName(nodeBefore, state);
|
|
1418
|
+
const lastArgument = getLastChild(nodeBefore, context);
|
|
1419
|
+
const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" || (lastArgument == null ? void 0 : lastArgument.name) === "Comma" ? void 0 : ",";
|
|
1420
|
+
let options = await suggestionProvider.getSuggestions("expression", {
|
|
1421
|
+
functionName
|
|
1422
|
+
});
|
|
1423
|
+
options = prefix ? applyPrefix(options, ", ") : options;
|
|
1424
|
+
if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
|
|
1425
|
+
options = [
|
|
1426
|
+
{
|
|
1427
|
+
apply: ") ",
|
|
1428
|
+
boost: 10,
|
|
1429
|
+
label: "Done - no more arguments"
|
|
1430
|
+
}
|
|
1431
|
+
].concat(options);
|
|
1432
|
+
}
|
|
1433
|
+
return { from: context.pos, options };
|
|
1434
|
+
}
|
|
1435
|
+
case "Equal":
|
|
1436
|
+
if (text.trim() === "=") {
|
|
1437
|
+
return makeSuggestions2(context, "expression");
|
|
1438
|
+
}
|
|
1439
|
+
break;
|
|
1440
|
+
case "ParenthesizedExpression":
|
|
1441
|
+
case "ColumnDefinitionExpression":
|
|
1442
|
+
if (context.pos === 0) {
|
|
1443
|
+
return makeSuggestions2(context, "expression");
|
|
1444
|
+
} else {
|
|
1445
|
+
const lastChild = getLastChild(nodeBefore, context);
|
|
1446
|
+
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1447
|
+
if (maybeComplete) {
|
|
1448
|
+
const options = [
|
|
1449
|
+
completionDone(onSubmit.current)
|
|
1450
|
+
];
|
|
1451
|
+
const columnName = (0, import_vuu_codemirror4.getValue)(lastChild, state);
|
|
1452
|
+
const columnOptions = await suggestionProvider.getSuggestions("operator", {
|
|
1453
|
+
columnName
|
|
1454
|
+
});
|
|
1455
|
+
return {
|
|
1456
|
+
from: context.pos,
|
|
1457
|
+
options: options.concat(columnOptions)
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
|
|
1461
|
+
if (maybeComplete) {
|
|
1462
|
+
return {
|
|
1463
|
+
from: context.pos,
|
|
1464
|
+
options: [completionDone(onSubmit.current)]
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
|
|
1468
|
+
if (maybeComplete) {
|
|
1469
|
+
let options = [completionDone(onSubmit.current)];
|
|
1470
|
+
const lastExpressionChild = getLastChild(lastChild, context);
|
|
1471
|
+
if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
|
|
1472
|
+
const columnName = (0, import_vuu_codemirror4.getValue)(lastExpressionChild, state);
|
|
1473
|
+
const suggestions = await suggestionProvider.getSuggestions(
|
|
1474
|
+
"operator",
|
|
1475
|
+
{ columnName }
|
|
1476
|
+
);
|
|
1477
|
+
options = options.concat(suggestions);
|
|
1478
|
+
}
|
|
1479
|
+
return {
|
|
1480
|
+
from: context.pos,
|
|
1481
|
+
options
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
|
|
1485
|
+
return handleConditionalExpression(
|
|
1486
|
+
lastChild,
|
|
1487
|
+
context,
|
|
1488
|
+
suggestionProvider,
|
|
1489
|
+
maybeComplete,
|
|
1490
|
+
onSubmit.current
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
break;
|
|
1494
|
+
}
|
|
1495
|
+
case "Column":
|
|
1496
|
+
{
|
|
1497
|
+
const isPartialMatch = await suggestionProvider.isPartialMatch(
|
|
1498
|
+
"expression",
|
|
1499
|
+
void 0,
|
|
1500
|
+
word.text
|
|
1501
|
+
);
|
|
1502
|
+
if (isPartialMatch) {
|
|
1503
|
+
return makeSuggestions2(context, "expression", {
|
|
1504
|
+
startsWith: word.text
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
break;
|
|
1509
|
+
case "Comma":
|
|
1510
|
+
{
|
|
1511
|
+
const parentNode = (0, import_vuu_codemirror4.getNamedParentNode)(nodeBefore);
|
|
1512
|
+
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1513
|
+
return makeSuggestions2(context, "expression");
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
break;
|
|
1517
|
+
case "CloseBrace":
|
|
1518
|
+
{
|
|
1519
|
+
const parentNode = (0, import_vuu_codemirror4.getNamedParentNode)(nodeBefore);
|
|
1520
|
+
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1521
|
+
return handleConditionalExpression(
|
|
1522
|
+
parentNode,
|
|
1523
|
+
context,
|
|
1524
|
+
suggestionProvider,
|
|
1525
|
+
maybeComplete,
|
|
1526
|
+
onSubmit.current
|
|
1527
|
+
);
|
|
1528
|
+
} else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
|
|
1529
|
+
if (maybeComplete) {
|
|
1530
|
+
return promptToSave(context, onSubmit.current);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
break;
|
|
1535
|
+
default: {
|
|
1536
|
+
if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
|
|
1537
|
+
console.log("looks like we ight be a or|and operator");
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
},
|
|
1542
|
+
[makeSuggestions2, onSubmit, suggestionProvider]
|
|
1543
|
+
);
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
1547
|
+
var getView = (ref) => {
|
|
1548
|
+
if (ref.current == void 0) {
|
|
1549
|
+
throw Error("EditorView not defined");
|
|
1550
|
+
}
|
|
1551
|
+
return ref.current;
|
|
1552
|
+
};
|
|
1553
|
+
var getOptionClass = () => {
|
|
1554
|
+
return "vuuSuggestion";
|
|
1555
|
+
};
|
|
1556
|
+
var noop = () => console.log("noooop");
|
|
1557
|
+
var hasExpressionType = (completion) => "expressionType" in completion;
|
|
1558
|
+
var injectOptionContent = (completion) => {
|
|
1559
|
+
if (hasExpressionType(completion)) {
|
|
1560
|
+
const div = (0, import_vuu_utils11.createEl)("div", "expression-type-container");
|
|
1561
|
+
const span = (0, import_vuu_utils11.createEl)("span", "expression-type", completion.expressionType);
|
|
1562
|
+
div.appendChild(span);
|
|
1563
|
+
return div;
|
|
1564
|
+
} else {
|
|
1565
|
+
return null;
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
var useColumnExpressionEditor = ({
|
|
1569
|
+
onChange,
|
|
1570
|
+
onSubmitExpression,
|
|
1571
|
+
source,
|
|
1572
|
+
suggestionProvider
|
|
1573
|
+
}) => {
|
|
1574
|
+
const editorRef = (0, import_react8.useRef)(null);
|
|
1575
|
+
const onSubmitRef = (0, import_react8.useRef)(noop);
|
|
1576
|
+
const viewRef = (0, import_react8.useRef)();
|
|
1577
|
+
const completionFn = useColumnAutoComplete(suggestionProvider, onSubmitRef);
|
|
1578
|
+
const [createState, clearInput, submit] = (0, import_react8.useMemo)(() => {
|
|
1579
|
+
const parseExpression = () => {
|
|
1580
|
+
const view = getView(viewRef);
|
|
1581
|
+
const source2 = view.state.doc.toString();
|
|
1582
|
+
const tree = (0, import_vuu_codemirror5.ensureSyntaxTree)(view.state, view.state.doc.length, 5e3);
|
|
1583
|
+
if (tree) {
|
|
1584
|
+
const expression = walkTree(tree, source2);
|
|
1585
|
+
return [source2, expression];
|
|
1586
|
+
} else {
|
|
1587
|
+
return ["", void 0];
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
const clearInput2 = () => {
|
|
1591
|
+
getView(viewRef).setState(createState2());
|
|
1592
|
+
};
|
|
1593
|
+
const submitExpression = () => {
|
|
1594
|
+
const [source2, expression] = parseExpression();
|
|
1595
|
+
onSubmitExpression == null ? void 0 : onSubmitExpression(source2, expression);
|
|
1596
|
+
};
|
|
1597
|
+
const showSuggestions = (key) => {
|
|
1598
|
+
return import_vuu_codemirror5.keymap.of([
|
|
1599
|
+
{
|
|
1600
|
+
key,
|
|
1601
|
+
run() {
|
|
1602
|
+
(0, import_vuu_codemirror5.startCompletion)(getView(viewRef));
|
|
1603
|
+
return true;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
]);
|
|
1607
|
+
};
|
|
1608
|
+
const createState2 = () => import_vuu_codemirror5.EditorState.create({
|
|
1609
|
+
doc: source,
|
|
1610
|
+
extensions: [
|
|
1611
|
+
import_vuu_codemirror5.minimalSetup,
|
|
1612
|
+
(0, import_vuu_codemirror5.autocompletion)({
|
|
1613
|
+
addToOptions: [
|
|
1614
|
+
{
|
|
1615
|
+
render: injectOptionContent,
|
|
1616
|
+
position: 70
|
|
1617
|
+
}
|
|
1618
|
+
],
|
|
1619
|
+
override: [completionFn],
|
|
1620
|
+
optionClass: getOptionClass
|
|
1621
|
+
}),
|
|
1622
|
+
columnExpressionLanguageSupport(),
|
|
1623
|
+
import_vuu_codemirror5.keymap.of(import_vuu_codemirror5.defaultKeymap),
|
|
1624
|
+
showSuggestions("ArrowDown"),
|
|
1625
|
+
import_vuu_codemirror5.EditorView.updateListener.of((v) => {
|
|
1626
|
+
const view = getView(viewRef);
|
|
1627
|
+
if (v.docChanged) {
|
|
1628
|
+
(0, import_vuu_codemirror5.startCompletion)(view);
|
|
1629
|
+
const source2 = view.state.doc.toString();
|
|
1630
|
+
onChange == null ? void 0 : onChange(source2);
|
|
1631
|
+
}
|
|
1632
|
+
}),
|
|
1633
|
+
// Enforces single line view
|
|
1634
|
+
import_vuu_codemirror5.EditorState.transactionFilter.of(
|
|
1635
|
+
(tr) => tr.newDoc.lines > 1 ? [] : tr
|
|
1636
|
+
),
|
|
1637
|
+
vuuTheme,
|
|
1638
|
+
vuuHighlighting
|
|
1639
|
+
]
|
|
1640
|
+
});
|
|
1641
|
+
onSubmitRef.current = () => {
|
|
1642
|
+
submitExpression();
|
|
1643
|
+
};
|
|
1644
|
+
return [createState2, clearInput2, submitExpression];
|
|
1645
|
+
}, [completionFn, onChange, onSubmitExpression, source]);
|
|
1646
|
+
(0, import_react8.useEffect)(() => {
|
|
1647
|
+
if (!editorRef.current) {
|
|
1648
|
+
throw Error("editor not in dom");
|
|
1649
|
+
}
|
|
1650
|
+
viewRef.current = new import_vuu_codemirror5.EditorView({
|
|
1651
|
+
state: createState(),
|
|
1652
|
+
parent: editorRef.current
|
|
1653
|
+
});
|
|
1654
|
+
return () => {
|
|
1655
|
+
var _a;
|
|
1656
|
+
(_a = viewRef.current) == null ? void 0 : _a.destroy();
|
|
1657
|
+
};
|
|
1658
|
+
}, [completionFn, createState]);
|
|
1659
|
+
const handleBlur = (0, import_react8.useCallback)(() => {
|
|
1660
|
+
submit();
|
|
1661
|
+
}, [submit]);
|
|
1662
|
+
return { editorRef, clearInput, onBlur: handleBlur };
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1665
|
+
// src/column-expression-input/ColumnExpressionInput.tsx
|
|
1666
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1667
|
+
var classBase7 = "vuuColumnExpressionInput";
|
|
1668
|
+
var ColumnExpressionInput = (0, import_react9.memo)(
|
|
1669
|
+
({
|
|
1670
|
+
onChange,
|
|
1671
|
+
onSubmitExpression,
|
|
1672
|
+
source = "",
|
|
1673
|
+
suggestionProvider
|
|
1674
|
+
}) => {
|
|
1675
|
+
const { editorRef, onBlur } = useColumnExpressionEditor({
|
|
1676
|
+
onChange,
|
|
1677
|
+
onSubmitExpression,
|
|
1678
|
+
source,
|
|
1679
|
+
suggestionProvider
|
|
1680
|
+
});
|
|
1681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `${classBase7}`, onBlur, ref: editorRef });
|
|
1682
|
+
},
|
|
1683
|
+
(prevProps, newProps) => {
|
|
1684
|
+
return prevProps.source === newProps.source;
|
|
1685
|
+
}
|
|
1686
|
+
);
|
|
1687
|
+
ColumnExpressionInput.displayName = "ColumnExpressionInput";
|
|
1688
|
+
|
|
1689
|
+
// src/column-expression-input/useColumnExpressionSuggestionProvider.ts
|
|
1690
|
+
var import_vuu_codemirror6 = require("@vuu-ui/vuu-codemirror");
|
|
1691
|
+
var import_vuu_data_react3 = require("@vuu-ui/vuu-data-react");
|
|
1692
|
+
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
1693
|
+
var import_react10 = require("react");
|
|
1694
|
+
|
|
1695
|
+
// src/column-expression-input/column-function-descriptors.ts
|
|
1696
|
+
var columnFunctionDescriptors = [
|
|
1697
|
+
/**
|
|
1698
|
+
* and
|
|
1699
|
+
*/
|
|
1700
|
+
{
|
|
1701
|
+
accepts: ["boolean"],
|
|
1702
|
+
description: "Applies boolean and operator across supplied parameters to returns a single boolean result",
|
|
1703
|
+
example: {
|
|
1704
|
+
expression: 'and(ccy="EUR",quantity=0)',
|
|
1705
|
+
result: "true | false"
|
|
1706
|
+
},
|
|
1707
|
+
name: "and",
|
|
1708
|
+
params: {
|
|
1709
|
+
description: "( boolean, [ boolean* ] )"
|
|
1710
|
+
},
|
|
1711
|
+
type: "boolean"
|
|
1712
|
+
},
|
|
1713
|
+
/**
|
|
1714
|
+
* concatenate()
|
|
1715
|
+
*/
|
|
1716
|
+
{
|
|
1717
|
+
accepts: "string",
|
|
1718
|
+
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.",
|
|
1719
|
+
example: {
|
|
1720
|
+
expression: 'concatenate("example", "-test")',
|
|
1721
|
+
result: '"example-test"'
|
|
1722
|
+
},
|
|
1723
|
+
name: "concatenate",
|
|
1724
|
+
params: {
|
|
1725
|
+
description: "( string, string, [ string* ] )"
|
|
1726
|
+
},
|
|
1727
|
+
type: "string"
|
|
1728
|
+
},
|
|
1729
|
+
/**
|
|
1730
|
+
* contains()
|
|
1731
|
+
*/
|
|
1732
|
+
{
|
|
1733
|
+
accepts: ["string", "string"],
|
|
1734
|
+
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>",
|
|
1735
|
+
example: {
|
|
1736
|
+
expression: 'contains("Royal Bank of Scotland", "bank")',
|
|
1737
|
+
result: "true"
|
|
1738
|
+
},
|
|
1739
|
+
name: "contains",
|
|
1740
|
+
params: {
|
|
1741
|
+
description: "( string )"
|
|
1742
|
+
},
|
|
1743
|
+
type: "boolean"
|
|
1744
|
+
},
|
|
1745
|
+
/**
|
|
1746
|
+
* left()
|
|
1747
|
+
*/
|
|
1748
|
+
{
|
|
1749
|
+
accepts: ["string", "number"],
|
|
1750
|
+
description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
|
|
1751
|
+
example: {
|
|
1752
|
+
expression: 'left("USD Benchmark Report", 3)',
|
|
1753
|
+
result: '"USD"'
|
|
1754
|
+
},
|
|
1755
|
+
name: "left",
|
|
1756
|
+
params: {
|
|
1757
|
+
count: 2,
|
|
1758
|
+
description: "( string, number )"
|
|
1759
|
+
},
|
|
1760
|
+
type: "string"
|
|
1761
|
+
},
|
|
1762
|
+
/**
|
|
1763
|
+
* len()
|
|
1764
|
+
*/
|
|
1765
|
+
{
|
|
1766
|
+
accepts: "string",
|
|
1767
|
+
description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
|
|
1768
|
+
example: {
|
|
1769
|
+
expression: 'len("example")',
|
|
1770
|
+
result: "7"
|
|
1771
|
+
},
|
|
1772
|
+
name: "len",
|
|
1773
|
+
params: {
|
|
1774
|
+
description: "(string)"
|
|
1775
|
+
},
|
|
1776
|
+
type: "number"
|
|
1777
|
+
},
|
|
1778
|
+
/**
|
|
1779
|
+
* lower()
|
|
1780
|
+
*/
|
|
1781
|
+
{
|
|
1782
|
+
accepts: "string",
|
|
1783
|
+
description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
|
|
1784
|
+
example: {
|
|
1785
|
+
expression: 'lower("examPLE")',
|
|
1786
|
+
result: '"example"'
|
|
1787
|
+
},
|
|
1788
|
+
name: "lower",
|
|
1789
|
+
params: {
|
|
1790
|
+
description: "( string )"
|
|
1791
|
+
},
|
|
1792
|
+
type: "string"
|
|
1793
|
+
},
|
|
1794
|
+
/**
|
|
1795
|
+
* or
|
|
1796
|
+
*/
|
|
1797
|
+
{
|
|
1798
|
+
accepts: ["boolean"],
|
|
1799
|
+
description: "Applies boolean or operator across supplied parameters to returns a single boolean result",
|
|
1800
|
+
example: {
|
|
1801
|
+
expression: 'or(status="cancelled",quantity=0)',
|
|
1802
|
+
result: "true | false"
|
|
1803
|
+
},
|
|
1804
|
+
name: "or",
|
|
1805
|
+
params: {
|
|
1806
|
+
description: "( boolean, [ boolean* ] )"
|
|
1807
|
+
},
|
|
1808
|
+
type: "boolean"
|
|
1809
|
+
},
|
|
1810
|
+
/**
|
|
1811
|
+
* upper()
|
|
1812
|
+
*/
|
|
1813
|
+
{
|
|
1814
|
+
accepts: "string",
|
|
1815
|
+
description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
|
|
1816
|
+
example: {
|
|
1817
|
+
expression: 'upper("example")',
|
|
1818
|
+
result: '"EXAMPLE"'
|
|
1819
|
+
},
|
|
1820
|
+
name: "upper",
|
|
1821
|
+
params: {
|
|
1822
|
+
description: "( string )"
|
|
1823
|
+
},
|
|
1824
|
+
type: "string"
|
|
1825
|
+
},
|
|
1826
|
+
/**
|
|
1827
|
+
* right()
|
|
1828
|
+
*/
|
|
1829
|
+
{
|
|
1830
|
+
accepts: ["string", "number"],
|
|
1831
|
+
description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
|
|
1832
|
+
example: {
|
|
1833
|
+
expression: "blah",
|
|
1834
|
+
result: "blah"
|
|
1835
|
+
},
|
|
1836
|
+
name: "right",
|
|
1837
|
+
params: {
|
|
1838
|
+
description: "( string )"
|
|
1839
|
+
},
|
|
1840
|
+
type: "string"
|
|
1841
|
+
},
|
|
1842
|
+
/**
|
|
1843
|
+
* replace()
|
|
1844
|
+
*/
|
|
1845
|
+
{
|
|
1846
|
+
accepts: ["string", "string", "string"],
|
|
1847
|
+
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>",
|
|
1848
|
+
example: {
|
|
1849
|
+
expression: "blah",
|
|
1850
|
+
result: "blah"
|
|
1851
|
+
},
|
|
1852
|
+
name: "replace",
|
|
1853
|
+
params: {
|
|
1854
|
+
description: "( string )"
|
|
1855
|
+
},
|
|
1856
|
+
type: "string"
|
|
1857
|
+
},
|
|
1858
|
+
/**
|
|
1859
|
+
* text()
|
|
1860
|
+
*/
|
|
1861
|
+
{
|
|
1862
|
+
accepts: "number",
|
|
1863
|
+
description: "Converts a number to a string.",
|
|
1864
|
+
example: {
|
|
1865
|
+
expression: "blah",
|
|
1866
|
+
result: "blah"
|
|
1867
|
+
},
|
|
1868
|
+
name: "text",
|
|
1869
|
+
params: {
|
|
1870
|
+
description: "( string )"
|
|
1871
|
+
},
|
|
1872
|
+
type: "string"
|
|
1873
|
+
},
|
|
1874
|
+
/**
|
|
1875
|
+
* starts()
|
|
1876
|
+
*/
|
|
1877
|
+
{
|
|
1878
|
+
accepts: "string",
|
|
1879
|
+
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>.",
|
|
1880
|
+
example: {
|
|
1881
|
+
expression: "blah",
|
|
1882
|
+
result: "blah"
|
|
1883
|
+
},
|
|
1884
|
+
name: "starts",
|
|
1885
|
+
params: {
|
|
1886
|
+
description: "( string )"
|
|
1887
|
+
},
|
|
1888
|
+
type: "boolean"
|
|
1889
|
+
},
|
|
1890
|
+
/**
|
|
1891
|
+
* starts()
|
|
1892
|
+
*/
|
|
1893
|
+
{
|
|
1894
|
+
accepts: "string",
|
|
1895
|
+
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>.",
|
|
1896
|
+
example: {
|
|
1897
|
+
expression: "blah",
|
|
1898
|
+
result: "blah"
|
|
1899
|
+
},
|
|
1900
|
+
name: "ends",
|
|
1901
|
+
params: {
|
|
1902
|
+
description: "( string )"
|
|
1903
|
+
},
|
|
1904
|
+
type: "boolean"
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
accepts: "number",
|
|
1908
|
+
description: "blah",
|
|
1909
|
+
example: {
|
|
1910
|
+
expression: "blah",
|
|
1911
|
+
result: "blah"
|
|
1912
|
+
},
|
|
1913
|
+
name: "min",
|
|
1914
|
+
params: {
|
|
1915
|
+
description: "( string )"
|
|
1916
|
+
},
|
|
1917
|
+
type: "number"
|
|
1918
|
+
},
|
|
1919
|
+
{
|
|
1920
|
+
accepts: "number",
|
|
1921
|
+
description: "blah",
|
|
1922
|
+
example: {
|
|
1923
|
+
expression: "blah",
|
|
1924
|
+
result: "blah"
|
|
1925
|
+
},
|
|
1926
|
+
name: "max",
|
|
1927
|
+
params: {
|
|
1928
|
+
description: "( string )"
|
|
1929
|
+
},
|
|
1930
|
+
type: "number"
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
accepts: "number",
|
|
1934
|
+
description: "blah",
|
|
1935
|
+
example: {
|
|
1936
|
+
expression: "blah",
|
|
1937
|
+
result: "blah"
|
|
1938
|
+
},
|
|
1939
|
+
name: "sum",
|
|
1940
|
+
params: {
|
|
1941
|
+
description: "( string )"
|
|
1942
|
+
},
|
|
1943
|
+
type: "number"
|
|
1944
|
+
},
|
|
1945
|
+
{
|
|
1946
|
+
accepts: "number",
|
|
1947
|
+
description: "blah",
|
|
1948
|
+
example: {
|
|
1949
|
+
expression: "blah",
|
|
1950
|
+
result: "blah"
|
|
1951
|
+
},
|
|
1952
|
+
name: "round",
|
|
1953
|
+
params: {
|
|
1954
|
+
description: "( string )"
|
|
1955
|
+
},
|
|
1956
|
+
type: "number"
|
|
1957
|
+
},
|
|
1958
|
+
{
|
|
1959
|
+
accepts: "any",
|
|
1960
|
+
description: "blah",
|
|
1961
|
+
example: {
|
|
1962
|
+
expression: "blah",
|
|
1963
|
+
result: "blah"
|
|
1964
|
+
},
|
|
1965
|
+
name: "or",
|
|
1966
|
+
params: {
|
|
1967
|
+
description: "( string )"
|
|
1968
|
+
},
|
|
1969
|
+
type: "boolean"
|
|
1970
|
+
},
|
|
1971
|
+
{
|
|
1972
|
+
accepts: "any",
|
|
1973
|
+
description: "blah",
|
|
1974
|
+
example: {
|
|
1975
|
+
expression: "blah",
|
|
1976
|
+
result: "blah"
|
|
1977
|
+
},
|
|
1978
|
+
name: "and",
|
|
1979
|
+
params: {
|
|
1980
|
+
description: "( string )"
|
|
1981
|
+
},
|
|
1982
|
+
type: "boolean"
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
accepts: "any",
|
|
1986
|
+
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>. ",
|
|
1987
|
+
example: {
|
|
1988
|
+
expression: "blah",
|
|
1989
|
+
result: "blah"
|
|
1990
|
+
},
|
|
1991
|
+
name: "if",
|
|
1992
|
+
params: {
|
|
1993
|
+
description: "( filterExpression, expression1, expression 2)"
|
|
1994
|
+
},
|
|
1995
|
+
type: "variable"
|
|
1996
|
+
}
|
|
1997
|
+
];
|
|
1998
|
+
|
|
1999
|
+
// src/column-expression-input/functionDocInfo.ts
|
|
2000
|
+
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
2001
|
+
var functionDocInfo = ({
|
|
2002
|
+
name: name2,
|
|
2003
|
+
description,
|
|
2004
|
+
example,
|
|
2005
|
+
params,
|
|
2006
|
+
type
|
|
2007
|
+
}) => {
|
|
2008
|
+
const rootElement = (0, import_vuu_utils12.createEl)("div", "vuuFunctionDoc");
|
|
2009
|
+
const headingElement = (0, import_vuu_utils12.createEl)("div", "function-heading");
|
|
2010
|
+
const nameElement = (0, import_vuu_utils12.createEl)("span", "function-name", name2);
|
|
2011
|
+
const paramElement = (0, import_vuu_utils12.createEl)("span", "param-list", params.description);
|
|
2012
|
+
const typeElement = (0, import_vuu_utils12.createEl)("span", "function-type", type);
|
|
2013
|
+
headingElement.appendChild(nameElement);
|
|
2014
|
+
headingElement.appendChild(paramElement);
|
|
2015
|
+
headingElement.appendChild(typeElement);
|
|
2016
|
+
const child2 = (0, import_vuu_utils12.createEl)("p", void 0, description);
|
|
2017
|
+
rootElement.appendChild(headingElement);
|
|
2018
|
+
rootElement.appendChild(child2);
|
|
2019
|
+
if (example) {
|
|
2020
|
+
const exampleElement = (0, import_vuu_utils12.createEl)("div", "example-container");
|
|
2021
|
+
const expressionElement = (0, import_vuu_utils12.createEl)(
|
|
2022
|
+
"div",
|
|
2023
|
+
"example-expression",
|
|
2024
|
+
example.expression
|
|
2025
|
+
);
|
|
2026
|
+
const resultElement = (0, import_vuu_utils12.createEl)("div", "example-result", example.result);
|
|
2027
|
+
exampleElement.appendChild(expressionElement);
|
|
2028
|
+
rootElement.appendChild(exampleElement);
|
|
2029
|
+
rootElement.appendChild(resultElement);
|
|
2030
|
+
}
|
|
2031
|
+
return rootElement;
|
|
2032
|
+
};
|
|
2033
|
+
|
|
2034
|
+
// src/column-expression-input/useColumnExpressionSuggestionProvider.ts
|
|
2035
|
+
var NO_OPERATORS = [];
|
|
2036
|
+
var withApplySpace = (suggestions) => suggestions.map((suggestion) => {
|
|
2037
|
+
var _a;
|
|
2038
|
+
return {
|
|
2039
|
+
...suggestion,
|
|
2040
|
+
apply: ((_a = suggestion.apply) != null ? _a : suggestion.label) + " "
|
|
2041
|
+
};
|
|
2042
|
+
});
|
|
2043
|
+
var getValidColumns = (columns, { functionName, operator }) => {
|
|
2044
|
+
if (operator) {
|
|
2045
|
+
return columns.filter(import_vuu_utils13.isNumericColumn);
|
|
2046
|
+
} else if (functionName) {
|
|
2047
|
+
const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
|
|
2048
|
+
if (fn) {
|
|
2049
|
+
switch (fn.accepts) {
|
|
2050
|
+
case "string":
|
|
2051
|
+
return columns.filter(import_vuu_utils13.isTextColumn);
|
|
2052
|
+
case "number":
|
|
2053
|
+
return columns.filter(import_vuu_utils13.isNumericColumn);
|
|
2054
|
+
default:
|
|
2055
|
+
return columns;
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
return columns;
|
|
2060
|
+
};
|
|
2061
|
+
var getColumns = (columns, options) => {
|
|
2062
|
+
const validColumns = getValidColumns(columns, options);
|
|
2063
|
+
return validColumns.map((column) => {
|
|
2064
|
+
var _a;
|
|
2065
|
+
const label = (_a = column.label) != null ? _a : column.name;
|
|
2066
|
+
return {
|
|
2067
|
+
apply: options.prefix ? `${options.prefix}${column.name}` : column.name,
|
|
2068
|
+
label,
|
|
2069
|
+
boost: 5,
|
|
2070
|
+
type: "column",
|
|
2071
|
+
expressionType: column.serverDataType
|
|
2072
|
+
};
|
|
2073
|
+
});
|
|
2074
|
+
};
|
|
2075
|
+
var arithmeticOperators = [
|
|
2076
|
+
{ apply: "* ", boost: 2, label: "*", type: "operator" },
|
|
2077
|
+
{ apply: "/ ", boost: 2, label: "/", type: "operator" },
|
|
2078
|
+
{ apply: "+ ", boost: 2, label: "+", type: "operator" },
|
|
2079
|
+
{ apply: "- ", boost: 2, label: "-", type: "operator" }
|
|
2080
|
+
];
|
|
2081
|
+
var getOperators = (column) => {
|
|
2082
|
+
if (column === void 0 || (0, import_vuu_utils13.isNumericColumn)(column)) {
|
|
2083
|
+
return arithmeticOperators;
|
|
2084
|
+
} else {
|
|
2085
|
+
return NO_OPERATORS;
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
var getConditionOperators = (column) => {
|
|
2089
|
+
switch (column.serverDataType) {
|
|
2090
|
+
case "string":
|
|
2091
|
+
case "char":
|
|
2092
|
+
return withApplySpace(
|
|
2093
|
+
import_vuu_codemirror6.stringOperators
|
|
2094
|
+
/*, startsWith*/
|
|
2095
|
+
);
|
|
2096
|
+
case "int":
|
|
2097
|
+
case "long":
|
|
2098
|
+
case "double":
|
|
2099
|
+
return withApplySpace(import_vuu_codemirror6.numericOperators);
|
|
2100
|
+
}
|
|
2101
|
+
};
|
|
2102
|
+
var toFunctionCompletion = (functionDescriptor) => ({
|
|
2103
|
+
apply: `${functionDescriptor.name}( `,
|
|
2104
|
+
boost: 2,
|
|
2105
|
+
expressionType: functionDescriptor.type,
|
|
2106
|
+
info: () => functionDocInfo(functionDescriptor),
|
|
2107
|
+
label: functionDescriptor.name,
|
|
2108
|
+
type: "function"
|
|
2109
|
+
});
|
|
2110
|
+
var getAcceptedTypes = (fn) => {
|
|
2111
|
+
if (fn) {
|
|
2112
|
+
if (typeof fn.accepts === "string") {
|
|
2113
|
+
return fn.accepts;
|
|
2114
|
+
} else if (Array.isArray(fn.accepts)) {
|
|
2115
|
+
if (fn.accepts.every((s) => s === "string")) {
|
|
2116
|
+
return "string";
|
|
2117
|
+
} else {
|
|
2118
|
+
return "any";
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
return "any";
|
|
2123
|
+
};
|
|
2124
|
+
var functions = columnFunctionDescriptors.map(toFunctionCompletion);
|
|
2125
|
+
var getFunctions = ({ functionName }) => {
|
|
2126
|
+
if (functionName) {
|
|
2127
|
+
const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
|
|
2128
|
+
const acceptedTypes = getAcceptedTypes(fn);
|
|
2129
|
+
if (fn) {
|
|
2130
|
+
switch (acceptedTypes) {
|
|
2131
|
+
case "string":
|
|
2132
|
+
return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
|
|
2133
|
+
case "number":
|
|
2134
|
+
return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
|
|
2135
|
+
default:
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
return functions;
|
|
2140
|
+
};
|
|
2141
|
+
var NONE = {};
|
|
2142
|
+
var useColumnExpressionSuggestionProvider = ({
|
|
2143
|
+
columns,
|
|
2144
|
+
table
|
|
2145
|
+
}) => {
|
|
2146
|
+
const findColumn = (0, import_react10.useCallback)(
|
|
2147
|
+
(name2) => name2 ? columns.find((col) => col.name === name2) : void 0,
|
|
2148
|
+
[columns]
|
|
2149
|
+
);
|
|
2150
|
+
const latestSuggestionsRef = (0, import_react10.useRef)();
|
|
2151
|
+
const getTypeaheadSuggestions = (0, import_vuu_data_react3.useTypeaheadSuggestions)();
|
|
2152
|
+
const getSuggestions = (0, import_react10.useCallback)(
|
|
2153
|
+
async (suggestionType, options = NONE) => {
|
|
2154
|
+
const { columnName, functionName, operator, prefix } = options;
|
|
2155
|
+
switch (suggestionType) {
|
|
2156
|
+
case "expression": {
|
|
2157
|
+
const suggestions = await withApplySpace(
|
|
2158
|
+
getColumns(columns, { functionName, prefix })
|
|
2159
|
+
).concat(getFunctions(options));
|
|
2160
|
+
return latestSuggestionsRef.current = suggestions;
|
|
2161
|
+
}
|
|
2162
|
+
case "column": {
|
|
2163
|
+
const suggestions = await getColumns(columns, options);
|
|
2164
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
2165
|
+
}
|
|
2166
|
+
case "operator": {
|
|
2167
|
+
const suggestions = await getOperators(findColumn(columnName));
|
|
2168
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
2169
|
+
}
|
|
2170
|
+
case "relational-operator": {
|
|
2171
|
+
const suggestions = await (0, import_vuu_codemirror6.getRelationalOperators)(
|
|
2172
|
+
findColumn(columnName)
|
|
2173
|
+
);
|
|
2174
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
2175
|
+
}
|
|
2176
|
+
case "condition-operator":
|
|
2177
|
+
{
|
|
2178
|
+
const column = findColumn(columnName);
|
|
2179
|
+
if (column) {
|
|
2180
|
+
const suggestions = await getConditionOperators(column);
|
|
2181
|
+
if (suggestions) {
|
|
2182
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
break;
|
|
2187
|
+
case "columnValue":
|
|
2188
|
+
if (columnName && operator) {
|
|
2189
|
+
const params = (0, import_vuu_data_react3.getTypeaheadParams)(
|
|
2190
|
+
table,
|
|
2191
|
+
columnName
|
|
2192
|
+
/*, startsWith*/
|
|
2193
|
+
);
|
|
2194
|
+
const suggestions = await getTypeaheadSuggestions(params);
|
|
2195
|
+
latestSuggestionsRef.current = (0, import_vuu_codemirror6.toSuggestions)(suggestions, {
|
|
2196
|
+
suffix: ""
|
|
2197
|
+
});
|
|
2198
|
+
latestSuggestionsRef.current.forEach((suggestion) => {
|
|
2199
|
+
suggestion.apply = (view, completion, from) => {
|
|
2200
|
+
const annotation = new import_vuu_codemirror6.AnnotationType();
|
|
2201
|
+
const cursorPos = from + completion.label.length + 1;
|
|
2202
|
+
view.dispatch({
|
|
2203
|
+
changes: { from, insert: completion.label },
|
|
2204
|
+
selection: { anchor: cursorPos, head: cursorPos },
|
|
2205
|
+
annotations: annotation.of(completion)
|
|
2206
|
+
});
|
|
2207
|
+
};
|
|
2208
|
+
});
|
|
2209
|
+
return latestSuggestionsRef.current;
|
|
2210
|
+
}
|
|
2211
|
+
break;
|
|
2212
|
+
}
|
|
2213
|
+
return [];
|
|
2214
|
+
},
|
|
2215
|
+
[columns, findColumn, getTypeaheadSuggestions, table]
|
|
2216
|
+
);
|
|
2217
|
+
const isPartialMatch = (0, import_react10.useCallback)(
|
|
2218
|
+
async (valueType, columnName, pattern) => {
|
|
2219
|
+
const { current: latestSuggestions } = latestSuggestionsRef;
|
|
2220
|
+
let maybe = false;
|
|
2221
|
+
const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
|
|
2222
|
+
if (pattern && suggestions) {
|
|
2223
|
+
for (const option of suggestions) {
|
|
2224
|
+
if (option.label === pattern) {
|
|
2225
|
+
return false;
|
|
2226
|
+
} else if (option.label.startsWith(pattern)) {
|
|
2227
|
+
maybe = true;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
return maybe;
|
|
2232
|
+
},
|
|
2233
|
+
[getSuggestions]
|
|
2234
|
+
);
|
|
2235
|
+
return {
|
|
2236
|
+
getSuggestions,
|
|
2237
|
+
isPartialMatch
|
|
2238
|
+
};
|
|
2239
|
+
};
|
|
2240
|
+
|
|
2241
|
+
// src/column-expression-panel/useColumnExpression.ts
|
|
2242
|
+
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
2243
|
+
var import_react11 = require("react");
|
|
2244
|
+
var applyDefaults = (column) => {
|
|
2245
|
+
const [name2, expression, type] = (0, import_vuu_utils14.getCalculatedColumnDetails)(column);
|
|
2246
|
+
if (type === "") {
|
|
2247
|
+
return {
|
|
2248
|
+
...column,
|
|
2249
|
+
name: `${name2}:string:${expression}`
|
|
2250
|
+
};
|
|
2251
|
+
} else {
|
|
2252
|
+
return column;
|
|
2253
|
+
}
|
|
2254
|
+
};
|
|
2255
|
+
var useColumnExpression = ({
|
|
2256
|
+
column: columnProp,
|
|
2257
|
+
onChangeName: onChangeNameProp,
|
|
2258
|
+
onChangeServerDataType: onChangeServerDataTypeProp
|
|
2259
|
+
}) => {
|
|
2260
|
+
const [column, _setColumn] = (0, import_react11.useState)(
|
|
2261
|
+
applyDefaults(columnProp)
|
|
2262
|
+
);
|
|
2263
|
+
const columnRef = (0, import_react11.useRef)(columnProp);
|
|
2264
|
+
const setColumn = (0, import_react11.useCallback)((column2) => {
|
|
2265
|
+
columnRef.current = column2;
|
|
2266
|
+
_setColumn(column2);
|
|
2267
|
+
}, []);
|
|
2268
|
+
const onChangeName = (0, import_react11.useCallback)(
|
|
2269
|
+
(evt) => {
|
|
2270
|
+
const { value } = evt.target;
|
|
2271
|
+
const newColumn = (0, import_vuu_utils14.setCalculatedColumnName)(column, value);
|
|
2272
|
+
setColumn(newColumn);
|
|
2273
|
+
onChangeNameProp == null ? void 0 : onChangeNameProp(newColumn.name);
|
|
2274
|
+
},
|
|
2275
|
+
[column, onChangeNameProp, setColumn]
|
|
2276
|
+
);
|
|
2277
|
+
const onChangeExpression = (0, import_react11.useCallback)(
|
|
2278
|
+
(value) => {
|
|
2279
|
+
const expression = value.trim();
|
|
2280
|
+
const { current: column2 } = columnRef;
|
|
2281
|
+
const newColumn = (0, import_vuu_utils14.setCalculatedColumnExpression)(column2, expression);
|
|
2282
|
+
setColumn(newColumn);
|
|
2283
|
+
onChangeNameProp == null ? void 0 : onChangeNameProp(newColumn.name);
|
|
2284
|
+
},
|
|
2285
|
+
[onChangeNameProp, setColumn]
|
|
2286
|
+
);
|
|
2287
|
+
const onChangeServerDataType = (0, import_react11.useCallback)(
|
|
2288
|
+
(evt, value) => {
|
|
2289
|
+
if ((0, import_vuu_utils14.isVuuColumnDataType)(value)) {
|
|
2290
|
+
const newColumn = (0, import_vuu_utils14.setCalculatedColumnType)(column, value);
|
|
2291
|
+
setColumn(newColumn);
|
|
2292
|
+
onChangeNameProp == null ? void 0 : onChangeNameProp(newColumn.name);
|
|
2293
|
+
onChangeServerDataTypeProp == null ? void 0 : onChangeServerDataTypeProp(value);
|
|
2294
|
+
}
|
|
2295
|
+
},
|
|
2296
|
+
[column, onChangeNameProp, onChangeServerDataTypeProp, setColumn]
|
|
2297
|
+
);
|
|
2298
|
+
return {
|
|
2299
|
+
column,
|
|
2300
|
+
onChangeExpression,
|
|
2301
|
+
onChangeName,
|
|
2302
|
+
onChangeServerDataType
|
|
2303
|
+
};
|
|
2304
|
+
};
|
|
2305
|
+
|
|
2306
|
+
// src/column-expression-panel/ColumnExpressionPanel.tsx
|
|
2307
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2308
|
+
var classBase8 = "vuuColumnExpressionPanel";
|
|
2309
|
+
var ColumnExpressionPanel = ({
|
|
2310
|
+
column: columnProp,
|
|
2311
|
+
onChangeName: onChangeNameProp,
|
|
2312
|
+
onChangeServerDataType: onChangeServerDataTypeProp,
|
|
2313
|
+
tableConfig,
|
|
2314
|
+
vuuTable
|
|
2315
|
+
}) => {
|
|
2316
|
+
const typeRef = (0, import_react12.useRef)(null);
|
|
2317
|
+
const { column, onChangeExpression, onChangeName, onChangeServerDataType } = useColumnExpression({
|
|
2318
|
+
column: columnProp,
|
|
2319
|
+
onChangeName: onChangeNameProp,
|
|
2320
|
+
onChangeServerDataType: onChangeServerDataTypeProp
|
|
2321
|
+
});
|
|
2322
|
+
const initialExpressionRef = (0, import_react12.useRef)(
|
|
2323
|
+
(0, import_vuu_utils15.getCalculatedColumnExpression)(column)
|
|
2324
|
+
);
|
|
2325
|
+
const suggestionProvider = useColumnExpressionSuggestionProvider({
|
|
2326
|
+
columns: tableConfig.columns,
|
|
2327
|
+
table: vuuTable
|
|
2328
|
+
});
|
|
2329
|
+
const handleSubmitExpression = (0, import_react12.useCallback)(() => {
|
|
2330
|
+
var _a, _b;
|
|
2331
|
+
if (typeRef.current) {
|
|
2332
|
+
(_b = (_a = typeRef.current) == null ? void 0 : _a.querySelector("button")) == null ? void 0 : _b.focus();
|
|
2333
|
+
}
|
|
2334
|
+
}, []);
|
|
2335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: classBase8, children: [
|
|
2336
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "vuuColumnSettingsPanel-header", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Calculation" }) }),
|
|
2337
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core3.FormField, { "data-field": "column-name", children: [
|
|
2338
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core3.FormFieldLabel, { children: "Column Name" }),
|
|
2339
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2340
|
+
import_core3.Input,
|
|
2341
|
+
{
|
|
2342
|
+
className: "vuuInput",
|
|
2343
|
+
onChange: onChangeName,
|
|
2344
|
+
value: (0, import_vuu_utils15.getCalculatedColumnName)(column)
|
|
2345
|
+
}
|
|
2346
|
+
)
|
|
2347
|
+
] }),
|
|
2348
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core3.FormField, { "data-field": "column-expression", children: [
|
|
2349
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core3.FormFieldLabel, { children: "Expression" }),
|
|
2350
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2351
|
+
ColumnExpressionInput,
|
|
2352
|
+
{
|
|
2353
|
+
onChange: onChangeExpression,
|
|
2354
|
+
onSubmitExpression: handleSubmitExpression,
|
|
2355
|
+
source: initialExpressionRef.current,
|
|
2356
|
+
suggestionProvider
|
|
2357
|
+
}
|
|
2358
|
+
)
|
|
2359
|
+
] }),
|
|
2360
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core3.FormField, { "data-field": "type", children: [
|
|
2361
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core3.FormFieldLabel, { children: "Column type" }),
|
|
2362
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2363
|
+
import_vuu_ui_controls4.Dropdown,
|
|
2364
|
+
{
|
|
2365
|
+
className: `${classBase8}-type`,
|
|
2366
|
+
onSelectionChange: onChangeServerDataType,
|
|
2367
|
+
ref: typeRef,
|
|
2368
|
+
selected: (0, import_vuu_utils15.getCalculatedColumnType)(column) || null,
|
|
2369
|
+
source: ["double", "long", "string", "boolean"],
|
|
2370
|
+
width: "100%"
|
|
2371
|
+
}
|
|
2372
|
+
)
|
|
2373
|
+
] })
|
|
2374
|
+
] });
|
|
2375
|
+
};
|
|
2376
|
+
|
|
2377
|
+
// src/column-formatting-settings/ColumnFormattingPanel.tsx
|
|
2378
|
+
var import_vuu_ui_controls6 = require("@vuu-ui/vuu-ui-controls");
|
|
2379
|
+
var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
|
|
2380
|
+
var import_core7 = require("@salt-ds/core");
|
|
2381
|
+
var import_clsx5 = __toESM(require("clsx"), 1);
|
|
2382
|
+
var import_react16 = require("react");
|
|
2383
|
+
|
|
2384
|
+
// src/column-formatting-settings/BaseNumericFormattingSettings.tsx
|
|
2385
|
+
var import_core4 = require("@salt-ds/core");
|
|
2386
|
+
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
2387
|
+
var import_react13 = require("react");
|
|
2388
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2389
|
+
var classBase9 = "vuuFormattingSettings";
|
|
2390
|
+
var BaseNumericFormattingSettings = ({
|
|
2391
|
+
column,
|
|
2392
|
+
onChangeFormatting: onChange
|
|
2393
|
+
}) => {
|
|
2394
|
+
var _a, _b, _c;
|
|
2395
|
+
const [formattingSettings, setFormattingSettings] = (0, import_react13.useState)((0, import_vuu_utils16.getTypeFormattingFromColumn)(column));
|
|
2396
|
+
const handleInputKeyDown = (0, import_react13.useCallback)(
|
|
2397
|
+
(evt) => {
|
|
2398
|
+
if (evt.key === "Enter" || evt.key === "Tab") {
|
|
2399
|
+
onChange(formattingSettings);
|
|
2400
|
+
}
|
|
2401
|
+
},
|
|
2402
|
+
[formattingSettings, onChange]
|
|
2403
|
+
);
|
|
2404
|
+
const handleChangeDecimals = (0, import_react13.useCallback)(
|
|
2405
|
+
(evt) => {
|
|
2406
|
+
const { value } = evt.target;
|
|
2407
|
+
const numericValue = value === "" ? void 0 : isNaN(parseInt(value)) ? void 0 : parseInt(value);
|
|
2408
|
+
const newFormattingSettings = {
|
|
2409
|
+
...formattingSettings,
|
|
2410
|
+
decimals: numericValue
|
|
2411
|
+
};
|
|
2412
|
+
setFormattingSettings(newFormattingSettings);
|
|
2413
|
+
},
|
|
2414
|
+
[formattingSettings]
|
|
2415
|
+
);
|
|
2416
|
+
const handleChangeAlignDecimals = (0, import_react13.useCallback)(
|
|
2417
|
+
(evt) => {
|
|
2418
|
+
const { checked } = evt.target;
|
|
2419
|
+
const newFormattingSettings = {
|
|
2420
|
+
...formattingSettings,
|
|
2421
|
+
alignOnDecimals: checked
|
|
2422
|
+
};
|
|
2423
|
+
setFormattingSettings(newFormattingSettings);
|
|
2424
|
+
onChange(newFormattingSettings);
|
|
2425
|
+
},
|
|
2426
|
+
[formattingSettings, onChange]
|
|
2427
|
+
);
|
|
2428
|
+
const handleChangeZeroPad = (0, import_react13.useCallback)(
|
|
2429
|
+
(evt) => {
|
|
2430
|
+
const { checked } = evt.target;
|
|
2431
|
+
const newFormattingSettings = {
|
|
2432
|
+
...formattingSettings,
|
|
2433
|
+
zeroPad: checked
|
|
2434
|
+
};
|
|
2435
|
+
setFormattingSettings(newFormattingSettings);
|
|
2436
|
+
onChange(newFormattingSettings);
|
|
2437
|
+
},
|
|
2438
|
+
[formattingSettings, onChange]
|
|
2439
|
+
);
|
|
2440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: classBase9, children: [
|
|
2441
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_core4.FormField, { "data-field": "decimals", children: [
|
|
2442
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core4.FormFieldLabel, { children: "Number of decimals" }),
|
|
2443
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2444
|
+
import_core4.Input,
|
|
2445
|
+
{
|
|
2446
|
+
className: "vuuInput",
|
|
2447
|
+
onChange: handleChangeDecimals,
|
|
2448
|
+
onKeyDown: handleInputKeyDown,
|
|
2449
|
+
value: (_a = formattingSettings.decimals) != null ? _a : ""
|
|
2450
|
+
}
|
|
2451
|
+
)
|
|
2452
|
+
] }),
|
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_core4.FormField, { labelPlacement: "left", children: [
|
|
2454
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core4.FormFieldLabel, { children: "Align on decimals" }),
|
|
2455
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2456
|
+
import_core4.Switch,
|
|
2457
|
+
{
|
|
2458
|
+
checked: (_b = formattingSettings.alignOnDecimals) != null ? _b : false,
|
|
2459
|
+
onChange: handleChangeAlignDecimals,
|
|
2460
|
+
value: "align-decimals"
|
|
2461
|
+
}
|
|
2462
|
+
)
|
|
2463
|
+
] }),
|
|
2464
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_core4.FormField, { labelPlacement: "left", children: [
|
|
2465
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core4.FormFieldLabel, { children: "Zero pad decimals" }),
|
|
2466
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2467
|
+
import_core4.Switch,
|
|
2468
|
+
{
|
|
2469
|
+
checked: (_c = formattingSettings.zeroPad) != null ? _c : false,
|
|
2470
|
+
onChange: handleChangeZeroPad,
|
|
2471
|
+
value: "zero-pad"
|
|
2472
|
+
}
|
|
2473
|
+
)
|
|
2474
|
+
] })
|
|
2475
|
+
] });
|
|
2476
|
+
};
|
|
2477
|
+
|
|
2478
|
+
// src/column-formatting-settings/LongTypeFormattingSettings.tsx
|
|
2479
|
+
var import_react15 = require("react");
|
|
2480
|
+
var import_core6 = require("@salt-ds/core");
|
|
2481
|
+
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
2482
|
+
|
|
2483
|
+
// src/column-formatting-settings/DateTimeFormattingSettings.tsx
|
|
2484
|
+
var import_react14 = require("react");
|
|
2485
|
+
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
2486
|
+
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
2487
|
+
var import_core5 = require("@salt-ds/core");
|
|
2488
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2489
|
+
var DateTimeFormattingSettings = ({ column, onChangeFormatting: onChange }) => {
|
|
2490
|
+
var _a, _b;
|
|
2491
|
+
const formatting = (0, import_vuu_utils17.getTypeFormattingFromColumn)(column);
|
|
2492
|
+
const { pattern = import_vuu_utils17.fallbackDateTimePattern } = formatting;
|
|
2493
|
+
const toggleValue = (0, import_react14.useMemo)(() => getToggleValue(pattern), [pattern]);
|
|
2494
|
+
const [fallbackState, setFallbackState] = (0, import_react14.useState)(
|
|
2495
|
+
{
|
|
2496
|
+
time: (_a = pattern.time) != null ? _a : import_vuu_utils17.defaultPatternsByType.time,
|
|
2497
|
+
date: (_b = pattern.date) != null ? _b : import_vuu_utils17.defaultPatternsByType.date
|
|
2498
|
+
}
|
|
2499
|
+
);
|
|
2500
|
+
const onPatternChange = (0, import_react14.useCallback)(
|
|
2501
|
+
(pattern2) => onChange({ ...formatting, pattern: pattern2 }),
|
|
2502
|
+
[onChange, formatting]
|
|
2503
|
+
);
|
|
2504
|
+
const onDropdownChange = (0, import_react14.useCallback)(
|
|
2505
|
+
(key) => (_, p) => {
|
|
2506
|
+
const updatedPattern = { ...pattern != null ? pattern : {}, [key]: p };
|
|
2507
|
+
setFallbackState((s) => {
|
|
2508
|
+
var _a2, _b2;
|
|
2509
|
+
return {
|
|
2510
|
+
time: (_a2 = updatedPattern.time) != null ? _a2 : s.time,
|
|
2511
|
+
date: (_b2 = updatedPattern.date) != null ? _b2 : s.date
|
|
2512
|
+
};
|
|
2513
|
+
});
|
|
2514
|
+
onPatternChange(updatedPattern);
|
|
2515
|
+
},
|
|
2516
|
+
[onPatternChange, pattern]
|
|
2517
|
+
);
|
|
2518
|
+
const onToggleChange = (0, import_react14.useCallback)(
|
|
2519
|
+
(evnt) => {
|
|
2520
|
+
var _a2, _b2, _c, _d;
|
|
2521
|
+
const value = evnt.currentTarget.value;
|
|
2522
|
+
switch (value) {
|
|
2523
|
+
case "time":
|
|
2524
|
+
return onPatternChange({
|
|
2525
|
+
[value]: (_a2 = pattern[value]) != null ? _a2 : fallbackState[value]
|
|
2526
|
+
});
|
|
2527
|
+
case "date":
|
|
2528
|
+
return onPatternChange({
|
|
2529
|
+
[value]: (_b2 = pattern[value]) != null ? _b2 : fallbackState[value]
|
|
2530
|
+
});
|
|
2531
|
+
case "both":
|
|
2532
|
+
return onPatternChange({
|
|
2533
|
+
time: (_c = pattern.time) != null ? _c : fallbackState.time,
|
|
2534
|
+
date: (_d = pattern.date) != null ? _d : fallbackState.date
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2537
|
+
},
|
|
2538
|
+
[onPatternChange, pattern, fallbackState]
|
|
2539
|
+
);
|
|
2540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2541
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_core5.FormField, { labelPlacement: "top", children: [
|
|
2542
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core5.FormFieldLabel, { children: "Display" }),
|
|
2543
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2544
|
+
import_core5.ToggleButtonGroup,
|
|
2545
|
+
{
|
|
2546
|
+
className: "vuuToggleButtonGroup",
|
|
2547
|
+
onChange: onToggleChange,
|
|
2548
|
+
value: toggleValue,
|
|
2549
|
+
"data-variant": "primary",
|
|
2550
|
+
children: toggleValues.map((v) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core5.ToggleButton, { value: v, children: v.toUpperCase() }, v))
|
|
2551
|
+
}
|
|
2552
|
+
)
|
|
2553
|
+
] }),
|
|
2554
|
+
["date", "time"].filter((v) => !!pattern[v]).map((v) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_core5.FormField, { labelPlacement: "top", children: [
|
|
2555
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core5.FormFieldLabel, { children: `${labelByType[v]} pattern` }),
|
|
2556
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2557
|
+
import_vuu_ui_controls5.Dropdown,
|
|
2558
|
+
{
|
|
2559
|
+
onSelectionChange: onDropdownChange(v),
|
|
2560
|
+
selected: pattern[v],
|
|
2561
|
+
source: import_vuu_utils17.supportedDateTimePatterns[v],
|
|
2562
|
+
width: "100%"
|
|
2563
|
+
}
|
|
2564
|
+
)
|
|
2565
|
+
] }, v))
|
|
2566
|
+
] });
|
|
2567
|
+
};
|
|
2568
|
+
var labelByType = { date: "Date", time: "Time" };
|
|
2569
|
+
var toggleValues = ["date", "time", "both"];
|
|
2570
|
+
function getToggleValue(pattern) {
|
|
2571
|
+
return !pattern.time ? "date" : !pattern.date ? "time" : "both";
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
// src/column-formatting-settings/LongTypeFormattingSettings.tsx
|
|
2575
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2576
|
+
var classBase10 = "vuuLongColumnFormattingSettings";
|
|
2577
|
+
var LongTypeFormattingSettings = (props) => {
|
|
2578
|
+
const { column, onChangeColumnType: onChangeType } = props;
|
|
2579
|
+
const type = (0, import_vuu_utils18.isTypeDescriptor)(column.type) ? column.type.name : column.type;
|
|
2580
|
+
const handleToggleChange = (0, import_react15.useCallback)(
|
|
2581
|
+
(event) => {
|
|
2582
|
+
const value = event.currentTarget.value;
|
|
2583
|
+
onChangeType(value);
|
|
2584
|
+
},
|
|
2585
|
+
[onChangeType]
|
|
2586
|
+
);
|
|
2587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: classBase10, children: [
|
|
2588
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_core6.FormField, { children: [
|
|
2589
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_core6.FormFieldLabel, { children: "Type inferred as" }),
|
|
2590
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2591
|
+
import_core6.ToggleButtonGroup,
|
|
2592
|
+
{
|
|
2593
|
+
className: "vuuToggleButtonGroup",
|
|
2594
|
+
onChange: handleToggleChange,
|
|
2595
|
+
value: type != null ? type : "number",
|
|
2596
|
+
children: toggleValues2.map((v) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_core6.ToggleButton, { value: v, children: v.toUpperCase() }, v))
|
|
2597
|
+
}
|
|
2598
|
+
)
|
|
2599
|
+
] }),
|
|
2600
|
+
(0, import_vuu_utils18.isDateTimeColumn)(column) ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DateTimeFormattingSettings, { ...props, column }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(BaseNumericFormattingSettings, { ...props })
|
|
2601
|
+
] });
|
|
2602
|
+
};
|
|
2603
|
+
var toggleValues2 = ["number", "date/time"];
|
|
2604
|
+
|
|
2605
|
+
// src/column-formatting-settings/ColumnFormattingPanel.tsx
|
|
2606
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2607
|
+
var classBase11 = "vuuColumnFormattingPanel";
|
|
2608
|
+
var itemToString = (item) => {
|
|
2609
|
+
var _a;
|
|
2610
|
+
return (_a = item.label) != null ? _a : item.name;
|
|
2611
|
+
};
|
|
2612
|
+
var ColumnFormattingPanel = ({
|
|
2613
|
+
availableRenderers,
|
|
2614
|
+
className,
|
|
2615
|
+
column,
|
|
2616
|
+
onChangeFormatting,
|
|
2617
|
+
onChangeColumnType,
|
|
2618
|
+
onChangeRendering,
|
|
2619
|
+
...htmlAttributes
|
|
2620
|
+
}) => {
|
|
2621
|
+
const formattingSettingsComponent = (0, import_react16.useMemo)(
|
|
2622
|
+
() => getFormattingSettingsComponent({
|
|
2623
|
+
column,
|
|
2624
|
+
onChangeFormatting,
|
|
2625
|
+
onChangeColumnType
|
|
2626
|
+
}),
|
|
2627
|
+
[column, onChangeColumnType, onChangeFormatting]
|
|
2628
|
+
);
|
|
2629
|
+
console.log({ formattingSettingsComponent });
|
|
2630
|
+
const ConfigEditor = (0, import_react16.useMemo)(() => {
|
|
2631
|
+
const { type } = column;
|
|
2632
|
+
if ((0, import_vuu_utils19.isTypeDescriptor)(type) && (0, import_vuu_utils19.isColumnTypeRenderer)(type.renderer)) {
|
|
2633
|
+
const cellRendererOptions = (0, import_vuu_utils19.getCellRendererOptions)(type.renderer.name);
|
|
2634
|
+
return (0, import_vuu_utils19.getConfigurationEditor)(cellRendererOptions == null ? void 0 : cellRendererOptions.configEditor);
|
|
2635
|
+
}
|
|
2636
|
+
return void 0;
|
|
2637
|
+
}, [column]);
|
|
2638
|
+
const selectedCellRenderer = (0, import_react16.useMemo)(() => {
|
|
2639
|
+
const { type } = column;
|
|
2640
|
+
const [defaultRenderer] = availableRenderers;
|
|
2641
|
+
const rendererName = (0, import_vuu_utils19.isTypeDescriptor)(type) && (0, import_vuu_utils19.isColumnTypeRenderer)(type.renderer) ? type.renderer.name : void 0;
|
|
2642
|
+
const configuredRenderer = availableRenderers.find(
|
|
2643
|
+
(renderer) => renderer.name === rendererName
|
|
2644
|
+
);
|
|
2645
|
+
return configuredRenderer != null ? configuredRenderer : defaultRenderer;
|
|
2646
|
+
}, [availableRenderers, column]);
|
|
2647
|
+
const handleChangeRenderer = (0, import_react16.useCallback)(
|
|
2648
|
+
(_, cellRendererDescriptor) => {
|
|
2649
|
+
const renderProps = {
|
|
2650
|
+
name: cellRendererDescriptor.name
|
|
2651
|
+
};
|
|
2652
|
+
onChangeRendering == null ? void 0 : onChangeRendering(renderProps);
|
|
2653
|
+
},
|
|
2654
|
+
[onChangeRendering]
|
|
2655
|
+
);
|
|
2656
|
+
const { serverDataType = "string" } = column;
|
|
2657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { ...htmlAttributes, className: `vuuColumnSettingsPanel-header`, children: [
|
|
2658
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: "Formatting" }),
|
|
2659
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_core7.FormField, { children: [
|
|
2660
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_core7.FormFieldLabel, { children: `Renderer (data type ${column.serverDataType})` }),
|
|
2661
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2662
|
+
import_vuu_ui_controls6.Dropdown,
|
|
2663
|
+
{
|
|
2664
|
+
className: (0, import_clsx5.default)(`${classBase11}-renderer`),
|
|
2665
|
+
itemToString,
|
|
2666
|
+
onSelectionChange: handleChangeRenderer,
|
|
2667
|
+
selected: selectedCellRenderer,
|
|
2668
|
+
source: availableRenderers,
|
|
2669
|
+
width: "100%"
|
|
2670
|
+
}
|
|
2671
|
+
)
|
|
2672
|
+
] }),
|
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2674
|
+
"div",
|
|
2675
|
+
{
|
|
2676
|
+
className: (0, import_clsx5.default)(classBase11, className, `${classBase11}-${serverDataType}`),
|
|
2677
|
+
children: [
|
|
2678
|
+
formattingSettingsComponent,
|
|
2679
|
+
ConfigEditor ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2680
|
+
ConfigEditor,
|
|
2681
|
+
{
|
|
2682
|
+
column,
|
|
2683
|
+
onChangeRendering
|
|
2684
|
+
}
|
|
2685
|
+
) : null
|
|
2686
|
+
]
|
|
2687
|
+
}
|
|
2688
|
+
)
|
|
2689
|
+
] });
|
|
2690
|
+
};
|
|
2691
|
+
function getFormattingSettingsComponent(props) {
|
|
2692
|
+
const { column } = props;
|
|
2693
|
+
switch (column.serverDataType) {
|
|
2694
|
+
case "double":
|
|
2695
|
+
case "int":
|
|
2696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(BaseNumericFormattingSettings, { ...props });
|
|
2697
|
+
case "long":
|
|
2698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LongTypeFormattingSettings, { ...props });
|
|
2699
|
+
default:
|
|
2700
|
+
return null;
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
// src/column-settings/ColumnNameLabel.tsx
|
|
2705
|
+
var import_clsx6 = __toESM(require("clsx"), 1);
|
|
2706
|
+
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
2707
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2708
|
+
var classBase12 = "vuuColumnNameLabel";
|
|
2709
|
+
var ColumnNameLabel = ({ column, onClick }) => {
|
|
2710
|
+
if ((0, import_vuu_utils20.isCalculatedColumn)(column.name)) {
|
|
2711
|
+
const [name2, type, expression] = (0, import_vuu_utils20.getCalculatedColumnDetails)(column);
|
|
2712
|
+
const displayName = name2 || "name";
|
|
2713
|
+
const displayExpression = "=expression";
|
|
2714
|
+
const nameClass = displayName === "name" ? `${classBase12}-placeholder` : void 0;
|
|
2715
|
+
const expressionClass = expression === "" ? `${classBase12}-placeholder` : void 0;
|
|
2716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2717
|
+
"div",
|
|
2718
|
+
{
|
|
2719
|
+
className: (0, import_clsx6.default)(classBase12, `${classBase12}-calculated`),
|
|
2720
|
+
onClick,
|
|
2721
|
+
children: [
|
|
2722
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: nameClass, children: displayName }),
|
|
2723
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: ":" }),
|
|
2724
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: type || "string" }),
|
|
2725
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: ":" }),
|
|
2726
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: expressionClass, children: displayExpression }),
|
|
2727
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `${classBase12}-edit`, "data-icon": "edit" })
|
|
2728
|
+
]
|
|
2729
|
+
}
|
|
2730
|
+
);
|
|
2731
|
+
} else {
|
|
2732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: classBase12, children: column.name });
|
|
2733
|
+
}
|
|
2734
|
+
};
|
|
2735
|
+
|
|
2736
|
+
// src/column-settings/useColumnSettings.ts
|
|
2737
|
+
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
2738
|
+
var import_react17 = require("react");
|
|
2739
|
+
var integerCellRenderers = [
|
|
2740
|
+
{
|
|
2741
|
+
description: "Default formatter for columns with data type integer",
|
|
2742
|
+
label: "Default Renderer (int, long)",
|
|
2743
|
+
name: "default-int"
|
|
2744
|
+
}
|
|
2745
|
+
];
|
|
2746
|
+
var doubleCellRenderers = [
|
|
2747
|
+
{
|
|
2748
|
+
description: "Default formatter for columns with data type double",
|
|
2749
|
+
label: "Default Renderer (double)",
|
|
2750
|
+
name: "default-double"
|
|
2751
|
+
}
|
|
2752
|
+
];
|
|
2753
|
+
var stringCellRenderers = [
|
|
2754
|
+
{
|
|
2755
|
+
description: "Default formatter for columns with data type string",
|
|
2756
|
+
label: "Default Renderer (string)",
|
|
2757
|
+
name: "default-string"
|
|
2758
|
+
}
|
|
2759
|
+
];
|
|
2760
|
+
var booleanCellRenderers = [];
|
|
2761
|
+
var getAvailableCellRenderers = (column) => {
|
|
2762
|
+
switch (column.serverDataType) {
|
|
2763
|
+
case "char":
|
|
2764
|
+
case "string":
|
|
2765
|
+
return stringCellRenderers.concat((0, import_vuu_utils21.getRegisteredCellRenderers)("string"));
|
|
2766
|
+
case "int":
|
|
2767
|
+
case "long":
|
|
2768
|
+
return integerCellRenderers.concat((0, import_vuu_utils21.getRegisteredCellRenderers)("int"));
|
|
2769
|
+
case "double":
|
|
2770
|
+
return doubleCellRenderers.concat((0, import_vuu_utils21.getRegisteredCellRenderers)("double"));
|
|
2771
|
+
case "boolean":
|
|
2772
|
+
return booleanCellRenderers.concat((0, import_vuu_utils21.getRegisteredCellRenderers)("boolean"));
|
|
2773
|
+
default:
|
|
2774
|
+
return stringCellRenderers;
|
|
2775
|
+
}
|
|
2776
|
+
};
|
|
2777
|
+
var getFieldName = (input) => {
|
|
2778
|
+
const saltFormField = input.closest(".saltFormField");
|
|
2779
|
+
if (saltFormField && saltFormField.dataset.field) {
|
|
2780
|
+
const {
|
|
2781
|
+
dataset: { field }
|
|
2782
|
+
} = saltFormField;
|
|
2783
|
+
return field;
|
|
2784
|
+
} else {
|
|
2785
|
+
throw Error("named form field not found");
|
|
2786
|
+
}
|
|
2787
|
+
};
|
|
2788
|
+
var getColumn = (columns, column) => {
|
|
2789
|
+
if (column.name === "::") {
|
|
2790
|
+
return column;
|
|
2791
|
+
} else {
|
|
2792
|
+
const col = columns.find((col2) => col2.name === column.name);
|
|
2793
|
+
if (col) {
|
|
2794
|
+
return col;
|
|
2795
|
+
}
|
|
2796
|
+
throw Error(`columns does not contain column ${name}`);
|
|
2797
|
+
}
|
|
2798
|
+
};
|
|
2799
|
+
var replaceColumn = (tableConfig, column) => ({
|
|
2800
|
+
...tableConfig,
|
|
2801
|
+
columns: tableConfig.columns.map(
|
|
2802
|
+
(col) => col.name === column.name ? column : col
|
|
2803
|
+
)
|
|
2804
|
+
});
|
|
2805
|
+
var useColumnSettings = ({
|
|
2806
|
+
column: columnProp,
|
|
2807
|
+
onCancelCreateColumn,
|
|
2808
|
+
onConfigChange,
|
|
2809
|
+
onCreateCalculatedColumn,
|
|
2810
|
+
tableConfig
|
|
2811
|
+
}) => {
|
|
2812
|
+
const [column, setColumn] = (0, import_react17.useState)(
|
|
2813
|
+
getColumn(tableConfig.columns, columnProp)
|
|
2814
|
+
);
|
|
2815
|
+
const columnRef = (0, import_react17.useRef)(column);
|
|
2816
|
+
const [inEditMode, setEditMode] = (0, import_react17.useState)(column.name === "::");
|
|
2817
|
+
const handleEditCalculatedcolumn = (0, import_react17.useCallback)(() => {
|
|
2818
|
+
columnRef.current = column;
|
|
2819
|
+
setEditMode(true);
|
|
2820
|
+
}, [column]);
|
|
2821
|
+
(0, import_react17.useEffect)(() => {
|
|
2822
|
+
setColumn(columnProp);
|
|
2823
|
+
setEditMode(columnProp.name === "::");
|
|
2824
|
+
}, [columnProp]);
|
|
2825
|
+
const availableRenderers = (0, import_react17.useMemo)(() => {
|
|
2826
|
+
return getAvailableCellRenderers(column);
|
|
2827
|
+
}, [column]);
|
|
2828
|
+
const handleInputCommit = (0, import_react17.useCallback)(() => {
|
|
2829
|
+
onConfigChange(replaceColumn(tableConfig, column));
|
|
2830
|
+
}, [column, onConfigChange, tableConfig]);
|
|
2831
|
+
const handleChangeToggleButton = (0, import_react17.useCallback)(
|
|
2832
|
+
(evt) => {
|
|
2833
|
+
const button = (0, import_vuu_utils21.queryClosest)(evt.target, "button");
|
|
2834
|
+
if (button) {
|
|
2835
|
+
const fieldName = getFieldName(button);
|
|
2836
|
+
const { value } = button;
|
|
2837
|
+
switch (fieldName) {
|
|
2838
|
+
case "column-alignment":
|
|
2839
|
+
if ((0, import_vuu_utils21.isValidColumnAlignment)(value)) {
|
|
2840
|
+
const newColumn = {
|
|
2841
|
+
...column,
|
|
2842
|
+
align: value || void 0
|
|
2843
|
+
};
|
|
2844
|
+
setColumn(newColumn);
|
|
2845
|
+
onConfigChange(replaceColumn(tableConfig, newColumn));
|
|
2846
|
+
}
|
|
2847
|
+
break;
|
|
2848
|
+
case "column-pin":
|
|
2849
|
+
if ((0, import_vuu_utils21.isValidPinLocation)(value)) {
|
|
2850
|
+
const newColumn = {
|
|
2851
|
+
...column,
|
|
2852
|
+
pin: value || void 0
|
|
2853
|
+
};
|
|
2854
|
+
setColumn(newColumn);
|
|
2855
|
+
onConfigChange(replaceColumn(tableConfig, newColumn));
|
|
2856
|
+
break;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
},
|
|
2861
|
+
[column, onConfigChange, tableConfig]
|
|
2862
|
+
);
|
|
2863
|
+
const handleChange = (0, import_react17.useCallback)((evt) => {
|
|
2864
|
+
const input = evt.target;
|
|
2865
|
+
const fieldName = getFieldName(input);
|
|
2866
|
+
const { value } = input;
|
|
2867
|
+
switch (fieldName) {
|
|
2868
|
+
case "column-label":
|
|
2869
|
+
setColumn((state) => ({ ...state, label: value }));
|
|
2870
|
+
break;
|
|
2871
|
+
case "column-name":
|
|
2872
|
+
setColumn((state) => (0, import_vuu_utils21.setCalculatedColumnName)(state, value));
|
|
2873
|
+
break;
|
|
2874
|
+
case "column-width":
|
|
2875
|
+
setColumn((state) => ({ ...state, width: parseInt(value) }));
|
|
2876
|
+
break;
|
|
2877
|
+
}
|
|
2878
|
+
}, []);
|
|
2879
|
+
const handleChangeCalculatedColumnName = (0, import_react17.useCallback)((name2) => {
|
|
2880
|
+
setColumn((state) => ({ ...state, name: name2 }));
|
|
2881
|
+
}, []);
|
|
2882
|
+
const handleChangeFormatting = (0, import_react17.useCallback)(
|
|
2883
|
+
(formatting) => {
|
|
2884
|
+
const newColumn = (0, import_vuu_utils21.updateColumnFormatting)(column, formatting);
|
|
2885
|
+
setColumn(newColumn);
|
|
2886
|
+
onConfigChange(replaceColumn(tableConfig, newColumn));
|
|
2887
|
+
},
|
|
2888
|
+
[column, onConfigChange, tableConfig]
|
|
2889
|
+
);
|
|
2890
|
+
const handleChangeType = (0, import_react17.useCallback)(
|
|
2891
|
+
(type) => {
|
|
2892
|
+
const updatedColumn = (0, import_vuu_utils21.updateColumnType)(column, type);
|
|
2893
|
+
setColumn(updatedColumn);
|
|
2894
|
+
onConfigChange(replaceColumn(tableConfig, updatedColumn));
|
|
2895
|
+
},
|
|
2896
|
+
[column, onConfigChange, tableConfig]
|
|
2897
|
+
);
|
|
2898
|
+
const handleChangeServerDataType = (0, import_react17.useCallback)(
|
|
2899
|
+
(serverDataType) => {
|
|
2900
|
+
setColumn((col) => ({ ...col, serverDataType }));
|
|
2901
|
+
},
|
|
2902
|
+
[]
|
|
2903
|
+
);
|
|
2904
|
+
const handleChangeRendering = (0, import_react17.useCallback)(
|
|
2905
|
+
(renderProps) => {
|
|
2906
|
+
if (renderProps) {
|
|
2907
|
+
const newColumn = (0, import_vuu_utils21.updateColumnRenderProps)(
|
|
2908
|
+
column,
|
|
2909
|
+
renderProps
|
|
2910
|
+
);
|
|
2911
|
+
setColumn(newColumn);
|
|
2912
|
+
onConfigChange(replaceColumn(tableConfig, newColumn));
|
|
2913
|
+
}
|
|
2914
|
+
},
|
|
2915
|
+
[column, onConfigChange, tableConfig]
|
|
2916
|
+
);
|
|
2917
|
+
const navigateColumn = (0, import_react17.useCallback)(
|
|
2918
|
+
({ moveBy }) => {
|
|
2919
|
+
const { columns } = tableConfig;
|
|
2920
|
+
const index = columns.indexOf(column) + moveBy;
|
|
2921
|
+
const newColumn = columns[index];
|
|
2922
|
+
if (newColumn) {
|
|
2923
|
+
setColumn(newColumn);
|
|
2924
|
+
}
|
|
2925
|
+
},
|
|
2926
|
+
[column, tableConfig]
|
|
2927
|
+
);
|
|
2928
|
+
const navigateNextColumn = (0, import_react17.useCallback)(() => {
|
|
2929
|
+
navigateColumn({ moveBy: 1 });
|
|
2930
|
+
}, [navigateColumn]);
|
|
2931
|
+
const navigatePrevColumn = (0, import_react17.useCallback)(() => {
|
|
2932
|
+
navigateColumn({ moveBy: -1 });
|
|
2933
|
+
}, [navigateColumn]);
|
|
2934
|
+
const handleSaveCalculatedColumn = (0, import_react17.useCallback)(() => {
|
|
2935
|
+
onCreateCalculatedColumn(column);
|
|
2936
|
+
}, [column, onCreateCalculatedColumn]);
|
|
2937
|
+
const handleCancelEdit = (0, import_react17.useCallback)(() => {
|
|
2938
|
+
if (columnProp.name === "::") {
|
|
2939
|
+
onCancelCreateColumn();
|
|
2940
|
+
} else {
|
|
2941
|
+
if (columnRef.current !== void 0 && columnRef.current !== column) {
|
|
2942
|
+
setColumn(columnRef.current);
|
|
2943
|
+
}
|
|
2944
|
+
setEditMode(false);
|
|
2945
|
+
}
|
|
2946
|
+
}, [column, columnProp.name, onCancelCreateColumn]);
|
|
2947
|
+
return {
|
|
2948
|
+
availableRenderers,
|
|
2949
|
+
editCalculatedColumn: inEditMode,
|
|
2950
|
+
column,
|
|
2951
|
+
navigateNextColumn,
|
|
2952
|
+
navigatePrevColumn,
|
|
2953
|
+
onCancel: handleCancelEdit,
|
|
2954
|
+
onChange: handleChange,
|
|
2955
|
+
onChangeCalculatedColumnName: handleChangeCalculatedColumnName,
|
|
2956
|
+
onChangeFormatting: handleChangeFormatting,
|
|
2957
|
+
onChangeRendering: handleChangeRendering,
|
|
2958
|
+
onChangeServerDataType: handleChangeServerDataType,
|
|
2959
|
+
onChangeToggleButton: handleChangeToggleButton,
|
|
2960
|
+
onChangeType: handleChangeType,
|
|
2961
|
+
onEditCalculatedColumn: handleEditCalculatedcolumn,
|
|
2962
|
+
onInputCommit: handleInputCommit,
|
|
2963
|
+
onSave: handleSaveCalculatedColumn
|
|
2964
|
+
};
|
|
2965
|
+
};
|
|
2966
|
+
|
|
2967
|
+
// src/column-settings/ColumnSettingsPanel.tsx
|
|
2968
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2969
|
+
var classBase13 = "vuuColumnSettingsPanel";
|
|
2970
|
+
var getColumnLabel2 = (column) => {
|
|
2971
|
+
const { name: name2, label } = column;
|
|
2972
|
+
if ((0, import_vuu_utils22.isCalculatedColumn)(name2)) {
|
|
2973
|
+
return label != null ? label : (0, import_vuu_utils22.getCalculatedColumnName)(column);
|
|
2974
|
+
} else {
|
|
2975
|
+
return label != null ? label : name2;
|
|
2976
|
+
}
|
|
2977
|
+
};
|
|
2978
|
+
var ColumnSettingsPanel = ({
|
|
2979
|
+
column: columnProp,
|
|
2980
|
+
onCancelCreateColumn,
|
|
2981
|
+
onConfigChange,
|
|
2982
|
+
onCreateCalculatedColumn,
|
|
2983
|
+
tableConfig,
|
|
2984
|
+
vuuTable
|
|
2985
|
+
}) => {
|
|
2986
|
+
const isNewCalculatedColumn = columnProp.name === "::";
|
|
2987
|
+
const {
|
|
2988
|
+
availableRenderers,
|
|
2989
|
+
editCalculatedColumn,
|
|
2990
|
+
column,
|
|
2991
|
+
navigateNextColumn,
|
|
2992
|
+
navigatePrevColumn,
|
|
2993
|
+
onCancel,
|
|
2994
|
+
onChange,
|
|
2995
|
+
onChangeCalculatedColumnName,
|
|
2996
|
+
onChangeFormatting,
|
|
2997
|
+
onChangeRendering,
|
|
2998
|
+
onChangeServerDataType,
|
|
2999
|
+
onChangeToggleButton,
|
|
3000
|
+
onChangeType,
|
|
3001
|
+
onEditCalculatedColumn,
|
|
3002
|
+
onInputCommit,
|
|
3003
|
+
onSave
|
|
3004
|
+
} = useColumnSettings({
|
|
3005
|
+
column: columnProp,
|
|
3006
|
+
onCancelCreateColumn,
|
|
3007
|
+
onConfigChange,
|
|
3008
|
+
onCreateCalculatedColumn,
|
|
3009
|
+
tableConfig
|
|
3010
|
+
});
|
|
3011
|
+
const {
|
|
3012
|
+
serverDataType,
|
|
3013
|
+
align = (0, import_vuu_utils22.getDefaultAlignment)(serverDataType),
|
|
3014
|
+
pin,
|
|
3015
|
+
width
|
|
3016
|
+
} = column;
|
|
3017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3018
|
+
"div",
|
|
3019
|
+
{
|
|
3020
|
+
className: (0, import_clsx7.default)(classBase13, {
|
|
3021
|
+
[`${classBase13}-editing`]: editCalculatedColumn
|
|
3022
|
+
}),
|
|
3023
|
+
children: [
|
|
3024
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `${classBase13}-header`, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ColumnNameLabel, { column, onClick: onEditCalculatedColumn }) }),
|
|
3025
|
+
editCalculatedColumn ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3026
|
+
ColumnExpressionPanel,
|
|
3027
|
+
{
|
|
3028
|
+
column,
|
|
3029
|
+
onChangeName: onChangeCalculatedColumnName,
|
|
3030
|
+
onChangeServerDataType,
|
|
3031
|
+
tableConfig,
|
|
3032
|
+
vuuTable
|
|
3033
|
+
}
|
|
3034
|
+
) : null,
|
|
3035
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_core8.FormField, { "data-field": "column-label", children: [
|
|
3036
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.FormFieldLabel, { children: "Column Label" }),
|
|
3037
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3038
|
+
import_vuu_ui_controls7.VuuInput,
|
|
3039
|
+
{
|
|
3040
|
+
className: "vuuInput",
|
|
3041
|
+
"data-embedded": true,
|
|
3042
|
+
onChange,
|
|
3043
|
+
onCommit: onInputCommit,
|
|
3044
|
+
value: getColumnLabel2(column)
|
|
3045
|
+
}
|
|
3046
|
+
)
|
|
3047
|
+
] }),
|
|
3048
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_core8.FormField, { "data-field": "column-width", children: [
|
|
3049
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.FormFieldLabel, { children: "Column Width" }),
|
|
3050
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3051
|
+
import_vuu_ui_controls7.VuuInput,
|
|
3052
|
+
{
|
|
3053
|
+
className: "vuuInput",
|
|
3054
|
+
"data-embedded": true,
|
|
3055
|
+
onChange,
|
|
3056
|
+
value: width,
|
|
3057
|
+
onCommit: onInputCommit
|
|
3058
|
+
}
|
|
3059
|
+
)
|
|
3060
|
+
] }),
|
|
3061
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_core8.FormField, { "data-field": "column-alignment", children: [
|
|
3062
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.FormFieldLabel, { children: "Alignment" }),
|
|
3063
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_core8.ToggleButtonGroup, { onChange: onChangeToggleButton, value: align, children: [
|
|
3064
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.ToggleButton, { value: "left", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_vuu_ui_controls7.Icon, { name: "align-left", size: 16 }) }),
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.ToggleButton, { value: "right", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_vuu_ui_controls7.Icon, { name: "align-right", size: 16 }) })
|
|
3066
|
+
] })
|
|
3067
|
+
] }),
|
|
3068
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_core8.FormField, { "data-field": "column-pin", children: [
|
|
3069
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.FormFieldLabel, { children: "Pin Column" }),
|
|
3070
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_core8.ToggleButtonGroup, { onChange: onChangeToggleButton, value: pin != null ? pin : "", children: [
|
|
3071
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.ToggleButton, { value: "left", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_vuu_ui_controls7.Icon, { name: "pin-left", size: 16 }) }),
|
|
3072
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.ToggleButton, { value: "floating", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_vuu_ui_controls7.Icon, { name: "pin-float", size: 16 }) }),
|
|
3073
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.ToggleButton, { value: "right", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_vuu_ui_controls7.Icon, { name: "pin-right", size: 16 }) }),
|
|
3074
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core8.ToggleButton, { value: "", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_vuu_ui_controls7.Icon, { name: "cross-circle", size: 16 }) })
|
|
3075
|
+
] })
|
|
3076
|
+
] }),
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3078
|
+
ColumnFormattingPanel,
|
|
3079
|
+
{
|
|
3080
|
+
availableRenderers,
|
|
3081
|
+
column,
|
|
3082
|
+
onChangeFormatting,
|
|
3083
|
+
onChangeRendering,
|
|
3084
|
+
onChangeColumnType: onChangeType
|
|
3085
|
+
}
|
|
3086
|
+
),
|
|
3087
|
+
editCalculatedColumn ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "vuuColumnSettingsPanel-buttonBar", "data-align": "right", children: [
|
|
3088
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3089
|
+
import_core8.Button,
|
|
3090
|
+
{
|
|
3091
|
+
className: `${classBase13}-buttonCancel`,
|
|
3092
|
+
onClick: onCancel,
|
|
3093
|
+
tabIndex: -1,
|
|
3094
|
+
children: "cancel"
|
|
3095
|
+
}
|
|
3096
|
+
),
|
|
3097
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3098
|
+
import_core8.Button,
|
|
3099
|
+
{
|
|
3100
|
+
className: `${classBase13}-buttonSave`,
|
|
3101
|
+
onClick: onSave,
|
|
3102
|
+
variant: "cta",
|
|
3103
|
+
children: "save"
|
|
3104
|
+
}
|
|
3105
|
+
)
|
|
3106
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3107
|
+
"div",
|
|
3108
|
+
{
|
|
3109
|
+
className: `${classBase13}-buttonBar`,
|
|
3110
|
+
"data-align": isNewCalculatedColumn ? "right" : void 0,
|
|
3111
|
+
children: [
|
|
3112
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3113
|
+
import_core8.Button,
|
|
3114
|
+
{
|
|
3115
|
+
className: `${classBase13}-buttonNavPrev`,
|
|
3116
|
+
variant: "secondary",
|
|
3117
|
+
"data-icon": "arrow-left",
|
|
3118
|
+
onClick: navigatePrevColumn,
|
|
3119
|
+
children: "PREVIOUS"
|
|
3120
|
+
}
|
|
3121
|
+
),
|
|
3122
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3123
|
+
import_core8.Button,
|
|
3124
|
+
{
|
|
3125
|
+
className: `${classBase13}-buttonNavNext`,
|
|
3126
|
+
variant: "secondary",
|
|
3127
|
+
"data-icon": "arrow-right",
|
|
3128
|
+
onClick: navigateNextColumn,
|
|
3129
|
+
children: "NEXT"
|
|
3130
|
+
}
|
|
3131
|
+
)
|
|
3132
|
+
]
|
|
3133
|
+
}
|
|
3134
|
+
)
|
|
3135
|
+
]
|
|
3136
|
+
}
|
|
3137
|
+
);
|
|
3138
|
+
};
|
|
3139
|
+
|
|
3140
|
+
// src/datasource-stats/DatasourceStats.tsx
|
|
3141
|
+
var import_clsx8 = __toESM(require("clsx"), 1);
|
|
3142
|
+
var import_react18 = require("react");
|
|
3143
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3144
|
+
var classBase14 = "vuuDatasourceStats";
|
|
3145
|
+
var numberFormatter = new Intl.NumberFormat();
|
|
3146
|
+
var DataSourceStats = ({
|
|
3147
|
+
className: classNameProp,
|
|
3148
|
+
dataSource
|
|
3149
|
+
}) => {
|
|
3150
|
+
const [range, setRange] = (0, import_react18.useState)(dataSource.range);
|
|
3151
|
+
const [size, setSize] = (0, import_react18.useState)(dataSource.size);
|
|
3152
|
+
(0, import_react18.useEffect)(() => {
|
|
3153
|
+
setSize(dataSource.size);
|
|
3154
|
+
dataSource.on("resize", setSize);
|
|
3155
|
+
dataSource.on("range", setRange);
|
|
3156
|
+
return () => {
|
|
3157
|
+
dataSource.removeListener("resize", setSize);
|
|
3158
|
+
dataSource.removeListener("range", setRange);
|
|
3159
|
+
};
|
|
3160
|
+
}, [dataSource]);
|
|
3161
|
+
const className = (0, import_clsx8.default)(classBase14, classNameProp);
|
|
3162
|
+
const from = numberFormatter.format(range.from + 1);
|
|
3163
|
+
const to = numberFormatter.format(Math.min(range.to, size));
|
|
3164
|
+
const value = numberFormatter.format(size);
|
|
3165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className, children: [
|
|
3166
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: `${classBase14}-label`, children: "Row count" }),
|
|
3167
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: `${classBase14}-range`, children: from }),
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "-" }),
|
|
3169
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: `${classBase14}-range`, children: to }),
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "of" }),
|
|
3171
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: `${classBase14}-size`, children: value })
|
|
3172
|
+
] });
|
|
3173
|
+
};
|
|
3174
|
+
|
|
3175
|
+
// src/table-settings/TableSettingsPanel.tsx
|
|
3176
|
+
var import_core9 = require("@salt-ds/core");
|
|
3177
|
+
|
|
3178
|
+
// src/table-settings/useTableSettings.ts
|
|
3179
|
+
var import_vuu_table = require("@vuu-ui/vuu-table");
|
|
3180
|
+
var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
|
|
3181
|
+
var import_react19 = require("react");
|
|
3182
|
+
var sortOrderFromAvailableColumns = (availableColumns, columns) => {
|
|
3183
|
+
const sortedColumns = [];
|
|
3184
|
+
for (const { name: name2 } of availableColumns) {
|
|
3185
|
+
const column = columns.find((col) => col.name === name2);
|
|
3186
|
+
if (column) {
|
|
3187
|
+
sortedColumns.push(column);
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
return sortedColumns;
|
|
3191
|
+
};
|
|
3192
|
+
var buildColumnItems = (availableColumns, configuredColumns) => {
|
|
3193
|
+
return availableColumns.map(({ name: name2, serverDataType }) => {
|
|
3194
|
+
const configuredColumn = configuredColumns.find((col) => col.name === name2);
|
|
3195
|
+
return {
|
|
3196
|
+
hidden: configuredColumn == null ? void 0 : configuredColumn.hidden,
|
|
3197
|
+
isCalculated: (0, import_vuu_utils23.isCalculatedColumn)(name2),
|
|
3198
|
+
label: configuredColumn == null ? void 0 : configuredColumn.label,
|
|
3199
|
+
name: name2,
|
|
3200
|
+
serverDataType,
|
|
3201
|
+
subscribed: configuredColumn !== void 0
|
|
3202
|
+
};
|
|
3203
|
+
});
|
|
3204
|
+
};
|
|
3205
|
+
var useTableSettings = ({
|
|
3206
|
+
availableColumns: availableColumnsProp,
|
|
3207
|
+
onConfigChange,
|
|
3208
|
+
onDataSourceConfigChange,
|
|
3209
|
+
tableConfig: tableConfigProp
|
|
3210
|
+
}) => {
|
|
3211
|
+
const [{ availableColumns, tableConfig }, setColumnState] = (0, import_react19.useState)({
|
|
3212
|
+
availableColumns: availableColumnsProp,
|
|
3213
|
+
tableConfig: tableConfigProp
|
|
3214
|
+
});
|
|
3215
|
+
const columnItems = (0, import_react19.useMemo)(
|
|
3216
|
+
() => buildColumnItems(availableColumns, tableConfig.columns),
|
|
3217
|
+
[availableColumns, tableConfig.columns]
|
|
3218
|
+
);
|
|
3219
|
+
const handleMoveListItem = (0, import_react19.useCallback)(
|
|
3220
|
+
(fromIndex, toIndex) => {
|
|
3221
|
+
setColumnState((state) => {
|
|
3222
|
+
const newAvailableColumns = (0, import_vuu_utils23.moveItem)(
|
|
3223
|
+
state.availableColumns,
|
|
3224
|
+
fromIndex,
|
|
3225
|
+
toIndex
|
|
3226
|
+
);
|
|
3227
|
+
const newColumns = sortOrderFromAvailableColumns(
|
|
3228
|
+
newAvailableColumns,
|
|
3229
|
+
tableConfig.columns
|
|
3230
|
+
);
|
|
3231
|
+
return {
|
|
3232
|
+
availableColumns: newAvailableColumns,
|
|
3233
|
+
tableConfig: {
|
|
3234
|
+
...state.tableConfig,
|
|
3235
|
+
columns: newColumns
|
|
3236
|
+
}
|
|
3237
|
+
};
|
|
3238
|
+
});
|
|
3239
|
+
},
|
|
3240
|
+
[tableConfig.columns]
|
|
3241
|
+
);
|
|
3242
|
+
const handleColumnChange = (0, import_react19.useCallback)(
|
|
3243
|
+
(name2, property, value) => {
|
|
3244
|
+
const columnItem = columnItems.find((col) => col.name === name2);
|
|
3245
|
+
if (property === "subscribed") {
|
|
3246
|
+
if (columnItem == null ? void 0 : columnItem.subscribed) {
|
|
3247
|
+
const subscribedColumns = tableConfig.columns.filter((col) => col.name !== name2).map((col) => col.name);
|
|
3248
|
+
setColumnState((state) => ({
|
|
3249
|
+
...state,
|
|
3250
|
+
tableConfig: {
|
|
3251
|
+
...tableConfig,
|
|
3252
|
+
columns: tableConfig.columns.filter(
|
|
3253
|
+
(0, import_vuu_utils23.subscribedOnly)(subscribedColumns)
|
|
3254
|
+
)
|
|
3255
|
+
}
|
|
3256
|
+
}));
|
|
3257
|
+
onDataSourceConfigChange({
|
|
3258
|
+
columns: subscribedColumns
|
|
3259
|
+
});
|
|
3260
|
+
} else {
|
|
3261
|
+
const newConfig = {
|
|
3262
|
+
...tableConfig,
|
|
3263
|
+
columns: (0, import_vuu_utils23.addColumnToSubscribedColumns)(
|
|
3264
|
+
tableConfig.columns,
|
|
3265
|
+
availableColumns,
|
|
3266
|
+
name2
|
|
3267
|
+
)
|
|
3268
|
+
};
|
|
3269
|
+
setColumnState((state) => ({
|
|
3270
|
+
...state,
|
|
3271
|
+
tableConfig: newConfig
|
|
3272
|
+
}));
|
|
3273
|
+
const subscribedColumns = newConfig.columns.map((col) => col.name);
|
|
3274
|
+
onDataSourceConfigChange({
|
|
3275
|
+
columns: subscribedColumns
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3278
|
+
} else if (columnItem == null ? void 0 : columnItem.subscribed) {
|
|
3279
|
+
const column = tableConfig.columns.find((col) => col.name === name2);
|
|
3280
|
+
if (column) {
|
|
3281
|
+
const newConfig = (0, import_vuu_table.updateTableConfig)(tableConfig, {
|
|
3282
|
+
type: "column-prop",
|
|
3283
|
+
property,
|
|
3284
|
+
column,
|
|
3285
|
+
value
|
|
3286
|
+
});
|
|
3287
|
+
setColumnState((state) => ({
|
|
3288
|
+
...state,
|
|
3289
|
+
tableConfig: newConfig
|
|
3290
|
+
}));
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
},
|
|
3294
|
+
[availableColumns, columnItems, onDataSourceConfigChange, tableConfig]
|
|
3295
|
+
);
|
|
3296
|
+
const handleChangeColumnLabels = (0, import_react19.useCallback)((evt) => {
|
|
3297
|
+
const button = (0, import_vuu_utils23.queryClosest)(evt.target, "button");
|
|
3298
|
+
if (button) {
|
|
3299
|
+
const value = parseInt(button.value);
|
|
3300
|
+
const columnFormatHeader = value === 0 ? void 0 : value === 1 ? "capitalize" : "uppercase";
|
|
3301
|
+
setColumnState((state) => ({
|
|
3302
|
+
...state,
|
|
3303
|
+
tableConfig: {
|
|
3304
|
+
...state.tableConfig,
|
|
3305
|
+
columnFormatHeader
|
|
3306
|
+
}
|
|
3307
|
+
}));
|
|
3308
|
+
}
|
|
3309
|
+
}, []);
|
|
3310
|
+
const handleChangeTableAttribute = (0, import_react19.useCallback)(
|
|
3311
|
+
(evt) => {
|
|
3312
|
+
const button = (0, import_vuu_utils23.queryClosest)(evt.target, "button");
|
|
3313
|
+
if (button) {
|
|
3314
|
+
const { ariaPressed, value } = button;
|
|
3315
|
+
console.log({ ariaPressed, value, button });
|
|
3316
|
+
setColumnState((state) => ({
|
|
3317
|
+
...state,
|
|
3318
|
+
tableConfig: {
|
|
3319
|
+
...state.tableConfig,
|
|
3320
|
+
[value]: ariaPressed !== "true"
|
|
3321
|
+
}
|
|
3322
|
+
}));
|
|
3323
|
+
}
|
|
3324
|
+
},
|
|
3325
|
+
[]
|
|
3326
|
+
);
|
|
3327
|
+
const handleCommitColumnWidth = (0, import_react19.useCallback)((_, value) => {
|
|
3328
|
+
const columnDefaultWidth = parseInt(value);
|
|
3329
|
+
if (!isNaN(columnDefaultWidth)) {
|
|
3330
|
+
setColumnState((state) => ({
|
|
3331
|
+
...state,
|
|
3332
|
+
tableConfig: {
|
|
3333
|
+
...state.tableConfig,
|
|
3334
|
+
columnDefaultWidth
|
|
3335
|
+
}
|
|
3336
|
+
}));
|
|
3337
|
+
}
|
|
3338
|
+
console.log({ value });
|
|
3339
|
+
}, []);
|
|
3340
|
+
(0, import_vuu_utils23.useLayoutEffectSkipFirst)(() => {
|
|
3341
|
+
onConfigChange == null ? void 0 : onConfigChange(tableConfig);
|
|
3342
|
+
}, [onConfigChange, tableConfig]);
|
|
3343
|
+
const columnLabelsValue = tableConfig.columnFormatHeader === void 0 ? 0 : tableConfig.columnFormatHeader === "capitalize" ? 1 : 2;
|
|
3344
|
+
return {
|
|
3345
|
+
columnItems,
|
|
3346
|
+
columnLabelsValue,
|
|
3347
|
+
onChangeColumnLabels: handleChangeColumnLabels,
|
|
3348
|
+
onChangeTableAttribute: handleChangeTableAttribute,
|
|
3349
|
+
onColumnChange: handleColumnChange,
|
|
3350
|
+
onCommitColumnWidth: handleCommitColumnWidth,
|
|
3351
|
+
onMoveListItem: handleMoveListItem,
|
|
3352
|
+
tableConfig
|
|
3353
|
+
};
|
|
3354
|
+
};
|
|
3355
|
+
|
|
3356
|
+
// src/table-settings/TableSettingsPanel.tsx
|
|
3357
|
+
var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
|
|
3358
|
+
var import_vuu_ui_controls9 = require("@vuu-ui/vuu-ui-controls");
|
|
3359
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3360
|
+
var classBase15 = "vuuTableSettingsPanel";
|
|
3361
|
+
var TableSettingsPanel = ({
|
|
3362
|
+
allowColumnLabelCase = true,
|
|
3363
|
+
allowColumnDefaultWidth = true,
|
|
3364
|
+
allowGridRowStyling = true,
|
|
3365
|
+
availableColumns,
|
|
3366
|
+
onAddCalculatedColumn,
|
|
3367
|
+
onConfigChange,
|
|
3368
|
+
onDataSourceConfigChange,
|
|
3369
|
+
onNavigateToColumn,
|
|
3370
|
+
tableConfig: tableConfigProp
|
|
3371
|
+
}) => {
|
|
3372
|
+
var _a, _b, _c;
|
|
3373
|
+
const {
|
|
3374
|
+
columnItems,
|
|
3375
|
+
columnLabelsValue,
|
|
3376
|
+
onChangeColumnLabels,
|
|
3377
|
+
onChangeTableAttribute,
|
|
3378
|
+
onColumnChange,
|
|
3379
|
+
onCommitColumnWidth,
|
|
3380
|
+
onMoveListItem,
|
|
3381
|
+
tableConfig
|
|
3382
|
+
} = useTableSettings({
|
|
3383
|
+
availableColumns,
|
|
3384
|
+
onConfigChange,
|
|
3385
|
+
onDataSourceConfigChange,
|
|
3386
|
+
tableConfig: tableConfigProp
|
|
3387
|
+
});
|
|
3388
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: classBase15, children: [
|
|
3389
|
+
allowColumnLabelCase || allowColumnDefaultWidth || allowGridRowStyling ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `${classBase15}-header`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "Column Settings" }) }) : null,
|
|
3390
|
+
allowColumnDefaultWidth ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_core9.FormField, { children: [
|
|
3391
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_core9.FormFieldLabel, { children: "Column Width" }),
|
|
3392
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3393
|
+
import_vuu_ui_controls9.VuuInput,
|
|
3394
|
+
{
|
|
3395
|
+
className: "vuuInput",
|
|
3396
|
+
"data-embedded": true,
|
|
3397
|
+
onCommit: onCommitColumnWidth
|
|
3398
|
+
}
|
|
3399
|
+
)
|
|
3400
|
+
] }) : null,
|
|
3401
|
+
allowColumnLabelCase ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_core9.FormField, { children: [
|
|
3402
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_core9.FormFieldLabel, { children: "Column Labels" }),
|
|
3403
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3404
|
+
import_core9.ToggleButtonGroup,
|
|
3405
|
+
{
|
|
3406
|
+
className: "vuuToggleButtonGroup",
|
|
3407
|
+
onChange: onChangeColumnLabels,
|
|
3408
|
+
value: columnLabelsValue,
|
|
3409
|
+
children: [
|
|
3410
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_core9.ToggleButton, { className: "vuuIconToggleButton", value: 0, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_vuu_ui_controls8.Icon, { name: "text-strikethrough", size: 48 }) }),
|
|
3411
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_core9.ToggleButton, { className: "vuuIconToggleButton", value: 1, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_vuu_ui_controls8.Icon, { name: "text-Tt", size: 48 }) }),
|
|
3412
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_core9.ToggleButton, { className: "vuuIconToggleButton", value: 2, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_vuu_ui_controls8.Icon, { name: "text-T", size: 48 }) })
|
|
3413
|
+
]
|
|
3414
|
+
}
|
|
3415
|
+
)
|
|
3416
|
+
] }) : null,
|
|
3417
|
+
allowGridRowStyling ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_core9.FormField, { children: [
|
|
3418
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_core9.FormFieldLabel, { children: "Grid separators" }),
|
|
3419
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "saltToggleButtonGroup vuuStateButtonGroup saltToggleButtonGroup-horizontal", children: [
|
|
3420
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3421
|
+
import_core9.ToggleButton,
|
|
3422
|
+
{
|
|
3423
|
+
selected: (_a = tableConfig.zebraStripes) != null ? _a : false,
|
|
3424
|
+
onChange: onChangeTableAttribute,
|
|
3425
|
+
value: "zebraStripes",
|
|
3426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_vuu_ui_controls8.Icon, { name: "row-striping", size: 16 })
|
|
3427
|
+
}
|
|
3428
|
+
),
|
|
3429
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3430
|
+
import_core9.ToggleButton,
|
|
3431
|
+
{
|
|
3432
|
+
selected: (_b = tableConfig.rowSeparators) != null ? _b : false,
|
|
3433
|
+
onChange: onChangeTableAttribute,
|
|
3434
|
+
value: "rowSeparators",
|
|
3435
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_vuu_ui_controls8.Icon, { name: "row-lines", size: 16 })
|
|
3436
|
+
}
|
|
3437
|
+
),
|
|
3438
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3439
|
+
import_core9.ToggleButton,
|
|
3440
|
+
{
|
|
3441
|
+
selected: (_c = tableConfig.columnSeparators) != null ? _c : false,
|
|
3442
|
+
onChange: onChangeTableAttribute,
|
|
3443
|
+
value: "columnSeparators",
|
|
3444
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_vuu_ui_controls8.Icon, { name: "col-lines", size: 16 })
|
|
3445
|
+
}
|
|
3446
|
+
)
|
|
3447
|
+
] })
|
|
3448
|
+
] }) : null,
|
|
3449
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3450
|
+
ColumnList,
|
|
3451
|
+
{
|
|
3452
|
+
columnItems,
|
|
3453
|
+
onChange: onColumnChange,
|
|
3454
|
+
onMoveListItem,
|
|
3455
|
+
onNavigateToColumn
|
|
3456
|
+
}
|
|
3457
|
+
),
|
|
3458
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `${classBase15}-calculatedButtonbar`, children: [
|
|
3459
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_core9.Button, { "data-icon": "plus", onClick: onAddCalculatedColumn }),
|
|
3460
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: `${classBase15}-calculatedLabel`, children: "Add calculated column" })
|
|
3461
|
+
] })
|
|
3462
|
+
] });
|
|
3463
|
+
};
|
|
2
3464
|
//# sourceMappingURL=index.js.map
|