@vuu-ui/vuu-table-extras 0.8.7 → 0.8.8-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 +3552 -1
- package/cjs/index.js.map +4 -4
- package/esm/index.js +3727 -1
- package/esm/index.js.map +4 -4
- package/index.css +1288 -1
- package/index.css.map +3 -3
- package/package.json +13 -13
- package/types/vuu-data/src/array-data-source/array-data-source.d.ts +65 -0
- package/types/vuu-data/src/array-data-source/group-utils.d.ts +10 -0
- package/types/vuu-data/src/array-data-source/sort-utils.d.ts +4 -0
- package/types/vuu-data/src/authenticate.d.ts +1 -0
- package/types/vuu-data/src/connection-manager.d.ts +46 -0
- package/types/vuu-data/src/connectionTypes.d.ts +5 -0
- package/types/vuu-data/src/constants.d.ts +41 -0
- package/types/vuu-data/src/data-source.d.ts +172 -0
- package/types/vuu-data/src/index.d.ts +10 -0
- package/types/vuu-data/src/inlined-worker.d.ts +1 -0
- package/types/vuu-data/src/json-data-source.d.ts +53 -0
- package/types/vuu-data/src/message-utils.d.ts +26 -0
- package/types/vuu-data/src/remote-data-source.d.ts +56 -0
- package/types/vuu-data/src/server-proxy/messages.d.ts +43 -0
- package/types/vuu-data/src/vuuUIMessageTypes.d.ts +202 -0
- package/types/vuu-data/src/websocket-connection.d.ts +25 -0
- package/types/vuu-table-extras/src/column-list/ColumnList.d.ts +12 -0
- package/types/vuu-table-extras/src/column-list/index.d.ts +1 -0
- package/types/{index.d.ts → vuu-table-extras/src/index.d.ts} +1 -0
- package/types/vuu-table-extras/src/table-settings/TableSettingsPanel.d.ts +15 -0
- package/types/vuu-table-extras/src/table-settings/index.d.ts +2 -0
- package/types/vuu-table-extras/src/table-settings/useTableSettings.d.ts +14 -0
- package/LICENSE +0 -201
- package/types/table-settings/column-picker/ColumnListItem.d.ts +0 -4
- package/types/table-settings/column-picker/ColumnPicker.d.ts +0 -13
- package/types/table-settings/column-picker/index.d.ts +0 -1
- /package/types/{cell-renderers → vuu-table-extras/src/cell-renderers}/background-cell/BackgroundCell.d.ts +0 -0
- /package/types/{cell-renderers → vuu-table-extras/src/cell-renderers}/background-cell/index.d.ts +0 -0
- /package/types/{cell-renderers → vuu-table-extras/src/cell-renderers}/background-cell/useDirection.d.ts +0 -0
- /package/types/{cell-renderers → vuu-table-extras/src/cell-renderers}/index.d.ts +0 -0
- /package/types/{cell-renderers → vuu-table-extras/src/cell-renderers}/progress-cell/ProgressCell.d.ts +0 -0
- /package/types/{cell-renderers → vuu-table-extras/src/cell-renderers}/progress-cell/index.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/ColumnExpressionInput.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-function-descriptors.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-language-parser/ColumnExpressionLanguage.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-language-parser/ColumnExpressionTreeWalker.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-language-parser/column-expression-parse-utils.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-language-parser/generated/column-parser.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-language-parser/generated/column-parser.terms.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-language-parser/index.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/column-language-parser/test.d.mts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/functionDocInfo.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/highlighting.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/index.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/theme.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/useColumnAutoComplete.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/useColumnExpressionEditor.d.ts +0 -0
- /package/types/{column-expression-input → vuu-table-extras/src/column-expression-input}/useColumnExpressionSuggestionProvider.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/calculated-column-panel/CalculatedColumnPanel.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/calculated-column-panel/index.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-picker/ColumnListItem.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-picker/ColumnPicker.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-picker/index.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-settings-panel/ColumnSettingsPanel.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-settings-panel/index.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-type-panel/ColumnTypePanel.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-type-panel/NumericColumnPanel.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-type-panel/StringColumnPanel.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/column-type-panel/index.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/index.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/settings-panel/DatagridSettingsPanel.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/settings-panel/GridSettingsPanel.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/settings-panel/index.d.ts +0 -0
- /package/types/{datagrid-configuration-ui → vuu-table-extras/src/datagrid-configuration-ui}/settings-panel/useGridSettings.d.ts +0 -0
- /package/types/{datasource-stats → vuu-table-extras/src/datasource-stats}/DatasourceStats.d.ts +0 -0
- /package/types/{datasource-stats → vuu-table-extras/src/datasource-stats}/index.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/calculated-column-panel/CalculatedColumnPanel.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/calculated-column-panel/index.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/column-settings-panel/ColumnSettingsPanel.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/column-settings-panel/index.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/column-type-panel/ColumnTypePanel.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/column-type-panel/NumericColumnPanel.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/column-type-panel/StringColumnPanel.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/column-type-panel/index.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/index.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/settings-panel/DatagridSettingsPanel.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/settings-panel/GridSettingsPanel.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/settings-panel/index.d.ts +0 -0
- /package/types/{table-settings → vuu-table-extras/src/table-settings-deprecated}/settings-panel/useGridSettings.d.ts +0 -0
package/cjs/index.js
CHANGED
|
@@ -1,2 +1,3553 @@
|
|
|
1
|
-
"use strict";var Nt=Object.create;var Ue=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var It=(e,n)=>{for(var t in n)Ue(e,t,{get:n[t],enumerable:!0})},wn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of At(n))!Qt.call(e,i)&&i!==t&&Ue(e,i,{get:()=>n[i],enumerable:!(o=kt(n,i))||o.enumerable});return e};var Y=(e,n,t)=>(t=e!=null?Nt(Lt(e)):{},wn(n||!e||!e.__esModule?Ue(t,"default",{value:e,enumerable:!0}):t,e)),Bt=e=>wn(Ue({},"__esModule",{value:!0}),e);var Fn=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)};var c=(e,n,t)=>(Fn(e,n,"read from private field"),t?t.call(e):n.get(e)),I=(e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)},j=(e,n,t,o)=>(Fn(e,n,"write to private field"),o?o.call(e,t):n.set(e,t),t);var Wo={};It(Wo,{ColumnExpressionInput:()=>bn,ColumnNamedTerms:()=>ze,ColumnSettingsPanel:()=>Go,DataSourceStats:()=>Qo,DatagridSettingsPanel:()=>Lo,columnExpressionLanguageSupport:()=>tn,isCompleteExpression:()=>cn,isCompleteRelationalExpression:()=>mn,lastNamedChild:()=>Ze,useColumnExpressionEditor:()=>hn,useColumnExpressionSuggestionProvider:()=>En,walkTree:()=>un});module.exports=Bt(Wo);var R=require("@vuu-ui/vuu-utils"),Nn=Y(require("classnames"),1);var te=require("@vuu-ui/vuu-utils"),He=require("react"),Mt=[void 0,void 0,void 0,void 0];function Rn(e,n,t){var E;let o=(0,He.useRef)(),[i,r,s,p]=o.current||Mt,{type:l}=t,u=(0,te.isTypeDescriptor)(l)?(E=l.formatting)==null?void 0:E.decimals:void 0,g=e===i&&(0,te.isValidNumber)(n)&&(0,te.isValidNumber)(r)&&t===s?(0,te.getMovingValueDirection)(n,p,r,u):"";return(0,He.useEffect)(()=>{o.current=[e,n,t,g]}),g}var We=require("react/jsx-runtime"),$t=String.fromCharCode(11014),Ut=String.fromCharCode(11015),{KEY:Ht}=R.metadataKeys,Ge="vuuBackgroundCell",De={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},Gt=e=>(0,R.isTypeDescriptor)(e)&&e.renderer&&"flashStyle"in e.renderer?e.renderer.flashStyle:De.BackgroundOnly,Wt=({column:e,row:n})=>{let{key:t,type:o,valueFormatter:i}=e,r=n[t],s=Gt(o),p=Rn(n[Ht],r,e),l=s===De.ArrowOnly||s===De.ArrowBackground?p===R.UP1||p===R.UP2?$t:p===R.DOWN1||p===R.DOWN2?Ut:null:null,u=p?" "+p:"",g=(0,Nn.default)(Ge,u,{[`${Ge}-arrowOnly`]:s===De.ArrowOnly,[`${Ge}-arrowBackground`]:s===De.ArrowBackground});return(0,We.jsxs)("div",{className:g,tabIndex:-1,children:[(0,We.jsx)("div",{className:`${Ge}-flasher`,children:l}),i(n[e.key])]})};(0,R.registerComponent)("background",Wt,"cell-renderer",{serverDataType:["long","int","double"]});var pe=require("@vuu-ui/vuu-utils"),kn=Y(require("classnames"),1);var oe=require("react/jsx-runtime"),we="vuuProgressCell",Xt=({column:e,columnMap:n,row:t})=>{let{type:o}=e,i=t[e.key],r=!1,s=0;if((0,pe.isTypeDescriptor)(o)&&(0,pe.isColumnTypeRenderer)(o.renderer)){let{associatedField:l}=o.renderer,u=t[n[l]];if(typeof i=="number"&&typeof u=="number")s=Math.min(Math.round(i/u*100),100),r=isFinite(s);else{let g=parseFloat(i);if(Number.isFinite(g)){let E=parseFloat(u);Number.isFinite(E)&&(s=Math.min(Math.round(g/E*100),100),r=isFinite(s))}}}let p=(0,kn.default)(we,{});return(0,oe.jsxs)("div",{className:p,tabIndex:-1,children:[r?(0,oe.jsxs)("span",{className:`${we}-track`,children:[(0,oe.jsx)("span",{className:`${we}-bg`}),(0,oe.jsx)("span",{className:`${we}-bar`,style:{"--progress-bar-pct":`-${100-s}%`}})]}):null,(0,oe.jsx)("span",{className:`${we}-text`,children:`${s} %`})]})};(0,pe.registerComponent)("vuu.progress",Xt,"cell-renderer",{serverDataType:["long","int","double"]});var P=require("@vuu-ui/vuu-codemirror"),xn=require("@vuu-ui/vuu-utils"),ee=require("react");var B=require("@vuu-ui/vuu-codemirror");var An=require("@lezer/lr"),Xe=An.LRParser.deserialize({version:14,states:"&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",stateData:")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",goto:"#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",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:375});var Vt=B.LRLanguage.define({name:"VuuColumnExpression",parser:Xe.configure({props:[(0,B.styleTags)({Function:B.tags.variableName,String:B.tags.string,Or:B.tags.emphasis,Operator:B.tags.operator})]})}),tn=()=>new B.LanguageSupport(Vt);var on=class{constructor(n){switch(this.value=n,typeof n){case"boolean":this.type="booleanLiteralExpression";break;case"number":this.type="numericLiteralExpression";break;default:this.type="stringLiteralExpression"}}toJSON(){return{type:this.type,value:this.value}}},rn=class{constructor(n){this.type="colExpression";this.column=n}toJSON(){return{type:this.type,column:this.column}}},Re,se,sn=class{constructor(n="unknown"){I(this,Re,[{type:"unknown"},{type:"unknown"}]);I(this,se,void 0);this.type="arithmeticExpression";j(this,se,n)}get op(){return c(this,se)}set op(n){j(this,se,n)}get expressions(){return c(this,Re)}toJSON(){return{type:this.type,op:c(this,se),expressions:c(this,Re)}}};Re=new WeakMap,se=new WeakMap;var de,an=class{constructor(n){I(this,de,[]);this.type="callExpression";this.functionName=n}get expressions(){return c(this,de)}get arguments(){return c(this,de)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:c(this,de).map(n=>{var t;return(t=n.toJSON)==null?void 0:t.call(n)})}}};de=new WeakMap;var Ne,ge,ce=class{constructor(){I(this,Ne,[{type:"unknown"},{type:"unknown"}]);I(this,ge,"unknown");this.type="relationalExpression"}get op(){return c(this,ge)}set op(n){j(this,ge,n)}get expressions(){return c(this,Ne)}toJSON(){return{type:this.type,op:c(this,ge),expressions:c(this,Ne)}}};Ne=new WeakMap,ge=new WeakMap;var ke,fe,me=class{constructor(n){I(this,ke,[{type:"unknown"},{type:"unknown"}]);I(this,fe,void 0);this.type="booleanCondition";j(this,fe,n)}get op(){return c(this,fe)}get expressions(){return c(this,ke)}toJSON(){return{type:this.type,op:c(this,fe),expressions:c(this,ke).map(n=>{var t;return(t=n.toJSON)==null?void 0:t.call(n)})}}};ke=new WeakMap,fe=new WeakMap;var U,Fe=class{constructor(n){I(this,U,void 0);this.type="conditionalExpression";j(this,U,[n?new me(n):new ce,{type:"unknown"},{type:"unknown"}])}get expressions(){return c(this,U)}get condition(){return c(this,U)[0]}get truthyExpression(){return c(this,U)[1]}set truthyExpression(n){c(this,U)[1]=n}get falsyExpression(){return c(this,U)[2]}set falsyExpression(n){c(this,U)[2]=n}toJSON(){var n,t,o,i,r;return{type:this.type,condition:(t=(n=this.condition).toJSON)==null?void 0:t.call(n),truthyExpression:this.truthyExpression,falsyExpression:(r=(i=(o=this.falsyExpression)==null?void 0:o.toJSON)==null?void 0:i.call(o))!=null?r:this.falsyExpression}}};U=new WeakMap;var re=e=>e.type==="unknown",Ve=e=>e.type==="arithmeticExpression",Yt=e=>e.type==="callExpression",ue=e=>e.type==="conditionalExpression",zt=e=>e.type==="relationalExpression"||e.type==="booleanCondition";var Zt=e=>e.type==="booleanCondition",pn=e=>(e==null?void 0:e.type)==="relationalExpression";var L=e=>{if(re(e))return e;if(pn(e)){let[n,t]=e.expressions;if(D(n))return L(n);if(e.op==="unknown")return e;if(D(t))return L(t)}else if(zt(e)){let{expressions:n=[]}=e;for(let t of n)if(D(t))return L(t)}else if(ue(e)){let{condition:n,truthyExpression:t,falsyExpression:o}=e;if(D(n))return L(n);if(D(t))return L(t);if(D(o))return L(o)}else if(Ve(e)){let{expressions:n=[]}=e;for(let t of n)if(D(t))return L(t)}},Ye=(e,n,t)=>{let{expressions:o=[]}=e;if(o.includes(n)){let i=o.indexOf(n);return o.splice(i,1,t),!0}else for(let i of o)if(Ye(i,n,t))return!0;return!1},D=e=>re(e)?!0:ue(e)?D(e.condition)||D(e.truthyExpression)||D(e.falsyExpression):pn(e)||Zt(e)?e.op===void 0||e.expressions.some(n=>D(n)):!1,Ln=(e,n)=>{let t=L(e);t?t.expressions?t.expressions.push(n):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},C,ie,ln=class{constructor(){I(this,C,void 0);I(this,ie,[])}setCondition(n){if(c(this,C)===void 0)this.addExpression(new Fe(n));else if(ue(c(this,C))){if(D(c(this,C).condition)){let t=n?new me(n):new ce;this.addExpression(t)}else if(re(c(this,C).truthyExpression))c(this,C).truthyExpression=new Fe(n);else if(D(c(this,C).truthyExpression)){let t=n?new me(n):new ce;this.addExpression(t)}else if(re(c(this,C).falsyExpression))c(this,C).falsyExpression=new Fe(n);else if(D(c(this,C).falsyExpression)){let t=n?new me(n):new ce;this.addExpression(t)}}else console.error("setCondition called unexpectedly")}addExpression(n){if(c(this,ie).length>0){let t=c(this,ie).at(-1);t==null||t.arguments.push(n)}else if(c(this,C)===void 0)j(this,C,n);else if(Ve(c(this,C))){let t=L(c(this,C));t&&re(t)&&Ye(c(this,C),t,n)}else if(ue(c(this,C))&&D(c(this,C))){let t=L(c(this,C));t&&re(t)?Ye(c(this,C),t,n):t&&Ln(t,n)}}setFunction(n){let t=new an(n);this.addExpression(t),c(this,ie).push(t)}setColumn(n){this.addExpression(new rn(n))}setArithmeticOp(n){let t=n,o=c(this,C);Ve(o)&&(o.op=t)}setRelationalOperator(n){let t=n;if(c(this,C)&&ue(c(this,C))){let o=L(c(this,C));pn(o)?o.op=t:console.error(`no target expression found (op = ${n})`)}}setValue(n){let t=new on(n);if(c(this,C)===void 0)j(this,C,t);else if(Ve(c(this,C)))this.addExpression(t);else if(Yt(c(this,C)))c(this,C).arguments.push(t);else if(ue(c(this,C)))if(D(c(this,C))){let o=L(c(this,C));o&&re(o)?Ye(c(this,C),o,t):o&&Ln(o,t)}else console.log("what do we do with value, in a complete expression")}closeBrace(){c(this,ie).pop()}get expression(){return c(this,C)}toJSON(){var n;return(n=c(this,C))==null?void 0:n.toJSON()}};C=new WeakMap,ie=new WeakMap;var un=(e,n)=>{let t=new ln,o=e.cursor();do{let{name:i,from:r,to:s}=o;switch(i){case"AndCondition":t.setCondition("and");break;case"OrCondition":t.setCondition("or");break;case"RelationalExpression":t.setCondition();break;case"ArithmeticExpression":t.addExpression(new sn);break;case"Column":{let p=n.substring(r,s);t.setColumn(p)}break;case"Function":{let p=n.substring(r,s);t.setFunction(p)}break;case"Times":case"Divide":case"Plus":case"Minus":{let p=n.substring(r,s);t.setArithmeticOp(p)}break;case"RelationalOperator":{let p=n.substring(r,s);t.setRelationalOperator(p)}break;case"False":case"True":{let p=n.substring(r,s);t.setValue(p==="true")}break;case"String":t.setValue(n.substring(r+1,s-1));break;case"Number":t.setValue(parseFloat(n.substring(r,s)));break;case"CloseBrace":t.closeBrace();break;default:}}while(o.next());return t.toJSON()};var Jt=Xe.configure({strict:!0}),Qn=["Number","String"],ze=[...Qn,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],cn=e=>{try{return Jt.parse(e),!0}catch{return!1}},Ze=e=>{let{lastChild:n}=e;for(;n&&!ze.includes(n.name);)n=n.prevSibling,console.log(n==null?void 0:n.name);return n},mn=e=>{if((e==null?void 0:e.name)==="RelationalExpression"){let{firstChild:n}=e,t=Ze(e);if((n==null?void 0:n.name)==="Column"&&typeof(t==null?void 0:t.name)=="string"&&Qn.includes(t.name))return!0}return!1};var ae=require("@vuu-ui/vuu-codemirror"),qt=ae.HighlightStyle.define([{tag:ae.tags.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:ae.tags.comment,color:"green",fontStyle:"italic"}]),In=(0,ae.syntaxHighlighting)(qt);var Bn=require("@vuu-ui/vuu-codemirror"),Mn=Bn.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-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",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 S=require("@vuu-ui/vuu-codemirror"),fn=require("react");var _t=(e,n)=>n?e.map(t=>{var o;return{...t,apply:typeof t.apply=="function"?t.apply:`${n}${(o=t.apply)!=null?o:t.label}`}}):e,Kt=e=>e===void 0?!1:["Times","Divide","Plus","Minus"].includes(e.name),Ce=(e,n)=>{var i;let{lastChild:t}=e,{pos:o}=n;for(;t;)if(t.from<o&&ze.includes(t.name)){if(t.name==="ParenthesizedExpression"){let s=(i=t.firstChild)==null?void 0:i.nextSibling;s&&(t=s)}return t}else t=t.prevSibling},$n=(e,n)=>{var t;if(e.name==="ArgList"){let o=e.prevSibling;if(o)return(0,S.getValue)(o,n)}else if(e.name==="OpenBrace"){let o=(t=e.parent)==null?void 0:t.prevSibling;if((o==null?void 0:o.name)==="Function")return(0,S.getValue)(o,n)}},Un=(e,n)=>{if(e.name==="RelationalExpression"){let t=Ze(e);if((t==null?void 0:t.name)==="RelationalOperator")return(0,S.getValue)(t,n)}else{let t=e.prevSibling;if((t==null?void 0:t.name)==="RelationalOperator")return(0,S.getValue)(t,n)}},Cn=(e,n)=>{var t;if(e.name==="RelationalExpression"){if(((t=e.firstChild)==null?void 0:t.name)==="Column")return(0,S.getValue)(e.firstChild,n)}else{let o=e.prevSibling;if((o==null?void 0:o.name)==="Column")return(0,S.getValue)(o,n);if((o==null?void 0:o.name)==="RelationalOperator")return Cn(o,n)}},dn=async(e,n,t,o={})=>{let i=await n.getSuggestions(t,o),{startsWith:r=""}=o;return{from:e.pos-r.length,options:i}},gn=(e,n,t,o,i)=>{let r=Ce(e,n);switch(console.log(`conditional expression last child ${r==null?void 0:r.name}`),r==null?void 0:r.name){case"If":return dn(n,t,"expression",{prefix:"( "});case"OpenBrace":return dn(n,t,"expression");case"Condition":return dn(n,t,"expression",{prefix:", "});case"CloseBrace":if(o){let s=[{apply:()=>{i==null||i()},label:"Save Expression",boost:10}];return{from:n.pos,options:s}}}},jt=(e,n)=>{let t=[{apply:()=>{n==null||n()},label:"Save Expression",boost:10}];return{from:e.pos,options:t}},Hn=(e,n)=>{let t=(0,fn.useCallback)(async(o,i,r={})=>{let s=await e.getSuggestions(i,r),{startsWith:p=""}=r;return{from:o.pos-p.length,options:s}},[e]);return(0,fn.useCallback)(async o=>{var E,v;let{state:i,pos:r}=o,s=(E=o.matchBefore(/\w*/))!=null?E:{from:0,to:0,text:void 0},l=(0,S.syntaxTree)(i).resolveInner(r,-1),u=i.doc.toString(),g=cn(u);switch(console.log({nodeBeforeName:l.name}),l.name){case"If":return console.log("conditional expression If"),t(o,"expression",{prefix:"( "});case"Condition":{let a=Ce(l,o);if((a==null?void 0:a.name)==="Column"){let d=(0,S.getPreviousNode)(a);if((d==null?void 0:d.name)!=="RelationalOperator")return t(o,"condition-operator",{columnName:(0,S.getValue)(a,i)});console.log(`Condition last child Column, prev child ${d==null?void 0:d.name}`)}else if((a==null?void 0:a.name)==="RelationalOperator")return t(o,"expression");console.log(`condition last child ${a==null?void 0:a.name}`)}break;case"ConditionalExpression":return gn(l,o,e);case"RelationalExpression":{if(mn(l))return{from:o.pos,options:S.booleanJoinSuggestions.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let a=Un(l,i),d=Cn(l,i);if(a)return t(o,"expression");{let f=await e.getSuggestions("condition-operator",{columnName:d});return{from:o.pos,options:f}}}}break;case"RelationalOperator":return t(o,"expression");case"String":{let a=Un(l,i),d=Cn(l,i),{from:f,to:m}=l;if(m-f===2&&o.pos===f+1){if(d&&a)return t(o,"columnValue",{columnName:d,operator:a,startsWith:s.text})}else if(m-f>2&&o.pos===m)return t(o,"expression",{prefix:", "});console.log(`we have a string, column is ${d} ${f} ${m}`)}break;case"ArithmeticExpression":{let a=Ce(l,o);if((a==null?void 0:a.name)==="Column")return t(o,"expression");if(Kt(a)){let d=a.name;return t(o,"column",{operator:d})}}break;case"OpenBrace":{let a=$n(l,i);return t(o,"expression",{functionName:a})}break;case"ArgList":{let a=$n(l,i),d=Ce(l,o),f=(d==null?void 0:d.name)==="OpenBrace"?void 0:",",m=await e.getSuggestions("expression",{functionName:a});return m=f?_t(m,", "):m,(d==null?void 0:d.name)!=="OpenBrace"&&(d==null?void 0:d.name)!=="Comma"&&(m=[{apply:") ",boost:10,label:"Done - no more arguments"}].concat(m)),{from:o.pos,options:m}}case"Equal":if(u.trim()==="=")return t(o,"expression");break;case"ParenthesizedExpression":case"ColumnDefinitionExpression":if(o.pos===0)return t(o,"expression");{let a=Ce(l,o);if((a==null?void 0:a.name)==="Column"){if(g){let d=[{apply:()=>{n.current()},label:"Save Expression",boost:10}],f=(0,S.getValue)(a,i),m=await e.getSuggestions("operator",{columnName:f});return{from:o.pos,options:d.concat(m)}}}else if((a==null?void 0:a.name)==="CallExpression"){if(g){let d=[{apply:()=>{n.current()},label:"Save Expression",boost:10}];return{from:o.pos,options:d}}}else if((a==null?void 0:a.name)==="ArithmeticExpression"){if(g){let d=[{apply:()=>{n.current()},label:"Save Expression",boost:10}],f=Ce(a,o);if((f==null?void 0:f.name)==="Column"){let m=(0,S.getValue)(f,i),T=await e.getSuggestions("operator",{columnName:m});d=d.concat(T)}return{from:o.pos,options:d}}}else if((a==null?void 0:a.name)==="ConditionalExpression")return gn(a,o,e,g,n.current);break}case"Column":if(await e.isPartialMatch("expression",void 0,s.text))return t(o,"expression",{startsWith:s.text});break;case"Comma":{let a=(0,S.getNamedParentNode)(l);if((a==null?void 0:a.name)==="ConditionalExpression")return t(o,"expression")}break;case"CloseBrace":{let a=(0,S.getNamedParentNode)(l);if((a==null?void 0:a.name)==="ConditionalExpression")return gn(a,o,e,g,n.current);if((a==null?void 0:a.name)==="ArgList"&&g)return jt(o,n.current);console.log(`does closebrace denote an ARgList or a parenthetised expression ? ${a}`)}break;default:((v=l==null?void 0:l.prevSibling)==null?void 0:v.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[t,n,e])};var Ae=e=>{if(e.current==null)throw Error("EditorView not defined");return e.current},eo=()=>"vuuSuggestion",no=()=>console.log("noooop"),to=e=>"expressionType"in e,oo=e=>{if(to(e)){let n=(0,xn.createEl)("div","expression-type-container"),t=(0,xn.createEl)("span","expression-type",e.expressionType);return n.appendChild(t),n}else return null},hn=({onChange:e,onSubmitExpression:n,suggestionProvider:t})=>{let o=(0,ee.useRef)(null),i=(0,ee.useRef)(no),r=(0,ee.useRef)(),s=Hn(t,i),[p,l]=(0,ee.useMemo)(()=>{let u=()=>{let f=Ae(r),m=f.state.doc.toString(),T=(0,P.ensureSyntaxTree)(f.state,f.state.doc.length,5e3);if(T){let $=un(T,m);return[m,$]}else return["",void 0]},g=()=>{Ae(r).setState(d())},E=()=>{let[f,m]=u();n==null||n(f,m),g()},v=f=>P.keymap.of([{key:f,run(){return E(),!0}}]),a=f=>P.keymap.of([{key:f,run(){return(0,P.startCompletion)(Ae(r)),!0}}]),d=()=>P.EditorState.create({doc:"",extensions:[P.minimalSetup,(0,P.autocompletion)({addToOptions:[{render:oo,position:70}],override:[s],optionClass:eo}),tn(),P.keymap.of(P.defaultKeymap),v("Ctrl-Enter"),a("ArrowDown"),P.EditorView.updateListener.of(f=>{let m=Ae(r);if(f.docChanged){(0,P.startCompletion)(m);let T=m.state.doc.toString();e==null||e(T,void 0)}}),Mn,In]});return i.current=()=>{E(),setTimeout(()=>{Ae(r).focus()},100)},[d,g]},[s,e,n]);return(0,ee.useEffect)(()=>{if(!o.current)throw Error("editor not in dom");return r.current=new P.EditorView({state:p(),parent:o.current}),()=>{var u;(u=r.current)==null||u.destroy()}},[s,p]),{editorRef:o,clearInput:l}};var Gn=require("react/jsx-runtime"),ro="vuuColumnExpressionInput",bn=({onChange:e,onSubmitExpression:n,suggestionProvider:t})=>{let{editorRef:o}=hn({onChange:e,onSubmitExpression:n,suggestionProvider:t});return(0,Gn.jsx)("div",{className:`${ro}`,ref:o})};var G=require("@vuu-ui/vuu-codemirror"),Je=require("@vuu-ui/vuu-data-react"),be=require("@vuu-ui/vuu-utils"),he=require("react");var xe=[{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:"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 H=require("@vuu-ui/vuu-utils"),Wn=({name:e,description:n,example:t,params:o,type:i})=>{let r=(0,H.createEl)("div","vuuFunctionDoc"),s=(0,H.createEl)("div","function-heading"),p=(0,H.createEl)("span","function-name",e),l=(0,H.createEl)("span","param-list",o.description),u=(0,H.createEl)("span","function-type",i);s.appendChild(p),s.appendChild(l),s.appendChild(u);let g=(0,H.createEl)("p",void 0,n);if(r.appendChild(s),r.appendChild(g),t){let E=(0,H.createEl)("div","example-container","Example:"),v=(0,H.createEl)("div","example-expression",t.expression),a=(0,H.createEl)("div","example-result",t.result);E.appendChild(v),E.appendChild(a),r.appendChild(E)}return r};var so=[],le=e=>e.map(n=>{var t;return{...n,apply:((t=n.apply)!=null?t:n.label)+" "}}),io=(e,{functionName:n,operator:t})=>{if(t)return e.filter(be.isNumericColumn);if(n){let o=xe.find(i=>i.name===n);if(o)switch(o.accepts){case"string":return e.filter(be.isTextColumn);case"number":return e.filter(be.isNumericColumn);default:return e}}return e},Xn=(e,n)=>io(e,n).map(o=>{var r;let i=(r=o.label)!=null?r:o.name;return{apply:n.prefix?`${n.prefix}${i}`:i,label:i,boost:5,type:"column",expressionType:o.serverDataType}}),ao=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],lo=e=>e===void 0||(0,be.isNumericColumn)(e)?ao:so,po=e=>{switch(e.serverDataType){case"string":case"char":return le(G.stringOperators);case"int":case"long":case"double":return le(G.numericOperators)}},yn=e=>({apply:`${e.name}( `,boost:2,expressionType:e.type,info:()=>Wn(e),label:e.name,type:"function"}),uo=e=>{if(e){if(typeof e.accepts=="string")return e.accepts;if(Array.isArray(e.accepts))return e.accepts.every(n=>n==="string")?"string":"any"}return"any"},co=xe.map(yn),mo=({functionName:e})=>{if(e){let n=xe.find(o=>o.name===e),t=uo(n);if(n)switch(t){case"string":return xe.filter(o=>o.type==="string"||o.type==="variable").map(yn);case"number":return xe.filter(o=>o.type==="number"||o.type==="variable").map(yn);default:}}return co},go={},En=({columns:e,table:n})=>{let t=(0,he.useCallback)(p=>p?e.find(l=>l.name===p):void 0,[e]),o=(0,he.useRef)(),i=(0,Je.useTypeaheadSuggestions)(),r=(0,he.useCallback)(async(p,l=go)=>{let{columnName:u,functionName:g,operator:E,prefix:v}=l;switch(p){case"expression":{let a=await le(Xn(e,{functionName:g,prefix:v})).concat(mo(l));return o.current=a}case"column":{let a=await Xn(e,l);return o.current=le(a)}case"operator":{let a=await lo(t(u));return o.current=le(a)}case"relational-operator":{let a=await(0,G.getRelationalOperators)(t(u));return o.current=le(a)}case"condition-operator":{let a=t(u);if(a){let d=await po(a);if(d)return o.current=le(d)}}break;case"columnValue":if(u&&E){let a=(0,Je.getTypeaheadParams)(n,u),d=await i(a);return o.current=(0,G.toSuggestions)(d,{suffix:""}),o.current.forEach(f=>{f.apply=(m,T,$)=>{let nn=new G.AnnotationType,Te=$+T.label.length+1;m.dispatch({changes:{from:$,insert:T.label},selection:{anchor:Te,head:Te},annotations:nn.of(T)})}}),o.current}break}return[]},[e,t,i,n]),s=(0,he.useCallback)(async(p,l,u)=>{let{current:g}=o,E=!1,v=g||await r(p,{columnName:l});if(u&&v)for(let a of v){if(a.label===u)return!1;a.label.startsWith(u)&&(E=!0)}return E},[r]);return{getSuggestions:r,isPartialMatch:s}};var Pe=require("@salt-ds/core"),ft=Y(require("classnames"),1),q=require("react");var vn=require("@salt-ds/lab"),M=require("@salt-ds/core"),z=require("react");var Vn=require("@salt-ds/lab"),Yn=Y(require("classnames"),1);var Ee=require("react/jsx-runtime"),ye="vuuColumnListItem",zn=({className:e,item:n,label:t,style:o,...i})=>{let r=(0,Yn.default)(ye,e,{[`${ye}-calculated`]:n==null?void 0:n.expression,[`${ye}-hidden`]:n==null?void 0:n.hidden});return(0,Ee.jsxs)(Vn.ListItem,{className:r,...i,children:[(0,Ee.jsx)("span",{className:`${ye}-iconType`}),(0,Ee.jsx)("label",{className:`${ye}-label`,children:t}),(0,Ee.jsx)("span",{className:`${ye}-iconHidden`})]})};var O=require("react/jsx-runtime"),ve="vuuColumnPicker",fo=(e,n)=>e.filter(t=>n.find(o=>o.name===t.name)==null),Zn=({availableColumns:e,id:n,dispatchColumnAction:t,onAddCalculatedColumnClick:o,onSelectionChange:i,chosenColumns:r,selectedColumn:s})=>{let[p,l]=(0,z.useState)([]),u=(0,M.useIdMemo)(n),g=fo(e,r),E=(0,z.useCallback)(()=>{p.length>0&&(l([]),t({type:"addColumn",columns:p}))},[t,p]),v=(0,z.useCallback)(()=>s&&t({type:"removeColumn",column:s}),[s,t]),a=(0,z.useCallback)(()=>s&&t({type:"moveColumn",column:s,moveBy:-1}),[t,s]),d=(0,z.useCallback)(()=>s&&t({type:"moveColumn",column:s,moveBy:1}),[t,s]),f=(0,z.useCallback)((T,$)=>l($),[]),m=(0,z.useCallback)((T,$)=>i==null?void 0:i($),[i]);return(0,O.jsxs)("div",{className:ve,id:u,children:[(0,O.jsxs)("div",{className:`${ve}-listColumn`,children:[(0,O.jsx)("label",{htmlFor:`available-${u}`,children:(0,O.jsx)(M.Text,{as:"h4",children:"Available Columns"})}),(0,O.jsx)("div",{className:`${ve}-listContainer`,style:{flex:1,overflow:"hidden"},children:(0,O.jsx)(vn.List,{borderless:!0,checkable:!1,height:"100%",id:`available-${u}`,itemHeight:24,itemToString:T=>T.name,onSelectionChange:f,selected:p,selectionStrategy:"extended",source:g})}),(0,O.jsx)("div",{style:{display:"flex",alignItems:"center",flex:"0 0 32px",marginTop:"var(--salt-size-basis-unit)"},children:(0,O.jsxs)(M.Button,{onClick:E,disabled:p.length===0,children:["Show",(0,O.jsx)("span",{"data-icon":"arrow-thin-right",style:{marginLeft:8}})]})})]}),(0,O.jsxs)("div",{className:`${ve}-listColumn`,children:[(0,O.jsx)("label",{htmlFor:`selected-${u}`,children:(0,O.jsx)(M.Text,{as:"h4",children:"Included Columns"})}),(0,O.jsx)("div",{className:`${ve}-listContainer`,style:{flex:1,overflow:"hidden"},children:(0,O.jsx)(vn.List,{ListItem:zn,borderless:!0,height:"100%",id:`selected-${u}`,itemHeight:24,itemToString:T=>T.name,onSelectionChange:m,selected:s,style:{flex:1},source:r})}),(0,O.jsxs)("div",{style:{alignItems:"center",flex:"0 0 32px",display:"flex",gap:6,marginTop:"var(--salt-size-basis-unit)"},children:[(0,O.jsxs)(M.Button,{onClick:v,disabled:s===null,children:[(0,O.jsx)("span",{"data-icon":"arrow-thin-left",style:{marginRight:8}}),"Hide"]}),(0,O.jsx)(M.Button,{"aria-label":"Move column up",onClick:a,disabled:s===null||(r==null?void 0:r.indexOf(s))===0,style:{width:28},children:(0,O.jsx)("span",{"data-icon":"arrow-thin-up"})}),(0,O.jsx)(M.Button,{"aria-label":"Move column down",onClick:d,disabled:s===null||r.indexOf(s)===r.length-1,style:{width:28},children:(0,O.jsx)("span",{"data-icon":"arrow-thin-down"})}),(0,O.jsx)(M.Button,{"aria-label":"Add calculated column",className:`${ve}-addCalculatedColumn`,onClick:o,variant:"primary",children:(0,O.jsx)("span",{"data-icon":"add"})})]})]})]})};var rt=require("@vuu-ui/vuu-layout"),st=require("@salt-ds/lab"),x=require("@salt-ds/core"),it=Y(require("classnames"),1),J=require("react");var Kn=require("@vuu-ui/vuu-utils"),jn=require("@salt-ds/lab"),et=require("@salt-ds/core"),Pn=Y(require("classnames"),1),nt=require("react");var Qe=require("@salt-ds/lab"),Oe=require("@salt-ds/core"),Le=require("react");var k=require("react/jsx-runtime"),Co={alignOnDecimals:!1,decimals:4,zeroPad:!1},xo=(e,n)=>{let t=typeof e=="object"&&e.formatting?e.formatting:{};return["alignOnDecimals","decimals","zeroPad"].reduce((i,r)=>t[r]!==void 0?{...i,[r]:t[r]}:(n==null?void 0:n[r])!==void 0?{...i,[r]:n[r]}:i,Co)},Jn=({column:e,dispatchColumnAction:n})=>{let{decimals:t,alignOnDecimals:o,zeroPad:i}=xo(e==null?void 0:e.type),r=(0,Le.useCallback)(u=>n({type:"updateColumnTypeFormatting",column:e,...u}),[e,n]),s=(0,Le.useCallback)(u=>r({decimals:parseInt(u.toString(),10)}),[r]),p=(0,Le.useCallback)((u,g)=>r({alignOnDecimals:g}),[r]),l=(0,Le.useCallback)((u,g)=>r({zeroPad:g}),[r]);switch(e.serverDataType){case"double":return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(Oe.FormField,{labelPlacement:"top",children:[(0,k.jsx)(Oe.FormFieldLabel,{children:"No of Decimals"}),(0,k.jsx)(Qe.StepperInput,{value:t,onChange:s})]}),(0,k.jsx)(Qe.Switch,{checked:o,label:"Align on decimals",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:p}),(0,k.jsx)(Qe.Switch,{checked:i,label:"Zero pad",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:l})]});case"long":case"int":return(0,k.jsx)(k.Fragment,{children:(0,k.jsx)(Oe.Text,{children:"Work in progress"})});default:return null}};var qe=require("react/jsx-runtime"),qn=({column:e,dispatchColumnAction:n})=>(console.log({column:e,dispatchColumnAction:n}),(0,qe.jsx)(qe.Fragment,{children:"what"}));var Z=require("react/jsx-runtime"),On="vuuColumnTypePanel",ho=["Default Renderer (int, long)"],bo=["Default Renderer (double)"],_n=["Default Renderer (string)"],yo=e=>{let t=(0,Kn.getRegisteredCellRenderers)(e.serverDataType).map(o=>o.name);switch(console.log({customRendererNames:t}),e.serverDataType){case"char":case"string":return _n;case"int":case"long":return ho;case"double":return bo.concat(t);default:return _n}},tt=({className:e,column:n,dispatchColumnAction:t,...o})=>{let i=(0,nt.useMemo)(()=>{switch(n.serverDataType){case"double":case"int":case"long":return(0,Z.jsx)(Jn,{column:n,dispatchColumnAction:t});default:return(0,Z.jsx)(qn,{column:n,dispatchColumnAction:t})}},[n,t]),{serverDataType:r="string"}=n,s=yo(n);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jn.Dropdown,{className:(0,Pn.default)(`${On}-renderer`),fullWidth:!0,selected:s[0],source:s}),(0,Z.jsx)(et.Panel,{...o,className:(0,Pn.default)(On,e,`${On}-${r}`),children:i})]})};var b=require("react/jsx-runtime"),ot="vuuColumnSettingsPanel",Eo={className:"salt-density-high"},at=({column:e,dispatchColumnAction:n,style:t,...o})=>{var v,a,d,f;let[i,r]=(0,J.useState)(0),s=(0,J.useCallback)(m=>n({type:"updateColumnProp",column:e,...m}),[e,n]),p=(0,J.useCallback)(m=>s({align:m.target.value}),[s]),l=(0,J.useCallback)(m=>s({pin:m.target.value}),[s]),u=(0,J.useCallback)(m=>s({hidden:m.target.checked}),[s]),g=(0,J.useCallback)(m=>s({label:m.target.value}),[s]),E=(0,J.useCallback)(m=>s({width:parseInt(m.toString(),10)}),[s]);return(0,b.jsxs)("div",{className:ot,...o,style:{...t},children:[(0,b.jsx)(x.Text,{as:"h4",children:"Column Settings"}),(0,b.jsxs)(rt.Stack,{active:i,className:(0,it.default)(`${ot}-columnTabs`),onTabSelectionChanged:r,TabstripProps:Eo,children:[(0,b.jsxs)(x.Panel,{title:"Column",children:[(0,b.jsxs)(x.FormField,{labelPlacement:"left",children:[(0,b.jsx)(x.FormFieldLabel,{children:"Hidden"}),(0,b.jsx)(x.Checkbox,{checked:e.hidden===!0,onChange:u})]}),(0,b.jsxs)(x.FormField,{labelPlacement:"left",children:[(0,b.jsx)(x.FormFieldLabel,{children:"Label"}),(0,b.jsx)(x.Input,{value:(v=e.label)!=null?v:e.name,onChange:g})]}),(0,b.jsxs)(x.FormField,{labelPlacement:"left",children:[(0,b.jsx)(x.FormFieldLabel,{children:"Width"}),(0,b.jsx)(st.StepperInput,{value:(a=e.width)!=null?a:100,onChange:E})]}),(0,b.jsxs)(x.FormField,{labelPlacement:"left",children:[(0,b.jsx)(x.FormFieldLabel,{children:"ALign"}),(0,b.jsxs)(x.RadioButtonGroup,{"aria-label":"Column Align",value:(d=e.align)!=null?d:"left",onChange:p,children:[(0,b.jsx)(x.RadioButton,{label:"Left",value:"left"}),(0,b.jsx)(x.RadioButton,{label:"Right",value:"right"})]})]}),(0,b.jsxs)(x.FormField,{labelPlacement:"left",children:[(0,b.jsx)(x.FormFieldLabel,{children:"Pin Column"}),(0,b.jsxs)(x.RadioButtonGroup,{"aria-label":"Pin Column",value:(f=e.pin)!=null?f:"",onChange:l,children:[(0,b.jsx)(x.RadioButton,{label:"Do not pin",value:""}),(0,b.jsx)(x.RadioButton,{label:"Left",value:"left"}),(0,b.jsx)(x.RadioButton,{label:"Right",value:"right"})]})]})]}),(0,b.jsx)(tt,{column:e,dispatchColumnAction:n,title:"Data Cell"}),(0,b.jsxs)(x.Panel,{title:"Vuu",variant:"secondary",children:[(0,b.jsxs)(x.FormField,{labelPlacement:"top",readOnly:!0,children:[(0,b.jsx)(x.FormFieldLabel,{children:"Name"}),(0,b.jsx)(x.Input,{value:e.name})]}),(0,b.jsxs)(x.FormField,{labelPlacement:"top",readOnly:!0,children:[(0,b.jsx)(x.FormFieldLabel,{children:"Vuu Type"}),(0,b.jsx)(x.Input,{value:e.serverDataType})]})]})]})]})};var w=require("@salt-ds/core"),lt=require("@salt-ds/lab"),_e=require("react");var N=require("react/jsx-runtime"),vo="vuuGridSettingsPanel",pt=({config:e,dispatchColumnAction:n,style:t,...o})=>{var p;let i=(0,_e.useCallback)(l=>n({type:"updateGridSettings",...l}),[n]),r=(0,_e.useCallback)(l=>i({columnFormatHeader:l.target.value}),[i]),s=(0,_e.useCallback)(l=>i({columnDefaultWidth:parseInt(l.toString(),10)}),[i]);return(0,N.jsxs)("div",{className:vo,...o,style:{...t},children:[(0,N.jsx)(w.Text,{as:"h4",children:"Grid Settings"}),(0,N.jsxs)(w.Panel,{children:[(0,N.jsxs)(w.FormField,{labelPlacement:"left",children:[(0,N.jsx)(w.FormFieldLabel,{children:"Format column labels"}),(0,N.jsxs)(w.RadioButtonGroup,{"aria-label":"Format column labels",value:e.columnFormatHeader,onChange:r,children:[(0,N.jsx)(w.RadioButton,{label:"No Formatting",value:void 0}),(0,N.jsx)(w.RadioButton,{label:"Capitalize",value:"capitalize"}),(0,N.jsx)(w.RadioButton,{label:"Uppercase",value:"uppercase"})]})]}),(0,N.jsxs)(w.FormField,{labelPlacement:"left",children:[(0,N.jsx)(w.FormFieldLabel,{children:"Default Column Width"}),(0,N.jsx)(lt.StepperInput,{value:(p=e.columnDefaultWidth)!=null?p:100,onChange:s})]})]})]})};var ut=require("react"),ct=require("@vuu-ui/vuu-ui-controls"),mt=require("@vuu-ui/vuu-utils"),Oo=(e,n)=>{switch(console.log(`gridSettingsReducer ${n.type}`),n.type){case"addColumn":return Po(e,n);case"addCalculatedColumn":return So(e,n);case"moveColumn":return Do(e,n);case"removeColumn":return To(e,n);case"updateColumn":return e;case"updateColumnProp":return wo(e,n);case"updateGridSettings":return Fo(e,n);case"updateColumnTypeFormatting":return Ro(e,n);default:return e}},dt=e=>{let[n,t]=(0,ut.useReducer)(Oo,e);return{gridSettings:n,dispatchColumnAction:t}};function Po(e,{column:n,columns:t,index:o=-1}){let{columns:i}=e;if(o===-1){if(Array.isArray(t))return{...e,columns:i.concat(t)};if(n)return{...e,columns:i.concat(n)}}return e}function So(e,{columnName:n,columnType:t,expression:o}){let{columns:i}=e,r={name:n,expression:o,serverDataType:t};return{...e,columns:i.concat(r)}}function To(e,{column:n}){let{columns:t}=e;return{...e,columns:t.filter(o=>o.name!==n.name)}}function Do(e,{column:n,moveBy:t,moveFrom:o,moveTo:i}){let{columns:r}=e;if(n&&typeof t=="number"){let s=r.indexOf(n),p=r.slice(),[l]=p.splice(s,1);return p.splice(s+t,0,l),{...e,columns:p}}else return typeof o=="number"&&typeof i=="number"?{...e,columns:(0,ct.moveItem)(r,o,i)}:e}function wo(e,{align:n,column:t,hidden:o,label:i,width:r}){let{columns:s}=e;return(n==="left"||n==="right")&&(s=Ie(s,{...t,align:n})),typeof o=="boolean"&&(s=Ie(s,{...t,hidden:o})),typeof i=="string"&&(s=Ie(s,{...t,label:i})),typeof r=="number"&&(s=Ie(s,{...t,width:r})),{...e,columns:s}}function Fo(e,{columnFormatHeader:n}){return{...e,columnFormatHeader:n!=null?n:e.columnFormatHeader}}function Ro(e,{alignOnDecimals:n,column:t,decimals:o,zeroPad:i}){let{columns:r}=e;if(r.find(p=>p.name===t.name)){let{serverDataType:p="string",type:l=(0,mt.fromServerDataType)(p)}=t,u=typeof l=="string"?{name:l}:{...l};return typeof n=="boolean"&&(u.formatting={...u.formatting,alignOnDecimals:n}),typeof o=="number"&&(u.formatting={...u.formatting,decimals:o}),typeof i=="boolean"&&(u.formatting={...u.formatting,zeroPad:i}),{...e,columns:Ie(r,{...t,type:u})}}else return e}function Ie(e,n){return e.map(t=>t.name===n.name?n:t)}var Ct=require("@vuu-ui/vuu-layout");var Q=require("@salt-ds/core"),X=require("react");var W=require("react/jsx-runtime"),gt=({columns:e,dispatchColumnAction:n,table:t})=>{let[o,i]=(0,X.useState)(""),[,r]=(0,X.useState)(),s=(0,X.useRef)(""),p=En({columns:e,table:t}),l=(0,X.useCallback)(v=>{let{value:a}=v.target;i(a)},[]),u=(0,X.useCallback)(v=>{s.current=v},[]),g=(0,X.useCallback)((v,a)=>{console.log({source:v}),r(a)},[]),E=(0,X.useCallback)(()=>{s.current&&(console.log(`save expression ${JSON.stringify(s.current,null,2)}`),n({type:"addCalculatedColumn",columnName:o,expression:s.current,columnType:"string"}))},[o,n]);return(0,W.jsxs)(Q.Panel,{className:"vuuCalculatedColumnPanel",title:"Define Computed Column",children:[(0,W.jsx)(Q.Text,{styleAs:"h4",children:"Define Computed Column"}),(0,W.jsxs)(Q.FormField,{labelPlacement:"left",children:[(0,W.jsx)(Q.FormFieldLabel,{children:"Column Name"}),(0,W.jsx)(Q.Input,{value:o,onChange:l})]}),(0,W.jsx)(bn,{onChange:u,onSubmitExpression:g,suggestionProvider:p}),(0,W.jsx)("div",{style:{marginTop:12},children:(0,W.jsx)(Q.Button,{onClick:E,children:"Add Column"})})]})};var F=require("react/jsx-runtime"),Ke="vuuDatagridSettingsPanel",No=()=>{},ko=["table-settings","column-chooser","column-settings","define-column"],Ao=(e,n)=>ko[n],Lo=({availableColumns:e,className:n,gridConfig:t,onCancel:o,onConfigChange:i,...r})=>{var Te;console.log("DatagridSettingsPanel render");let[s,p]=(0,q.useState)(0),{gridSettings:l,dispatchColumnAction:u}=dt(t),[g,E]=(0,q.useState)(null),v=(0,q.useCallback)(V=>{E(V?V.name:null)},[]),a=(0,q.useCallback)((V,Rt=!1)=>{console.log("1) DataGridSettingsPanel fire onConfigChange"),i==null||i(l,Rt)},[l,i]),d=(0,q.useCallback)(V=>{p(V)},[]),f=(0,q.useCallback)(V=>a(V,!0),[a]),m=g===null?null:(Te=l.columns.find(V=>V.name===g))!=null?Te:null,T={activeTabIndex:s,allowRenameTab:!1,orientation:"vertical"},$=(0,q.useCallback)(()=>p(3),[]),nn=s===2?"right":void 0;return(0,F.jsxs)("div",{...r,className:(0,ft.default)(Ke,n),children:[(0,F.jsxs)(Ct.Stack,{TabstripProps:T,className:`${Ke}-stack`,getTabIcon:Ao,getTabLabel:No,active:s===2?1:s,onTabSelectionChanged:d,children:[(0,F.jsx)(pt,{config:l,dispatchColumnAction:u}),(0,F.jsxs)("div",{className:`${Ke}-columnPanels`,"data-align":nn,children:[(0,F.jsx)(Zn,{availableColumns:e,chosenColumns:l.columns,dispatchColumnAction:u,onSelectionChange:v,onAddCalculatedColumnClick:$,selectedColumn:m}),m===null?(0,F.jsx)(Pe.Panel,{className:"vuuColumnSettingsPanel",children:"Select a column"}):(0,F.jsx)(at,{column:m,dispatchColumnAction:u,style:{background:"white",flex:"1 0 150px"}})]}),(0,F.jsx)("div",{title:"Column Settings",children:"Column Settings"}),(0,F.jsx)(gt,{columns:l.columns,dispatchColumnAction:u,table:{module:"SIMUL",table:"instruments"}})]}),(0,F.jsxs)("div",{className:`${Ke}-buttonBar`,children:[(0,F.jsx)(Pe.Button,{onClick:o,children:"Cancel"}),(0,F.jsx)(Pe.Button,{onClick:a,children:"Apply"}),(0,F.jsx)(Pe.Button,{onClick:f,children:"Save"})]})]})};var Be=require("react"),xt=Y(require("classnames"),1);var ne=require("react/jsx-runtime"),je="vuuDatasourceStats",Sn=new Intl.NumberFormat,Qo=({className:e,dataSource:n})=>{let[t,o]=(0,Be.useState)(n.range),[i,r]=(0,Be.useState)(n.size);(0,Be.useEffect)(()=>{r(n.size),n.on("resize",r),n.on("range",o)},[n]);let s=(0,xt.default)(je,e),p=Sn.format(t.from),l=Sn.format(t.to-1),u=Sn.format(i);return(0,ne.jsxs)("div",{className:s,children:[(0,ne.jsx)("span",{children:"Showing rows"}),(0,ne.jsx)("span",{className:`${je}-range`,children:p}),(0,ne.jsx)("span",{className:`${je}-range`,children:l}),(0,ne.jsx)("span",{children:"of"}),(0,ne.jsx)("span",{className:`${je}-size`,children:u})]})};var Dt=require("@vuu-ui/vuu-layout"),wt=require("@salt-ds/lab"),h=require("@salt-ds/core"),Ft=Y(require("classnames"),1),K=require("react");var Et=require("@vuu-ui/vuu-utils"),vt=require("@salt-ds/lab"),Ot=require("@salt-ds/core"),Dn=Y(require("classnames"),1),Pt=require("react");var $e=require("@salt-ds/lab"),Se=require("@salt-ds/core"),Me=require("react");var A=require("react/jsx-runtime"),Io={alignOnDecimals:!1,decimals:4,zeroPad:!1},Bo=(e,n)=>{let t=typeof e=="object"&&e.formatting?e.formatting:{};return["alignOnDecimals","decimals","zeroPad"].reduce((i,r)=>t[r]!==void 0?{...i,[r]:t[r]}:(n==null?void 0:n[r])!==void 0?{...i,[r]:n[r]}:i,Io)},ht=({column:e,dispatchColumnAction:n})=>{let{decimals:t,alignOnDecimals:o,zeroPad:i}=Bo(e==null?void 0:e.type),r=(0,Me.useCallback)(u=>n({type:"updateColumnTypeFormatting",column:e,...u}),[e,n]),s=(0,Me.useCallback)(u=>r({decimals:parseInt(u.toString(),10)}),[r]),p=(0,Me.useCallback)((u,g)=>r({alignOnDecimals:g}),[r]),l=(0,Me.useCallback)((u,g)=>r({zeroPad:g}),[r]);switch(e.serverDataType){case"double":return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(Se.FormField,{labelPlacement:"top",children:[(0,A.jsx)(Se.FormFieldLabel,{children:"No of Decimals"}),(0,A.jsx)($e.StepperInput,{value:t,onChange:s})]}),(0,A.jsx)($e.Switch,{checked:o,label:"Align on decimals",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:p}),(0,A.jsx)($e.Switch,{checked:i,label:"Zero pad",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:l})]});case"long":case"int":return(0,A.jsx)(A.Fragment,{children:(0,A.jsx)(Se.Text,{children:"Work in progress"})});default:return null}};var en=require("react/jsx-runtime"),bt=({column:e,dispatchColumnAction:n})=>(console.log(e,n),(0,en.jsx)(en.Fragment,{children:"what"}));var _=require("react/jsx-runtime"),Tn="vuuColumnTypePanel",Mo=["Default Renderer (int, long)"],$o=["Default Renderer (double)"],yt=["Default Renderer (string)"],Uo=e=>{let t=(0,Et.getRegisteredCellRenderers)(e.serverDataType).map(o=>o.name);switch(console.log({customRendererNames:t}),e.serverDataType){case"char":case"string":return yt;case"int":case"long":return Mo;case"double":return $o.concat(t);default:return yt}},St=({className:e,column:n,dispatchColumnAction:t,...o})=>{let i=(0,Pt.useMemo)(()=>{switch(n.serverDataType){case"double":case"int":case"long":return(0,_.jsx)(ht,{column:n,dispatchColumnAction:t});default:return(0,_.jsx)(bt,{column:n,dispatchColumnAction:t})}},[n,t]),{serverDataType:r="string"}=n,s=Uo(n);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(vt.Dropdown,{className:(0,Dn.default)(`${Tn}-renderer`),fullWidth:!0,selected:s[0],source:s}),(0,_.jsx)(Ot.Panel,{...o,className:(0,Dn.default)(Tn,e,`${Tn}-${r}`),children:i})]})};var y=require("react/jsx-runtime"),Tt="vuuColumnSettingsPanel",Ho={className:"salt-density-high"},Go=({column:e,dispatchColumnAction:n,style:t,...o})=>{var v,a,d,f;let[i,r]=(0,K.useState)(0),s=(0,K.useCallback)(m=>n({type:"updateColumnProp",column:e,...m}),[e,n]),p=(0,K.useCallback)(m=>s({align:m.target.value}),[s]),l=(0,K.useCallback)(m=>s({pin:m.target.value}),[s]),u=(0,K.useCallback)(m=>s({hidden:m.target.checked}),[s]),g=(0,K.useCallback)(m=>s({label:m.target.value}),[s]),E=(0,K.useCallback)(m=>s({width:parseInt(m.toString(),10)}),[s]);return(0,y.jsxs)("div",{className:Tt,...o,style:{...t},children:[(0,y.jsx)(h.Text,{as:"h4",children:"Column Settings"}),(0,y.jsxs)(Dt.Stack,{active:i,className:(0,Ft.default)(`${Tt}-columnTabs`),onTabSelectionChanged:r,TabstripProps:Ho,children:[(0,y.jsxs)(h.Panel,{title:"Column",children:[(0,y.jsxs)(h.FormField,{labelPlacement:"left",children:[(0,y.jsx)(h.FormFieldLabel,{children:"Hidden"}),(0,y.jsx)(h.Checkbox,{checked:e.hidden===!0,onChange:u})]}),(0,y.jsxs)(h.FormField,{labelPlacement:"left",children:[(0,y.jsx)(h.FormFieldLabel,{children:"Label"}),(0,y.jsx)(h.Input,{value:(v=e.label)!=null?v:e.name,onChange:g})]}),(0,y.jsxs)(h.FormField,{labelPlacement:"left",children:[(0,y.jsx)(h.FormFieldLabel,{children:"Width"}),(0,y.jsx)(wt.StepperInput,{value:(a=e.width)!=null?a:100,onChange:E})]}),(0,y.jsxs)(h.FormField,{labelPlacement:"left",children:[(0,y.jsx)(h.FormFieldLabel,{children:"Align"}),(0,y.jsxs)(h.RadioButtonGroup,{"aria-label":"Column Align",value:(d=e.align)!=null?d:"left",onChange:p,children:[(0,y.jsx)(h.RadioButton,{label:"Left",value:"left"}),(0,y.jsx)(h.RadioButton,{label:"Right",value:"right"})]})]}),(0,y.jsxs)(h.FormField,{labelPlacement:"left",children:[(0,y.jsx)(h.FormFieldLabel,{children:"Pin Column"}),(0,y.jsxs)(h.RadioButtonGroup,{"aria-label":"Pin Column",value:(f=e.pin)!=null?f:"",onChange:l,children:[(0,y.jsx)(h.RadioButton,{label:"Do not pin",value:""}),(0,y.jsx)(h.RadioButton,{label:"Left",value:"left"}),(0,y.jsx)(h.RadioButton,{label:"Right",value:"right"})]})]})]}),(0,y.jsx)(St,{column:e,dispatchColumnAction:n,title:"Data Cell"}),(0,y.jsxs)(h.Panel,{title:"Vuu",variant:"secondary",children:[(0,y.jsxs)(h.FormField,{labelPlacement:"top",readOnly:!0,children:[(0,y.jsx)(h.FormFieldLabel,{children:"Name"}),(0,y.jsx)(h.Input,{value:e.name})]}),(0,y.jsxs)(h.FormField,{labelPlacement:"top",readOnly:!0,children:[(0,y.jsx)(h.FormFieldLabel,{children:"Vuu Type"}),(0,y.jsx)(h.Input,{value:e.serverDataType})]})]})]})]})};
|
|
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 name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], 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
|
+
ColumnExpressionInput: () => ColumnExpressionInput,
|
|
52
|
+
ColumnList: () => ColumnList,
|
|
53
|
+
ColumnNamedTerms: () => ColumnNamedTerms,
|
|
54
|
+
DataSourceStats: () => DataSourceStats,
|
|
55
|
+
DatagridSettingsPanel: () => DatagridSettingsPanel,
|
|
56
|
+
TableSettingsPanel: () => TableSettingsPanel,
|
|
57
|
+
columnExpressionLanguageSupport: () => columnExpressionLanguageSupport,
|
|
58
|
+
isCompleteExpression: () => isCompleteExpression,
|
|
59
|
+
isCompleteRelationalExpression: () => isCompleteRelationalExpression,
|
|
60
|
+
lastNamedChild: () => lastNamedChild,
|
|
61
|
+
useColumnExpressionEditor: () => useColumnExpressionEditor,
|
|
62
|
+
useColumnExpressionSuggestionProvider: () => useColumnExpressionSuggestionProvider,
|
|
63
|
+
useTableSettings: () => useTableSettings,
|
|
64
|
+
walkTree: () => walkTree
|
|
65
|
+
});
|
|
66
|
+
module.exports = __toCommonJS(src_exports);
|
|
67
|
+
|
|
68
|
+
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
69
|
+
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
70
|
+
var import_classnames = __toESM(require("classnames"), 1);
|
|
71
|
+
|
|
72
|
+
// src/cell-renderers/background-cell/useDirection.ts
|
|
73
|
+
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
74
|
+
var import_react = require("react");
|
|
75
|
+
var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
|
|
76
|
+
function useDirection(key, value, column) {
|
|
77
|
+
var _a;
|
|
78
|
+
const ref = (0, import_react.useRef)();
|
|
79
|
+
const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
|
|
80
|
+
const { type: dataType } = column;
|
|
81
|
+
const decimals = (0, import_vuu_utils.isTypeDescriptor)(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
|
|
82
|
+
const direction = key === prevKey && (0, import_vuu_utils.isValidNumber)(value) && (0, import_vuu_utils.isValidNumber)(prevValue) && column === prevColumn ? (0, import_vuu_utils.getMovingValueDirection)(value, prevDirection, prevValue, decimals) : "";
|
|
83
|
+
(0, import_react.useEffect)(() => {
|
|
84
|
+
ref.current = [key, value, column, direction];
|
|
85
|
+
});
|
|
86
|
+
return direction;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
90
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
91
|
+
var CHAR_ARROW_UP = String.fromCharCode(11014);
|
|
92
|
+
var CHAR_ARROW_DOWN = String.fromCharCode(11015);
|
|
93
|
+
var { KEY } = import_vuu_utils2.metadataKeys;
|
|
94
|
+
var classBase = "vuuBackgroundCell";
|
|
95
|
+
var FlashStyle = {
|
|
96
|
+
ArrowOnly: "arrow",
|
|
97
|
+
BackgroundOnly: "bg-only",
|
|
98
|
+
ArrowBackground: "arrow-bg"
|
|
99
|
+
};
|
|
100
|
+
var getFlashStyle = (colType) => {
|
|
101
|
+
if ((0, import_vuu_utils2.isTypeDescriptor)(colType) && colType.renderer) {
|
|
102
|
+
if ("flashStyle" in colType.renderer) {
|
|
103
|
+
return colType.renderer["flashStyle"];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return FlashStyle.BackgroundOnly;
|
|
107
|
+
};
|
|
108
|
+
var BackgroundCell = ({ column, row }) => {
|
|
109
|
+
const { key, type, valueFormatter } = column;
|
|
110
|
+
const value = row[key];
|
|
111
|
+
const flashStyle = getFlashStyle(type);
|
|
112
|
+
const direction = useDirection(row[KEY], value, column);
|
|
113
|
+
const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === import_vuu_utils2.UP1 || direction === import_vuu_utils2.UP2 ? CHAR_ARROW_UP : direction === import_vuu_utils2.DOWN1 || direction === import_vuu_utils2.DOWN2 ? CHAR_ARROW_DOWN : null : null;
|
|
114
|
+
const dirClass = direction ? ` ` + direction : "";
|
|
115
|
+
const className = (0, import_classnames.default)(classBase, dirClass, {
|
|
116
|
+
[`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
|
|
117
|
+
[`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
|
|
118
|
+
});
|
|
119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className, tabIndex: -1, children: [
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${classBase}-flasher`, children: arrow }),
|
|
121
|
+
valueFormatter(row[column.key])
|
|
122
|
+
] });
|
|
123
|
+
};
|
|
124
|
+
(0, import_vuu_utils2.registerComponent)("background", BackgroundCell, "cell-renderer", {
|
|
125
|
+
serverDataType: ["long", "int", "double"]
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// src/cell-renderers/progress-cell/ProgressCell.tsx
|
|
129
|
+
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
130
|
+
var import_classnames2 = __toESM(require("classnames"), 1);
|
|
131
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
132
|
+
var classBase2 = "vuuProgressCell";
|
|
133
|
+
var ProgressCell = ({ column, columnMap, row }) => {
|
|
134
|
+
const { type } = column;
|
|
135
|
+
const value = row[column.key];
|
|
136
|
+
let showProgress = false;
|
|
137
|
+
let percentage = 0;
|
|
138
|
+
if ((0, import_vuu_utils3.isTypeDescriptor)(type) && (0, import_vuu_utils3.isColumnTypeRenderer)(type.renderer)) {
|
|
139
|
+
const { associatedField } = type.renderer;
|
|
140
|
+
const associatedValue = row[columnMap[associatedField]];
|
|
141
|
+
if (typeof value === "number" && typeof associatedValue === "number") {
|
|
142
|
+
percentage = Math.min(Math.round(value / associatedValue * 100), 100);
|
|
143
|
+
showProgress = isFinite(percentage);
|
|
144
|
+
} else {
|
|
145
|
+
const floatValue = parseFloat(value);
|
|
146
|
+
if (Number.isFinite(floatValue)) {
|
|
147
|
+
const floatOtherValue = parseFloat(associatedValue);
|
|
148
|
+
if (Number.isFinite(floatOtherValue)) {
|
|
149
|
+
percentage = Math.min(
|
|
150
|
+
Math.round(floatValue / floatOtherValue * 100),
|
|
151
|
+
100
|
|
152
|
+
);
|
|
153
|
+
showProgress = isFinite(percentage);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const className = (0, import_classnames2.default)(classBase2, {});
|
|
159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className, tabIndex: -1, children: [
|
|
160
|
+
showProgress ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `${classBase2}-track`, children: [
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `${classBase2}-bg` }),
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
163
|
+
"span",
|
|
164
|
+
{
|
|
165
|
+
className: `${classBase2}-bar`,
|
|
166
|
+
style: { "--progress-bar-pct": `-${100 - percentage}%` }
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] }) : null,
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `${classBase2}-text`, children: `${percentage} %` })
|
|
171
|
+
] });
|
|
172
|
+
};
|
|
173
|
+
(0, import_vuu_utils3.registerComponent)("vuu.progress", ProgressCell, "cell-renderer", {
|
|
174
|
+
serverDataType: ["long", "int", "double"]
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// src/column-list/ColumnList.tsx
|
|
178
|
+
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
179
|
+
var import_core = require("@salt-ds/core");
|
|
180
|
+
var import_lab = require("@salt-ds/lab");
|
|
181
|
+
var import_classnames3 = __toESM(require("classnames"), 1);
|
|
182
|
+
var import_react2 = require("react");
|
|
183
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
184
|
+
var classBase3 = "vuuColumnList";
|
|
185
|
+
var classBaseListItem = "vuuColumnListItem";
|
|
186
|
+
var ColumnListItem = ({
|
|
187
|
+
className: classNameProp,
|
|
188
|
+
item,
|
|
189
|
+
...listItemProps
|
|
190
|
+
}) => {
|
|
191
|
+
var _a;
|
|
192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
193
|
+
import_vuu_ui_controls.ListItem,
|
|
194
|
+
{
|
|
195
|
+
...listItemProps,
|
|
196
|
+
className: (0, import_classnames3.default)(classNameProp, classBaseListItem),
|
|
197
|
+
"data-name": item == null ? void 0 : item.name,
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lab.Switch, { className: `${classBase3}-switch`, checked: item == null ? void 0 : item.subscribed }),
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `${classBase3}-text`, children: (_a = item == null ? void 0 : item.label) != null ? _a : item == null ? void 0 : item.name }),
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
202
|
+
import_core.Checkbox,
|
|
203
|
+
{
|
|
204
|
+
className: `${classBase3}-checkBox`,
|
|
205
|
+
checked: (item == null ? void 0 : item.hidden) !== true,
|
|
206
|
+
disabled: (item == null ? void 0 : item.subscribed) !== true
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
var ColumnList = ({
|
|
214
|
+
columnItems,
|
|
215
|
+
onChange,
|
|
216
|
+
onMoveListItem,
|
|
217
|
+
...htmlAttributes
|
|
218
|
+
}) => {
|
|
219
|
+
const handleChange = (0, import_react2.useCallback)(
|
|
220
|
+
(evt) => {
|
|
221
|
+
const input = evt.target;
|
|
222
|
+
const listItem = input.closest(`.${classBaseListItem}`);
|
|
223
|
+
const {
|
|
224
|
+
dataset: { name }
|
|
225
|
+
} = listItem;
|
|
226
|
+
if (name) {
|
|
227
|
+
const saltSwitch = input.closest(`.${classBase3}-switch`);
|
|
228
|
+
const saltCheckbox = input.closest(
|
|
229
|
+
`.${classBase3}-checkBox`
|
|
230
|
+
);
|
|
231
|
+
if (saltSwitch) {
|
|
232
|
+
onChange(name, "subscribed", input.checked);
|
|
233
|
+
} else if (saltCheckbox) {
|
|
234
|
+
onChange(name, "hidden", input.checked === false);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
[onChange]
|
|
239
|
+
);
|
|
240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ...htmlAttributes, className: classBase3, children: [
|
|
241
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${classBase3}-header`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Column Selection" }) }),
|
|
242
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `${classBase3}-colHeadings`, children: [
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Column subscription" }),
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Visibility" })
|
|
245
|
+
] }),
|
|
246
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
247
|
+
import_vuu_ui_controls.List,
|
|
248
|
+
{
|
|
249
|
+
ListItem: ColumnListItem,
|
|
250
|
+
allowDragDrop: true,
|
|
251
|
+
height: "100%",
|
|
252
|
+
onChange: handleChange,
|
|
253
|
+
onMoveListItem,
|
|
254
|
+
selectionStrategy: "none",
|
|
255
|
+
source: columnItems,
|
|
256
|
+
itemHeight: 33
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
] });
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
263
|
+
var import_vuu_codemirror5 = require("@vuu-ui/vuu-codemirror");
|
|
264
|
+
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
265
|
+
var import_react4 = require("react");
|
|
266
|
+
|
|
267
|
+
// src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
|
|
268
|
+
var import_vuu_codemirror = require("@vuu-ui/vuu-codemirror");
|
|
269
|
+
|
|
270
|
+
// src/column-expression-input/column-language-parser/generated/column-parser.js
|
|
271
|
+
var import_lr = require("@lezer/lr");
|
|
272
|
+
var parser = import_lr.LRParser.deserialize({
|
|
273
|
+
version: 14,
|
|
274
|
+
states: "&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",
|
|
275
|
+
stateData: ")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",
|
|
276
|
+
goto: "#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",
|
|
277
|
+
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",
|
|
278
|
+
maxTerm: 39,
|
|
279
|
+
skippedNodes: [0],
|
|
280
|
+
repeatNodeCount: 1,
|
|
281
|
+
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",
|
|
282
|
+
tokenizers: [0, 1],
|
|
283
|
+
topRules: { "ColumnDefinitionExpression": [0, 1] },
|
|
284
|
+
tokenPrec: 375
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
|
|
288
|
+
var columnExpressionLanguage = import_vuu_codemirror.LRLanguage.define({
|
|
289
|
+
name: "VuuColumnExpression",
|
|
290
|
+
parser: parser.configure({
|
|
291
|
+
props: [
|
|
292
|
+
(0, import_vuu_codemirror.styleTags)({
|
|
293
|
+
Function: import_vuu_codemirror.tags.variableName,
|
|
294
|
+
String: import_vuu_codemirror.tags.string,
|
|
295
|
+
Or: import_vuu_codemirror.tags.emphasis,
|
|
296
|
+
Operator: import_vuu_codemirror.tags.operator
|
|
297
|
+
})
|
|
298
|
+
]
|
|
299
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
|
+
})
|
|
301
|
+
});
|
|
302
|
+
var columnExpressionLanguageSupport = () => {
|
|
303
|
+
return new import_vuu_codemirror.LanguageSupport(
|
|
304
|
+
columnExpressionLanguage
|
|
305
|
+
/*, [exampleCompletion]*/
|
|
306
|
+
);
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.ts
|
|
310
|
+
var LiteralExpressionImpl = class {
|
|
311
|
+
constructor(value) {
|
|
312
|
+
this.value = value;
|
|
313
|
+
switch (typeof value) {
|
|
314
|
+
case "boolean":
|
|
315
|
+
this.type = "booleanLiteralExpression";
|
|
316
|
+
break;
|
|
317
|
+
case "number":
|
|
318
|
+
this.type = "numericLiteralExpression";
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
this.type = "stringLiteralExpression";
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
toJSON() {
|
|
325
|
+
return {
|
|
326
|
+
type: this.type,
|
|
327
|
+
value: this.value
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
var ColumnExpressionImpl = class {
|
|
332
|
+
constructor(columnName) {
|
|
333
|
+
this.type = "colExpression";
|
|
334
|
+
this.column = columnName;
|
|
335
|
+
}
|
|
336
|
+
toJSON() {
|
|
337
|
+
return {
|
|
338
|
+
type: this.type,
|
|
339
|
+
column: this.column
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
var _expressions, _op;
|
|
344
|
+
var ArithmeticExpressionImpl = class {
|
|
345
|
+
constructor(op = "unknown") {
|
|
346
|
+
__privateAdd(this, _expressions, [
|
|
347
|
+
{ type: "unknown" },
|
|
348
|
+
{ type: "unknown" }
|
|
349
|
+
]);
|
|
350
|
+
__privateAdd(this, _op, void 0);
|
|
351
|
+
this.type = "arithmeticExpression";
|
|
352
|
+
__privateSet(this, _op, op);
|
|
353
|
+
}
|
|
354
|
+
get op() {
|
|
355
|
+
return __privateGet(this, _op);
|
|
356
|
+
}
|
|
357
|
+
set op(op) {
|
|
358
|
+
__privateSet(this, _op, op);
|
|
359
|
+
}
|
|
360
|
+
get expressions() {
|
|
361
|
+
return __privateGet(this, _expressions);
|
|
362
|
+
}
|
|
363
|
+
toJSON() {
|
|
364
|
+
return {
|
|
365
|
+
type: this.type,
|
|
366
|
+
op: __privateGet(this, _op),
|
|
367
|
+
expressions: __privateGet(this, _expressions)
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
_expressions = new WeakMap();
|
|
372
|
+
_op = new WeakMap();
|
|
373
|
+
var _expressions2;
|
|
374
|
+
var CallExpressionImpl = class {
|
|
375
|
+
constructor(functionName) {
|
|
376
|
+
__privateAdd(this, _expressions2, []);
|
|
377
|
+
this.type = "callExpression";
|
|
378
|
+
this.functionName = functionName;
|
|
379
|
+
}
|
|
380
|
+
get expressions() {
|
|
381
|
+
return __privateGet(this, _expressions2);
|
|
382
|
+
}
|
|
383
|
+
get arguments() {
|
|
384
|
+
return __privateGet(this, _expressions2);
|
|
385
|
+
}
|
|
386
|
+
toJSON() {
|
|
387
|
+
return {
|
|
388
|
+
type: this.type,
|
|
389
|
+
functionName: this.functionName,
|
|
390
|
+
arguments: __privateGet(this, _expressions2).map((e) => {
|
|
391
|
+
var _a;
|
|
392
|
+
return (_a = e.toJSON) == null ? void 0 : _a.call(e);
|
|
393
|
+
})
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
_expressions2 = new WeakMap();
|
|
398
|
+
var _expressions3, _op2;
|
|
399
|
+
var RelationalExpressionImpl = class {
|
|
400
|
+
constructor() {
|
|
401
|
+
__privateAdd(this, _expressions3, [
|
|
402
|
+
{ type: "unknown" },
|
|
403
|
+
{ type: "unknown" }
|
|
404
|
+
]);
|
|
405
|
+
__privateAdd(this, _op2, "unknown");
|
|
406
|
+
this.type = "relationalExpression";
|
|
407
|
+
}
|
|
408
|
+
get op() {
|
|
409
|
+
return __privateGet(this, _op2);
|
|
410
|
+
}
|
|
411
|
+
set op(op) {
|
|
412
|
+
__privateSet(this, _op2, op);
|
|
413
|
+
}
|
|
414
|
+
get expressions() {
|
|
415
|
+
return __privateGet(this, _expressions3);
|
|
416
|
+
}
|
|
417
|
+
toJSON() {
|
|
418
|
+
return {
|
|
419
|
+
type: this.type,
|
|
420
|
+
op: __privateGet(this, _op2),
|
|
421
|
+
expressions: __privateGet(this, _expressions3)
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
_expressions3 = new WeakMap();
|
|
426
|
+
_op2 = new WeakMap();
|
|
427
|
+
var _expressions4, _op3;
|
|
428
|
+
var BooleanConditionImp = class {
|
|
429
|
+
constructor(booleanOperator) {
|
|
430
|
+
__privateAdd(this, _expressions4, [
|
|
431
|
+
{ type: "unknown" },
|
|
432
|
+
{ type: "unknown" }
|
|
433
|
+
]);
|
|
434
|
+
__privateAdd(this, _op3, void 0);
|
|
435
|
+
this.type = "booleanCondition";
|
|
436
|
+
__privateSet(this, _op3, booleanOperator);
|
|
437
|
+
}
|
|
438
|
+
get op() {
|
|
439
|
+
return __privateGet(this, _op3);
|
|
440
|
+
}
|
|
441
|
+
get expressions() {
|
|
442
|
+
return __privateGet(this, _expressions4);
|
|
443
|
+
}
|
|
444
|
+
toJSON() {
|
|
445
|
+
return {
|
|
446
|
+
type: this.type,
|
|
447
|
+
op: __privateGet(this, _op3),
|
|
448
|
+
expressions: __privateGet(this, _expressions4).map((e) => {
|
|
449
|
+
var _a;
|
|
450
|
+
return (_a = e.toJSON) == null ? void 0 : _a.call(e);
|
|
451
|
+
})
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
_expressions4 = new WeakMap();
|
|
456
|
+
_op3 = new WeakMap();
|
|
457
|
+
var _expressions5;
|
|
458
|
+
var ConditionalExpressionImpl = class {
|
|
459
|
+
constructor(booleanOperator) {
|
|
460
|
+
__privateAdd(this, _expressions5, void 0);
|
|
461
|
+
this.type = "conditionalExpression";
|
|
462
|
+
__privateSet(this, _expressions5, [
|
|
463
|
+
booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
|
|
464
|
+
{ type: "unknown" },
|
|
465
|
+
{ type: "unknown" }
|
|
466
|
+
]);
|
|
467
|
+
}
|
|
468
|
+
get expressions() {
|
|
469
|
+
return __privateGet(this, _expressions5);
|
|
470
|
+
}
|
|
471
|
+
get condition() {
|
|
472
|
+
return __privateGet(this, _expressions5)[0];
|
|
473
|
+
}
|
|
474
|
+
get truthyExpression() {
|
|
475
|
+
return __privateGet(this, _expressions5)[1];
|
|
476
|
+
}
|
|
477
|
+
set truthyExpression(expression) {
|
|
478
|
+
__privateGet(this, _expressions5)[1] = expression;
|
|
479
|
+
}
|
|
480
|
+
get falsyExpression() {
|
|
481
|
+
return __privateGet(this, _expressions5)[2];
|
|
482
|
+
}
|
|
483
|
+
set falsyExpression(expression) {
|
|
484
|
+
__privateGet(this, _expressions5)[2] = expression;
|
|
485
|
+
}
|
|
486
|
+
toJSON() {
|
|
487
|
+
var _a, _b, _c, _d, _e;
|
|
488
|
+
return {
|
|
489
|
+
type: this.type,
|
|
490
|
+
condition: (_b = (_a = this.condition).toJSON) == null ? void 0 : _b.call(_a),
|
|
491
|
+
truthyExpression: this.truthyExpression,
|
|
492
|
+
falsyExpression: (_e = (_d = (_c = this.falsyExpression) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c)) != null ? _e : this.falsyExpression
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
_expressions5 = new WeakMap();
|
|
497
|
+
var isUnknown = (e) => e.type === "unknown";
|
|
498
|
+
var isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
|
|
499
|
+
var isCallExpression = (expression) => expression.type === "callExpression";
|
|
500
|
+
var isConditionalExpression = (expression) => expression.type === "conditionalExpression";
|
|
501
|
+
var isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
|
|
502
|
+
var isBooleanCondition = (expression) => expression.type === "booleanCondition";
|
|
503
|
+
var isRelationalExpression = (expression) => (expression == null ? void 0 : expression.type) === "relationalExpression";
|
|
504
|
+
var firstIncompleteExpression = (expression) => {
|
|
505
|
+
if (isUnknown(expression)) {
|
|
506
|
+
return expression;
|
|
507
|
+
} else if (isRelationalExpression(expression)) {
|
|
508
|
+
const [operand1, operand2] = expression.expressions;
|
|
509
|
+
if (expressionIsIncomplete(operand1)) {
|
|
510
|
+
return firstIncompleteExpression(operand1);
|
|
511
|
+
} else if (expression.op === "unknown") {
|
|
512
|
+
return expression;
|
|
513
|
+
} else if (expressionIsIncomplete(operand2)) {
|
|
514
|
+
return firstIncompleteExpression(operand2);
|
|
515
|
+
}
|
|
516
|
+
} else if (isCondition(expression)) {
|
|
517
|
+
const { expressions = [] } = expression;
|
|
518
|
+
for (const e of expressions) {
|
|
519
|
+
if (expressionIsIncomplete(e)) {
|
|
520
|
+
return firstIncompleteExpression(e);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
} else if (isConditionalExpression(expression)) {
|
|
524
|
+
const { condition, truthyExpression, falsyExpression } = expression;
|
|
525
|
+
if (expressionIsIncomplete(condition)) {
|
|
526
|
+
return firstIncompleteExpression(condition);
|
|
527
|
+
} else if (expressionIsIncomplete(truthyExpression)) {
|
|
528
|
+
return firstIncompleteExpression(truthyExpression);
|
|
529
|
+
} else if (expressionIsIncomplete(falsyExpression)) {
|
|
530
|
+
return firstIncompleteExpression(falsyExpression);
|
|
531
|
+
}
|
|
532
|
+
} else if (isArithmeticExpression(expression)) {
|
|
533
|
+
const { expressions = [] } = expression;
|
|
534
|
+
for (const e of expressions) {
|
|
535
|
+
if (expressionIsIncomplete(e)) {
|
|
536
|
+
return firstIncompleteExpression(e);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
var replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
|
|
542
|
+
const { expressions = [] } = incompleteExpression;
|
|
543
|
+
if (expressions.includes(unknownExpression)) {
|
|
544
|
+
const pos = expressions.indexOf(unknownExpression);
|
|
545
|
+
expressions.splice(pos, 1, expression);
|
|
546
|
+
return true;
|
|
547
|
+
} else {
|
|
548
|
+
for (const e of expressions) {
|
|
549
|
+
if (replaceUnknownExpression(e, unknownExpression, expression)) {
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return false;
|
|
555
|
+
};
|
|
556
|
+
var expressionIsIncomplete = (expression) => {
|
|
557
|
+
if (isUnknown(expression)) {
|
|
558
|
+
return true;
|
|
559
|
+
} else if (isConditionalExpression(expression)) {
|
|
560
|
+
return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
|
|
561
|
+
} else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
|
|
562
|
+
return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
|
|
563
|
+
}
|
|
564
|
+
return false;
|
|
565
|
+
};
|
|
566
|
+
var addExpression = (expression, subExpression) => {
|
|
567
|
+
const targetExpression = firstIncompleteExpression(expression);
|
|
568
|
+
if (targetExpression) {
|
|
569
|
+
if (targetExpression.expressions) {
|
|
570
|
+
targetExpression.expressions.push(subExpression);
|
|
571
|
+
} else {
|
|
572
|
+
console.warn("don't know how to treat targetExpression");
|
|
573
|
+
}
|
|
574
|
+
} else {
|
|
575
|
+
console.error("no target expression found");
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
var _expression, _callStack;
|
|
579
|
+
var ColumnExpression = class {
|
|
580
|
+
constructor() {
|
|
581
|
+
__privateAdd(this, _expression, void 0);
|
|
582
|
+
__privateAdd(this, _callStack, []);
|
|
583
|
+
}
|
|
584
|
+
setCondition(booleanOperator) {
|
|
585
|
+
if (__privateGet(this, _expression) === void 0) {
|
|
586
|
+
this.addExpression(new ConditionalExpressionImpl(booleanOperator));
|
|
587
|
+
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
588
|
+
if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
|
|
589
|
+
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
590
|
+
this.addExpression(condition);
|
|
591
|
+
} else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
|
|
592
|
+
__privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
|
|
593
|
+
booleanOperator
|
|
594
|
+
);
|
|
595
|
+
} else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
|
|
596
|
+
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
597
|
+
this.addExpression(condition);
|
|
598
|
+
} else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
|
|
599
|
+
__privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
|
|
600
|
+
booleanOperator
|
|
601
|
+
);
|
|
602
|
+
} else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
|
|
603
|
+
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
604
|
+
this.addExpression(condition);
|
|
605
|
+
}
|
|
606
|
+
} else {
|
|
607
|
+
console.error("setCondition called unexpectedly");
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
addExpression(expression) {
|
|
611
|
+
if (__privateGet(this, _callStack).length > 0) {
|
|
612
|
+
const currentCallExpression = __privateGet(this, _callStack).at(-1);
|
|
613
|
+
currentCallExpression == null ? void 0 : currentCallExpression.arguments.push(expression);
|
|
614
|
+
} else if (__privateGet(this, _expression) === void 0) {
|
|
615
|
+
__privateSet(this, _expression, expression);
|
|
616
|
+
} else if (isArithmeticExpression(__privateGet(this, _expression))) {
|
|
617
|
+
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
618
|
+
if (targetExpression && isUnknown(targetExpression)) {
|
|
619
|
+
replaceUnknownExpression(
|
|
620
|
+
__privateGet(this, _expression),
|
|
621
|
+
targetExpression,
|
|
622
|
+
expression
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
626
|
+
if (expressionIsIncomplete(__privateGet(this, _expression))) {
|
|
627
|
+
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
628
|
+
if (targetExpression && isUnknown(targetExpression)) {
|
|
629
|
+
replaceUnknownExpression(
|
|
630
|
+
__privateGet(this, _expression),
|
|
631
|
+
targetExpression,
|
|
632
|
+
expression
|
|
633
|
+
);
|
|
634
|
+
} else if (targetExpression) {
|
|
635
|
+
addExpression(targetExpression, expression);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
setFunction(functionName) {
|
|
641
|
+
const callExpression = new CallExpressionImpl(functionName);
|
|
642
|
+
this.addExpression(callExpression);
|
|
643
|
+
__privateGet(this, _callStack).push(callExpression);
|
|
644
|
+
}
|
|
645
|
+
setColumn(columnName) {
|
|
646
|
+
this.addExpression(new ColumnExpressionImpl(columnName));
|
|
647
|
+
}
|
|
648
|
+
setArithmeticOp(value) {
|
|
649
|
+
const op = value;
|
|
650
|
+
const expression = __privateGet(this, _expression);
|
|
651
|
+
if (isArithmeticExpression(expression)) {
|
|
652
|
+
expression.op = op;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
setRelationalOperator(value) {
|
|
656
|
+
const op = value;
|
|
657
|
+
if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
|
|
658
|
+
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
659
|
+
if (isRelationalExpression(targetExpression)) {
|
|
660
|
+
targetExpression.op = op;
|
|
661
|
+
} else {
|
|
662
|
+
console.error(`no target expression found (op = ${value})`);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
setValue(value) {
|
|
667
|
+
const literalExpression = new LiteralExpressionImpl(value);
|
|
668
|
+
if (__privateGet(this, _expression) === void 0) {
|
|
669
|
+
__privateSet(this, _expression, literalExpression);
|
|
670
|
+
} else if (isArithmeticExpression(__privateGet(this, _expression))) {
|
|
671
|
+
this.addExpression(literalExpression);
|
|
672
|
+
} else if (isCallExpression(__privateGet(this, _expression))) {
|
|
673
|
+
__privateGet(this, _expression).arguments.push(literalExpression);
|
|
674
|
+
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
675
|
+
if (expressionIsIncomplete(__privateGet(this, _expression))) {
|
|
676
|
+
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
677
|
+
if (targetExpression && isUnknown(targetExpression)) {
|
|
678
|
+
replaceUnknownExpression(
|
|
679
|
+
__privateGet(this, _expression),
|
|
680
|
+
targetExpression,
|
|
681
|
+
literalExpression
|
|
682
|
+
);
|
|
683
|
+
} else if (targetExpression) {
|
|
684
|
+
addExpression(targetExpression, literalExpression);
|
|
685
|
+
}
|
|
686
|
+
} else {
|
|
687
|
+
console.log("what do we do with value, in a complete expression");
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
closeBrace() {
|
|
692
|
+
__privateGet(this, _callStack).pop();
|
|
693
|
+
}
|
|
694
|
+
get expression() {
|
|
695
|
+
return __privateGet(this, _expression);
|
|
696
|
+
}
|
|
697
|
+
toJSON() {
|
|
698
|
+
var _a;
|
|
699
|
+
return (_a = __privateGet(this, _expression)) == null ? void 0 : _a.toJSON();
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
_expression = new WeakMap();
|
|
703
|
+
_callStack = new WeakMap();
|
|
704
|
+
var walkTree = (tree, source) => {
|
|
705
|
+
const columnExpression = new ColumnExpression();
|
|
706
|
+
const cursor = tree.cursor();
|
|
707
|
+
do {
|
|
708
|
+
const { name, from, to } = cursor;
|
|
709
|
+
switch (name) {
|
|
710
|
+
case "AndCondition":
|
|
711
|
+
columnExpression.setCondition("and");
|
|
712
|
+
break;
|
|
713
|
+
case "OrCondition":
|
|
714
|
+
columnExpression.setCondition("or");
|
|
715
|
+
break;
|
|
716
|
+
case "RelationalExpression":
|
|
717
|
+
columnExpression.setCondition();
|
|
718
|
+
break;
|
|
719
|
+
case "ArithmeticExpression":
|
|
720
|
+
columnExpression.addExpression(new ArithmeticExpressionImpl());
|
|
721
|
+
break;
|
|
722
|
+
case "Column":
|
|
723
|
+
{
|
|
724
|
+
const columnName = source.substring(from, to);
|
|
725
|
+
columnExpression.setColumn(columnName);
|
|
726
|
+
}
|
|
727
|
+
break;
|
|
728
|
+
case "Function":
|
|
729
|
+
{
|
|
730
|
+
const functionName = source.substring(from, to);
|
|
731
|
+
columnExpression.setFunction(functionName);
|
|
732
|
+
}
|
|
733
|
+
break;
|
|
734
|
+
case "Times":
|
|
735
|
+
case "Divide":
|
|
736
|
+
case "Plus":
|
|
737
|
+
case "Minus":
|
|
738
|
+
{
|
|
739
|
+
const op = source.substring(from, to);
|
|
740
|
+
columnExpression.setArithmeticOp(op);
|
|
741
|
+
}
|
|
742
|
+
break;
|
|
743
|
+
case "RelationalOperator":
|
|
744
|
+
{
|
|
745
|
+
const op = source.substring(from, to);
|
|
746
|
+
columnExpression.setRelationalOperator(op);
|
|
747
|
+
}
|
|
748
|
+
break;
|
|
749
|
+
case "False":
|
|
750
|
+
case "True":
|
|
751
|
+
{
|
|
752
|
+
const value = source.substring(from, to);
|
|
753
|
+
columnExpression.setValue(value === "true" ? true : false);
|
|
754
|
+
}
|
|
755
|
+
break;
|
|
756
|
+
case "String":
|
|
757
|
+
columnExpression.setValue(source.substring(from + 1, to - 1));
|
|
758
|
+
break;
|
|
759
|
+
case "Number":
|
|
760
|
+
columnExpression.setValue(parseFloat(source.substring(from, to)));
|
|
761
|
+
break;
|
|
762
|
+
case "CloseBrace":
|
|
763
|
+
columnExpression.closeBrace();
|
|
764
|
+
break;
|
|
765
|
+
default:
|
|
766
|
+
}
|
|
767
|
+
} while (cursor.next());
|
|
768
|
+
return columnExpression.toJSON();
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// src/column-expression-input/column-language-parser/column-expression-parse-utils.ts
|
|
772
|
+
var strictParser = parser.configure({ strict: true });
|
|
773
|
+
var RelationalOperands = ["Number", "String"];
|
|
774
|
+
var ColumnNamedTerms = [
|
|
775
|
+
...RelationalOperands,
|
|
776
|
+
"AndCondition",
|
|
777
|
+
"ArithmeticExpression",
|
|
778
|
+
"BooleanOperator",
|
|
779
|
+
"RelationalOperatorOperator",
|
|
780
|
+
"CallExpression",
|
|
781
|
+
"CloseBrace",
|
|
782
|
+
"Column",
|
|
783
|
+
"Comma",
|
|
784
|
+
"ConditionalExpression",
|
|
785
|
+
"Divide",
|
|
786
|
+
"Equal",
|
|
787
|
+
"If",
|
|
788
|
+
"Minus",
|
|
789
|
+
"OpenBrace",
|
|
790
|
+
"OrCondition",
|
|
791
|
+
"ParenthesizedExpression",
|
|
792
|
+
"Plus",
|
|
793
|
+
"RelationalExpression",
|
|
794
|
+
"RelationalOperator",
|
|
795
|
+
"Times"
|
|
796
|
+
];
|
|
797
|
+
var isCompleteExpression = (src) => {
|
|
798
|
+
try {
|
|
799
|
+
strictParser.parse(src);
|
|
800
|
+
return true;
|
|
801
|
+
} catch (err) {
|
|
802
|
+
return false;
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
var lastNamedChild = (node) => {
|
|
806
|
+
let { lastChild } = node;
|
|
807
|
+
while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
|
|
808
|
+
lastChild = lastChild.prevSibling;
|
|
809
|
+
console.log(lastChild == null ? void 0 : lastChild.name);
|
|
810
|
+
}
|
|
811
|
+
return lastChild;
|
|
812
|
+
};
|
|
813
|
+
var isCompleteRelationalExpression = (node) => {
|
|
814
|
+
if ((node == null ? void 0 : node.name) === "RelationalExpression") {
|
|
815
|
+
const { firstChild } = node;
|
|
816
|
+
const lastChild = lastNamedChild(node);
|
|
817
|
+
if ((firstChild == null ? void 0 : firstChild.name) === "Column" && typeof (lastChild == null ? void 0 : lastChild.name) === "string" && RelationalOperands.includes(lastChild.name)) {
|
|
818
|
+
return true;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return false;
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
// src/column-expression-input/highlighting.ts
|
|
825
|
+
var import_vuu_codemirror2 = require("@vuu-ui/vuu-codemirror");
|
|
826
|
+
var myHighlightStyle = import_vuu_codemirror2.HighlightStyle.define([
|
|
827
|
+
{ tag: import_vuu_codemirror2.tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
|
|
828
|
+
{ tag: import_vuu_codemirror2.tags.comment, color: "green", fontStyle: "italic" }
|
|
829
|
+
]);
|
|
830
|
+
var vuuHighlighting = (0, import_vuu_codemirror2.syntaxHighlighting)(myHighlightStyle);
|
|
831
|
+
|
|
832
|
+
// src/column-expression-input/theme.ts
|
|
833
|
+
var import_vuu_codemirror3 = require("@vuu-ui/vuu-codemirror");
|
|
834
|
+
var vuuTheme = import_vuu_codemirror3.EditorView.theme(
|
|
835
|
+
{
|
|
836
|
+
"&": {
|
|
837
|
+
border: "solid 1px var(--salt-container-primary-borderColor)",
|
|
838
|
+
color: "var(--vuuFilterEditor-color)",
|
|
839
|
+
backgroundColor: "var(--vuuFilterEditor-background)"
|
|
840
|
+
},
|
|
841
|
+
".cm-content": {
|
|
842
|
+
caretColor: "var(--vuuFilterEditor-cursorColor)"
|
|
843
|
+
},
|
|
844
|
+
"&.cm-focused .cm-cursor": {
|
|
845
|
+
borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
|
|
846
|
+
},
|
|
847
|
+
"&.cm-focused .cm-selectionBackground, ::selection": {
|
|
848
|
+
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
849
|
+
},
|
|
850
|
+
".cm-selectionBackground, ::selection": {
|
|
851
|
+
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
852
|
+
},
|
|
853
|
+
".cm-scroller": {
|
|
854
|
+
fontFamily: "var(--vuuFilterEditor-fontFamily)"
|
|
855
|
+
},
|
|
856
|
+
".cm-tooltip": {
|
|
857
|
+
background: "var(--vuuFilterEditor-tooltipBackground)",
|
|
858
|
+
border: "var(--vuuFilterEditor-tooltipBorder)",
|
|
859
|
+
boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
|
|
860
|
+
"&.cm-tooltip-autocomplete > ul": {
|
|
861
|
+
fontFamily: "var(--vuuFilterEditor-fontFamily)",
|
|
862
|
+
fontSize: "var(--vuuFilterEditor-fontSize)",
|
|
863
|
+
maxHeight: "240px"
|
|
864
|
+
},
|
|
865
|
+
"&.cm-tooltip-autocomplete > ul > li": {
|
|
866
|
+
height: "var(--vuuFilterEditor-suggestion-height)",
|
|
867
|
+
padding: "0 3px",
|
|
868
|
+
lineHeight: "var(--vuuFilterEditor-suggestion-height)"
|
|
869
|
+
},
|
|
870
|
+
"&.cm-tooltip-autocomplete li[aria-selected]": {
|
|
871
|
+
background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
|
|
872
|
+
color: "var(--vuuFilterEditor-suggestion-selectedColor)"
|
|
873
|
+
},
|
|
874
|
+
"&.cm-tooltip-autocomplete li .cm-completionDetail": {
|
|
875
|
+
color: "var(--vuuFilterEditor-suggestion-detailColor)"
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
},
|
|
879
|
+
{ dark: false }
|
|
880
|
+
);
|
|
881
|
+
|
|
882
|
+
// src/column-expression-input/useColumnAutoComplete.ts
|
|
883
|
+
var import_vuu_codemirror4 = require("@vuu-ui/vuu-codemirror");
|
|
884
|
+
var import_react3 = require("react");
|
|
885
|
+
var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
|
|
886
|
+
var _a;
|
|
887
|
+
return {
|
|
888
|
+
...completion,
|
|
889
|
+
apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
|
|
890
|
+
};
|
|
891
|
+
}) : completions;
|
|
892
|
+
var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
|
|
893
|
+
var getLastChild = (node, context) => {
|
|
894
|
+
var _a;
|
|
895
|
+
let { lastChild: childNode } = node;
|
|
896
|
+
const { pos } = context;
|
|
897
|
+
while (childNode) {
|
|
898
|
+
const isBeforeCursor = childNode.from < pos;
|
|
899
|
+
if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
|
|
900
|
+
if (childNode.name === "ParenthesizedExpression") {
|
|
901
|
+
const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
|
|
902
|
+
if (expression) {
|
|
903
|
+
childNode = expression;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return childNode;
|
|
907
|
+
} else {
|
|
908
|
+
childNode = childNode.prevSibling;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
var getFunctionName = (node, state) => {
|
|
913
|
+
var _a;
|
|
914
|
+
if (node.name === "ArgList") {
|
|
915
|
+
const functionNode = node.prevSibling;
|
|
916
|
+
if (functionNode) {
|
|
917
|
+
return (0, import_vuu_codemirror4.getValue)(functionNode, state);
|
|
918
|
+
}
|
|
919
|
+
} else if (node.name === "OpenBrace") {
|
|
920
|
+
const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
|
|
921
|
+
if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
|
|
922
|
+
return (0, import_vuu_codemirror4.getValue)(maybeFunction, state);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
var getRelationalOperator = (node, state) => {
|
|
927
|
+
if (node.name === "RelationalExpression") {
|
|
928
|
+
const lastNode = lastNamedChild(node);
|
|
929
|
+
if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
|
|
930
|
+
return (0, import_vuu_codemirror4.getValue)(lastNode, state);
|
|
931
|
+
}
|
|
932
|
+
} else {
|
|
933
|
+
const prevNode = node.prevSibling;
|
|
934
|
+
if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
935
|
+
return (0, import_vuu_codemirror4.getValue)(prevNode, state);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
var getColumnName = (node, state) => {
|
|
940
|
+
var _a;
|
|
941
|
+
if (node.name === "RelationalExpression") {
|
|
942
|
+
if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
|
|
943
|
+
return (0, import_vuu_codemirror4.getValue)(node.firstChild, state);
|
|
944
|
+
}
|
|
945
|
+
} else {
|
|
946
|
+
const prevNode = node.prevSibling;
|
|
947
|
+
if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
|
|
948
|
+
return (0, import_vuu_codemirror4.getValue)(prevNode, state);
|
|
949
|
+
} else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
950
|
+
return getColumnName(prevNode, state);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
|
|
955
|
+
const options = await suggestionProvider.getSuggestions(
|
|
956
|
+
suggestionType,
|
|
957
|
+
optionalArgs
|
|
958
|
+
);
|
|
959
|
+
const { startsWith = "" } = optionalArgs;
|
|
960
|
+
return { from: context.pos - startsWith.length, options };
|
|
961
|
+
};
|
|
962
|
+
var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
|
|
963
|
+
const lastChild = getLastChild(node, context);
|
|
964
|
+
console.log(`conditional expression last child ${lastChild == null ? void 0 : lastChild.name}`);
|
|
965
|
+
switch (lastChild == null ? void 0 : lastChild.name) {
|
|
966
|
+
case "If":
|
|
967
|
+
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
968
|
+
prefix: "( "
|
|
969
|
+
});
|
|
970
|
+
case "OpenBrace":
|
|
971
|
+
return makeSuggestions(context, suggestionProvider, "expression");
|
|
972
|
+
case "Condition":
|
|
973
|
+
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
974
|
+
prefix: ", "
|
|
975
|
+
});
|
|
976
|
+
case "CloseBrace":
|
|
977
|
+
if (maybeComplete) {
|
|
978
|
+
const options = [
|
|
979
|
+
{
|
|
980
|
+
apply: () => {
|
|
981
|
+
onSubmit == null ? void 0 : onSubmit();
|
|
982
|
+
},
|
|
983
|
+
label: "Save Expression",
|
|
984
|
+
boost: 10
|
|
985
|
+
}
|
|
986
|
+
];
|
|
987
|
+
return { from: context.pos, options };
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
var promptToSave = (context, onSubmit) => {
|
|
992
|
+
const options = [
|
|
993
|
+
{
|
|
994
|
+
apply: () => {
|
|
995
|
+
onSubmit == null ? void 0 : onSubmit();
|
|
996
|
+
},
|
|
997
|
+
label: "Save Expression",
|
|
998
|
+
boost: 10
|
|
999
|
+
}
|
|
1000
|
+
];
|
|
1001
|
+
return { from: context.pos, options };
|
|
1002
|
+
};
|
|
1003
|
+
var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
|
|
1004
|
+
const makeSuggestions2 = (0, import_react3.useCallback)(
|
|
1005
|
+
async (context, suggestionType, optionalArgs = {}) => {
|
|
1006
|
+
const options = await suggestionProvider.getSuggestions(
|
|
1007
|
+
suggestionType,
|
|
1008
|
+
optionalArgs
|
|
1009
|
+
);
|
|
1010
|
+
const { startsWith = "" } = optionalArgs;
|
|
1011
|
+
return { from: context.pos - startsWith.length, options };
|
|
1012
|
+
},
|
|
1013
|
+
[suggestionProvider]
|
|
1014
|
+
);
|
|
1015
|
+
return (0, import_react3.useCallback)(
|
|
1016
|
+
async (context) => {
|
|
1017
|
+
var _a, _b;
|
|
1018
|
+
const { state, pos } = context;
|
|
1019
|
+
const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
|
|
1020
|
+
from: 0,
|
|
1021
|
+
to: 0,
|
|
1022
|
+
text: void 0
|
|
1023
|
+
};
|
|
1024
|
+
const tree = (0, import_vuu_codemirror4.syntaxTree)(state);
|
|
1025
|
+
const nodeBefore = tree.resolveInner(pos, -1);
|
|
1026
|
+
const text = state.doc.toString();
|
|
1027
|
+
const maybeComplete = isCompleteExpression(text);
|
|
1028
|
+
console.log({ nodeBeforeName: nodeBefore.name });
|
|
1029
|
+
switch (nodeBefore.name) {
|
|
1030
|
+
case "If": {
|
|
1031
|
+
console.log(`conditional expression If`);
|
|
1032
|
+
return makeSuggestions2(context, "expression", { prefix: "( " });
|
|
1033
|
+
}
|
|
1034
|
+
case "Condition":
|
|
1035
|
+
{
|
|
1036
|
+
const lastChild = getLastChild(nodeBefore, context);
|
|
1037
|
+
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1038
|
+
const prevChild = (0, import_vuu_codemirror4.getPreviousNode)(lastChild);
|
|
1039
|
+
if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
|
|
1040
|
+
return makeSuggestions2(context, "condition-operator", {
|
|
1041
|
+
columnName: (0, import_vuu_codemirror4.getValue)(lastChild, state)
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
console.log(
|
|
1045
|
+
`Condition last child Column, prev child ${prevChild == null ? void 0 : prevChild.name}`
|
|
1046
|
+
);
|
|
1047
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
|
|
1048
|
+
return makeSuggestions2(context, "expression");
|
|
1049
|
+
}
|
|
1050
|
+
console.log(`condition last child ${lastChild == null ? void 0 : lastChild.name}`);
|
|
1051
|
+
}
|
|
1052
|
+
break;
|
|
1053
|
+
case "ConditionalExpression":
|
|
1054
|
+
return handleConditionalExpression(
|
|
1055
|
+
nodeBefore,
|
|
1056
|
+
context,
|
|
1057
|
+
suggestionProvider
|
|
1058
|
+
);
|
|
1059
|
+
case "RelationalExpression":
|
|
1060
|
+
{
|
|
1061
|
+
if (isCompleteRelationalExpression(nodeBefore)) {
|
|
1062
|
+
return {
|
|
1063
|
+
from: context.pos,
|
|
1064
|
+
options: import_vuu_codemirror4.booleanJoinSuggestions.concat({
|
|
1065
|
+
label: ", <truthy expression>, <falsy expression>",
|
|
1066
|
+
apply: ", "
|
|
1067
|
+
})
|
|
1068
|
+
};
|
|
1069
|
+
} else {
|
|
1070
|
+
const operator = getRelationalOperator(nodeBefore, state);
|
|
1071
|
+
const columnName = getColumnName(nodeBefore, state);
|
|
1072
|
+
if (!operator) {
|
|
1073
|
+
const options = await suggestionProvider.getSuggestions(
|
|
1074
|
+
"condition-operator",
|
|
1075
|
+
{
|
|
1076
|
+
columnName
|
|
1077
|
+
}
|
|
1078
|
+
);
|
|
1079
|
+
return { from: context.pos, options };
|
|
1080
|
+
} else {
|
|
1081
|
+
return makeSuggestions2(context, "expression");
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
break;
|
|
1086
|
+
case "RelationalOperator":
|
|
1087
|
+
return makeSuggestions2(context, "expression");
|
|
1088
|
+
case "String":
|
|
1089
|
+
{
|
|
1090
|
+
const operator = getRelationalOperator(
|
|
1091
|
+
nodeBefore,
|
|
1092
|
+
state
|
|
1093
|
+
);
|
|
1094
|
+
const columnName = getColumnName(nodeBefore, state);
|
|
1095
|
+
const { from, to } = nodeBefore;
|
|
1096
|
+
if (to - from === 2 && context.pos === from + 1) {
|
|
1097
|
+
if (columnName && operator) {
|
|
1098
|
+
return makeSuggestions2(context, "columnValue", {
|
|
1099
|
+
columnName,
|
|
1100
|
+
operator,
|
|
1101
|
+
startsWith: word.text
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
} else if (to - from > 2 && context.pos === to) {
|
|
1105
|
+
return makeSuggestions2(context, "expression", {
|
|
1106
|
+
prefix: ", "
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
console.log(
|
|
1110
|
+
`we have a string, column is ${columnName} ${from} ${to}`
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
break;
|
|
1114
|
+
case "ArithmeticExpression":
|
|
1115
|
+
{
|
|
1116
|
+
const lastChild = getLastChild(nodeBefore, context);
|
|
1117
|
+
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1118
|
+
return makeSuggestions2(context, "expression");
|
|
1119
|
+
} else if (isOperator(lastChild)) {
|
|
1120
|
+
const operator = lastChild.name;
|
|
1121
|
+
return makeSuggestions2(context, "column", { operator });
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
break;
|
|
1125
|
+
case "OpenBrace":
|
|
1126
|
+
{
|
|
1127
|
+
const functionName = getFunctionName(nodeBefore, state);
|
|
1128
|
+
return makeSuggestions2(context, "expression", { functionName });
|
|
1129
|
+
}
|
|
1130
|
+
break;
|
|
1131
|
+
case "ArgList": {
|
|
1132
|
+
const functionName = getFunctionName(nodeBefore, state);
|
|
1133
|
+
const lastArgument = getLastChild(nodeBefore, context);
|
|
1134
|
+
const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" ? void 0 : ",";
|
|
1135
|
+
let options = await suggestionProvider.getSuggestions("expression", {
|
|
1136
|
+
functionName
|
|
1137
|
+
});
|
|
1138
|
+
options = prefix ? applyPrefix(options, ", ") : options;
|
|
1139
|
+
if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
|
|
1140
|
+
options = [
|
|
1141
|
+
{
|
|
1142
|
+
apply: ") ",
|
|
1143
|
+
boost: 10,
|
|
1144
|
+
label: "Done - no more arguments"
|
|
1145
|
+
}
|
|
1146
|
+
].concat(options);
|
|
1147
|
+
}
|
|
1148
|
+
return { from: context.pos, options };
|
|
1149
|
+
}
|
|
1150
|
+
case "Equal":
|
|
1151
|
+
if (text.trim() === "=") {
|
|
1152
|
+
return makeSuggestions2(context, "expression");
|
|
1153
|
+
}
|
|
1154
|
+
break;
|
|
1155
|
+
case "ParenthesizedExpression":
|
|
1156
|
+
case "ColumnDefinitionExpression":
|
|
1157
|
+
if (context.pos === 0) {
|
|
1158
|
+
return makeSuggestions2(context, "expression");
|
|
1159
|
+
} else {
|
|
1160
|
+
const lastChild = getLastChild(nodeBefore, context);
|
|
1161
|
+
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1162
|
+
if (maybeComplete) {
|
|
1163
|
+
const options = [
|
|
1164
|
+
{
|
|
1165
|
+
apply: () => {
|
|
1166
|
+
onSubmit.current();
|
|
1167
|
+
},
|
|
1168
|
+
label: "Save Expression",
|
|
1169
|
+
boost: 10
|
|
1170
|
+
}
|
|
1171
|
+
];
|
|
1172
|
+
const columnName = (0, import_vuu_codemirror4.getValue)(lastChild, state);
|
|
1173
|
+
const columnOptions = await suggestionProvider.getSuggestions("operator", {
|
|
1174
|
+
columnName
|
|
1175
|
+
});
|
|
1176
|
+
return {
|
|
1177
|
+
from: context.pos,
|
|
1178
|
+
options: options.concat(columnOptions)
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
|
|
1182
|
+
if (maybeComplete) {
|
|
1183
|
+
const options = [
|
|
1184
|
+
{
|
|
1185
|
+
apply: () => {
|
|
1186
|
+
onSubmit.current();
|
|
1187
|
+
},
|
|
1188
|
+
label: "Save Expression",
|
|
1189
|
+
boost: 10
|
|
1190
|
+
}
|
|
1191
|
+
];
|
|
1192
|
+
return {
|
|
1193
|
+
from: context.pos,
|
|
1194
|
+
options
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
|
|
1198
|
+
if (maybeComplete) {
|
|
1199
|
+
let options = [
|
|
1200
|
+
{
|
|
1201
|
+
apply: () => {
|
|
1202
|
+
onSubmit.current();
|
|
1203
|
+
},
|
|
1204
|
+
label: "Save Expression",
|
|
1205
|
+
boost: 10
|
|
1206
|
+
}
|
|
1207
|
+
];
|
|
1208
|
+
const lastExpressionChild = getLastChild(lastChild, context);
|
|
1209
|
+
if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
|
|
1210
|
+
const columnName = (0, import_vuu_codemirror4.getValue)(lastExpressionChild, state);
|
|
1211
|
+
const suggestions = await suggestionProvider.getSuggestions(
|
|
1212
|
+
"operator",
|
|
1213
|
+
{ columnName }
|
|
1214
|
+
);
|
|
1215
|
+
options = options.concat(suggestions);
|
|
1216
|
+
}
|
|
1217
|
+
return {
|
|
1218
|
+
from: context.pos,
|
|
1219
|
+
options
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
} else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
|
|
1223
|
+
return handleConditionalExpression(
|
|
1224
|
+
lastChild,
|
|
1225
|
+
context,
|
|
1226
|
+
suggestionProvider,
|
|
1227
|
+
maybeComplete,
|
|
1228
|
+
onSubmit.current
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1231
|
+
break;
|
|
1232
|
+
}
|
|
1233
|
+
case "Column":
|
|
1234
|
+
{
|
|
1235
|
+
const isPartialMatch = await suggestionProvider.isPartialMatch(
|
|
1236
|
+
"expression",
|
|
1237
|
+
void 0,
|
|
1238
|
+
word.text
|
|
1239
|
+
);
|
|
1240
|
+
if (isPartialMatch) {
|
|
1241
|
+
return makeSuggestions2(context, "expression", {
|
|
1242
|
+
startsWith: word.text
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
break;
|
|
1247
|
+
case "Comma":
|
|
1248
|
+
{
|
|
1249
|
+
const parentNode = (0, import_vuu_codemirror4.getNamedParentNode)(nodeBefore);
|
|
1250
|
+
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1251
|
+
return makeSuggestions2(context, "expression");
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
break;
|
|
1255
|
+
case "CloseBrace":
|
|
1256
|
+
{
|
|
1257
|
+
const parentNode = (0, import_vuu_codemirror4.getNamedParentNode)(nodeBefore);
|
|
1258
|
+
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1259
|
+
return handleConditionalExpression(
|
|
1260
|
+
parentNode,
|
|
1261
|
+
context,
|
|
1262
|
+
suggestionProvider,
|
|
1263
|
+
maybeComplete,
|
|
1264
|
+
onSubmit.current
|
|
1265
|
+
);
|
|
1266
|
+
} else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
|
|
1267
|
+
if (maybeComplete) {
|
|
1268
|
+
return promptToSave(context, onSubmit.current);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
console.log(
|
|
1272
|
+
`does closebrace denote an ARgList or a parenthetised expression ? ${parentNode}`
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
break;
|
|
1276
|
+
default: {
|
|
1277
|
+
if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
|
|
1278
|
+
console.log("looks like we ight be a or|and operator");
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
},
|
|
1283
|
+
[makeSuggestions2, onSubmit, suggestionProvider]
|
|
1284
|
+
);
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
1288
|
+
var getView = (ref) => {
|
|
1289
|
+
if (ref.current == void 0) {
|
|
1290
|
+
throw Error("EditorView not defined");
|
|
1291
|
+
}
|
|
1292
|
+
return ref.current;
|
|
1293
|
+
};
|
|
1294
|
+
var getOptionClass = () => {
|
|
1295
|
+
return "vuuSuggestion";
|
|
1296
|
+
};
|
|
1297
|
+
var noop = () => console.log("noooop");
|
|
1298
|
+
var hasExpressionType = (completion) => "expressionType" in completion;
|
|
1299
|
+
var injectOptionContent = (completion) => {
|
|
1300
|
+
if (hasExpressionType(completion)) {
|
|
1301
|
+
const div = (0, import_vuu_utils4.createEl)("div", "expression-type-container");
|
|
1302
|
+
const span = (0, import_vuu_utils4.createEl)("span", "expression-type", completion.expressionType);
|
|
1303
|
+
div.appendChild(span);
|
|
1304
|
+
return div;
|
|
1305
|
+
} else {
|
|
1306
|
+
return null;
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
var useColumnExpressionEditor = ({
|
|
1310
|
+
onChange,
|
|
1311
|
+
onSubmitExpression,
|
|
1312
|
+
suggestionProvider
|
|
1313
|
+
}) => {
|
|
1314
|
+
const editorRef = (0, import_react4.useRef)(null);
|
|
1315
|
+
const onSubmit = (0, import_react4.useRef)(noop);
|
|
1316
|
+
const viewRef = (0, import_react4.useRef)();
|
|
1317
|
+
const completionFn = useColumnAutoComplete(suggestionProvider, onSubmit);
|
|
1318
|
+
const [createState, clearInput] = (0, import_react4.useMemo)(() => {
|
|
1319
|
+
const parseExpression = () => {
|
|
1320
|
+
const view = getView(viewRef);
|
|
1321
|
+
const source = view.state.doc.toString();
|
|
1322
|
+
const tree = (0, import_vuu_codemirror5.ensureSyntaxTree)(view.state, view.state.doc.length, 5e3);
|
|
1323
|
+
if (tree) {
|
|
1324
|
+
const expression = walkTree(tree, source);
|
|
1325
|
+
return [source, expression];
|
|
1326
|
+
} else {
|
|
1327
|
+
return ["", void 0];
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
const clearInput2 = () => {
|
|
1331
|
+
getView(viewRef).setState(createState2());
|
|
1332
|
+
};
|
|
1333
|
+
const submitExpressionAndClearInput = () => {
|
|
1334
|
+
const [source, expression] = parseExpression();
|
|
1335
|
+
onSubmitExpression == null ? void 0 : onSubmitExpression(source, expression);
|
|
1336
|
+
clearInput2();
|
|
1337
|
+
};
|
|
1338
|
+
const submitFilter = (key) => {
|
|
1339
|
+
return import_vuu_codemirror5.keymap.of([
|
|
1340
|
+
{
|
|
1341
|
+
key,
|
|
1342
|
+
run() {
|
|
1343
|
+
submitExpressionAndClearInput();
|
|
1344
|
+
return true;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
]);
|
|
1348
|
+
};
|
|
1349
|
+
const showSuggestions = (key) => {
|
|
1350
|
+
return import_vuu_codemirror5.keymap.of([
|
|
1351
|
+
{
|
|
1352
|
+
key,
|
|
1353
|
+
run() {
|
|
1354
|
+
(0, import_vuu_codemirror5.startCompletion)(getView(viewRef));
|
|
1355
|
+
return true;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
]);
|
|
1359
|
+
};
|
|
1360
|
+
const createState2 = () => import_vuu_codemirror5.EditorState.create({
|
|
1361
|
+
doc: "",
|
|
1362
|
+
extensions: [
|
|
1363
|
+
import_vuu_codemirror5.minimalSetup,
|
|
1364
|
+
(0, import_vuu_codemirror5.autocompletion)({
|
|
1365
|
+
addToOptions: [
|
|
1366
|
+
{
|
|
1367
|
+
render: injectOptionContent,
|
|
1368
|
+
position: 70
|
|
1369
|
+
}
|
|
1370
|
+
],
|
|
1371
|
+
override: [completionFn],
|
|
1372
|
+
optionClass: getOptionClass
|
|
1373
|
+
}),
|
|
1374
|
+
columnExpressionLanguageSupport(),
|
|
1375
|
+
import_vuu_codemirror5.keymap.of(import_vuu_codemirror5.defaultKeymap),
|
|
1376
|
+
submitFilter("Ctrl-Enter"),
|
|
1377
|
+
showSuggestions("ArrowDown"),
|
|
1378
|
+
import_vuu_codemirror5.EditorView.updateListener.of((v) => {
|
|
1379
|
+
const view = getView(viewRef);
|
|
1380
|
+
if (v.docChanged) {
|
|
1381
|
+
(0, import_vuu_codemirror5.startCompletion)(view);
|
|
1382
|
+
const source = view.state.doc.toString();
|
|
1383
|
+
onChange == null ? void 0 : onChange(source, void 0);
|
|
1384
|
+
}
|
|
1385
|
+
}),
|
|
1386
|
+
// Enforces single line view
|
|
1387
|
+
// EditorState.transactionFilter.of((tr) =>
|
|
1388
|
+
// tr.newDoc.lines > 1 ? [] : tr
|
|
1389
|
+
// ),
|
|
1390
|
+
vuuTheme,
|
|
1391
|
+
vuuHighlighting
|
|
1392
|
+
]
|
|
1393
|
+
});
|
|
1394
|
+
onSubmit.current = () => {
|
|
1395
|
+
submitExpressionAndClearInput();
|
|
1396
|
+
setTimeout(() => {
|
|
1397
|
+
getView(viewRef).focus();
|
|
1398
|
+
}, 100);
|
|
1399
|
+
};
|
|
1400
|
+
return [createState2, clearInput2];
|
|
1401
|
+
}, [completionFn, onChange, onSubmitExpression]);
|
|
1402
|
+
(0, import_react4.useEffect)(() => {
|
|
1403
|
+
if (!editorRef.current) {
|
|
1404
|
+
throw Error("editor not in dom");
|
|
1405
|
+
}
|
|
1406
|
+
viewRef.current = new import_vuu_codemirror5.EditorView({
|
|
1407
|
+
state: createState(),
|
|
1408
|
+
parent: editorRef.current
|
|
1409
|
+
});
|
|
1410
|
+
return () => {
|
|
1411
|
+
var _a;
|
|
1412
|
+
(_a = viewRef.current) == null ? void 0 : _a.destroy();
|
|
1413
|
+
};
|
|
1414
|
+
}, [completionFn, createState]);
|
|
1415
|
+
return { editorRef, clearInput };
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
// src/column-expression-input/ColumnExpressionInput.tsx
|
|
1419
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1420
|
+
var classBase4 = "vuuColumnExpressionInput";
|
|
1421
|
+
var ColumnExpressionInput = ({
|
|
1422
|
+
onChange,
|
|
1423
|
+
onSubmitExpression,
|
|
1424
|
+
suggestionProvider
|
|
1425
|
+
}) => {
|
|
1426
|
+
const { editorRef } = useColumnExpressionEditor({
|
|
1427
|
+
onChange,
|
|
1428
|
+
onSubmitExpression,
|
|
1429
|
+
suggestionProvider
|
|
1430
|
+
});
|
|
1431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `${classBase4}`, ref: editorRef });
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
// src/column-expression-input/useColumnExpressionSuggestionProvider.ts
|
|
1435
|
+
var import_vuu_codemirror6 = require("@vuu-ui/vuu-codemirror");
|
|
1436
|
+
var import_vuu_data_react = require("@vuu-ui/vuu-data-react");
|
|
1437
|
+
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
1438
|
+
var import_react5 = require("react");
|
|
1439
|
+
|
|
1440
|
+
// src/column-expression-input/column-function-descriptors.ts
|
|
1441
|
+
var columnFunctionDescriptors = [
|
|
1442
|
+
/**
|
|
1443
|
+
* concatenate()
|
|
1444
|
+
*/
|
|
1445
|
+
{
|
|
1446
|
+
accepts: "string",
|
|
1447
|
+
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.",
|
|
1448
|
+
example: {
|
|
1449
|
+
expression: 'concatenate("example", "-test")',
|
|
1450
|
+
result: '"example-test"'
|
|
1451
|
+
},
|
|
1452
|
+
name: "concatenate",
|
|
1453
|
+
params: {
|
|
1454
|
+
description: "( string, string, [ string* ] )"
|
|
1455
|
+
},
|
|
1456
|
+
type: "string"
|
|
1457
|
+
},
|
|
1458
|
+
/**
|
|
1459
|
+
* contains()
|
|
1460
|
+
*/
|
|
1461
|
+
{
|
|
1462
|
+
accepts: ["string", "string"],
|
|
1463
|
+
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>",
|
|
1464
|
+
example: {
|
|
1465
|
+
expression: 'contains("Royal Bank of Scotland", "bank")',
|
|
1466
|
+
result: "true"
|
|
1467
|
+
},
|
|
1468
|
+
name: "contains",
|
|
1469
|
+
params: {
|
|
1470
|
+
description: "( string )"
|
|
1471
|
+
},
|
|
1472
|
+
type: "boolean"
|
|
1473
|
+
},
|
|
1474
|
+
/**
|
|
1475
|
+
* left()
|
|
1476
|
+
*/
|
|
1477
|
+
{
|
|
1478
|
+
accepts: ["string", "number"],
|
|
1479
|
+
description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
|
|
1480
|
+
example: {
|
|
1481
|
+
expression: 'left("USD Benchmark Report", 3)',
|
|
1482
|
+
result: '"USD"'
|
|
1483
|
+
},
|
|
1484
|
+
name: "left",
|
|
1485
|
+
params: {
|
|
1486
|
+
count: 2,
|
|
1487
|
+
description: "( string, number )"
|
|
1488
|
+
},
|
|
1489
|
+
type: "string"
|
|
1490
|
+
},
|
|
1491
|
+
/**
|
|
1492
|
+
* len()
|
|
1493
|
+
*/
|
|
1494
|
+
{
|
|
1495
|
+
accepts: "string",
|
|
1496
|
+
description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
|
|
1497
|
+
example: {
|
|
1498
|
+
expression: 'len("example")',
|
|
1499
|
+
result: "7"
|
|
1500
|
+
},
|
|
1501
|
+
name: "len",
|
|
1502
|
+
params: {
|
|
1503
|
+
description: "(string)"
|
|
1504
|
+
},
|
|
1505
|
+
type: "number"
|
|
1506
|
+
},
|
|
1507
|
+
/**
|
|
1508
|
+
* lower()
|
|
1509
|
+
*/
|
|
1510
|
+
{
|
|
1511
|
+
accepts: "string",
|
|
1512
|
+
description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
|
|
1513
|
+
example: {
|
|
1514
|
+
expression: 'lower("examPLE")',
|
|
1515
|
+
result: '"example"'
|
|
1516
|
+
},
|
|
1517
|
+
name: "lower",
|
|
1518
|
+
params: {
|
|
1519
|
+
description: "( string )"
|
|
1520
|
+
},
|
|
1521
|
+
type: "string"
|
|
1522
|
+
},
|
|
1523
|
+
/**
|
|
1524
|
+
* upper()
|
|
1525
|
+
*/
|
|
1526
|
+
{
|
|
1527
|
+
accepts: "string",
|
|
1528
|
+
description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
|
|
1529
|
+
example: {
|
|
1530
|
+
expression: 'upper("example")',
|
|
1531
|
+
result: '"EXAMPLE"'
|
|
1532
|
+
},
|
|
1533
|
+
name: "upper",
|
|
1534
|
+
params: {
|
|
1535
|
+
description: "( string )"
|
|
1536
|
+
},
|
|
1537
|
+
type: "string"
|
|
1538
|
+
},
|
|
1539
|
+
/**
|
|
1540
|
+
* right()
|
|
1541
|
+
*/
|
|
1542
|
+
{
|
|
1543
|
+
accepts: ["string", "number"],
|
|
1544
|
+
description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
|
|
1545
|
+
example: {
|
|
1546
|
+
expression: "blah",
|
|
1547
|
+
result: "blah"
|
|
1548
|
+
},
|
|
1549
|
+
name: "right",
|
|
1550
|
+
params: {
|
|
1551
|
+
description: "( string )"
|
|
1552
|
+
},
|
|
1553
|
+
type: "string"
|
|
1554
|
+
},
|
|
1555
|
+
/**
|
|
1556
|
+
* replace()
|
|
1557
|
+
*/
|
|
1558
|
+
{
|
|
1559
|
+
accepts: ["string", "string", "string"],
|
|
1560
|
+
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>",
|
|
1561
|
+
example: {
|
|
1562
|
+
expression: "blah",
|
|
1563
|
+
result: "blah"
|
|
1564
|
+
},
|
|
1565
|
+
name: "replace",
|
|
1566
|
+
params: {
|
|
1567
|
+
description: "( string )"
|
|
1568
|
+
},
|
|
1569
|
+
type: "string"
|
|
1570
|
+
},
|
|
1571
|
+
/**
|
|
1572
|
+
* text()
|
|
1573
|
+
*/
|
|
1574
|
+
{
|
|
1575
|
+
accepts: "number",
|
|
1576
|
+
description: "Converts a number to a string.",
|
|
1577
|
+
example: {
|
|
1578
|
+
expression: "blah",
|
|
1579
|
+
result: "blah"
|
|
1580
|
+
},
|
|
1581
|
+
name: "text",
|
|
1582
|
+
params: {
|
|
1583
|
+
description: "( string )"
|
|
1584
|
+
},
|
|
1585
|
+
type: "string"
|
|
1586
|
+
},
|
|
1587
|
+
/**
|
|
1588
|
+
* starts()
|
|
1589
|
+
*/
|
|
1590
|
+
{
|
|
1591
|
+
accepts: "string",
|
|
1592
|
+
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>.",
|
|
1593
|
+
example: {
|
|
1594
|
+
expression: "blah",
|
|
1595
|
+
result: "blah"
|
|
1596
|
+
},
|
|
1597
|
+
name: "starts",
|
|
1598
|
+
params: {
|
|
1599
|
+
description: "( string )"
|
|
1600
|
+
},
|
|
1601
|
+
type: "boolean"
|
|
1602
|
+
},
|
|
1603
|
+
/**
|
|
1604
|
+
* starts()
|
|
1605
|
+
*/
|
|
1606
|
+
{
|
|
1607
|
+
accepts: "string",
|
|
1608
|
+
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>.",
|
|
1609
|
+
example: {
|
|
1610
|
+
expression: "blah",
|
|
1611
|
+
result: "blah"
|
|
1612
|
+
},
|
|
1613
|
+
name: "ends",
|
|
1614
|
+
params: {
|
|
1615
|
+
description: "( string )"
|
|
1616
|
+
},
|
|
1617
|
+
type: "boolean"
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
accepts: "number",
|
|
1621
|
+
description: "blah",
|
|
1622
|
+
example: {
|
|
1623
|
+
expression: "blah",
|
|
1624
|
+
result: "blah"
|
|
1625
|
+
},
|
|
1626
|
+
name: "min",
|
|
1627
|
+
params: {
|
|
1628
|
+
description: "( string )"
|
|
1629
|
+
},
|
|
1630
|
+
type: "number"
|
|
1631
|
+
},
|
|
1632
|
+
{
|
|
1633
|
+
accepts: "number",
|
|
1634
|
+
description: "blah",
|
|
1635
|
+
example: {
|
|
1636
|
+
expression: "blah",
|
|
1637
|
+
result: "blah"
|
|
1638
|
+
},
|
|
1639
|
+
name: "max",
|
|
1640
|
+
params: {
|
|
1641
|
+
description: "( string )"
|
|
1642
|
+
},
|
|
1643
|
+
type: "number"
|
|
1644
|
+
},
|
|
1645
|
+
{
|
|
1646
|
+
accepts: "number",
|
|
1647
|
+
description: "blah",
|
|
1648
|
+
example: {
|
|
1649
|
+
expression: "blah",
|
|
1650
|
+
result: "blah"
|
|
1651
|
+
},
|
|
1652
|
+
name: "sum",
|
|
1653
|
+
params: {
|
|
1654
|
+
description: "( string )"
|
|
1655
|
+
},
|
|
1656
|
+
type: "number"
|
|
1657
|
+
},
|
|
1658
|
+
{
|
|
1659
|
+
accepts: "number",
|
|
1660
|
+
description: "blah",
|
|
1661
|
+
example: {
|
|
1662
|
+
expression: "blah",
|
|
1663
|
+
result: "blah"
|
|
1664
|
+
},
|
|
1665
|
+
name: "round",
|
|
1666
|
+
params: {
|
|
1667
|
+
description: "( string )"
|
|
1668
|
+
},
|
|
1669
|
+
type: "number"
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
accepts: "any",
|
|
1673
|
+
description: "blah",
|
|
1674
|
+
example: {
|
|
1675
|
+
expression: "blah",
|
|
1676
|
+
result: "blah"
|
|
1677
|
+
},
|
|
1678
|
+
name: "or",
|
|
1679
|
+
params: {
|
|
1680
|
+
description: "( string )"
|
|
1681
|
+
},
|
|
1682
|
+
type: "boolean"
|
|
1683
|
+
},
|
|
1684
|
+
{
|
|
1685
|
+
accepts: "any",
|
|
1686
|
+
description: "blah",
|
|
1687
|
+
example: {
|
|
1688
|
+
expression: "blah",
|
|
1689
|
+
result: "blah"
|
|
1690
|
+
},
|
|
1691
|
+
name: "and",
|
|
1692
|
+
params: {
|
|
1693
|
+
description: "( string )"
|
|
1694
|
+
},
|
|
1695
|
+
type: "boolean"
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
accepts: "any",
|
|
1699
|
+
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>. ",
|
|
1700
|
+
example: {
|
|
1701
|
+
expression: "blah",
|
|
1702
|
+
result: "blah"
|
|
1703
|
+
},
|
|
1704
|
+
name: "if",
|
|
1705
|
+
params: {
|
|
1706
|
+
description: "( filterExpression, expression1, expression 2)"
|
|
1707
|
+
},
|
|
1708
|
+
type: "variable"
|
|
1709
|
+
}
|
|
1710
|
+
];
|
|
1711
|
+
|
|
1712
|
+
// src/column-expression-input/functionDocInfo.ts
|
|
1713
|
+
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
1714
|
+
var functionDocInfo = ({
|
|
1715
|
+
name,
|
|
1716
|
+
description,
|
|
1717
|
+
example,
|
|
1718
|
+
params,
|
|
1719
|
+
type
|
|
1720
|
+
}) => {
|
|
1721
|
+
const rootElement = (0, import_vuu_utils5.createEl)("div", "vuuFunctionDoc");
|
|
1722
|
+
const headingElement = (0, import_vuu_utils5.createEl)("div", "function-heading");
|
|
1723
|
+
const nameElement = (0, import_vuu_utils5.createEl)("span", "function-name", name);
|
|
1724
|
+
const paramElement = (0, import_vuu_utils5.createEl)("span", "param-list", params.description);
|
|
1725
|
+
const typeElement = (0, import_vuu_utils5.createEl)("span", "function-type", type);
|
|
1726
|
+
headingElement.appendChild(nameElement);
|
|
1727
|
+
headingElement.appendChild(paramElement);
|
|
1728
|
+
headingElement.appendChild(typeElement);
|
|
1729
|
+
const child2 = (0, import_vuu_utils5.createEl)("p", void 0, description);
|
|
1730
|
+
rootElement.appendChild(headingElement);
|
|
1731
|
+
rootElement.appendChild(child2);
|
|
1732
|
+
if (example) {
|
|
1733
|
+
const exampleElement = (0, import_vuu_utils5.createEl)("div", "example-container", "Example:");
|
|
1734
|
+
const expressionElement = (0, import_vuu_utils5.createEl)(
|
|
1735
|
+
"div",
|
|
1736
|
+
"example-expression",
|
|
1737
|
+
example.expression
|
|
1738
|
+
);
|
|
1739
|
+
const resultElement = (0, import_vuu_utils5.createEl)("div", "example-result", example.result);
|
|
1740
|
+
exampleElement.appendChild(expressionElement);
|
|
1741
|
+
exampleElement.appendChild(resultElement);
|
|
1742
|
+
rootElement.appendChild(exampleElement);
|
|
1743
|
+
}
|
|
1744
|
+
return rootElement;
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
// src/column-expression-input/useColumnExpressionSuggestionProvider.ts
|
|
1748
|
+
var NO_OPERATORS = [];
|
|
1749
|
+
var withApplySpace = (suggestions) => suggestions.map((suggestion) => {
|
|
1750
|
+
var _a;
|
|
1751
|
+
return {
|
|
1752
|
+
...suggestion,
|
|
1753
|
+
apply: ((_a = suggestion.apply) != null ? _a : suggestion.label) + " "
|
|
1754
|
+
};
|
|
1755
|
+
});
|
|
1756
|
+
var getValidColumns = (columns, { functionName, operator }) => {
|
|
1757
|
+
if (operator) {
|
|
1758
|
+
return columns.filter(import_vuu_utils6.isNumericColumn);
|
|
1759
|
+
} else if (functionName) {
|
|
1760
|
+
const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
|
|
1761
|
+
if (fn) {
|
|
1762
|
+
switch (fn.accepts) {
|
|
1763
|
+
case "string":
|
|
1764
|
+
return columns.filter(import_vuu_utils6.isTextColumn);
|
|
1765
|
+
case "number":
|
|
1766
|
+
return columns.filter(import_vuu_utils6.isNumericColumn);
|
|
1767
|
+
default:
|
|
1768
|
+
return columns;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
return columns;
|
|
1773
|
+
};
|
|
1774
|
+
var getColumns = (columns, options) => {
|
|
1775
|
+
const validColumns = getValidColumns(columns, options);
|
|
1776
|
+
return validColumns.map((column) => {
|
|
1777
|
+
var _a;
|
|
1778
|
+
const label = (_a = column.label) != null ? _a : column.name;
|
|
1779
|
+
return {
|
|
1780
|
+
apply: options.prefix ? `${options.prefix}${label}` : label,
|
|
1781
|
+
label,
|
|
1782
|
+
boost: 5,
|
|
1783
|
+
type: "column",
|
|
1784
|
+
expressionType: column.serverDataType
|
|
1785
|
+
};
|
|
1786
|
+
});
|
|
1787
|
+
};
|
|
1788
|
+
var arithmeticOperators = [
|
|
1789
|
+
{ apply: "* ", boost: 2, label: "*", type: "operator" },
|
|
1790
|
+
{ apply: "/ ", boost: 2, label: "/", type: "operator" },
|
|
1791
|
+
{ apply: "+ ", boost: 2, label: "+", type: "operator" },
|
|
1792
|
+
{ apply: "- ", boost: 2, label: "-", type: "operator" }
|
|
1793
|
+
];
|
|
1794
|
+
var getOperators = (column) => {
|
|
1795
|
+
if (column === void 0 || (0, import_vuu_utils6.isNumericColumn)(column)) {
|
|
1796
|
+
return arithmeticOperators;
|
|
1797
|
+
} else {
|
|
1798
|
+
return NO_OPERATORS;
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
var getConditionOperators = (column) => {
|
|
1802
|
+
switch (column.serverDataType) {
|
|
1803
|
+
case "string":
|
|
1804
|
+
case "char":
|
|
1805
|
+
return withApplySpace(
|
|
1806
|
+
import_vuu_codemirror6.stringOperators
|
|
1807
|
+
/*, startsWith*/
|
|
1808
|
+
);
|
|
1809
|
+
case "int":
|
|
1810
|
+
case "long":
|
|
1811
|
+
case "double":
|
|
1812
|
+
return withApplySpace(import_vuu_codemirror6.numericOperators);
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
var toFunctionCompletion = (functionDescriptor) => ({
|
|
1816
|
+
apply: `${functionDescriptor.name}( `,
|
|
1817
|
+
boost: 2,
|
|
1818
|
+
expressionType: functionDescriptor.type,
|
|
1819
|
+
info: () => functionDocInfo(functionDescriptor),
|
|
1820
|
+
label: functionDescriptor.name,
|
|
1821
|
+
type: "function"
|
|
1822
|
+
});
|
|
1823
|
+
var getAcceptedTypes = (fn) => {
|
|
1824
|
+
if (fn) {
|
|
1825
|
+
if (typeof fn.accepts === "string") {
|
|
1826
|
+
return fn.accepts;
|
|
1827
|
+
} else if (Array.isArray(fn.accepts)) {
|
|
1828
|
+
if (fn.accepts.every((s) => s === "string")) {
|
|
1829
|
+
return "string";
|
|
1830
|
+
} else {
|
|
1831
|
+
return "any";
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
return "any";
|
|
1836
|
+
};
|
|
1837
|
+
var functions = columnFunctionDescriptors.map(toFunctionCompletion);
|
|
1838
|
+
var getFunctions = ({ functionName }) => {
|
|
1839
|
+
if (functionName) {
|
|
1840
|
+
const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
|
|
1841
|
+
const acceptedTypes = getAcceptedTypes(fn);
|
|
1842
|
+
if (fn) {
|
|
1843
|
+
switch (acceptedTypes) {
|
|
1844
|
+
case "string":
|
|
1845
|
+
return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
|
|
1846
|
+
case "number":
|
|
1847
|
+
return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
|
|
1848
|
+
default:
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
return functions;
|
|
1853
|
+
};
|
|
1854
|
+
var NONE = {};
|
|
1855
|
+
var useColumnExpressionSuggestionProvider = ({
|
|
1856
|
+
columns,
|
|
1857
|
+
table
|
|
1858
|
+
}) => {
|
|
1859
|
+
const findColumn3 = (0, import_react5.useCallback)(
|
|
1860
|
+
(name) => name ? columns.find((col) => col.name === name) : void 0,
|
|
1861
|
+
[columns]
|
|
1862
|
+
);
|
|
1863
|
+
const latestSuggestionsRef = (0, import_react5.useRef)();
|
|
1864
|
+
const getTypeaheadSuggestions = (0, import_vuu_data_react.useTypeaheadSuggestions)();
|
|
1865
|
+
const getSuggestions = (0, import_react5.useCallback)(
|
|
1866
|
+
async (suggestionType, options = NONE) => {
|
|
1867
|
+
const { columnName, functionName, operator, prefix } = options;
|
|
1868
|
+
switch (suggestionType) {
|
|
1869
|
+
case "expression": {
|
|
1870
|
+
const suggestions = await withApplySpace(
|
|
1871
|
+
getColumns(columns, { functionName, prefix })
|
|
1872
|
+
).concat(getFunctions(options));
|
|
1873
|
+
return latestSuggestionsRef.current = suggestions;
|
|
1874
|
+
}
|
|
1875
|
+
case "column": {
|
|
1876
|
+
const suggestions = await getColumns(columns, options);
|
|
1877
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1878
|
+
}
|
|
1879
|
+
case "operator": {
|
|
1880
|
+
const suggestions = await getOperators(findColumn3(columnName));
|
|
1881
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1882
|
+
}
|
|
1883
|
+
case "relational-operator": {
|
|
1884
|
+
const suggestions = await (0, import_vuu_codemirror6.getRelationalOperators)(
|
|
1885
|
+
findColumn3(columnName)
|
|
1886
|
+
);
|
|
1887
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1888
|
+
}
|
|
1889
|
+
case "condition-operator":
|
|
1890
|
+
{
|
|
1891
|
+
const column = findColumn3(columnName);
|
|
1892
|
+
if (column) {
|
|
1893
|
+
const suggestions = await getConditionOperators(column);
|
|
1894
|
+
if (suggestions) {
|
|
1895
|
+
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
break;
|
|
1900
|
+
case "columnValue":
|
|
1901
|
+
if (columnName && operator) {
|
|
1902
|
+
const params = (0, import_vuu_data_react.getTypeaheadParams)(
|
|
1903
|
+
table,
|
|
1904
|
+
columnName
|
|
1905
|
+
/*, startsWith*/
|
|
1906
|
+
);
|
|
1907
|
+
const suggestions = await getTypeaheadSuggestions(params);
|
|
1908
|
+
latestSuggestionsRef.current = (0, import_vuu_codemirror6.toSuggestions)(suggestions, {
|
|
1909
|
+
suffix: ""
|
|
1910
|
+
});
|
|
1911
|
+
latestSuggestionsRef.current.forEach((suggestion) => {
|
|
1912
|
+
suggestion.apply = (view, completion, from) => {
|
|
1913
|
+
const annotation = new import_vuu_codemirror6.AnnotationType();
|
|
1914
|
+
const cursorPos = from + completion.label.length + 1;
|
|
1915
|
+
view.dispatch({
|
|
1916
|
+
changes: { from, insert: completion.label },
|
|
1917
|
+
selection: { anchor: cursorPos, head: cursorPos },
|
|
1918
|
+
annotations: annotation.of(completion)
|
|
1919
|
+
});
|
|
1920
|
+
};
|
|
1921
|
+
});
|
|
1922
|
+
return latestSuggestionsRef.current;
|
|
1923
|
+
}
|
|
1924
|
+
break;
|
|
1925
|
+
}
|
|
1926
|
+
return [];
|
|
1927
|
+
},
|
|
1928
|
+
[columns, findColumn3, getTypeaheadSuggestions, table]
|
|
1929
|
+
);
|
|
1930
|
+
const isPartialMatch = (0, import_react5.useCallback)(
|
|
1931
|
+
async (valueType, columnName, pattern) => {
|
|
1932
|
+
const { current: latestSuggestions } = latestSuggestionsRef;
|
|
1933
|
+
let maybe = false;
|
|
1934
|
+
const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
|
|
1935
|
+
if (pattern && suggestions) {
|
|
1936
|
+
for (const option of suggestions) {
|
|
1937
|
+
if (option.label === pattern) {
|
|
1938
|
+
return false;
|
|
1939
|
+
} else if (option.label.startsWith(pattern)) {
|
|
1940
|
+
maybe = true;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
return maybe;
|
|
1945
|
+
},
|
|
1946
|
+
[getSuggestions]
|
|
1947
|
+
);
|
|
1948
|
+
return {
|
|
1949
|
+
getSuggestions,
|
|
1950
|
+
isPartialMatch
|
|
1951
|
+
};
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1954
|
+
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
1955
|
+
var import_core7 = require("@salt-ds/core");
|
|
1956
|
+
var import_classnames6 = __toESM(require("classnames"), 1);
|
|
1957
|
+
var import_react12 = require("react");
|
|
1958
|
+
|
|
1959
|
+
// src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
|
|
1960
|
+
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
1961
|
+
var import_lab4 = require("@salt-ds/lab");
|
|
1962
|
+
var import_core4 = require("@salt-ds/core");
|
|
1963
|
+
var import_classnames5 = __toESM(require("classnames"), 1);
|
|
1964
|
+
var import_react8 = require("react");
|
|
1965
|
+
|
|
1966
|
+
// src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
|
|
1967
|
+
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
1968
|
+
var import_lab3 = require("@salt-ds/lab");
|
|
1969
|
+
var import_core3 = require("@salt-ds/core");
|
|
1970
|
+
var import_classnames4 = __toESM(require("classnames"), 1);
|
|
1971
|
+
var import_react7 = require("react");
|
|
1972
|
+
|
|
1973
|
+
// src/datagrid-configuration-ui/column-type-panel/NumericColumnPanel.tsx
|
|
1974
|
+
var import_lab2 = require("@salt-ds/lab");
|
|
1975
|
+
var import_core2 = require("@salt-ds/core");
|
|
1976
|
+
var import_react6 = require("react");
|
|
1977
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1978
|
+
var defaultValues = {
|
|
1979
|
+
alignOnDecimals: false,
|
|
1980
|
+
decimals: 4,
|
|
1981
|
+
zeroPad: false
|
|
1982
|
+
};
|
|
1983
|
+
var getColumnValues = (columnType, gridDefaultValues) => {
|
|
1984
|
+
const columnValue = typeof columnType === "object" && columnType.formatting ? columnType.formatting : {};
|
|
1985
|
+
const properties = ["alignOnDecimals", "decimals", "zeroPad"];
|
|
1986
|
+
return properties.reduce((configValues, property) => {
|
|
1987
|
+
if (columnValue[property] !== void 0) {
|
|
1988
|
+
return {
|
|
1989
|
+
...configValues,
|
|
1990
|
+
[property]: columnValue[property]
|
|
1991
|
+
};
|
|
1992
|
+
} else if ((gridDefaultValues == null ? void 0 : gridDefaultValues[property]) !== void 0) {
|
|
1993
|
+
return {
|
|
1994
|
+
...configValues,
|
|
1995
|
+
[property]: gridDefaultValues[property]
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
return configValues;
|
|
1999
|
+
}, defaultValues);
|
|
2000
|
+
};
|
|
2001
|
+
var NumericColumnPanel = ({
|
|
2002
|
+
column,
|
|
2003
|
+
dispatchColumnAction
|
|
2004
|
+
}) => {
|
|
2005
|
+
const { decimals, alignOnDecimals, zeroPad } = getColumnValues(column == null ? void 0 : column.type);
|
|
2006
|
+
const dispatchUpdate = (0, import_react6.useCallback)(
|
|
2007
|
+
(values) => dispatchColumnAction({
|
|
2008
|
+
type: "updateColumnTypeFormatting",
|
|
2009
|
+
column,
|
|
2010
|
+
...values
|
|
2011
|
+
}),
|
|
2012
|
+
[column, dispatchColumnAction]
|
|
2013
|
+
);
|
|
2014
|
+
const handleChangeDecimals = (0, import_react6.useCallback)(
|
|
2015
|
+
(value) => dispatchUpdate({ decimals: parseInt(value.toString(), 10) }),
|
|
2016
|
+
[dispatchUpdate]
|
|
2017
|
+
);
|
|
2018
|
+
const handleChangeAlignOnDecimals = (0, import_react6.useCallback)(
|
|
2019
|
+
(evt) => dispatchUpdate({ alignOnDecimals: Boolean(evt.target.value) }),
|
|
2020
|
+
[dispatchUpdate]
|
|
2021
|
+
);
|
|
2022
|
+
const handleChangeZeroPad = (0, import_react6.useCallback)(
|
|
2023
|
+
(evt) => dispatchUpdate({ zeroPad: Boolean(evt.target.value) }),
|
|
2024
|
+
[dispatchUpdate]
|
|
2025
|
+
);
|
|
2026
|
+
switch (column.serverDataType) {
|
|
2027
|
+
case "double":
|
|
2028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_core2.FormField, { labelPlacement: "top", children: [
|
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core2.FormFieldLabel, { children: "No of Decimals" }),
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lab2.StepperInput, { value: decimals, onChange: handleChangeDecimals })
|
|
2032
|
+
] }),
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2034
|
+
import_lab2.Switch,
|
|
2035
|
+
{
|
|
2036
|
+
checked: alignOnDecimals,
|
|
2037
|
+
label: "Align on decimals",
|
|
2038
|
+
onChange: handleChangeAlignOnDecimals
|
|
2039
|
+
}
|
|
2040
|
+
),
|
|
2041
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2042
|
+
import_lab2.Switch,
|
|
2043
|
+
{
|
|
2044
|
+
checked: zeroPad,
|
|
2045
|
+
label: "Zero pad",
|
|
2046
|
+
onChange: handleChangeZeroPad
|
|
2047
|
+
}
|
|
2048
|
+
)
|
|
2049
|
+
] });
|
|
2050
|
+
case "long":
|
|
2051
|
+
case "int":
|
|
2052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core2.Text, { children: "Work in progress" }) });
|
|
2053
|
+
default:
|
|
2054
|
+
return null;
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
|
|
2058
|
+
// src/datagrid-configuration-ui/column-type-panel/StringColumnPanel.tsx
|
|
2059
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2060
|
+
var StringColumnPanel = ({
|
|
2061
|
+
column,
|
|
2062
|
+
dispatchColumnAction
|
|
2063
|
+
}) => {
|
|
2064
|
+
console.log({ column, dispatchColumnAction });
|
|
2065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: "what" });
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
// src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
|
|
2069
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2070
|
+
var classBase5 = "vuuColumnTypePanel";
|
|
2071
|
+
var integerCellRenderers = ["Default Renderer (int, long)"];
|
|
2072
|
+
var doubleCellRenderers = ["Default Renderer (double)"];
|
|
2073
|
+
var stringCellRenderers = ["Default Renderer (string)"];
|
|
2074
|
+
var getAvailableCellRenderers = (column) => {
|
|
2075
|
+
const customCellRenderers = (0, import_vuu_utils7.getRegisteredCellRenderers)(column.serverDataType);
|
|
2076
|
+
const customRendererNames = customCellRenderers.map((r) => r.name);
|
|
2077
|
+
console.log({ customRendererNames });
|
|
2078
|
+
switch (column.serverDataType) {
|
|
2079
|
+
case "char":
|
|
2080
|
+
case "string":
|
|
2081
|
+
return stringCellRenderers;
|
|
2082
|
+
case "int":
|
|
2083
|
+
case "long":
|
|
2084
|
+
return integerCellRenderers;
|
|
2085
|
+
case "double":
|
|
2086
|
+
return doubleCellRenderers.concat(customRendererNames);
|
|
2087
|
+
default:
|
|
2088
|
+
return stringCellRenderers;
|
|
2089
|
+
}
|
|
2090
|
+
};
|
|
2091
|
+
var ColumnTypePanel = ({
|
|
2092
|
+
className,
|
|
2093
|
+
column,
|
|
2094
|
+
dispatchColumnAction,
|
|
2095
|
+
...props
|
|
2096
|
+
}) => {
|
|
2097
|
+
const content = (0, import_react7.useMemo)(() => {
|
|
2098
|
+
switch (column.serverDataType) {
|
|
2099
|
+
case "double":
|
|
2100
|
+
case "int":
|
|
2101
|
+
case "long":
|
|
2102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2103
|
+
NumericColumnPanel,
|
|
2104
|
+
{
|
|
2105
|
+
column,
|
|
2106
|
+
dispatchColumnAction
|
|
2107
|
+
}
|
|
2108
|
+
);
|
|
2109
|
+
default:
|
|
2110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2111
|
+
StringColumnPanel,
|
|
2112
|
+
{
|
|
2113
|
+
column,
|
|
2114
|
+
dispatchColumnAction
|
|
2115
|
+
}
|
|
2116
|
+
);
|
|
2117
|
+
}
|
|
2118
|
+
}, [column, dispatchColumnAction]);
|
|
2119
|
+
const { serverDataType = "string" } = column;
|
|
2120
|
+
const availableRenderers = getAvailableCellRenderers(column);
|
|
2121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
2122
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2123
|
+
import_lab3.Dropdown,
|
|
2124
|
+
{
|
|
2125
|
+
className: (0, import_classnames4.default)(`${classBase5}-renderer`),
|
|
2126
|
+
fullWidth: true,
|
|
2127
|
+
selected: availableRenderers[0],
|
|
2128
|
+
source: availableRenderers
|
|
2129
|
+
}
|
|
2130
|
+
),
|
|
2131
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2132
|
+
import_core3.Panel,
|
|
2133
|
+
{
|
|
2134
|
+
...props,
|
|
2135
|
+
className: (0, import_classnames4.default)(classBase5, className, `${classBase5}-${serverDataType}`),
|
|
2136
|
+
children: content
|
|
2137
|
+
}
|
|
2138
|
+
)
|
|
2139
|
+
] });
|
|
2140
|
+
};
|
|
2141
|
+
|
|
2142
|
+
// src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
|
|
2143
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2144
|
+
var classBase6 = "vuuColumnSettingsPanel";
|
|
2145
|
+
var tabstripProps = {
|
|
2146
|
+
className: "salt-density-high"
|
|
2147
|
+
};
|
|
2148
|
+
var ColumnSettingsPanel = ({
|
|
2149
|
+
column,
|
|
2150
|
+
dispatchColumnAction,
|
|
2151
|
+
style: styleProp,
|
|
2152
|
+
...props
|
|
2153
|
+
}) => {
|
|
2154
|
+
var _a, _b, _c, _d;
|
|
2155
|
+
const [activeTab, setActiveTab] = (0, import_react8.useState)(0);
|
|
2156
|
+
const dispatchUpdate = (0, import_react8.useCallback)(
|
|
2157
|
+
(values) => dispatchColumnAction({
|
|
2158
|
+
type: "updateColumnProp",
|
|
2159
|
+
column,
|
|
2160
|
+
...values
|
|
2161
|
+
}),
|
|
2162
|
+
[column, dispatchColumnAction]
|
|
2163
|
+
);
|
|
2164
|
+
const handleChangeAlign = (0, import_react8.useCallback)(
|
|
2165
|
+
(evt) => dispatchUpdate({ align: evt.target.value }),
|
|
2166
|
+
[dispatchUpdate]
|
|
2167
|
+
);
|
|
2168
|
+
const handleChangePin = (0, import_react8.useCallback)(
|
|
2169
|
+
(evt) => dispatchUpdate({ pin: evt.target.value }),
|
|
2170
|
+
[dispatchUpdate]
|
|
2171
|
+
);
|
|
2172
|
+
const handleChangeHidden = (0, import_react8.useCallback)(
|
|
2173
|
+
(evt) => dispatchUpdate({ hidden: evt.target.checked }),
|
|
2174
|
+
[dispatchUpdate]
|
|
2175
|
+
);
|
|
2176
|
+
const handleChangeLabel = (0, import_react8.useCallback)(
|
|
2177
|
+
(evt) => dispatchUpdate({ label: evt.target.value }),
|
|
2178
|
+
[dispatchUpdate]
|
|
2179
|
+
);
|
|
2180
|
+
const handleChangeWidth = (0, import_react8.useCallback)(
|
|
2181
|
+
(value) => dispatchUpdate({ width: parseInt(value.toString(), 10) }),
|
|
2182
|
+
[dispatchUpdate]
|
|
2183
|
+
);
|
|
2184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2185
|
+
"div",
|
|
2186
|
+
{
|
|
2187
|
+
className: classBase6,
|
|
2188
|
+
...props,
|
|
2189
|
+
style: {
|
|
2190
|
+
...styleProp
|
|
2191
|
+
},
|
|
2192
|
+
children: [
|
|
2193
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.Text, { as: "h4", children: "Column Settings" }),
|
|
2194
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2195
|
+
import_vuu_layout.Stack,
|
|
2196
|
+
{
|
|
2197
|
+
active: activeTab,
|
|
2198
|
+
className: (0, import_classnames5.default)(`${classBase6}-columnTabs`),
|
|
2199
|
+
onTabSelectionChanged: setActiveTab,
|
|
2200
|
+
TabstripProps: tabstripProps,
|
|
2201
|
+
children: [
|
|
2202
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.Panel, { title: "Column", children: [
|
|
2203
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.FormField, { labelPlacement: "left", children: [
|
|
2204
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.FormFieldLabel, { children: "Hidden" }),
|
|
2205
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2206
|
+
import_core4.Checkbox,
|
|
2207
|
+
{
|
|
2208
|
+
checked: column.hidden === true,
|
|
2209
|
+
onChange: handleChangeHidden
|
|
2210
|
+
}
|
|
2211
|
+
)
|
|
2212
|
+
] }),
|
|
2213
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.FormField, { labelPlacement: "left", children: [
|
|
2214
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.FormFieldLabel, { children: "Label" }),
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2216
|
+
import_core4.Input,
|
|
2217
|
+
{
|
|
2218
|
+
value: (_a = column.label) != null ? _a : column.name,
|
|
2219
|
+
onChange: handleChangeLabel
|
|
2220
|
+
}
|
|
2221
|
+
)
|
|
2222
|
+
] }),
|
|
2223
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.FormField, { labelPlacement: "left", children: [
|
|
2224
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.FormFieldLabel, { children: "Width" }),
|
|
2225
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2226
|
+
import_lab4.StepperInput,
|
|
2227
|
+
{
|
|
2228
|
+
value: (_b = column.width) != null ? _b : 100,
|
|
2229
|
+
onChange: handleChangeWidth
|
|
2230
|
+
}
|
|
2231
|
+
)
|
|
2232
|
+
] }),
|
|
2233
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.FormField, { labelPlacement: "left", children: [
|
|
2234
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.FormFieldLabel, { children: "ALign" }),
|
|
2235
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2236
|
+
import_core4.RadioButtonGroup,
|
|
2237
|
+
{
|
|
2238
|
+
"aria-label": "Column Align",
|
|
2239
|
+
value: (_c = column.align) != null ? _c : "left",
|
|
2240
|
+
onChange: handleChangeAlign,
|
|
2241
|
+
children: [
|
|
2242
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.RadioButton, { label: "Left", value: "left" }),
|
|
2243
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.RadioButton, { label: "Right", value: "right" })
|
|
2244
|
+
]
|
|
2245
|
+
}
|
|
2246
|
+
)
|
|
2247
|
+
] }),
|
|
2248
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.FormField, { labelPlacement: "left", children: [
|
|
2249
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.FormFieldLabel, { children: "Pin Column" }),
|
|
2250
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2251
|
+
import_core4.RadioButtonGroup,
|
|
2252
|
+
{
|
|
2253
|
+
"aria-label": "Pin Column",
|
|
2254
|
+
value: (_d = column.pin) != null ? _d : "",
|
|
2255
|
+
onChange: handleChangePin,
|
|
2256
|
+
children: [
|
|
2257
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.RadioButton, { label: "Do not pin", value: "" }),
|
|
2258
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.RadioButton, { label: "Left", value: "left" }),
|
|
2259
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.RadioButton, { label: "Right", value: "right" })
|
|
2260
|
+
]
|
|
2261
|
+
}
|
|
2262
|
+
)
|
|
2263
|
+
] })
|
|
2264
|
+
] }),
|
|
2265
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2266
|
+
ColumnTypePanel,
|
|
2267
|
+
{
|
|
2268
|
+
column,
|
|
2269
|
+
dispatchColumnAction,
|
|
2270
|
+
title: "Data Cell"
|
|
2271
|
+
}
|
|
2272
|
+
),
|
|
2273
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.Panel, { title: "Vuu", variant: "secondary", children: [
|
|
2274
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.FormField, { labelPlacement: "top", readOnly: true, children: [
|
|
2275
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.FormFieldLabel, { children: "Name" }),
|
|
2276
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.Input, { value: column.name })
|
|
2277
|
+
] }),
|
|
2278
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core4.FormField, { labelPlacement: "top", readOnly: true, children: [
|
|
2279
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.FormFieldLabel, { children: "Vuu Type" }),
|
|
2280
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core4.Input, { value: column.serverDataType })
|
|
2281
|
+
] })
|
|
2282
|
+
] })
|
|
2283
|
+
]
|
|
2284
|
+
}
|
|
2285
|
+
)
|
|
2286
|
+
]
|
|
2287
|
+
}
|
|
2288
|
+
);
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
// src/datagrid-configuration-ui/settings-panel/GridSettingsPanel.tsx
|
|
2292
|
+
var import_core5 = require("@salt-ds/core");
|
|
2293
|
+
var import_lab5 = require("@salt-ds/lab");
|
|
2294
|
+
var import_react9 = require("react");
|
|
2295
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2296
|
+
var classBase7 = "vuuGridSettingsPanel";
|
|
2297
|
+
var GridSettingsPanel = ({
|
|
2298
|
+
config,
|
|
2299
|
+
dispatchColumnAction,
|
|
2300
|
+
style: styleProp,
|
|
2301
|
+
...props
|
|
2302
|
+
}) => {
|
|
2303
|
+
var _a;
|
|
2304
|
+
const dispatchUpdate = (0, import_react9.useCallback)(
|
|
2305
|
+
(values) => dispatchColumnAction({
|
|
2306
|
+
type: "updateGridSettings",
|
|
2307
|
+
...values
|
|
2308
|
+
}),
|
|
2309
|
+
[dispatchColumnAction]
|
|
2310
|
+
);
|
|
2311
|
+
const handleChangeLabelFormatting = (0, import_react9.useCallback)(
|
|
2312
|
+
(evt) => dispatchUpdate({
|
|
2313
|
+
columnFormatHeader: evt.target.value
|
|
2314
|
+
}),
|
|
2315
|
+
[dispatchUpdate]
|
|
2316
|
+
);
|
|
2317
|
+
const handleChangeWidth = (0, import_react9.useCallback)(
|
|
2318
|
+
(value) => dispatchUpdate({ columnDefaultWidth: parseInt(value.toString(), 10) }),
|
|
2319
|
+
[dispatchUpdate]
|
|
2320
|
+
);
|
|
2321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2322
|
+
"div",
|
|
2323
|
+
{
|
|
2324
|
+
className: classBase7,
|
|
2325
|
+
...props,
|
|
2326
|
+
style: {
|
|
2327
|
+
...styleProp
|
|
2328
|
+
},
|
|
2329
|
+
children: [
|
|
2330
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core5.Text, { as: "h4", children: "Grid Settings" }),
|
|
2331
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core5.Panel, { children: [
|
|
2332
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core5.FormField, { labelPlacement: "left", children: [
|
|
2333
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core5.FormFieldLabel, { children: "Format column labels" }),
|
|
2334
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2335
|
+
import_core5.RadioButtonGroup,
|
|
2336
|
+
{
|
|
2337
|
+
"aria-label": "Format column labels",
|
|
2338
|
+
value: config.columnFormatHeader,
|
|
2339
|
+
onChange: handleChangeLabelFormatting,
|
|
2340
|
+
children: [
|
|
2341
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core5.RadioButton, { label: "No Formatting", value: void 0 }),
|
|
2342
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core5.RadioButton, { label: "Capitalize", value: "capitalize" }),
|
|
2343
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core5.RadioButton, { label: "Uppercase", value: "uppercase" })
|
|
2344
|
+
]
|
|
2345
|
+
}
|
|
2346
|
+
)
|
|
2347
|
+
] }),
|
|
2348
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core5.FormField, { labelPlacement: "left", children: [
|
|
2349
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core5.FormFieldLabel, { children: "Default Column Width" }),
|
|
2350
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2351
|
+
import_lab5.StepperInput,
|
|
2352
|
+
{
|
|
2353
|
+
value: (_a = config.columnDefaultWidth) != null ? _a : 100,
|
|
2354
|
+
onChange: handleChangeWidth
|
|
2355
|
+
}
|
|
2356
|
+
)
|
|
2357
|
+
] })
|
|
2358
|
+
] })
|
|
2359
|
+
]
|
|
2360
|
+
}
|
|
2361
|
+
);
|
|
2362
|
+
};
|
|
2363
|
+
|
|
2364
|
+
// src/datagrid-configuration-ui/settings-panel/useGridSettings.ts
|
|
2365
|
+
var import_react10 = require("react");
|
|
2366
|
+
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
2367
|
+
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
2368
|
+
var gridSettingsReducer = (state, action) => {
|
|
2369
|
+
console.log(`gridSettingsReducer ${action.type}`);
|
|
2370
|
+
switch (action.type) {
|
|
2371
|
+
case "addColumn":
|
|
2372
|
+
return addColumn(state, action);
|
|
2373
|
+
case "addCalculatedColumn":
|
|
2374
|
+
return addCalculatedColumn(state, action);
|
|
2375
|
+
case "moveColumn":
|
|
2376
|
+
return moveColumn(state, action);
|
|
2377
|
+
case "removeColumn":
|
|
2378
|
+
return removeColumn(state, action);
|
|
2379
|
+
case "updateColumn":
|
|
2380
|
+
return state;
|
|
2381
|
+
case "updateColumnProp":
|
|
2382
|
+
return updateColumnProp(state, action);
|
|
2383
|
+
case "updateGridSettings":
|
|
2384
|
+
return updateGridSettings(state, action);
|
|
2385
|
+
case "updateColumnTypeFormatting":
|
|
2386
|
+
return updateColumnTypeFormatting(state, action);
|
|
2387
|
+
default:
|
|
2388
|
+
return state;
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
var useGridSettings = (config) => {
|
|
2392
|
+
const [state, dispatchColumnAction] = (0, import_react10.useReducer)(
|
|
2393
|
+
gridSettingsReducer,
|
|
2394
|
+
config
|
|
2395
|
+
);
|
|
2396
|
+
return {
|
|
2397
|
+
gridSettings: state,
|
|
2398
|
+
dispatchColumnAction
|
|
2399
|
+
};
|
|
2400
|
+
};
|
|
2401
|
+
function addColumn(state, { column, columns, index = -1 }) {
|
|
2402
|
+
const { columns: stateColumns } = state;
|
|
2403
|
+
if (index === -1) {
|
|
2404
|
+
if (Array.isArray(columns)) {
|
|
2405
|
+
return { ...state, columns: stateColumns.concat(columns) };
|
|
2406
|
+
} else if (column) {
|
|
2407
|
+
return { ...state, columns: stateColumns.concat(column) };
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
return state;
|
|
2411
|
+
}
|
|
2412
|
+
function addCalculatedColumn(state, { columnName, columnType, expression }) {
|
|
2413
|
+
const { columns: stateColumns } = state;
|
|
2414
|
+
const calculatedColumn = {
|
|
2415
|
+
name: columnName,
|
|
2416
|
+
expression,
|
|
2417
|
+
serverDataType: columnType
|
|
2418
|
+
};
|
|
2419
|
+
return { ...state, columns: stateColumns.concat(calculatedColumn) };
|
|
2420
|
+
}
|
|
2421
|
+
function removeColumn(state, { column }) {
|
|
2422
|
+
const { columns: stateColumns } = state;
|
|
2423
|
+
return {
|
|
2424
|
+
...state,
|
|
2425
|
+
columns: stateColumns.filter((col) => col.name !== column.name)
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2428
|
+
function moveColumn(state, { column, moveBy, moveFrom, moveTo }) {
|
|
2429
|
+
const { columns: stateColumns } = state;
|
|
2430
|
+
if (column && typeof moveBy === "number") {
|
|
2431
|
+
const idx = stateColumns.indexOf(column);
|
|
2432
|
+
const newColumns = stateColumns.slice();
|
|
2433
|
+
const [movedColumns] = newColumns.splice(idx, 1);
|
|
2434
|
+
newColumns.splice(idx + moveBy, 0, movedColumns);
|
|
2435
|
+
return {
|
|
2436
|
+
...state,
|
|
2437
|
+
columns: newColumns
|
|
2438
|
+
};
|
|
2439
|
+
} else if (typeof moveFrom === "number" && typeof moveTo === "number") {
|
|
2440
|
+
return {
|
|
2441
|
+
...state,
|
|
2442
|
+
columns: (0, import_vuu_ui_controls2.moveItem)(stateColumns, moveFrom, moveTo)
|
|
2443
|
+
};
|
|
2444
|
+
} else {
|
|
2445
|
+
return state;
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
function updateColumnProp(state, { align, column, hidden, label, width }) {
|
|
2449
|
+
let { columns: stateColumns } = state;
|
|
2450
|
+
if (align === "left" || align === "right") {
|
|
2451
|
+
stateColumns = replaceColumn(stateColumns, { ...column, align });
|
|
2452
|
+
}
|
|
2453
|
+
if (typeof hidden === "boolean") {
|
|
2454
|
+
stateColumns = replaceColumn(stateColumns, { ...column, hidden });
|
|
2455
|
+
}
|
|
2456
|
+
if (typeof label === "string") {
|
|
2457
|
+
stateColumns = replaceColumn(stateColumns, { ...column, label });
|
|
2458
|
+
}
|
|
2459
|
+
if (typeof width === "number") {
|
|
2460
|
+
stateColumns = replaceColumn(stateColumns, { ...column, width });
|
|
2461
|
+
}
|
|
2462
|
+
return {
|
|
2463
|
+
...state,
|
|
2464
|
+
columns: stateColumns
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
function updateGridSettings(state, { columnFormatHeader }) {
|
|
2468
|
+
return {
|
|
2469
|
+
...state,
|
|
2470
|
+
columnFormatHeader: columnFormatHeader != null ? columnFormatHeader : state.columnFormatHeader
|
|
2471
|
+
};
|
|
2472
|
+
}
|
|
2473
|
+
function updateColumnTypeFormatting(state, {
|
|
2474
|
+
alignOnDecimals,
|
|
2475
|
+
column,
|
|
2476
|
+
decimals,
|
|
2477
|
+
zeroPad
|
|
2478
|
+
}) {
|
|
2479
|
+
const { columns: stateColumns } = state;
|
|
2480
|
+
const targetColumn = stateColumns.find((col) => col.name === column.name);
|
|
2481
|
+
if (targetColumn) {
|
|
2482
|
+
const {
|
|
2483
|
+
serverDataType = "string",
|
|
2484
|
+
type: columnType = (0, import_vuu_utils8.fromServerDataType)(serverDataType)
|
|
2485
|
+
} = column;
|
|
2486
|
+
const type = typeof columnType === "string" ? {
|
|
2487
|
+
name: columnType
|
|
2488
|
+
} : {
|
|
2489
|
+
...columnType
|
|
2490
|
+
};
|
|
2491
|
+
if (typeof alignOnDecimals === "boolean") {
|
|
2492
|
+
type.formatting = {
|
|
2493
|
+
...type.formatting,
|
|
2494
|
+
alignOnDecimals
|
|
2495
|
+
};
|
|
2496
|
+
}
|
|
2497
|
+
if (typeof decimals === "number") {
|
|
2498
|
+
type.formatting = {
|
|
2499
|
+
...type.formatting,
|
|
2500
|
+
decimals
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
if (typeof zeroPad === "boolean") {
|
|
2504
|
+
type.formatting = {
|
|
2505
|
+
...type.formatting,
|
|
2506
|
+
zeroPad
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
return {
|
|
2510
|
+
...state,
|
|
2511
|
+
columns: replaceColumn(stateColumns, { ...column, type })
|
|
2512
|
+
};
|
|
2513
|
+
} else {
|
|
2514
|
+
return state;
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
function replaceColumn(columns, column) {
|
|
2518
|
+
return columns.map((col) => col.name === column.name ? column : col);
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
2522
|
+
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
2523
|
+
|
|
2524
|
+
// src/datagrid-configuration-ui/calculated-column-panel/CalculatedColumnPanel.tsx
|
|
2525
|
+
var import_core6 = require("@salt-ds/core");
|
|
2526
|
+
var import_react11 = require("react");
|
|
2527
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2528
|
+
var CalculatedColumnPanel = ({
|
|
2529
|
+
columns,
|
|
2530
|
+
dispatchColumnAction,
|
|
2531
|
+
table
|
|
2532
|
+
}) => {
|
|
2533
|
+
const [columnName, setColumnName] = (0, import_react11.useState)("");
|
|
2534
|
+
const [, setExpression] = (0, import_react11.useState)();
|
|
2535
|
+
const sourceRef = (0, import_react11.useRef)("");
|
|
2536
|
+
const suggestionProvider = useColumnExpressionSuggestionProvider({
|
|
2537
|
+
columns,
|
|
2538
|
+
table
|
|
2539
|
+
});
|
|
2540
|
+
const handleChangeName = (0, import_react11.useCallback)(
|
|
2541
|
+
(evt) => {
|
|
2542
|
+
const { value } = evt.target;
|
|
2543
|
+
setColumnName(value);
|
|
2544
|
+
},
|
|
2545
|
+
[]
|
|
2546
|
+
);
|
|
2547
|
+
const handleChangeExpression = (0, import_react11.useCallback)((source) => {
|
|
2548
|
+
sourceRef.current = source;
|
|
2549
|
+
}, []);
|
|
2550
|
+
const handleSubmitExpression = (0, import_react11.useCallback)(
|
|
2551
|
+
(source, expression) => {
|
|
2552
|
+
console.log({ source });
|
|
2553
|
+
setExpression(expression);
|
|
2554
|
+
},
|
|
2555
|
+
[]
|
|
2556
|
+
);
|
|
2557
|
+
const handleSave = (0, import_react11.useCallback)(() => {
|
|
2558
|
+
if (sourceRef.current) {
|
|
2559
|
+
console.log(
|
|
2560
|
+
`save expression ${JSON.stringify(sourceRef.current, null, 2)}`
|
|
2561
|
+
);
|
|
2562
|
+
dispatchColumnAction({
|
|
2563
|
+
type: "addCalculatedColumn",
|
|
2564
|
+
columnName,
|
|
2565
|
+
expression: sourceRef.current,
|
|
2566
|
+
columnType: "string"
|
|
2567
|
+
});
|
|
2568
|
+
}
|
|
2569
|
+
}, [columnName, dispatchColumnAction]);
|
|
2570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_core6.Panel, { className: "vuuCalculatedColumnPanel", title: "Define Computed Column", children: [
|
|
2571
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core6.Text, { styleAs: "h4", children: "Define Computed Column" }),
|
|
2572
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_core6.FormField, { labelPlacement: "left", children: [
|
|
2573
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core6.FormFieldLabel, { children: "Column Name" }),
|
|
2574
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core6.Input, { value: columnName, onChange: handleChangeName })
|
|
2575
|
+
] }),
|
|
2576
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2577
|
+
ColumnExpressionInput,
|
|
2578
|
+
{
|
|
2579
|
+
onChange: handleChangeExpression,
|
|
2580
|
+
onSubmitExpression: handleSubmitExpression,
|
|
2581
|
+
suggestionProvider
|
|
2582
|
+
}
|
|
2583
|
+
),
|
|
2584
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core6.Button, { onClick: handleSave, children: "Add Column" }) })
|
|
2585
|
+
] });
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2588
|
+
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
2589
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2590
|
+
var classBase8 = "vuuDatagridSettingsPanel";
|
|
2591
|
+
var getTabLabel = () => void 0;
|
|
2592
|
+
var icons = [
|
|
2593
|
+
"table-settings",
|
|
2594
|
+
"column-chooser",
|
|
2595
|
+
"column-settings",
|
|
2596
|
+
"define-column"
|
|
2597
|
+
];
|
|
2598
|
+
var getTabIcon = (component, tabIndex) => icons[tabIndex];
|
|
2599
|
+
var DatagridSettingsPanel = ({
|
|
2600
|
+
availableColumns,
|
|
2601
|
+
className,
|
|
2602
|
+
gridConfig,
|
|
2603
|
+
onCancel,
|
|
2604
|
+
onConfigChange,
|
|
2605
|
+
...props
|
|
2606
|
+
}) => {
|
|
2607
|
+
var _a;
|
|
2608
|
+
console.log(`DatagridSettingsPanel render`);
|
|
2609
|
+
const [selectedTabIndex, setSelectedTabIndex] = (0, import_react12.useState)(0);
|
|
2610
|
+
const { gridSettings, dispatchColumnAction } = useGridSettings(gridConfig);
|
|
2611
|
+
const [selectedColumnName, setSelectedColumnName] = (0, import_react12.useState)(
|
|
2612
|
+
null
|
|
2613
|
+
);
|
|
2614
|
+
const handleColumnSelected = (0, import_react12.useCallback)(
|
|
2615
|
+
(selected) => {
|
|
2616
|
+
setSelectedColumnName(selected ? selected.name : null);
|
|
2617
|
+
},
|
|
2618
|
+
[]
|
|
2619
|
+
);
|
|
2620
|
+
const handleApply = (0, import_react12.useCallback)(
|
|
2621
|
+
(evt, closePanel = false) => {
|
|
2622
|
+
console.log(`1) DataGridSettingsPanel fire onConfigChange`);
|
|
2623
|
+
onConfigChange == null ? void 0 : onConfigChange(gridSettings, closePanel);
|
|
2624
|
+
},
|
|
2625
|
+
[gridSettings, onConfigChange]
|
|
2626
|
+
);
|
|
2627
|
+
const handleTabSelectionChanged = (0, import_react12.useCallback)((selectedTabIndex2) => {
|
|
2628
|
+
setSelectedTabIndex(selectedTabIndex2);
|
|
2629
|
+
}, []);
|
|
2630
|
+
const handleSave = (0, import_react12.useCallback)(
|
|
2631
|
+
(evt) => handleApply(evt, true),
|
|
2632
|
+
[handleApply]
|
|
2633
|
+
);
|
|
2634
|
+
const selectedColumn = selectedColumnName === null ? null : (_a = gridSettings.columns.find((col) => col.name === selectedColumnName)) != null ? _a : null;
|
|
2635
|
+
const tabstripProps2 = {
|
|
2636
|
+
activeTabIndex: selectedTabIndex,
|
|
2637
|
+
allowRenameTab: false,
|
|
2638
|
+
orientation: "vertical"
|
|
2639
|
+
};
|
|
2640
|
+
const handleAddCalculatedColumn = (0, import_react12.useCallback)(
|
|
2641
|
+
() => setSelectedTabIndex(3),
|
|
2642
|
+
[]
|
|
2643
|
+
);
|
|
2644
|
+
const panelShift = selectedTabIndex === 2 ? "right" : void 0;
|
|
2645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ...props, className: (0, import_classnames6.default)(classBase8, className), children: [
|
|
2646
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2647
|
+
import_vuu_layout2.Stack,
|
|
2648
|
+
{
|
|
2649
|
+
TabstripProps: tabstripProps2,
|
|
2650
|
+
className: `${classBase8}-stack`,
|
|
2651
|
+
getTabIcon,
|
|
2652
|
+
getTabLabel,
|
|
2653
|
+
active: selectedTabIndex === 2 ? 1 : selectedTabIndex,
|
|
2654
|
+
onTabSelectionChanged: handleTabSelectionChanged,
|
|
2655
|
+
children: [
|
|
2656
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2657
|
+
GridSettingsPanel,
|
|
2658
|
+
{
|
|
2659
|
+
config: gridSettings,
|
|
2660
|
+
dispatchColumnAction
|
|
2661
|
+
}
|
|
2662
|
+
),
|
|
2663
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: `${classBase8}-columnPanels`, "data-align": panelShift, children: selectedColumn === null ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core7.Panel, { className: "vuuColumnSettingsPanel", children: "Select a column" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2664
|
+
ColumnSettingsPanel,
|
|
2665
|
+
{
|
|
2666
|
+
column: selectedColumn,
|
|
2667
|
+
dispatchColumnAction,
|
|
2668
|
+
style: { background: "white", flex: "1 0 150px" }
|
|
2669
|
+
}
|
|
2670
|
+
) }),
|
|
2671
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { title: "Column Settings", children: "Column Settings" }),
|
|
2672
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2673
|
+
CalculatedColumnPanel,
|
|
2674
|
+
{
|
|
2675
|
+
columns: gridSettings.columns,
|
|
2676
|
+
dispatchColumnAction,
|
|
2677
|
+
table: { module: "SIMUL", table: "instruments" }
|
|
2678
|
+
}
|
|
2679
|
+
)
|
|
2680
|
+
]
|
|
2681
|
+
}
|
|
2682
|
+
),
|
|
2683
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase8}-buttonBar`, children: [
|
|
2684
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core7.Button, { onClick: onCancel, children: "Cancel" }),
|
|
2685
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core7.Button, { onClick: handleApply, children: "Apply" }),
|
|
2686
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core7.Button, { onClick: handleSave, children: "Save" })
|
|
2687
|
+
] })
|
|
2688
|
+
] });
|
|
2689
|
+
};
|
|
2690
|
+
|
|
2691
|
+
// src/datasource-stats/DatasourceStats.tsx
|
|
2692
|
+
var import_react13 = require("react");
|
|
2693
|
+
var import_classnames7 = __toESM(require("classnames"), 1);
|
|
2694
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2695
|
+
var classBase9 = "vuuDatasourceStats";
|
|
2696
|
+
var numberFormatter = new Intl.NumberFormat();
|
|
2697
|
+
var DataSourceStats = ({
|
|
2698
|
+
className: classNameProp,
|
|
2699
|
+
dataSource
|
|
2700
|
+
}) => {
|
|
2701
|
+
const [range, setRange] = (0, import_react13.useState)(dataSource.range);
|
|
2702
|
+
const [size, setSize] = (0, import_react13.useState)(dataSource.size);
|
|
2703
|
+
(0, import_react13.useEffect)(() => {
|
|
2704
|
+
setSize(dataSource.size);
|
|
2705
|
+
dataSource.on("resize", setSize);
|
|
2706
|
+
dataSource.on("range", setRange);
|
|
2707
|
+
}, [dataSource]);
|
|
2708
|
+
const className = (0, import_classnames7.default)(classBase9, classNameProp);
|
|
2709
|
+
const from = numberFormatter.format(range.from);
|
|
2710
|
+
const to = numberFormatter.format(range.to - 1);
|
|
2711
|
+
const value = numberFormatter.format(size);
|
|
2712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className, children: [
|
|
2713
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "Showing rows" }),
|
|
2714
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: `${classBase9}-range`, children: from }),
|
|
2715
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: `${classBase9}-range`, children: to }),
|
|
2716
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "of" }),
|
|
2717
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: `${classBase9}-size`, children: value })
|
|
2718
|
+
] });
|
|
2719
|
+
};
|
|
2720
|
+
|
|
2721
|
+
// src/table-settings/TableSettingsPanel.tsx
|
|
2722
|
+
var import_core9 = require("@salt-ds/core");
|
|
2723
|
+
|
|
2724
|
+
// src/table-settings/useTableSettings.ts
|
|
2725
|
+
var import_vuu_layout4 = require("@vuu-ui/vuu-layout");
|
|
2726
|
+
|
|
2727
|
+
// ../vuu-table/src/table/ColumnResizer.tsx
|
|
2728
|
+
var import_react14 = require("react");
|
|
2729
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2730
|
+
|
|
2731
|
+
// ../vuu-table/src/table/context-menu/buildContextMenuDescriptors.ts
|
|
2732
|
+
var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
|
|
2733
|
+
|
|
2734
|
+
// ../vuu-table/src/table/context-menu/useTableContextMenu.ts
|
|
2735
|
+
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
2736
|
+
var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
|
|
2737
|
+
var { Average, Count, Distinct, High, Low, Sum } = import_vuu_utils11.AggregationType;
|
|
2738
|
+
|
|
2739
|
+
// ../vuu-table/src/table/Table.tsx
|
|
2740
|
+
var import_vuu_popups4 = require("@vuu-ui/vuu-popups");
|
|
2741
|
+
var import_core8 = require("@salt-ds/core");
|
|
2742
|
+
|
|
2743
|
+
// ../vuu-table/src/table/RowBasedTable.tsx
|
|
2744
|
+
var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
|
|
2745
|
+
var import_react22 = require("react");
|
|
2746
|
+
|
|
2747
|
+
// ../vuu-table/src/table/TableRow.tsx
|
|
2748
|
+
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
2749
|
+
var import_classnames9 = __toESM(require("classnames"));
|
|
2750
|
+
var import_react17 = require("react");
|
|
2751
|
+
|
|
2752
|
+
// ../vuu-table/src/table/TableCell.tsx
|
|
2753
|
+
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
2754
|
+
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
2755
|
+
var import_classnames8 = __toESM(require("classnames"));
|
|
2756
|
+
var import_react15 = require("react");
|
|
2757
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2758
|
+
var { KEY: KEY2 } = import_vuu_utils12.metadataKeys;
|
|
2759
|
+
var TableCell = (0, import_react15.memo)(
|
|
2760
|
+
({
|
|
2761
|
+
className: classNameProp,
|
|
2762
|
+
column,
|
|
2763
|
+
columnMap,
|
|
2764
|
+
onClick,
|
|
2765
|
+
row
|
|
2766
|
+
}) => {
|
|
2767
|
+
const labelFieldRef = (0, import_react15.useRef)(null);
|
|
2768
|
+
const {
|
|
2769
|
+
align,
|
|
2770
|
+
CellRenderer,
|
|
2771
|
+
key,
|
|
2772
|
+
pin,
|
|
2773
|
+
editable,
|
|
2774
|
+
resizing,
|
|
2775
|
+
valueFormatter
|
|
2776
|
+
} = column;
|
|
2777
|
+
const [editing, setEditing] = (0, import_react15.useState)(false);
|
|
2778
|
+
const value = valueFormatter(row[key]);
|
|
2779
|
+
const [editableValue, setEditableValue] = (0, import_react15.useState)(value);
|
|
2780
|
+
const handleTitleMouseDown = () => {
|
|
2781
|
+
var _a;
|
|
2782
|
+
(_a = labelFieldRef.current) == null ? void 0 : _a.focus();
|
|
2783
|
+
};
|
|
2784
|
+
const handleTitleKeyDown = (evt) => {
|
|
2785
|
+
if (evt.key === "Enter") {
|
|
2786
|
+
setEditing(true);
|
|
2787
|
+
}
|
|
2788
|
+
};
|
|
2789
|
+
const handleClick = (0, import_react15.useCallback)(
|
|
2790
|
+
(evt) => {
|
|
2791
|
+
onClick == null ? void 0 : onClick(evt, column);
|
|
2792
|
+
},
|
|
2793
|
+
[column, onClick]
|
|
2794
|
+
);
|
|
2795
|
+
const handleEnterEditMode = () => {
|
|
2796
|
+
setEditing(true);
|
|
2797
|
+
};
|
|
2798
|
+
const handleExitEditMode = (originalValue = "", finalValue = "", allowDeactivation = true, editCancelled = false) => {
|
|
2799
|
+
var _a;
|
|
2800
|
+
setEditing(false);
|
|
2801
|
+
if (editCancelled) {
|
|
2802
|
+
setEditableValue(originalValue);
|
|
2803
|
+
} else if (finalValue !== originalValue) {
|
|
2804
|
+
setEditableValue(finalValue);
|
|
2805
|
+
}
|
|
2806
|
+
if (allowDeactivation === false) {
|
|
2807
|
+
(_a = labelFieldRef.current) == null ? void 0 : _a.focus();
|
|
2808
|
+
}
|
|
2809
|
+
};
|
|
2810
|
+
const className = (0, import_classnames8.default)(classNameProp, {
|
|
2811
|
+
vuuAlignRight: align === "right",
|
|
2812
|
+
vuuPinFloating: pin === "floating",
|
|
2813
|
+
vuuPinLeft: pin === "left",
|
|
2814
|
+
vuuPinRight: pin === "right",
|
|
2815
|
+
"vuuTableCell-resizing": resizing
|
|
2816
|
+
}) || void 0;
|
|
2817
|
+
const style = (0, import_vuu_utils12.getColumnStyle)(column);
|
|
2818
|
+
return editable ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2819
|
+
"div",
|
|
2820
|
+
{
|
|
2821
|
+
className,
|
|
2822
|
+
"data-editable": true,
|
|
2823
|
+
role: "cell",
|
|
2824
|
+
style,
|
|
2825
|
+
onKeyDown: handleTitleKeyDown,
|
|
2826
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2827
|
+
import_vuu_ui_controls3.EditableLabel,
|
|
2828
|
+
{
|
|
2829
|
+
editing,
|
|
2830
|
+
value: editableValue,
|
|
2831
|
+
onChange: setEditableValue,
|
|
2832
|
+
onMouseDownCapture: handleTitleMouseDown,
|
|
2833
|
+
onEnterEditMode: handleEnterEditMode,
|
|
2834
|
+
onExitEditMode: handleExitEditMode,
|
|
2835
|
+
onKeyDown: handleTitleKeyDown,
|
|
2836
|
+
ref: labelFieldRef,
|
|
2837
|
+
tabIndex: 0
|
|
2838
|
+
},
|
|
2839
|
+
"title"
|
|
2840
|
+
)
|
|
2841
|
+
}
|
|
2842
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2843
|
+
"div",
|
|
2844
|
+
{
|
|
2845
|
+
className,
|
|
2846
|
+
role: "cell",
|
|
2847
|
+
style,
|
|
2848
|
+
onClick: handleClick,
|
|
2849
|
+
children: CellRenderer ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CellRenderer, { column, columnMap, row }) : value
|
|
2850
|
+
}
|
|
2851
|
+
);
|
|
2852
|
+
},
|
|
2853
|
+
cellValuesAreEqual
|
|
2854
|
+
);
|
|
2855
|
+
TableCell.displayName = "TableCell";
|
|
2856
|
+
function cellValuesAreEqual(prev, next) {
|
|
2857
|
+
return prev.column === next.column && prev.onClick === next.onClick && prev.row[KEY2] === next.row[KEY2] && prev.row[prev.column.key] === next.row[next.column.key];
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
// ../vuu-table/src/table/TableGroupCell.tsx
|
|
2861
|
+
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
2862
|
+
var import_react16 = require("react");
|
|
2863
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2864
|
+
var { IS_LEAF } = import_vuu_utils13.metadataKeys;
|
|
2865
|
+
var TableGroupCell = ({ column, onClick, row }) => {
|
|
2866
|
+
const { columns } = column;
|
|
2867
|
+
const [value, offset] = (0, import_vuu_utils13.getGroupValueAndOffset)(columns, row);
|
|
2868
|
+
const handleClick = (0, import_react16.useCallback)(
|
|
2869
|
+
(evt) => {
|
|
2870
|
+
onClick == null ? void 0 : onClick(evt, column);
|
|
2871
|
+
},
|
|
2872
|
+
[column, onClick]
|
|
2873
|
+
);
|
|
2874
|
+
const style = (0, import_vuu_utils13.getColumnStyle)(column);
|
|
2875
|
+
const isLeaf = row[IS_LEAF];
|
|
2876
|
+
const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "vuuTableGroupCell-spacer" }, i));
|
|
2877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2878
|
+
"div",
|
|
2879
|
+
{
|
|
2880
|
+
className: "vuuTableGroupCell vuuPinLeft",
|
|
2881
|
+
onClick: isLeaf ? void 0 : handleClick,
|
|
2882
|
+
role: "cell",
|
|
2883
|
+
style,
|
|
2884
|
+
children: [
|
|
2885
|
+
spacers,
|
|
2886
|
+
isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "vuuTableGroupCell-toggle", "data-icon": "triangle-right" }),
|
|
2887
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: value })
|
|
2888
|
+
]
|
|
2889
|
+
}
|
|
2890
|
+
);
|
|
2891
|
+
};
|
|
2892
|
+
|
|
2893
|
+
// ../vuu-table/src/table/TableRow.tsx
|
|
2894
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2895
|
+
var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils14.metadataKeys;
|
|
2896
|
+
var classBase10 = "vuuTableRow";
|
|
2897
|
+
var TableRow = (0, import_react17.memo)(function Row({
|
|
2898
|
+
columnMap,
|
|
2899
|
+
columns,
|
|
2900
|
+
offset,
|
|
2901
|
+
onClick,
|
|
2902
|
+
onToggleGroup,
|
|
2903
|
+
virtualColSpan = 0,
|
|
2904
|
+
row
|
|
2905
|
+
}) {
|
|
2906
|
+
const {
|
|
2907
|
+
[IDX]: rowIndex,
|
|
2908
|
+
[IS_EXPANDED]: isExpanded,
|
|
2909
|
+
[SELECTED]: isSelected
|
|
2910
|
+
} = row;
|
|
2911
|
+
const className = (0, import_classnames9.default)(classBase10, {
|
|
2912
|
+
[`${classBase10}-even`]: rowIndex % 2 === 0,
|
|
2913
|
+
[`${classBase10}-expanded`]: isExpanded,
|
|
2914
|
+
[`${classBase10}-preSelected`]: isSelected === 2
|
|
2915
|
+
});
|
|
2916
|
+
const handleRowClick = (0, import_react17.useCallback)(
|
|
2917
|
+
(evt) => {
|
|
2918
|
+
const rangeSelect = evt.shiftKey;
|
|
2919
|
+
const keepExistingSelection = evt.ctrlKey || evt.metaKey;
|
|
2920
|
+
onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
|
|
2921
|
+
},
|
|
2922
|
+
[onClick, row]
|
|
2923
|
+
);
|
|
2924
|
+
const handleGroupCellClick = (0, import_react17.useCallback)(
|
|
2925
|
+
(evt, column) => {
|
|
2926
|
+
if ((0, import_vuu_utils14.isGroupColumn)(column) || (0, import_vuu_utils14.isJsonGroup)(column, row)) {
|
|
2927
|
+
evt.stopPropagation();
|
|
2928
|
+
onToggleGroup == null ? void 0 : onToggleGroup(row, column);
|
|
2929
|
+
}
|
|
2930
|
+
},
|
|
2931
|
+
[onToggleGroup, row]
|
|
2932
|
+
);
|
|
2933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2934
|
+
"div",
|
|
2935
|
+
{
|
|
2936
|
+
"aria-selected": isSelected === 1 ? true : void 0,
|
|
2937
|
+
"aria-rowindex": rowIndex,
|
|
2938
|
+
className,
|
|
2939
|
+
onClick: handleRowClick,
|
|
2940
|
+
role: "row",
|
|
2941
|
+
style: {
|
|
2942
|
+
transform: `translate3d(0px, ${offset}px, 0px)`
|
|
2943
|
+
},
|
|
2944
|
+
children: [
|
|
2945
|
+
virtualColSpan > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { role: "cell", style: { width: virtualColSpan } }) : null,
|
|
2946
|
+
columns.filter(import_vuu_utils14.notHidden).map((column) => {
|
|
2947
|
+
const isGroup = (0, import_vuu_utils14.isGroupColumn)(column);
|
|
2948
|
+
const isJsonCell = (0, import_vuu_utils14.isJsonColumn)(column);
|
|
2949
|
+
const Cell = isGroup ? TableGroupCell : TableCell;
|
|
2950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2951
|
+
Cell,
|
|
2952
|
+
{
|
|
2953
|
+
column,
|
|
2954
|
+
columnMap,
|
|
2955
|
+
onClick: isGroup || isJsonCell ? handleGroupCellClick : void 0,
|
|
2956
|
+
row
|
|
2957
|
+
},
|
|
2958
|
+
column.name
|
|
2959
|
+
);
|
|
2960
|
+
})
|
|
2961
|
+
]
|
|
2962
|
+
}
|
|
2963
|
+
);
|
|
2964
|
+
});
|
|
2965
|
+
|
|
2966
|
+
// ../vuu-table/src/table/TableGroupHeaderCell.tsx
|
|
2967
|
+
var import_classnames10 = __toESM(require("classnames"));
|
|
2968
|
+
var import_react19 = require("react");
|
|
2969
|
+
|
|
2970
|
+
// ../vuu-table/src/table/useTableColumnResize.tsx
|
|
2971
|
+
var import_react18 = require("react");
|
|
2972
|
+
|
|
2973
|
+
// ../vuu-table/src/table/TableGroupHeaderCell.tsx
|
|
2974
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2975
|
+
|
|
2976
|
+
// ../vuu-table/src/table/TableHeaderCell.tsx
|
|
2977
|
+
var import_classnames13 = __toESM(require("classnames"));
|
|
2978
|
+
var import_react21 = require("react");
|
|
2979
|
+
|
|
2980
|
+
// ../vuu-table/src/table/SortIndicator.tsx
|
|
2981
|
+
var import_classnames11 = __toESM(require("classnames"));
|
|
2982
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2983
|
+
|
|
2984
|
+
// ../vuu-table/src/table/TableHeaderCell.tsx
|
|
2985
|
+
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
2986
|
+
|
|
2987
|
+
// ../vuu-table/src/table/filter-indicator.tsx
|
|
2988
|
+
var import_vuu_popups = require("@vuu-ui/vuu-popups");
|
|
2989
|
+
var import_classnames12 = __toESM(require("classnames"));
|
|
2990
|
+
var import_react20 = require("react");
|
|
2991
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2992
|
+
|
|
2993
|
+
// ../vuu-table/src/table/TableHeaderCell.tsx
|
|
2994
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2995
|
+
|
|
2996
|
+
// ../vuu-table/src/table/RowBasedTable.tsx
|
|
2997
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2998
|
+
var { RENDER_IDX } = import_vuu_utils15.metadataKeys;
|
|
2999
|
+
|
|
3000
|
+
// ../vuu-table/src/table/useTable.ts
|
|
3001
|
+
var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
|
|
3002
|
+
var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
|
|
3003
|
+
var import_react33 = require("react");
|
|
3004
|
+
|
|
3005
|
+
// ../vuu-table/src/table/useDataSource.ts
|
|
3006
|
+
var import_vuu_data_react2 = require("@vuu-ui/vuu-data-react");
|
|
3007
|
+
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
3008
|
+
var import_react23 = require("react");
|
|
3009
|
+
var { SELECTED: SELECTED2 } = import_vuu_utils16.metadataKeys;
|
|
3010
|
+
|
|
3011
|
+
// ../vuu-table/src/table/useDraggableColumn.ts
|
|
3012
|
+
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
3013
|
+
var import_react24 = require("react");
|
|
3014
|
+
|
|
3015
|
+
// ../vuu-table/src/table/useKeyboardNavigation.ts
|
|
3016
|
+
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
3017
|
+
var import_react25 = require("react");
|
|
3018
|
+
|
|
3019
|
+
// ../vuu-table/src/table/keyUtils.ts
|
|
3020
|
+
function union(set1, ...sets) {
|
|
3021
|
+
const result = new Set(set1);
|
|
3022
|
+
for (let set of sets) {
|
|
3023
|
+
for (let element of set) {
|
|
3024
|
+
result.add(element);
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
return result;
|
|
3028
|
+
}
|
|
3029
|
+
var ArrowUp = "ArrowUp";
|
|
3030
|
+
var ArrowDown = "ArrowDown";
|
|
3031
|
+
var ArrowLeft = "ArrowLeft";
|
|
3032
|
+
var ArrowRight = "ArrowRight";
|
|
3033
|
+
var Home = "Home";
|
|
3034
|
+
var End = "End";
|
|
3035
|
+
var PageUp = "PageUp";
|
|
3036
|
+
var PageDown = "PageDown";
|
|
3037
|
+
var actionKeys = /* @__PURE__ */ new Set(["Enter", "Delete", " "]);
|
|
3038
|
+
var focusKeys = /* @__PURE__ */ new Set(["Tab"]);
|
|
3039
|
+
var arrowLeftRightKeys = /* @__PURE__ */ new Set(["ArrowRight", "ArrowLeft"]);
|
|
3040
|
+
var navigationKeys = /* @__PURE__ */ new Set([
|
|
3041
|
+
Home,
|
|
3042
|
+
End,
|
|
3043
|
+
PageUp,
|
|
3044
|
+
PageDown,
|
|
3045
|
+
ArrowDown,
|
|
3046
|
+
ArrowLeft,
|
|
3047
|
+
ArrowRight,
|
|
3048
|
+
ArrowUp
|
|
3049
|
+
]);
|
|
3050
|
+
var functionKeys = /* @__PURE__ */ new Set([
|
|
3051
|
+
"F1",
|
|
3052
|
+
"F2",
|
|
3053
|
+
"F3",
|
|
3054
|
+
"F4",
|
|
3055
|
+
"F5",
|
|
3056
|
+
"F6",
|
|
3057
|
+
"F7",
|
|
3058
|
+
"F8",
|
|
3059
|
+
"F9",
|
|
3060
|
+
"F10",
|
|
3061
|
+
"F11",
|
|
3062
|
+
"F12"
|
|
3063
|
+
]);
|
|
3064
|
+
var specialKeys = union(
|
|
3065
|
+
actionKeys,
|
|
3066
|
+
navigationKeys,
|
|
3067
|
+
arrowLeftRightKeys,
|
|
3068
|
+
functionKeys,
|
|
3069
|
+
focusKeys
|
|
3070
|
+
);
|
|
3071
|
+
|
|
3072
|
+
// ../vuu-table/src/table/useMeasuredContainer.ts
|
|
3073
|
+
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
3074
|
+
var import_react27 = require("react");
|
|
3075
|
+
|
|
3076
|
+
// ../vuu-table/src/table/useResizeObserver.ts
|
|
3077
|
+
var import_react26 = require("react");
|
|
3078
|
+
var observedMap = /* @__PURE__ */ new Map();
|
|
3079
|
+
var getTargetSize = (element, size, dimension) => {
|
|
3080
|
+
switch (dimension) {
|
|
3081
|
+
case "height":
|
|
3082
|
+
return size.height;
|
|
3083
|
+
case "clientHeight":
|
|
3084
|
+
return element.clientHeight;
|
|
3085
|
+
case "clientWidth":
|
|
3086
|
+
return element.clientWidth;
|
|
3087
|
+
case "contentHeight":
|
|
3088
|
+
return size.contentHeight;
|
|
3089
|
+
case "contentWidth":
|
|
3090
|
+
return size.contentWidth;
|
|
3091
|
+
case "scrollHeight":
|
|
3092
|
+
return Math.ceil(element.scrollHeight);
|
|
3093
|
+
case "scrollWidth":
|
|
3094
|
+
return Math.ceil(element.scrollWidth);
|
|
3095
|
+
case "width":
|
|
3096
|
+
return size.width;
|
|
3097
|
+
default:
|
|
3098
|
+
return 0;
|
|
3099
|
+
}
|
|
3100
|
+
};
|
|
3101
|
+
var resizeObserver = new ResizeObserver((entries) => {
|
|
3102
|
+
for (const entry of entries) {
|
|
3103
|
+
const { target, borderBoxSize, contentBoxSize } = entry;
|
|
3104
|
+
const observedTarget = observedMap.get(target);
|
|
3105
|
+
if (observedTarget) {
|
|
3106
|
+
const [{ blockSize: height, inlineSize: width }] = borderBoxSize;
|
|
3107
|
+
const [{ blockSize: contentHeight, inlineSize: contentWidth }] = contentBoxSize;
|
|
3108
|
+
const { onResize, measurements } = observedTarget;
|
|
3109
|
+
let sizeChanged = false;
|
|
3110
|
+
for (const [dimension, size] of Object.entries(measurements)) {
|
|
3111
|
+
const newSize = getTargetSize(
|
|
3112
|
+
target,
|
|
3113
|
+
{ height, width, contentHeight, contentWidth },
|
|
3114
|
+
dimension
|
|
3115
|
+
);
|
|
3116
|
+
if (newSize !== size) {
|
|
3117
|
+
sizeChanged = true;
|
|
3118
|
+
measurements[dimension] = newSize;
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
if (sizeChanged) {
|
|
3122
|
+
onResize && onResize(measurements);
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
|
|
3128
|
+
// ../vuu-table/src/table/useSelection.ts
|
|
3129
|
+
var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
|
|
3130
|
+
var import_react28 = require("react");
|
|
3131
|
+
var { IDX: IDX2 } = import_vuu_utils19.metadataKeys;
|
|
3132
|
+
|
|
3133
|
+
// ../vuu-table/src/table/useTableModel.ts
|
|
3134
|
+
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
3135
|
+
var import_react29 = require("react");
|
|
3136
|
+
var KEY_OFFSET = import_vuu_utils20.metadataKeys.count;
|
|
3137
|
+
|
|
3138
|
+
// ../vuu-table/src/table/useTableScroll.ts
|
|
3139
|
+
var import_react30 = require("react");
|
|
3140
|
+
|
|
3141
|
+
// ../vuu-table/src/table/useTableViewport.ts
|
|
3142
|
+
var import_react31 = require("react");
|
|
3143
|
+
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
3144
|
+
|
|
3145
|
+
// ../vuu-table/src/table/useVirtualViewport.ts
|
|
3146
|
+
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
3147
|
+
var import_react32 = require("react");
|
|
3148
|
+
|
|
3149
|
+
// ../vuu-table/src/table/useTable.ts
|
|
3150
|
+
var { KEY: KEY3, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils23.metadataKeys;
|
|
3151
|
+
|
|
3152
|
+
// ../vuu-table/src/table/Table.tsx
|
|
3153
|
+
var import_classnames14 = __toESM(require("classnames"));
|
|
3154
|
+
var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
|
|
3155
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3156
|
+
|
|
3157
|
+
// ../vuu-table/src/table/cell-renderers/json-cell/JsonCell.tsx
|
|
3158
|
+
var import_classnames15 = __toESM(require("classnames"));
|
|
3159
|
+
var import_vuu_utils25 = require("@vuu-ui/vuu-utils");
|
|
3160
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3161
|
+
var classBase11 = "vuuJsonCell";
|
|
3162
|
+
var { IS_EXPANDED: IS_EXPANDED3, KEY: KEY4 } = import_vuu_utils25.metadataKeys;
|
|
3163
|
+
var localKey = (key) => {
|
|
3164
|
+
const pos = key.lastIndexOf("|");
|
|
3165
|
+
if (pos === -1) {
|
|
3166
|
+
return "";
|
|
3167
|
+
} else {
|
|
3168
|
+
return key.slice(pos + 1);
|
|
3169
|
+
}
|
|
3170
|
+
};
|
|
3171
|
+
var JsonCell = ({ column, row }) => {
|
|
3172
|
+
const {
|
|
3173
|
+
key: columnKey
|
|
3174
|
+
/*, type, valueFormatter */
|
|
3175
|
+
} = column;
|
|
3176
|
+
let value = row[columnKey];
|
|
3177
|
+
let isToggle = false;
|
|
3178
|
+
if ((0, import_vuu_utils25.isJsonAttribute)(value)) {
|
|
3179
|
+
value = value.slice(0, -1);
|
|
3180
|
+
isToggle = true;
|
|
3181
|
+
}
|
|
3182
|
+
const rowKey = localKey(row[KEY4]);
|
|
3183
|
+
const className = (0, import_classnames15.default)({
|
|
3184
|
+
[`${classBase11}-name`]: rowKey === value,
|
|
3185
|
+
[`${classBase11}-value`]: rowKey !== value,
|
|
3186
|
+
[`${classBase11}-group`]: isToggle
|
|
3187
|
+
});
|
|
3188
|
+
if (isToggle) {
|
|
3189
|
+
const toggleIcon = row[IS_EXPANDED3] ? "minus-box" : "plus-box";
|
|
3190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className, children: [
|
|
3191
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: `${classBase11}-value`, children: value }),
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: `${classBase11}-toggle`, "data-icon": toggleIcon })
|
|
3193
|
+
] });
|
|
3194
|
+
} else if (value) {
|
|
3195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className, children: value });
|
|
3196
|
+
} else {
|
|
3197
|
+
return null;
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
(0, import_vuu_utils25.registerComponent)("json", JsonCell, "cell-renderer", {});
|
|
3201
|
+
|
|
3202
|
+
// ../vuu-table/src/table-next/TableNext.tsx
|
|
3203
|
+
var import_vuu_popups7 = require("@vuu-ui/vuu-popups");
|
|
3204
|
+
var import_vuu_utils31 = require("@vuu-ui/vuu-utils");
|
|
3205
|
+
|
|
3206
|
+
// ../vuu-table/src/table-next/HeaderCell.tsx
|
|
3207
|
+
var import_react38 = require("react");
|
|
3208
|
+
|
|
3209
|
+
// ../vuu-table/src/table-next/useCell.ts
|
|
3210
|
+
var import_vuu_utils26 = require("@vuu-ui/vuu-utils");
|
|
3211
|
+
var import_classnames16 = __toESM(require("classnames"));
|
|
3212
|
+
var import_react34 = require("react");
|
|
3213
|
+
var useCell = (column, classBase14, isHeader) => (
|
|
3214
|
+
// TODO measure perf without the memo, might not be worth the cost
|
|
3215
|
+
(0, import_react34.useMemo)(() => {
|
|
3216
|
+
const className = (0, import_classnames16.default)(classBase14, {
|
|
3217
|
+
vuuPinFloating: column.pin === "floating",
|
|
3218
|
+
vuuPinLeft: column.pin === "left",
|
|
3219
|
+
vuuPinRight: column.pin === "right",
|
|
3220
|
+
vuuEndPin: isHeader && column.endPin,
|
|
3221
|
+
[`${classBase14}-resizing`]: column.resizing,
|
|
3222
|
+
[`${classBase14}-right`]: column.align === "right"
|
|
3223
|
+
});
|
|
3224
|
+
const style = (0, import_vuu_utils26.getColumnStyle)(column);
|
|
3225
|
+
return {
|
|
3226
|
+
className,
|
|
3227
|
+
style
|
|
3228
|
+
};
|
|
3229
|
+
}, [column, classBase14, isHeader])
|
|
3230
|
+
);
|
|
3231
|
+
|
|
3232
|
+
// ../vuu-table/src/table-next/ColumnMenu.tsx
|
|
3233
|
+
var import_vuu_popups5 = require("@vuu-ui/vuu-popups");
|
|
3234
|
+
var import_classnames17 = __toESM(require("classnames"));
|
|
3235
|
+
var import_react35 = require("react");
|
|
3236
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3237
|
+
|
|
3238
|
+
// ../vuu-table/src/table-next/column-resizing/ColumnResizer.tsx
|
|
3239
|
+
var import_react36 = require("react");
|
|
3240
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3241
|
+
|
|
3242
|
+
// ../vuu-table/src/table-next/column-resizing/useTableColumnResize.tsx
|
|
3243
|
+
var import_react37 = require("react");
|
|
3244
|
+
|
|
3245
|
+
// ../vuu-table/src/table-next/HeaderCell.tsx
|
|
3246
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3247
|
+
|
|
3248
|
+
// ../vuu-table/src/table-next/Row.tsx
|
|
3249
|
+
var import_vuu_utils28 = require("@vuu-ui/vuu-utils");
|
|
3250
|
+
var import_classnames18 = __toESM(require("classnames"));
|
|
3251
|
+
var import_react40 = require("react");
|
|
3252
|
+
|
|
3253
|
+
// ../vuu-table/src/table-next/TableCell.tsx
|
|
3254
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3255
|
+
var TableCell2 = ({ column, row }) => {
|
|
3256
|
+
const { className, style } = useCell(column, "vuuTableNextCell");
|
|
3257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className, role: "cell", style, children: row[column.key] });
|
|
3258
|
+
};
|
|
3259
|
+
|
|
3260
|
+
// ../vuu-table/src/table-next/TableGroupCell.tsx
|
|
3261
|
+
var import_vuu_utils27 = require("@vuu-ui/vuu-utils");
|
|
3262
|
+
var import_react39 = require("react");
|
|
3263
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3264
|
+
var { IS_LEAF: IS_LEAF3 } = import_vuu_utils27.metadataKeys;
|
|
3265
|
+
var TableGroupCell2 = ({ column, onClick, row }) => {
|
|
3266
|
+
const { columns } = column;
|
|
3267
|
+
const [value, offset] = (0, import_vuu_utils27.getGroupValueAndOffset)(columns, row);
|
|
3268
|
+
const { className, style } = useCell(column, "vuuTable2-groupCell");
|
|
3269
|
+
const handleClick = (0, import_react39.useCallback)(
|
|
3270
|
+
(evt) => {
|
|
3271
|
+
onClick == null ? void 0 : onClick(evt, column);
|
|
3272
|
+
},
|
|
3273
|
+
[column, onClick]
|
|
3274
|
+
);
|
|
3275
|
+
const isLeaf = row[IS_LEAF3];
|
|
3276
|
+
const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "vuuTable2-groupCell-spacer" }, i));
|
|
3277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3278
|
+
"div",
|
|
3279
|
+
{
|
|
3280
|
+
className,
|
|
3281
|
+
role: "cell",
|
|
3282
|
+
style,
|
|
3283
|
+
onClick: isLeaf ? void 0 : handleClick,
|
|
3284
|
+
children: [
|
|
3285
|
+
spacers,
|
|
3286
|
+
isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3287
|
+
"span",
|
|
3288
|
+
{
|
|
3289
|
+
className: "vuuTable2-groupCell-toggle",
|
|
3290
|
+
"data-icon": "vuu-triangle-right"
|
|
3291
|
+
}
|
|
3292
|
+
),
|
|
3293
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: value })
|
|
3294
|
+
]
|
|
3295
|
+
}
|
|
3296
|
+
);
|
|
3297
|
+
};
|
|
3298
|
+
|
|
3299
|
+
// ../vuu-table/src/table-next/Row.tsx
|
|
3300
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3301
|
+
var import_react41 = require("react");
|
|
3302
|
+
var { IDX: IDX3, IS_EXPANDED: IS_EXPANDED4, SELECTED: SELECTED3 } = import_vuu_utils28.metadataKeys;
|
|
3303
|
+
var classBase12 = "vuuTableNextRow";
|
|
3304
|
+
var Row2 = (0, import_react40.memo)(
|
|
3305
|
+
({
|
|
3306
|
+
className: classNameProp,
|
|
3307
|
+
columnMap,
|
|
3308
|
+
columns,
|
|
3309
|
+
row,
|
|
3310
|
+
offset,
|
|
3311
|
+
onClick,
|
|
3312
|
+
onToggleGroup,
|
|
3313
|
+
...htmlAttributes
|
|
3314
|
+
}) => {
|
|
3315
|
+
const {
|
|
3316
|
+
[IDX3]: rowIndex,
|
|
3317
|
+
[IS_EXPANDED4]: isExpanded,
|
|
3318
|
+
[SELECTED3]: selectionStatus
|
|
3319
|
+
} = row;
|
|
3320
|
+
const handleRowClick = (0, import_react40.useCallback)(
|
|
3321
|
+
(evt) => {
|
|
3322
|
+
const rangeSelect = evt.shiftKey;
|
|
3323
|
+
const keepExistingSelection = evt.ctrlKey || evt.metaKey;
|
|
3324
|
+
onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
|
|
3325
|
+
},
|
|
3326
|
+
[onClick, row]
|
|
3327
|
+
);
|
|
3328
|
+
const { True, First, Last } = import_vuu_utils28.RowSelected;
|
|
3329
|
+
const className = (0, import_classnames18.default)(classBase12, classNameProp, {
|
|
3330
|
+
[`${classBase12}-even`]: rowIndex % 2 === 0,
|
|
3331
|
+
[`${classBase12}-expanded`]: isExpanded,
|
|
3332
|
+
[`${classBase12}-selected`]: selectionStatus & True,
|
|
3333
|
+
[`${classBase12}-selectedStart`]: selectionStatus & First,
|
|
3334
|
+
[`${classBase12}-selectedEnd`]: selectionStatus & Last
|
|
3335
|
+
});
|
|
3336
|
+
const style = typeof offset === "number" ? { transform: `translate3d(0px, ${offset}px, 0px)` } : void 0;
|
|
3337
|
+
return /* @__PURE__ */ (0, import_react41.createElement)(
|
|
3338
|
+
"div",
|
|
3339
|
+
{
|
|
3340
|
+
...htmlAttributes,
|
|
3341
|
+
key: `row-${row[0]}`,
|
|
3342
|
+
role: "row",
|
|
3343
|
+
className,
|
|
3344
|
+
onClick: handleRowClick,
|
|
3345
|
+
style
|
|
3346
|
+
},
|
|
3347
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: `${classBase12}-selectionDecorator vuuStickyLeft` }),
|
|
3348
|
+
columns.filter(import_vuu_utils28.notHidden).map((column) => {
|
|
3349
|
+
const isGroup = (0, import_vuu_utils28.isGroupColumn)(column);
|
|
3350
|
+
const Cell = isGroup ? TableGroupCell2 : TableCell2;
|
|
3351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Cell, { column, row }, column.key);
|
|
3352
|
+
}),
|
|
3353
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: `${classBase12}-selectionDecorator vuuStickyRight` })
|
|
3354
|
+
);
|
|
3355
|
+
}
|
|
3356
|
+
);
|
|
3357
|
+
Row2.displayName = "Row";
|
|
3358
|
+
|
|
3359
|
+
// ../vuu-table/src/table-next/useTableNext.ts
|
|
3360
|
+
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
3361
|
+
var import_vuu_popups6 = require("@vuu-ui/vuu-popups");
|
|
3362
|
+
var import_vuu_utils30 = require("@vuu-ui/vuu-utils");
|
|
3363
|
+
var import_react47 = require("react");
|
|
3364
|
+
|
|
3365
|
+
// ../vuu-table/src/table-next/table-config.ts
|
|
3366
|
+
var updateTableConfig = (config, action) => {
|
|
3367
|
+
switch (action.type) {
|
|
3368
|
+
case "col-size":
|
|
3369
|
+
return {
|
|
3370
|
+
...config,
|
|
3371
|
+
columns: config.columns.map(
|
|
3372
|
+
(col) => col.name === action.column.name ? { ...col, width: action.width } : col
|
|
3373
|
+
)
|
|
3374
|
+
};
|
|
3375
|
+
case "column-prop":
|
|
3376
|
+
return {
|
|
3377
|
+
...config,
|
|
3378
|
+
columns: config.columns.map(
|
|
3379
|
+
(col) => col.name === action.column.name ? { ...col, [action.property]: action.value } : col
|
|
3380
|
+
)
|
|
3381
|
+
};
|
|
3382
|
+
default:
|
|
3383
|
+
return config;
|
|
3384
|
+
}
|
|
3385
|
+
};
|
|
3386
|
+
|
|
3387
|
+
// ../vuu-table/src/table-next/useDataSource.ts
|
|
3388
|
+
var import_react42 = require("react");
|
|
3389
|
+
|
|
3390
|
+
// ../vuu-table/src/table-next/useInitialValue.ts
|
|
3391
|
+
var import_react43 = require("react");
|
|
3392
|
+
|
|
3393
|
+
// ../vuu-table/src/table-next/useTableModel.ts
|
|
3394
|
+
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
3395
|
+
var import_vuu_utils29 = require("@vuu-ui/vuu-utils");
|
|
3396
|
+
var import_react44 = require("react");
|
|
3397
|
+
var { info } = (0, import_vuu_utils29.logger)("useTableModel");
|
|
3398
|
+
var KEY_OFFSET2 = import_vuu_utils29.metadataKeys.count;
|
|
3399
|
+
|
|
3400
|
+
// ../vuu-table/src/table-next/useTableScroll.ts
|
|
3401
|
+
var import_react45 = require("react");
|
|
3402
|
+
|
|
3403
|
+
// ../vuu-table/src/table-next/useVirtualViewport.ts
|
|
3404
|
+
var import_react46 = require("react");
|
|
3405
|
+
|
|
3406
|
+
// ../vuu-table/src/table-next/TableNext.tsx
|
|
3407
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3408
|
+
var { IDX: IDX4, RENDER_IDX: RENDER_IDX2 } = import_vuu_utils31.metadataKeys;
|
|
3409
|
+
|
|
3410
|
+
// src/table-settings/useTableSettings.ts
|
|
3411
|
+
var import_react48 = require("react");
|
|
3412
|
+
var buildColumnItems = (availableColumns, configuredColumns) => {
|
|
3413
|
+
return availableColumns.map(({ name, serverDataType }) => {
|
|
3414
|
+
const configuredColumn = configuredColumns.find((col) => col.name === name);
|
|
3415
|
+
return {
|
|
3416
|
+
hidden: configuredColumn == null ? void 0 : configuredColumn.hidden,
|
|
3417
|
+
label: configuredColumn == null ? void 0 : configuredColumn.label,
|
|
3418
|
+
name,
|
|
3419
|
+
serverDataType,
|
|
3420
|
+
subscribed: configuredColumn !== void 0
|
|
3421
|
+
};
|
|
3422
|
+
});
|
|
3423
|
+
};
|
|
3424
|
+
var useTableSettings = ({
|
|
3425
|
+
availableColumns,
|
|
3426
|
+
onConfigChange,
|
|
3427
|
+
tableConfig: tableConfigProp
|
|
3428
|
+
}) => {
|
|
3429
|
+
const [tableConfig, setTableConfig] = (0, import_react48.useState)(tableConfigProp);
|
|
3430
|
+
const columnItems = (0, import_react48.useMemo)(
|
|
3431
|
+
() => buildColumnItems(availableColumns, tableConfig.columns),
|
|
3432
|
+
[availableColumns, tableConfig.columns]
|
|
3433
|
+
);
|
|
3434
|
+
const handleMoveListItem = (0, import_react48.useCallback)(
|
|
3435
|
+
(fromIndex, toIndex) => {
|
|
3436
|
+
console.log(`move list item from ${fromIndex} to ${toIndex}`);
|
|
3437
|
+
},
|
|
3438
|
+
[]
|
|
3439
|
+
);
|
|
3440
|
+
const handleColumnChange = (0, import_react48.useCallback)(
|
|
3441
|
+
(name, property, value) => {
|
|
3442
|
+
const columnItem = columnItems.find((col) => col.name === name);
|
|
3443
|
+
if (property === "subscribed") {
|
|
3444
|
+
console.log(`unsubscribe from ${name}`);
|
|
3445
|
+
} else if (columnItem == null ? void 0 : columnItem.subscribed) {
|
|
3446
|
+
const column = tableConfig.columns.find((col) => col.name === name);
|
|
3447
|
+
if (column) {
|
|
3448
|
+
const newConfig = updateTableConfig(tableConfig, {
|
|
3449
|
+
type: "column-prop",
|
|
3450
|
+
property,
|
|
3451
|
+
column,
|
|
3452
|
+
value
|
|
3453
|
+
});
|
|
3454
|
+
setTableConfig(newConfig);
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
},
|
|
3458
|
+
[columnItems, tableConfig]
|
|
3459
|
+
);
|
|
3460
|
+
const handleChangeColumnLabels = (0, import_react48.useCallback)((evt) => {
|
|
3461
|
+
const { value } = evt.target;
|
|
3462
|
+
const columnFormatHeader = value === "0" ? void 0 : value === "1" ? "capitalize" : "uppercase";
|
|
3463
|
+
setTableConfig((config) => ({
|
|
3464
|
+
...config,
|
|
3465
|
+
columnFormatHeader
|
|
3466
|
+
}));
|
|
3467
|
+
}, []);
|
|
3468
|
+
(0, import_vuu_layout4.useLayoutEffectSkipFirst)(() => {
|
|
3469
|
+
onConfigChange == null ? void 0 : onConfigChange(tableConfig);
|
|
3470
|
+
}, [onConfigChange, tableConfig]);
|
|
3471
|
+
const columnLabelsValue = tableConfig.columnFormatHeader === void 0 ? 0 : tableConfig.columnFormatHeader === "capitalize" ? 1 : 2;
|
|
3472
|
+
return {
|
|
3473
|
+
columnItems,
|
|
3474
|
+
columnLabelsValue,
|
|
3475
|
+
onChangeColumnLabels: handleChangeColumnLabels,
|
|
3476
|
+
onColumnChange: handleColumnChange,
|
|
3477
|
+
onMoveListItem: handleMoveListItem
|
|
3478
|
+
};
|
|
3479
|
+
};
|
|
3480
|
+
|
|
3481
|
+
// src/table-settings/TableSettingsPanel.tsx
|
|
3482
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3483
|
+
var classBase13 = "vuuTableSettingsPanel";
|
|
3484
|
+
var TableSettingsPanel = ({
|
|
3485
|
+
availableColumns,
|
|
3486
|
+
onConfigChange,
|
|
3487
|
+
tableConfig,
|
|
3488
|
+
...htmlAttributes
|
|
3489
|
+
}) => {
|
|
3490
|
+
const {
|
|
3491
|
+
columnItems,
|
|
3492
|
+
columnLabelsValue,
|
|
3493
|
+
onChangeColumnLabels,
|
|
3494
|
+
onColumnChange,
|
|
3495
|
+
onMoveListItem
|
|
3496
|
+
} = useTableSettings({
|
|
3497
|
+
availableColumns,
|
|
3498
|
+
onConfigChange,
|
|
3499
|
+
tableConfig
|
|
3500
|
+
});
|
|
3501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { ...htmlAttributes, className: classBase13, children: [
|
|
3502
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_core9.FormField, { children: [
|
|
3503
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_core9.FormFieldLabel, { children: "Column Labels" }),
|
|
3504
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
3505
|
+
import_core9.ToggleButtonGroup,
|
|
3506
|
+
{
|
|
3507
|
+
className: "vuuToggleButtonGroup",
|
|
3508
|
+
onChange: onChangeColumnLabels,
|
|
3509
|
+
value: columnLabelsValue,
|
|
3510
|
+
children: [
|
|
3511
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3512
|
+
import_core9.ToggleButton,
|
|
3513
|
+
{
|
|
3514
|
+
className: "vuuIconToggleButton",
|
|
3515
|
+
"data-icon": "text-strikethrough",
|
|
3516
|
+
value: 0
|
|
3517
|
+
}
|
|
3518
|
+
),
|
|
3519
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3520
|
+
import_core9.ToggleButton,
|
|
3521
|
+
{
|
|
3522
|
+
className: "vuuIconToggleButton",
|
|
3523
|
+
"data-icon": "text-Tt",
|
|
3524
|
+
value: 1
|
|
3525
|
+
}
|
|
3526
|
+
),
|
|
3527
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3528
|
+
import_core9.ToggleButton,
|
|
3529
|
+
{
|
|
3530
|
+
className: "vuuIconToggleButton",
|
|
3531
|
+
"data-icon": "text-T",
|
|
3532
|
+
value: 2
|
|
3533
|
+
}
|
|
3534
|
+
)
|
|
3535
|
+
]
|
|
3536
|
+
}
|
|
3537
|
+
)
|
|
3538
|
+
] }),
|
|
3539
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_core9.FormField, { children: [
|
|
3540
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_core9.FormFieldLabel, { children: "Default Column Width" }),
|
|
3541
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_core9.Input, { className: "vuuInput" })
|
|
3542
|
+
] }),
|
|
3543
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3544
|
+
ColumnList,
|
|
3545
|
+
{
|
|
3546
|
+
columnItems,
|
|
3547
|
+
onChange: onColumnChange,
|
|
3548
|
+
onMoveListItem
|
|
3549
|
+
}
|
|
3550
|
+
)
|
|
3551
|
+
] });
|
|
3552
|
+
};
|
|
2
3553
|
//# sourceMappingURL=index.js.map
|