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