@deephaven/iris-grid 0.83.1-beta.4 → 0.84.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.
@@ -1,14 +1,10 @@
1
- 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); } }
2
- 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); }); }; }
3
1
  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; }
4
2
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
3
  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); }
6
- /* eslint class-methods-use-this: "off" */
7
4
  import deepEqual from 'fast-deep-equal';
8
5
  import { Formatter, TableUtils } from '@deephaven/jsapi-utils';
9
6
  import Log from '@deephaven/log';
10
7
  import { EventShimCustomEvent, PromiseUtils } from '@deephaven/utils';
11
- import { isEditableGridModel, isExpandableGridModel, isDeletableGridModel } from '@deephaven/grid';
12
8
  import IrisGridTableModel from "./IrisGridTableModel.js";
13
9
  import IrisGridPartitionedTableModel from "./IrisGridPartitionedTableModel.js";
14
10
  import IrisGridTreeTableModel from "./IrisGridTreeTableModel.js";
@@ -29,7 +25,11 @@ function makeModel(dh, table, formatter, inputTable) {
29
25
  /**
30
26
  * Model which proxies calls to other IrisGridModels.
31
27
  * This allows for operations that generate new tables, like rollups.
28
+ * The proxy model will call any methods it has implemented and delegate any
29
+ * it does not implement to the underlying model.
32
30
  */
31
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
+ // @ts-ignore
33
33
  class IrisGridProxyModel extends IrisGridModel {
34
34
  /**
35
35
  * @param dh JSAPI instance
@@ -39,137 +39,20 @@ class IrisGridProxyModel extends IrisGridModel {
39
39
  */
40
40
 
41
41
  constructor(dh, table) {
42
- var _this;
43
42
  var formatter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Formatter(dh);
44
43
  var inputTable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
45
44
  super(dh);
46
- _this = this;
45
+
46
+ // The EventTarget methods must be bound to this instance
47
+ // Otherwise they throw errors because of the Proxy
48
+ _defineProperty(this, "model", void 0);
47
49
  _defineProperty(this, "dh", void 0);
48
50
  _defineProperty(this, "originalModel", void 0);
49
- _defineProperty(this, "model", void 0);
50
51
  _defineProperty(this, "modelPromise", void 0);
51
52
  _defineProperty(this, "rollup", void 0);
52
53
  _defineProperty(this, "partition", void 0);
53
54
  _defineProperty(this, "selectDistinct", void 0);
54
55
  _defineProperty(this, "currentViewport", void 0);
55
- _defineProperty(this, "textForCell", function () {
56
- return _this.model.textForCell(...arguments);
57
- });
58
- _defineProperty(this, "truncationCharForCell", function () {
59
- return _this.model.truncationCharForCell(...arguments);
60
- });
61
- _defineProperty(this, "textAlignForCell", function () {
62
- return _this.model.textAlignForCell(...arguments);
63
- });
64
- _defineProperty(this, "colorForCell", function () {
65
- return _this.model.colorForCell(...arguments);
66
- });
67
- _defineProperty(this, "backgroundColorForCell", function () {
68
- return _this.model.backgroundColorForCell(...arguments);
69
- });
70
- _defineProperty(this, "textForColumnHeader", function () {
71
- return _this.model.textForColumnHeader(...arguments);
72
- });
73
- _defineProperty(this, "colorForColumnHeader", function () {
74
- return _this.model.colorForColumnHeader(...arguments);
75
- });
76
- _defineProperty(this, "textForRowHeader", function () {
77
- return _this.model.textForRowHeader(...arguments);
78
- });
79
- _defineProperty(this, "textForRowFooter", function () {
80
- return _this.model.textForRowFooter(...arguments);
81
- });
82
- _defineProperty(this, "isRowMovable", function () {
83
- return _this.model.isRowMovable(...arguments);
84
- });
85
- _defineProperty(this, "isColumnMovable", function () {
86
- return _this.model.isColumnMovable(...arguments);
87
- });
88
- _defineProperty(this, "isRowExpandable", function () {
89
- if (isExpandableGridModel(_this.model)) {
90
- return _this.model.isRowExpandable(...arguments);
91
- }
92
- return false;
93
- });
94
- _defineProperty(this, "isRowExpanded", function () {
95
- if (isExpandableGridModel(_this.model)) {
96
- return _this.model.isRowExpanded(...arguments);
97
- }
98
- return false;
99
- });
100
- _defineProperty(this, "setRowExpanded", function () {
101
- if (isExpandableGridModel(_this.model)) {
102
- return _this.model.setRowExpanded(...arguments);
103
- }
104
- throw Error('Function setRowExpanded does not exist on IrisGridTableModel');
105
- });
106
- _defineProperty(this, "expandAll", () => {
107
- if (isExpandableGridModel(this.model)) {
108
- return this.model.expandAll();
109
- }
110
- throw Error('Function expandAll does not exist on IrisGridTableModel');
111
- });
112
- _defineProperty(this, "collapseAll", () => {
113
- if (isExpandableGridModel(this.model)) {
114
- return this.model.collapseAll();
115
- }
116
- throw Error('Function collapseAll does not exist on IrisGridTableModel');
117
- });
118
- _defineProperty(this, "depthForRow", function () {
119
- if (isExpandableGridModel(_this.model)) {
120
- return _this.model.depthForRow(...arguments);
121
- }
122
- return 0;
123
- // throw Error('Function depthForRow does not exist on IrisGridTableModel');
124
- });
125
- _defineProperty(this, "getColumnHeaderGroup", function () {
126
- return _this.model.getColumnHeaderGroup(...arguments);
127
- });
128
- _defineProperty(this, "getColumnHeaderParentGroup", function () {
129
- return _this.model.getColumnHeaderParentGroup(...arguments);
130
- });
131
- _defineProperty(this, "sourceForCell", function () {
132
- return _this.model.sourceForCell(...arguments);
133
- });
134
- _defineProperty(this, "getClearFilterRange", function () {
135
- return _this.model.getClearFilterRange(...arguments);
136
- });
137
- _defineProperty(this, "formatForCell", function () {
138
- return _this.model.formatForCell(...arguments);
139
- });
140
- _defineProperty(this, "valueForCell", function () {
141
- return _this.model.valueForCell(...arguments);
142
- });
143
- _defineProperty(this, "renderTypeForCell", function () {
144
- return _this.model.renderTypeForCell(...arguments);
145
- });
146
- _defineProperty(this, "dataBarOptionsForCell", function () {
147
- return _this.model.dataBarOptionsForCell(...arguments);
148
- });
149
- _defineProperty(this, "displayString", function () {
150
- return _this.model.displayString(...arguments);
151
- });
152
- _defineProperty(this, "isEditableRange", function () {
153
- if (isEditableGridModel(_this.model)) {
154
- return _this.model.isEditableRange(...arguments);
155
- }
156
- return false;
157
- });
158
- _defineProperty(this, "isDeletableRange", function () {
159
- if (isDeletableGridModel(_this.model)) {
160
- return _this.model.isDeletableRange(...arguments);
161
- }
162
- return false;
163
- });
164
- _defineProperty(this, "isDeletableRanges", function () {
165
- if (isDeletableGridModel(_this.model)) {
166
- return _this.model.isDeletableRanges(...arguments);
167
- }
168
- return false;
169
- });
170
- _defineProperty(this, "isFilterable", function () {
171
- return _this.model.isFilterable(...arguments);
172
- });
173
56
  _defineProperty(this, "setViewport", (top, bottom, columns) => {
174
57
  this.currentViewport = {
175
58
  top,
@@ -178,54 +61,9 @@ class IrisGridProxyModel extends IrisGridModel {
178
61
  };
179
62
  this.model.setViewport(top, bottom, columns);
180
63
  });
181
- _defineProperty(this, "snapshot", function () {
182
- return _this.model.snapshot(...arguments);
183
- });
184
- _defineProperty(this, "textSnapshot", function () {
185
- return _this.model.textSnapshot(...arguments);
186
- });
187
- _defineProperty(this, "valuesTable", function () {
188
- return _this.model.valuesTable(...arguments);
189
- });
190
- _defineProperty(this, "editValueForCell", function () {
191
- if (isEditableGridModel(_this.model)) {
192
- return _this.model.editValueForCell(...arguments);
193
- }
194
- return '';
195
- });
196
- _defineProperty(this, "setValueForCell", function () {
197
- if (isEditableGridModel(_this.model)) {
198
- return _this.model.setValueForCell(...arguments);
199
- }
200
- return Promise.reject(new Error('Model is not editable'));
201
- });
202
- _defineProperty(this, "setValueForRanges", function () {
203
- if (isEditableGridModel(_this.model)) {
204
- return _this.model.setValueForRanges(...arguments);
205
- }
206
- return Promise.reject(new Error('Model is not editable'));
207
- });
208
- _defineProperty(this, "setValues", function () {
209
- if (isEditableGridModel(_this.model)) {
210
- return _this.model.setValues(...arguments);
211
- }
212
- return Promise.resolve();
213
- });
214
- _defineProperty(this, "isValidForCell", function () {
215
- if (isEditableGridModel(_this.model)) {
216
- return _this.model.isValidForCell(...arguments);
217
- }
218
- return false;
219
- });
220
- _defineProperty(this, "delete", function () {
221
- if (isDeletableGridModel(_this.model)) {
222
- return _this.model.delete(...arguments);
223
- }
224
- return Promise.reject(new Error('Model is not deletable'));
225
- });
226
- _defineProperty(this, "commitPending", function () {
227
- return _this.model.commitPending(...arguments);
228
- });
64
+ this.addEventListener = this.addEventListener.bind(this);
65
+ this.removeEventListener = this.removeEventListener.bind(this);
66
+ this.dispatchEvent = this.dispatchEvent.bind(this);
229
67
  this.handleModelEvent = this.handleModelEvent.bind(this);
230
68
  var model = makeModel(dh, table, formatter, inputTable);
231
69
  this.dh = dh;
@@ -235,6 +73,37 @@ class IrisGridProxyModel extends IrisGridModel {
235
73
  this.rollup = null;
236
74
  this.partition = null;
237
75
  this.selectDistinct = [];
76
+
77
+ // eslint-disable-next-line no-constructor-return
78
+ return new Proxy(this, {
79
+ // We want to use any properties on the proxy model if defined
80
+ // If not, then proxy to the underlying model
81
+ get(target, prop, receiver) {
82
+ var _Object$getOwnPropert;
83
+ // Does this class have a getter for the prop
84
+ // Getter functions are on the prototype
85
+ var proxyHasGetter = ((_Object$getOwnPropert = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(target), prop)) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.get) != null;
86
+ if (proxyHasGetter) {
87
+ return Reflect.get(target, prop, receiver);
88
+ }
89
+
90
+ // Does this class implement the property
91
+ var proxyHasProp = Object.prototype.hasOwnProperty.call(target, prop);
92
+
93
+ // Does the class implement a function for the property
94
+ var proxyHasFn = Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(target), prop);
95
+ var trueTarget = proxyHasProp || proxyHasFn ? target : target.model;
96
+ return Reflect.get(trueTarget, prop);
97
+ },
98
+ set(target, prop, value) {
99
+ var _Object$getOwnPropert2;
100
+ var proxyHasSetter = ((_Object$getOwnPropert2 = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(target), prop)) === null || _Object$getOwnPropert2 === void 0 ? void 0 : _Object$getOwnPropert2.set) != null;
101
+ if (proxyHasSetter) {
102
+ return Reflect.set(target, prop, value, target);
103
+ }
104
+ return Reflect.set(target.model, prop, value, target.model);
105
+ }
106
+ });
238
107
  }
239
108
  close() {
240
109
  this.originalModel.close();
@@ -335,138 +204,26 @@ class IrisGridProxyModel extends IrisGridModel {
335
204
  model.removeEventListener(events[i], this.handleModelEvent);
336
205
  }
337
206
  }
338
- get rowCount() {
339
- return this.model.rowCount;
340
- }
341
- get columnCount() {
342
- return this.model.columnCount;
343
- }
344
- get floatingTopRowCount() {
345
- return this.model.floatingTopRowCount;
346
- }
347
- get floatingBottomRowCount() {
348
- return this.model.floatingBottomRowCount;
349
- }
350
- get floatingLeftColumnCount() {
351
- return this.model.floatingLeftColumnCount;
352
- }
353
- get floatingRightColumnCount() {
354
- return this.model.floatingRightColumnCount;
355
- }
356
- isColumnFrozen(x) {
357
- return this.model.isColumnFrozen(x);
358
- }
359
- isColumnSortable(index) {
360
- return this.model.isColumnSortable(index);
361
- }
362
- get hasExpandableRows() {
363
- if (isExpandableGridModel(this.model)) {
364
- return this.model.hasExpandableRows;
365
- }
366
- return false;
367
- }
368
- get isExpandAllAvailable() {
369
- if (isExpandableGridModel(this.model)) {
370
- var _this$model$isExpandA;
371
- return (_this$model$isExpandA = this.model.isExpandAllAvailable) !== null && _this$model$isExpandA !== void 0 ? _this$model$isExpandA : false;
372
- }
373
- return false;
374
- }
375
- get isExportAvailable() {
376
- return this.model.isExportAvailable;
377
- }
378
- get isColumnStatisticsAvailable() {
379
- return this.model.isColumnStatisticsAvailable;
380
- }
381
- get isValuesTableAvailable() {
382
- return this.model.isValuesTableAvailable;
383
- }
384
207
  get isCustomColumnsAvailable() {
385
208
  return this.model.isCustomColumnsAvailable &&
386
209
  // Disable for selectDistinct tables
387
210
  !(this.isSelectDistinctAvailable && this.selectDistinctColumns.length > 0);
388
211
  }
389
- get isFormatColumnsAvailable() {
390
- return this.model.isFormatColumnsAvailable;
391
- }
392
- get isChartBuilderAvailable() {
393
- return this.model.isChartBuilderAvailable;
394
- }
395
212
  get isRollupAvailable() {
396
213
  return (this.originalModel.isRollupAvailable || this.rollup != null) && this.selectDistinct.length === 0;
397
214
  }
398
215
  get isSelectDistinctAvailable() {
399
216
  return (this.originalModel.isSelectDistinctAvailable || this.selectDistinct.length > 0) && this.rollup == null;
400
217
  }
401
- get isTotalsAvailable() {
402
- return this.model.isTotalsAvailable;
403
- }
404
- get isReversible() {
405
- return this.model.isReversible;
406
- }
407
- get columns() {
408
- return this.model.columns;
409
- }
410
- get initialMovedColumns() {
411
- return this.model.initialMovedColumns;
412
- }
413
- get initialMovedRows() {
414
- return this.model.initialMovedRows;
415
- }
416
- get layoutHints() {
417
- return this.model.layoutHints;
418
- }
419
- get frontColumns() {
420
- return this.model.frontColumns;
421
- }
422
- get backColumns() {
423
- return this.model.backColumns;
424
- }
425
- get frozenColumns() {
426
- return this.model.frozenColumns;
427
- }
428
- get keyColumnSet() {
429
- return this.model.keyColumnSet;
430
- }
431
- get columnHeaderGroups() {
432
- return this.model.columnHeaderGroups;
433
- }
434
- set columnHeaderGroups(groups) {
435
- this.model.columnHeaderGroups = groups;
436
- }
437
- get initialColumnHeaderGroups() {
438
- return this.model.initialColumnHeaderGroups;
439
- }
440
- get columnHeaderGroupMap() {
441
- return this.model.columnHeaderGroupMap;
442
- }
443
- get columnHeaderMaxDepth() {
444
- return this.model.columnHeaderMaxDepth;
445
- }
446
- updateFrozenColumns(columns) {
447
- return this.model.updateFrozenColumns(columns);
448
- }
449
218
  get originalColumns() {
450
219
  return this.originalModel.columns;
451
220
  }
452
- get groupedColumns() {
453
- return this.model.groupedColumns;
454
- }
455
221
  get partitionColumns() {
456
222
  if (!isPartitionedGridModelProvider(this.originalModel)) {
457
223
  return [];
458
224
  }
459
225
  return this.originalModel.partitionColumns;
460
226
  }
461
- get description() {
462
- return this.model.description;
463
- }
464
- get filter() {
465
- return this.model.filter;
466
- }
467
- set filter(filter) {
468
- this.model.filter = filter;
469
- }
470
227
  get partitionConfig() {
471
228
  if (!isPartitionedGridModelProvider(this.originalModel) || !this.originalModel.isPartitionRequired) {
472
229
  return null;
@@ -509,30 +266,6 @@ class IrisGridProxyModel extends IrisGridModel {
509
266
  }
510
267
  return this.originalModel.partitionTable(partitions);
511
268
  }
512
- get formatter() {
513
- return this.model.formatter;
514
- }
515
- set formatter(formatter) {
516
- this.model.formatter = formatter;
517
- }
518
- get sort() {
519
- return this.model.sort;
520
- }
521
- set sort(sort) {
522
- this.model.sort = sort;
523
- }
524
- get customColumns() {
525
- return this.model.customColumns;
526
- }
527
- set customColumns(customColumns) {
528
- this.model.customColumns = customColumns;
529
- }
530
- get formatColumns() {
531
- return this.model.formatColumns;
532
- }
533
- set formatColumns(formatColumns) {
534
- this.model.formatColumns = formatColumns;
535
- }
536
269
  get rollupConfig() {
537
270
  return this.rollup;
538
271
  }
@@ -574,72 +307,12 @@ class IrisGridProxyModel extends IrisGridModel {
574
307
  }
575
308
  this.setNextModel(modelPromise);
576
309
  }
577
- get table() {
578
- if (isIrisGridTableModelTemplate(this.model)) {
579
- return this.model.table;
580
- }
581
- return undefined;
582
- }
583
- get totalsConfig() {
584
- return this.model.totalsConfig;
585
- }
586
- set totalsConfig(totalsConfig) {
587
- this.model.totalsConfig = totalsConfig;
588
- }
589
310
  get isFilterRequired() {
590
311
  return this.originalModel.isFilterRequired;
591
312
  }
592
313
  get isPartitionRequired() {
593
314
  return isPartitionedGridModelProvider(this.originalModel) ? this.originalModel.isPartitionRequired : false;
594
315
  }
595
- get isEditable() {
596
- return isEditableGridModel(this.model) && this.model.isEditable;
597
- }
598
- get isDeletable() {
599
- return isDeletableGridModel(this.model) && this.model.isDeletable;
600
- }
601
- get isViewportPending() {
602
- return this.model.isViewportPending;
603
- }
604
- export() {
605
- if (TableUtils.isTreeTable(this.model)) {
606
- throw new Error("TreeTable has no 'export' property");
607
- }
608
- return this.model.export();
609
- }
610
- columnStatistics(column) {
611
- if (TableUtils.isTreeTable(this.model)) {
612
- throw new Error("TreeTable has no 'columnStatistics' function");
613
- }
614
- return this.model.columnStatistics(column);
615
- }
616
- get pendingDataMap() {
617
- return this.model.pendingDataMap;
618
- }
619
- set pendingDataMap(map) {
620
- this.model.pendingDataMap = map;
621
- }
622
- get pendingRowCount() {
623
- return this.model.pendingRowCount;
624
- }
625
- set pendingRowCount(count) {
626
- this.model.pendingRowCount = count;
627
- }
628
- get pendingDataErrors() {
629
- return this.model.pendingDataErrors;
630
- }
631
- getColumnIndexByName(name) {
632
- return this.model.getColumnIndexByName(name);
633
- }
634
- seekRow(startRow, column, valueType, value, insensitive, contains, isBackwards) {
635
- var _this2 = this;
636
- return _asyncToGenerator(function* () {
637
- return _this2.model.seekRow(startRow, column, valueType, value, insensitive, contains, isBackwards);
638
- })();
639
- }
640
- get isSeekRowAvailable() {
641
- return this.model.isSeekRowAvailable;
642
- }
643
316
  }
644
317
  export default IrisGridProxyModel;
645
318
  //# sourceMappingURL=IrisGridProxyModel.js.map