@vuu-ui/vuu-data-local 0.13.7 → 0.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/cjs/index.js +1992 -6
  2. package/cjs/index.js.map +1 -1
  3. package/esm/index.js +1993 -3
  4. package/esm/index.js.map +1 -1
  5. package/package.json +7 -7
  6. package/cjs/array-data-source/aggregate-utils.js +0 -237
  7. package/cjs/array-data-source/aggregate-utils.js.map +0 -1
  8. package/cjs/array-data-source/array-data-source.js +0 -669
  9. package/cjs/array-data-source/array-data-source.js.map +0 -1
  10. package/cjs/array-data-source/array-data-utils.js +0 -52
  11. package/cjs/array-data-source/array-data-utils.js.map +0 -1
  12. package/cjs/array-data-source/group-utils.js +0 -181
  13. package/cjs/array-data-source/group-utils.js.map +0 -1
  14. package/cjs/array-data-source/sort-utils.js +0 -54
  15. package/cjs/array-data-source/sort-utils.js.map +0 -1
  16. package/cjs/json-data-source/JsonDataSource.js +0 -398
  17. package/cjs/json-data-source/JsonDataSource.js.map +0 -1
  18. package/cjs/tree-data-source/IconProvider.js +0 -31
  19. package/cjs/tree-data-source/IconProvider.js.map +0 -1
  20. package/cjs/tree-data-source/TreeDataSource.js +0 -421
  21. package/cjs/tree-data-source/TreeDataSource.js.map +0 -1
  22. package/esm/array-data-source/aggregate-utils.js +0 -235
  23. package/esm/array-data-source/aggregate-utils.js.map +0 -1
  24. package/esm/array-data-source/array-data-source.js +0 -667
  25. package/esm/array-data-source/array-data-source.js.map +0 -1
  26. package/esm/array-data-source/array-data-utils.js +0 -49
  27. package/esm/array-data-source/array-data-utils.js.map +0 -1
  28. package/esm/array-data-source/group-utils.js +0 -177
  29. package/esm/array-data-source/group-utils.js.map +0 -1
  30. package/esm/array-data-source/sort-utils.js +0 -52
  31. package/esm/array-data-source/sort-utils.js.map +0 -1
  32. package/esm/json-data-source/JsonDataSource.js +0 -396
  33. package/esm/json-data-source/JsonDataSource.js.map +0 -1
  34. package/esm/tree-data-source/IconProvider.js +0 -29
  35. package/esm/tree-data-source/IconProvider.js.map +0 -1
  36. package/esm/tree-data-source/TreeDataSource.js +0 -419
  37. package/esm/tree-data-source/TreeDataSource.js.map +0 -1
@@ -1,667 +0,0 @@
1
- import { parseFilter, filterPredicate } from '@vuu-ui/vuu-filter-parser';
2
- import { logger, EventEmitter, KeySet, NULL_RANGE, Range, uuid, buildColumnMap, selectionCount, withConfigDefaults, hasFilter, hasBaseFilter, combineFilters, hasSort, isGroupByChanged, hasGroupBy, isConfigChanged, rangeNewItems, getAddedItems, getMissingItems, isEditCellRequest, metadataKeys, vanillaConfig } from '@vuu-ui/vuu-utils';
3
- import { aggregateData } from './aggregate-utils.js';
4
- import { buildDataToClientMap, toClientRow } from './array-data-utils.js';
5
- import { expandGroup, collapseGroup, groupRows } from './group-utils.js';
6
- import { sortRows } from './sort-utils.js';
7
-
8
- var __defProp = Object.defineProperty;
9
- var __typeError = (msg) => {
10
- throw TypeError(msg);
11
- };
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
14
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
15
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
16
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
17
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
18
- var _columnMap, _data, _keys, _links, _range, _selectedRowsCount, _status, _title;
19
- const { debug, info } = logger("ArrayDataSource");
20
- const { KEY } = metadataKeys;
21
- const toDataSourceRow = (key) => (data, index) => {
22
- return [index, index, true, false, 1, 0, String(data[key]), 0, ...data];
23
- };
24
- const buildTableSchema = (columns, keyColumn) => {
25
- const schema = {
26
- columns: columns.map(({ name, serverDataType = "string" }) => ({
27
- name,
28
- serverDataType
29
- })),
30
- key: keyColumn ?? columns[0].name,
31
- table: { module: "", table: "Array" }
32
- };
33
- return schema;
34
- };
35
- class ArrayDataSource extends EventEmitter {
36
- constructor({
37
- aggregations,
38
- baseFilterSpec,
39
- // different from RemoteDataSource
40
- columnDescriptors,
41
- data,
42
- dataMap,
43
- filterSpec,
44
- groupBy,
45
- keyColumn,
46
- rangeChangeRowset = "delta",
47
- sort,
48
- title,
49
- viewport
50
- }) {
51
- super();
52
- __publicField(this, "clientCallback");
53
- __publicField(this, "columnDescriptors");
54
- /** sorted offsets of data within raw data, reflecting sort order
55
- * of columns specified by client.
56
- */
57
- __publicField(this, "dataIndices");
58
- /** Map reflecting positions of data items in raw data */
59
- __publicField(this, "dataMap");
60
- __publicField(this, "groupMap");
61
- /** the index of key field within raw data row */
62
- __publicField(this, "key");
63
- __publicField(this, "lastRangeServed", { from: 0, to: 0 });
64
- __publicField(this, "rangeChangeRowset");
65
- __publicField(this, "openTreeNodes", []);
66
- /** Map reflecting positions of columns in client data sent to user */
67
- __privateAdd(this, _columnMap);
68
- __publicField(this, "_config", vanillaConfig);
69
- __privateAdd(this, _data);
70
- __privateAdd(this, _keys, new KeySet(NULL_RANGE));
71
- __privateAdd(this, _links);
72
- __privateAdd(this, _range, Range(0, 0));
73
- __privateAdd(this, _selectedRowsCount, 0);
74
- __privateAdd(this, _status, "initialising");
75
- __privateAdd(this, _title);
76
- __publicField(this, "_menu");
77
- __publicField(this, "selectedRows", []);
78
- __publicField(this, "tableSchema");
79
- __publicField(this, "viewport");
80
- __publicField(this, "processedData");
81
- __publicField(this, "insert", (row) => {
82
- const dataSourceRow = toDataSourceRow(this.key)(row, this.size);
83
- __privateGet(this, _data).push(dataSourceRow);
84
- const { from, to } = __privateGet(this, _range);
85
- const [rowIdx] = dataSourceRow;
86
- if (rowIdx >= from && rowIdx < to) {
87
- this.sendRowsToClient();
88
- }
89
- });
90
- __publicField(this, "updateDataItem", (keyValue, columnName, value) => {
91
- this.validateDataValue(columnName, value);
92
- const colIndex = __privateGet(this, _columnMap)[columnName];
93
- const dataColIndex = this.dataMap?.[columnName];
94
- const dataIndex = this.indexOfRowWithKey(keyValue);
95
- if (dataIndex !== -1 && dataColIndex !== void 0) {
96
- const dataSourceRow = __privateGet(this, _data)[dataIndex];
97
- dataSourceRow[colIndex] = value;
98
- const { from, to } = __privateGet(this, _range);
99
- const [rowIdx] = dataSourceRow;
100
- if (rowIdx >= from && rowIdx < to) {
101
- this.sendRowsToClient(false, dataSourceRow);
102
- }
103
- }
104
- });
105
- __publicField(this, "indexOfRowWithKey", (key) => __privateGet(this, _data).findIndex((row) => row[KEY] === key));
106
- __publicField(this, "update", (row, columnName) => {
107
- const keyValue = row[this.key];
108
- const dataColIndex = this.dataMap?.[columnName];
109
- return this.updateDataItem(keyValue, columnName, row[dataColIndex]);
110
- });
111
- __publicField(this, "updateRow", (row) => {
112
- const keyValue = row[this.key];
113
- const dataIndex = __privateGet(this, _data).findIndex((row2) => row2[KEY] === keyValue);
114
- if (dataIndex !== -1) {
115
- const dataSourceRow = toDataSourceRow(this.key)(row, dataIndex);
116
- __privateGet(this, _data)[dataIndex] = dataSourceRow;
117
- const { from, to } = __privateGet(this, _range);
118
- if (dataIndex >= from && dataIndex < to) {
119
- this.sendRowsToClient(false, dataSourceRow);
120
- }
121
- }
122
- });
123
- if (!data || !columnDescriptors) {
124
- throw Error(
125
- "ArrayDataSource constructor called without data or without columnDescriptors"
126
- );
127
- }
128
- this.columnDescriptors = columnDescriptors;
129
- this.dataMap = dataMap;
130
- this.key = keyColumn ? this.columnDescriptors.findIndex((col) => col.name === keyColumn) : 0;
131
- this.rangeChangeRowset = rangeChangeRowset;
132
- this.tableSchema = buildTableSchema(columnDescriptors, keyColumn);
133
- this.viewport = viewport || uuid();
134
- __privateSet(this, _title, title);
135
- const columns = columnDescriptors.map((col) => col.name);
136
- __privateSet(this, _columnMap, buildColumnMap(columns));
137
- this.dataIndices = buildDataToClientMap(__privateGet(this, _columnMap), this.dataMap);
138
- __privateSet(this, _data, data.map(toDataSourceRow(this.key)));
139
- this.config = {
140
- ...this._config,
141
- aggregations: aggregations || this._config.aggregations,
142
- baseFilterSpec,
143
- columns,
144
- filterSpec: filterSpec || this._config.filterSpec,
145
- groupBy: groupBy || this._config.groupBy,
146
- sort: sort || this._config.sort
147
- };
148
- debug?.(`columnMap: ${JSON.stringify(__privateGet(this, _columnMap))}`);
149
- }
150
- async subscribe({
151
- viewport = this.viewport ?? (this.viewport = uuid()),
152
- columns,
153
- aggregations,
154
- baseFilterSpec,
155
- range,
156
- selectedIndexValues,
157
- selectedKeyValues,
158
- sort,
159
- groupBy,
160
- filterSpec
161
- }, callback) {
162
- console.log(`%cArrayDataSource subscribe`, "color: red;font-weight:bold;");
163
- this.clientCallback = callback;
164
- this.viewport = viewport;
165
- __privateSet(this, _status, "subscribed");
166
- this.selectedRows = selectedIndexValues ?? this.convertKeysToIndexValues(selectedKeyValues) ?? [];
167
- __privateSet(this, _selectedRowsCount, selectionCount(this.selectedRows));
168
- this.lastRangeServed = { from: 0, to: 0 };
169
- let config = this._config;
170
- const hasConfigProps = aggregations || columns || filterSpec || groupBy || sort;
171
- if (hasConfigProps) {
172
- if (range) {
173
- this.setRange(range);
174
- }
175
- config = {
176
- ...config,
177
- aggregations: aggregations || this._config.aggregations,
178
- baseFilterSpec: baseFilterSpec || this._config.baseFilterSpec,
179
- columns: columns || this._config.columns,
180
- filterSpec: filterSpec || this._config.filterSpec,
181
- groupBy: groupBy || this._config.groupBy,
182
- sort: sort || this._config.sort
183
- };
184
- }
185
- const subscribedMessage = {
186
- ...config,
187
- type: "subscribed",
188
- clientViewportId: this.viewport,
189
- range: __privateGet(this, _range),
190
- tableSchema: this.tableSchema
191
- };
192
- this.clientCallback?.(subscribedMessage);
193
- this.emit("subscribed", subscribedMessage);
194
- if (hasConfigProps) {
195
- this.config = config;
196
- } else {
197
- this.clientCallback({
198
- clientViewportId: this.viewport,
199
- mode: "size-only",
200
- type: "viewport-update",
201
- size: __privateGet(this, _data).length
202
- });
203
- if (range && !__privateGet(this, _range).equals(range)) {
204
- this.range = range;
205
- } else if (__privateGet(this, _range) !== NULL_RANGE) {
206
- this.sendRowsToClient();
207
- }
208
- if (this.range.to !== 0) {
209
- const pageCount = Math.ceil(
210
- this.size / (this.range.to - this.range.from)
211
- );
212
- this.emit("page-count", pageCount);
213
- }
214
- }
215
- }
216
- unsubscribe() {
217
- __privateSet(this, _status, "unsubscribed");
218
- this.emit("unsubscribed", this.viewport);
219
- }
220
- suspend() {
221
- if (__privateGet(this, _status) !== "unsubscribed") {
222
- info?.(`suspend #${this.viewport}, current status ${__privateGet(this, _status)}`);
223
- __privateSet(this, _status, "suspended");
224
- this.emit("suspended", this.viewport);
225
- }
226
- }
227
- resume(callback) {
228
- const isSuspended = __privateGet(this, _status) === "suspended";
229
- info?.(`resume #${this.viewport}, current status ${__privateGet(this, _status)}`);
230
- if (callback) {
231
- this.clientCallback = callback;
232
- }
233
- if (isSuspended) {
234
- __privateSet(this, _status, "subscribed");
235
- }
236
- this.emit("resumed", this.viewport);
237
- this.sendRowsToClient(true);
238
- }
239
- disable() {
240
- this.emit("disabled", this.viewport);
241
- }
242
- enable() {
243
- this.emit("enabled", this.viewport);
244
- }
245
- select(selected) {
246
- __privateSet(this, _selectedRowsCount, selectionCount(selected));
247
- debug?.(`select ${JSON.stringify(selected)}`);
248
- this.selectedRows = selected;
249
- this.setRange(__privateGet(this, _range), true);
250
- this.emit("row-selection", selected, __privateGet(this, _selectedRowsCount));
251
- }
252
- getRowKey(keyOrIndex) {
253
- if (typeof keyOrIndex === "string") {
254
- return keyOrIndex;
255
- }
256
- const row = this.getRowAtIndex(keyOrIndex);
257
- if (row === void 0) {
258
- throw Error(`row not found at index ${keyOrIndex}`);
259
- }
260
- return row?.[KEY];
261
- }
262
- openTreeNode(keyOrIndex) {
263
- const key = this.getRowKey(keyOrIndex);
264
- this.openTreeNodes.push(key);
265
- this.processedData = expandGroup(
266
- this.openTreeNodes,
267
- __privateGet(this, _data),
268
- this._config.groupBy,
269
- __privateGet(this, _columnMap),
270
- this.groupMap,
271
- this.processedData
272
- );
273
- this.setRange(__privateGet(this, _range).reset, true);
274
- }
275
- closeTreeNode(keyOrIndex) {
276
- const key = this.getRowKey(keyOrIndex);
277
- this.openTreeNodes = this.openTreeNodes.filter((value) => value !== key);
278
- if (this.processedData) {
279
- this.processedData = collapseGroup(key, this.processedData);
280
- this.setRange(__privateGet(this, _range).reset, true);
281
- }
282
- }
283
- get pageSize() {
284
- return __privateGet(this, _range).to - __privateGet(this, _range).from;
285
- }
286
- get links() {
287
- return __privateGet(this, _links);
288
- }
289
- set links(links) {
290
- __privateSet(this, _links, links);
291
- }
292
- get menu() {
293
- return this._menu;
294
- }
295
- get status() {
296
- return __privateGet(this, _status);
297
- }
298
- get data() {
299
- return __privateGet(this, _data);
300
- }
301
- // Only used by the UpdateGenerator
302
- get currentData() {
303
- return this.processedData ?? __privateGet(this, _data);
304
- }
305
- get table() {
306
- return this.tableSchema.table;
307
- }
308
- get config() {
309
- return this._config;
310
- }
311
- set config(config) {
312
- const configChanges = this.applyConfig(config);
313
- if (configChanges) {
314
- if (config) {
315
- const originalConfig = this._config;
316
- const newConfig = config?.filterSpec?.filter && config?.filterSpec.filterStruct === void 0 ? {
317
- ...config,
318
- filterSpec: {
319
- filter: config.filterSpec.filter,
320
- filterStruct: parseFilter(config.filterSpec.filter)
321
- }
322
- } : config;
323
- this._config = withConfigDefaults(newConfig);
324
- let processedData;
325
- if (hasFilter(config) || hasBaseFilter(config)) {
326
- const {
327
- filterSpec: { filterStruct }
328
- } = combineFilters(this._config);
329
- if (filterStruct) {
330
- const fn = filterPredicate(__privateGet(this, _columnMap), filterStruct);
331
- processedData = __privateGet(this, _data).filter(fn);
332
- } else {
333
- throw Error("filter must include filterStruct");
334
- }
335
- }
336
- if (hasSort(config)) {
337
- processedData = sortRows(
338
- processedData ?? __privateGet(this, _data),
339
- config.sort,
340
- __privateGet(this, _columnMap)
341
- );
342
- }
343
- if (this.openTreeNodes.length > 0 && isGroupByChanged(originalConfig, config)) {
344
- if (this._config.groupBy.length === 0) {
345
- this.openTreeNodes.length = 0;
346
- }
347
- }
348
- if (hasGroupBy(config)) {
349
- const [groupedData, groupMap] = groupRows(
350
- processedData ?? __privateGet(this, _data),
351
- config.groupBy,
352
- __privateGet(this, _columnMap)
353
- );
354
- this.groupMap = groupMap;
355
- processedData = groupedData;
356
- if (this.openTreeNodes.length > 0) {
357
- processedData = expandGroup(
358
- this.openTreeNodes,
359
- __privateGet(this, _data),
360
- this._config.groupBy,
361
- __privateGet(this, _columnMap),
362
- this.groupMap,
363
- processedData
364
- );
365
- }
366
- }
367
- this.processedData = processedData?.map((row, i) => {
368
- const dolly = row.slice();
369
- dolly[0] = i;
370
- dolly[1] = i;
371
- return dolly;
372
- });
373
- }
374
- if (__privateGet(this, _status) === "subscribed") {
375
- this.setRange(__privateGet(this, _range).reset, true);
376
- this.emit("config", this._config, this.range, void 0, configChanges);
377
- }
378
- }
379
- }
380
- applyConfig(config, preserveExistingConfigAttributes = false) {
381
- const { noChanges, ...otherChanges } = isConfigChanged(
382
- this._config,
383
- config
384
- );
385
- if (noChanges !== true) {
386
- if (config) {
387
- const newConfig = config?.filterSpec?.filter && config?.filterSpec.filterStruct === void 0 ? {
388
- ...config,
389
- filterSpec: {
390
- filter: config.filterSpec.filter,
391
- filterStruct: parseFilter(config.filterSpec.filter)
392
- }
393
- } : config;
394
- if (preserveExistingConfigAttributes) {
395
- this._config = {
396
- ...this._config,
397
- ...config
398
- };
399
- } else {
400
- this._config = withConfigDefaults(newConfig);
401
- }
402
- return otherChanges;
403
- }
404
- }
405
- }
406
- get columnMap() {
407
- return __privateGet(this, _columnMap);
408
- }
409
- get selectedRowsCount() {
410
- return __privateGet(this, _selectedRowsCount);
411
- }
412
- get size() {
413
- return this.processedData?.length ?? __privateGet(this, _data).length;
414
- }
415
- get range() {
416
- return __privateGet(this, _range);
417
- }
418
- set range(range) {
419
- this.setRange(range);
420
- }
421
- getRowAtIndex(rowIndex) {
422
- return this.processedData?.[rowIndex];
423
- }
424
- delete(row) {
425
- console.log(`delete row ${row.join(",")}`);
426
- }
427
- validateDataValue(columnName, value) {
428
- const columnDescriptor = this.columnDescriptors.find(
429
- (col) => col.name === columnName
430
- );
431
- if (columnDescriptor) {
432
- switch (columnDescriptor.serverDataType) {
433
- case "int":
434
- {
435
- if (typeof value === "number") {
436
- if (Math.floor(value) !== value) {
437
- throw Error(`${columnName} is int but value = ${value}`);
438
- }
439
- } else if (typeof value === "string") {
440
- const numericValue = parseFloat(value);
441
- if (Math.floor(numericValue) !== numericValue) {
442
- throw Error(`${columnName} is ${value} is not a valid integer`);
443
- }
444
- }
445
- }
446
- break;
447
- }
448
- } else {
449
- throw Error(`Unknown column ${columnName}`);
450
- }
451
- }
452
- setRange(range, forceFullRefresh = false) {
453
- if (range.from !== __privateGet(this, _range).from || range.to !== __privateGet(this, _range).to) {
454
- const currentPageCount = Math.ceil(
455
- this.size / (__privateGet(this, _range).to - __privateGet(this, _range).from)
456
- );
457
- const newPageCount = Math.ceil(this.size / (range.to - range.from));
458
- __privateSet(this, _range, range);
459
- const keysResequenced = __privateGet(this, _keys).reset(range);
460
- this.sendRowsToClient(forceFullRefresh || keysResequenced);
461
- requestAnimationFrame(() => {
462
- if (newPageCount !== currentPageCount) {
463
- this.emit("page-count", newPageCount);
464
- }
465
- this.emit("range", range);
466
- });
467
- } else if (forceFullRefresh) {
468
- this.sendRowsToClient(forceFullRefresh);
469
- }
470
- }
471
- sendRowsToClient(forceFullRefresh = false, row) {
472
- if (row) {
473
- this.clientCallback?.({
474
- clientViewportId: this.viewport,
475
- mode: "update",
476
- rows: [
477
- toClientRow(row, __privateGet(this, _keys), this.selectedRows, this.dataIndices)
478
- ],
479
- type: "viewport-update"
480
- });
481
- } else {
482
- const rowRange = this.rangeChangeRowset === "delta" && !forceFullRefresh ? rangeNewItems(this.lastRangeServed, __privateGet(this, _range)) : __privateGet(this, _range);
483
- const data = this.processedData ?? __privateGet(this, _data);
484
- const rowsWithinViewport = data.slice(rowRange.from, rowRange.to).map(
485
- (row2) => toClientRow(row2, __privateGet(this, _keys), this.selectedRows, this.dataIndices)
486
- );
487
- this.clientCallback?.({
488
- clientViewportId: this.viewport,
489
- mode: "batch",
490
- range: __privateGet(this, _range),
491
- rows: rowsWithinViewport,
492
- size: data.length,
493
- type: "viewport-update"
494
- });
495
- this.lastRangeServed = {
496
- from: __privateGet(this, _range).from,
497
- to: __privateGet(this, _range).to
498
- // to: Math.min(
499
- // this.#range.to,
500
- // this.#range.from + rowsWithinViewport.length,
501
- // ),
502
- };
503
- }
504
- }
505
- get columns() {
506
- return this._config.columns;
507
- }
508
- set columns(columns) {
509
- const addedColumns = getAddedItems(this.config.columns, columns);
510
- if (addedColumns.length > 0) {
511
- const columnsWithoutDescriptors = getMissingItems(
512
- this.columnDescriptors,
513
- addedColumns,
514
- (col) => col.name
515
- );
516
- console.log(`columnsWithoutDescriptors`, {
517
- columnsWithoutDescriptors
518
- });
519
- }
520
- __privateSet(this, _columnMap, buildColumnMap(columns));
521
- this.dataIndices = buildDataToClientMap(__privateGet(this, _columnMap), this.dataMap);
522
- this.config = {
523
- ...this._config,
524
- columns
525
- };
526
- }
527
- get aggregations() {
528
- return this._config.aggregations;
529
- }
530
- set aggregations(aggregations) {
531
- this._config = {
532
- ...this._config,
533
- aggregations
534
- };
535
- const targetData = this.processedData ?? __privateGet(this, _data);
536
- const leafData = __privateGet(this, _data);
537
- aggregateData(
538
- aggregations,
539
- targetData,
540
- this._config.groupBy,
541
- leafData,
542
- __privateGet(this, _columnMap),
543
- this.groupMap
544
- );
545
- this.setRange(__privateGet(this, _range).reset, true);
546
- this.emit("config", this._config, this.range);
547
- }
548
- get sort() {
549
- return this._config.sort;
550
- }
551
- set sort(sort) {
552
- debug?.(`sort ${JSON.stringify(sort)}`);
553
- this.config = {
554
- ...this._config,
555
- sort
556
- };
557
- }
558
- get baseFilter() {
559
- return this._config.baseFilterSpec;
560
- }
561
- set baseFilter(baseFilter) {
562
- debug?.(`baseFilter ${JSON.stringify(baseFilter)}`);
563
- this.config = {
564
- ...this._config,
565
- baseFilterSpec: baseFilter
566
- };
567
- }
568
- get filter() {
569
- return this._config.filterSpec;
570
- }
571
- set filter(filter) {
572
- debug?.(`filter ${JSON.stringify(filter)}`);
573
- this.config = {
574
- ...this._config,
575
- filterSpec: filter
576
- };
577
- }
578
- get groupBy() {
579
- return this._config.groupBy;
580
- }
581
- set groupBy(groupBy) {
582
- this.config = {
583
- ...this._config,
584
- groupBy
585
- };
586
- }
587
- get title() {
588
- return __privateGet(this, _title) ?? `${this.table.module} ${this.table.table}`;
589
- }
590
- set title(title) {
591
- __privateSet(this, _title, title);
592
- this.emit("title-changed", this.viewport, title);
593
- }
594
- get _clientCallback() {
595
- return this.clientCallback;
596
- }
597
- createLink({
598
- parentVpId,
599
- link: { fromColumn, toColumn }
600
- }) {
601
- console.log("create link", {
602
- parentVpId,
603
- fromColumn,
604
- toColumn
605
- });
606
- }
607
- removeLink() {
608
- console.log("remove link");
609
- }
610
- applyEdit(rowKey, columnName, value) {
611
- console.log(`ArrayDataSource applyEdit ${rowKey} ${columnName} ${value}`);
612
- return Promise.resolve(true);
613
- }
614
- async remoteProcedureCall() {
615
- return Promise.reject();
616
- }
617
- async menuRpcCall(rpcRequest) {
618
- return new Promise((resolve) => {
619
- if (isEditCellRequest(rpcRequest)) {
620
- const { rowKey, field, value } = rpcRequest;
621
- try {
622
- this.updateDataItem(rowKey, field, value);
623
- resolve({
624
- action: {
625
- type: "VP_EDIT_SUCCESS"
626
- },
627
- rpcName: "VP_EDIT_CELL_RPC",
628
- type: "VIEW_PORT_MENU_RESP",
629
- vpId: this.viewport
630
- });
631
- } catch (error) {
632
- resolve({
633
- error: String(error),
634
- rpcName: "VP_EDIT_CELL_RPC",
635
- type: "VIEW_PORT_MENU_REJ",
636
- vpId: this.viewport
637
- });
638
- }
639
- } else {
640
- throw Error("menuRpcCall invalid rpcRequest");
641
- }
642
- });
643
- }
644
- convertKeysToIndexValues(keys) {
645
- if (Array.isArray(keys)) {
646
- const indexValues = [];
647
- keys.forEach((key) => {
648
- const rowIdx = this.indexOfRowWithKey(key);
649
- if (rowIdx !== -1) {
650
- indexValues.push(rowIdx);
651
- }
652
- });
653
- return indexValues;
654
- }
655
- }
656
- }
657
- _columnMap = new WeakMap();
658
- _data = new WeakMap();
659
- _keys = new WeakMap();
660
- _links = new WeakMap();
661
- _range = new WeakMap();
662
- _selectedRowsCount = new WeakMap();
663
- _status = new WeakMap();
664
- _title = new WeakMap();
665
-
666
- export { ArrayDataSource };
667
- //# sourceMappingURL=array-data-source.js.map