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