@vuu-ui/vuu-table-extras 0.13.6 → 0.13.8

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 (217) hide show
  1. package/cjs/index.js +4254 -65
  2. package/cjs/index.js.map +1 -1
  3. package/esm/index.js +4221 -28
  4. package/esm/index.js.map +1 -1
  5. package/package.json +12 -13
  6. package/cjs/cell-edit-validators/CaseValidator.js +0 -25
  7. package/cjs/cell-edit-validators/CaseValidator.js.map +0 -1
  8. package/cjs/cell-edit-validators/PatternValidator.js +0 -31
  9. package/cjs/cell-edit-validators/PatternValidator.js.map +0 -1
  10. package/cjs/cell-renderers/background-cell/BackgroundCell.css.js +0 -6
  11. package/cjs/cell-renderers/background-cell/BackgroundCell.css.js.map +0 -1
  12. package/cjs/cell-renderers/background-cell/BackgroundCell.js +0 -76
  13. package/cjs/cell-renderers/background-cell/BackgroundCell.js.map +0 -1
  14. package/cjs/cell-renderers/background-cell/BackgroundCellConfigurationEditor.css.js +0 -6
  15. package/cjs/cell-renderers/background-cell/BackgroundCellConfigurationEditor.css.js.map +0 -1
  16. package/cjs/cell-renderers/background-cell/BackgroundCellConfigurationEditor.js +0 -67
  17. package/cjs/cell-renderers/background-cell/BackgroundCellConfigurationEditor.js.map +0 -1
  18. package/cjs/cell-renderers/background-cell/BackgroundKeyframes.css.js +0 -6
  19. package/cjs/cell-renderers/background-cell/BackgroundKeyframes.css.js.map +0 -1
  20. package/cjs/cell-renderers/background-cell/useDirection.js +0 -20
  21. package/cjs/cell-renderers/background-cell/useDirection.js.map +0 -1
  22. package/cjs/cell-renderers/dropdown-cell/DropdownCell.css.js +0 -6
  23. package/cjs/cell-renderers/dropdown-cell/DropdownCell.css.js.map +0 -1
  24. package/cjs/cell-renderers/dropdown-cell/DropdownCell.js +0 -94
  25. package/cjs/cell-renderers/dropdown-cell/DropdownCell.js.map +0 -1
  26. package/cjs/cell-renderers/lookup-cell/LookupCell.js +0 -23
  27. package/cjs/cell-renderers/lookup-cell/LookupCell.js.map +0 -1
  28. package/cjs/cell-renderers/pct-progress-cell/PctProgressCell.css.js +0 -6
  29. package/cjs/cell-renderers/pct-progress-cell/PctProgressCell.css.js.map +0 -1
  30. package/cjs/cell-renderers/pct-progress-cell/PctProgressCell.js +0 -62
  31. package/cjs/cell-renderers/pct-progress-cell/PctProgressCell.js.map +0 -1
  32. package/cjs/cell-renderers/progress-cell/ProgressCell.css.js +0 -6
  33. package/cjs/cell-renderers/progress-cell/ProgressCell.css.js.map +0 -1
  34. package/cjs/cell-renderers/progress-cell/ProgressCell.js +0 -69
  35. package/cjs/cell-renderers/progress-cell/ProgressCell.js.map +0 -1
  36. package/cjs/column-expression-input/ColumnExpressionInput.css.js +0 -6
  37. package/cjs/column-expression-input/ColumnExpressionInput.css.js.map +0 -1
  38. package/cjs/column-expression-input/ColumnExpressionInput.js +0 -39
  39. package/cjs/column-expression-input/ColumnExpressionInput.js.map +0 -1
  40. package/cjs/column-expression-input/column-function-descriptors.js +0 -307
  41. package/cjs/column-expression-input/column-function-descriptors.js.map +0 -1
  42. package/cjs/column-expression-input/column-language-parser/ColumnExpressionLanguage.js +0 -28
  43. package/cjs/column-expression-input/column-language-parser/ColumnExpressionLanguage.js.map +0 -1
  44. package/cjs/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.js +0 -465
  45. package/cjs/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.js.map +0 -1
  46. package/cjs/column-expression-input/column-language-parser/column-expression-parse-utils.js +0 -61
  47. package/cjs/column-expression-input/column-language-parser/column-expression-parse-utils.js.map +0 -1
  48. package/cjs/column-expression-input/column-language-parser/generated/column-parser.js +0 -21
  49. package/cjs/column-expression-input/column-language-parser/generated/column-parser.js.map +0 -1
  50. package/cjs/column-expression-input/functionDocInfo.js +0 -39
  51. package/cjs/column-expression-input/functionDocInfo.js.map +0 -1
  52. package/cjs/column-expression-input/highlighting.js +0 -16
  53. package/cjs/column-expression-input/highlighting.js.map +0 -1
  54. package/cjs/column-expression-input/theme.js +0 -63
  55. package/cjs/column-expression-input/theme.js.map +0 -1
  56. package/cjs/column-expression-input/useColumnAutoComplete.js +0 -358
  57. package/cjs/column-expression-input/useColumnAutoComplete.js.map +0 -1
  58. package/cjs/column-expression-input/useColumnExpressionEditor.js +0 -131
  59. package/cjs/column-expression-input/useColumnExpressionEditor.js.map +0 -1
  60. package/cjs/column-expression-input/useColumnExpressionSuggestionProvider.js +0 -213
  61. package/cjs/column-expression-input/useColumnExpressionSuggestionProvider.js.map +0 -1
  62. package/cjs/column-expression-panel/ColumnExpressionPanel.js +0 -85
  63. package/cjs/column-expression-panel/ColumnExpressionPanel.js.map +0 -1
  64. package/cjs/column-expression-panel/useColumnExpression.js +0 -69
  65. package/cjs/column-expression-panel/useColumnExpression.js.map +0 -1
  66. package/cjs/column-formatting-settings/BaseNumericFormattingSettings.js +0 -97
  67. package/cjs/column-formatting-settings/BaseNumericFormattingSettings.js.map +0 -1
  68. package/cjs/column-formatting-settings/ColumnFormattingPanel.js +0 -104
  69. package/cjs/column-formatting-settings/ColumnFormattingPanel.js.map +0 -1
  70. package/cjs/column-formatting-settings/DateTimeFormattingSettings.js +0 -99
  71. package/cjs/column-formatting-settings/DateTimeFormattingSettings.js.map +0 -1
  72. package/cjs/column-formatting-settings/LongTypeFormattingSettings.css.js +0 -6
  73. package/cjs/column-formatting-settings/LongTypeFormattingSettings.css.js.map +0 -1
  74. package/cjs/column-formatting-settings/LongTypeFormattingSettings.js +0 -49
  75. package/cjs/column-formatting-settings/LongTypeFormattingSettings.js.map +0 -1
  76. package/cjs/column-list/ColumnList.css.js +0 -6
  77. package/cjs/column-list/ColumnList.css.js.map +0 -1
  78. package/cjs/column-list/ColumnList.js +0 -174
  79. package/cjs/column-list/ColumnList.js.map +0 -1
  80. package/cjs/column-menu/ColumnMenu.css.js +0 -6
  81. package/cjs/column-menu/ColumnMenu.css.js.map +0 -1
  82. package/cjs/column-menu/ColumnMenu.js +0 -116
  83. package/cjs/column-menu/ColumnMenu.js.map +0 -1
  84. package/cjs/column-menu/column-menu-utils.js +0 -489
  85. package/cjs/column-menu/column-menu-utils.js.map +0 -1
  86. package/cjs/column-menu/useColumnActions.js +0 -75
  87. package/cjs/column-menu/useColumnActions.js.map +0 -1
  88. package/cjs/datasource-stats/DatasourceStats.css.js +0 -6
  89. package/cjs/datasource-stats/DatasourceStats.css.js.map +0 -1
  90. package/cjs/datasource-stats/DatasourceStats.js +0 -52
  91. package/cjs/datasource-stats/DatasourceStats.js.map +0 -1
  92. package/cjs/table-column-settings/ColumnNameLabel.css.js +0 -6
  93. package/cjs/table-column-settings/ColumnNameLabel.css.js.map +0 -1
  94. package/cjs/table-column-settings/ColumnNameLabel.js +0 -45
  95. package/cjs/table-column-settings/ColumnNameLabel.js.map +0 -1
  96. package/cjs/table-column-settings/ColumnSettingsPanel.css.js +0 -6
  97. package/cjs/table-column-settings/ColumnSettingsPanel.css.js.map +0 -1
  98. package/cjs/table-column-settings/ColumnSettingsPanel.js +0 -202
  99. package/cjs/table-column-settings/ColumnSettingsPanel.js.map +0 -1
  100. package/cjs/table-column-settings/TableSettingsPanel.css.js +0 -6
  101. package/cjs/table-column-settings/TableSettingsPanel.css.js.map +0 -1
  102. package/cjs/table-column-settings/TableSettingsPanel.js +0 -139
  103. package/cjs/table-column-settings/TableSettingsPanel.js.map +0 -1
  104. package/cjs/table-column-settings/useColumnSettings.js +0 -224
  105. package/cjs/table-column-settings/useColumnSettings.js.map +0 -1
  106. package/cjs/table-column-settings/useTableAndColumnSettings.js +0 -126
  107. package/cjs/table-column-settings/useTableAndColumnSettings.js.map +0 -1
  108. package/cjs/table-column-settings/useTableSettings.js +0 -172
  109. package/cjs/table-column-settings/useTableSettings.js.map +0 -1
  110. package/cjs/table-provider/TableProvider.js +0 -48
  111. package/cjs/table-provider/TableProvider.js.map +0 -1
  112. package/esm/cell-edit-validators/CaseValidator.js +0 -23
  113. package/esm/cell-edit-validators/CaseValidator.js.map +0 -1
  114. package/esm/cell-edit-validators/PatternValidator.js +0 -29
  115. package/esm/cell-edit-validators/PatternValidator.js.map +0 -1
  116. package/esm/cell-renderers/background-cell/BackgroundCell.css.js +0 -4
  117. package/esm/cell-renderers/background-cell/BackgroundCell.css.js.map +0 -1
  118. package/esm/cell-renderers/background-cell/BackgroundCell.js +0 -74
  119. package/esm/cell-renderers/background-cell/BackgroundCell.js.map +0 -1
  120. package/esm/cell-renderers/background-cell/BackgroundCellConfigurationEditor.css.js +0 -4
  121. package/esm/cell-renderers/background-cell/BackgroundCellConfigurationEditor.css.js.map +0 -1
  122. package/esm/cell-renderers/background-cell/BackgroundCellConfigurationEditor.js +0 -65
  123. package/esm/cell-renderers/background-cell/BackgroundCellConfigurationEditor.js.map +0 -1
  124. package/esm/cell-renderers/background-cell/BackgroundKeyframes.css.js +0 -4
  125. package/esm/cell-renderers/background-cell/BackgroundKeyframes.css.js.map +0 -1
  126. package/esm/cell-renderers/background-cell/useDirection.js +0 -18
  127. package/esm/cell-renderers/background-cell/useDirection.js.map +0 -1
  128. package/esm/cell-renderers/dropdown-cell/DropdownCell.css.js +0 -4
  129. package/esm/cell-renderers/dropdown-cell/DropdownCell.css.js.map +0 -1
  130. package/esm/cell-renderers/dropdown-cell/DropdownCell.js +0 -92
  131. package/esm/cell-renderers/dropdown-cell/DropdownCell.js.map +0 -1
  132. package/esm/cell-renderers/lookup-cell/LookupCell.js +0 -21
  133. package/esm/cell-renderers/lookup-cell/LookupCell.js.map +0 -1
  134. package/esm/cell-renderers/pct-progress-cell/PctProgressCell.css.js +0 -4
  135. package/esm/cell-renderers/pct-progress-cell/PctProgressCell.css.js.map +0 -1
  136. package/esm/cell-renderers/pct-progress-cell/PctProgressCell.js +0 -60
  137. package/esm/cell-renderers/pct-progress-cell/PctProgressCell.js.map +0 -1
  138. package/esm/cell-renderers/progress-cell/ProgressCell.css.js +0 -4
  139. package/esm/cell-renderers/progress-cell/ProgressCell.css.js.map +0 -1
  140. package/esm/cell-renderers/progress-cell/ProgressCell.js +0 -67
  141. package/esm/cell-renderers/progress-cell/ProgressCell.js.map +0 -1
  142. package/esm/column-expression-input/ColumnExpressionInput.css.js +0 -4
  143. package/esm/column-expression-input/ColumnExpressionInput.css.js.map +0 -1
  144. package/esm/column-expression-input/ColumnExpressionInput.js +0 -37
  145. package/esm/column-expression-input/ColumnExpressionInput.js.map +0 -1
  146. package/esm/column-expression-input/column-function-descriptors.js +0 -305
  147. package/esm/column-expression-input/column-function-descriptors.js.map +0 -1
  148. package/esm/column-expression-input/column-language-parser/ColumnExpressionLanguage.js +0 -26
  149. package/esm/column-expression-input/column-language-parser/ColumnExpressionLanguage.js.map +0 -1
  150. package/esm/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.js +0 -463
  151. package/esm/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.js.map +0 -1
  152. package/esm/column-expression-input/column-language-parser/column-expression-parse-utils.js +0 -56
  153. package/esm/column-expression-input/column-language-parser/column-expression-parse-utils.js.map +0 -1
  154. package/esm/column-expression-input/column-language-parser/generated/column-parser.js +0 -19
  155. package/esm/column-expression-input/column-language-parser/generated/column-parser.js.map +0 -1
  156. package/esm/column-expression-input/functionDocInfo.js +0 -37
  157. package/esm/column-expression-input/functionDocInfo.js.map +0 -1
  158. package/esm/column-expression-input/highlighting.js +0 -14
  159. package/esm/column-expression-input/highlighting.js.map +0 -1
  160. package/esm/column-expression-input/theme.js +0 -61
  161. package/esm/column-expression-input/theme.js.map +0 -1
  162. package/esm/column-expression-input/useColumnAutoComplete.js +0 -356
  163. package/esm/column-expression-input/useColumnAutoComplete.js.map +0 -1
  164. package/esm/column-expression-input/useColumnExpressionEditor.js +0 -129
  165. package/esm/column-expression-input/useColumnExpressionEditor.js.map +0 -1
  166. package/esm/column-expression-input/useColumnExpressionSuggestionProvider.js +0 -211
  167. package/esm/column-expression-input/useColumnExpressionSuggestionProvider.js.map +0 -1
  168. package/esm/column-expression-panel/ColumnExpressionPanel.js +0 -83
  169. package/esm/column-expression-panel/ColumnExpressionPanel.js.map +0 -1
  170. package/esm/column-expression-panel/useColumnExpression.js +0 -67
  171. package/esm/column-expression-panel/useColumnExpression.js.map +0 -1
  172. package/esm/column-formatting-settings/BaseNumericFormattingSettings.js +0 -95
  173. package/esm/column-formatting-settings/BaseNumericFormattingSettings.js.map +0 -1
  174. package/esm/column-formatting-settings/ColumnFormattingPanel.js +0 -102
  175. package/esm/column-formatting-settings/ColumnFormattingPanel.js.map +0 -1
  176. package/esm/column-formatting-settings/DateTimeFormattingSettings.js +0 -97
  177. package/esm/column-formatting-settings/DateTimeFormattingSettings.js.map +0 -1
  178. package/esm/column-formatting-settings/LongTypeFormattingSettings.css.js +0 -4
  179. package/esm/column-formatting-settings/LongTypeFormattingSettings.css.js.map +0 -1
  180. package/esm/column-formatting-settings/LongTypeFormattingSettings.js +0 -47
  181. package/esm/column-formatting-settings/LongTypeFormattingSettings.js.map +0 -1
  182. package/esm/column-list/ColumnList.css.js +0 -4
  183. package/esm/column-list/ColumnList.css.js.map +0 -1
  184. package/esm/column-list/ColumnList.js +0 -172
  185. package/esm/column-list/ColumnList.js.map +0 -1
  186. package/esm/column-menu/ColumnMenu.css.js +0 -4
  187. package/esm/column-menu/ColumnMenu.css.js.map +0 -1
  188. package/esm/column-menu/ColumnMenu.js +0 -114
  189. package/esm/column-menu/ColumnMenu.js.map +0 -1
  190. package/esm/column-menu/column-menu-utils.js +0 -480
  191. package/esm/column-menu/column-menu-utils.js.map +0 -1
  192. package/esm/column-menu/useColumnActions.js +0 -73
  193. package/esm/column-menu/useColumnActions.js.map +0 -1
  194. package/esm/datasource-stats/DatasourceStats.css.js +0 -4
  195. package/esm/datasource-stats/DatasourceStats.css.js.map +0 -1
  196. package/esm/datasource-stats/DatasourceStats.js +0 -50
  197. package/esm/datasource-stats/DatasourceStats.js.map +0 -1
  198. package/esm/table-column-settings/ColumnNameLabel.css.js +0 -4
  199. package/esm/table-column-settings/ColumnNameLabel.css.js.map +0 -1
  200. package/esm/table-column-settings/ColumnNameLabel.js +0 -43
  201. package/esm/table-column-settings/ColumnNameLabel.js.map +0 -1
  202. package/esm/table-column-settings/ColumnSettingsPanel.css.js +0 -4
  203. package/esm/table-column-settings/ColumnSettingsPanel.css.js.map +0 -1
  204. package/esm/table-column-settings/ColumnSettingsPanel.js +0 -200
  205. package/esm/table-column-settings/ColumnSettingsPanel.js.map +0 -1
  206. package/esm/table-column-settings/TableSettingsPanel.css.js +0 -4
  207. package/esm/table-column-settings/TableSettingsPanel.css.js.map +0 -1
  208. package/esm/table-column-settings/TableSettingsPanel.js +0 -136
  209. package/esm/table-column-settings/TableSettingsPanel.js.map +0 -1
  210. package/esm/table-column-settings/useColumnSettings.js +0 -222
  211. package/esm/table-column-settings/useColumnSettings.js.map +0 -1
  212. package/esm/table-column-settings/useTableAndColumnSettings.js +0 -122
  213. package/esm/table-column-settings/useTableAndColumnSettings.js.map +0 -1
  214. package/esm/table-column-settings/useTableSettings.js +0 -170
  215. package/esm/table-column-settings/useTableSettings.js.map +0 -1
  216. package/esm/table-provider/TableProvider.js +0 -44
  217. package/esm/table-provider/TableProvider.js.map +0 -1
package/cjs/index.js CHANGED
@@ -1,68 +1,4257 @@
1
1
  'use strict';
2
2
 
3
- var CaseValidator = require('./cell-edit-validators/CaseValidator.js');
4
- var PatternValidator = require('./cell-edit-validators/PatternValidator.js');
5
- var BackgroundCell = require('./cell-renderers/background-cell/BackgroundCell.js');
6
- var BackgroundCellConfigurationEditor = require('./cell-renderers/background-cell/BackgroundCellConfigurationEditor.js');
7
- var DropdownCell = require('./cell-renderers/dropdown-cell/DropdownCell.js');
8
- var LookupCell = require('./cell-renderers/lookup-cell/LookupCell.js');
9
- var PctProgressCell = require('./cell-renderers/pct-progress-cell/PctProgressCell.js');
10
- require('./cell-renderers/progress-cell/ProgressCell.js');
11
- var ColumnList = require('./column-list/ColumnList.js');
12
- var ColumnMenu = require('./column-menu/ColumnMenu.js');
13
- var useColumnActions = require('./column-menu/useColumnActions.js');
14
- var ColumnSettingsPanel = require('./table-column-settings/ColumnSettingsPanel.js');
15
- var useColumnSettings = require('./table-column-settings/useColumnSettings.js');
16
- var TableSettingsPanel = require('./table-column-settings/TableSettingsPanel.js');
17
- var useTableSettings = require('./table-column-settings/useTableSettings.js');
18
- var useTableAndColumnSettings = require('./table-column-settings/useTableAndColumnSettings.js');
19
- var ColumnExpressionInput = require('./column-expression-input/ColumnExpressionInput.js');
20
- var ColumnExpressionLanguage = require('./column-expression-input/column-language-parser/ColumnExpressionLanguage.js');
21
- var ColumnExpressionTreeWalker = require('./column-expression-input/column-language-parser/ColumnExpressionTreeWalker.js');
22
- var columnExpressionParseUtils = require('./column-expression-input/column-language-parser/column-expression-parse-utils.js');
23
- var useColumnExpressionEditor = require('./column-expression-input/useColumnExpressionEditor.js');
24
- var useColumnExpressionSuggestionProvider = require('./column-expression-input/useColumnExpressionSuggestionProvider.js');
25
- var ColumnExpressionPanel = require('./column-expression-panel/ColumnExpressionPanel.js');
26
- var ColumnFormattingPanel = require('./column-formatting-settings/ColumnFormattingPanel.js');
27
- var BaseNumericFormattingSettings = require('./column-formatting-settings/BaseNumericFormattingSettings.js');
28
- var DateTimeFormattingSettings = require('./column-formatting-settings/DateTimeFormattingSettings.js');
29
- var DatasourceStats = require('./datasource-stats/DatasourceStats.js');
30
- var TableProvider = require('./table-provider/TableProvider.js');
31
-
32
-
33
-
34
- exports.CaseValidator = CaseValidator.CaseValidator;
35
- exports.PatternValidator = PatternValidator.PatternValidator;
36
- exports.BackgroundCell = BackgroundCell.BackgroundCell;
37
- exports.BackgroundCellConfigurationEditor = BackgroundCellConfigurationEditor.BackgroundCellConfigurationEditor;
38
- exports.DropdownCell = DropdownCell.DropdownCell;
39
- exports.LookupCell = LookupCell.LookupCell;
40
- exports.PctProgressCell = PctProgressCell.PctProgressCell;
41
- exports.ColumnList = ColumnList.ColumnList;
42
- exports.ColumnMenu = ColumnMenu.ColumnMenu;
43
- exports.useColumnActions = useColumnActions.useColumnActions;
44
- exports.ColumnSettingsPanel = ColumnSettingsPanel.ColumnSettingsPanel;
45
- exports.useColumnSettings = useColumnSettings.useColumnSettings;
46
- exports.TableSettingsPanel = TableSettingsPanel.TableSettingsPanel;
47
- exports.defaultTableSettingsPermissions = TableSettingsPanel.defaultTableSettingsPermissions;
48
- exports.useTableSettings = useTableSettings.useTableSettings;
49
- exports.columnSettingsFromColumnMenuPermissions = useTableAndColumnSettings.columnSettingsFromColumnMenuPermissions;
50
- exports.tableSettingsFromColumnMenuPermissions = useTableAndColumnSettings.tableSettingsFromColumnMenuPermissions;
51
- exports.useTableAndColumnSettings = useTableAndColumnSettings.useTableAndColumnSettings;
52
- exports.ColumnExpressionInput = ColumnExpressionInput.ColumnExpressionInput;
53
- exports.columnExpressionLanguageSupport = ColumnExpressionLanguage.columnExpressionLanguageSupport;
54
- exports.walkTree = ColumnExpressionTreeWalker.walkTree;
55
- exports.ColumnNamedTerms = columnExpressionParseUtils.ColumnNamedTerms;
56
- exports.isCompleteExpression = columnExpressionParseUtils.isCompleteExpression;
57
- exports.isCompleteRelationalExpression = columnExpressionParseUtils.isCompleteRelationalExpression;
58
- exports.lastNamedChild = columnExpressionParseUtils.lastNamedChild;
59
- exports.useColumnExpressionEditor = useColumnExpressionEditor.useColumnExpressionEditor;
60
- exports.useColumnExpressionSuggestionProvider = useColumnExpressionSuggestionProvider.useColumnExpressionSuggestionProvider;
61
- exports.ColumnExpressionPanel = ColumnExpressionPanel.ColumnExpressionPanel;
62
- exports.ColumnFormattingPanel = ColumnFormattingPanel.ColumnFormattingPanel;
63
- exports.BaseNumericFormattingSettings = BaseNumericFormattingSettings.BaseNumericFormattingSettings;
64
- exports.DateTimeFormattingSettings = DateTimeFormattingSettings.DateTimeFormattingSettings;
65
- exports.DataSourceStats = DatasourceStats.DataSourceStats;
66
- exports.TableProvider = TableProvider.TableProvider;
67
- exports.useTableContext = TableProvider.useTableContext;
3
+ var vuuUtils = require('@vuu-ui/vuu-utils');
4
+ var vuuDataReact = require('@vuu-ui/vuu-data-react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var styles = require('@salt-ds/styles');
7
+ var window = require('@salt-ds/window');
8
+ var cx = require('clsx');
9
+ var react = require('react');
10
+ var core = require('@salt-ds/core');
11
+ var vuuUiControls = require('@vuu-ui/vuu-ui-controls');
12
+ var vuuTable = require('@vuu-ui/vuu-table');
13
+ var vuuCodemirror = require('@vuu-ui/vuu-codemirror');
14
+ var lr = require('@lezer/lr');
15
+
16
+ const isString$1 = (value) => typeof value === "string";
17
+ const CaseValidator = (rule, value) => {
18
+ if (isString$1(value)) {
19
+ if (value === "") {
20
+ return vuuDataReact.OK;
21
+ } else if (rule.value === "lower" && value.toLowerCase() !== value) {
22
+ return { ok: false, message: "value must be all lowercase" };
23
+ } else if (rule.value === "upper" && value.toUpperCase() !== value) {
24
+ return { ok: false, message: "value must be all uppercase" };
25
+ } else {
26
+ return vuuDataReact.OK;
27
+ }
28
+ } else {
29
+ return { ok: false, message: "value must be a string" };
30
+ }
31
+ };
32
+ vuuUtils.registerComponent("vuu-case", CaseValidator, "data-edit-validator", {});
33
+
34
+ const isString = (value) => typeof value === "string";
35
+ const defaultMessage = "value does not match expected pattern";
36
+ const PatternValidator = (rule, value) => {
37
+ if (typeof rule.value !== "string") {
38
+ throw Error("Pattern validation rule must provide pattern");
39
+ }
40
+ if (isString(value)) {
41
+ if (value === "") {
42
+ return vuuDataReact.OK;
43
+ } else {
44
+ const { message = defaultMessage } = rule;
45
+ const pattern = new RegExp(rule.value);
46
+ if (pattern.test(value)) {
47
+ return vuuDataReact.OK;
48
+ } else {
49
+ return { ok: false, message };
50
+ }
51
+ }
52
+ } else {
53
+ return { ok: false, message: "value must be a string" };
54
+ }
55
+ };
56
+ vuuUtils.registerComponent("vuu-pattern", PatternValidator, "data-edit-validator", {});
57
+
58
+ const INITIAL_VALUE = [void 0, void 0, void 0, void 0];
59
+ function useDirection(key, value, column) {
60
+ const ref = react.useRef(void 0);
61
+ const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
62
+ const { type: dataType } = column;
63
+ const decimals = vuuUtils.isTypeDescriptor(dataType) ? dataType.formatting?.decimals : void 0;
64
+ const direction = key === prevKey && vuuUtils.isValidNumber(value) && vuuUtils.isValidNumber(prevValue) && column === prevColumn ? vuuUtils.getMovingValueDirection(value, prevDirection, prevValue, decimals) : "";
65
+ react.useEffect(() => {
66
+ ref.current = [key, value, column, direction];
67
+ });
68
+ return direction;
69
+ }
70
+
71
+ var backgroundCellCss = "\n.vuuBackgroundCell {\n --background-animation-duration: 10s;\n color: var(--vuuBackgroundCell-color, var(--vuu-color-gray-80));\n padding-right: var(--salt-size-unit);\n position: relative;\n z-index: -1;\n}\n\n.vuuBackgroundCell-arrowBackground,\n.vuuBackgroundCell-arrowOnly {\n padding-left: 14px;\n}\n\n.vuuBackgroundCell-arrow {\n background-color: var(--background-cell-background);\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n z-index: -1;\n}\n\n.vuuBackgroundCell-arrow {\n text-align: left;\n}\n.vuuBackgroundCell-arrow + .num {\n padding-left: 8px;\n}\n\n.right .vuuBackgroundCell-arrow {\n text-align: right;\n}\n.right .vuuBackgroundCell-arrow + .num {\n padding-right: 8px;\n}\n\n.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {\n background-color: transparent;\n}\n\n.vuuBackgroundCell-backgroundOnly.up1,\n.vuuBackgroundCell-arrowBackground.up1 {\n animation-duration: var(--background-animation-duration);\n animation-name: vuubgup1;\n}\n\n.vuuBackgroundCell-backgroundOnly.up2,\n.vuuBackgroundCell-arrowBackground.up2 {\n animation-duration: var(--background-animation-duration);\n animation-name: vuubgup2;\n}\n\n.vuuBackgroundCell-backgroundOnly.down1,\n.vuuBackgroundCell-arrowBackground.down1 {\n animation-duration: var(--background-animation-duration);\n animation-name: vuubgdown1;\n}\n\n.vuuBackgroundCell-backgroundOnly.down2,\n.vuuBackgroundCell-arrowBackground.down2 {\n animation-duration: var(--background-animation-duration);\n animation-name: vuubgdown2;\n}\n\n.up1.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuuarrowup1;\n}\n\n.up2.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuuarrowup2;\n}\n\n.down1.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuuarrowdown1;\n}\n\n.down2.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuuarrowdown2;\n}\n\n.up1.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuubgarrowup1;\n}\n\n.up2.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuubgarrowup2;\n}\n\n.down1.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuubgarrowdown1;\n}\n\n.down2.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {\n animation-duration: 30s;\n animation-name: vuubgarrowdown2;\n}\n";
72
+
73
+ var backgroundKeyFramesCss = "\n@keyframes vuubgup1 {\n 0% {\n background-color: var(--vuu-color-green-50);\n color: white;\n }\n\n 30% {\n color: white;\n } \n 33% {\n color: var(--vuu-color-gray-80);\n } \n\n 100% {\n background-color: transparent;\n color: var(--vuu-color-gray-80);\n }\n }\n \n @keyframes vuubgup2 {\n 0% {\n background-color: var(--vuu-color-green-50);\n color: white;\n }\n\n 30% {\n color: white;\n } \n 33% {\n color: var(--vuu-color-gray-80);\n } \n\n 100% {\n background-color: transparent;\n color: var(--vuu-color-gray-80);\n }\n }\n \n @keyframes vuubgdown1 {\n 0% {\n background-color: var(--vuu-color-red-50);\n color: white;\n }\n 30% {\n color: white;\n } \n 33% {\n color: var(--vuu-color-gray-80);\n } \n 100% {\n background-color: transparent;\n color: var(--vuu-color-gray-80);\n }\n }\n \n @keyframes vuubgdown2 {\n 0% {\n background-color: var(--vuu-color-red-50);\n color: white;\n }\n 30% {\n color: white;\n } \n 33% {\n color: var(--vuu-color-gray-80);\n } \n 100% {\n background-color: transparent;\n color: var(--vuu-color-gray-80);\n }\n }\n \n @keyframes vuuarrowup1 {\n from {\n color: var(--salt-differential-positive-foreground);\n }\n to {\n color: transparent;\n }\n }\n \n @keyframes vuuarrowup2 {\n from {\n color: var(--salt-differential-positive-foreground);\n }\n to {\n color: transparent;\n }\n }\n \n @keyframes vuuarrowdown1 {\n from {\n color: var(--salt-differential-negative-foreground);\n }\n to {\n color: transparent;\n }\n }\n \n @keyframes vuuarrowdown2 {\n from {\n color: var(--salt-differential-negative-foreground);\n }\n to {\n color: transparent;\n }\n }\n \n @keyframes vuubgarrowup1 {\n 0% {\n color: var(--salt-differential-positive-foreground);\n background-color: var(--vuu-color-green-50);\n }\n 20% {\n color: var(--salt-differential-positive-foreground);\n background-color: transparent;\n }\n 100% {\n color: transparent;\n background-color: transparent;\n }\n }\n \n @keyframes vuubgarrowup2 {\n 0% {\n color: var(--salt-differential-positive-foreground);\n background-color: var(--vuu-color-green-50);\n }\n 20% {\n color: var(--salt-differential-positive-foreground);\n background-color: transparent;\n }\n 100% {\n color: transparent;\n background-color: transparent;\n }\n }\n \n @keyframes vuubgarrowdown1 {\n 0% {\n color: var(--salt-differential-negative-foreground);\n background-color: var(--vuu-color-red-50);\n }\n 20% {\n color: var(--salt-differential-negative-foreground);\n background-color: transparent;\n }\n 100% {\n color: transparent;\n background-color: transparent;\n }\n }\n \n @keyframes vuubgarrowdown2 {\n 0% {\n color: var(--salt-differential-negative-foreground);\n background-color: var(--vuu-color-red-50);\n }\n 20% {\n color: var(--salt-differential-negative-foreground);\n background-color: transparent;\n }\n 100% {\n color: transparent;\n background-color: transparent;\n }\n }\n ";
74
+
75
+ const CHAR_ARROW_UP = String.fromCharCode(11014);
76
+ const CHAR_ARROW_DOWN = String.fromCharCode(11015);
77
+ const { KEY } = vuuUtils.metadataKeys;
78
+ const classBase$f = "vuuBackgroundCell";
79
+ const FlashStyle = {
80
+ ArrowOnly: "arrow",
81
+ BackgroundOnly: "bg-only",
82
+ ArrowBackground: "arrow-bg"
83
+ };
84
+ const getFlashStyle = (colType) => {
85
+ if (vuuUtils.isTypeDescriptor(colType) && colType.renderer) {
86
+ if ("flashStyle" in colType.renderer) {
87
+ return colType.renderer["flashStyle"];
88
+ }
89
+ }
90
+ return FlashStyle.BackgroundOnly;
91
+ };
92
+ const BackgroundCell = react.memo(function BackgroundCell2({
93
+ column,
94
+ columnMap,
95
+ row
96
+ }) {
97
+ const targetWindow = window.useWindow();
98
+ styles.useComponentCssInjection({
99
+ testId: "vuu-background-cell",
100
+ css: backgroundCellCss,
101
+ window: targetWindow
102
+ });
103
+ styles.useComponentCssInjection({
104
+ testId: "vuu-background-keyframes",
105
+ css: backgroundKeyFramesCss,
106
+ window: targetWindow
107
+ });
108
+ const { name, type, valueFormatter } = column;
109
+ const dataIdx = columnMap[name];
110
+ const value = row[dataIdx];
111
+ const flashStyle = getFlashStyle(type);
112
+ const direction = useDirection(row[KEY], value, column);
113
+ const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === vuuUtils.UP1 || direction === vuuUtils.UP2 ? CHAR_ARROW_UP : direction === vuuUtils.DOWN1 || direction === vuuUtils.DOWN2 ? CHAR_ARROW_DOWN : null : null;
114
+ const dirClass = direction ? ` ` + direction : "";
115
+ const className = cx(classBase$f, dirClass, {
116
+ [`${classBase$f}-backgroundOnly`]: flashStyle === FlashStyle.BackgroundOnly,
117
+ [`${classBase$f}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
118
+ [`${classBase$f}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
119
+ });
120
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, tabIndex: -1, children: [
121
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase$f}-arrow`, children: arrow }),
122
+ valueFormatter(row[dataIdx])
123
+ ] });
124
+ }, vuuUtils.dataAndColumnUnchanged);
125
+ vuuUtils.registerComponent(
126
+ "vuu.price-move-background",
127
+ BackgroundCell,
128
+ "cell-renderer",
129
+ {
130
+ description: "Change background color of cell when value changes",
131
+ configEditor: "BackgroundCellConfigurationEditor",
132
+ label: "Background Flash",
133
+ serverDataType: ["long", "int", "double"]
134
+ }
135
+ );
136
+
137
+ var backgroundCellConfigurationEditorCss = ".vuuBackgroundCellConfiguration {\n height: 50px;\n background-color: red;\n}";
138
+
139
+ const classBase$e = "vuuBackgroundCellConfiguration";
140
+ const flashOptions = [
141
+ { label: "Background Only", value: "bg-only" },
142
+ { label: "Background and Arrow", value: "arrow-bg" },
143
+ { label: "Arrow Only", value: "arrow" }
144
+ ];
145
+ const [defaultFlashOption] = flashOptions;
146
+ const valueFromColumn = (column) => {
147
+ const { flashStyle } = column.type.renderer;
148
+ return flashOptions.find((o) => o.value === flashStyle) || defaultFlashOption;
149
+ };
150
+ const BackgroundCellConfigurationEditor = ({
151
+ column,
152
+ onChangeRendering
153
+ }) => {
154
+ const targetWindow = window.useWindow();
155
+ styles.useComponentCssInjection({
156
+ testId: "vuu-background-cell-configuration-editor",
157
+ css: backgroundCellConfigurationEditorCss,
158
+ window: targetWindow
159
+ });
160
+ console.log({ type: column.type });
161
+ const [flashStyle, setFlashStyle] = react.useState(
162
+ valueFromColumn(column)
163
+ );
164
+ const handleSelectionChange = react.useCallback(
165
+ (_, [flashOption]) => {
166
+ setFlashStyle(flashOption);
167
+ const renderProps = column.type.renderer;
168
+ onChangeRendering({
169
+ ...renderProps,
170
+ flashStyle: flashOption?.value ?? defaultFlashOption.value
171
+ });
172
+ },
173
+ [column.type, onChangeRendering]
174
+ );
175
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { children: [
176
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Flash Style" }),
177
+ /* @__PURE__ */ jsxRuntime.jsx(
178
+ core.Dropdown,
179
+ {
180
+ className: `${classBase$e}-flashStyle`,
181
+ onSelectionChange: handleSelectionChange,
182
+ selected: flashStyle ? [flashStyle] : [],
183
+ value: flashStyle?.label,
184
+ children: flashOptions.map((flashOption, i) => /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: flashOption, children: flashOption.label }, i))
185
+ }
186
+ )
187
+ ] });
188
+ };
189
+ vuuUtils.registerConfigurationEditor(
190
+ "BackgroundCellConfigurationEditor",
191
+ BackgroundCellConfigurationEditor
192
+ );
193
+
194
+ var dropdownCellCss = ".vuuTableCell {\n .vuuTableDropdownCell {\n --vuu-icon-height: 15px;\n --vuu-icon-left: calc(100% - 20px);\n --vuu-icon-size: 8px;\n --vuu-icon-top: -2px;\n --salt-focused-outlineStyle: none;\n --saltButton-borderRadius: 2px;\n\n border: solid 1px var(--salt-editable-borderColor);\n border-radius: 2px;\n position: relative;\n font-weight: 500;\n height: var(--vuu-table-embedded-control-height);\n min-height: var(--vuu-table-embedded-control-height);\n text-align: left;\n\n button:focus-visible {\n --saltButton-borderColor: var(--salt-focused-outlineColor);\n --saltButton-borderWidth: 2px;\n padding-left: 7px;\n }\n &.saltDropdown:focus {\n outline: none;\n }\n }\n\n .vuuTableDropdownCell:focus {\n border: solid 2px var(--salt-focused-outlineColor);\n }\n}\n\n/* .vuuTableCell:focus .vuuTableInputCell.saltInput-primary,\n.vuuTableInputCell.saltInput-primary.saltInput-focused {\n border: solid 2px var(--salt-focused-outlineColor);\n padding: 0 3px;\n} */\n";
195
+
196
+ const classBase$d = "vuuTableDropdownCell";
197
+ const DropdownCell = react.memo(function DropdownCell2({
198
+ column,
199
+ columnMap,
200
+ onEdit,
201
+ row
202
+ }) {
203
+ const targetWindow = window.useWindow();
204
+ styles.useComponentCssInjection({
205
+ testId: "vuu-dropdown-cell",
206
+ css: dropdownCellCss,
207
+ window: targetWindow
208
+ });
209
+ const [open, setOpen] = react.useState(false);
210
+ const dataIdx = columnMap[column.name];
211
+ const dataValue = row[dataIdx];
212
+ const { values } = vuuDataReact.useLookupValues(column, dataValue);
213
+ const valueRef = react.useRef(void 0);
214
+ react.useMemo(() => {
215
+ valueRef.current = vuuUtils.getSelectedOption(values, dataValue);
216
+ }, [dataValue, values]);
217
+ const handleOpenChange = react.useCallback((isOpen) => {
218
+ console.log(`handleOpenChange ${isOpen}`);
219
+ if (isOpen === false) {
220
+ setOpen(false);
221
+ }
222
+ }, []);
223
+ const handleSelectionChange = react.useCallback(
224
+ async (evt, [selectedOption2]) => {
225
+ if (selectedOption2) {
226
+ const response = await onEdit?.(
227
+ {
228
+ editType: "commit",
229
+ previousValue: valueRef.current?.value,
230
+ value: selectedOption2.value
231
+ },
232
+ "commit"
233
+ );
234
+ if (response === true) {
235
+ vuuUtils.dispatchCustomEvent(evt.target, "vuu-commit");
236
+ }
237
+ }
238
+ },
239
+ [onEdit]
240
+ );
241
+ const handleClick = react.useCallback(() => {
242
+ if (!open) {
243
+ setOpen(true);
244
+ }
245
+ }, [open]);
246
+ const handleKeyDown = react.useCallback(
247
+ (e) => {
248
+ if (e.key === "Enter" && !open) {
249
+ e.preventDefault();
250
+ e.stopPropagation();
251
+ setOpen(true);
252
+ }
253
+ },
254
+ [open]
255
+ );
256
+ const { current: selectedOption } = valueRef;
257
+ return /* @__PURE__ */ jsxRuntime.jsx(
258
+ core.Dropdown,
259
+ {
260
+ className: classBase$d,
261
+ "data-icon": "triangle-down",
262
+ onClick: handleClick,
263
+ onKeyDownCapture: handleKeyDown,
264
+ onOpenChange: handleOpenChange,
265
+ onSelectionChange: handleSelectionChange,
266
+ open,
267
+ selected: selectedOption ? [selectedOption] : [],
268
+ value: selectedOption?.label,
269
+ children: values.map((listOption, i) => /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: listOption, children: listOption.label }, i))
270
+ }
271
+ );
272
+ }, vuuUtils.dataColumnAndKeyUnchanged);
273
+ vuuUtils.registerComponent("dropdown-cell", DropdownCell, "cell-renderer", {
274
+ userCanAssign: false
275
+ });
276
+
277
+ const LookupCell = react.memo(function LookupCell2({
278
+ column,
279
+ columnMap,
280
+ row
281
+ }) {
282
+ const dataIdx = columnMap[column.name];
283
+ const dataValue = row[dataIdx];
284
+ const { initialValue: value } = vuuDataReact.useLookupValues(column, dataValue);
285
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { children: value?.label });
286
+ }, vuuUtils.dataAndColumnUnchanged);
287
+ vuuUtils.registerComponent("lookup-cell", LookupCell, "cell-renderer", {
288
+ userCanAssign: false
289
+ });
290
+
291
+ var pctProgressCellCss = ".vuuPctProgressCell {\n --progress-bar-width: 2px;\n position: relative;\n}\n\n.vuuPctProgressCell-zero {\n --progress-bar-width: 0px;\n}\n.vuuPctProgressCell-complete {\n --progress-bar-width: 0px;\n}\n\n.vuuPctProgressCell-progressBar {\n background-color: var(--vuu-color-green-60-fade-30);\n border-right: solid var(--progress-bar-width) var(--vuu-color-green-60);\n display: inline-block;\n height: 20px;\n left: 0;\n overflow: hidden;\n position: absolute;\n width: var(--progress-bar-pct, 0);\n}\n\n\n.vuuPctProgressCell-text {\n display: inline-block;\n text-align: left;\n width: 80%;\n z-index: 1;\n}";
292
+
293
+ const classBase$c = "vuuPctProgressCell";
294
+ const getPercentageValue = (value) => {
295
+ if (value >= 0 && value <= 1) {
296
+ return value * 100;
297
+ } else if (value > 2) {
298
+ return 0;
299
+ } else if (value > 1) {
300
+ return 100;
301
+ } else {
302
+ return 0;
303
+ }
304
+ };
305
+ const PctProgressCell = ({ column, columnMap, row }) => {
306
+ const targetWindow = window.useWindow();
307
+ styles.useComponentCssInjection({
308
+ testId: "vuu-pct-progress-cell",
309
+ css: pctProgressCellCss,
310
+ window: targetWindow
311
+ });
312
+ const value = row[columnMap[column.name]];
313
+ const percentageValue = getPercentageValue(value);
314
+ const className = cx(classBase$c, {});
315
+ return /* @__PURE__ */ jsxRuntime.jsxs(
316
+ "div",
317
+ {
318
+ className: cx(className, {
319
+ [`${classBase$c}-zero`]: percentageValue === 0,
320
+ [`${classBase$c}-complete`]: percentageValue >= 100
321
+ }),
322
+ tabIndex: -1,
323
+ children: [
324
+ /* @__PURE__ */ jsxRuntime.jsx(
325
+ "span",
326
+ {
327
+ className: `${classBase$c}-progressBar`,
328
+ style: { "--progress-bar-pct": `${percentageValue}%` }
329
+ }
330
+ ),
331
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase$c}-text`, children: `${percentageValue.toFixed(
332
+ 2
333
+ )} %` })
334
+ ]
335
+ }
336
+ );
337
+ };
338
+ vuuUtils.registerComponent("vuu.pct-progress", PctProgressCell, "cell-renderer", {
339
+ description: "Percentage formatter",
340
+ label: "Percentage formatter",
341
+ serverDataType: "double"
342
+ });
343
+
344
+ var progressCellCss = ".vuuProgressCell {\n align-items: center;\n display: flex;\n}\n\n.vuuProgressCell-track {\n display: inline-block;\n flex: auto 1 1;\n height: 4px;\n overflow: hidden;\n position: relative;\n}\n\n.vuuProgressCell-bg {\n background-color: var(--salt-measured-background);\n display: inline-block;\n height: 2px;\n left: 0;\n position: absolute;\n top: 1px;\n width: 100%;\n}\n\n\n.vuuProgressCell-bar {\n background-color: var(--salt-measured-fill);\n display: inline-block;\n height: 100%;\n left: 0;\n position: absolute;\n top:0;\n transform: translateX(var(--progress-bar-pct, -100%));\n width: 100%;\n}\n\n.vuuProgressCell-text {\n flex: 35px 0 0;\n text-align: right;\n}";
345
+
346
+ const classBase$b = "vuuProgressCell";
347
+ const ProgressCell = ({ column, columnMap, row }) => {
348
+ const targetWindow = window.useWindow();
349
+ styles.useComponentCssInjection({
350
+ testId: "vuu-progress-cell",
351
+ css: progressCellCss,
352
+ window: targetWindow
353
+ });
354
+ const { name, type } = column;
355
+ const value = row[columnMap[name]];
356
+ let showProgress = false;
357
+ let percentage = 0;
358
+ if (vuuUtils.isTypeDescriptor(type) && vuuUtils.isColumnTypeRenderer(type.renderer)) {
359
+ const { associatedField } = type.renderer;
360
+ if (associatedField) {
361
+ const associatedValue = row[columnMap[associatedField]];
362
+ if (vuuUtils.isValidNumber(value) && vuuUtils.isValidNumber(associatedValue)) {
363
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
364
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
365
+ showProgress = isFinite(percentage);
366
+ } else {
367
+ const floatValue = parseFloat(value);
368
+ if (Number.isFinite(floatValue)) {
369
+ const floatOtherValue = parseFloat(associatedValue);
370
+ if (Number.isFinite(floatOtherValue)) {
371
+ percentage = Math.min(
372
+ Math.round(floatValue / floatOtherValue * 100),
373
+ 100
374
+ );
375
+ showProgress = isFinite(percentage);
376
+ }
377
+ }
378
+ }
379
+ } else {
380
+ throw Error("ProgressCell associatedField is required to render");
381
+ }
382
+ }
383
+ const className = cx(classBase$b, {});
384
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, tabIndex: -1, children: [
385
+ showProgress ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `${classBase$b}-track`, children: [
386
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase$b}-bg` }),
387
+ /* @__PURE__ */ jsxRuntime.jsx(
388
+ "span",
389
+ {
390
+ className: `${classBase$b}-bar`,
391
+ style: { "--progress-bar-pct": `-${100 - percentage}%` }
392
+ }
393
+ )
394
+ ] }) : null,
395
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase$b}-text`, children: `${percentage} %` })
396
+ ] });
397
+ };
398
+ vuuUtils.registerComponent("vuu.progress", ProgressCell, "cell-renderer", {
399
+ description: "Progress formatter",
400
+ label: "Progress formatter",
401
+ serverDataType: ["long", "int", "double"],
402
+ // Not until we provide settings for associaetd field
403
+ userCanAssign: false
404
+ });
405
+
406
+ var columnList = ".vuuColumnList {\n --vuuMeasuredContainer-flex: 1 1 1px;\n --vuu-svg-function: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 14 14\"><path d=\"M5.8625 10.5V9.625H6.72291L8.4875 7.59792L6.72291 5.54167H5.64375L4.60833 10.8792C4.53055 11.3167 4.36527 11.6545 4.1125 11.8927C3.85972 12.1309 3.53402 12.25 3.13541 12.25C2.7368 12.25 2.40382 12.1333 2.13645 11.9C1.86909 11.6667 1.73541 11.375 1.73541 11.025C1.73541 10.7625 1.80833 10.551 1.95416 10.3906C2.1 10.2302 2.28958 10.15 2.52291 10.15C2.72708 10.15 2.89479 10.2083 3.02604 10.325C3.15729 10.4417 3.22291 10.5972 3.22291 10.7917C3.22291 10.8986 3.20104 10.9983 3.15729 11.0906C3.11354 11.183 3.05277 11.2583 2.975 11.3167C3.01388 11.3361 3.0552 11.3507 3.09895 11.3604C3.1427 11.3701 3.18888 11.375 3.2375 11.375C3.36388 11.375 3.47083 11.3142 3.55833 11.1927C3.64583 11.0712 3.70902 10.9132 3.74791 10.7188L4.75416 5.54167H2.91666V4.66667H4.91458L5.22083 3.12083C5.30833 2.68333 5.48333 2.34549 5.74583 2.10729C6.00833 1.8691 6.33402 1.75 6.72291 1.75C7.12152 1.75 7.44965 1.86667 7.70729 2.1C7.96493 2.33333 8.09375 2.625 8.09375 2.975C8.09375 3.2375 8.02083 3.44896 7.875 3.60938C7.72916 3.76979 7.53958 3.85 7.30625 3.85C7.1118 3.85 6.94652 3.7941 6.81041 3.68229C6.6743 3.57049 6.60625 3.42222 6.60625 3.2375C6.60625 3.14028 6.62569 3.04549 6.66458 2.95312C6.70347 2.86076 6.75208 2.78542 6.81041 2.72708C6.79097 2.70764 6.7618 2.69063 6.72291 2.67604C6.68402 2.66146 6.64513 2.65417 6.60625 2.65417C6.47986 2.65417 6.37048 2.7125 6.27812 2.82917C6.18576 2.94583 6.12013 3.09653 6.08125 3.28125L5.81875 4.66667H8.575V5.54167H7.88958L9.1 6.94167L10.2375 5.54167H9.5375V4.66667H12.25V5.54167H11.4042L9.65416 7.59792L11.4042 9.625H12.25V10.5H9.5375V9.625H10.2375L9.07083 8.26875L7.875 9.625H8.575V10.5H5.8625Z\"/></svg>');\n --vuuList-borderStyle: none;\n --vuuListItem-padding: 0;\n display: flex;\n flex-direction: column;\n\n\n .saltOption {\n align-items: center;\n background-color: var(--salt-container-primary-background);\n border-bottom: var(--vuuColumnListItem-border, solid) 1px\n var(--salt-separable-tertiary-borderColor);\n gap: var(--salt-spacing-200);\n padding: var(--salt=spacin-100) 0;\n\n .vuuIcon {\n --vuu-icon-color: var(--salt-content-secondary-foreground);\n }\n }\n\n .vuuColumnList-text {\n flex: 1 1 auto;\n }\n\n}\n\n[data-icon=\"function\"] {\n --vuu-icon-svg: var(--vuu-svg-function);\n}\n\n\n\n.vuuColumnList-withColumnNavgation {\n .vuuColumnList-text:hover {\n font-weight: 600;\n text-decoration: underline;\n }\n}\n\n.vuuColumnList-header {\n border-top: solid 2px var(--vuu-color-gray-30);\n flex: 0 0 40px;\n font-size: 14px;\n font-weight: 600;\n padding-top: 24px;\n}\n\n.vuuColumnList-colHeadings {\n border-bottom: solid 2px var(--vuu-color-gray-30);\n color: var(--vuu-color-gray-50);\n display: flex;\n flex: 0 0 24px;\n font-size: 10px;\n justify-content: space-between;\n margin-top: 16px;\n padding-bottom: 8px;\n}\n";
407
+
408
+ const classBase$a = "vuuColumnList";
409
+ const classBaseListItem = "vuuColumnListItem";
410
+ const useSorting = (id, index, allowSort = true) => {
411
+ const { handleRef: sortableHandleRef, ref: sortableRef } = vuuUtils.useSortable({
412
+ id,
413
+ index
414
+ });
415
+ const noopRef = react.useCallback(() => {
416
+ }, []);
417
+ const [handleRef, ref] = react.useMemo(() => {
418
+ return allowSort ? [sortableHandleRef, sortableRef] : [noopRef, noopRef];
419
+ }, [allowSort, noopRef, sortableHandleRef, sortableRef]);
420
+ return {
421
+ handleRef,
422
+ ref
423
+ };
424
+ };
425
+ const ColumnListItem = ({
426
+ className: classNameProp,
427
+ index,
428
+ item,
429
+ permissions: { allowHideColumns, allowRemoveColumns, allowReorderColumns },
430
+ ...optionProps
431
+ }) => {
432
+ const { handleRef, ref } = useSorting(item.name, index, allowReorderColumns);
433
+ return /* @__PURE__ */ jsxRuntime.jsxs(
434
+ core.Option,
435
+ {
436
+ ...optionProps,
437
+ className: cx(classNameProp, classBaseListItem),
438
+ "data-name": item.name,
439
+ id: item.name,
440
+ ref,
441
+ children: [
442
+ allowReorderColumns ? /* @__PURE__ */ jsxRuntime.jsx(
443
+ vuuUiControls.IconButton,
444
+ {
445
+ "data-embedded": true,
446
+ appearance: "transparent",
447
+ icon: "draggable",
448
+ ref: handleRef,
449
+ size: 16
450
+ }
451
+ ) : null,
452
+ item?.isCalculated ? /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "function" }) : /* @__PURE__ */ jsxRuntime.jsx(
453
+ core.Checkbox,
454
+ {
455
+ className: `${classBase$a}-checkBox`,
456
+ checked: item?.subscribed,
457
+ readOnly: allowRemoveColumns === false
458
+ }
459
+ ),
460
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase$a}-text`, children: vuuUtils.getColumnLabel(item) }),
461
+ allowHideColumns !== false ? /* @__PURE__ */ jsxRuntime.jsx(
462
+ core.Switch,
463
+ {
464
+ className: `${classBase$a}-switch`,
465
+ checked: item?.hidden !== true,
466
+ disabled: item?.subscribed !== true
467
+ }
468
+ ) : null
469
+ ]
470
+ }
471
+ );
472
+ };
473
+ const defaultPermissions = {
474
+ allowHideColumns: true,
475
+ allowRemoveColumns: true,
476
+ allowReorderColumns: true
477
+ };
478
+ const ColumnList = ({
479
+ className,
480
+ columnItems,
481
+ onChange,
482
+ onNavigateToColumn,
483
+ onReorderColumnItems,
484
+ permissions = defaultPermissions,
485
+ ...htmlAttributes
486
+ }) => {
487
+ const targetWindow = window.useWindow();
488
+ styles.useComponentCssInjection({
489
+ testId: "vuu-column-list",
490
+ css: columnList,
491
+ window: targetWindow
492
+ });
493
+ const listRef = react.useRef(null);
494
+ const handleChange = react.useCallback(
495
+ ({ target }) => {
496
+ const input = target;
497
+ const listItem = vuuUtils.queryClosest(target, `.${classBaseListItem}`);
498
+ if (listItem) {
499
+ const {
500
+ dataset: { name }
501
+ } = listItem;
502
+ if (name) {
503
+ const saltCheckbox = vuuUtils.queryClosest(target, `.${classBase$a}-checkBox`);
504
+ const saltSwitch = vuuUtils.queryClosest(target, `.${classBase$a}-switch`);
505
+ if (saltCheckbox) {
506
+ onChange(name, "subscribed", input.checked);
507
+ } else if (saltSwitch) {
508
+ onChange(name, "hidden", input.checked === false);
509
+ }
510
+ }
511
+ }
512
+ },
513
+ [onChange]
514
+ );
515
+ const handleClick = react.useCallback(
516
+ (evt) => {
517
+ const targetEl = evt.target;
518
+ if (targetEl.classList.contains("vuuColumnList-text")) {
519
+ const listItemEl = targetEl.closest(".vuuListItem");
520
+ if (listItemEl?.dataset.name) {
521
+ onNavigateToColumn?.(listItemEl.dataset.name);
522
+ }
523
+ }
524
+ },
525
+ [onNavigateToColumn]
526
+ );
527
+ const handleDragEnd = react.useCallback(() => {
528
+ setTimeout(() => {
529
+ const listItems = listRef.current?.querySelectorAll(".saltOption");
530
+ if (listItems) {
531
+ const orderedIds = Array.from(listItems).map(({ id }) => id);
532
+ onReorderColumnItems?.(vuuUtils.reorderColumnItems(columnItems, orderedIds));
533
+ }
534
+ }, 300);
535
+ }, [columnItems, onReorderColumnItems]);
536
+ return /* @__PURE__ */ jsxRuntime.jsx(vuuUtils.DragDropProvider, { onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsxRuntime.jsxs(
537
+ "div",
538
+ {
539
+ ...htmlAttributes,
540
+ className: cx(classBase$a, className, {
541
+ [`${classBase$a}-withColumnNavigation`]: typeof onNavigateToColumn === "function"
542
+ }),
543
+ children: [
544
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase$a}-header`, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Column Selection" }) }),
545
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classBase$a}-colHeadings`, children: [
546
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Column subscription" }),
547
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Visibility" })
548
+ ] }),
549
+ /* @__PURE__ */ jsxRuntime.jsx(core.ListBox, { ref: listRef, children: columnItems.map((columnItem, index) => /* @__PURE__ */ jsxRuntime.jsx(
550
+ ColumnListItem,
551
+ {
552
+ item: columnItem,
553
+ index,
554
+ onChange: handleChange,
555
+ onClick: handleClick,
556
+ permissions,
557
+ value: columnItem
558
+ },
559
+ columnItem.name
560
+ )) })
561
+ ]
562
+ }
563
+ ) });
564
+ };
565
+
566
+ const NullMenuActionHandler = (menuItemId) => {
567
+ console.log(
568
+ `[TableContext] no menu action handler installed (menuItemHandler invoked with ${menuItemId})`
569
+ );
570
+ return false;
571
+ };
572
+ const NullDataSource = {};
573
+ const TableContext = react.createContext({
574
+ dataSource: NullDataSource,
575
+ menuActionHandler: NullMenuActionHandler
576
+ });
577
+ const TableProvider = ({
578
+ children,
579
+ dataSource,
580
+ menuActionHandler
581
+ }) => {
582
+ return /* @__PURE__ */ jsxRuntime.jsx(
583
+ TableContext.Provider,
584
+ {
585
+ value: {
586
+ dataSource,
587
+ menuActionHandler
588
+ },
589
+ children
590
+ }
591
+ );
592
+ };
593
+ function useTableContext(throwIfNoDataSource = false) {
594
+ const { dataSource, menuActionHandler } = react.useContext(TableContext);
595
+ if (dataSource === NullDataSource && menuActionHandler == NullMenuActionHandler && throwIfNoDataSource) {
596
+ throw Error(`[TableProvider] no DataSourceProvider has been declared`);
597
+ } else {
598
+ return {
599
+ dataSource,
600
+ menuActionHandler
601
+ };
602
+ }
603
+ }
604
+
605
+ var columnMenuCss = ".vuuMenuItem {\n --vuu-svg-cog: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M12.9533 8.65331C12.98 8.43998 13 8.22665 13 7.99998C13 7.77331 12.98 7.55998 12.9533 7.34665L14.36 6.24665C14.4867 6.14665 14.52 5.96665 14.44 5.81998L13.1067 3.51331C13.0267 3.36665 12.8467 3.31331 12.7 3.36665L11.04 4.03331C10.6933 3.76665 10.32 3.54665 9.91333 3.37998L9.66 1.61331C9.64 1.45331 9.5 1.33331 9.33333 1.33331H6.66667C6.5 1.33331 6.36 1.45331 6.34 1.61331L6.08667 3.37998C5.68 3.54665 5.30667 3.77331 4.96 4.03331L3.3 3.36665C3.14667 3.30665 2.97333 3.36665 2.89333 3.51331L1.56 5.81998C1.47333 5.96665 1.51333 6.14665 1.64 6.24665L3.04667 7.34665C3.02 7.55998 3 7.77998 3 7.99998C3 8.21998 3.02 8.43998 3.04667 8.65331L1.64 9.75331C1.51333 9.85331 1.48 10.0333 1.56 10.18L2.89333 12.4866C2.97333 12.6333 3.15333 12.6866 3.3 12.6333L4.96 11.9666C5.30667 12.2333 5.68 12.4533 6.08667 12.62L6.34 14.3866C6.36 14.5466 6.5 14.6666 6.66667 14.6666H9.33333C9.5 14.6666 9.64 14.5466 9.66 14.3866L9.91333 12.62C10.32 12.4533 10.6933 12.2266 11.04 11.9666L12.7 12.6333C12.8533 12.6933 13.0267 12.6333 13.1067 12.4866L14.44 10.18C14.52 10.0333 14.4867 9.85331 14.36 9.75331L12.9533 8.65331V8.65331ZM8 10.3333C6.71333 10.3333 5.66667 9.28665 5.66667 7.99998C5.66667 6.71331 6.71333 5.66665 8 5.66665C9.28667 5.66665 10.3333 6.71331 10.3333 7.99998C10.3333 9.28665 9.28667 10.3333 8 10.3333Z\"/></svg>');\n}\n.vuuColumnMenu {\n --menu-button-size: calc(var(--salt-size-base) - var(--salt-spacing-100));\n --saltButton-padding: var(--salt-spacing-50);\n --saltButton-minWidth: var(--menu-button-size);\n --saltButton-height: var(--menu-button-size);\n --saltButton-width: var(--menu-button-size);\n\n --vuu-icon-height: var(--menu-button-size);\n --vuu-icon-left: 0px;\n --vuu-icon-top: 0px;\n --vuu-icon-width: var(--menu-button-size);\n\n border: none;\n border-radius: 4px;\n flex: 0 0 var(--menu-button-size);\n margin: var(--vuuTable-columnMenu-margin, 0);\n padding: 0;\n}\n";
606
+
607
+ const isColumnMenuActionType = (value) => value !== void 0 && [
608
+ "agg-count",
609
+ "agg-distinct",
610
+ "agg-sum",
611
+ "agg-avg",
612
+ "agg-high",
613
+ "agg-low",
614
+ "sort-asc",
615
+ "sort-dsc",
616
+ "sort-add-asc",
617
+ "sort-add-dsc",
618
+ "remove-sort",
619
+ "group-column",
620
+ "remove-group",
621
+ "add-to-group",
622
+ "remove-from-group",
623
+ "pin-column-left",
624
+ "pin-column-right",
625
+ "pin-column-floating",
626
+ "unpin-column",
627
+ "hide-column",
628
+ "remove-column",
629
+ "column-settings",
630
+ "table-settings"
631
+ ].includes(value);
632
+ const getColumnMenuActionType = (target) => {
633
+ const { menuActionId } = target.dataset;
634
+ if (isColumnMenuActionType(menuActionId)) {
635
+ return menuActionId;
636
+ } else {
637
+ throw Error(
638
+ "[vuu-table-extras] column-menu-utils target element is not a valid Column MenuItem"
639
+ );
640
+ }
641
+ };
642
+ function buildSortMenu(column, dataSource, menuActionClickHandler, isAllowed = true) {
643
+ if (!isAllowed || column.sortable === false) {
644
+ return null;
645
+ } else {
646
+ const { name, label = name } = column;
647
+ const menuItems = [];
648
+ const columnSortStatus = vuuUtils.getSortStatus(column.name, dataSource.sort);
649
+ switch (columnSortStatus) {
650
+ case "no-sort":
651
+ menuItems.push(
652
+ /* @__PURE__ */ jsxRuntime.jsx(
653
+ core.MenuItem,
654
+ {
655
+ "data-menu-action-id": "sort-asc",
656
+ onClick: menuActionClickHandler,
657
+ children: "Sort ascending"
658
+ },
659
+ "sort-asc"
660
+ )
661
+ );
662
+ menuItems.push(
663
+ /* @__PURE__ */ jsxRuntime.jsx(
664
+ core.MenuItem,
665
+ {
666
+ "data-menu-action-id": "sort-dsc",
667
+ onClick: menuActionClickHandler,
668
+ children: "Sort descending"
669
+ },
670
+ "sort-dsc"
671
+ )
672
+ );
673
+ break;
674
+ case "single-sort-asc":
675
+ menuItems.push(
676
+ /* @__PURE__ */ jsxRuntime.jsx(
677
+ core.MenuItem,
678
+ {
679
+ "data-menu-action-id": "sort-dsc",
680
+ onClick: menuActionClickHandler,
681
+ children: "Reverse Sort (DSC)"
682
+ },
683
+ "sort-dsc"
684
+ ),
685
+ /* @__PURE__ */ jsxRuntime.jsx(
686
+ core.MenuItem,
687
+ {
688
+ "data-menu-action-id": "remove-sort",
689
+ onClick: menuActionClickHandler,
690
+ children: "Remove Sort"
691
+ },
692
+ "remove-sort"
693
+ )
694
+ );
695
+ break;
696
+ case "single-sort-desc":
697
+ menuItems.push(
698
+ /* @__PURE__ */ jsxRuntime.jsx(
699
+ core.MenuItem,
700
+ {
701
+ "data-menu-action-id": "sort-asc",
702
+ onClick: menuActionClickHandler,
703
+ children: "Reverse Sort (ASC)"
704
+ },
705
+ "sort-asc"
706
+ ),
707
+ /* @__PURE__ */ jsxRuntime.jsx(
708
+ core.MenuItem,
709
+ {
710
+ "data-menu-action-id": "remove-sort",
711
+ onClick: menuActionClickHandler,
712
+ children: "Remove Sort"
713
+ },
714
+ "remove-sort"
715
+ )
716
+ );
717
+ break;
718
+ case "sort-other-column":
719
+ menuItems.push(
720
+ /* @__PURE__ */ jsxRuntime.jsx(
721
+ core.MenuItem,
722
+ {
723
+ "data-menu-action-id": "sort-add-asc",
724
+ onClick: menuActionClickHandler,
725
+ children: "Add to sort ASC"
726
+ },
727
+ "sort-add-asc"
728
+ )
729
+ );
730
+ menuItems.push(
731
+ /* @__PURE__ */ jsxRuntime.jsx(
732
+ core.MenuItem,
733
+ {
734
+ "data-menu-action-id": "sort-add-dsc",
735
+ onClick: menuActionClickHandler,
736
+ children: "Add to sort DSC"
737
+ },
738
+ "sort-add-dsc"
739
+ )
740
+ );
741
+ menuItems.push(
742
+ /* @__PURE__ */ jsxRuntime.jsx(
743
+ core.MenuItem,
744
+ {
745
+ "data-menu-action-id": "sort-asc",
746
+ onClick: menuActionClickHandler,
747
+ children: "Ascending"
748
+ },
749
+ "sort-asc"
750
+ )
751
+ );
752
+ menuItems.push(
753
+ /* @__PURE__ */ jsxRuntime.jsx(
754
+ core.MenuItem,
755
+ {
756
+ "data-menu-action-id": "sort-dsc",
757
+ onClick: menuActionClickHandler,
758
+ children: "Descending"
759
+ },
760
+ "sort-dsc"
761
+ )
762
+ );
763
+ break;
764
+ case "multi-sort-includes-column-asc":
765
+ case "multi-sort-includes-column-desc":
766
+ break;
767
+ default:
768
+ vuuUtils.logUnhandledMessage(
769
+ columnSortStatus,
770
+ "[vuu-table-extras] column-menu-utils buildSortMenu"
771
+ );
772
+ }
773
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
774
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(core.MenuItem, { children: `Sort by ${label}` }) }),
775
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuPanel, { children: menuItems })
776
+ ] }, "sort-menu");
777
+ }
778
+ }
779
+ function buildGroupMenu(column, dataSource, menuActionClickHandler, isAllowed = true) {
780
+ if (!isAllowed || column.groupable === false) {
781
+ return null;
782
+ } else {
783
+ const menuItems = [];
784
+ const columnGroupStatus = vuuUtils.getGroupStatus(column.name, dataSource.groupBy);
785
+ const { name, label = name } = column;
786
+ switch (columnGroupStatus) {
787
+ case "no-groupby":
788
+ case "single-groupby-other-column":
789
+ return /* @__PURE__ */ jsxRuntime.jsx(
790
+ core.MenuItem,
791
+ {
792
+ "data-menu-action-id": "group-column",
793
+ onClick: menuActionClickHandler,
794
+ children: `Group by ${label}`
795
+ },
796
+ "group-column"
797
+ );
798
+ case "single-groupby":
799
+ menuItems.push(
800
+ /* @__PURE__ */ jsxRuntime.jsx(
801
+ core.MenuItem,
802
+ {
803
+ "data-menu-action-id": "remove-group",
804
+ onClick: menuActionClickHandler,
805
+ children: "Remove Grouping"
806
+ },
807
+ "remove-group"
808
+ )
809
+ );
810
+ break;
811
+ case "multi-groupby-other-columns":
812
+ menuItems.push(
813
+ /* @__PURE__ */ jsxRuntime.jsx(
814
+ core.MenuItem,
815
+ {
816
+ "data-menu-action-id": "add-to-group",
817
+ onClick: menuActionClickHandler,
818
+ children: "Add to grouping"
819
+ },
820
+ "add-to-group"
821
+ )
822
+ );
823
+ break;
824
+ case "multi-groupby-includes-column":
825
+ menuItems.push(
826
+ /* @__PURE__ */ jsxRuntime.jsx(
827
+ core.MenuItem,
828
+ {
829
+ "data-menu-action-id": "remove-from-group",
830
+ onClick: menuActionClickHandler,
831
+ children: "Remove from grouping"
832
+ },
833
+ "remove-from-group"
834
+ )
835
+ );
836
+ break;
837
+ default:
838
+ vuuUtils.logUnhandledMessage(
839
+ columnGroupStatus,
840
+ "[vuu-table-extras] column-menu-utils buildGroupMenu"
841
+ );
842
+ }
843
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
844
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(core.MenuItem, { children: "Group data" }) }),
845
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuPanel, { children: menuItems })
846
+ ] }, "group-menu");
847
+ }
848
+ }
849
+ const buildVisibilityMenuItems = (column, menuActionClickHandler, isAllowed = true) => {
850
+ if (!isAllowed) {
851
+ return null;
852
+ }
853
+ const menuItems = [];
854
+ const { name, label = name } = column;
855
+ menuItems.push(
856
+ /* @__PURE__ */ jsxRuntime.jsx(
857
+ core.MenuItem,
858
+ {
859
+ "data-menu-action-id": "hide-column",
860
+ onClick: menuActionClickHandler,
861
+ children: `Hide ${label} column`
862
+ },
863
+ "hide-column"
864
+ )
865
+ );
866
+ menuItems.push(
867
+ /* @__PURE__ */ jsxRuntime.jsx(
868
+ core.MenuItem,
869
+ {
870
+ "data-menu-action-id": "remove-column",
871
+ onClick: menuActionClickHandler,
872
+ children: `Remove ${label} column`
873
+ },
874
+ "remove-column"
875
+ )
876
+ );
877
+ return menuItems;
878
+ };
879
+ const buildPinMenuItems = (column, menuActionClickHandler, isAllowed = true) => {
880
+ if (!isAllowed || column === void 0) {
881
+ return [];
882
+ }
883
+ const { pin } = column;
884
+ const menuItems = [];
885
+ const pinLeft = /* @__PURE__ */ jsxRuntime.jsx(
886
+ core.MenuItem,
887
+ {
888
+ "data-menu-action-id": "pin-column-left",
889
+ onClick: menuActionClickHandler,
890
+ children: "Pin left"
891
+ },
892
+ "pin-column-left"
893
+ );
894
+ const pinFloating = /* @__PURE__ */ jsxRuntime.jsx(
895
+ core.MenuItem,
896
+ {
897
+ "data-menu-action-id": "pin-column-floating",
898
+ onClick: menuActionClickHandler,
899
+ children: "Pin floating"
900
+ },
901
+ "pin-column-floating"
902
+ );
903
+ const pinRight = /* @__PURE__ */ jsxRuntime.jsx(
904
+ core.MenuItem,
905
+ {
906
+ "data-menu-action-id": "pin-column-right",
907
+ onClick: menuActionClickHandler,
908
+ children: "Pin right"
909
+ },
910
+ "pin-column-right"
911
+ );
912
+ if (pin === void 0) {
913
+ menuItems.push(
914
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
915
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(core.MenuItem, { children: "Pin Column" }) }),
916
+ /* @__PURE__ */ jsxRuntime.jsxs(core.MenuPanel, { children: [
917
+ pinLeft,
918
+ pinFloating,
919
+ pinRight
920
+ ] })
921
+ ] }, "pin-menu")
922
+ );
923
+ } else {
924
+ menuItems.push(
925
+ /* @__PURE__ */ jsxRuntime.jsx(
926
+ core.MenuItem,
927
+ {
928
+ "data-menu-action-id": "unpin-column",
929
+ onClick: menuActionClickHandler,
930
+ children: "Unpin"
931
+ },
932
+ "unpin-column"
933
+ )
934
+ );
935
+ if (pin === "left") {
936
+ menuItems.push(
937
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
938
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(core.MenuItem, { children: "Pin Column" }) }),
939
+ /* @__PURE__ */ jsxRuntime.jsxs(core.MenuPanel, { children: [
940
+ pinFloating,
941
+ pinRight
942
+ ] })
943
+ ] }, "pin-menu")
944
+ );
945
+ } else if (pin === "floating") {
946
+ menuItems.push(
947
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
948
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(core.MenuItem, { children: "Pin Column" }) }),
949
+ /* @__PURE__ */ jsxRuntime.jsxs(core.MenuPanel, { children: [
950
+ pinLeft,
951
+ pinRight
952
+ ] })
953
+ ] }, "pin-menu")
954
+ );
955
+ } else {
956
+ menuItems.push(
957
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
958
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(core.MenuItem, { children: "Pin Column" }) }),
959
+ /* @__PURE__ */ jsxRuntime.jsxs(core.MenuPanel, { children: [
960
+ pinFloating,
961
+ pinRight
962
+ ] })
963
+ ] }, "pin-menu")
964
+ );
965
+ }
966
+ }
967
+ return menuItems;
968
+ };
969
+ const buildSettingsMenuItems = (_, menuActionClickHandler, allowColumnSettings = true, allowTableSettings = true) => {
970
+ if (!allowColumnSettings && !allowTableSettings) {
971
+ return null;
972
+ }
973
+ const menuItems = [];
974
+ if (allowColumnSettings) {
975
+ menuItems.push(
976
+ /* @__PURE__ */ jsxRuntime.jsx(
977
+ core.MenuItem,
978
+ {
979
+ "data-icon": "settings",
980
+ "data-menu-action-id": "column-settings",
981
+ onClick: menuActionClickHandler,
982
+ children: "Column settings ..."
983
+ },
984
+ "column-settings"
985
+ )
986
+ );
987
+ }
988
+ if (allowTableSettings) {
989
+ menuItems.push(
990
+ /* @__PURE__ */ jsxRuntime.jsx(
991
+ core.MenuItem,
992
+ {
993
+ "data-icon": "settings",
994
+ "data-menu-action-id": "table-settings",
995
+ onClick: menuActionClickHandler,
996
+ children: "Table settings ..."
997
+ },
998
+ "table-settings"
999
+ )
1000
+ );
1001
+ }
1002
+ return menuItems;
1003
+ };
1004
+ function buildAggregationMenuItems(column, dataSource, menuActionClickHandler, isAllowed = true) {
1005
+ if (!isAllowed) {
1006
+ return null;
1007
+ }
1008
+ const { name, label = name } = column;
1009
+ if (dataSource.groupBy?.length === 0) {
1010
+ return [];
1011
+ } else {
1012
+ const menuItems = [
1013
+ /* @__PURE__ */ jsxRuntime.jsx(
1014
+ core.MenuItem,
1015
+ {
1016
+ "data-menu-action-id": "agg-count",
1017
+ onClick: menuActionClickHandler,
1018
+ children: "Count"
1019
+ },
1020
+ "agg-count"
1021
+ ),
1022
+ /* @__PURE__ */ jsxRuntime.jsx(
1023
+ core.MenuItem,
1024
+ {
1025
+ "data-menu-action-id": "agg-distinct",
1026
+ onClick: menuActionClickHandler,
1027
+ children: "Distinct"
1028
+ },
1029
+ "agg-distinct"
1030
+ )
1031
+ ];
1032
+ if (vuuUtils.isNumericColumn(column)) {
1033
+ menuItems.push(
1034
+ /* @__PURE__ */ jsxRuntime.jsx(
1035
+ core.MenuItem,
1036
+ {
1037
+ "data-menu-action-id": "agg-sum",
1038
+ onClick: menuActionClickHandler,
1039
+ children: "Sum"
1040
+ },
1041
+ "agg-sum"
1042
+ ),
1043
+ /* @__PURE__ */ jsxRuntime.jsx(
1044
+ core.MenuItem,
1045
+ {
1046
+ "data-menu-action-id": "agg-avg",
1047
+ onClick: menuActionClickHandler,
1048
+ children: "Average"
1049
+ },
1050
+ "agg-avg"
1051
+ ),
1052
+ /* @__PURE__ */ jsxRuntime.jsx(
1053
+ core.MenuItem,
1054
+ {
1055
+ "data-menu-action-id": "agg-high",
1056
+ onClick: menuActionClickHandler,
1057
+ children: "High"
1058
+ },
1059
+ "agg-high"
1060
+ ),
1061
+ /* @__PURE__ */ jsxRuntime.jsx(
1062
+ core.MenuItem,
1063
+ {
1064
+ "data-menu-action-id": "agg-low",
1065
+ onClick: menuActionClickHandler,
1066
+ children: "Low"
1067
+ },
1068
+ "agg-low"
1069
+ )
1070
+ );
1071
+ }
1072
+ return [
1073
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
1074
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(core.MenuItem, { children: `Aggregate ${label}` }) }),
1075
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuPanel, { children: menuItems })
1076
+ ] }, "aggregate-menu")
1077
+ ];
1078
+ }
1079
+ }
1080
+
1081
+ const buildColumnItems = (availableColumns, configuredColumns) => {
1082
+ return availableColumns.map(({ name, serverDataType }) => {
1083
+ const configuredColumn = configuredColumns.find((col) => col.name === name);
1084
+ return {
1085
+ hidden: configuredColumn?.hidden,
1086
+ isCalculated: vuuUtils.isCalculatedColumn(name),
1087
+ label: configuredColumn?.label ?? name,
1088
+ name,
1089
+ serverDataType,
1090
+ subscribed: configuredColumn !== void 0
1091
+ };
1092
+ });
1093
+ };
1094
+ const useTableSettings = ({
1095
+ availableColumns: availableColumnsProp,
1096
+ onConfigChange,
1097
+ onDataSourceConfigChange,
1098
+ tableConfig: tableConfigProp
1099
+ }) => {
1100
+ const [{ availableColumns, tableConfig }, setColumnState] = react.useState({
1101
+ availableColumns: availableColumnsProp,
1102
+ tableConfig: tableConfigProp
1103
+ });
1104
+ const columnItems = react.useMemo(
1105
+ () => buildColumnItems(availableColumns, tableConfig.columns),
1106
+ [availableColumns, tableConfig.columns]
1107
+ );
1108
+ const handleReorderColumnItems = react.useCallback(
1109
+ (columnItems2) => {
1110
+ const orderedNames = columnItems2.map((c) => c.name);
1111
+ setColumnState((state) => {
1112
+ const newAvailableColumns = vuuUtils.reorderColumnItems(
1113
+ state.availableColumns,
1114
+ orderedNames
1115
+ );
1116
+ const newColumns = vuuUtils.reorderColumnItems(
1117
+ tableConfig.columns,
1118
+ orderedNames
1119
+ );
1120
+ return {
1121
+ availableColumns: newAvailableColumns,
1122
+ tableConfig: {
1123
+ ...state.tableConfig,
1124
+ columns: newColumns
1125
+ }
1126
+ };
1127
+ });
1128
+ },
1129
+ [tableConfig.columns]
1130
+ );
1131
+ const handleColumnChange = react.useCallback(
1132
+ (name, property, value) => {
1133
+ const columnItem = columnItems.find((col) => col.name === name);
1134
+ if (property === "subscribed") {
1135
+ if (columnItem?.subscribed) {
1136
+ const subscribedColumns = tableConfig.columns.filter((col) => col.name !== name).map((col) => col.name);
1137
+ setColumnState((state) => ({
1138
+ ...state,
1139
+ tableConfig: {
1140
+ ...tableConfig,
1141
+ columns: tableConfig.columns.filter(
1142
+ vuuUtils.subscribedOnly(subscribedColumns)
1143
+ )
1144
+ }
1145
+ }));
1146
+ onDataSourceConfigChange({
1147
+ columns: subscribedColumns
1148
+ });
1149
+ } else {
1150
+ const newConfig = {
1151
+ ...tableConfig,
1152
+ columns: vuuUtils.addColumnToSubscribedColumns(
1153
+ tableConfig.columns,
1154
+ availableColumns,
1155
+ name
1156
+ )
1157
+ };
1158
+ setColumnState((state) => ({
1159
+ ...state,
1160
+ tableConfig: newConfig
1161
+ }));
1162
+ const subscribedColumns = newConfig.columns.map((col) => col.name);
1163
+ onDataSourceConfigChange({
1164
+ columns: subscribedColumns
1165
+ });
1166
+ }
1167
+ } else if (columnItem?.subscribed) {
1168
+ const column = tableConfig.columns.find((col) => col.name === name);
1169
+ if (column) {
1170
+ const newConfig = vuuTable.updateTableConfig(tableConfig, {
1171
+ type: "column-prop",
1172
+ property,
1173
+ column,
1174
+ value
1175
+ });
1176
+ setColumnState((state) => ({
1177
+ ...state,
1178
+ tableConfig: newConfig
1179
+ }));
1180
+ }
1181
+ }
1182
+ },
1183
+ [availableColumns, columnItems, onDataSourceConfigChange, tableConfig]
1184
+ );
1185
+ const handleChangeColumnLabels = react.useCallback((evt) => {
1186
+ const button = vuuUtils.queryClosest(evt.target, "button");
1187
+ if (button) {
1188
+ const value = parseInt(button.value);
1189
+ const columnFormatHeader = value === 0 ? void 0 : value === 1 ? "capitalize" : "uppercase";
1190
+ setColumnState((state) => ({
1191
+ ...state,
1192
+ tableConfig: {
1193
+ ...state.tableConfig,
1194
+ columnFormatHeader
1195
+ }
1196
+ }));
1197
+ }
1198
+ }, []);
1199
+ const handleChangeTableAttribute = react.useCallback(
1200
+ (evt) => {
1201
+ const button = vuuUtils.queryClosest(evt.target, "button");
1202
+ if (button) {
1203
+ const { ariaPressed, value } = button;
1204
+ setColumnState((state) => ({
1205
+ ...state,
1206
+ tableConfig: {
1207
+ ...state.tableConfig,
1208
+ [value]: ariaPressed !== "true"
1209
+ }
1210
+ }));
1211
+ }
1212
+ },
1213
+ []
1214
+ );
1215
+ const handleCommitColumnWidth = react.useCallback((_, value) => {
1216
+ if (typeof value === "string") {
1217
+ const columnDefaultWidth = parseInt(value);
1218
+ if (!isNaN(columnDefaultWidth)) {
1219
+ setColumnState((state) => ({
1220
+ ...state,
1221
+ tableConfig: {
1222
+ ...state.tableConfig,
1223
+ columnDefaultWidth
1224
+ }
1225
+ }));
1226
+ }
1227
+ }
1228
+ }, []);
1229
+ vuuUtils.useLayoutEffectSkipFirst(() => {
1230
+ onConfigChange?.(tableConfig);
1231
+ }, [onConfigChange, tableConfig]);
1232
+ const columnLabelsValue = tableConfig.columnFormatHeader === void 0 ? 0 : tableConfig.columnFormatHeader === "capitalize" ? 1 : 2;
1233
+ return {
1234
+ columnItems,
1235
+ columnLabelsValue,
1236
+ onChangeColumnLabels: handleChangeColumnLabels,
1237
+ onChangeTableAttribute: handleChangeTableAttribute,
1238
+ onColumnChange: handleColumnChange,
1239
+ onCommitColumnWidth: handleCommitColumnWidth,
1240
+ onReorderColumnItems: handleReorderColumnItems,
1241
+ tableConfig
1242
+ };
1243
+ };
1244
+
1245
+ var tableSettingsPanelCss = ".vuuTableSettingsPanel {\n --vuu-svg-text-strikethrough: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 24\"><path d=\"M28.3333 9.33334C28.8867 9.33334 29.3333 8.88668 29.3333 8.33334C29.3333 7.78001 28.8867 7.33334 28.3333 7.33334H20.26L22.26 9.33334H23.48L23.1133 10.1867L24.5067 11.58L25.4733 9.33334H28.3333ZM27.6267 16.5867L18.7467 7.70668C18.4867 7.44668 18.0667 7.44668 17.8067 7.70668C17.5467 7.96668 17.5467 8.38668 17.8067 8.64668L21.98 12.82L20.88 15.38C20.62 15.9933 21.0667 16.6667 21.7267 16.6667C22.0933 16.6667 22.4267 16.4467 22.5733 16.1067L23.38 14.22L26.68 17.52C26.94 17.78 27.36 17.78 27.62 17.52C27.8867 17.2667 27.8867 16.8467 27.6267 16.5867Z\"/></svg>');\n --vuu-svg-text-Tt: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 24\"><path d=\"M17.6667 7.66666C17.6667 8.21999 18.1133 8.66666 18.6667 8.66666H21V15.6667C21 16.22 21.4467 16.6667 22 16.6667C22.5533 16.6667 23 16.22 23 15.6667V8.66666H25.3333C25.8867 8.66666 26.3333 8.21999 26.3333 7.66666C26.3333 7.11332 25.8867 6.66666 25.3333 6.66666H18.6667C18.1133 6.66666 17.6667 7.11332 17.6667 7.66666ZM29.3333 9.99999H25.3333C24.78 9.99999 24.3333 10.4467 24.3333 11C24.3333 11.5533 24.78 12 25.3333 12H26.3333V15.6667C26.3333 16.22 26.78 16.6667 27.3333 16.6667C27.8867 16.6667 28.3333 16.22 28.3333 15.6667V12H29.3333C29.8867 12 30.3333 11.5533 30.3333 11C30.3333 10.4467 29.8867 9.99999 29.3333 9.99999Z\" /></svg>');\n --vuu-svg-text-T: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 24\"><path d=\"M19.3333 7.66666C19.3333 8.21999 19.78 8.66666 20.3333 8.66666H23V15.6667C23 16.22 23.4467 16.6667 24 16.6667C24.5533 16.6667 25 16.22 25 15.6667V8.66666H27.6667C28.22 8.66666 28.6667 8.21999 28.6667 7.66666C28.6667 7.11332 28.22 6.66666 27.6667 6.66666H20.3333C19.78 6.66666 19.3333 7.11332 19.3333 7.66666Z\"/></svg>');\n --vuu-svg-stripes: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><rect x=\"2\" y=\"2\" width=\"12\" height=\"2\" rx=\"0.3\"/><rect x=\"2\" y=\"5\" width=\"12\" height=\"2\" rx=\"0.3\"/><rect x=\"2\" y=\"8\" width=\"12\" height=\"2\" rx=\"0.3\"/><rect x=\"2\" y=\"11\" width=\"12\" height=\"2\" rx=\"0.3\"/></svg>');\n --vuu-svg-row-lines: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><rect x=\"2\" y=\"3\" width=\"12\" height=\"1\" rx=\"0.3\" /><rect x=\"2\" y=\"6\" width=\"12\" height=\"1\" rx=\"0.3\" /><rect x=\"2\" y=\"9\" width=\"12\" height=\"1\" rx=\"0.3\" /><rect x=\"2\" y=\"12\" width=\"12\" height=\"1\" rx=\"0.3\"/></svg>');\n --vuu-svg-col-lines: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><rect x=\"3\" y=\"14\" width=\"12\" height=\"1\" rx=\"0.3\" transform=\"rotate(-90 3 14)\"/><rect x=\"6\" y=\"14\" width=\"12\" height=\"1\" rx=\"0.3\" transform=\"rotate(-90 6 14)\"/><rect x=\"9\" y=\"14\" width=\"12\" height=\"1\" rx=\"0.3\" transform=\"rotate(-90 9 14)\"/><rect x=\"12\" y=\"14\" width=\"12\" height=\"1\" rx=\"0.3\" transform=\"rotate(-90 12 14)\"/></svg>');\n\n display: flex;\n flex-direction: column;\n gap: 24px;\n height: 100%;\n max-width: 254px;\n padding: 24px 2px 0 2px;\n}\n\n\n.vuuTableSettingsPanel [data-icon=\"text-strikethrough\"]{\n --vuu-icon-svg: var(--vuu-svg-text-strikethrough);\n}\n.vuuTableSettingsPanel [data-icon=\"text-Tt\"]{\n --vuu-icon-svg: var(--vuu-svg-text-Tt);\n}\n.vuuTableSettingsPanel [data-icon=\"text-T\"]{\n --vuu-icon-svg: var(--vuu-svg-text-T);\n}\n.vuuTableSettingsPanel [data-icon=\"col-lines\"]{\n --vuu-icon-svg: var(--vuu-svg-col-lines);\n}\n.vuuTableSettingsPanel [data-icon=\"row-lines\"]{\n --vuu-icon-svg: var(--vuu-svg-row-lines);\n}\n.vuuTableSettingsPanel [data-icon=\"row-striping\"]{\n --vuu-icon-svg: var(--vuu-svg-stripes);\n}\n\n.vuuTableSettingsPanel-header {\n border-top: solid 2px var(--vuu-color-gray-30);\n font-size: 14px;\n font-weight: 600;\n padding-top: 24px;\n}\n\n.vuuTableSettingsPanel .vuuColumnList {\n flex-grow: 1;\n flex-shrink: 1;\n flex-basis: 0;\n}\n\n.vuuTableSettingsPanel-calculatedButtonbar {\n --vuu-icon-size: 16px;\n --saltButton-height: 24px;\n --saltButton-width: 24px;\n align-items: center;\n display: flex;\n flex: 0 0 32px;\n gap: 12px;\n}\n\n\n\n\n\n\n";
1246
+
1247
+ const classBase$9 = "vuuTableSettingsPanel";
1248
+ const defaultTableSettingsPermissions = {
1249
+ allowColumnLabelCase: true,
1250
+ allowColumnDefaultWidth: true,
1251
+ allowGridSeparators: true,
1252
+ allowReorderColumns: true,
1253
+ allowRemoveColumns: true,
1254
+ allowHideColumns: true,
1255
+ allowCalculatedColumns: true
1256
+ };
1257
+ const TableSettingsPanel = ({
1258
+ availableColumns,
1259
+ onAddCalculatedColumn,
1260
+ onConfigChange,
1261
+ onDataSourceConfigChange,
1262
+ onNavigateToColumn,
1263
+ tableConfig: tableConfigProp,
1264
+ permissions = defaultTableSettingsPermissions
1265
+ }) => {
1266
+ const targetWindow = window.useWindow();
1267
+ styles.useComponentCssInjection({
1268
+ testId: "vuu-table-settings-panel",
1269
+ css: tableSettingsPanelCss,
1270
+ window: targetWindow
1271
+ });
1272
+ const {
1273
+ columnItems,
1274
+ columnLabelsValue,
1275
+ onChangeColumnLabels,
1276
+ onChangeTableAttribute,
1277
+ onReorderColumnItems,
1278
+ onColumnChange,
1279
+ onCommitColumnWidth,
1280
+ tableConfig
1281
+ } = useTableSettings({
1282
+ availableColumns,
1283
+ onConfigChange,
1284
+ onDataSourceConfigChange,
1285
+ tableConfig: tableConfigProp
1286
+ });
1287
+ const {
1288
+ allowColumnLabelCase = true,
1289
+ allowColumnDefaultWidth = true,
1290
+ allowGridSeparators = true,
1291
+ allowCalculatedColumns,
1292
+ ...columnListPermissions
1293
+ } = permissions;
1294
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classBase$9, children: [
1295
+ allowColumnLabelCase || allowColumnDefaultWidth || allowGridSeparators ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase$9}-header`, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Column Settings" }) }) : null,
1296
+ allowColumnDefaultWidth ? /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { children: [
1297
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Column Width" }),
1298
+ /* @__PURE__ */ jsxRuntime.jsx(
1299
+ vuuUiControls.VuuInput,
1300
+ {
1301
+ className: "vuuInput",
1302
+ "data-embedded": true,
1303
+ onCommit: onCommitColumnWidth
1304
+ }
1305
+ )
1306
+ ] }) : null,
1307
+ allowColumnLabelCase ? /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { children: [
1308
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Column Labels" }),
1309
+ /* @__PURE__ */ jsxRuntime.jsxs(
1310
+ core.ToggleButtonGroup,
1311
+ {
1312
+ className: "vuuToggleButtonGroup",
1313
+ onChange: onChangeColumnLabels,
1314
+ value: columnLabelsValue,
1315
+ children: [
1316
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { className: "vuuIconToggleButton", value: 0, children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "text-strikethrough", size: 48 }) }),
1317
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { className: "vuuIconToggleButton", value: 1, children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "text-Tt", size: 48 }) }),
1318
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { className: "vuuIconToggleButton", value: 2, children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "text-T", size: 48 }) })
1319
+ ]
1320
+ }
1321
+ )
1322
+ ] }) : null,
1323
+ allowGridSeparators ? /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { children: [
1324
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Grid separators" }),
1325
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "saltToggleButtonGroup vuuStateButtonGroup saltToggleButtonGroup-horizontal", children: [
1326
+ /* @__PURE__ */ jsxRuntime.jsx(
1327
+ core.ToggleButton,
1328
+ {
1329
+ selected: tableConfig.zebraStripes ?? false,
1330
+ onChange: onChangeTableAttribute,
1331
+ value: "zebraStripes",
1332
+ children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "row-striping", size: 16 })
1333
+ }
1334
+ ),
1335
+ /* @__PURE__ */ jsxRuntime.jsx(
1336
+ core.ToggleButton,
1337
+ {
1338
+ selected: tableConfig.rowSeparators ?? false,
1339
+ onChange: onChangeTableAttribute,
1340
+ value: "rowSeparators",
1341
+ children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "row-lines", size: 16 })
1342
+ }
1343
+ ),
1344
+ /* @__PURE__ */ jsxRuntime.jsx(
1345
+ core.ToggleButton,
1346
+ {
1347
+ selected: tableConfig.columnSeparators ?? false,
1348
+ onChange: onChangeTableAttribute,
1349
+ value: "columnSeparators",
1350
+ children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "col-lines", size: 16 })
1351
+ }
1352
+ )
1353
+ ] })
1354
+ ] }) : null,
1355
+ /* @__PURE__ */ jsxRuntime.jsx(
1356
+ ColumnList,
1357
+ {
1358
+ columnItems,
1359
+ permissions: columnListPermissions,
1360
+ onChange: onColumnChange,
1361
+ onNavigateToColumn,
1362
+ onReorderColumnItems
1363
+ }
1364
+ ),
1365
+ allowCalculatedColumns ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classBase$9}-calculatedButtonbar`, children: [
1366
+ /* @__PURE__ */ jsxRuntime.jsx(core.Button, { "data-icon": "plus", onClick: onAddCalculatedColumn }),
1367
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase$9}-calculatedLabel`, children: "Add calculated column" })
1368
+ ] }) : null
1369
+ ] });
1370
+ };
1371
+
1372
+ const classBase$8 = "vuuColumnMenu";
1373
+ const defaultColumnMenuPermissions = {
1374
+ allowSort: true,
1375
+ allowGroup: true,
1376
+ allowAggregation: true,
1377
+ allowHide: true,
1378
+ allowPin: true,
1379
+ allowColumnSettings: true,
1380
+ allowTableSettings: defaultTableSettingsPermissions
1381
+ };
1382
+ const ColumnMenu = ({
1383
+ className,
1384
+ column,
1385
+ menuActionHandler: menuActionHandlerProp,
1386
+ menuPermissions: {
1387
+ allowSort,
1388
+ allowGroup,
1389
+ allowAggregation,
1390
+ allowHide,
1391
+ allowPin,
1392
+ allowColumnSettings,
1393
+ allowTableSettings
1394
+ } = defaultColumnMenuPermissions
1395
+ }) => {
1396
+ const targetWindow = window.useWindow();
1397
+ styles.useComponentCssInjection({
1398
+ testId: "vuu-column-menu",
1399
+ css: columnMenuCss,
1400
+ window: targetWindow
1401
+ });
1402
+ const { dataSource, menuActionHandler } = useTableContext(true);
1403
+ const menuActionClickHandler = react.useCallback(
1404
+ (evt) => {
1405
+ const columnMenuActionType = getColumnMenuActionType(evt.target);
1406
+ if (menuActionHandlerProp?.(columnMenuActionType, column) !== true) {
1407
+ return menuActionHandler(columnMenuActionType, column);
1408
+ }
1409
+ },
1410
+ [column, menuActionHandler, menuActionHandlerProp]
1411
+ );
1412
+ const sortMenu = buildSortMenu(
1413
+ column,
1414
+ dataSource,
1415
+ menuActionClickHandler,
1416
+ allowSort
1417
+ );
1418
+ const groupMenu = buildGroupMenu(
1419
+ column,
1420
+ dataSource,
1421
+ menuActionClickHandler,
1422
+ allowGroup
1423
+ );
1424
+ const aggregationMenu = buildAggregationMenuItems(
1425
+ column,
1426
+ dataSource,
1427
+ menuActionClickHandler,
1428
+ allowAggregation
1429
+ );
1430
+ const visibilityMenuItems = buildVisibilityMenuItems(
1431
+ column,
1432
+ menuActionClickHandler,
1433
+ allowHide
1434
+ );
1435
+ const pinMenu = buildPinMenuItems(column, menuActionClickHandler, allowPin);
1436
+ const settingsMenuItems = buildSettingsMenuItems(
1437
+ column,
1438
+ menuActionClickHandler,
1439
+ allowColumnSettings,
1440
+ allowTableSettings
1441
+ );
1442
+ const handleClick = react.useCallback(
1443
+ (evt) => {
1444
+ evt.stopPropagation();
1445
+ },
1446
+ []
1447
+ );
1448
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Menu, { children: [
1449
+ /* @__PURE__ */ jsxRuntime.jsx(core.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
1450
+ vuuUiControls.IconButton,
1451
+ {
1452
+ appearance: "transparent",
1453
+ className: cx(classBase$8, className),
1454
+ "data-embedded": true,
1455
+ icon: "more-vert",
1456
+ sentiment: "neutral",
1457
+ "aria-label": "Open Column Menu",
1458
+ onClick: handleClick
1459
+ }
1460
+ ) }),
1461
+ /* @__PURE__ */ jsxRuntime.jsxs(core.MenuPanel, { children: [
1462
+ sortMenu,
1463
+ groupMenu,
1464
+ aggregationMenu,
1465
+ visibilityMenuItems,
1466
+ pinMenu,
1467
+ settingsMenuItems
1468
+ ] })
1469
+ ] });
1470
+ };
1471
+
1472
+ const { Average, Count, Distinct, High, Low, Sum } = vuuUtils.AggregationType;
1473
+ const useColumnActions = ({
1474
+ dataSource,
1475
+ onColumnDisplayAction,
1476
+ onDisplaySettingsAction
1477
+ }) => {
1478
+ const handleContextMenuAction = (columnMenuActionType, column) => {
1479
+ if (column && dataSource) {
1480
+ switch (columnMenuActionType) {
1481
+ // 1) DataSource operations ...
1482
+ case "sort-asc":
1483
+ return dataSource.sort = vuuUtils.setSortColumn(dataSource.sort, column, "A"), true;
1484
+ case "sort-dsc":
1485
+ return dataSource.sort = vuuUtils.setSortColumn(dataSource.sort, column, "D"), true;
1486
+ case "remove-sort":
1487
+ return dataSource.sort = { sortDefs: [] }, true;
1488
+ case "sort-add-asc":
1489
+ return dataSource.sort = vuuUtils.addSortColumn(dataSource.sort, column, "A"), true;
1490
+ case "sort-add-dsc":
1491
+ return dataSource.sort = vuuUtils.addSortColumn(dataSource.sort, column, "D"), true;
1492
+ case "group-column":
1493
+ return dataSource.groupBy = vuuUtils.addGroupColumn(dataSource.groupBy ?? [], column), true;
1494
+ case "add-to-group":
1495
+ return dataSource.groupBy = vuuUtils.addGroupColumn(dataSource.groupBy ?? [], column), true;
1496
+ case "remove-group":
1497
+ return dataSource.groupBy = [], true;
1498
+ case "remove-from-group":
1499
+ return dataSource.groupBy = vuuUtils.removeGroupColumn(dataSource.groupBy ?? [], column), true;
1500
+ case "remove-column":
1501
+ return dataSource.columns = dataSource.columns.filter((name) => name !== column.name), true;
1502
+ // case "filter-remove-column": return (dataSource.filter = removeFilterColumn(dataSource.filter, column)), true;
1503
+ // case "remove-filters": return (dataSource.filter = {filter:""}), true;
1504
+ case "agg-avg":
1505
+ return dataSource.aggregations = vuuUtils.setAggregations(dataSource.aggregations, column, Average), true;
1506
+ case "agg-high":
1507
+ return dataSource.aggregations = vuuUtils.setAggregations(dataSource.aggregations, column, High), true;
1508
+ case "agg-low":
1509
+ return dataSource.aggregations = vuuUtils.setAggregations(dataSource.aggregations, column, Low), true;
1510
+ case "agg-count":
1511
+ return dataSource.aggregations = vuuUtils.setAggregations(dataSource.aggregations, column, Count), true;
1512
+ case "agg-distinct":
1513
+ return dataSource.aggregations = vuuUtils.setAggregations(dataSource.aggregations, column, Distinct), true;
1514
+ case "agg-sum":
1515
+ return dataSource.aggregations = vuuUtils.setAggregations(dataSource.aggregations, column, Sum), true;
1516
+ // 2) Column display options ...
1517
+ case "hide-column":
1518
+ return onColumnDisplayAction?.({ type: "hideColumn", column }), true;
1519
+ case "pin-column-floating":
1520
+ return onColumnDisplayAction?.({ type: "pinColumn", column, pin: "floating" }), true;
1521
+ case "pin-column-left":
1522
+ return onColumnDisplayAction?.({ type: "pinColumn", column, pin: "left" }), true;
1523
+ case "pin-column-right":
1524
+ return onColumnDisplayAction?.({ type: "pinColumn", column, pin: "right" }), true;
1525
+ case "unpin-column":
1526
+ return onColumnDisplayAction?.({ type: "pinColumn", column, pin: false }), true;
1527
+ // 3) Table Admin options ...
1528
+ case "column-settings":
1529
+ return onDisplaySettingsAction?.({ type: "column-settings", column }), true;
1530
+ case "table-settings":
1531
+ return onDisplaySettingsAction?.({ type: "table-settings" }), true;
1532
+ default:
1533
+ vuuUtils.logUnhandledMessage(columnMenuActionType, `[vuu-table-extras] useColumnActions handleContextMenuAction, unhandled columnMenuActionType`);
1534
+ }
1535
+ }
1536
+ return false;
1537
+ };
1538
+ return handleContextMenuAction;
1539
+ };
1540
+
1541
+ const parser = lr.LRParser.deserialize({
1542
+ version: 14,
1543
+ states: "&xOVQPOOO!fQPO'#C^OVQPO'#CcQ!pQPOOO#bQPO'#CkO#gQPO'#CrOOQO'#Cy'#CyO#lQPO,58}OVQPO,59QOVQPO,59QOOQO'#Cn'#CnOVQPO,59XOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO$bQPO1G.lO%ZQPO1G.sO!pQPO'#CmO%qQQO1G.qO%|QQO'#C{OOQO'#C{'#C{O&wQPO,59`OVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO'RQPO1G.zOOQO1G.z1G.zO'ZQQO'#C^O'eQQO1G.sO'{QQO1G.uOOQO1G.v1G.vO(WQPO<<GwO(_QPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(iQQO1G.lO(yQPOG22}OOQOLD(iLD(iO)QQPO,59QO)QQPO,59QO)QQPO,59X",
1544
+ stateData: ")n~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXpQXqQXrQXsQXtQXuQXeQX~OjQXXQX~PnOZWO[WO]XO^XOpYOqYOrYOsYOtYOuYO~OW[O~OW]O~OX_O~P!pO]Yi^YipYiqYirYisYitYiuYieYi~OZWO[WOjYiXYi~P#sOpaiqairaisaitaiuaieai~OZWO[WO]XO^XOjaiXai~P$rOejOvhOwiO~OZmX[mX]mX^mXeoXpmXqmXrmXsmXtmXumXvoXwoX~OXmOekO~P!pOXuOekO~OvQXwQX~PnOZzO[zO]{O^{Ovaiwai~P$rOwiOecivci~OevO~P!pOXiaeia~P!pOZzO[zOvYiwYi~P#sOXyO~P!pORUOSUOTUOUUOWQO`SOnnO~O`UTn~",
1545
+ goto: "$epPPqPPPPqPPqPPPPqP!S!g!r!rPq!w#Y#]PPP#cP$[oUOQWXZ[]hijkvz{|hUOQWXZ]jkvz{|Ve[hi[ZRVgrsxR|cVf[hioTOQWXZ[]hijkvz{|R^TQlgRtlQROQVQS`WzQaXQbZUc[hiQg]Qo|QrjQskQw{RxvQd[QphRqi",
1546
+ 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",
1547
+ maxTerm: 39,
1548
+ skippedNodes: [0],
1549
+ repeatNodeCount: 1,
1550
+ 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",
1551
+ tokenizers: [0, 1],
1552
+ topRules: { "ColumnDefinitionExpression": [0, 1] },
1553
+ tokenPrec: 393
1554
+ });
1555
+
1556
+ const columnExpressionLanguage = vuuCodemirror.LRLanguage.define({
1557
+ name: "VuuColumnExpression",
1558
+ parser: parser.configure({
1559
+ props: [
1560
+ vuuCodemirror.styleTags({
1561
+ Column: vuuCodemirror.tags.attributeValue,
1562
+ Function: vuuCodemirror.tags.variableName,
1563
+ String: vuuCodemirror.tags.string,
1564
+ Or: vuuCodemirror.tags.emphasis,
1565
+ Operator: vuuCodemirror.tags.operator
1566
+ })
1567
+ ]
1568
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1569
+ })
1570
+ });
1571
+ const columnExpressionLanguageSupport = () => {
1572
+ return new vuuCodemirror.LanguageSupport(
1573
+ columnExpressionLanguage
1574
+ );
1575
+ };
1576
+
1577
+ var __defProp = Object.defineProperty;
1578
+ var __typeError = (msg) => {
1579
+ throw TypeError(msg);
1580
+ };
1581
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1582
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1583
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
1584
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1585
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1586
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
1587
+ var _expressions, _op, _expressions2, _expressions3, _op2, _expressions4, _op3, _expressions5, _expression, _callStack;
1588
+ class LiteralExpressionImpl {
1589
+ constructor(value) {
1590
+ __publicField(this, "type");
1591
+ __publicField(this, "value");
1592
+ this.value = value;
1593
+ switch (typeof value) {
1594
+ case "boolean":
1595
+ this.type = "booleanLiteralExpression";
1596
+ break;
1597
+ case "number":
1598
+ this.type = "numericLiteralExpression";
1599
+ break;
1600
+ default:
1601
+ this.type = "stringLiteralExpression";
1602
+ }
1603
+ }
1604
+ toJSON() {
1605
+ return {
1606
+ type: this.type,
1607
+ value: this.value
1608
+ };
1609
+ }
1610
+ }
1611
+ class ColumnExpressionImpl {
1612
+ constructor(columnName) {
1613
+ __publicField(this, "type", "colExpression");
1614
+ __publicField(this, "column");
1615
+ this.column = columnName;
1616
+ }
1617
+ toJSON() {
1618
+ return {
1619
+ type: this.type,
1620
+ column: this.column
1621
+ };
1622
+ }
1623
+ }
1624
+ class ArithmeticExpressionImpl {
1625
+ constructor(op = "unknown") {
1626
+ __privateAdd(this, _expressions, [
1627
+ { type: "unknown" },
1628
+ { type: "unknown" }
1629
+ ]);
1630
+ __privateAdd(this, _op);
1631
+ __publicField(this, "type", "arithmeticExpression");
1632
+ __privateSet(this, _op, op);
1633
+ }
1634
+ get op() {
1635
+ return __privateGet(this, _op);
1636
+ }
1637
+ set op(op) {
1638
+ __privateSet(this, _op, op);
1639
+ }
1640
+ get expressions() {
1641
+ return __privateGet(this, _expressions);
1642
+ }
1643
+ toJSON() {
1644
+ return {
1645
+ type: this.type,
1646
+ op: __privateGet(this, _op),
1647
+ expressions: __privateGet(this, _expressions)
1648
+ };
1649
+ }
1650
+ }
1651
+ _expressions = new WeakMap();
1652
+ _op = new WeakMap();
1653
+ class CallExpressionImpl {
1654
+ constructor(functionName) {
1655
+ __privateAdd(this, _expressions2, []);
1656
+ __publicField(this, "functionName");
1657
+ __publicField(this, "type", "callExpression");
1658
+ this.functionName = functionName;
1659
+ }
1660
+ get expressions() {
1661
+ return __privateGet(this, _expressions2);
1662
+ }
1663
+ get arguments() {
1664
+ return __privateGet(this, _expressions2);
1665
+ }
1666
+ toJSON() {
1667
+ return {
1668
+ type: this.type,
1669
+ functionName: this.functionName,
1670
+ arguments: __privateGet(this, _expressions2).map((e) => e.toJSON?.())
1671
+ };
1672
+ }
1673
+ }
1674
+ _expressions2 = new WeakMap();
1675
+ class RelationalExpressionImpl {
1676
+ constructor() {
1677
+ __privateAdd(this, _expressions3, [
1678
+ { type: "unknown" },
1679
+ { type: "unknown" }
1680
+ ]);
1681
+ __privateAdd(this, _op2, "unknown");
1682
+ __publicField(this, "type", "relationalExpression");
1683
+ }
1684
+ get op() {
1685
+ return __privateGet(this, _op2);
1686
+ }
1687
+ set op(op) {
1688
+ __privateSet(this, _op2, op);
1689
+ }
1690
+ get expressions() {
1691
+ return __privateGet(this, _expressions3);
1692
+ }
1693
+ toJSON() {
1694
+ return {
1695
+ type: this.type,
1696
+ op: __privateGet(this, _op2),
1697
+ expressions: __privateGet(this, _expressions3)
1698
+ };
1699
+ }
1700
+ }
1701
+ _expressions3 = new WeakMap();
1702
+ _op2 = new WeakMap();
1703
+ class BooleanConditionImp {
1704
+ constructor(booleanOperator) {
1705
+ __privateAdd(this, _expressions4, [
1706
+ { type: "unknown" },
1707
+ { type: "unknown" }
1708
+ ]);
1709
+ __privateAdd(this, _op3);
1710
+ __publicField(this, "type", "booleanCondition");
1711
+ __privateSet(this, _op3, booleanOperator);
1712
+ }
1713
+ get op() {
1714
+ return __privateGet(this, _op3);
1715
+ }
1716
+ get expressions() {
1717
+ return __privateGet(this, _expressions4);
1718
+ }
1719
+ toJSON() {
1720
+ return {
1721
+ type: this.type,
1722
+ op: __privateGet(this, _op3),
1723
+ expressions: __privateGet(this, _expressions4).map((e) => e.toJSON?.())
1724
+ };
1725
+ }
1726
+ }
1727
+ _expressions4 = new WeakMap();
1728
+ _op3 = new WeakMap();
1729
+ class ConditionalExpressionImpl {
1730
+ constructor(booleanOperator) {
1731
+ __privateAdd(this, _expressions5);
1732
+ __publicField(this, "type", "conditionalExpression");
1733
+ __privateSet(this, _expressions5, [
1734
+ booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
1735
+ { type: "unknown" },
1736
+ { type: "unknown" }
1737
+ ]);
1738
+ }
1739
+ get expressions() {
1740
+ return __privateGet(this, _expressions5);
1741
+ }
1742
+ get condition() {
1743
+ return __privateGet(this, _expressions5)[0];
1744
+ }
1745
+ get truthyExpression() {
1746
+ return __privateGet(this, _expressions5)[1];
1747
+ }
1748
+ set truthyExpression(expression) {
1749
+ __privateGet(this, _expressions5)[1] = expression;
1750
+ }
1751
+ get falsyExpression() {
1752
+ return __privateGet(this, _expressions5)[2];
1753
+ }
1754
+ set falsyExpression(expression) {
1755
+ __privateGet(this, _expressions5)[2] = expression;
1756
+ }
1757
+ toJSON() {
1758
+ return {
1759
+ type: this.type,
1760
+ condition: this.condition.toJSON?.(),
1761
+ truthyExpression: this.truthyExpression,
1762
+ falsyExpression: this.falsyExpression?.toJSON?.() ?? this.falsyExpression
1763
+ };
1764
+ }
1765
+ }
1766
+ _expressions5 = new WeakMap();
1767
+ const isUnknown = (e) => e.type === "unknown";
1768
+ const isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
1769
+ const isCallExpression = (expression) => expression.type === "callExpression";
1770
+ const isConditionalExpression = (expression) => expression.type === "conditionalExpression";
1771
+ const isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
1772
+ const isBooleanCondition = (expression) => expression.type === "booleanCondition";
1773
+ const isRelationalExpression = (expression) => expression?.type === "relationalExpression";
1774
+ const firstIncompleteExpression = (expression) => {
1775
+ if (isUnknown(expression)) {
1776
+ return expression;
1777
+ } else if (isRelationalExpression(expression)) {
1778
+ const [operand1, operand2] = expression.expressions;
1779
+ if (expressionIsIncomplete(operand1)) {
1780
+ return firstIncompleteExpression(operand1);
1781
+ } else if (expression.op === "unknown") {
1782
+ return expression;
1783
+ } else if (expressionIsIncomplete(operand2)) {
1784
+ return firstIncompleteExpression(operand2);
1785
+ }
1786
+ } else if (isCondition(expression)) {
1787
+ const { expressions = [] } = expression;
1788
+ for (const e of expressions) {
1789
+ if (expressionIsIncomplete(e)) {
1790
+ return firstIncompleteExpression(e);
1791
+ }
1792
+ }
1793
+ } else if (isConditionalExpression(expression)) {
1794
+ const { condition, truthyExpression, falsyExpression } = expression;
1795
+ if (expressionIsIncomplete(condition)) {
1796
+ return firstIncompleteExpression(condition);
1797
+ } else if (expressionIsIncomplete(truthyExpression)) {
1798
+ return firstIncompleteExpression(truthyExpression);
1799
+ } else if (expressionIsIncomplete(falsyExpression)) {
1800
+ return firstIncompleteExpression(falsyExpression);
1801
+ }
1802
+ } else if (isArithmeticExpression(expression)) {
1803
+ const { expressions = [] } = expression;
1804
+ for (const e of expressions) {
1805
+ if (expressionIsIncomplete(e)) {
1806
+ return firstIncompleteExpression(e);
1807
+ }
1808
+ }
1809
+ }
1810
+ };
1811
+ const replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
1812
+ const { expressions = [] } = incompleteExpression;
1813
+ if (expressions.includes(unknownExpression)) {
1814
+ const pos = expressions.indexOf(unknownExpression);
1815
+ expressions.splice(pos, 1, expression);
1816
+ return true;
1817
+ } else {
1818
+ for (const e of expressions) {
1819
+ if (replaceUnknownExpression(e, unknownExpression, expression)) {
1820
+ return true;
1821
+ }
1822
+ }
1823
+ }
1824
+ return false;
1825
+ };
1826
+ const expressionIsIncomplete = (expression) => {
1827
+ if (isUnknown(expression)) {
1828
+ return true;
1829
+ } else if (isConditionalExpression(expression)) {
1830
+ return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
1831
+ } else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
1832
+ return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
1833
+ }
1834
+ return false;
1835
+ };
1836
+ const addExpression = (expression, subExpression) => {
1837
+ const targetExpression = firstIncompleteExpression(expression);
1838
+ if (targetExpression) {
1839
+ if (targetExpression.expressions) {
1840
+ targetExpression.expressions.push(subExpression);
1841
+ } else {
1842
+ console.warn("don't know how to treat targetExpression");
1843
+ }
1844
+ } else {
1845
+ console.error("no target expression found");
1846
+ }
1847
+ };
1848
+ class ColumnExpression {
1849
+ constructor() {
1850
+ __privateAdd(this, _expression);
1851
+ __privateAdd(this, _callStack, []);
1852
+ }
1853
+ setCondition(booleanOperator) {
1854
+ if (__privateGet(this, _expression) === void 0) {
1855
+ this.addExpression(new ConditionalExpressionImpl(booleanOperator));
1856
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
1857
+ if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
1858
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
1859
+ this.addExpression(condition);
1860
+ } else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
1861
+ __privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
1862
+ booleanOperator
1863
+ );
1864
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
1865
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
1866
+ this.addExpression(condition);
1867
+ } else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
1868
+ __privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
1869
+ booleanOperator
1870
+ );
1871
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
1872
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
1873
+ this.addExpression(condition);
1874
+ }
1875
+ } else {
1876
+ console.error("setCondition called unexpectedly");
1877
+ }
1878
+ }
1879
+ addExpression(expression) {
1880
+ if (__privateGet(this, _callStack).length > 0) {
1881
+ const currentCallExpression = __privateGet(this, _callStack).at(-1);
1882
+ currentCallExpression?.arguments.push(expression);
1883
+ } else if (__privateGet(this, _expression) === void 0) {
1884
+ __privateSet(this, _expression, expression);
1885
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
1886
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1887
+ if (targetExpression && isUnknown(targetExpression)) {
1888
+ replaceUnknownExpression(
1889
+ __privateGet(this, _expression),
1890
+ targetExpression,
1891
+ expression
1892
+ );
1893
+ }
1894
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
1895
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
1896
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1897
+ if (targetExpression && isUnknown(targetExpression)) {
1898
+ replaceUnknownExpression(
1899
+ __privateGet(this, _expression),
1900
+ targetExpression,
1901
+ expression
1902
+ );
1903
+ } else if (targetExpression) {
1904
+ addExpression(targetExpression, expression);
1905
+ }
1906
+ }
1907
+ }
1908
+ }
1909
+ setFunction(functionName) {
1910
+ const callExpression = new CallExpressionImpl(functionName);
1911
+ this.addExpression(callExpression);
1912
+ __privateGet(this, _callStack).push(callExpression);
1913
+ }
1914
+ setColumn(columnName) {
1915
+ this.addExpression(new ColumnExpressionImpl(columnName));
1916
+ }
1917
+ setArithmeticOp(value) {
1918
+ const op = value;
1919
+ const expression = __privateGet(this, _expression);
1920
+ if (isArithmeticExpression(expression)) {
1921
+ expression.op = op;
1922
+ }
1923
+ }
1924
+ setRelationalOperator(value) {
1925
+ const op = value;
1926
+ if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
1927
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1928
+ if (isRelationalExpression(targetExpression)) {
1929
+ targetExpression.op = op;
1930
+ } else {
1931
+ console.error(`no target expression found (op = ${value})`);
1932
+ }
1933
+ }
1934
+ }
1935
+ setValue(value) {
1936
+ const literalExpression = new LiteralExpressionImpl(value);
1937
+ if (__privateGet(this, _expression) === void 0) {
1938
+ __privateSet(this, _expression, literalExpression);
1939
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
1940
+ this.addExpression(literalExpression);
1941
+ } else if (isCallExpression(__privateGet(this, _expression))) {
1942
+ __privateGet(this, _expression).arguments.push(literalExpression);
1943
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
1944
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
1945
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
1946
+ if (targetExpression && isUnknown(targetExpression)) {
1947
+ replaceUnknownExpression(
1948
+ __privateGet(this, _expression),
1949
+ targetExpression,
1950
+ literalExpression
1951
+ );
1952
+ } else if (targetExpression) {
1953
+ addExpression(targetExpression, literalExpression);
1954
+ }
1955
+ } else {
1956
+ console.log("what do we do with value, in a complete expression");
1957
+ }
1958
+ }
1959
+ }
1960
+ closeBrace() {
1961
+ __privateGet(this, _callStack).pop();
1962
+ }
1963
+ get expression() {
1964
+ return __privateGet(this, _expression);
1965
+ }
1966
+ toJSON() {
1967
+ return __privateGet(this, _expression)?.toJSON();
1968
+ }
1969
+ }
1970
+ _expression = new WeakMap();
1971
+ _callStack = new WeakMap();
1972
+ const walkTree = (tree, source) => {
1973
+ const columnExpression = new ColumnExpression();
1974
+ const cursor = tree.cursor();
1975
+ do {
1976
+ const { name, from, to } = cursor;
1977
+ switch (name) {
1978
+ case "AndCondition":
1979
+ columnExpression.setCondition("and");
1980
+ break;
1981
+ case "OrCondition":
1982
+ columnExpression.setCondition("or");
1983
+ break;
1984
+ case "RelationalExpression":
1985
+ columnExpression.setCondition();
1986
+ break;
1987
+ case "ArithmeticExpression":
1988
+ columnExpression.addExpression(new ArithmeticExpressionImpl());
1989
+ break;
1990
+ case "Column":
1991
+ {
1992
+ const columnName = source.substring(from, to);
1993
+ columnExpression.setColumn(columnName);
1994
+ }
1995
+ break;
1996
+ case "Function":
1997
+ {
1998
+ const functionName = source.substring(from, to);
1999
+ columnExpression.setFunction(functionName);
2000
+ }
2001
+ break;
2002
+ case "Times":
2003
+ case "Divide":
2004
+ case "Plus":
2005
+ case "Minus":
2006
+ {
2007
+ const op = source.substring(from, to);
2008
+ columnExpression.setArithmeticOp(op);
2009
+ }
2010
+ break;
2011
+ case "RelationalOperator":
2012
+ {
2013
+ const op = source.substring(from, to);
2014
+ columnExpression.setRelationalOperator(op);
2015
+ }
2016
+ break;
2017
+ case "False":
2018
+ case "True":
2019
+ {
2020
+ const value = source.substring(from, to);
2021
+ columnExpression.setValue(value === "true" ? true : false);
2022
+ }
2023
+ break;
2024
+ case "String":
2025
+ columnExpression.setValue(source.substring(from + 1, to - 1));
2026
+ break;
2027
+ case "Number":
2028
+ columnExpression.setValue(parseFloat(source.substring(from, to)));
2029
+ break;
2030
+ case "CloseBrace":
2031
+ columnExpression.closeBrace();
2032
+ break;
2033
+ }
2034
+ } while (cursor.next());
2035
+ return columnExpression.toJSON();
2036
+ };
2037
+
2038
+ const strictParser = parser.configure({ strict: true });
2039
+ const RelationalOperands = ["Number", "String"];
2040
+ const ColumnNamedTerms = [
2041
+ ...RelationalOperands,
2042
+ "AndCondition",
2043
+ "ArithmeticExpression",
2044
+ "BooleanOperator",
2045
+ "RelationalOperatorOperator",
2046
+ "CallExpression",
2047
+ "CloseBrace",
2048
+ "Column",
2049
+ "Comma",
2050
+ "ConditionalExpression",
2051
+ "Divide",
2052
+ "Equal",
2053
+ "If",
2054
+ "Minus",
2055
+ "OpenBrace",
2056
+ "OrCondition",
2057
+ "ParenthesizedExpression",
2058
+ "Plus",
2059
+ "RelationalExpression",
2060
+ "RelationalOperator",
2061
+ "Times"
2062
+ ];
2063
+ const isCompleteExpression = (src) => {
2064
+ try {
2065
+ strictParser.parse(src);
2066
+ return true;
2067
+ } catch (err) {
2068
+ return false;
2069
+ }
2070
+ };
2071
+ const lastNamedChild = (node) => {
2072
+ let { lastChild } = node;
2073
+ while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
2074
+ lastChild = lastChild.prevSibling;
2075
+ console.log(lastChild?.name);
2076
+ }
2077
+ return lastChild;
2078
+ };
2079
+ const isCompleteRelationalExpression = (node) => {
2080
+ if (node?.name === "RelationalExpression") {
2081
+ const { firstChild } = node;
2082
+ const lastChild = lastNamedChild(node);
2083
+ if (firstChild?.name === "Column" && typeof lastChild?.name === "string" && RelationalOperands.includes(lastChild.name)) {
2084
+ return true;
2085
+ }
2086
+ }
2087
+ return false;
2088
+ };
2089
+
2090
+ const myHighlightStyle = vuuCodemirror.HighlightStyle.define([
2091
+ {
2092
+ tag: vuuCodemirror.tags.attributeValue,
2093
+ color: "var(--vuuFilterEditor-variableColor);font-weight: bold"
2094
+ },
2095
+ { tag: vuuCodemirror.tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
2096
+ { tag: vuuCodemirror.tags.comment, color: "green", fontStyle: "italic" }
2097
+ ]);
2098
+ const vuuHighlighting = vuuCodemirror.syntaxHighlighting(myHighlightStyle);
2099
+
2100
+ const vuuTheme = vuuCodemirror.EditorView.theme(
2101
+ {
2102
+ "&": {
2103
+ border: "solid 1px var(--salt-container-primary-borderColor)",
2104
+ color: "var(--vuuFilterEditor-color)",
2105
+ backgroundColor: "var(--vuuFilterEditor-background)"
2106
+ },
2107
+ ".cm-content": {
2108
+ caretColor: "var(--vuuFilterEditor-cursorColor)"
2109
+ },
2110
+ "&.cm-focused .cm-cursor": {
2111
+ borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
2112
+ },
2113
+ "&.cm-focused .cm-selectionBackground, ::selection": {
2114
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
2115
+ },
2116
+ ".cm-selectionBackground, ::selection": {
2117
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
2118
+ },
2119
+ ".cm-scroller": {
2120
+ fontFamily: "var(--vuuFilterEditor-fontFamily)"
2121
+ },
2122
+ ".cm-completionLabel": {
2123
+ color: "var(--vuu-color-gray-50)"
2124
+ },
2125
+ ".cm-completionMatchedText": {
2126
+ color: "var(--vuu-color-gray-80)",
2127
+ fontWeight: 700,
2128
+ textDecoration: "none"
2129
+ },
2130
+ ".cm-tooltip": {
2131
+ background: "var(--vuuFilterEditor-tooltipBackground)",
2132
+ border: "var(--vuuFilterEditor-tooltipBorder)",
2133
+ borderRadius: "4px",
2134
+ boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
2135
+ "&.cm-tooltip-autocomplete > ul": {
2136
+ fontFamily: "var(--vuuFilterEditor-fontFamily)",
2137
+ fontSize: "var(--vuuFilterEditor-fontSize)",
2138
+ maxHeight: "240px"
2139
+ },
2140
+ "&.cm-tooltip-autocomplete > ul > li": {
2141
+ height: "var(--vuuFilterEditor-suggestion-height)",
2142
+ padding: "0 3px",
2143
+ lineHeight: "var(--vuuFilterEditor-suggestion-height)"
2144
+ },
2145
+ "&.cm-tooltip-autocomplete li[aria-selected]": {
2146
+ background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
2147
+ color: "var(--vuuFilterEditor-suggestion-selectedColor)"
2148
+ },
2149
+ "&.cm-tooltip-autocomplete li .cm-completionDetail": {
2150
+ color: "var(--vuuFilterEditor-suggestion-detailColor)"
2151
+ }
2152
+ }
2153
+ },
2154
+ { dark: false }
2155
+ );
2156
+
2157
+ const applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => ({
2158
+ ...completion,
2159
+ apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${completion.apply ?? completion.label}`
2160
+ })) : completions;
2161
+ const isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
2162
+ const completionDone = (onSubmit) => ({
2163
+ apply: () => {
2164
+ onSubmit?.();
2165
+ },
2166
+ label: "Done",
2167
+ boost: 10
2168
+ });
2169
+ const getLastChild = (node, context) => {
2170
+ let { lastChild: childNode } = node;
2171
+ const { pos } = context;
2172
+ while (childNode) {
2173
+ const isBeforeCursor = childNode.from < pos;
2174
+ if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
2175
+ if (childNode.name === "ParenthesizedExpression") {
2176
+ const expression = childNode.firstChild?.nextSibling;
2177
+ if (expression) {
2178
+ childNode = expression;
2179
+ }
2180
+ }
2181
+ return childNode;
2182
+ } else {
2183
+ childNode = childNode.prevSibling;
2184
+ }
2185
+ }
2186
+ };
2187
+ const getFunctionName = (node, state) => {
2188
+ if (node.name === "ArgList") {
2189
+ const functionNode = node.prevSibling;
2190
+ if (functionNode) {
2191
+ return vuuCodemirror.getValue(functionNode, state);
2192
+ }
2193
+ } else if (node.name === "OpenBrace") {
2194
+ const maybeFunction = node.parent?.prevSibling;
2195
+ if (maybeFunction?.name === "Function") {
2196
+ return vuuCodemirror.getValue(maybeFunction, state);
2197
+ }
2198
+ }
2199
+ };
2200
+ const getRelationalOperator = (node, state) => {
2201
+ if (node.name === "RelationalExpression") {
2202
+ const lastNode = lastNamedChild(node);
2203
+ if (lastNode?.name === "RelationalOperator") {
2204
+ return vuuCodemirror.getValue(lastNode, state);
2205
+ }
2206
+ } else {
2207
+ const prevNode = node.prevSibling;
2208
+ if (prevNode?.name === "RelationalOperator") {
2209
+ return vuuCodemirror.getValue(prevNode, state);
2210
+ }
2211
+ }
2212
+ };
2213
+ const getColumnName = (node, state) => {
2214
+ if (node.name === "RelationalExpression") {
2215
+ if (node.firstChild?.name === "Column") {
2216
+ return vuuCodemirror.getValue(node.firstChild, state);
2217
+ }
2218
+ } else {
2219
+ const prevNode = node.prevSibling;
2220
+ if (prevNode?.name === "Column") {
2221
+ return vuuCodemirror.getValue(prevNode, state);
2222
+ } else if (prevNode?.name === "RelationalOperator") {
2223
+ return getColumnName(prevNode, state);
2224
+ }
2225
+ }
2226
+ };
2227
+ const makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
2228
+ const options = await suggestionProvider.getSuggestions(
2229
+ suggestionType,
2230
+ optionalArgs
2231
+ );
2232
+ const { startsWith = "" } = optionalArgs;
2233
+ return { from: context.pos - startsWith.length, options };
2234
+ };
2235
+ const handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
2236
+ const lastChild = getLastChild(node, context);
2237
+ switch (lastChild?.name) {
2238
+ case "If":
2239
+ return makeSuggestions(context, suggestionProvider, "expression", {
2240
+ prefix: "( "
2241
+ });
2242
+ case "OpenBrace":
2243
+ return makeSuggestions(context, suggestionProvider, "expression");
2244
+ case "Condition":
2245
+ return makeSuggestions(context, suggestionProvider, "expression", {
2246
+ prefix: ", "
2247
+ });
2248
+ case "CloseBrace":
2249
+ if (maybeComplete) {
2250
+ const options = [completionDone(onSubmit)];
2251
+ return { from: context.pos, options };
2252
+ }
2253
+ }
2254
+ };
2255
+ const promptToSave = (context, onSubmit) => {
2256
+ const options = [completionDone(onSubmit)];
2257
+ return { from: context.pos, options };
2258
+ };
2259
+ const useColumnAutoComplete = (suggestionProvider, onSubmit) => {
2260
+ const makeSuggestions2 = react.useCallback(
2261
+ async (context, suggestionType, optionalArgs = {}) => {
2262
+ const options = await suggestionProvider.getSuggestions(
2263
+ suggestionType,
2264
+ optionalArgs
2265
+ );
2266
+ const { startsWith = "" } = optionalArgs;
2267
+ return { from: context.pos - startsWith.length, options };
2268
+ },
2269
+ [suggestionProvider]
2270
+ );
2271
+ return react.useCallback(
2272
+ async (context) => {
2273
+ const { state, pos } = context;
2274
+ const word = context.matchBefore(/\w*/) ?? {
2275
+ from: 0,
2276
+ to: 0,
2277
+ text: void 0
2278
+ };
2279
+ const tree = vuuCodemirror.syntaxTree(state);
2280
+ const nodeBefore = tree.resolveInner(pos, -1);
2281
+ const text = state.doc.toString();
2282
+ const maybeComplete = isCompleteExpression(text);
2283
+ switch (nodeBefore.name) {
2284
+ case "If": {
2285
+ return makeSuggestions2(context, "expression", { prefix: "( " });
2286
+ }
2287
+ case "Condition":
2288
+ {
2289
+ const lastChild = getLastChild(nodeBefore, context);
2290
+ if (lastChild?.name === "Column") {
2291
+ const prevChild = vuuCodemirror.getPreviousNode(lastChild);
2292
+ if (prevChild?.name !== "RelationalOperator") {
2293
+ return makeSuggestions2(context, "condition-operator", {
2294
+ columnName: vuuCodemirror.getValue(lastChild, state)
2295
+ });
2296
+ }
2297
+ } else if (lastChild?.name === "RelationalOperator") {
2298
+ return makeSuggestions2(context, "expression");
2299
+ }
2300
+ }
2301
+ break;
2302
+ case "ConditionalExpression":
2303
+ return handleConditionalExpression(
2304
+ nodeBefore,
2305
+ context,
2306
+ suggestionProvider
2307
+ );
2308
+ case "RelationalExpression":
2309
+ {
2310
+ if (isCompleteRelationalExpression(nodeBefore)) {
2311
+ return {
2312
+ from: context.pos,
2313
+ options: vuuCodemirror.booleanJoinSuggestions.concat({
2314
+ label: ", <truthy expression>, <falsy expression>",
2315
+ apply: ", "
2316
+ })
2317
+ };
2318
+ } else {
2319
+ const operator = getRelationalOperator(nodeBefore, state);
2320
+ const columnName = getColumnName(nodeBefore, state);
2321
+ if (!operator) {
2322
+ const options = await suggestionProvider.getSuggestions(
2323
+ "condition-operator",
2324
+ {
2325
+ columnName
2326
+ }
2327
+ );
2328
+ return { from: context.pos, options };
2329
+ } else {
2330
+ return makeSuggestions2(context, "expression");
2331
+ }
2332
+ }
2333
+ }
2334
+ case "RelationalOperator":
2335
+ return makeSuggestions2(context, "expression");
2336
+ case "String":
2337
+ {
2338
+ const operator = getRelationalOperator(
2339
+ nodeBefore,
2340
+ state
2341
+ );
2342
+ const columnName = getColumnName(nodeBefore, state);
2343
+ const { from, to } = nodeBefore;
2344
+ if (to - from === 2 && context.pos === from + 1) {
2345
+ if (columnName && operator) {
2346
+ return makeSuggestions2(context, "columnValue", {
2347
+ columnName,
2348
+ operator,
2349
+ startsWith: word.text
2350
+ });
2351
+ }
2352
+ } else if (to - from > 2 && context.pos === to) {
2353
+ return makeSuggestions2(context, "expression", {
2354
+ prefix: ", "
2355
+ });
2356
+ }
2357
+ }
2358
+ break;
2359
+ case "ArithmeticExpression":
2360
+ {
2361
+ const lastChild = getLastChild(nodeBefore, context);
2362
+ if (lastChild?.name === "Column") {
2363
+ return makeSuggestions2(context, "expression");
2364
+ } else if (isOperator(lastChild)) {
2365
+ const operator = lastChild.name;
2366
+ return makeSuggestions2(context, "column", { operator });
2367
+ }
2368
+ }
2369
+ break;
2370
+ case "OpenBrace":
2371
+ {
2372
+ const functionName = getFunctionName(nodeBefore, state);
2373
+ return makeSuggestions2(context, "expression", { functionName });
2374
+ }
2375
+ case "ArgList": {
2376
+ const functionName = getFunctionName(nodeBefore, state);
2377
+ const lastArgument = getLastChild(nodeBefore, context);
2378
+ const prefix = lastArgument?.name === "OpenBrace" || lastArgument?.name === "Comma" ? void 0 : ",";
2379
+ let options = await suggestionProvider.getSuggestions("expression", {
2380
+ functionName
2381
+ });
2382
+ options = prefix ? applyPrefix(options, ", ") : options;
2383
+ if (lastArgument?.name !== "OpenBrace" && lastArgument?.name !== "Comma") {
2384
+ options = [
2385
+ {
2386
+ apply: ") ",
2387
+ boost: 10,
2388
+ label: "Done - no more arguments"
2389
+ }
2390
+ ].concat(options);
2391
+ }
2392
+ return { from: context.pos, options };
2393
+ }
2394
+ case "Equal":
2395
+ if (text.trim() === "=") {
2396
+ return makeSuggestions2(context, "expression");
2397
+ }
2398
+ break;
2399
+ case "ParenthesizedExpression":
2400
+ case "ColumnDefinitionExpression":
2401
+ if (context.pos === 0) {
2402
+ return makeSuggestions2(context, "expression");
2403
+ } else {
2404
+ const lastChild = getLastChild(nodeBefore, context);
2405
+ if (lastChild?.name === "Column") {
2406
+ if (maybeComplete) {
2407
+ const options = [
2408
+ completionDone(onSubmit.current)
2409
+ ];
2410
+ const columnName = vuuCodemirror.getValue(lastChild, state);
2411
+ const columnOptions = await suggestionProvider.getSuggestions("operator", {
2412
+ columnName
2413
+ });
2414
+ return {
2415
+ from: context.pos,
2416
+ options: options.concat(columnOptions)
2417
+ };
2418
+ }
2419
+ } else if (lastChild?.name === "CallExpression") {
2420
+ if (maybeComplete) {
2421
+ return {
2422
+ from: context.pos,
2423
+ options: [completionDone(onSubmit.current)]
2424
+ };
2425
+ }
2426
+ } else if (lastChild?.name === "ArithmeticExpression") {
2427
+ if (maybeComplete) {
2428
+ let options = [completionDone(onSubmit.current)];
2429
+ const lastExpressionChild = getLastChild(lastChild, context);
2430
+ if (lastExpressionChild?.name === "Column") {
2431
+ const columnName = vuuCodemirror.getValue(lastExpressionChild, state);
2432
+ const suggestions = await suggestionProvider.getSuggestions(
2433
+ "operator",
2434
+ { columnName }
2435
+ );
2436
+ options = options.concat(suggestions);
2437
+ }
2438
+ return {
2439
+ from: context.pos,
2440
+ options
2441
+ };
2442
+ }
2443
+ } else if (lastChild?.name === "ConditionalExpression") {
2444
+ return handleConditionalExpression(
2445
+ lastChild,
2446
+ context,
2447
+ suggestionProvider,
2448
+ maybeComplete,
2449
+ onSubmit.current
2450
+ );
2451
+ }
2452
+ break;
2453
+ }
2454
+ case "Column":
2455
+ {
2456
+ const isPartialMatch = await suggestionProvider.isPartialMatch(
2457
+ "expression",
2458
+ void 0,
2459
+ word.text
2460
+ );
2461
+ if (isPartialMatch) {
2462
+ return makeSuggestions2(context, "expression", {
2463
+ startsWith: word.text
2464
+ });
2465
+ }
2466
+ }
2467
+ break;
2468
+ case "Comma":
2469
+ {
2470
+ const parentNode = vuuCodemirror.getNamedParentNode(nodeBefore);
2471
+ if (parentNode?.name === "ConditionalExpression") {
2472
+ return makeSuggestions2(context, "expression");
2473
+ }
2474
+ }
2475
+ break;
2476
+ case "CloseBrace":
2477
+ {
2478
+ const parentNode = vuuCodemirror.getNamedParentNode(nodeBefore);
2479
+ if (parentNode?.name === "ConditionalExpression") {
2480
+ return handleConditionalExpression(
2481
+ parentNode,
2482
+ context,
2483
+ suggestionProvider,
2484
+ maybeComplete,
2485
+ onSubmit.current
2486
+ );
2487
+ } else if (parentNode?.name === "ArgList") {
2488
+ if (maybeComplete) {
2489
+ return promptToSave(context, onSubmit.current);
2490
+ }
2491
+ }
2492
+ }
2493
+ break;
2494
+ default: {
2495
+ if (nodeBefore?.prevSibling?.name === "FilterClause") {
2496
+ console.log("looks like we ight be a or|and operator");
2497
+ }
2498
+ }
2499
+ }
2500
+ },
2501
+ [makeSuggestions2, onSubmit, suggestionProvider]
2502
+ );
2503
+ };
2504
+
2505
+ const getView = (ref) => {
2506
+ if (ref.current == void 0) {
2507
+ throw Error("EditorView not defined");
2508
+ }
2509
+ return ref.current;
2510
+ };
2511
+ const getOptionClass = () => {
2512
+ return "vuuSuggestion";
2513
+ };
2514
+ const noop = () => console.log("noooop");
2515
+ const hasExpressionType = (completion) => "expressionType" in completion;
2516
+ const injectOptionContent = (completion) => {
2517
+ if (hasExpressionType(completion)) {
2518
+ const div = vuuUtils.createEl("div", "expression-type-container");
2519
+ const span = vuuUtils.createEl("span", "expression-type", completion.expressionType);
2520
+ div.appendChild(span);
2521
+ return div;
2522
+ } else {
2523
+ return null;
2524
+ }
2525
+ };
2526
+ const useColumnExpressionEditor = ({
2527
+ onChange,
2528
+ onSubmitExpression,
2529
+ source,
2530
+ suggestionProvider
2531
+ }) => {
2532
+ const editorRef = react.useRef(null);
2533
+ const onSubmitRef = react.useRef(noop);
2534
+ const viewRef = react.useRef(void 0);
2535
+ const completionFn = useColumnAutoComplete(suggestionProvider, onSubmitRef);
2536
+ const [createState, clearInput, submit] = react.useMemo(() => {
2537
+ const parseExpression = () => {
2538
+ const view = getView(viewRef);
2539
+ const source2 = view.state.doc.toString();
2540
+ const tree = vuuCodemirror.ensureSyntaxTree(view.state, view.state.doc.length, 5e3);
2541
+ if (tree) {
2542
+ const expression = walkTree(tree, source2);
2543
+ return [source2, expression];
2544
+ } else {
2545
+ return ["", void 0];
2546
+ }
2547
+ };
2548
+ const clearInput2 = () => {
2549
+ getView(viewRef).setState(createState2());
2550
+ };
2551
+ const submitExpression = () => {
2552
+ const [source2, expression] = parseExpression();
2553
+ onSubmitExpression?.(source2, expression);
2554
+ };
2555
+ const showSuggestions = (key) => {
2556
+ return vuuCodemirror.keymap.of([
2557
+ {
2558
+ key,
2559
+ run() {
2560
+ vuuCodemirror.startCompletion(getView(viewRef));
2561
+ return true;
2562
+ }
2563
+ }
2564
+ ]);
2565
+ };
2566
+ const createState2 = () => vuuCodemirror.EditorState.create({
2567
+ doc: source,
2568
+ extensions: [
2569
+ vuuCodemirror.minimalSetup,
2570
+ vuuCodemirror.autocompletion({
2571
+ addToOptions: [
2572
+ {
2573
+ render: injectOptionContent,
2574
+ position: 70
2575
+ }
2576
+ ],
2577
+ override: [completionFn],
2578
+ optionClass: getOptionClass
2579
+ }),
2580
+ columnExpressionLanguageSupport(),
2581
+ vuuCodemirror.keymap.of(vuuCodemirror.defaultKeymap),
2582
+ showSuggestions("ArrowDown"),
2583
+ vuuCodemirror.EditorView.updateListener.of((v) => {
2584
+ const view = getView(viewRef);
2585
+ if (v.docChanged) {
2586
+ vuuCodemirror.startCompletion(view);
2587
+ const source2 = view.state.doc.toString();
2588
+ onChange?.(source2);
2589
+ }
2590
+ }),
2591
+ // Enforces single line view
2592
+ vuuCodemirror.EditorState.transactionFilter.of(
2593
+ (tr) => tr.newDoc.lines > 1 ? [] : tr
2594
+ ),
2595
+ vuuTheme,
2596
+ vuuHighlighting
2597
+ ]
2598
+ });
2599
+ onSubmitRef.current = () => {
2600
+ submitExpression();
2601
+ };
2602
+ return [createState2, clearInput2, submitExpression];
2603
+ }, [completionFn, onChange, onSubmitExpression, source]);
2604
+ react.useEffect(() => {
2605
+ if (!editorRef.current) {
2606
+ throw Error("editor not in dom");
2607
+ }
2608
+ viewRef.current = new vuuCodemirror.EditorView({
2609
+ state: createState(),
2610
+ parent: editorRef.current
2611
+ });
2612
+ return () => {
2613
+ viewRef.current?.destroy();
2614
+ };
2615
+ }, [completionFn, createState]);
2616
+ const handleBlur = react.useCallback(() => {
2617
+ submit();
2618
+ }, [submit]);
2619
+ return { editorRef, clearInput, onBlur: handleBlur };
2620
+ };
2621
+
2622
+ var colummExpressionInputCss = "\n.vuuColumnExpressionInput {\n --vuuFilterEditor-background: var(--salt-container-primary-background);\n --vuuFilterEditor-color: var(--salt-content-primary-foreground);\n --vuuFilterEditor-fontFamily: var(--salt-typography-fontFamily);\n --vuuFilterEditor-fontSize: var(--salt-text-fontSize);\n --vuuFilterEditor-cursorColor: var(--salt-content-secondary-foreground);\n --vuuFilterEditor-selectionBackground: var(--salt-text-background-selected);\n --vuuFilterEditor-tooltipBackground: var(--salt-container-primary-background);\n --vuuFilterEditor-tooltipBorder: solid 1px var(--vuu-color-purple-10); \n --vuuFilterEditor-tooltipElevation: var(--salt-overlayable-shadow-popout);\n --vuuFilterEditor-suggestion-selectedBackground: var(--vuu-color-gray-10);\n --vuuFilterEditor-suggestion-selectedColor: var(--salt-content-primary-foreground);\n --vuuFilterEditor-suggestion-detailColor: var(--salt-content-secondary-foreground-disabled);\n --vuuFilterEditor-suggestion-height: 24px;\n --vuuFilterEditor-variableColor: var(--vuu-color-purple-10);\n\n align-items: center;\n box-sizing: border-box;\n height: 30px;\n}\n\n.vuuColumnExpressionInput-FilterButton,\n.vuuColumnExpressionInput-ClearButton {\n --vuu-icon-size: 12px;\n --saltButton-width: 28px;\n}\n\n.expression-type-container {\n margin: 0 3px 0 auto;\n color: var(--salt-content-secondary-foreground)\n}\n\n.expression-kind {\n display: inline-block;\n width: 50px;\n}\n\n.expression-type {\n display: inline-block;\n text-align: right;\n width: 50px;\n}\n\n.vuuSuggestion {\n display: flex;\n align-items: center;\n}\n\n.vuuFunctionDoc {\n padding: 13px 7px;\n}\n\n.vuuFunctionDoc .function-heading {\n display: flex;\n gap: 3px;\n}\n\n.vuuFunctionDoc .function-name {\n font-weight: 700;\n text-transform: capitalize;\n}\n\n.vuuFunctionDoc .param-list {\n color: var(--vuu-color-gray-50);\n white-space: pre;\n}\n\n.vuuFunctionDoc .function-type {\n color: var(--vuu-color-gray-50);\n font-weight: 700;\n margin-left: auto;\n text-transform: capitalize;\n}\n\n.vuuFunctionDoc .example-container {\n background-color: var(--vuu-color-gray-03);\n margin: 6px 0;\n padding: 3px;\n}\n\n.vuuFunctionDoc .example-expression {\n color: var(--vuu-color-gray-80);\n font-family: var(--salt-typography-fontFamily-code);\n font-weight: 500;\n padding: 8px;\n}\n\n.vuuFunctionDoc .example-result {\n margin-left: 8px;\n margin-top: 6px;\n}";
2623
+
2624
+ const classBase$7 = "vuuColumnExpressionInput";
2625
+ const ColumnExpressionInput = react.memo(
2626
+ ({
2627
+ onChange,
2628
+ onSubmitExpression,
2629
+ source = "",
2630
+ suggestionProvider
2631
+ }) => {
2632
+ const targetWindow = window.useWindow();
2633
+ styles.useComponentCssInjection({
2634
+ testId: "vuu-column-expression-input",
2635
+ css: colummExpressionInputCss,
2636
+ window: targetWindow
2637
+ });
2638
+ const { editorRef, onBlur } = useColumnExpressionEditor({
2639
+ onChange,
2640
+ onSubmitExpression,
2641
+ source,
2642
+ suggestionProvider
2643
+ });
2644
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase$7}`, onBlur, ref: editorRef });
2645
+ },
2646
+ (prevProps, newProps) => {
2647
+ return prevProps.source === newProps.source;
2648
+ }
2649
+ );
2650
+ ColumnExpressionInput.displayName = "ColumnExpressionInput";
2651
+
2652
+ const columnFunctionDescriptors = [
2653
+ /**
2654
+ * and
2655
+ */
2656
+ {
2657
+ accepts: ["boolean"],
2658
+ description: "Applies boolean and operator across supplied parameters to returns a single boolean result",
2659
+ example: {
2660
+ expression: 'and(ccy="EUR",quantity=0)',
2661
+ result: "true | false"
2662
+ },
2663
+ name: "and",
2664
+ params: {
2665
+ description: "( boolean, [ boolean* ] )"
2666
+ },
2667
+ type: "boolean"
2668
+ },
2669
+ /**
2670
+ * concatenate()
2671
+ */
2672
+ {
2673
+ accepts: "string",
2674
+ 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.",
2675
+ example: {
2676
+ expression: 'concatenate("example", "-test")',
2677
+ result: '"example-test"'
2678
+ },
2679
+ name: "concatenate",
2680
+ params: {
2681
+ description: "( string, string, [ string* ] )"
2682
+ },
2683
+ type: "string"
2684
+ },
2685
+ /**
2686
+ * contains()
2687
+ */
2688
+ {
2689
+ accepts: ["string", "string"],
2690
+ 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>",
2691
+ example: {
2692
+ expression: 'contains("Royal Bank of Scotland", "bank")',
2693
+ result: "true"
2694
+ },
2695
+ name: "contains",
2696
+ params: {
2697
+ description: "( string )"
2698
+ },
2699
+ type: "boolean"
2700
+ },
2701
+ /**
2702
+ * left()
2703
+ */
2704
+ {
2705
+ accepts: ["string", "number"],
2706
+ description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
2707
+ example: {
2708
+ expression: 'left("USD Benchmark Report", 3)',
2709
+ result: '"USD"'
2710
+ },
2711
+ name: "left",
2712
+ params: {
2713
+ count: 2,
2714
+ description: "( string, number )"
2715
+ },
2716
+ type: "string"
2717
+ },
2718
+ /**
2719
+ * len()
2720
+ */
2721
+ {
2722
+ accepts: "string",
2723
+ description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
2724
+ example: {
2725
+ expression: 'len("example")',
2726
+ result: "7"
2727
+ },
2728
+ name: "len",
2729
+ params: {
2730
+ description: "(string)"
2731
+ },
2732
+ type: "number"
2733
+ },
2734
+ /**
2735
+ * lower()
2736
+ */
2737
+ {
2738
+ accepts: "string",
2739
+ description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
2740
+ example: {
2741
+ expression: 'lower("examPLE")',
2742
+ result: '"example"'
2743
+ },
2744
+ name: "lower",
2745
+ params: {
2746
+ description: "( string )"
2747
+ },
2748
+ type: "string"
2749
+ },
2750
+ /**
2751
+ * or
2752
+ */
2753
+ {
2754
+ accepts: ["boolean"],
2755
+ description: "Applies boolean or operator across supplied parameters to returns a single boolean result",
2756
+ example: {
2757
+ expression: 'or(status="cancelled",quantity=0)',
2758
+ result: "true | false"
2759
+ },
2760
+ name: "or",
2761
+ params: {
2762
+ description: "( boolean, [ boolean* ] )"
2763
+ },
2764
+ type: "boolean"
2765
+ },
2766
+ /**
2767
+ * upper()
2768
+ */
2769
+ {
2770
+ accepts: "string",
2771
+ description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
2772
+ example: {
2773
+ expression: 'upper("example")',
2774
+ result: '"EXAMPLE"'
2775
+ },
2776
+ name: "upper",
2777
+ params: {
2778
+ description: "( string )"
2779
+ },
2780
+ type: "string"
2781
+ },
2782
+ /**
2783
+ * right()
2784
+ */
2785
+ {
2786
+ accepts: ["string", "number"],
2787
+ description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
2788
+ example: {
2789
+ expression: "blah",
2790
+ result: "blah"
2791
+ },
2792
+ name: "right",
2793
+ params: {
2794
+ description: "( string )"
2795
+ },
2796
+ type: "string"
2797
+ },
2798
+ /**
2799
+ * replace()
2800
+ */
2801
+ {
2802
+ accepts: ["string", "string", "string"],
2803
+ 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>",
2804
+ example: {
2805
+ expression: "blah",
2806
+ result: "blah"
2807
+ },
2808
+ name: "replace",
2809
+ params: {
2810
+ description: "( string )"
2811
+ },
2812
+ type: "string"
2813
+ },
2814
+ /**
2815
+ * text()
2816
+ */
2817
+ {
2818
+ accepts: "number",
2819
+ description: "Converts a number to a string.",
2820
+ example: {
2821
+ expression: "blah",
2822
+ result: "blah"
2823
+ },
2824
+ name: "text",
2825
+ params: {
2826
+ description: "( string )"
2827
+ },
2828
+ type: "string"
2829
+ },
2830
+ /**
2831
+ * starts()
2832
+ */
2833
+ {
2834
+ accepts: "string",
2835
+ 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>.",
2836
+ example: {
2837
+ expression: "blah",
2838
+ result: "blah"
2839
+ },
2840
+ name: "starts",
2841
+ params: {
2842
+ description: "( string )"
2843
+ },
2844
+ type: "boolean"
2845
+ },
2846
+ /**
2847
+ * starts()
2848
+ */
2849
+ {
2850
+ accepts: "string",
2851
+ 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>.",
2852
+ example: {
2853
+ expression: "blah",
2854
+ result: "blah"
2855
+ },
2856
+ name: "ends",
2857
+ params: {
2858
+ description: "( string )"
2859
+ },
2860
+ type: "boolean"
2861
+ },
2862
+ {
2863
+ accepts: "number",
2864
+ description: "blah",
2865
+ example: {
2866
+ expression: "blah",
2867
+ result: "blah"
2868
+ },
2869
+ name: "min",
2870
+ params: {
2871
+ description: "( string )"
2872
+ },
2873
+ type: "number"
2874
+ },
2875
+ {
2876
+ accepts: "number",
2877
+ description: "blah",
2878
+ example: {
2879
+ expression: "blah",
2880
+ result: "blah"
2881
+ },
2882
+ name: "max",
2883
+ params: {
2884
+ description: "( string )"
2885
+ },
2886
+ type: "number"
2887
+ },
2888
+ {
2889
+ accepts: "number",
2890
+ description: "blah",
2891
+ example: {
2892
+ expression: "blah",
2893
+ result: "blah"
2894
+ },
2895
+ name: "sum",
2896
+ params: {
2897
+ description: "( string )"
2898
+ },
2899
+ type: "number"
2900
+ },
2901
+ {
2902
+ accepts: "number",
2903
+ description: "blah",
2904
+ example: {
2905
+ expression: "blah",
2906
+ result: "blah"
2907
+ },
2908
+ name: "round",
2909
+ params: {
2910
+ description: "( string )"
2911
+ },
2912
+ type: "number"
2913
+ },
2914
+ {
2915
+ accepts: "any",
2916
+ description: "blah",
2917
+ example: {
2918
+ expression: "blah",
2919
+ result: "blah"
2920
+ },
2921
+ name: "or",
2922
+ params: {
2923
+ description: "( string )"
2924
+ },
2925
+ type: "boolean"
2926
+ },
2927
+ {
2928
+ accepts: "any",
2929
+ description: "blah",
2930
+ example: {
2931
+ expression: "blah",
2932
+ result: "blah"
2933
+ },
2934
+ name: "and",
2935
+ params: {
2936
+ description: "( string )"
2937
+ },
2938
+ type: "boolean"
2939
+ },
2940
+ {
2941
+ accepts: "any",
2942
+ 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>. ",
2943
+ example: {
2944
+ expression: "blah",
2945
+ result: "blah"
2946
+ },
2947
+ name: "if",
2948
+ params: {
2949
+ description: "( filterExpression, expression1, expression 2)"
2950
+ },
2951
+ type: "variable"
2952
+ }
2953
+ ];
2954
+
2955
+ const functionDocInfo = ({
2956
+ name,
2957
+ description,
2958
+ example,
2959
+ params,
2960
+ type
2961
+ }) => {
2962
+ const rootElement = vuuUtils.createEl("div", "vuuFunctionDoc");
2963
+ const headingElement = vuuUtils.createEl("div", "function-heading");
2964
+ const nameElement = vuuUtils.createEl("span", "function-name", name);
2965
+ const paramElement = vuuUtils.createEl("span", "param-list", params.description);
2966
+ const typeElement = vuuUtils.createEl("span", "function-type", type);
2967
+ headingElement.appendChild(nameElement);
2968
+ headingElement.appendChild(paramElement);
2969
+ headingElement.appendChild(typeElement);
2970
+ const child2 = vuuUtils.createEl("p", void 0, description);
2971
+ rootElement.appendChild(headingElement);
2972
+ rootElement.appendChild(child2);
2973
+ if (example) {
2974
+ const exampleElement = vuuUtils.createEl("div", "example-container");
2975
+ const expressionElement = vuuUtils.createEl(
2976
+ "div",
2977
+ "example-expression",
2978
+ example.expression
2979
+ );
2980
+ const resultElement = vuuUtils.createEl("div", "example-result", example.result);
2981
+ exampleElement.appendChild(expressionElement);
2982
+ rootElement.appendChild(exampleElement);
2983
+ rootElement.appendChild(resultElement);
2984
+ }
2985
+ return rootElement;
2986
+ };
2987
+
2988
+ const NO_OPERATORS = [];
2989
+ const withApplySpace = (suggestions) => suggestions.map((suggestion) => ({
2990
+ ...suggestion,
2991
+ apply: (suggestion.apply ?? suggestion.label) + " "
2992
+ }));
2993
+ const getValidColumns = (columns, { functionName, operator }) => {
2994
+ if (operator) {
2995
+ return columns.filter(vuuUtils.isNumericColumn);
2996
+ } else if (functionName) {
2997
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
2998
+ if (fn) {
2999
+ switch (fn.accepts) {
3000
+ case "string":
3001
+ return columns.filter(vuuUtils.isTextColumn);
3002
+ case "number":
3003
+ return columns.filter(vuuUtils.isNumericColumn);
3004
+ default:
3005
+ return columns;
3006
+ }
3007
+ }
3008
+ }
3009
+ return columns;
3010
+ };
3011
+ const getColumns = (columns, options) => {
3012
+ const validColumns = getValidColumns(columns, options);
3013
+ return validColumns.map((column) => {
3014
+ const label = column.label ?? column.name;
3015
+ return {
3016
+ apply: options.prefix ? `${options.prefix}${column.name}` : column.name,
3017
+ label,
3018
+ boost: 5,
3019
+ type: "column",
3020
+ expressionType: column.serverDataType
3021
+ };
3022
+ });
3023
+ };
3024
+ const arithmeticOperators = [
3025
+ { apply: "* ", boost: 2, label: "*", type: "operator" },
3026
+ { apply: "/ ", boost: 2, label: "/", type: "operator" },
3027
+ { apply: "+ ", boost: 2, label: "+", type: "operator" },
3028
+ { apply: "- ", boost: 2, label: "-", type: "operator" }
3029
+ ];
3030
+ const getOperators = (column) => {
3031
+ if (column === void 0 || vuuUtils.isNumericColumn(column)) {
3032
+ return arithmeticOperators;
3033
+ } else {
3034
+ return NO_OPERATORS;
3035
+ }
3036
+ };
3037
+ const getConditionOperators = (column) => {
3038
+ switch (column.serverDataType) {
3039
+ case "string":
3040
+ case "char":
3041
+ return withApplySpace(
3042
+ vuuCodemirror.stringOperators
3043
+ /*, startsWith*/
3044
+ );
3045
+ case "int":
3046
+ case "long":
3047
+ case "double":
3048
+ return withApplySpace(vuuCodemirror.numericOperators);
3049
+ }
3050
+ };
3051
+ const toFunctionCompletion = (functionDescriptor) => ({
3052
+ apply: `${functionDescriptor.name}( `,
3053
+ boost: 2,
3054
+ expressionType: functionDescriptor.type,
3055
+ info: () => functionDocInfo(functionDescriptor),
3056
+ label: functionDescriptor.name,
3057
+ type: "function"
3058
+ });
3059
+ const getAcceptedTypes = (fn) => {
3060
+ if (fn) {
3061
+ if (typeof fn.accepts === "string") {
3062
+ return fn.accepts;
3063
+ } else if (Array.isArray(fn.accepts)) {
3064
+ if (fn.accepts.every((s) => s === "string")) {
3065
+ return "string";
3066
+ } else {
3067
+ return "any";
3068
+ }
3069
+ }
3070
+ }
3071
+ return "any";
3072
+ };
3073
+ const functions = columnFunctionDescriptors.map(toFunctionCompletion);
3074
+ const getFunctions = ({ functionName }) => {
3075
+ if (functionName) {
3076
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
3077
+ const acceptedTypes = getAcceptedTypes(fn);
3078
+ if (fn) {
3079
+ switch (acceptedTypes) {
3080
+ case "string":
3081
+ return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
3082
+ case "number":
3083
+ return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
3084
+ }
3085
+ }
3086
+ }
3087
+ return functions;
3088
+ };
3089
+ const NONE = {};
3090
+ const useColumnExpressionSuggestionProvider = ({
3091
+ columns,
3092
+ table
3093
+ }) => {
3094
+ const findColumn = react.useCallback(
3095
+ (name) => name ? columns.find((col) => col.name === name) : void 0,
3096
+ [columns]
3097
+ );
3098
+ const latestSuggestionsRef = react.useRef(void 0);
3099
+ const getTypeaheadSuggestions = vuuDataReact.useTypeaheadSuggestions();
3100
+ const getSuggestions = react.useCallback(
3101
+ async (suggestionType, options = NONE) => {
3102
+ const { columnName, functionName, operator, prefix } = options;
3103
+ switch (suggestionType) {
3104
+ case "expression": {
3105
+ const suggestions = await withApplySpace(
3106
+ getColumns(columns, { functionName, prefix })
3107
+ ).concat(getFunctions(options));
3108
+ return latestSuggestionsRef.current = suggestions;
3109
+ }
3110
+ case "column": {
3111
+ const suggestions = await getColumns(columns, options);
3112
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
3113
+ }
3114
+ case "operator": {
3115
+ const suggestions = await getOperators(findColumn(columnName));
3116
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
3117
+ }
3118
+ case "relational-operator": {
3119
+ const suggestions = await vuuCodemirror.getRelationalOperators(
3120
+ findColumn(columnName)
3121
+ );
3122
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
3123
+ }
3124
+ case "condition-operator":
3125
+ {
3126
+ const column = findColumn(columnName);
3127
+ if (column) {
3128
+ const suggestions = await getConditionOperators(column);
3129
+ if (suggestions) {
3130
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
3131
+ }
3132
+ }
3133
+ }
3134
+ break;
3135
+ case "columnValue":
3136
+ if (columnName && operator) {
3137
+ const params = vuuDataReact.getTypeaheadParams(
3138
+ table,
3139
+ columnName
3140
+ );
3141
+ const suggestions = await getTypeaheadSuggestions(params);
3142
+ if (suggestions) {
3143
+ latestSuggestionsRef.current = vuuCodemirror.toSuggestions(suggestions, {
3144
+ suffix: ""
3145
+ });
3146
+ latestSuggestionsRef.current.forEach((suggestion) => {
3147
+ suggestion.apply = (view, completion, from) => {
3148
+ const annotation = new vuuCodemirror.AnnotationType();
3149
+ const cursorPos = from + completion.label.length + 1;
3150
+ view.dispatch({
3151
+ changes: { from, insert: completion.label },
3152
+ selection: { anchor: cursorPos, head: cursorPos },
3153
+ annotations: annotation.of(completion)
3154
+ });
3155
+ };
3156
+ });
3157
+ }
3158
+ return latestSuggestionsRef.current || [];
3159
+ }
3160
+ break;
3161
+ }
3162
+ return [];
3163
+ },
3164
+ [columns, findColumn, getTypeaheadSuggestions, table]
3165
+ );
3166
+ const isPartialMatch = react.useCallback(
3167
+ async (valueType, columnName, pattern) => {
3168
+ const { current: latestSuggestions } = latestSuggestionsRef;
3169
+ let maybe = false;
3170
+ const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
3171
+ if (pattern && suggestions) {
3172
+ for (const option of suggestions) {
3173
+ if (option.label === pattern) {
3174
+ return false;
3175
+ } else if (option.label.startsWith(pattern)) {
3176
+ maybe = true;
3177
+ }
3178
+ }
3179
+ }
3180
+ return maybe;
3181
+ },
3182
+ [getSuggestions]
3183
+ );
3184
+ return {
3185
+ getSuggestions,
3186
+ isPartialMatch
3187
+ };
3188
+ };
3189
+
3190
+ const applyDefaults = (column) => {
3191
+ const { name, expression, serverDataType } = vuuUtils.getCalculatedColumnDetails(column);
3192
+ if (serverDataType === void 0) {
3193
+ return {
3194
+ ...column,
3195
+ name: `${name}:string:${expression}`
3196
+ };
3197
+ } else {
3198
+ return column;
3199
+ }
3200
+ };
3201
+ const useColumnExpression = ({
3202
+ column: columnProp,
3203
+ onChangeName: onChangeNameProp,
3204
+ onChangeServerDataType: onChangeServerDataTypeProp
3205
+ }) => {
3206
+ const [column, _setColumn] = react.useState(
3207
+ applyDefaults(columnProp)
3208
+ );
3209
+ const columnRef = react.useRef(columnProp);
3210
+ const setColumn = react.useCallback((column2) => {
3211
+ columnRef.current = column2;
3212
+ _setColumn(column2);
3213
+ }, []);
3214
+ const onChangeName = react.useCallback(
3215
+ (evt) => {
3216
+ const { value } = evt.target;
3217
+ const newColumn = vuuUtils.setCalculatedColumnName(column, value);
3218
+ setColumn(newColumn);
3219
+ onChangeNameProp?.(newColumn.name);
3220
+ },
3221
+ [column, onChangeNameProp, setColumn]
3222
+ );
3223
+ const onChangeExpression = react.useCallback(
3224
+ (value) => {
3225
+ const expression = value.trim();
3226
+ const { current: column2 } = columnRef;
3227
+ const newColumn = vuuUtils.setCalculatedColumnExpression(column2, expression);
3228
+ setColumn(newColumn);
3229
+ onChangeNameProp?.(newColumn.name);
3230
+ },
3231
+ [onChangeNameProp, setColumn]
3232
+ );
3233
+ const onChangeServerDataType = react.useCallback(
3234
+ (_e, [serverDataType]) => {
3235
+ if (vuuUtils.isVuuColumnDataType(serverDataType)) {
3236
+ const newColumn = vuuUtils.setCalculatedColumnType(column, serverDataType);
3237
+ setColumn(newColumn);
3238
+ onChangeNameProp?.(newColumn.name);
3239
+ onChangeServerDataTypeProp?.(serverDataType);
3240
+ }
3241
+ },
3242
+ [column, onChangeNameProp, onChangeServerDataTypeProp, setColumn]
3243
+ );
3244
+ return {
3245
+ column,
3246
+ onChangeExpression,
3247
+ onChangeName,
3248
+ onChangeServerDataType
3249
+ };
3250
+ };
3251
+
3252
+ const classBase$6 = "vuuColumnExpressionPanel";
3253
+ const ColumnExpressionPanel = ({
3254
+ column: columnProp,
3255
+ onChangeName: onChangeNameProp,
3256
+ onChangeServerDataType: onChangeServerDataTypeProp,
3257
+ tableConfig,
3258
+ vuuTable
3259
+ }) => {
3260
+ const typeRef = react.useRef(null);
3261
+ const { column, onChangeExpression, onChangeName, onChangeServerDataType } = useColumnExpression({
3262
+ column: columnProp,
3263
+ onChangeName: onChangeNameProp,
3264
+ onChangeServerDataType: onChangeServerDataTypeProp
3265
+ });
3266
+ const initialExpressionRef = react.useRef(
3267
+ vuuUtils.getCalculatedColumnDetails(column).expression ?? ""
3268
+ );
3269
+ const suggestionProvider = useColumnExpressionSuggestionProvider({
3270
+ columns: tableConfig.columns,
3271
+ table: vuuTable
3272
+ });
3273
+ const handleSubmitExpression = react.useCallback(() => {
3274
+ if (typeRef.current) {
3275
+ typeRef.current?.querySelector("button")?.focus();
3276
+ }
3277
+ }, []);
3278
+ const { name, serverDataType } = vuuUtils.getCalculatedColumnDetails(column);
3279
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classBase$6, children: [
3280
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "vuuColumnSettingsPanel-header", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Calculation" }) }),
3281
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "column-name", children: [
3282
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Column Name" }),
3283
+ /* @__PURE__ */ jsxRuntime.jsx(core.Input, { className: "vuuInput", onChange: onChangeName, value: name })
3284
+ ] }),
3285
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "column-expression", children: [
3286
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Expression" }),
3287
+ /* @__PURE__ */ jsxRuntime.jsx(
3288
+ ColumnExpressionInput,
3289
+ {
3290
+ onChange: onChangeExpression,
3291
+ onSubmitExpression: handleSubmitExpression,
3292
+ source: initialExpressionRef.current,
3293
+ suggestionProvider
3294
+ }
3295
+ )
3296
+ ] }),
3297
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "type", children: [
3298
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Column type" }),
3299
+ /* @__PURE__ */ jsxRuntime.jsxs(
3300
+ core.Dropdown,
3301
+ {
3302
+ className: `${classBase$6}-type`,
3303
+ onSelectionChange: onChangeServerDataType,
3304
+ ref: typeRef,
3305
+ selected: serverDataType ? [serverDataType] : [],
3306
+ value: serverDataType,
3307
+ children: [
3308
+ /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: "boolean", children: "Boolean" }),
3309
+ /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: "double", children: "Double" }),
3310
+ /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: "long", children: "Long" }),
3311
+ /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: "string", children: "String" })
3312
+ ]
3313
+ }
3314
+ )
3315
+ ] })
3316
+ ] });
3317
+ };
3318
+
3319
+ const classBase$5 = "vuuFormattingSettings";
3320
+ const BaseNumericFormattingSettings = ({
3321
+ column,
3322
+ onChangeFormatting: onChange
3323
+ }) => {
3324
+ const [formattingSettings, setFormattingSettings] = react.useState(vuuUtils.getTypeFormattingFromColumn(column));
3325
+ const handleInputKeyDown = react.useCallback(
3326
+ (evt) => {
3327
+ if (evt.key === "Enter" || evt.key === "Tab") {
3328
+ onChange(formattingSettings);
3329
+ }
3330
+ },
3331
+ [formattingSettings, onChange]
3332
+ );
3333
+ const handleChangeDecimals = react.useCallback(
3334
+ (evt) => {
3335
+ const { value } = evt.target;
3336
+ const numericValue = value === "" ? void 0 : isNaN(parseInt(value)) ? void 0 : parseInt(value);
3337
+ const newFormattingSettings = {
3338
+ ...formattingSettings,
3339
+ decimals: numericValue
3340
+ };
3341
+ setFormattingSettings(newFormattingSettings);
3342
+ },
3343
+ [formattingSettings]
3344
+ );
3345
+ const handleChangeAlignDecimals = react.useCallback(
3346
+ (evt) => {
3347
+ const { checked } = evt.target;
3348
+ const newFormattingSettings = {
3349
+ ...formattingSettings,
3350
+ alignOnDecimals: checked
3351
+ };
3352
+ setFormattingSettings(newFormattingSettings);
3353
+ onChange(newFormattingSettings);
3354
+ },
3355
+ [formattingSettings, onChange]
3356
+ );
3357
+ const handleChangeZeroPad = react.useCallback(
3358
+ (evt) => {
3359
+ const { checked } = evt.target;
3360
+ const newFormattingSettings = {
3361
+ ...formattingSettings,
3362
+ zeroPad: checked
3363
+ };
3364
+ setFormattingSettings(newFormattingSettings);
3365
+ onChange(newFormattingSettings);
3366
+ },
3367
+ [formattingSettings, onChange]
3368
+ );
3369
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classBase$5, children: [
3370
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "decimals", children: [
3371
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Number of decimals" }),
3372
+ /* @__PURE__ */ jsxRuntime.jsx(
3373
+ core.Input,
3374
+ {
3375
+ className: "vuuInput",
3376
+ onChange: handleChangeDecimals,
3377
+ onKeyDown: handleInputKeyDown,
3378
+ value: formattingSettings.decimals ?? ""
3379
+ }
3380
+ )
3381
+ ] }),
3382
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { labelPlacement: "left", children: [
3383
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Align on decimals" }),
3384
+ /* @__PURE__ */ jsxRuntime.jsx(
3385
+ core.Switch,
3386
+ {
3387
+ checked: formattingSettings.alignOnDecimals ?? false,
3388
+ onChange: handleChangeAlignDecimals,
3389
+ value: "align-decimals"
3390
+ }
3391
+ )
3392
+ ] }),
3393
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { labelPlacement: "left", children: [
3394
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Zero pad decimals" }),
3395
+ /* @__PURE__ */ jsxRuntime.jsx(
3396
+ core.Switch,
3397
+ {
3398
+ checked: formattingSettings.zeroPad ?? false,
3399
+ onChange: handleChangeZeroPad,
3400
+ value: "zero-pad"
3401
+ }
3402
+ )
3403
+ ] })
3404
+ ] });
3405
+ };
3406
+
3407
+ const toggleValues$1 = ["date", "time", "both"];
3408
+ function getToggleValue(pattern) {
3409
+ return !pattern.time ? "date" : !pattern.date ? "time" : "both";
3410
+ }
3411
+ const getSelectedPattern = (pattern) => {
3412
+ if (vuuUtils.isDatePattern(pattern)) {
3413
+ return [pattern];
3414
+ } else if (vuuUtils.isTimePattern(pattern)) {
3415
+ return [pattern];
3416
+ } else {
3417
+ return void 0;
3418
+ }
3419
+ };
3420
+ const DateTimeFormattingSettings = ({ column, onChangeFormatting: onChange }) => {
3421
+ const formatting = vuuUtils.getTypeFormattingFromColumn(column);
3422
+ const { pattern = vuuUtils.fallbackDateTimePattern } = formatting;
3423
+ const toggleValue = react.useMemo(() => getToggleValue(pattern), [pattern]);
3424
+ const [fallbackState, setFallbackState] = react.useState(
3425
+ {
3426
+ time: pattern.time ?? vuuUtils.defaultPatternsByType.time,
3427
+ date: pattern.date ?? vuuUtils.defaultPatternsByType.date
3428
+ }
3429
+ );
3430
+ const onPatternChange = react.useCallback(
3431
+ (pattern2) => onChange({ ...formatting, pattern: pattern2 }),
3432
+ [onChange, formatting]
3433
+ );
3434
+ const onDropdownChange = react.useCallback(
3435
+ (dateTime) => (_, [selectedPattern]) => {
3436
+ const updatedPattern = {
3437
+ ...pattern ?? {},
3438
+ [dateTime]: selectedPattern
3439
+ };
3440
+ setFallbackState((s) => ({
3441
+ time: updatedPattern.time ?? s.time,
3442
+ date: updatedPattern.date ?? s.date
3443
+ }));
3444
+ onPatternChange(updatedPattern);
3445
+ },
3446
+ [onPatternChange, pattern]
3447
+ );
3448
+ const onToggleChange = react.useCallback(
3449
+ (evnt) => {
3450
+ const value = evnt.currentTarget.value;
3451
+ switch (value) {
3452
+ case "time":
3453
+ return onPatternChange({
3454
+ [value]: pattern[value] ?? fallbackState[value]
3455
+ });
3456
+ case "date":
3457
+ return onPatternChange({
3458
+ [value]: pattern[value] ?? fallbackState[value]
3459
+ });
3460
+ case "both":
3461
+ return onPatternChange({
3462
+ time: pattern.time ?? fallbackState.time,
3463
+ date: pattern.date ?? fallbackState.date
3464
+ });
3465
+ }
3466
+ },
3467
+ [onPatternChange, pattern, fallbackState]
3468
+ );
3469
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3470
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { labelPlacement: "top", children: [
3471
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Display" }),
3472
+ /* @__PURE__ */ jsxRuntime.jsx(
3473
+ core.ToggleButtonGroup,
3474
+ {
3475
+ className: "vuuToggleButtonGroup",
3476
+ onChange: onToggleChange,
3477
+ value: toggleValue,
3478
+ "data-variant": "primary",
3479
+ children: toggleValues$1.map((v) => /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: v, children: v.toUpperCase() }, v))
3480
+ }
3481
+ )
3482
+ ] }),
3483
+ ["date", "time"].filter((v) => !!pattern[v]).map((v) => /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { labelPlacement: "top", children: [
3484
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: `${vuuUtils.dateTimeLabelByType[v]} pattern` }),
3485
+ /* @__PURE__ */ jsxRuntime.jsx(
3486
+ core.Dropdown,
3487
+ {
3488
+ onSelectionChange: onDropdownChange(v),
3489
+ selected: getSelectedPattern(pattern[v]),
3490
+ children: vuuUtils.supportedDateTimePatterns[v].map((pattern2, i) => /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: pattern2, children: pattern2 }, i))
3491
+ }
3492
+ )
3493
+ ] }, v))
3494
+ ] });
3495
+ };
3496
+
3497
+ var longTypeFormattingSettingsCss = ".vuuLongColumnFormattingSettings {\n display: flex;\n flex-direction: column;\n gap: var(--salt-spacing-200);\n padding-top: 6px;\n}\n";
3498
+
3499
+ const classBase$4 = "vuuLongColumnFormattingSettings";
3500
+ const LongTypeFormattingSettings = (props) => {
3501
+ const targetWindow = window.useWindow();
3502
+ styles.useComponentCssInjection({
3503
+ testId: "vuu-long-formatting-settings",
3504
+ css: longTypeFormattingSettingsCss,
3505
+ window: targetWindow
3506
+ });
3507
+ const { column, onChangeColumnType: onChangeType } = props;
3508
+ const type = vuuUtils.isTypeDescriptor(column.type) ? column.type.name : column.type;
3509
+ const handleToggleChange = react.useCallback(
3510
+ (event) => {
3511
+ const value = event.currentTarget.value;
3512
+ onChangeType(value);
3513
+ },
3514
+ [onChangeType]
3515
+ );
3516
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classBase$4, children: [
3517
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { children: [
3518
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Type inferred as" }),
3519
+ /* @__PURE__ */ jsxRuntime.jsx(
3520
+ core.ToggleButtonGroup,
3521
+ {
3522
+ className: "vuuToggleButtonGroup",
3523
+ onChange: handleToggleChange,
3524
+ value: type ?? "number",
3525
+ children: toggleValues.map((v) => /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: v, children: v.toUpperCase() }, v))
3526
+ }
3527
+ )
3528
+ ] }),
3529
+ vuuUtils.isDateTimeDataValue(column) ? /* @__PURE__ */ jsxRuntime.jsx(DateTimeFormattingSettings, { ...props, column }) : /* @__PURE__ */ jsxRuntime.jsx(BaseNumericFormattingSettings, { ...props })
3530
+ ] });
3531
+ };
3532
+ const toggleValues = ["number", "date/time"];
3533
+
3534
+ const classBase$3 = "vuuColumnFormattingPanel";
3535
+ const ColumnFormattingPanel = ({
3536
+ availableRenderers,
3537
+ className,
3538
+ column,
3539
+ onChangeFormatting,
3540
+ onChangeColumnType,
3541
+ onChangeRendering,
3542
+ ...htmlAttributes
3543
+ }) => {
3544
+ const formattingSettingsComponent = react.useMemo(
3545
+ () => getFormattingSettingsComponent({
3546
+ column,
3547
+ onChangeFormatting,
3548
+ onChangeColumnType
3549
+ }),
3550
+ [column, onChangeColumnType, onChangeFormatting]
3551
+ );
3552
+ console.log({ formattingSettingsComponent });
3553
+ const ConfigEditor = react.useMemo(() => {
3554
+ const { type } = column;
3555
+ if (vuuUtils.isTypeDescriptor(type) && vuuUtils.isColumnTypeRenderer(type.renderer)) {
3556
+ const cellRendererOptions = vuuUtils.getCellRendererOptions(type.renderer.name);
3557
+ return vuuUtils.getConfigurationEditor(cellRendererOptions?.configEditor);
3558
+ }
3559
+ return void 0;
3560
+ }, [column]);
3561
+ const selectedCellRenderer = react.useMemo(() => {
3562
+ const { type } = column;
3563
+ const [defaultRenderer] = availableRenderers;
3564
+ const rendererName = vuuUtils.isTypeDescriptor(type) && vuuUtils.isColumnTypeRenderer(type.renderer) ? type.renderer.name : void 0;
3565
+ const configuredRenderer = availableRenderers.find(
3566
+ (renderer) => renderer.name === rendererName
3567
+ );
3568
+ return configuredRenderer ?? defaultRenderer;
3569
+ }, [availableRenderers, column]);
3570
+ const handleChangeRenderer = react.useCallback(
3571
+ (_e, [cellRendererDescriptor]) => {
3572
+ const renderProps = {
3573
+ name: cellRendererDescriptor.name
3574
+ };
3575
+ onChangeRendering?.(renderProps);
3576
+ },
3577
+ [onChangeRendering]
3578
+ );
3579
+ const { serverDataType = "string" } = column;
3580
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...htmlAttributes, className: `vuuColumnSettingsPanel-header`, children: [
3581
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Formatting" }),
3582
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { children: [
3583
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: `Renderer (data type ${column.serverDataType})` }),
3584
+ /* @__PURE__ */ jsxRuntime.jsx(
3585
+ core.Dropdown,
3586
+ {
3587
+ className: cx(`${classBase$3}-renderer`),
3588
+ onSelectionChange: handleChangeRenderer,
3589
+ selected: selectedCellRenderer ? [selectedCellRenderer] : [],
3590
+ value: selectedCellRenderer?.label ?? selectedCellRenderer?.name,
3591
+ children: availableRenderers.map((cellRenderer, i) => /* @__PURE__ */ jsxRuntime.jsx(core.Option, { value: cellRenderer, children: cellRenderer.label ?? cellRenderer.name }, i))
3592
+ }
3593
+ )
3594
+ ] }),
3595
+ /* @__PURE__ */ jsxRuntime.jsxs(
3596
+ "div",
3597
+ {
3598
+ className: cx(classBase$3, className, `${classBase$3}-${serverDataType}`),
3599
+ children: [
3600
+ formattingSettingsComponent,
3601
+ ConfigEditor ? /* @__PURE__ */ jsxRuntime.jsx(
3602
+ ConfigEditor,
3603
+ {
3604
+ column,
3605
+ onChangeRendering
3606
+ }
3607
+ ) : null
3608
+ ]
3609
+ }
3610
+ )
3611
+ ] });
3612
+ };
3613
+ function getFormattingSettingsComponent(props) {
3614
+ const { column } = props;
3615
+ switch (column.serverDataType) {
3616
+ case "double":
3617
+ case "int":
3618
+ return /* @__PURE__ */ jsxRuntime.jsx(BaseNumericFormattingSettings, { ...props });
3619
+ case "long":
3620
+ return /* @__PURE__ */ jsxRuntime.jsx(LongTypeFormattingSettings, { ...props });
3621
+ default:
3622
+ return null;
3623
+ }
3624
+ }
3625
+
3626
+ var columnNameLabelCss = ".vuuColumnNameLabel-calculated {\n cursor: pointer;\n display: flex;\n gap: 2px;\n}\n\n.vuuColumnNameLabel-edit {\n margin-left: auto;\n}\n\n.vuuColumnNameLabel-placeholder {\n color: var(--vuu-color-gray-35);\n}";
3627
+
3628
+ const classBase$2 = "vuuColumnNameLabel";
3629
+ const ColumnNameLabel = ({ column, onClick }) => {
3630
+ const targetWindow = window.useWindow();
3631
+ styles.useComponentCssInjection({
3632
+ testId: "vuu-column-label",
3633
+ css: columnNameLabelCss,
3634
+ window: targetWindow
3635
+ });
3636
+ if (vuuUtils.isCalculatedColumn(column.name)) {
3637
+ const { name, serverDataType, expression } = vuuUtils.getCalculatedColumnDetails(column);
3638
+ const displayName = name || "name";
3639
+ const displayExpression = "=expression";
3640
+ const nameClass = displayName === "name" ? `${classBase$2}-placeholder` : void 0;
3641
+ const expressionClass = expression === "" ? `${classBase$2}-placeholder` : void 0;
3642
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3643
+ "div",
3644
+ {
3645
+ className: cx(classBase$2, `${classBase$2}-calculated`),
3646
+ onClick,
3647
+ children: [
3648
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: nameClass, children: displayName }),
3649
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: ":" }),
3650
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: serverDataType || "string" }),
3651
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: ":" }),
3652
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: expressionClass, children: displayExpression }),
3653
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase$2}-edit`, "data-icon": "edit" })
3654
+ ]
3655
+ }
3656
+ );
3657
+ } else {
3658
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classBase$2, children: column.name });
3659
+ }
3660
+ };
3661
+
3662
+ const integerCellRenderers = [
3663
+ {
3664
+ description: "Default formatter for columns with data type integer",
3665
+ label: "Default Renderer (int, long)",
3666
+ name: "default-int"
3667
+ }
3668
+ ];
3669
+ const doubleCellRenderers = [
3670
+ {
3671
+ description: "Default formatter for columns with data type double",
3672
+ label: "Default Renderer (double)",
3673
+ name: "default-double"
3674
+ }
3675
+ ];
3676
+ const stringCellRenderers = [
3677
+ {
3678
+ description: "Default formatter for columns with data type string",
3679
+ label: "Default Renderer (string)",
3680
+ name: "default-string"
3681
+ }
3682
+ ];
3683
+ const booleanCellRenderers = [];
3684
+ const getAvailableCellRenderers = (column) => {
3685
+ switch (column.serverDataType) {
3686
+ case "char":
3687
+ case "string":
3688
+ return stringCellRenderers.concat(vuuUtils.getRegisteredCellRenderers("string"));
3689
+ case "int":
3690
+ case "long":
3691
+ return integerCellRenderers.concat(vuuUtils.getRegisteredCellRenderers("int"));
3692
+ case "double":
3693
+ return doubleCellRenderers.concat(vuuUtils.getRegisteredCellRenderers("double"));
3694
+ case "boolean":
3695
+ return booleanCellRenderers.concat(vuuUtils.getRegisteredCellRenderers("boolean"));
3696
+ default:
3697
+ return stringCellRenderers;
3698
+ }
3699
+ };
3700
+ const getColumn = (columns, column) => {
3701
+ if (column.name === "::") {
3702
+ return column;
3703
+ } else {
3704
+ const col = columns.find((col2) => col2.name === column.name);
3705
+ if (col) {
3706
+ return col;
3707
+ }
3708
+ throw Error(`columns does not contain column ${name}`);
3709
+ }
3710
+ };
3711
+ const replaceColumn = (tableConfig, column) => ({
3712
+ ...tableConfig,
3713
+ columns: tableConfig.columns.map(
3714
+ (col) => col.name === column.name ? column : col
3715
+ )
3716
+ });
3717
+ const useColumnSettings = ({
3718
+ column: columnProp,
3719
+ onCancelCreateColumn,
3720
+ onConfigChange,
3721
+ onCreateCalculatedColumn,
3722
+ tableConfig
3723
+ }) => {
3724
+ const [column, setColumn] = react.useState(
3725
+ getColumn(tableConfig.columns, columnProp)
3726
+ );
3727
+ const columnRef = react.useRef(column);
3728
+ const [inEditMode, setEditMode] = react.useState(column.name === "::");
3729
+ const handleEditCalculatedcolumn = react.useCallback(() => {
3730
+ columnRef.current = column;
3731
+ setEditMode(true);
3732
+ }, [column]);
3733
+ react.useEffect(() => {
3734
+ setColumn(columnProp);
3735
+ setEditMode(columnProp.name === "::");
3736
+ }, [columnProp]);
3737
+ const availableRenderers = react.useMemo(() => {
3738
+ return getAvailableCellRenderers(column);
3739
+ }, [column]);
3740
+ const handleInputCommit = react.useCallback(() => {
3741
+ onConfigChange(replaceColumn(tableConfig, column));
3742
+ }, [column, onConfigChange, tableConfig]);
3743
+ const handleChangeToggleButton = react.useCallback(
3744
+ (evt) => {
3745
+ const button = vuuUtils.queryClosest(evt.target, "button");
3746
+ if (button) {
3747
+ const fieldName = vuuUtils.getFieldName(button);
3748
+ const { value } = button;
3749
+ switch (fieldName) {
3750
+ case "column-alignment":
3751
+ if (vuuUtils.isValidColumnAlignment(value)) {
3752
+ const newColumn = {
3753
+ ...column,
3754
+ align: value || void 0
3755
+ };
3756
+ setColumn(newColumn);
3757
+ onConfigChange(replaceColumn(tableConfig, newColumn));
3758
+ }
3759
+ break;
3760
+ case "column-pin":
3761
+ if (vuuUtils.isValidPinLocation(value)) {
3762
+ const newColumn = {
3763
+ ...column,
3764
+ pin: value || void 0
3765
+ };
3766
+ setColumn(newColumn);
3767
+ onConfigChange(replaceColumn(tableConfig, newColumn));
3768
+ break;
3769
+ }
3770
+ }
3771
+ }
3772
+ },
3773
+ [column, onConfigChange, tableConfig]
3774
+ );
3775
+ const handleChange = react.useCallback((evt) => {
3776
+ const input = evt.target;
3777
+ const fieldName = vuuUtils.getFieldName(input);
3778
+ const { value } = input;
3779
+ switch (fieldName) {
3780
+ case "column-label":
3781
+ setColumn((state) => ({ ...state, label: value }));
3782
+ break;
3783
+ case "column-name":
3784
+ setColumn((state) => vuuUtils.setCalculatedColumnName(state, value));
3785
+ break;
3786
+ case "column-width":
3787
+ setColumn((state) => ({ ...state, width: parseInt(value) }));
3788
+ break;
3789
+ }
3790
+ }, []);
3791
+ const handleChangeCalculatedColumnName = react.useCallback((name2) => {
3792
+ setColumn((state) => ({ ...state, name: name2 }));
3793
+ }, []);
3794
+ const handleChangeFormatting = react.useCallback(
3795
+ (formatting) => {
3796
+ const newColumn = vuuUtils.updateColumnFormatting(column, formatting);
3797
+ setColumn(newColumn);
3798
+ onConfigChange(replaceColumn(tableConfig, newColumn));
3799
+ },
3800
+ [column, onConfigChange, tableConfig]
3801
+ );
3802
+ const handleChangeType = react.useCallback(
3803
+ (type) => {
3804
+ const updatedColumn = vuuUtils.updateColumnType(column, type);
3805
+ setColumn(updatedColumn);
3806
+ onConfigChange(replaceColumn(tableConfig, updatedColumn));
3807
+ },
3808
+ [column, onConfigChange, tableConfig]
3809
+ );
3810
+ const handleChangeServerDataType = react.useCallback(
3811
+ (serverDataType) => {
3812
+ setColumn((col) => ({ ...col, serverDataType }));
3813
+ },
3814
+ []
3815
+ );
3816
+ const handleChangeRendering = react.useCallback(
3817
+ (renderProps) => {
3818
+ if (renderProps) {
3819
+ const newColumn = vuuUtils.updateColumnRenderProps(
3820
+ column,
3821
+ renderProps
3822
+ );
3823
+ setColumn(newColumn);
3824
+ onConfigChange(replaceColumn(tableConfig, newColumn));
3825
+ }
3826
+ },
3827
+ [column, onConfigChange, tableConfig]
3828
+ );
3829
+ const navigateColumn = react.useCallback(
3830
+ ({ moveBy }) => {
3831
+ const { columns } = tableConfig;
3832
+ const index = columns.indexOf(column) + moveBy;
3833
+ const newColumn = columns[index];
3834
+ if (newColumn) {
3835
+ setColumn(newColumn);
3836
+ }
3837
+ },
3838
+ [column, tableConfig]
3839
+ );
3840
+ const navigateNextColumn = react.useCallback(() => {
3841
+ navigateColumn({ moveBy: 1 });
3842
+ }, [navigateColumn]);
3843
+ const navigatePrevColumn = react.useCallback(() => {
3844
+ navigateColumn({ moveBy: -1 });
3845
+ }, [navigateColumn]);
3846
+ const handleSaveCalculatedColumn = react.useCallback(() => {
3847
+ onCreateCalculatedColumn(column);
3848
+ }, [column, onCreateCalculatedColumn]);
3849
+ const handleCancelEdit = react.useCallback(() => {
3850
+ if (columnProp.name === "::") {
3851
+ onCancelCreateColumn();
3852
+ } else {
3853
+ if (columnRef.current !== void 0 && columnRef.current !== column) {
3854
+ setColumn(columnRef.current);
3855
+ }
3856
+ setEditMode(false);
3857
+ }
3858
+ }, [column, columnProp.name, onCancelCreateColumn]);
3859
+ return {
3860
+ availableRenderers,
3861
+ editCalculatedColumn: inEditMode,
3862
+ column,
3863
+ navigateNextColumn,
3864
+ navigatePrevColumn,
3865
+ onCancel: handleCancelEdit,
3866
+ onChange: handleChange,
3867
+ onChangeCalculatedColumnName: handleChangeCalculatedColumnName,
3868
+ onChangeFormatting: handleChangeFormatting,
3869
+ onChangeRendering: handleChangeRendering,
3870
+ onChangeServerDataType: handleChangeServerDataType,
3871
+ onChangeToggleButton: handleChangeToggleButton,
3872
+ onChangeType: handleChangeType,
3873
+ onEditCalculatedColumn: handleEditCalculatedcolumn,
3874
+ onInputCommit: handleInputCommit,
3875
+ onSave: handleSaveCalculatedColumn
3876
+ };
3877
+ };
3878
+
3879
+ var colunSettingsPanelCss = ".vuuColumnSettingsPanel {\n --vuu-svg-align-left: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M9.33333 10H2.66667C2.3 10 2 10.3 2 10.6667C2 11.0333 2.3 11.3333 2.66667 11.3333H9.33333C9.7 11.3333 10 11.0333 10 10.6667C10 10.3 9.7 10 9.33333 10ZM9.33333 4.66667H2.66667C2.3 4.66667 2 4.96667 2 5.33333C2 5.7 2.3 6 2.66667 6H9.33333C9.7 6 10 5.7 10 5.33333C10 4.96667 9.7 4.66667 9.33333 4.66667ZM2.66667 8.66667H13.3333C13.7 8.66667 14 8.36667 14 8C14 7.63333 13.7 7.33333 13.3333 7.33333H2.66667C2.3 7.33333 2 7.63333 2 8C2 8.36667 2.3 8.66667 2.66667 8.66667ZM2.66667 14H13.3333C13.7 14 14 13.7 14 13.3333C14 12.9667 13.7 12.6667 13.3333 12.6667H2.66667C2.3 12.6667 2 12.9667 2 13.3333C2 13.7 2.3 14 2.66667 14ZM2 2.66667C2 3.03333 2.3 3.33333 2.66667 3.33333H13.3333C13.7 3.33333 14 3.03333 14 2.66667C14 2.3 13.7 2 13.3333 2H2.66667C2.3 2 2 2.3 2 2.66667Z\" /></svg>');\n --vuu-svg-align-right: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M2.66667 14H13.3333C13.7 14 14 13.7 14 13.3333C14 12.9667 13.7 12.6667 13.3333 12.6667H2.66667C2.3 12.6667 2 12.9667 2 13.3333C2 13.7 2.3 14 2.66667 14ZM6.66667 11.3333H13.3333C13.7 11.3333 14 11.0333 14 10.6667C14 10.3 13.7 10 13.3333 10H6.66667C6.3 10 6 10.3 6 10.6667C6 11.0333 6.3 11.3333 6.66667 11.3333ZM2.66667 8.66667H13.3333C13.7 8.66667 14 8.36667 14 8C14 7.63333 13.7 7.33333 13.3333 7.33333H2.66667C2.3 7.33333 2 7.63333 2 8C2 8.36667 2.3 8.66667 2.66667 8.66667ZM6.66667 6H13.3333C13.7 6 14 5.7 14 5.33333C14 4.96667 13.7 4.66667 13.3333 4.66667H6.66667C6.3 4.66667 6 4.96667 6 5.33333C6 5.7 6.3 6 6.66667 6ZM2 2.66667C2 3.03333 2.3 3.33333 2.66667 3.33333H13.3333C13.7 3.33333 14 3.03333 14 2.66667C14 2.3 13.7 2 13.3333 2H2.66667C2.3 2 2 2.3 2 2.66667Z\" /></svg>');\n --vuu-svg-pin-left: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M7.33333 9.86V8.66666H13.3333C13.7 8.66666 14 8.36666 14 8C14 7.63333 13.7 7.33333 13.3333 7.33333L7.33333 7.33333V6.14C7.33333 5.84 6.97333 5.69333 6.76667 5.90666L4.90667 7.76666C4.77333 7.89999 4.77333 8.10666 4.90667 8.24L6.76667 10.1C6.97333 10.3067 7.33333 10.16 7.33333 9.86ZM2.66667 13.3333C3.03333 13.3333 3.33333 13.0333 3.33333 12.6667L3.33333 3.33333C3.33333 2.96666 3.03333 2.66666 2.66667 2.66666C2.3 2.66666 2 2.96666 2 3.33333L2 12.6667C2 13.0333 2.3 13.3333 2.66667 13.3333Z\" /></svg>');\n --vuu-svg-pin-float: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M6 4.66667H4.66667V6H6V4.66667ZM6 7.33333H4.66667V8.66667H6V7.33333ZM6 2C5.26 2 4.66667 2.6 4.66667 3.33333H6V2ZM8.66667 10H7.33333V11.3333H8.66667V10ZM12.6667 2V3.33333H14C14 2.6 13.4 2 12.6667 2ZM8.66667 2H7.33333V3.33333H8.66667V2ZM6 11.3333V10H4.66667C4.66667 10.7333 5.26 11.3333 6 11.3333ZM12.6667 8.66667H14V7.33333H12.6667V8.66667ZM12.6667 6H14V4.66667H12.6667V6ZM12.6667 11.3333C13.4 11.3333 14 10.7333 14 10H12.6667V11.3333ZM2.66667 4.66667C2.3 4.66667 2 4.96667 2 5.33333V12.6667C2 13.4 2.6 14 3.33333 14H10.6667C11.0333 14 11.3333 13.7 11.3333 13.3333C11.3333 12.9667 11.0333 12.6667 10.6667 12.6667H4C3.63333 12.6667 3.33333 12.3667 3.33333 12V5.33333C3.33333 4.96667 3.03333 4.66667 2.66667 4.66667ZM10 3.33333H11.3333V2H10V3.33333ZM10 11.3333H11.3333V10H10V11.3333Z\" /></svg>');\n --vuu-svg-pin-right: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M8.66667 6.14V7.33333H2.66667C2.3 7.33333 2 7.63333 2 8C2 8.36666 2.3 8.66666 2.66667 8.66666H8.66667V9.86C8.66667 10.16 9.02667 10.3067 9.23333 10.0933L11.0933 8.23333C11.2267 8.1 11.2267 7.89333 11.0933 7.76L9.23333 5.9C9.02667 5.69333 8.66667 5.84 8.66667 6.14ZM13.3333 13.3333C13.7 13.3333 14 13.0333 14 12.6667V3.33333C14 2.96666 13.7 2.66666 13.3333 2.66666C12.9667 2.66666 12.6667 2.96666 12.6667 3.33333V12.6667C12.6667 13.0333 12.9667 13.3333 13.3333 13.3333Z\"/></svg>');\n --vuuDropdown-height: 24px;\n --vuuDropdown-width: 100%;\n \n display: flex;\n flex-direction: column;\n gap: 24px;\n height: 100%;\n padding-top: 24px;\n}\n\n.vuuColumnSettingsPanel-header {\n border-top: solid 2px var(--vuu-color-gray-30);\n font-size: 14px;\n font-weight: 600;\n padding: 24px 2px 0 2px;\n}\n\n\n.vuuColumnSettingsPanel-buttonBar {\n align-items: center;\n display: flex;\n justify-content: space-between;\n margin-top: auto;\n}\n\n.vuuColumnSettingsPanel-buttonBar[data-align=\"right\"]{\n gap: 6px;\n justify-content: flex-end;\n}\n\n.vuuColumnSettingsPanel-buttonNavPrev {\n --vuu-icon-left: 6px;\n padding-left: 24px\n}\n\n.vuuColumnSettingsPanel-buttonNavNext {\n --vuu-icon-left: calc(100% - 18px);\n padding-right: 24px\n}\n\n\n\n[data-icon='align-left'] {\n --vuu-icon-svg: var(--vuu-svg-align-left);\n }\n\n [data-icon='align-right'] {\n --vuu-icon-svg: var(--vuu-svg-align-right);\n }\n\n [data-icon='pin-left'] {\n --vuu-icon-svg: var(--vuu-svg-pin-left);\n }\n [data-icon='pin-float'] {\n --vuu-icon-svg: var(--vuu-svg-pin-float);\n }\n [data-icon='pin-right'] {\n --vuu-icon-svg: var(--vuu-svg-pin-right);\n }\n\n .vuuColumnSettingsPanel-editing .vuuColumnNameLabel-edit {\n display: none;\n }\n \n\n\n \n \n \n \n \n";
3880
+
3881
+ const classBase$1 = "vuuColumnSettingsPanel";
3882
+ const getColumnLabel = (column) => {
3883
+ const { name, label } = column;
3884
+ if (vuuUtils.isCalculatedColumn(name)) {
3885
+ return label ?? vuuUtils.getCalculatedColumnDetails(column).name;
3886
+ } else {
3887
+ return label ?? name;
3888
+ }
3889
+ };
3890
+ const ColumnSettingsPanel = ({
3891
+ column: columnProp,
3892
+ onCancelCreateColumn,
3893
+ onConfigChange,
3894
+ onCreateCalculatedColumn,
3895
+ tableConfig,
3896
+ vuuTable
3897
+ }) => {
3898
+ const targetWindow = window.useWindow();
3899
+ styles.useComponentCssInjection({
3900
+ testId: "vuu-column-settings-panel",
3901
+ css: colunSettingsPanelCss,
3902
+ window: targetWindow
3903
+ });
3904
+ const isNewCalculatedColumn = columnProp.name === "::";
3905
+ const {
3906
+ availableRenderers,
3907
+ editCalculatedColumn,
3908
+ column,
3909
+ navigateNextColumn,
3910
+ navigatePrevColumn,
3911
+ onCancel,
3912
+ onChange,
3913
+ onChangeCalculatedColumnName,
3914
+ onChangeFormatting,
3915
+ onChangeRendering,
3916
+ onChangeServerDataType,
3917
+ onChangeToggleButton,
3918
+ onChangeType,
3919
+ onEditCalculatedColumn,
3920
+ onInputCommit,
3921
+ onSave
3922
+ } = useColumnSettings({
3923
+ column: columnProp,
3924
+ onCancelCreateColumn,
3925
+ onConfigChange,
3926
+ onCreateCalculatedColumn,
3927
+ tableConfig
3928
+ });
3929
+ const {
3930
+ serverDataType,
3931
+ align = vuuUtils.getDefaultAlignment(serverDataType),
3932
+ pin,
3933
+ width
3934
+ } = column;
3935
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3936
+ "div",
3937
+ {
3938
+ className: cx(classBase$1, {
3939
+ [`${classBase$1}-editing`]: editCalculatedColumn
3940
+ }),
3941
+ children: [
3942
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase$1}-header`, children: /* @__PURE__ */ jsxRuntime.jsx(ColumnNameLabel, { column, onClick: onEditCalculatedColumn }) }),
3943
+ editCalculatedColumn ? /* @__PURE__ */ jsxRuntime.jsx(
3944
+ ColumnExpressionPanel,
3945
+ {
3946
+ column,
3947
+ onChangeName: onChangeCalculatedColumnName,
3948
+ onChangeServerDataType,
3949
+ tableConfig,
3950
+ vuuTable
3951
+ }
3952
+ ) : null,
3953
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "column-label", children: [
3954
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Column Label" }),
3955
+ /* @__PURE__ */ jsxRuntime.jsx(
3956
+ vuuUiControls.VuuInput,
3957
+ {
3958
+ className: "vuuInput",
3959
+ "data-embedded": true,
3960
+ onChange,
3961
+ onCommit: onInputCommit,
3962
+ value: getColumnLabel(column)
3963
+ }
3964
+ )
3965
+ ] }),
3966
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "column-width", children: [
3967
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Column Width" }),
3968
+ /* @__PURE__ */ jsxRuntime.jsx(
3969
+ vuuUiControls.VuuInput,
3970
+ {
3971
+ className: "vuuInput",
3972
+ "data-embedded": true,
3973
+ onChange,
3974
+ value: width,
3975
+ onCommit: onInputCommit
3976
+ }
3977
+ )
3978
+ ] }),
3979
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "column-alignment", children: [
3980
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Alignment" }),
3981
+ /* @__PURE__ */ jsxRuntime.jsxs(core.ToggleButtonGroup, { onChange: onChangeToggleButton, value: align, children: [
3982
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: "left", children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "align-left", size: 16 }) }),
3983
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: "right", children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "align-right", size: 16 }) })
3984
+ ] })
3985
+ ] }),
3986
+ /* @__PURE__ */ jsxRuntime.jsxs(core.FormField, { "data-field": "column-pin", children: [
3987
+ /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldLabel, { children: "Pin Column" }),
3988
+ /* @__PURE__ */ jsxRuntime.jsxs(
3989
+ core.ToggleButtonGroup,
3990
+ {
3991
+ onChange: onChangeToggleButton,
3992
+ value: pin || "false",
3993
+ children: [
3994
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: "left", children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "pin-left", size: 16 }) }),
3995
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: "floating", children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "pin-float", size: 16 }) }),
3996
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: "right", children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "pin-right", size: 16 }) }),
3997
+ /* @__PURE__ */ jsxRuntime.jsx(core.ToggleButton, { value: "", children: /* @__PURE__ */ jsxRuntime.jsx(vuuUiControls.Icon, { name: "cross-circle", size: 16 }) })
3998
+ ]
3999
+ }
4000
+ )
4001
+ ] }),
4002
+ /* @__PURE__ */ jsxRuntime.jsx(
4003
+ ColumnFormattingPanel,
4004
+ {
4005
+ availableRenderers,
4006
+ column,
4007
+ onChangeFormatting,
4008
+ onChangeRendering,
4009
+ onChangeColumnType: onChangeType
4010
+ }
4011
+ ),
4012
+ editCalculatedColumn ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "vuuColumnSettingsPanel-buttonBar", "data-align": "right", children: [
4013
+ /* @__PURE__ */ jsxRuntime.jsx(
4014
+ core.Button,
4015
+ {
4016
+ className: `${classBase$1}-buttonCancel`,
4017
+ onClick: onCancel,
4018
+ tabIndex: -1,
4019
+ children: "cancel"
4020
+ }
4021
+ ),
4022
+ /* @__PURE__ */ jsxRuntime.jsx(
4023
+ core.Button,
4024
+ {
4025
+ className: `${classBase$1}-buttonSave`,
4026
+ onClick: onSave,
4027
+ variant: "cta",
4028
+ children: "save"
4029
+ }
4030
+ )
4031
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(
4032
+ "div",
4033
+ {
4034
+ className: `${classBase$1}-buttonBar`,
4035
+ "data-align": isNewCalculatedColumn ? "right" : void 0,
4036
+ children: [
4037
+ /* @__PURE__ */ jsxRuntime.jsx(
4038
+ core.Button,
4039
+ {
4040
+ className: `${classBase$1}-buttonNavPrev`,
4041
+ variant: "secondary",
4042
+ "data-icon": "arrow-left",
4043
+ onClick: navigatePrevColumn,
4044
+ children: "PREVIOUS"
4045
+ }
4046
+ ),
4047
+ /* @__PURE__ */ jsxRuntime.jsx(
4048
+ core.Button,
4049
+ {
4050
+ className: `${classBase$1}-buttonNavNext`,
4051
+ variant: "secondary",
4052
+ "data-icon": "arrow-right",
4053
+ onClick: navigateNextColumn,
4054
+ children: "NEXT"
4055
+ }
4056
+ )
4057
+ ]
4058
+ }
4059
+ )
4060
+ ]
4061
+ }
4062
+ );
4063
+ };
4064
+
4065
+ const columnSettingsFromColumnMenuPermissions = (settings) => typeof settings === void 0 ? true : typeof settings === "boolean" ? settings : settings?.allowColumnSettings ?? true;
4066
+ const tableSettingsFromColumnMenuPermissions = (settings) => typeof settings === void 0 ? defaultTableSettingsPermissions : typeof settings === "boolean" ? settings : settings?.allowTableSettings ?? defaultTableSettingsPermissions;
4067
+ const useTableAndColumnSettings = ({
4068
+ availableColumns: availableColumnsProps,
4069
+ settingsPermissions,
4070
+ onAvailableColumnsChange,
4071
+ onConfigChange,
4072
+ onCreateCalculatedColumn,
4073
+ onDataSourceConfigChange,
4074
+ tableConfig
4075
+ }) => {
4076
+ const showTableSettingsRef = react.useRef(void 0);
4077
+ const [availableColumns, setAvailableColumns] = react.useState(
4078
+ availableColumnsProps
4079
+ );
4080
+ const showContextPanel = vuuUiControls.useContextPanel();
4081
+ const handleCancelCreateColumn = react.useCallback(() => {
4082
+ requestAnimationFrame(() => {
4083
+ showTableSettingsRef.current?.();
4084
+ });
4085
+ }, []);
4086
+ const handleCreateCalculatedColumn = react.useCallback(
4087
+ (column) => {
4088
+ const { serverDataType } = vuuUtils.getCalculatedColumnDetails(column);
4089
+ if (serverDataType) {
4090
+ const newAvailableColumns = availableColumns.concat({
4091
+ name: column.name,
4092
+ serverDataType
4093
+ });
4094
+ setAvailableColumns(newAvailableColumns);
4095
+ onAvailableColumnsChange?.(newAvailableColumns);
4096
+ requestAnimationFrame(() => {
4097
+ showTableSettingsRef.current?.();
4098
+ });
4099
+ onCreateCalculatedColumn(column);
4100
+ } else {
4101
+ throw Error(
4102
+ "Cannot create calculatec columns without valis serverDataType"
4103
+ );
4104
+ }
4105
+ },
4106
+ [availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
4107
+ );
4108
+ const showColumnSettingsPanel = react.useCallback(
4109
+ (action) => {
4110
+ showContextPanel("ColumnSettings", "Column Settings", {
4111
+ column: action.column,
4112
+ onCancelCreateColumn: handleCancelCreateColumn,
4113
+ onConfigChange,
4114
+ onCreateCalculatedColumn: handleCreateCalculatedColumn,
4115
+ tableConfig,
4116
+ vuuTable: action.vuuTable
4117
+ });
4118
+ },
4119
+ [
4120
+ handleCancelCreateColumn,
4121
+ handleCreateCalculatedColumn,
4122
+ onConfigChange,
4123
+ showContextPanel,
4124
+ tableConfig
4125
+ ]
4126
+ );
4127
+ const handleAddCalculatedColumn = react.useCallback(() => {
4128
+ showColumnSettingsPanel({
4129
+ column: {
4130
+ name: "::",
4131
+ serverDataType: "string"
4132
+ },
4133
+ type: "column-settings",
4134
+ vuuTable: { module: "SIMUL", table: "instruments" }
4135
+ });
4136
+ }, [showColumnSettingsPanel]);
4137
+ const handleNavigateToColumn = react.useCallback(
4138
+ (columnName) => {
4139
+ const column = tableConfig.columns.find((c) => c.name === columnName);
4140
+ if (column) {
4141
+ showColumnSettingsPanel({
4142
+ type: "column-settings",
4143
+ column,
4144
+ //TODO where do we get this from
4145
+ vuuTable: { module: "SIMUL", table: "instruments" }
4146
+ });
4147
+ }
4148
+ },
4149
+ [showColumnSettingsPanel, tableConfig.columns]
4150
+ );
4151
+ showTableSettingsRef.current = react.useCallback(() => {
4152
+ showContextPanel("TableSettings", "DataGrid Settings", {
4153
+ availableColumns: availableColumns ?? tableConfig.columns.map(({ name, serverDataType }) => ({
4154
+ name,
4155
+ serverDataType
4156
+ })),
4157
+ onAddCalculatedColumn: handleAddCalculatedColumn,
4158
+ onConfigChange,
4159
+ onDataSourceConfigChange,
4160
+ onNavigateToColumn: handleNavigateToColumn,
4161
+ permissions: settingsPermissions?.allowTableSettings,
4162
+ tableConfig
4163
+ });
4164
+ }, [
4165
+ availableColumns,
4166
+ handleAddCalculatedColumn,
4167
+ handleNavigateToColumn,
4168
+ onConfigChange,
4169
+ onDataSourceConfigChange,
4170
+ settingsPermissions,
4171
+ showContextPanel,
4172
+ tableConfig
4173
+ ]);
4174
+ return {
4175
+ showColumnSettingsPanel,
4176
+ showTableSettingsPanel: showTableSettingsRef.current
4177
+ };
4178
+ };
4179
+
4180
+ var dataSourceStats = ".vuuDatasourceStats {\n display: flex;\n font-size: 10px;\n gap: var(--salt-spacing-100);\n padding: 4px 0 0 12px;\n}\n\n.vuuDatasourceStats-label {\n color: var(--salt-content-secondary-foreground);\n}\n";
4181
+
4182
+ const classBase = "vuuDatasourceStats";
4183
+ const numberFormatter = new Intl.NumberFormat();
4184
+ const DataSourceStats = ({
4185
+ className: classNameProp,
4186
+ dataSource
4187
+ }) => {
4188
+ const targetWindow = window.useWindow();
4189
+ styles.useComponentCssInjection({
4190
+ testId: "vuu-datasource-stats",
4191
+ css: dataSourceStats,
4192
+ window: targetWindow
4193
+ });
4194
+ const [range, setRange] = react.useState(dataSource.range);
4195
+ const [size, setSize] = react.useState(dataSource.size);
4196
+ react.useEffect(() => {
4197
+ setSize(dataSource.size);
4198
+ dataSource.on("resize", setSize);
4199
+ dataSource.on("range", setRange);
4200
+ return () => {
4201
+ dataSource.removeListener("resize", setSize);
4202
+ dataSource.removeListener("range", setRange);
4203
+ };
4204
+ }, [dataSource]);
4205
+ const className = cx(classBase, classNameProp);
4206
+ const from = numberFormatter.format(range.firstRowInViewport);
4207
+ const to = numberFormatter.format(range.lastRowInViewport);
4208
+ const value = numberFormatter.format(size);
4209
+ if (size === 0) {
4210
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase}-label`, children: "No Rows to display" }) });
4211
+ } else {
4212
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
4213
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase}-label`, children: "Rows" }),
4214
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase}-range`, children: from }),
4215
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "-" }),
4216
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase}-range`, children: to }),
4217
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "of" }),
4218
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${classBase}-size`, children: value })
4219
+ ] });
4220
+ }
4221
+ };
4222
+
4223
+ exports.BackgroundCell = BackgroundCell;
4224
+ exports.BackgroundCellConfigurationEditor = BackgroundCellConfigurationEditor;
4225
+ exports.BaseNumericFormattingSettings = BaseNumericFormattingSettings;
4226
+ exports.CaseValidator = CaseValidator;
4227
+ exports.ColumnExpressionInput = ColumnExpressionInput;
4228
+ exports.ColumnExpressionPanel = ColumnExpressionPanel;
4229
+ exports.ColumnFormattingPanel = ColumnFormattingPanel;
4230
+ exports.ColumnList = ColumnList;
4231
+ exports.ColumnMenu = ColumnMenu;
4232
+ exports.ColumnNamedTerms = ColumnNamedTerms;
4233
+ exports.ColumnSettingsPanel = ColumnSettingsPanel;
4234
+ exports.DataSourceStats = DataSourceStats;
4235
+ exports.DateTimeFormattingSettings = DateTimeFormattingSettings;
4236
+ exports.DropdownCell = DropdownCell;
4237
+ exports.LookupCell = LookupCell;
4238
+ exports.PatternValidator = PatternValidator;
4239
+ exports.PctProgressCell = PctProgressCell;
4240
+ exports.TableProvider = TableProvider;
4241
+ exports.TableSettingsPanel = TableSettingsPanel;
4242
+ exports.columnExpressionLanguageSupport = columnExpressionLanguageSupport;
4243
+ exports.columnSettingsFromColumnMenuPermissions = columnSettingsFromColumnMenuPermissions;
4244
+ exports.defaultTableSettingsPermissions = defaultTableSettingsPermissions;
4245
+ exports.isCompleteExpression = isCompleteExpression;
4246
+ exports.isCompleteRelationalExpression = isCompleteRelationalExpression;
4247
+ exports.lastNamedChild = lastNamedChild;
4248
+ exports.tableSettingsFromColumnMenuPermissions = tableSettingsFromColumnMenuPermissions;
4249
+ exports.useColumnActions = useColumnActions;
4250
+ exports.useColumnExpressionEditor = useColumnExpressionEditor;
4251
+ exports.useColumnExpressionSuggestionProvider = useColumnExpressionSuggestionProvider;
4252
+ exports.useColumnSettings = useColumnSettings;
4253
+ exports.useTableAndColumnSettings = useTableAndColumnSettings;
4254
+ exports.useTableContext = useTableContext;
4255
+ exports.useTableSettings = useTableSettings;
4256
+ exports.walkTree = walkTree;
68
4257
  //# sourceMappingURL=index.js.map