@deephaven/iris-grid 0.43.0 → 0.44.1-beta.0

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 (282) hide show
  1. package/dist/AdvancedFilterCreator.css +106 -0
  2. package/dist/AdvancedFilterCreator.css.map +1 -0
  3. package/dist/AdvancedFilterCreator.js +541 -0
  4. package/dist/AdvancedFilterCreator.js.map +1 -0
  5. package/dist/AdvancedFilterCreatorFilterItem.css +9 -0
  6. package/dist/AdvancedFilterCreatorFilterItem.css.map +1 -0
  7. package/dist/AdvancedFilterCreatorFilterItem.js +184 -0
  8. package/dist/AdvancedFilterCreatorFilterItem.js.map +1 -0
  9. package/dist/AdvancedFilterCreatorSelectValue.css +50 -0
  10. package/dist/AdvancedFilterCreatorSelectValue.css.map +1 -0
  11. package/dist/AdvancedFilterCreatorSelectValue.js +301 -0
  12. package/dist/AdvancedFilterCreatorSelectValue.js.map +1 -0
  13. package/dist/AdvancedFilterCreatorSelectValueList.js +272 -0
  14. package/dist/AdvancedFilterCreatorSelectValueList.js.map +1 -0
  15. package/dist/ColumnHeaderGroup.js +61 -0
  16. package/dist/ColumnHeaderGroup.js.map +1 -0
  17. package/dist/ColumnStatistics.css +76 -0
  18. package/dist/ColumnStatistics.css.map +1 -0
  19. package/dist/ColumnStatistics.js +202 -0
  20. package/dist/ColumnStatistics.js.map +1 -0
  21. package/dist/CommonTypes.js +2 -0
  22. package/dist/CommonTypes.js.map +1 -0
  23. package/dist/CrossColumnSearch.css +35 -0
  24. package/dist/CrossColumnSearch.css.map +1 -0
  25. package/dist/CrossColumnSearch.js +199 -0
  26. package/dist/CrossColumnSearch.js.map +1 -0
  27. package/dist/FilterInputField.css +56 -0
  28. package/dist/FilterInputField.css.map +1 -0
  29. package/dist/FilterInputField.js +232 -0
  30. package/dist/FilterInputField.js.map +1 -0
  31. package/dist/GotoRow.css +45 -0
  32. package/dist/GotoRow.css.map +1 -0
  33. package/dist/GotoRow.js +298 -0
  34. package/dist/GotoRow.js.map +1 -0
  35. package/dist/IrisGrid.css +359 -0
  36. package/dist/IrisGrid.css.map +1 -0
  37. package/dist/IrisGrid.js +3651 -0
  38. package/dist/IrisGrid.js.map +1 -0
  39. package/dist/IrisGridBottomBar.css +85 -0
  40. package/dist/IrisGridBottomBar.css.map +1 -0
  41. package/dist/IrisGridBottomBar.js +36 -0
  42. package/dist/IrisGridBottomBar.js.map +1 -0
  43. package/dist/IrisGridCellOverflowModal.css +17 -0
  44. package/dist/IrisGridCellOverflowModal.css.map +1 -0
  45. package/dist/IrisGridCellOverflowModal.js +157 -0
  46. package/dist/IrisGridCellOverflowModal.js.map +1 -0
  47. package/dist/IrisGridCellRendererUtils.js +20 -0
  48. package/dist/IrisGridCellRendererUtils.js.map +1 -0
  49. package/dist/IrisGridCopyHandler.css +64 -0
  50. package/dist/IrisGridCopyHandler.css.map +1 -0
  51. package/dist/IrisGridCopyHandler.js +331 -0
  52. package/dist/IrisGridCopyHandler.js.map +1 -0
  53. package/dist/IrisGridDataBarCellRenderer.js +10 -0
  54. package/dist/IrisGridDataBarCellRenderer.js.map +1 -0
  55. package/dist/IrisGridIcons.js +25 -0
  56. package/dist/IrisGridIcons.js.map +1 -0
  57. package/dist/IrisGridMetricCalculator.js +33 -0
  58. package/dist/IrisGridMetricCalculator.js.map +1 -0
  59. package/dist/IrisGridModel.js +263 -0
  60. package/dist/IrisGridModel.js.map +1 -0
  61. package/dist/IrisGridModelFactory.js +27 -0
  62. package/dist/IrisGridModelFactory.js.map +1 -0
  63. package/dist/IrisGridModelUpdater.js +96 -0
  64. package/dist/IrisGridModelUpdater.js.map +1 -0
  65. package/dist/IrisGridPartitionSelector.css +48 -0
  66. package/dist/IrisGridPartitionSelector.css.map +1 -0
  67. package/dist/IrisGridPartitionSelector.js +198 -0
  68. package/dist/IrisGridPartitionSelector.js.map +1 -0
  69. package/dist/IrisGridProxyModel.js +530 -0
  70. package/dist/IrisGridProxyModel.js.map +1 -0
  71. package/dist/IrisGridRenderer.js +779 -0
  72. package/dist/IrisGridRenderer.js.map +1 -0
  73. package/dist/IrisGridShortcuts.js +59 -0
  74. package/dist/IrisGridShortcuts.js.map +1 -0
  75. package/dist/IrisGridTableModel.js +273 -0
  76. package/dist/IrisGridTableModel.js.map +1 -0
  77. package/dist/IrisGridTableModelTemplate.js +1589 -0
  78. package/dist/IrisGridTableModelTemplate.js.map +1 -0
  79. package/dist/IrisGridTestUtils.js +121 -0
  80. package/dist/IrisGridTestUtils.js.map +1 -0
  81. package/dist/IrisGridTextCellRenderer.js +139 -0
  82. package/dist/IrisGridTextCellRenderer.js.map +1 -0
  83. package/dist/IrisGridTheme.js +96 -0
  84. package/dist/IrisGridTheme.js.map +1 -0
  85. package/dist/IrisGridTheme.module.css +69 -0
  86. package/dist/IrisGridTheme.module.css.map +1 -0
  87. package/dist/IrisGridTreeTableModel.js +145 -0
  88. package/dist/IrisGridTreeTableModel.js.map +1 -0
  89. package/dist/IrisGridUtils.js +1279 -0
  90. package/dist/IrisGridUtils.js.map +1 -0
  91. package/dist/MissingKeyError.js +15 -0
  92. package/dist/MissingKeyError.js.map +1 -0
  93. package/dist/PartitionSelectorSearch.css +22 -0
  94. package/dist/PartitionSelectorSearch.css.map +1 -0
  95. package/dist/PartitionSelectorSearch.js +317 -0
  96. package/dist/PartitionSelectorSearch.js.map +1 -0
  97. package/dist/PendingDataBottomBar.css +13 -0
  98. package/dist/PendingDataBottomBar.css.map +1 -0
  99. package/dist/PendingDataBottomBar.js +98 -0
  100. package/dist/PendingDataBottomBar.js.map +1 -0
  101. package/dist/TableViewportUpdater.js +156 -0
  102. package/dist/TableViewportUpdater.js.map +1 -0
  103. package/dist/ToastBottomBar.js +42 -0
  104. package/dist/ToastBottomBar.js.map +1 -0
  105. package/dist/TreeTableViewportUpdater.js +96 -0
  106. package/dist/TreeTableViewportUpdater.js.map +1 -0
  107. package/dist/declaration.d.js +2 -0
  108. package/dist/declaration.d.js.map +1 -0
  109. package/dist/format-context-menus/CustomFormatAction.css +25 -0
  110. package/dist/format-context-menus/CustomFormatAction.css.map +1 -0
  111. package/dist/format-context-menus/CustomFormatAction.js +132 -0
  112. package/dist/format-context-menus/CustomFormatAction.js.map +1 -0
  113. package/dist/format-context-menus/DateTimeFormatContextMenu.js +53 -0
  114. package/dist/format-context-menus/DateTimeFormatContextMenu.js.map +1 -0
  115. package/dist/format-context-menus/DecimalFormatContextMenu.js +59 -0
  116. package/dist/format-context-menus/DecimalFormatContextMenu.js.map +1 -0
  117. package/dist/format-context-menus/FormatContextMenuUtils.js +63 -0
  118. package/dist/format-context-menus/FormatContextMenuUtils.js.map +1 -0
  119. package/dist/format-context-menus/IntegerFormatContextMenu.js +43 -0
  120. package/dist/format-context-menus/IntegerFormatContextMenu.js.map +1 -0
  121. package/dist/format-context-menus/index.js +4 -0
  122. package/dist/format-context-menus/index.js.map +1 -0
  123. package/dist/index.js +24 -0
  124. package/dist/index.js.map +1 -0
  125. package/dist/key-handlers/ClearFilterKeyHandler.js +21 -0
  126. package/dist/key-handlers/ClearFilterKeyHandler.js.map +1 -0
  127. package/dist/key-handlers/CopyKeyHandler.js +31 -0
  128. package/dist/key-handlers/CopyKeyHandler.js.map +1 -0
  129. package/dist/key-handlers/ReverseKeyHandler.js +32 -0
  130. package/dist/key-handlers/ReverseKeyHandler.js.map +1 -0
  131. package/dist/key-handlers/index.js +4 -0
  132. package/dist/key-handlers/index.js.map +1 -0
  133. package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.js +175 -0
  134. package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.js.map +1 -0
  135. package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js +139 -0
  136. package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js.map +1 -0
  137. package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js +83 -0
  138. package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js.map +1 -0
  139. package/dist/mousehandlers/IrisGridContextMenuHandler.css +19 -0
  140. package/dist/mousehandlers/IrisGridContextMenuHandler.css.map +1 -0
  141. package/dist/mousehandlers/IrisGridContextMenuHandler.js +1220 -0
  142. package/dist/mousehandlers/IrisGridContextMenuHandler.js.map +1 -0
  143. package/dist/mousehandlers/IrisGridDataSelectMouseHandler.js +28 -0
  144. package/dist/mousehandlers/IrisGridDataSelectMouseHandler.js.map +1 -0
  145. package/dist/mousehandlers/IrisGridFilterMouseHandler.js +80 -0
  146. package/dist/mousehandlers/IrisGridFilterMouseHandler.js.map +1 -0
  147. package/dist/mousehandlers/IrisGridRowTreeMouseHandler.js +126 -0
  148. package/dist/mousehandlers/IrisGridRowTreeMouseHandler.js.map +1 -0
  149. package/dist/mousehandlers/IrisGridSortMouseHandler.js +46 -0
  150. package/dist/mousehandlers/IrisGridSortMouseHandler.js.map +1 -0
  151. package/dist/mousehandlers/IrisGridTokenMouseHandler.js +151 -0
  152. package/dist/mousehandlers/IrisGridTokenMouseHandler.js.map +1 -0
  153. package/dist/mousehandlers/PendingMouseHandler.js +39 -0
  154. package/dist/mousehandlers/PendingMouseHandler.js.map +1 -0
  155. package/dist/mousehandlers/index.js +11 -0
  156. package/dist/mousehandlers/index.js.map +1 -0
  157. package/dist/sidebar/AdvancedSettings.js +6 -0
  158. package/dist/sidebar/AdvancedSettings.js.map +1 -0
  159. package/dist/sidebar/AdvancedSettingsMenu.js +29 -0
  160. package/dist/sidebar/AdvancedSettingsMenu.js.map +1 -0
  161. package/dist/sidebar/AdvancedSettingsType.js +7 -0
  162. package/dist/sidebar/AdvancedSettingsType.js.map +1 -0
  163. package/dist/sidebar/ChartBuilder.css +56 -0
  164. package/dist/sidebar/ChartBuilder.css.map +1 -0
  165. package/dist/sidebar/ChartBuilder.js +443 -0
  166. package/dist/sidebar/ChartBuilder.js.map +1 -0
  167. package/dist/sidebar/CustomColumnBuilder.css +58 -0
  168. package/dist/sidebar/CustomColumnBuilder.css.map +1 -0
  169. package/dist/sidebar/CustomColumnBuilder.js +384 -0
  170. package/dist/sidebar/CustomColumnBuilder.js.map +1 -0
  171. package/dist/sidebar/CustomColumnInput.d.ts.map +1 -1
  172. package/dist/sidebar/CustomColumnInput.js +91 -0
  173. package/dist/sidebar/CustomColumnInput.js.map +1 -0
  174. package/dist/sidebar/InputEditor.css +35 -0
  175. package/dist/sidebar/InputEditor.css.map +1 -0
  176. package/dist/sidebar/InputEditor.d.ts +4 -2
  177. package/dist/sidebar/InputEditor.d.ts.map +1 -1
  178. package/dist/sidebar/InputEditor.js +180 -0
  179. package/dist/sidebar/InputEditor.js.map +1 -0
  180. package/dist/sidebar/OptionType.js +19 -0
  181. package/dist/sidebar/OptionType.js.map +1 -0
  182. package/dist/sidebar/RollupRows.css +120 -0
  183. package/dist/sidebar/RollupRows.css.map +1 -0
  184. package/dist/sidebar/RollupRows.js +519 -0
  185. package/dist/sidebar/RollupRows.js.map +1 -0
  186. package/dist/sidebar/SelectDistinctBuilder.css +41 -0
  187. package/dist/sidebar/SelectDistinctBuilder.css.map +1 -0
  188. package/dist/sidebar/SelectDistinctBuilder.js +155 -0
  189. package/dist/sidebar/SelectDistinctBuilder.js.map +1 -0
  190. package/dist/sidebar/TableCsvExporter.css +32 -0
  191. package/dist/sidebar/TableCsvExporter.css.map +1 -0
  192. package/dist/sidebar/TableCsvExporter.js +399 -0
  193. package/dist/sidebar/TableCsvExporter.js.map +1 -0
  194. package/dist/sidebar/TableSaver.js +487 -0
  195. package/dist/sidebar/TableSaver.js.map +1 -0
  196. package/dist/sidebar/aggregations/AggregationEdit.css +61 -0
  197. package/dist/sidebar/aggregations/AggregationEdit.css.map +1 -0
  198. package/dist/sidebar/aggregations/AggregationEdit.js +155 -0
  199. package/dist/sidebar/aggregations/AggregationEdit.js.map +1 -0
  200. package/dist/sidebar/aggregations/AggregationOperation.js +19 -0
  201. package/dist/sidebar/aggregations/AggregationOperation.js.map +1 -0
  202. package/dist/sidebar/aggregations/AggregationUtils.js +59 -0
  203. package/dist/sidebar/aggregations/AggregationUtils.js.map +1 -0
  204. package/dist/sidebar/aggregations/Aggregations.css +43 -0
  205. package/dist/sidebar/aggregations/Aggregations.css.map +1 -0
  206. package/dist/sidebar/aggregations/Aggregations.js +178 -0
  207. package/dist/sidebar/aggregations/Aggregations.js.map +1 -0
  208. package/dist/sidebar/aggregations/index.js +2 -0
  209. package/dist/sidebar/aggregations/index.js.map +1 -0
  210. package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js +123 -0
  211. package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js.map +1 -0
  212. package/dist/sidebar/conditional-formatting/ConditionEditor.js +243 -0
  213. package/dist/sidebar/conditional-formatting/ConditionEditor.js.map +1 -0
  214. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.css +22 -0
  215. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.css.map +1 -0
  216. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js +109 -0
  217. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js.map +1 -0
  218. package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js +18 -0
  219. package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js.map +1 -0
  220. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.css +57 -0
  221. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.css.map +1 -0
  222. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js +150 -0
  223. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js.map +1 -0
  224. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js +635 -0
  225. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js.map +1 -0
  226. package/dist/sidebar/conditional-formatting/RowFormatEditor.js +122 -0
  227. package/dist/sidebar/conditional-formatting/RowFormatEditor.js.map +1 -0
  228. package/dist/sidebar/conditional-formatting/StyleEditor.css +55 -0
  229. package/dist/sidebar/conditional-formatting/StyleEditor.css.map +1 -0
  230. package/dist/sidebar/conditional-formatting/StyleEditor.js +150 -0
  231. package/dist/sidebar/conditional-formatting/StyleEditor.js.map +1 -0
  232. package/dist/sidebar/icons/BarIcon.js +24 -0
  233. package/dist/sidebar/icons/BarIcon.js.map +1 -0
  234. package/dist/sidebar/icons/FormatColumnWhereIcon.js +42 -0
  235. package/dist/sidebar/icons/FormatColumnWhereIcon.js.map +1 -0
  236. package/dist/sidebar/icons/FormatRowWhereIcon.js +36 -0
  237. package/dist/sidebar/icons/FormatRowWhereIcon.js.map +1 -0
  238. package/dist/sidebar/icons/HistogramIcon.js +24 -0
  239. package/dist/sidebar/icons/HistogramIcon.js.map +1 -0
  240. package/dist/sidebar/icons/LineIcon.js +27 -0
  241. package/dist/sidebar/icons/LineIcon.js.map +1 -0
  242. package/dist/sidebar/icons/PieIcon.js +24 -0
  243. package/dist/sidebar/icons/PieIcon.js.map +1 -0
  244. package/dist/sidebar/icons/ScatterIcon.js +74 -0
  245. package/dist/sidebar/icons/ScatterIcon.js.map +1 -0
  246. package/dist/sidebar/icons/index.js +8 -0
  247. package/dist/sidebar/icons/index.js.map +1 -0
  248. package/dist/sidebar/index.d.ts +1 -0
  249. package/dist/sidebar/index.d.ts.map +1 -1
  250. package/dist/sidebar/index.js +19 -0
  251. package/dist/sidebar/index.js.map +1 -0
  252. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingBuilder.css +68 -0
  253. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingBuilder.css.map +1 -0
  254. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingBuilder.js +964 -0
  255. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingBuilder.js.map +1 -0
  256. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingBuilderUtils.js +132 -0
  257. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingBuilderUtils.js.map +1 -0
  258. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.css +29 -0
  259. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.css.map +1 -0
  260. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.js +188 -0
  261. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.js.map +1 -0
  262. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingItem.js +81 -0
  263. package/dist/sidebar/visibility-ordering-builder/VisibilityOrderingItem.js.map +1 -0
  264. package/dist/sidebar/visibility-ordering-builder/sortable-tree/PointerSensorWithInteraction.js +30 -0
  265. package/dist/sidebar/visibility-ordering-builder/sortable-tree/PointerSensorWithInteraction.js.map +1 -0
  266. package/dist/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.js +158 -0
  267. package/dist/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.js.map +1 -0
  268. package/dist/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.js +146 -0
  269. package/dist/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.js.map +1 -0
  270. package/dist/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeItem.js +59 -0
  271. package/dist/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeItem.js.map +1 -0
  272. package/dist/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.css +139 -0
  273. package/dist/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.css.map +1 -0
  274. package/dist/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.js +44 -0
  275. package/dist/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.js.map +1 -0
  276. package/dist/sidebar/visibility-ordering-builder/sortable-tree/keyboardCoordinates.js +129 -0
  277. package/dist/sidebar/visibility-ordering-builder/sortable-tree/keyboardCoordinates.js.map +1 -0
  278. package/dist/sidebar/visibility-ordering-builder/sortable-tree/types.js +4 -0
  279. package/dist/sidebar/visibility-ordering-builder/sortable-tree/types.js.map +1 -0
  280. package/dist/sidebar/visibility-ordering-builder/sortable-tree/utilities.js +261 -0
  281. package/dist/sidebar/visibility-ordering-builder/sortable-tree/utilities.js.map +1 -0
  282. package/package.json +15 -15
@@ -0,0 +1,1589 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ /* eslint-disable no-underscore-dangle */
9
+ /* eslint class-methods-use-this: "off" */
10
+ import memoize from 'memoize-one';
11
+ import throttle from 'lodash.throttle';
12
+ import { GridRange, GridUtils, memoizeClear } from '@deephaven/grid';
13
+ import Log from '@deephaven/log';
14
+ import { EventShimCustomEvent, PromiseUtils, assertNotNull } from '@deephaven/utils';
15
+ import { TableUtils, Formatter, FormatterUtils } from '@deephaven/jsapi-utils';
16
+ import IrisGridModel from "./IrisGridModel.js";
17
+ import AggregationOperation from "./sidebar/aggregations/AggregationOperation.js";
18
+ import IrisGridUtils from "./IrisGridUtils.js";
19
+ import MissingKeyError from "./MissingKeyError.js";
20
+ import { isColumnHeaderGroup } from "./ColumnHeaderGroup.js";
21
+ var log = Log.module('IrisGridTableModel');
22
+ var SET_VIEWPORT_THROTTLE = 150;
23
+ var APPLY_VIEWPORT_THROTTLE = 0;
24
+ var EMPTY_ARRAY = [];
25
+ export function isIrisGridTableModelTemplate(model) {
26
+ return model.table !== undefined;
27
+ }
28
+
29
+ /**
30
+ * Template model for a grid
31
+ */
32
+
33
+ class IrisGridTableModelTemplate extends IrisGridModel {
34
+ seekRow(startRow, column, valueType, value, insensitive, contains, isBackwards) {
35
+ throw new Error('Method not implemented.');
36
+ }
37
+ export() {
38
+ throw new Error('Method not implemented.');
39
+ }
40
+ columnStatistics(column) {
41
+ throw new Error('Method not implemented.');
42
+ }
43
+ get customColumns() {
44
+ return [];
45
+ }
46
+ set customColumns(customColumns) {
47
+ throw new Error('Method not implemented.');
48
+ }
49
+ get formatColumns() {
50
+ return [];
51
+ }
52
+ set formatColumns(formatColumns) {
53
+ throw new Error('Method not implemented.');
54
+ }
55
+ updateFrozenColumns(columns) {
56
+ throw new Error('Method not implemented.');
57
+ }
58
+ get rollupConfig() {
59
+ throw new Error('Method not implemented.');
60
+ }
61
+ set rollupConfig(rollupConfig) {
62
+ throw new Error('Method not implemented.');
63
+ }
64
+ get selectDistinctColumns() {
65
+ throw new Error('Method not implemented.');
66
+ }
67
+ set selectDistinctColumns(names) {
68
+ throw new Error('Method not implemented.');
69
+ }
70
+
71
+ /**
72
+ * Returns an array of the columns in the model
73
+ * The order of model columns should never change once established
74
+ */
75
+ get columns() {
76
+ return this.table.columns;
77
+ }
78
+ /**
79
+ * @param dh JSAPI instance
80
+ * @param table Iris data table to be used in the model
81
+ * @param formatter The formatter to use when getting formats
82
+ * @param inputTable Iris input table associated with this table
83
+ */
84
+ constructor(dh, table) {
85
+ var _this$layoutHints$col, _this$layoutHints;
86
+ var _formatter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Formatter(dh);
87
+ var inputTable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
88
+ super(dh);
89
+ _defineProperty(this, "dh", void 0);
90
+ _defineProperty(this, "irisGridUtils", void 0);
91
+ _defineProperty(this, "tableUtils", void 0);
92
+ _defineProperty(this, "irisFormatter", void 0);
93
+ _defineProperty(this, "inputTable", void 0);
94
+ _defineProperty(this, "subscription", void 0);
95
+ _defineProperty(this, "table", void 0);
96
+ _defineProperty(this, "viewport", void 0);
97
+ _defineProperty(this, "viewportData", void 0);
98
+ _defineProperty(this, "formattedStringData", void 0);
99
+ _defineProperty(this, "pendingStringData", void 0);
100
+ _defineProperty(this, "isSaveInProgress", void 0);
101
+ _defineProperty(this, "totalsTable", void 0);
102
+ _defineProperty(this, "totalsTablePromise", void 0);
103
+ _defineProperty(this, "totals", void 0);
104
+ _defineProperty(this, "totalsDataMap", void 0);
105
+ _defineProperty(this, "pendingNewDataMap", void 0);
106
+ _defineProperty(this, "pendingNewRowCount", 0);
107
+ _defineProperty(this, "_columnHeaderGroupMap", new Map());
108
+ _defineProperty(this, "columnHeaderParentMap", new Map());
109
+ _defineProperty(this, "_columnHeaderMaxDepth", null);
110
+ _defineProperty(this, "_columnHeaderGroups", []);
111
+ _defineProperty(this, "_movedColumns", null);
112
+ _defineProperty(this, "getMemoizedInitialMovedColumns", memoize(layoutHints => {
113
+ var _layoutHints$columnGr;
114
+ if (!layoutHints) {
115
+ return [];
116
+ }
117
+ var movedColumns = [];
118
+ var {
119
+ groupMap
120
+ } = IrisGridUtils.parseColumnHeaderGroups(this, (_layoutHints$columnGr = layoutHints === null || layoutHints === void 0 ? void 0 : layoutHints.columnGroups) !== null && _layoutHints$columnGr !== void 0 ? _layoutHints$columnGr : []);
121
+ var moveColumn = (name, toIndex) => {
122
+ var modelIndex = this.getColumnIndexByName(name);
123
+ if (modelIndex == null) {
124
+ throw new Error("Unknown layout hint column: ".concat(name));
125
+ }
126
+ var visibleIndex = GridUtils.getVisibleIndex(modelIndex, movedColumns);
127
+ movedColumns = GridUtils.moveItem(visibleIndex, toIndex, movedColumns);
128
+ };
129
+ var moveGroup = (name, toIndex) => {
130
+ var group = groupMap.get(name);
131
+ if (group == null) {
132
+ throw new Error("Unknown layout hint group: ".concat(name));
133
+ }
134
+ var visibleRange = group.getVisibleRange(movedColumns);
135
+ movedColumns = GridUtils.moveRange(visibleRange, toIndex, movedColumns);
136
+ };
137
+ var {
138
+ frontColumns = [],
139
+ backColumns = [],
140
+ frozenColumns = []
141
+ } = layoutHints;
142
+ if (frontColumns.length || backColumns.length || frozenColumns.length) {
143
+ var usedColumns = new Set();
144
+ var frontIndex = 0;
145
+ frozenColumns.forEach(name => {
146
+ if (usedColumns.has(name)) {
147
+ throw new Error("Column specified in multiple layout hints: ".concat(name));
148
+ }
149
+ moveColumn(name, frontIndex);
150
+ frontIndex += 1;
151
+ });
152
+ frontColumns.forEach(name => {
153
+ if (usedColumns.has(name)) {
154
+ throw new Error("Column specified in multiple layout hints: ".concat(name));
155
+ }
156
+ moveColumn(name, frontIndex);
157
+ frontIndex += 1;
158
+ });
159
+ var backIndex = this.columnMap.size - 1;
160
+ backColumns.forEach(name => {
161
+ if (usedColumns.has(name)) {
162
+ throw new Error("Column specified in multiple layout hints: ".concat(name));
163
+ }
164
+ moveColumn(name, backIndex);
165
+ backIndex -= 1;
166
+ });
167
+ }
168
+ var layoutHintColumnGroups = layoutHints === null || layoutHints === void 0 ? void 0 : layoutHints.columnGroups;
169
+ if (layoutHintColumnGroups) {
170
+ var columnGroups = [...groupMap.values()];
171
+ columnGroups.sort((a, b) => a.depth - b.depth);
172
+ columnGroups.forEach(group => {
173
+ var firstChildName = group.children[0];
174
+ var rightModelIndex = this.getColumnIndexByName(firstChildName);
175
+ var rightVisibleIndex;
176
+ if (rightModelIndex != null) {
177
+ rightVisibleIndex = GridUtils.getVisibleIndex(rightModelIndex, movedColumns);
178
+ } else {
179
+ var firstChildGroup = groupMap.get(firstChildName);
180
+ if (!firstChildGroup) {
181
+ throw new Error("Unknown column ".concat(firstChildName, " in group ").concat(group.name));
182
+ }
183
+ var visibleRange = firstChildGroup.getVisibleRange(movedColumns);
184
+ // Columns will be moved to start at the end of the first child group
185
+ [, rightVisibleIndex] = visibleRange;
186
+ }
187
+ for (var i = 1; i < group.children.length; i += 1) {
188
+ var childName = group.children[i];
189
+ var childGroup = groupMap.get(childName);
190
+ var childColumn = this.getColumnIndexByName(childName);
191
+ if (childGroup) {
192
+ // All columns in the group will be before or after the start index
193
+ // Lower level groups are re-arranged first, so they will be contiguous
194
+ var isBeforeGroup = childGroup.getVisibleRange(movedColumns)[0] < rightVisibleIndex;
195
+ var moveToIndex = isBeforeGroup ? rightVisibleIndex - childGroup.childIndexes.length + 1 : rightVisibleIndex + 1;
196
+ moveGroup(childName, moveToIndex);
197
+ rightVisibleIndex = moveToIndex + childGroup.childIndexes.length - 1;
198
+ } else if (childColumn != null) {
199
+ var _isBeforeGroup = GridUtils.getVisibleIndex(childColumn, movedColumns) < rightVisibleIndex;
200
+ var _moveToIndex = _isBeforeGroup ? rightVisibleIndex : rightVisibleIndex + 1;
201
+ moveColumn(childName, _moveToIndex);
202
+ rightVisibleIndex = _moveToIndex;
203
+ }
204
+ }
205
+ });
206
+ }
207
+ this._movedColumns = movedColumns;
208
+ return movedColumns;
209
+ }));
210
+ _defineProperty(this, "getMemoizedInitialColumnHeaderGroups", memoize(layoutHints => {
211
+ var _layoutHints$columnGr2;
212
+ return IrisGridUtils.parseColumnHeaderGroups(this, (_layoutHints$columnGr2 = layoutHints === null || layoutHints === void 0 ? void 0 : layoutHints.columnGroups) !== null && _layoutHints$columnGr2 !== void 0 ? _layoutHints$columnGr2 : []).groups;
213
+ }));
214
+ _defineProperty(this, "getMemoizedColumnMap", memoize(tableColumns => {
215
+ var columnMap = new Map();
216
+ tableColumns.forEach(col => columnMap.set(col.name, col));
217
+ return columnMap;
218
+ }));
219
+ _defineProperty(this, "getColumnIndicesByNameMap", memoize(columns => {
220
+ var indices = new Map();
221
+ columns.forEach((_ref, i) => {
222
+ var {
223
+ name
224
+ } = _ref;
225
+ return indices.set(name, i);
226
+ });
227
+ return indices;
228
+ }));
229
+ _defineProperty(this, "setViewport", throttle((top, bottom, columns) => {
230
+ if (bottom < top) {
231
+ log.error('Invalid viewport', top, bottom);
232
+ return;
233
+ }
234
+ var {
235
+ viewport
236
+ } = this;
237
+ if (viewport != null && viewport.top === top && viewport.bottom === bottom && viewport.columns === columns) {
238
+ log.debug2('Ignoring duplicate viewport', viewport);
239
+ return;
240
+ }
241
+ this.viewport = {
242
+ top,
243
+ bottom,
244
+ columns
245
+ };
246
+ log.debug2('setViewport', this.viewport);
247
+ this.applyViewport();
248
+ }, SET_VIEWPORT_THROTTLE));
249
+ _defineProperty(this, "applyViewport", throttle(() => {
250
+ if (!this.viewport) {
251
+ return;
252
+ }
253
+ log.debug2('applyViewport', this.viewport);
254
+ var {
255
+ top,
256
+ bottom,
257
+ columns
258
+ } = this.viewport;
259
+ var [viewportTop, viewportBottom] = this.getCachedViewportRowRange(top, bottom);
260
+ this.applyBufferedViewport(viewportTop, viewportBottom, columns);
261
+ }, APPLY_VIEWPORT_THROTTLE, {
262
+ leading: false
263
+ }));
264
+ _defineProperty(this, "getCachedFormattedString", memoizeClear((formatter, value, columnType, columnName, formatOverride) => formatter.getFormattedString(value, columnType, columnName, formatOverride), {
265
+ max: 10000
266
+ }));
267
+ _defineProperty(this, "getCachedCustomColumnFormatFlag", memoizeClear(FormatterUtils.isCustomColumnFormatDefined, {
268
+ max: 10000
269
+ }));
270
+ _defineProperty(this, "getCachedViewportRowRange", memoize((top, bottom) => {
271
+ var viewHeight = bottom - top;
272
+ var viewportTop = Math.max(0, top - viewHeight * IrisGridTableModelTemplate.ROW_BUFFER_PAGES);
273
+ var viewportBottom = bottom + viewHeight * IrisGridTableModelTemplate.ROW_BUFFER_PAGES;
274
+ return [viewportTop, viewportBottom];
275
+ }));
276
+ _defineProperty(this, "getCachedPendingErrors", memoize((pendingDataMap, columns, keyColumnCount) => {
277
+ var map = new Map();
278
+ pendingDataMap.forEach((row, rowIndex) => {
279
+ var {
280
+ data: rowData
281
+ } = row;
282
+ for (var i = 0; i < keyColumnCount; i += 1) {
283
+ if (!rowData.has(i)) {
284
+ var _map$get;
285
+ if (!map.has(rowIndex)) {
286
+ map.set(rowIndex, []);
287
+ }
288
+ (_map$get = map.get(rowIndex)) === null || _map$get === void 0 ? void 0 : _map$get.push(new MissingKeyError(rowIndex, columns[i].name));
289
+ }
290
+ }
291
+ });
292
+ return map;
293
+ }));
294
+ this.handleTableDisconnect = this.handleTableDisconnect.bind(this);
295
+ this.handleTableReconnect = this.handleTableReconnect.bind(this);
296
+ this.handleTableUpdate = this.handleTableUpdate.bind(this);
297
+ this.handleTotalsUpdate = this.handleTotalsUpdate.bind(this);
298
+ this.handleRequestFailed = this.handleRequestFailed.bind(this);
299
+ this.handleCustomColumnsChanged = this.handleCustomColumnsChanged.bind(this);
300
+ this.dh = dh;
301
+ this.irisFormatter = _formatter;
302
+ this.irisGridUtils = new IrisGridUtils(dh);
303
+ this.inputTable = inputTable;
304
+ this.subscription = null;
305
+ this.table = table;
306
+ this.tableUtils = new TableUtils(dh);
307
+ this.viewport = null;
308
+ this.viewportData = null;
309
+ this.formattedStringData = [];
310
+ this.pendingStringData = [];
311
+ this.isSaveInProgress = false;
312
+ this.totalsTable = null;
313
+ this.totalsTablePromise = null;
314
+ this.totals = null;
315
+ this.totalsDataMap = null;
316
+
317
+ // Map from new row index to their values. Only for input tables that can have new rows added.
318
+ // The index of these rows start at 0, and they are appended at the end of the regular table data.
319
+ // These rows can be sparse, so using a map instead of an array.
320
+ this.pendingNewDataMap = new Map();
321
+ this.pendingNewRowCount = 0;
322
+ this.columnHeaderGroups = IrisGridUtils.parseColumnHeaderGroups(this, (_this$layoutHints$col = (_this$layoutHints = this.layoutHints) === null || _this$layoutHints === void 0 ? void 0 : _this$layoutHints.columnGroups) !== null && _this$layoutHints$col !== void 0 ? _this$layoutHints$col : []).groups;
323
+ }
324
+ close() {
325
+ this.table.close();
326
+ if (this.totalsTable !== null) {
327
+ this.totalsTable.close();
328
+ }
329
+ if (this.totalsTablePromise !== null) {
330
+ this.totalsTablePromise.cancel();
331
+ }
332
+ }
333
+ startListening() {
334
+ super.startListening();
335
+ var {
336
+ dh
337
+ } = this;
338
+ this.table.addEventListener(dh.Table.EVENT_DISCONNECT, this.handleTableDisconnect);
339
+ this.table.addEventListener(dh.Table.EVENT_RECONNECT, this.handleTableReconnect);
340
+ this.table.addEventListener(dh.Table.EVENT_UPDATED, this.handleTableUpdate);
341
+ this.table.addEventListener(dh.Client.EVENT_REQUEST_FAILED, this.handleRequestFailed);
342
+ this.table.addEventListener(dh.Table.EVENT_CUSTOMCOLUMNSCHANGED, this.handleCustomColumnsChanged);
343
+ if (this.totalsTable != null) {
344
+ this.addTotalsListeners(this.totalsTable);
345
+ }
346
+ this.applyViewport();
347
+ }
348
+ stopListening() {
349
+ super.stopListening();
350
+ var {
351
+ dh
352
+ } = this;
353
+ this.table.removeEventListener(dh.Table.EVENT_DISCONNECT, this.handleTableDisconnect);
354
+ this.table.removeEventListener(dh.Table.EVENT_RECONNECT, this.handleTableReconnect);
355
+ this.table.removeEventListener(dh.Table.EVENT_UPDATED, this.handleTableUpdate);
356
+ this.table.removeEventListener(dh.Client.EVENT_REQUEST_FAILED, this.handleRequestFailed);
357
+ this.table.removeEventListener(dh.Table.EVENT_CUSTOMCOLUMNSCHANGED, this.handleCustomColumnsChanged);
358
+ if (this.totalsTable != null) {
359
+ this.removeTotalsListeners(this.totalsTable);
360
+ }
361
+ this.closeSubscription();
362
+ }
363
+ addTotalsListeners(totalsTable) {
364
+ var {
365
+ dh
366
+ } = this;
367
+ totalsTable.addEventListener(dh.Table.EVENT_UPDATED, this.handleTotalsUpdate);
368
+
369
+ // Totals table only has one row of data
370
+ totalsTable.setViewport(0, 0);
371
+ }
372
+ removeTotalsListeners(totalsTable) {
373
+ var {
374
+ dh
375
+ } = this;
376
+ totalsTable.removeEventListener(dh.Table.EVENT_UPDATED, this.handleTotalsUpdate);
377
+ }
378
+ handleTableDisconnect() {
379
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.DISCONNECT));
380
+ }
381
+ handleTableReconnect() {
382
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.RECONNECT));
383
+ }
384
+ handleTableUpdate(event) {
385
+ this.copyViewportData(event.detail);
386
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
387
+ }
388
+ handleTotalsUpdate(event) {
389
+ this.copyTotalsData(event.detail);
390
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
391
+ }
392
+ handleRequestFailed(event) {
393
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.REQUEST_FAILED, event));
394
+ }
395
+ handleCustomColumnsChanged() {
396
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.COLUMNS_CHANGED, {
397
+ detail: this.columns
398
+ }));
399
+ }
400
+ get rowCount() {
401
+ var _this$totals$operatio, _this$totals, _this$totals$operatio2;
402
+ return this.table.size + this.pendingNewRowCount + ((_this$totals$operatio = (_this$totals = this.totals) === null || _this$totals === void 0 ? void 0 : (_this$totals$operatio2 = _this$totals.operationOrder) === null || _this$totals$operatio2 === void 0 ? void 0 : _this$totals$operatio2.length) !== null && _this$totals$operatio !== void 0 ? _this$totals$operatio : 0);
403
+ }
404
+ get pendingDataErrors() {
405
+ var _this$inputTable$keyC, _this$inputTable;
406
+ return this.getCachedPendingErrors(this.pendingNewDataMap, this.columns, (_this$inputTable$keyC = (_this$inputTable = this.inputTable) === null || _this$inputTable === void 0 ? void 0 : _this$inputTable.keyColumns.length) !== null && _this$inputTable$keyC !== void 0 ? _this$inputTable$keyC : 0);
407
+ }
408
+ get pendingDataMap() {
409
+ return this.pendingNewDataMap;
410
+ }
411
+ set pendingDataMap(map) {
412
+ if (map === this.pendingNewDataMap) {
413
+ return;
414
+ }
415
+ map.forEach((row, rowIndex) => {
416
+ if (!IrisGridUtils.isValidIndex(rowIndex)) {
417
+ throw new Error("Invalid rowIndex ".concat(rowIndex));
418
+ }
419
+ var {
420
+ data
421
+ } = row;
422
+ data.forEach((value, columnIndex) => {
423
+ if (!IrisGridUtils.isValidIndex(columnIndex)) {
424
+ throw new Error("Invalid columnIndex ".concat(columnIndex));
425
+ }
426
+ });
427
+ });
428
+ this.pendingNewDataMap = map;
429
+ this.pendingNewRowCount = Math.max(this.pendingNewRowCount, this.maxPendingDataRow);
430
+ this.formattedStringData = [];
431
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.PENDING_DATA_UPDATED));
432
+ }
433
+ get pendingRowCount() {
434
+ return this.pendingNewRowCount;
435
+ }
436
+ set pendingRowCount(count) {
437
+ if (count === this.pendingNewRowCount) {
438
+ return;
439
+ }
440
+ this.pendingNewRowCount = Math.max(0, count, this.maxPendingDataRow);
441
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
442
+ }
443
+ get maxPendingDataRow() {
444
+ return this.pendingNewDataMap.size > 0 ? Math.max(...this.pendingNewDataMap.keys()) + 1 : 0;
445
+ }
446
+ get columnCount() {
447
+ return this.columns.length;
448
+ }
449
+ get floatingBottomRowCount() {
450
+ var _this$totals$operatio3, _this$totals2, _this$totals2$operati;
451
+ return this.totals != null && this.totals.showOnTop ? 0 : (_this$totals$operatio3 = (_this$totals2 = this.totals) === null || _this$totals2 === void 0 ? void 0 : (_this$totals2$operati = _this$totals2.operationOrder) === null || _this$totals2$operati === void 0 ? void 0 : _this$totals2$operati.length) !== null && _this$totals$operatio3 !== void 0 ? _this$totals$operatio3 : 0;
452
+ }
453
+ get floatingTopRowCount() {
454
+ var _this$totals$operatio4, _this$totals3, _this$totals3$operati;
455
+ return this.totals != null && this.totals.showOnTop ? (_this$totals$operatio4 = (_this$totals3 = this.totals) === null || _this$totals3 === void 0 ? void 0 : (_this$totals3$operati = _this$totals3.operationOrder) === null || _this$totals3$operati === void 0 ? void 0 : _this$totals3$operati.length) !== null && _this$totals$operatio4 !== void 0 ? _this$totals$operatio4 : 0 : 0;
456
+ }
457
+ get isChartBuilderAvailable() {
458
+ return true;
459
+ }
460
+ get isTotalsAvailable() {
461
+ return this.table.getTotalsTable != null;
462
+ }
463
+ get isEditable() {
464
+ return !this.isSaveInProgress && this.inputTable != null;
465
+ }
466
+ cacheFormattedValue(x, y, text) {
467
+ if (this.formattedStringData[x] == null) {
468
+ this.formattedStringData[x] = [];
469
+ }
470
+ this.formattedStringData[x][y] = text;
471
+ }
472
+ cachePendingValue(x, y, text) {
473
+ if (this.pendingStringData[x] == null) {
474
+ this.pendingStringData[x] = [];
475
+ }
476
+ this.pendingStringData[x][y] = text;
477
+ }
478
+ clearPendingValue(x, y) {
479
+ var column = this.pendingStringData[x];
480
+ if (column != null) {
481
+ delete column[y];
482
+ }
483
+ }
484
+ textValueForCell(x, y) {
485
+ var _this$pendingStringDa, _this$formattedString;
486
+ // First check if there's any pending values we should read from
487
+ if (((_this$pendingStringDa = this.pendingStringData[x]) === null || _this$pendingStringDa === void 0 ? void 0 : _this$pendingStringDa[y]) !== undefined) {
488
+ return this.pendingStringData[x][y];
489
+ }
490
+
491
+ // Use a separate cache from memoization just for the strings that are currently displayed
492
+ if (((_this$formattedString = this.formattedStringData[x]) === null || _this$formattedString === void 0 ? void 0 : _this$formattedString[y]) === undefined) {
493
+ var _this$totalsColumn;
494
+ var _value = this.valueForCell(x, y);
495
+ if (_value === null) {
496
+ return null;
497
+ }
498
+ if (_value === undefined) {
499
+ return undefined;
500
+ }
501
+ var _column = (_this$totalsColumn = this.totalsColumn(x, y)) !== null && _this$totalsColumn !== void 0 ? _this$totalsColumn : this.columns[x];
502
+ var hasCustomColumnFormat = this.getCachedCustomColumnFormatFlag(this.formatter, _column.name, _column.type);
503
+ var formatOverride;
504
+ if (!hasCustomColumnFormat) {
505
+ var formatForCell = this.formatForCell(x, y);
506
+ if ((formatForCell === null || formatForCell === void 0 ? void 0 : formatForCell.formatString) != null) {
507
+ formatOverride = formatForCell;
508
+ }
509
+ }
510
+ var text = this.displayString(_value, _column.type, _column.name, formatOverride);
511
+ this.cacheFormattedValue(x, y, text);
512
+ }
513
+ return this.formattedStringData[x][y];
514
+ }
515
+ textForCell(x, y) {
516
+ var _this$columns$x;
517
+ var text = this.textValueForCell(x, y);
518
+ if (text == null && this.isKeyColumn(x)) {
519
+ var pendingRow = this.pendingRow(y);
520
+ if (pendingRow != null && this.pendingDataMap.has(pendingRow)) {
521
+ // Asterisk to show a value is required for a key column on a row that has some data entered
522
+ return '*';
523
+ }
524
+ }
525
+ if (TableUtils.isTextType((_this$columns$x = this.columns[x]) === null || _this$columns$x === void 0 ? void 0 : _this$columns$x.type)) {
526
+ if (text === null) {
527
+ return 'null';
528
+ }
529
+ if (text === '') {
530
+ return 'empty';
531
+ }
532
+ }
533
+ return text !== null && text !== void 0 ? text : '';
534
+ }
535
+ truncationCharForCell(x) {
536
+ var column = this.columns[x];
537
+ var {
538
+ type
539
+ } = column;
540
+ if (TableUtils.isNumberType(type) && this.formatter.truncateNumbersWithPound) {
541
+ return '#';
542
+ }
543
+ return undefined;
544
+ }
545
+ colorForCell(x, y, theme) {
546
+ var data = this.dataForCell(x, y);
547
+ if (data) {
548
+ var {
549
+ format,
550
+ value: _value2
551
+ } = data;
552
+ if (_value2 == null || _value2 === '') {
553
+ assertNotNull(theme.nullStringColor);
554
+ return theme.nullStringColor;
555
+ }
556
+ if (format && format.color) {
557
+ return format.color;
558
+ }
559
+ if (this.isPendingRow(y)) {
560
+ // Data entered in a pending row
561
+ assertNotNull(theme.pendingTextColor);
562
+ return theme.pendingTextColor;
563
+ }
564
+
565
+ // Fallback to formatting based on the value/type of the cell
566
+ if (_value2 != null) {
567
+ var _this$totalsColumn2;
568
+ var _column2 = (_this$totalsColumn2 = this.totalsColumn(x, y)) !== null && _this$totalsColumn2 !== void 0 ? _this$totalsColumn2 : this.columns[x];
569
+ if (TableUtils.isDateType(_column2.type) || _column2.name === 'Date') {
570
+ assertNotNull(theme.dateColor);
571
+ return theme.dateColor;
572
+ }
573
+ if (TableUtils.isNumberType(_column2.type)) {
574
+ if (_value2 > 0) {
575
+ assertNotNull(theme.positiveNumberColor);
576
+ return theme.positiveNumberColor;
577
+ }
578
+ if (_value2 < 0) {
579
+ assertNotNull(theme.negativeNumberColor);
580
+ return theme.negativeNumberColor;
581
+ }
582
+ assertNotNull(theme.zeroNumberColor);
583
+ return theme.zeroNumberColor;
584
+ }
585
+ }
586
+ } else if (this.isPendingRow(y) && this.isKeyColumn(x)) {
587
+ assertNotNull(theme.errorTextColor);
588
+ return theme.errorTextColor;
589
+ }
590
+ return theme.textColor;
591
+ }
592
+ backgroundColorForCell(x, y) {
593
+ var _this$formatForCell$b, _this$formatForCell;
594
+ return (_this$formatForCell$b = (_this$formatForCell = this.formatForCell(x, y)) === null || _this$formatForCell === void 0 ? void 0 : _this$formatForCell.backgroundColor) !== null && _this$formatForCell$b !== void 0 ? _this$formatForCell$b : null;
595
+ }
596
+ textAlignForCell(x) {
597
+ var column = this.columns[x];
598
+ var {
599
+ type
600
+ } = column;
601
+ if (TableUtils.isNumberType(type)) {
602
+ return 'right';
603
+ }
604
+ if (TableUtils.isDateType(type) || column.name === 'Date') {
605
+ return 'center';
606
+ }
607
+ return 'left';
608
+ }
609
+ textForColumnHeader(x) {
610
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
611
+ var header = this.columnAtDepth(x, depth);
612
+ if (isColumnHeaderGroup(header)) {
613
+ return header.isNew ? '' : header.name;
614
+ }
615
+ return header === null || header === void 0 ? void 0 : header.name;
616
+ }
617
+ colorForColumnHeader(x) {
618
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
619
+ var column = this.columnAtDepth(x, depth);
620
+ if (isColumnHeaderGroup(column)) {
621
+ var _column$color;
622
+ return (_column$color = column.color) !== null && _column$color !== void 0 ? _column$color : null;
623
+ }
624
+ return null;
625
+ }
626
+ getColumnHeaderGroup(modelIndex, depth) {
627
+ var group = this.columnAtDepth(modelIndex, depth);
628
+ if (isColumnHeaderGroup(group)) {
629
+ return group;
630
+ }
631
+ return undefined;
632
+ }
633
+ getColumnHeaderParentGroup(modelIndex, depth) {
634
+ var _this$columnAtDepth$n, _this$columnAtDepth;
635
+ return this.columnHeaderParentMap.get((_this$columnAtDepth$n = (_this$columnAtDepth = this.columnAtDepth(modelIndex, depth)) === null || _this$columnAtDepth === void 0 ? void 0 : _this$columnAtDepth.name) !== null && _this$columnAtDepth$n !== void 0 ? _this$columnAtDepth$n : '');
636
+ }
637
+ columnAtDepth(x) {
638
+ var _this$columns$x2;
639
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
640
+ if (depth === 0) {
641
+ return this.columns[x];
642
+ }
643
+ var columnName = (_this$columns$x2 = this.columns[x]) === null || _this$columns$x2 === void 0 ? void 0 : _this$columns$x2.name;
644
+ var group = this.columnHeaderParentMap.get(columnName);
645
+ if (!group) {
646
+ return undefined;
647
+ }
648
+ var currentDepth = group.depth;
649
+ while (currentDepth < depth) {
650
+ group = this.columnHeaderParentMap.get(group.name);
651
+ if (!group) {
652
+ return undefined;
653
+ }
654
+ currentDepth = group.depth;
655
+ }
656
+ if (group.depth === depth) {
657
+ return group;
658
+ }
659
+ return undefined;
660
+ }
661
+ textForRowFooter(y) {
662
+ var totalsRow = this.totalsRow(y);
663
+ if (totalsRow != null && this.totals) {
664
+ return this.totals.operationOrder[totalsRow];
665
+ }
666
+ return '';
667
+ }
668
+ /**
669
+ * Used to get the initial moved columns based on layout hints
670
+ */
671
+ get initialMovedColumns() {
672
+ var _this$layoutHints2;
673
+ return this.getMemoizedInitialMovedColumns((_this$layoutHints2 = this.layoutHints) !== null && _this$layoutHints2 !== void 0 ? _this$layoutHints2 : undefined);
674
+ }
675
+
676
+ /**
677
+ * Not currently used by anything.
678
+ */
679
+ get initialMovedRows() {
680
+ return EMPTY_ARRAY;
681
+ }
682
+ get initialColumnHeaderGroups() {
683
+ var _this$layoutHints3;
684
+ return this.getMemoizedInitialColumnHeaderGroups((_this$layoutHints3 = this.layoutHints) !== null && _this$layoutHints3 !== void 0 ? _this$layoutHints3 : undefined);
685
+ }
686
+ get columnMap() {
687
+ return this.getMemoizedColumnMap(this.table.columns);
688
+ }
689
+ get columnHeaderMaxDepth() {
690
+ var _this$_columnHeaderMa;
691
+ return (_this$_columnHeaderMa = this._columnHeaderMaxDepth) !== null && _this$_columnHeaderMa !== void 0 ? _this$_columnHeaderMa : 1;
692
+ }
693
+ set columnHeaderMaxDepth(depth) {
694
+ this._columnHeaderMaxDepth = depth;
695
+ }
696
+ get columnHeaderGroupMap() {
697
+ return this._columnHeaderGroupMap;
698
+ }
699
+ get columnHeaderGroups() {
700
+ return this._columnHeaderGroups;
701
+ }
702
+ set columnHeaderGroups(groups) {
703
+ if (groups === this._columnHeaderGroups) {
704
+ return;
705
+ }
706
+ var {
707
+ groups: newGroups,
708
+ maxDepth,
709
+ parentMap,
710
+ groupMap
711
+ } = IrisGridUtils.parseColumnHeaderGroups(this, groups !== null && groups !== void 0 ? groups : this.initialColumnHeaderGroups);
712
+ this._columnHeaderGroups = newGroups;
713
+ this.columnHeaderMaxDepth = maxDepth;
714
+ this.columnHeaderParentMap = parentMap;
715
+ this._columnHeaderGroupMap = groupMap;
716
+ }
717
+ get groupedColumns() {
718
+ return [];
719
+ }
720
+ row(y) {
721
+ var _this$totals$operatio5, _this$totals4, _this$totals4$operati, _this$totals$showOnTo, _this$totals5, _this$viewportData$of, _this$viewportData, _this$viewportData$ro, _this$viewportData2, _this$viewportData2$r;
722
+ var totalsRowCount = (_this$totals$operatio5 = (_this$totals4 = this.totals) === null || _this$totals4 === void 0 ? void 0 : (_this$totals4$operati = _this$totals4.operationOrder) === null || _this$totals4$operati === void 0 ? void 0 : _this$totals4$operati.length) !== null && _this$totals$operatio5 !== void 0 ? _this$totals$operatio5 : 0;
723
+ var showOnTop = (_this$totals$showOnTo = (_this$totals5 = this.totals) === null || _this$totals5 === void 0 ? void 0 : _this$totals5.showOnTop) !== null && _this$totals$showOnTo !== void 0 ? _this$totals$showOnTo : false;
724
+ var totalsRow = this.totalsRow(y);
725
+ if (totalsRow != null) {
726
+ var _this$totals6, _this$totalsDataMap$g, _this$totalsDataMap;
727
+ var operation = (_this$totals6 = this.totals) === null || _this$totals6 === void 0 ? void 0 : _this$totals6.operationOrder[totalsRow];
728
+ assertNotNull(operation);
729
+ return (_this$totalsDataMap$g = (_this$totalsDataMap = this.totalsDataMap) === null || _this$totalsDataMap === void 0 ? void 0 : _this$totalsDataMap.get(operation)) !== null && _this$totalsDataMap$g !== void 0 ? _this$totalsDataMap$g : null;
730
+ }
731
+ var pendingRow = this.pendingRow(y);
732
+ if (pendingRow != null) {
733
+ var _this$pendingNewDataM;
734
+ return (_this$pendingNewDataM = this.pendingNewDataMap.get(pendingRow)) !== null && _this$pendingNewDataM !== void 0 ? _this$pendingNewDataM : null;
735
+ }
736
+ var offset = (_this$viewportData$of = (_this$viewportData = this.viewportData) === null || _this$viewportData === void 0 ? void 0 : _this$viewportData.offset) !== null && _this$viewportData$of !== void 0 ? _this$viewportData$of : 0;
737
+ var viewportY = (showOnTop ? y - totalsRowCount : y) - offset;
738
+ return (_this$viewportData$ro = (_this$viewportData2 = this.viewportData) === null || _this$viewportData2 === void 0 ? void 0 : (_this$viewportData2$r = _this$viewportData2.rows) === null || _this$viewportData2$r === void 0 ? void 0 : _this$viewportData2$r[viewportY]) !== null && _this$viewportData$ro !== void 0 ? _this$viewportData$ro : null;
739
+ }
740
+
741
+ /**
742
+ * Retrieve the totals column if this is a totals row, or null otherwise
743
+ * @param x Column index to get the totals column from
744
+ * @param y Row index to get the totals column from
745
+ */
746
+ totalsColumn(x, y) {
747
+ var _this$totals7, _this$totals$defaultO, _this$totals8, _this$totalsTable;
748
+ var totalsRow = this.totalsRow(y);
749
+ if (totalsRow == null) return null;
750
+ var operation = (_this$totals7 = this.totals) === null || _this$totals7 === void 0 ? void 0 : _this$totals7.operationOrder[totalsRow];
751
+ var defaultOperation = (_this$totals$defaultO = (_this$totals8 = this.totals) === null || _this$totals8 === void 0 ? void 0 : _this$totals8.defaultOperation) !== null && _this$totals$defaultO !== void 0 ? _this$totals$defaultO : AggregationOperation.SUM;
752
+ var tableColumn = this.columns[x];
753
+
754
+ // Find the matching totals table column for the operation
755
+ // When there are multiple aggregations, the column name will be the original name of the column with the operation appended afterward
756
+ // When the the operation is the default operation OR there is only one operation, then the totals column name is just the original column name
757
+ return (_this$totalsTable = this.totalsTable) === null || _this$totalsTable === void 0 ? void 0 : _this$totalsTable.columns.find(column => {
758
+ var _this$totals9;
759
+ return column.name === "".concat(tableColumn.name, "__").concat(operation) || (operation === defaultOperation || ((_this$totals9 = this.totals) === null || _this$totals9 === void 0 ? void 0 : _this$totals9.operationOrder.length) === 1) && column.name === tableColumn.name;
760
+ });
761
+ }
762
+
763
+ /**
764
+ * Translate from the row in the model to a row in the totals table.
765
+ * If the row is not a totals row, return null
766
+ * @param y The row in the model to get the totals row for
767
+ * @returns The row within the totals table if it's a totals row, null otherwise
768
+ */
769
+ totalsRow(y) {
770
+ var _this$totals$operatio6, _this$totals10, _this$totals10$operat, _this$totals$showOnTo2, _this$totals11;
771
+ var totalsRowCount = (_this$totals$operatio6 = (_this$totals10 = this.totals) === null || _this$totals10 === void 0 ? void 0 : (_this$totals10$operat = _this$totals10.operationOrder) === null || _this$totals10$operat === void 0 ? void 0 : _this$totals10$operat.length) !== null && _this$totals$operatio6 !== void 0 ? _this$totals$operatio6 : 0;
772
+ var showOnTop = (_this$totals$showOnTo2 = (_this$totals11 = this.totals) === null || _this$totals11 === void 0 ? void 0 : _this$totals11.showOnTop) !== null && _this$totals$showOnTo2 !== void 0 ? _this$totals$showOnTo2 : false;
773
+ var totalsRow = showOnTop ? y : y - this.table.size;
774
+ if (totalsRow >= 0 && totalsRow < totalsRowCount) {
775
+ return totalsRow;
776
+ }
777
+ return null;
778
+ }
779
+
780
+ /**
781
+ * Translate from the row in the model to a pending input row.
782
+ * If the row is not a pending input row, return null
783
+ * @param y The row in the model to get the pending row for
784
+ * @returns The row within the pending input rows if it's a pending row, null otherwise
785
+ */
786
+ pendingRow(y) {
787
+ var pendingRow = y - this.floatingTopRowCount - this.table.size;
788
+ if (pendingRow >= 0 && pendingRow < this.pendingNewRowCount) {
789
+ return pendingRow;
790
+ }
791
+ return null;
792
+ }
793
+
794
+ /**
795
+ * Check if a row is a totals table row
796
+ * @param y The row in the model to check if it's a totals table row
797
+ * @returns True if the row is a totals row, false if not
798
+ */
799
+ isTotalsRow(y) {
800
+ return this.totalsRow(y) != null;
801
+ }
802
+
803
+ /**
804
+ * Check if a row is a pending input row
805
+ * @param y The row in the model to check if it's a pending new row
806
+ * @returns True if the row is a pending new row, false if not
807
+ */
808
+ isPendingRow(y) {
809
+ return this.pendingRow(y) != null;
810
+ }
811
+ dataForCell(x, y) {
812
+ var _this$row;
813
+ return (_this$row = this.row(y)) === null || _this$row === void 0 ? void 0 : _this$row.data.get(x);
814
+ }
815
+ formatForCell(x, y) {
816
+ var _this$dataForCell;
817
+ return (_this$dataForCell = this.dataForCell(x, y)) === null || _this$dataForCell === void 0 ? void 0 : _this$dataForCell.format;
818
+ }
819
+ valueForCell(x, y) {
820
+ var data = this.dataForCell(x, y);
821
+
822
+ /* JS API current sets null values as undefined in some instances. This means
823
+ we need to nullish coaelesce so all undefined values from the API return null
824
+ since the data has been fetched. undefined is used to indicate the API has not
825
+ fetched data yet */
826
+ if (data) {
827
+ var _data$value;
828
+ return (_data$value = data.value) !== null && _data$value !== void 0 ? _data$value : null;
829
+ }
830
+ return undefined;
831
+ }
832
+ copyViewportData(data) {
833
+ if (data == null) {
834
+ log.warn('invalid data!');
835
+ return;
836
+ }
837
+ this.viewportData = this.extractViewportData(data);
838
+ this.formattedStringData = [];
839
+ }
840
+ copyTotalsData(totalsData) {
841
+ var _this$totals$defaultO2,
842
+ _this$totals12,
843
+ _this$totals13,
844
+ _this = this;
845
+ if (totalsData == null) {
846
+ log.warn('invalid data!');
847
+ return;
848
+ }
849
+ var {
850
+ columns,
851
+ rows
852
+ } = totalsData;
853
+ if (rows.length !== 1) {
854
+ log.error('Unexpected number of rows received for totals table, ignoring update');
855
+ return;
856
+ }
857
+ var dataMap = new Map();
858
+ var row = rows[0];
859
+ var defaultOperation = (_this$totals$defaultO2 = (_this$totals12 = this.totals) === null || _this$totals12 === void 0 ? void 0 : _this$totals12.defaultOperation) !== null && _this$totals$defaultO2 !== void 0 ? _this$totals$defaultO2 : AggregationOperation.SUM;
860
+ var operationMap = (_this$totals13 = this.totals) === null || _this$totals13 === void 0 ? void 0 : _this$totals13.operationMap;
861
+ var _loop = function _loop() {
862
+ var _operationMap$name$, _operationMap$name;
863
+ var column = columns[c];
864
+ var [name, operation = (_operationMap$name$ = operationMap === null || operationMap === void 0 ? void 0 : (_operationMap$name = operationMap[name]) === null || _operationMap$name === void 0 ? void 0 : _operationMap$name[0]) !== null && _operationMap$name$ !== void 0 ? _operationMap$name$ : defaultOperation] = column.name.split('__');
865
+ if (!dataMap.has(operation)) {
866
+ dataMap.set(operation, {
867
+ data: new Map()
868
+ });
869
+ }
870
+ var {
871
+ data: rowData
872
+ } = dataMap.get(operation);
873
+ var columnIndex = _this.columns.findIndex(col => col.name === name);
874
+ rowData.set(columnIndex, {
875
+ value: row.get(column),
876
+ format: row.getFormat(column)
877
+ });
878
+ };
879
+ for (var c = 0; c < columns.length; c += 1) {
880
+ _loop();
881
+ }
882
+ log.debug2('copyTotalsData', dataMap);
883
+ this.totalsDataMap = dataMap;
884
+ this.formattedStringData = [];
885
+ }
886
+
887
+ /**
888
+ * Use this as the canonical column index since things like layoutHints could have
889
+ * changed the column order.
890
+ */
891
+ getColumnIndexByName(name) {
892
+ return this.getColumnIndicesByNameMap(this.columns).get(name);
893
+ }
894
+ /**
895
+ * Copies all the viewport data into an object that we can reference later.
896
+ * @param data The data to copy from
897
+ */
898
+ extractViewportData(data) {
899
+ var newData = {
900
+ offset: data.offset,
901
+ rows: []
902
+ };
903
+ var {
904
+ columns
905
+ } = data;
906
+ for (var r = 0; r < data.rows.length; r += 1) {
907
+ var _row = data.rows[r];
908
+ var newRow = this.extractViewportRow(_row, columns);
909
+ newData.rows.push(newRow);
910
+ }
911
+ return newData;
912
+ }
913
+ extractViewportRow(row, columns) {
914
+ var data = new Map();
915
+ for (var c = 0; c < columns.length; c += 1) {
916
+ var _column3 = columns[c];
917
+ var index = this.getColumnIndexByName(_column3.name);
918
+ assertNotNull(index);
919
+ data.set(index, {
920
+ value: row.get(_column3),
921
+ format: row.getFormat(_column3)
922
+ });
923
+ }
924
+ return {
925
+ data
926
+ };
927
+ }
928
+ closeSubscription() {
929
+ log.debug2('closeSubscription', this.subscription);
930
+ if (this.subscription) {
931
+ this.subscription.close();
932
+ this.subscription = null;
933
+ }
934
+ this.setViewport.cancel();
935
+ this.applyViewport.cancel();
936
+ }
937
+ get filter() {
938
+ return this.table.filter;
939
+ }
940
+ set filter(filter) {
941
+ this.closeSubscription();
942
+ this.table.applyFilter(filter);
943
+ this.applyViewport();
944
+ }
945
+ get formatter() {
946
+ return this.irisFormatter;
947
+ }
948
+ set formatter(formatter) {
949
+ this.irisFormatter = formatter;
950
+ this.formattedStringData = [];
951
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.FORMATTER_UPDATED));
952
+ }
953
+ displayString(value, columnType) {
954
+ var columnName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
955
+ var formatOverride = arguments.length > 3 ? arguments[3] : undefined;
956
+ return this.getCachedFormattedString(this.formatter, value, columnType, columnName, formatOverride);
957
+ }
958
+ get sort() {
959
+ return this.table.sort;
960
+ }
961
+ set sort(sort) {
962
+ this.closeSubscription();
963
+ this.table.applySort(sort);
964
+ this.applyViewport();
965
+ }
966
+ set totalsConfig(totalsConfig) {
967
+ log.debug('set totalsConfig', totalsConfig);
968
+ if (totalsConfig === this.totals) {
969
+ // Totals already set, or it will be set when the next model actually gets set
970
+ return;
971
+ }
972
+ this.totals = totalsConfig;
973
+ this.formattedStringData = [];
974
+ if (this.totalsTablePromise != null) {
975
+ this.totalsTablePromise.cancel();
976
+ }
977
+ this.setTotalsTable(null);
978
+ if (totalsConfig == null) {
979
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
980
+ return;
981
+ }
982
+ this.totalsTablePromise = PromiseUtils.makeCancelable(this.table.getTotalsTable(totalsConfig), table => table.close());
983
+ this.totalsTablePromise.then(totalsTable => {
984
+ this.totalsTablePromise = null;
985
+ this.setTotalsTable(totalsTable);
986
+ }).catch(err => {
987
+ if (PromiseUtils.isCanceled(err)) {
988
+ return;
989
+ }
990
+ log.error('Unable to set next totalsTable', err);
991
+ this.totalsTablePromise = null;
992
+ this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.REQUEST_FAILED, {
993
+ detail: err
994
+ }));
995
+ });
996
+ }
997
+ setTotalsTable(totalsTable) {
998
+ log.debug('setTotalsTable', totalsTable);
999
+ if (this.totalsTable !== null) {
1000
+ if (this.listenerCount > 0) {
1001
+ this.removeTotalsListeners(this.totalsTable);
1002
+ }
1003
+ this.totalsTable.close();
1004
+ }
1005
+ this.totalsTable = totalsTable;
1006
+ this.totalsDataMap = null;
1007
+ if (this.listenerCount > 0 && this.totalsTable != null) {
1008
+ this.addTotalsListeners(this.totalsTable);
1009
+ }
1010
+ }
1011
+ applyBufferedViewport(viewportTop, viewportBottom, columns) {
1012
+ log.debug2('applyBufferedViewport', viewportTop, viewportBottom, columns);
1013
+ if (this.subscription == null) {
1014
+ log.debug2('applyBufferedViewport creating new subscription');
1015
+ this.subscription = this.table.setViewport(viewportTop, viewportBottom, columns);
1016
+ } else {
1017
+ log.debug2('applyBufferedViewport using existing subscription');
1018
+ this.subscription.setViewport(viewportTop, viewportBottom, columns);
1019
+ }
1020
+ }
1021
+ snapshot(ranges) {
1022
+ var _arguments = arguments,
1023
+ _this2 = this;
1024
+ return _asyncToGenerator(function* () {
1025
+ var includeHeaders = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : false;
1026
+ var formatValue = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : value => value;
1027
+ var consolidateRanges = _arguments.length > 3 && _arguments[3] !== undefined ? _arguments[3] : true;
1028
+ if (_this2.subscription == null) {
1029
+ throw new Error('No subscription available');
1030
+ }
1031
+ var consolidated = consolidateRanges ? GridRange.consolidate(ranges) : ranges;
1032
+ if (!IrisGridUtils.isValidSnapshotRanges(consolidated)) {
1033
+ throw new Error("Invalid snapshot ranges ".concat(ranges));
1034
+ }
1035
+
1036
+ // Need to separate out the floating ranges as they're from a different source
1037
+ var topFloatingRowsSet = new Set();
1038
+ var tableRanges = [];
1039
+ var bottomFloatingRowsSet = new Set();
1040
+ for (var i = 0; i < consolidated.length; i += 1) {
1041
+ var range = consolidated[i];
1042
+ assertNotNull(range.endRow);
1043
+ assertNotNull(range.startRow);
1044
+ // Get the rows that are in the top aggregations section
1045
+ for (var r = range.startRow; r <= range.endRow && r < _this2.floatingTopRowCount; r += 1) {
1046
+ topFloatingRowsSet.add(r);
1047
+ }
1048
+
1049
+ // Separate out the range that is part of the actual table (ie. not the floating ranges, not aggregations)
1050
+ if (range.endRow >= _this2.floatingTopRowCount && range.startRow <= _this2.floatingTopRowCount + _this2.table.size) {
1051
+ tableRanges.push(new GridRange(range.startColumn, Math.min(Math.max(0, range.startRow - _this2.floatingTopRowCount)), range.endColumn, Math.min(Math.max(0, range.endRow - _this2.floatingTopRowCount), _this2.table.size - _this2.floatingTopRowCount)));
1052
+ }
1053
+ // Get the rows that are in the bottom aggregations section
1054
+ for (var _r = Math.max(range.startRow, _this2.floatingTopRowCount + _this2.table.size); _r <= range.endRow && _r < _this2.floatingTopRowCount + _this2.table.size + _this2.floatingBottomRowCount; _r += 1) {
1055
+ bottomFloatingRowsSet.add(_r);
1056
+ }
1057
+ }
1058
+ var columns = IrisGridUtils.columnsFromRanges(consolidated, _this2.columns);
1059
+ var result = [];
1060
+ if (includeHeaders) {
1061
+ result.push(columns.map(c => c.name));
1062
+ }
1063
+ var topFloatingRows = [...topFloatingRowsSet].sort();
1064
+ var _loop2 = function* _loop2() {
1065
+ var row = topFloatingRows[_i];
1066
+ var rowData = columns.map(column => {
1067
+ var index = _this2.getColumnIndexByName(column.name);
1068
+ assertNotNull(index);
1069
+ return formatValue(_this2.valueForCell(index, row), column);
1070
+ });
1071
+ if (includeHeaders) {
1072
+ rowData.push(_this2.textForRowFooter(row));
1073
+ }
1074
+ result.push(rowData);
1075
+ };
1076
+ for (var _i = 0; _i < topFloatingRows.length; _i += 1) {
1077
+ yield* _loop2();
1078
+ }
1079
+ if (tableRanges.length > 0) {
1080
+ var rangeSet = _this2.irisGridUtils.rangeSetFromRanges(tableRanges);
1081
+ var snapshot = yield _this2.subscription.snapshot(rangeSet, columns);
1082
+ result.push(...snapshot.rows.map(rowData => columns.map(column => formatValue(rowData.get(column), column))));
1083
+ }
1084
+ var bottomFloatingRows = [...bottomFloatingRowsSet].sort();
1085
+ var _loop3 = function* _loop3() {
1086
+ var row = bottomFloatingRows[_i2];
1087
+ var rowData = columns.map(column => {
1088
+ var index = _this2.getColumnIndexByName(column.name);
1089
+ assertNotNull(index);
1090
+ return formatValue(_this2.valueForCell(index, row), column);
1091
+ });
1092
+ if (includeHeaders) {
1093
+ rowData.push(_this2.textForRowFooter(row));
1094
+ }
1095
+ result.push(rowData);
1096
+ };
1097
+ for (var _i2 = 0; _i2 < bottomFloatingRows.length; _i2 += 1) {
1098
+ yield* _loop3();
1099
+ }
1100
+ return result;
1101
+ })();
1102
+ }
1103
+
1104
+ /**
1105
+ * Get a text snapshot of the provided ranges
1106
+ * @param ranges The ranges to get the snapshot for
1107
+ * @param includeHeaders Whether to include the headers in the snapshot or not
1108
+ * @param formatValue Function for formatting the raw value into a string
1109
+ * @returns A formatted string of all the data, columns separated by `\t` and rows separated by `\n`
1110
+ */
1111
+ textSnapshot(ranges) {
1112
+ var _arguments2 = arguments,
1113
+ _this3 = this;
1114
+ return _asyncToGenerator(function* () {
1115
+ var includeHeaders = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : false;
1116
+ var formatValue = _arguments2.length > 2 && _arguments2[2] !== undefined ? _arguments2[2] : value => "".concat(value);
1117
+ log.debug2('textSnapshot', ranges, includeHeaders);
1118
+ var data = yield _this3.snapshot(ranges, includeHeaders, formatValue, false);
1119
+ return data.map(row => row.join('\t')).join('\n');
1120
+ })();
1121
+ }
1122
+ valuesTable(column) {
1123
+ var _this4 = this;
1124
+ return _asyncToGenerator(function* () {
1125
+ var table = null;
1126
+ try {
1127
+ table = yield _this4.table.copy();
1128
+ table.applyFilter([]);
1129
+ table.applySort([]);
1130
+ return table.selectDistinct([column]);
1131
+ } finally {
1132
+ if (table != null) {
1133
+ table.close();
1134
+ }
1135
+ }
1136
+ })();
1137
+ }
1138
+ isColumnMovable(modelIndex, depth) {
1139
+ if (modelIndex < 0 || modelIndex >= this.columnCount) {
1140
+ return false;
1141
+ }
1142
+
1143
+ // All groups are movable
1144
+ if (depth > 0) {
1145
+ return true;
1146
+ }
1147
+ var columnName = this.columns[modelIndex].name;
1148
+ if (this.frontColumns.includes(columnName) || this.backColumns.includes(columnName) || this.frozenColumns.includes(columnName) || !columnName) {
1149
+ return false;
1150
+ }
1151
+ return !this.isKeyColumn(modelIndex);
1152
+ }
1153
+ isKeyColumn(x) {
1154
+ var _this$inputTable$keyC2, _this$inputTable2;
1155
+ return x < ((_this$inputTable$keyC2 = (_this$inputTable2 = this.inputTable) === null || _this$inputTable2 === void 0 ? void 0 : _this$inputTable2.keyColumns.length) !== null && _this$inputTable$keyC2 !== void 0 ? _this$inputTable$keyC2 : 0);
1156
+ }
1157
+ isRowMovable() {
1158
+ return false;
1159
+ }
1160
+ isEditableRange(range) {
1161
+ // Make sure we have an input table and a valid range
1162
+ if (this.inputTable == null || !GridRange.isBounded(range)) {
1163
+ return false;
1164
+ }
1165
+
1166
+ // Check that the edit is in the editable range
1167
+ // If an input table has keyed columns, the non-key columns are always editable
1168
+ // If an input table does not have key columns, it is append only and existing rows cannot be editable
1169
+ // Pending rows are always editable
1170
+ var isPendingRange = this.isPendingRow(range.startRow) && this.isPendingRow(range.endRow);
1171
+ if (!(isPendingRange || this.inputTable.keyColumns.length !== 0 && range.startColumn >= this.inputTable.keyColumns.length && range.endColumn >= this.inputTable.keyColumns.length)) {
1172
+ return false;
1173
+ }
1174
+
1175
+ // Editing the aggregations/totals which are floating above/below is not allowed
1176
+ if (range.startRow < this.floatingTopRowCount || range.startRow >= this.floatingTopRowCount + this.table.size + this.pendingRowCount || range.endRow >= this.floatingTopRowCount + this.table.size + this.pendingRowCount) {
1177
+ return false;
1178
+ }
1179
+ return true;
1180
+ }
1181
+ isDeletableRange(range) {
1182
+ return this.inputTable != null && range.startRow != null && range.endRow != null && range.startRow >= this.floatingTopRowCount && range.startRow < this.floatingTopRowCount + this.table.size + this.pendingRowCount && range.endRow < this.floatingTopRowCount + this.table.size + this.pendingRowCount;
1183
+ }
1184
+ isEditableRanges(ranges) {
1185
+ return ranges.every(range => this.isEditableRange(range));
1186
+ }
1187
+ isDeletableRanges(ranges) {
1188
+ return ranges.every(range => this.isDeletableRange(range));
1189
+ }
1190
+
1191
+ /**
1192
+ * @returns A range corresponding to the underlying table
1193
+ */
1194
+ getTableAreaRange() {
1195
+ return new GridRange(null, this.floatingTopRowCount, null, this.floatingTopRowCount + this.table.size - 1);
1196
+ }
1197
+
1198
+ /**
1199
+ * @returns A range corresponding to the pending new rows
1200
+ */
1201
+ getPendingAreaRange() {
1202
+ return new GridRange(null, this.floatingTopRowCount + this.table.size, null, this.floatingTopRowCount + this.table.size + this.pendingNewRowCount - 1);
1203
+ }
1204
+
1205
+ /**
1206
+ * Set value in an editable table
1207
+ * @param x The column to set
1208
+ * @param y The row to set
1209
+ * @param value The value to set
1210
+ * @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error
1211
+ */
1212
+ setValueForCell(x, y, text) {
1213
+ var _this5 = this;
1214
+ return _asyncToGenerator(function* () {
1215
+ // Cache the value in our pending string cache so that it stays displayed until our edit has been completed
1216
+ return _this5.setValueForRanges([new GridRange(x, y, x, y)], text);
1217
+ })();
1218
+ }
1219
+
1220
+ /**
1221
+ * Set value in an editable table
1222
+ * @param ranges The ranges to set
1223
+ * @param value The values to set
1224
+ * @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error
1225
+ */
1226
+ setValueForRanges(ranges, text) {
1227
+ var _this6 = this;
1228
+ return _asyncToGenerator(function* () {
1229
+ if (!_this6.isEditableRanges(ranges)) {
1230
+ throw new Error("Uneditable ranges ".concat(ranges));
1231
+ }
1232
+ try {
1233
+ // Cache the value in our pending string cache so that it stays displayed until our edit has been completed
1234
+ var columnSet = new Set();
1235
+
1236
+ // Formatted text for each column
1237
+ // Since there could be different formatting for each column, but the value will be the same across rows
1238
+ var formattedText = [];
1239
+ GridRange.forEachCell(ranges, (x, y) => {
1240
+ var column = _this6.columns[x];
1241
+ columnSet.add(column);
1242
+ if (formattedText[x] === undefined) {
1243
+ var _value3 = _this6.tableUtils.makeValue(column.type, text, _this6.formatter.timeZone);
1244
+ formattedText[x] = _value3 != null ? _this6.displayString(_value3, column.type, column.name) : null;
1245
+ }
1246
+ _this6.cachePendingValue(x, y, formattedText[x]);
1247
+ });
1248
+
1249
+ // Take care of updates to the pending new area first, as they can be updated synchronously
1250
+ var pendingAreaRange = _this6.getPendingAreaRange();
1251
+ var pendingRanges = ranges.map(range => GridRange.intersection(pendingAreaRange, range)).filter(range => range != null).map(range => {
1252
+ assertNotNull(range);
1253
+ return GridRange.offset(range, 0, -(_this6.floatingTopRowCount + _this6.table.size));
1254
+ });
1255
+ if (pendingRanges.length > 0) {
1256
+ var newDataMap = new Map(_this6.pendingNewDataMap);
1257
+ GridRange.forEachCell(pendingRanges, (columnIndex, rowIndex) => {
1258
+ if (!newDataMap.has(rowIndex)) {
1259
+ newDataMap.set(rowIndex, {
1260
+ data: new Map()
1261
+ });
1262
+ }
1263
+ var column = _this6.columns[columnIndex];
1264
+ var row = newDataMap.get(rowIndex);
1265
+ assertNotNull(row);
1266
+ var {
1267
+ data: rowData
1268
+ } = row;
1269
+ var newRowData = new Map(rowData);
1270
+ var value = _this6.tableUtils.makeValue(column.type, text, _this6.formatter.timeZone);
1271
+ if (value != null) {
1272
+ newRowData.set(columnIndex, {
1273
+ value
1274
+ });
1275
+ } else {
1276
+ newRowData.delete(columnIndex);
1277
+ }
1278
+ if (newRowData.size > 0) {
1279
+ newDataMap.set(rowIndex, _objectSpread(_objectSpread({}, row), {}, {
1280
+ data: newRowData
1281
+ }));
1282
+ } else {
1283
+ newDataMap.delete(rowIndex);
1284
+ }
1285
+ });
1286
+ _this6.pendingDataMap = newDataMap;
1287
+ }
1288
+ _this6.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
1289
+ var tableAreaRange = _this6.getTableAreaRange();
1290
+ var tableRanges = ranges.map(range => GridRange.intersection(tableAreaRange, range)).filter(range => range != null);
1291
+ if (tableRanges.length > 0) {
1292
+ var _this6$inputTable;
1293
+ // Get a snapshot of the full rows, as we need to write a full row when editing
1294
+ var data = yield _this6.snapshot(tableRanges.map(range => {
1295
+ var _range$startRow, _range$endRow;
1296
+ return new GridRange(null, (_range$startRow = range === null || range === void 0 ? void 0 : range.startRow) !== null && _range$startRow !== void 0 ? _range$startRow : null, null, (_range$endRow = range === null || range === void 0 ? void 0 : range.endRow) !== null && _range$endRow !== void 0 ? _range$endRow : null);
1297
+ }));
1298
+ var newRows = data.map(row => {
1299
+ var newRow = {};
1300
+ for (var c = 0; c < _this6.columns.length; c += 1) {
1301
+ newRow[_this6.columns[c].name] = row[c];
1302
+ }
1303
+ columnSet.forEach(column => {
1304
+ newRow[column.name] = _this6.tableUtils.makeValue(column.type, text, _this6.formatter.timeZone);
1305
+ });
1306
+ return newRow;
1307
+ });
1308
+ var result = yield (_this6$inputTable = _this6.inputTable) === null || _this6$inputTable === void 0 ? void 0 : _this6$inputTable.addRows(newRows);
1309
+ log.debug('setValueForRanges(', ranges, ',', text, ') set tableRanges', tableRanges, 'result', result);
1310
+ }
1311
+
1312
+ // Add the changes to the formatted cache so it's still displayed until the update event is received
1313
+ // The update event could be received on the next tick, after the input rows have been committed,
1314
+ // so make sure we don't display stale data
1315
+ GridRange.forEachCell(ranges, (x, y) => {
1316
+ var cellText = formattedText[x];
1317
+ assertNotNull(cellText);
1318
+ _this6.cacheFormattedValue(x, y, cellText);
1319
+ });
1320
+ } catch (err) {
1321
+ log.error('Unable to set ranges', ranges, text, err);
1322
+ } finally {
1323
+ GridRange.forEachCell(ranges, (x, y) => {
1324
+ _this6.clearPendingValue(x, y);
1325
+ });
1326
+ }
1327
+ })();
1328
+ }
1329
+ setValues() {
1330
+ var _arguments3 = arguments,
1331
+ _this7 = this;
1332
+ return _asyncToGenerator(function* () {
1333
+ var edits = _arguments3.length > 0 && _arguments3[0] !== undefined ? _arguments3[0] : [];
1334
+ log.debug('setValues(', edits, ')');
1335
+ if (!edits.every(edit => {
1336
+ var _edit$column, _edit$row;
1337
+ return _this7.isEditableRange(GridRange.makeCell((_edit$column = edit.column) !== null && _edit$column !== void 0 ? _edit$column : edit.x, (_edit$row = edit.row) !== null && _edit$row !== void 0 ? _edit$row : edit.y));
1338
+ })) {
1339
+ throw new Error("Uneditable ranges ".concat(edits));
1340
+ }
1341
+ try {
1342
+ var newDataMap = new Map(_this7.pendingNewDataMap);
1343
+
1344
+ // Cache the display values
1345
+ edits.forEach(edit => {
1346
+ var _edit$column2, _edit$row2;
1347
+ var {
1348
+ text
1349
+ } = edit;
1350
+ var x = (_edit$column2 = edit.column) !== null && _edit$column2 !== void 0 ? _edit$column2 : edit.x;
1351
+ var y = (_edit$row2 = edit.row) !== null && _edit$row2 !== void 0 ? _edit$row2 : edit.y;
1352
+ var column = _this7.columns[x];
1353
+ var value = _this7.tableUtils.makeValue(column.type, text, _this7.formatter.timeZone);
1354
+ var formattedText = value != null ? _this7.displayString(value, column.type, column.name) : null;
1355
+ _this7.cachePendingValue(x, y, formattedText);
1356
+
1357
+ // Take care of updates to the pending new area as well, as that can be updated synchronously
1358
+ var pendingRow = _this7.pendingRow(y);
1359
+ if (pendingRow != null) {
1360
+ if (!newDataMap.has(pendingRow)) {
1361
+ newDataMap.set(pendingRow, {
1362
+ data: new Map()
1363
+ });
1364
+ }
1365
+ var _row2 = newDataMap.get(pendingRow);
1366
+ assertNotNull(_row2);
1367
+ var {
1368
+ data: rowData
1369
+ } = _row2;
1370
+ var newRowData = new Map(rowData);
1371
+ if (value != null) {
1372
+ newRowData.set(x, {
1373
+ value
1374
+ });
1375
+ } else {
1376
+ newRowData.delete(x);
1377
+ }
1378
+ if (newRowData.size > 0) {
1379
+ newDataMap.set(pendingRow, _objectSpread(_objectSpread({}, _row2), {}, {
1380
+ data: newRowData
1381
+ }));
1382
+ } else {
1383
+ newDataMap.delete(pendingRow);
1384
+ }
1385
+ }
1386
+ });
1387
+ _this7.pendingDataMap = newDataMap;
1388
+
1389
+ // Send an update right after setting the pending map so the values are displayed immediately
1390
+ _this7.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
1391
+
1392
+ // Need to group by row...
1393
+ var rowEditMap = edits.reduce((rowMap, edit) => {
1394
+ var _edit$row3, _rowMap$get;
1395
+ var y = (_edit$row3 = edit.row) !== null && _edit$row3 !== void 0 ? _edit$row3 : edit.y;
1396
+ if (!rowMap.has(y)) {
1397
+ rowMap.set(y, []);
1398
+ }
1399
+ (_rowMap$get = rowMap.get(y)) === null || _rowMap$get === void 0 ? void 0 : _rowMap$get.push(edit);
1400
+ return rowMap;
1401
+ }, new Map());
1402
+ var ranges = GridRange.consolidate(edits.map(edit => {
1403
+ var _edit$column3, _edit$row4;
1404
+ return GridRange.makeCell((_edit$column3 = edit.column) !== null && _edit$column3 !== void 0 ? _edit$column3 : edit.x, (_edit$row4 = edit.row) !== null && _edit$row4 !== void 0 ? _edit$row4 : edit.y);
1405
+ }));
1406
+ var tableAreaRange = _this7.getTableAreaRange();
1407
+ var tableRanges = ranges.map(range => GridRange.intersection(tableAreaRange, range)).filter(range => range != null);
1408
+ if (tableRanges.length > 0) {
1409
+ var _this7$inputTable;
1410
+ // Get a snapshot of the full rows, as we need to write a full row when editing
1411
+ var data = yield _this7.snapshot(tableRanges.map(range => {
1412
+ assertNotNull(range);
1413
+ return new GridRange(null, range.startRow, null, range.endRow);
1414
+ }));
1415
+ var newRows = data.map((row, dataIndex) => {
1416
+ var rowIndex = null;
1417
+ var r = dataIndex;
1418
+ for (var i = 0; i < tableRanges.length; i += 1) {
1419
+ var range = tableRanges[i];
1420
+ assertNotNull(range);
1421
+ var rangeRowCount = GridRange.rowCount([range]);
1422
+ if (r < rangeRowCount) {
1423
+ assertNotNull(range.startRow);
1424
+ rowIndex = range.startRow + r;
1425
+ break;
1426
+ }
1427
+ r -= rangeRowCount;
1428
+ }
1429
+ var newRow = {};
1430
+ for (var c = 0; c < _this7.columns.length; c += 1) {
1431
+ newRow[_this7.columns[c].name] = row[c];
1432
+ }
1433
+ assertNotNull(rowIndex);
1434
+ var rowEdits = rowEditMap.get(rowIndex);
1435
+ if (rowEdits != null) {
1436
+ rowEdits.forEach(edit => {
1437
+ var _edit$column4;
1438
+ var column = _this7.columns[(_edit$column4 = edit.column) !== null && _edit$column4 !== void 0 ? _edit$column4 : edit.x];
1439
+ newRow[column.name] = _this7.tableUtils.makeValue(column.type, edit.text, _this7.formatter.timeZone);
1440
+ });
1441
+ }
1442
+ return newRow;
1443
+ });
1444
+ log.info('setValues setting tableRanges', tableRanges);
1445
+ var result = yield (_this7$inputTable = _this7.inputTable) === null || _this7$inputTable === void 0 ? void 0 : _this7$inputTable.addRows(newRows);
1446
+ log.info('setValues set tableRanges', tableRanges, 'SUCCESS', result);
1447
+ }
1448
+
1449
+ // We've sent the changes to the server, but have not yet got an update with those changes committed
1450
+ // Add the changes to the formatted cache so it's still displayed until the update event is received
1451
+ // The update event could be received on the next tick, after the input rows have been committed,
1452
+ // so make sure we don't display stale data
1453
+ edits.forEach(edit => {
1454
+ var _edit$column5, _edit$row5;
1455
+ var {
1456
+ text
1457
+ } = edit;
1458
+ var x = (_edit$column5 = edit.column) !== null && _edit$column5 !== void 0 ? _edit$column5 : edit.x;
1459
+ var y = (_edit$row5 = edit.row) !== null && _edit$row5 !== void 0 ? _edit$row5 : edit.y;
1460
+ var column = _this7.columns[x];
1461
+ var value = _this7.tableUtils.makeValue(column.type, text, _this7.formatter.timeZone);
1462
+ var formattedText = value != null ? _this7.displayString(value, column.type, column.name) : null;
1463
+ _this7.cacheFormattedValue(x, y, formattedText);
1464
+ });
1465
+ } finally {
1466
+ edits.forEach(edit => {
1467
+ _this7.clearPendingValue(edit.column, edit.row);
1468
+ });
1469
+ }
1470
+ })();
1471
+ }
1472
+ commitPending() {
1473
+ var _this8 = this;
1474
+ return _asyncToGenerator(function* () {
1475
+ if (_this8.pendingNewDataMap.size <= 0) {
1476
+ throw new Error('No pending changes to commit');
1477
+ }
1478
+ try {
1479
+ var _this8$inputTable, _this8$viewport$botto, _this8$viewport;
1480
+ _this8.isSaveInProgress = true;
1481
+ var newRows = [];
1482
+ _this8.pendingNewDataMap.forEach(row => {
1483
+ var newRow = {};
1484
+ row.data.forEach((_ref2, columnIndex) => {
1485
+ var {
1486
+ value
1487
+ } = _ref2;
1488
+ var column = _this8.columns[columnIndex];
1489
+ newRow[column.name] = value;
1490
+ });
1491
+ newRows.push(newRow);
1492
+ });
1493
+ var result = yield (_this8$inputTable = _this8.inputTable) === null || _this8$inputTable === void 0 ? void 0 : _this8$inputTable.addRows(newRows);
1494
+ log.debug('commitPending()', _this8.pendingNewDataMap, 'result', result);
1495
+ _this8.pendingNewDataMap = new Map();
1496
+ _this8.pendingNewRowCount = Math.max(0, ((_this8$viewport$botto = (_this8$viewport = _this8.viewport) === null || _this8$viewport === void 0 ? void 0 : _this8$viewport.bottom) !== null && _this8$viewport$botto !== void 0 ? _this8$viewport$botto : 0) - _this8.table.size);
1497
+ _this8.formattedStringData = [];
1498
+ _this8.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.PENDING_DATA_UPDATED));
1499
+ } finally {
1500
+ _this8.isSaveInProgress = false;
1501
+ }
1502
+ })();
1503
+ }
1504
+ editValueForCell(x, y) {
1505
+ return this.textValueForCell(x, y);
1506
+ }
1507
+ delete(ranges) {
1508
+ var _this9 = this;
1509
+ return _asyncToGenerator(function* () {
1510
+ if (!_this9.isDeletableRanges(ranges)) {
1511
+ throw new Error("Undeletable ranges ".concat(ranges));
1512
+ }
1513
+ assertNotNull(_this9.inputTable);
1514
+ var {
1515
+ keyColumns
1516
+ } = _this9.inputTable;
1517
+ if (keyColumns.length === 0) {
1518
+ throw new Error('No key columns to allow deletion');
1519
+ }
1520
+ var pendingAreaRange = _this9.getPendingAreaRange();
1521
+ var pendingRanges = ranges.map(range => GridRange.intersection(pendingAreaRange, range)).filter(range => range != null).map(range => {
1522
+ assertNotNull(range);
1523
+ return GridRange.offset(range, 0, -(_this9.floatingTopRowCount + _this9.table.size));
1524
+ });
1525
+ if (pendingRanges.length > 0) {
1526
+ var newDataMap = new Map(_this9.pendingNewDataMap);
1527
+ for (var i = 0; i < pendingRanges.length; i += 1) {
1528
+ var pendingRange = pendingRanges[i];
1529
+ assertNotNull(pendingRange.startRow);
1530
+ assertNotNull(pendingRange.endRow);
1531
+ for (var r = pendingRange.startRow; r <= pendingRange.endRow; r += 1) {
1532
+ newDataMap.delete(r);
1533
+ }
1534
+ }
1535
+ _this9.pendingNewDataMap = newDataMap;
1536
+ _this9.formattedStringData = [];
1537
+ _this9.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.PENDING_DATA_UPDATED));
1538
+ _this9.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
1539
+ }
1540
+ var tableAreaRange = _this9.getTableAreaRange();
1541
+ var tableRanges = ranges.map(range => GridRange.intersection(tableAreaRange, range)).filter(range => range != null);
1542
+ if (tableRanges.length <= 0) {
1543
+ return;
1544
+ }
1545
+ var [data, deleteTable] = yield Promise.all([
1546
+ // Need to get the key values of each row
1547
+ _this9.snapshot(tableRanges.map(range => {
1548
+ assertNotNull(range);
1549
+ return new GridRange(0, range.startRow, keyColumns.length - 1, range.endRow);
1550
+ })), _this9.table.copy()]);
1551
+
1552
+ // Now copy the existing table and filter it on the values in the snapshot for the key columns in the input table
1553
+ var filters = data.map(row => {
1554
+ var columnFilters = [];
1555
+ for (var c = 0; c < keyColumns.length; c += 1) {
1556
+ var _column4 = keyColumns[c];
1557
+ var _value4 = row[c];
1558
+ var filterValue = _this9.tableUtils.makeFilterRawValue(_column4.type, _value4);
1559
+ var _filter = _column4.filter().eq(filterValue);
1560
+ columnFilters.push(_filter);
1561
+ }
1562
+ return columnFilters.reduce((agg, curr) => {
1563
+ var _agg$and;
1564
+ return (_agg$and = agg === null || agg === void 0 ? void 0 : agg.and(curr)) !== null && _agg$and !== void 0 ? _agg$and : curr;
1565
+ });
1566
+ });
1567
+ var filter = filters.reduce((agg, curr) => {
1568
+ var _agg$or;
1569
+ return (_agg$or = agg === null || agg === void 0 ? void 0 : agg.or(curr)) !== null && _agg$or !== void 0 ? _agg$or : curr;
1570
+ });
1571
+ deleteTable.applyFilter([filter]);
1572
+
1573
+ // await this.inputTable?.deleteTable(deleteTable);
1574
+ deleteTable.close();
1575
+ })();
1576
+ }
1577
+ isValidForCell(x, y, value) {
1578
+ try {
1579
+ var _column5 = this.columns[x];
1580
+ this.tableUtils.makeValue(_column5.type, value, this.formatter.timeZone);
1581
+ return true;
1582
+ } catch (e) {
1583
+ return false;
1584
+ }
1585
+ }
1586
+ }
1587
+ _defineProperty(IrisGridTableModelTemplate, "ROW_BUFFER_PAGES", 1);
1588
+ export default IrisGridTableModelTemplate;
1589
+ //# sourceMappingURL=IrisGridTableModelTemplate.js.map