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