@vuu-ui/vuu-data-local 4.1.0 → 5.0.0-alpha.1

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.
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
- "version": "4.1.0",
2
+ "version": "5.0.0-alpha.1",
3
3
  "main": "./src/index.js",
4
4
  "author": "heswell",
5
+ "type": "module",
5
6
  "license": "Apache-2.0",
6
7
  "scripts": {
7
- "build:dev": "node ../../scripts/run-build.mjs",
8
8
  "build": "node ../../scripts/run-build-rslib.ts",
9
9
  "test": "vitest run",
10
10
  "type-defs": "node ../../scripts/build-type-defs.mjs"
11
11
  },
12
12
  "devDependencies": {
13
- "@vuu-ui/vuu-data-types": "4.1.0",
14
- "@vuu-ui/vuu-table-types": "4.1.0",
15
- "@vuu-ui/vuu-filter-types": "4.1.0",
16
- "@vuu-ui/vuu-protocol-types": "4.1.0"
13
+ "@vuu-ui/vuu-data-types": "5.0.0-alpha.1",
14
+ "@vuu-ui/vuu-table-types": "5.0.0-alpha.1",
15
+ "@vuu-ui/vuu-filter-types": "5.0.0-alpha.1",
16
+ "@vuu-ui/vuu-protocol-types": "5.0.0-alpha.1"
17
17
  },
18
18
  "dependencies": {
19
- "@vuu-ui/vuu-filter-parser": "4.1.0",
20
- "@vuu-ui/vuu-utils": "4.1.0"
19
+ "@vuu-ui/vuu-filter-parser": "5.0.0-alpha.1",
20
+ "@vuu-ui/vuu-utils": "5.0.0-alpha.1"
21
21
  },
22
22
  "sideEffects": false,
23
23
  "files": [
@@ -27,13 +27,12 @@
27
27
  ],
28
28
  "exports": {
29
29
  ".": {
30
+ "types": "./types/index.d.ts",
30
31
  "import": "./src/index.js",
31
- "default": "./src/index.js",
32
- "types": "./types/index.d.ts"
32
+ "default": "./src/index.js"
33
33
  }
34
34
  },
35
35
  "module": "./src/index.js",
36
36
  "name": "@vuu-ui/vuu-data-local",
37
- "type": "module",
38
37
  "types": "types/index.d.ts"
39
38
  }
@@ -71,7 +71,7 @@ class ArrayDataSource extends EventEmitter {
71
71
  this.columnDescriptors = columnDescriptors;
72
72
  this.#filterColumnsByName = getColumnsByName(columnDescriptors);
73
73
  this.dataMap = dataMap;
74
- this.key = keyColumn ? this.columnDescriptors.findIndex((col)=>col.name === keyColumn) : 0;
74
+ this.key = keyColumn ? dataMap?.[keyColumn] ?? this.columnDescriptors.findIndex((col)=>col.name === keyColumn) : 0;
75
75
  this.rangeChangeRowset = rangeChangeRowset;
76
76
  this.tableSchema = buildTableSchema(columnDescriptors, keyColumn);
77
77
  this.viewport = viewport || uuid();
@@ -120,8 +120,15 @@ class ArrayDataSource extends EventEmitter {
120
120
  };
121
121
  this.clientCallback?.(subscribedMessage);
122
122
  this.emit("subscribed", subscribedMessage);
123
- if (hasConfigProps) this.config = config;
124
- else {
123
+ if (hasConfigProps) {
124
+ if (range) {
125
+ this.constrainRangeToMaxRangeEnd(range);
126
+ this.#range = range;
127
+ this.#keys.reset(this.rangeWithBufferWithinMaxRangeEnd);
128
+ }
129
+ this.config = config;
130
+ this.sendRowsToClient(true);
131
+ } else {
125
132
  this.sendSizeUpdateToClient();
126
133
  this.emit("resize", this.processedData ? this.processedData.length : this.#data.length, this.#maxRangeEnd);
127
134
  if (range && !this.#range.equals(range)) this.range = range;
@@ -452,17 +459,17 @@ class ArrayDataSource extends EventEmitter {
452
459
  }
453
460
  indexOfRowWithKey = (key)=>this.#data.findIndex((row)=>row[KEY] === key);
454
461
  update = (row, columnName)=>{
455
- const keyValue = row[this.key];
462
+ const keyValue = String(row[this.key]);
456
463
  const dataColIndex = this.dataMap?.[columnName];
457
464
  return this.updateDataItem(keyValue, columnName, row[dataColIndex]);
458
465
  };
459
466
  updateRow = (row, _columnName)=>{
460
- const keyValue = row[this.key];
467
+ const keyValue = String(row[this.key]);
461
468
  const dataIndex = this.#data.findIndex((row)=>row[KEY] === keyValue);
462
469
  if (-1 !== dataIndex) {
463
470
  const dataSourceRow = toDataSourceRow(this.key)(row, dataIndex);
464
471
  this.#data[dataIndex] = dataSourceRow;
465
- const { from, to } = this.#range;
472
+ const { from, to } = this.rangeWithBufferWithinMaxRangeEnd;
466
473
  const isFiltered = hasFilter(this.config) || hasBaseFilter(this.config);
467
474
  const isSorted = hasSort(this.config);
468
475
  if (isFiltered) {
@@ -1,4 +1,4 @@
1
- import { BaseDataSource, KeySet, NULL_RANGE, getParentRow, isSingleValueFilter, lastPathSegment, metadataKeys, missingAncestor, treeToDataSourceRows, uuid } from "@vuu-ui/vuu-utils";
1
+ import { BaseDataSource, KeySet, NULL_RANGE, getParentRow, isSingleValueFilter, lastPathSegment, metadataKeys, treeToDataSourceRows, uuid } from "@vuu-ui/vuu-utils";
2
2
  import { IconProvider } from "./IconProvider.js";
3
3
  import { parseFilter } from "@vuu-ui/vuu-filter-parser";
4
4
  const treeSchema = (columns)=>({
@@ -32,6 +32,7 @@ class TreeDataSource extends BaseDataSource {
32
32
  #size = 0;
33
33
  #status = "initialising";
34
34
  #filterSet;
35
+ #filterCollapsedRows = new Set();
35
36
  rowCount;
36
37
  keys = new KeySet(this._range);
37
38
  constructor({ data, ...props }){
@@ -40,7 +41,6 @@ class TreeDataSource extends BaseDataSource {
40
41
  this.#iconProvider = new IconProvider();
41
42
  [this.columnDescriptors, this.#data] = treeToDataSourceRows(data, this.#iconProvider);
42
43
  this.expandedRows = getInitiallyExpandedKeys(data);
43
- console.table(this.#data);
44
44
  if (this.columnDescriptors) {
45
45
  const columns = this.columnDescriptors.map((c)=>c.name);
46
46
  this._configWithVisualLink = {
@@ -62,7 +62,7 @@ class TreeDataSource extends BaseDataSource {
62
62
  this.#status = "subscribed";
63
63
  this.#selectedRowsCount = selectedKeyValues?.length ?? 0;
64
64
  if (selectedKeyValues) this.applySelectedKeyValues(selectedKeyValues, revealSelected);
65
- [this.visibleRows, this.visibleRowIndex] = getVisibleRows(this.#data, this.expandedRows);
65
+ this.computeVisibleRows();
66
66
  this.clientCallback?.({
67
67
  aggregations: this.#aggregations,
68
68
  type: "subscribed",
@@ -72,7 +72,7 @@ class TreeDataSource extends BaseDataSource {
72
72
  groupBy: this._configWithVisualLink.groupBy,
73
73
  range: this.range,
74
74
  sort: this.sort,
75
- tableSchema: treeSchema(this.columnDescriptors)
75
+ tableSchema: this.tableSchema
76
76
  });
77
77
  this.clientCallback({
78
78
  clientViewportId: this.viewport,
@@ -118,7 +118,32 @@ class TreeDataSource extends BaseDataSource {
118
118
  };
119
119
  if (filter.filter) this.applyFilter(filter);
120
120
  else this.#filterSet = void 0;
121
- [this.visibleRows, this.visibleRowIndex] = getVisibleRows(this.#data, this.expandedRows, this.#filterSet);
121
+ this.refreshVisibleRows();
122
+ }
123
+ filterNodes(predicate) {
124
+ if (predicate) {
125
+ const filterSet = [];
126
+ const { count: nodeDataIndex } = metadataKeys;
127
+ for (const row of this.#data){
128
+ const { [DEPTH]: depth, [KEY]: key, [IDX]: idx } = row;
129
+ const label = row[nodeDataIndex + depth];
130
+ if (predicate({
131
+ depth,
132
+ key,
133
+ label: "string" == typeof label ? label : "",
134
+ nodeData: row[nodeDataIndex]
135
+ })) filterSet.push(idx);
136
+ }
137
+ this.#filterSet = filterSet;
138
+ } else this.#filterSet = void 0;
139
+ this.refreshVisibleRows();
140
+ }
141
+ computeVisibleRows() {
142
+ [this.visibleRows, this.visibleRowIndex] = getVisibleRows(this.#data, this.expandedRows, this.#filterSet, this.#filterCollapsedRows);
143
+ }
144
+ refreshVisibleRows() {
145
+ this.#filterCollapsedRows.clear();
146
+ this.computeVisibleRows();
122
147
  const { from, to } = this.range;
123
148
  this.clientCallback?.({
124
149
  clientViewportId: this.viewport,
@@ -134,8 +159,9 @@ class TreeDataSource extends BaseDataSource {
134
159
  const filterSet = [];
135
160
  const regex = new RegExp(`${filter.value}`, "i");
136
161
  for (const row of this.#data){
137
- const { [KEY]: key, [IDX]: idx } = row;
138
- if (regex.test(lastPathSegment(key, "|"))) filterSet.push(idx);
162
+ const { [DEPTH]: depth, [KEY]: key, [IDX]: idx } = row;
163
+ const label = row[metadataKeys.count + depth];
164
+ if (regex.test(lastPathSegment(key, "|")) || "string" == typeof label && regex.test(label)) filterSet.push(idx);
139
165
  }
140
166
  this.#filterSet = filterSet;
141
167
  }
@@ -198,8 +224,9 @@ class TreeDataSource extends BaseDataSource {
198
224
  }
199
225
  openTreeNode(keyOrIndex) {
200
226
  const key = this.getRowKey(keyOrIndex);
201
- this.expandedRows.add(key);
202
- [this.visibleRows, this.visibleRowIndex] = getVisibleRows(this.#data, this.expandedRows);
227
+ if (this.#filterSet) this.#filterCollapsedRows.delete(key);
228
+ else this.expandedRows.add(key);
229
+ this.computeVisibleRows();
203
230
  const { from, to } = this._range;
204
231
  this.clientCallback?.({
205
232
  clientViewportId: this.viewport,
@@ -211,13 +238,19 @@ class TreeDataSource extends BaseDataSource {
211
238
  }
212
239
  closeTreeNode(keyOrIndex, cascade = false) {
213
240
  const key = this.getRowKey(keyOrIndex);
214
- this.expandedRows.delete(key);
215
- if (cascade) {
216
- for (const rowKey of this.expandedRows.keys())if (rowKey.startsWith(key)) this.expandedRows.delete(rowKey);
241
+ if (this.#filterSet) this.#filterCollapsedRows.add(key);
242
+ else {
243
+ this.expandedRows.delete(key);
244
+ if (cascade) {
245
+ for (const rowKey of this.expandedRows.keys())if (rowKey.startsWith(key)) this.expandedRows.delete(rowKey);
246
+ }
217
247
  }
218
- [this.visibleRows, this.visibleRowIndex] = getVisibleRows(this.#data, this.expandedRows);
248
+ this.computeVisibleRows();
219
249
  this.sendRowsToClient();
220
250
  }
251
+ get tableSchema() {
252
+ return treeSchema(this.columnDescriptors);
253
+ }
221
254
  get status() {
222
255
  return this.#status;
223
256
  }
@@ -287,44 +320,45 @@ class TreeDataSource extends BaseDataSource {
287
320
  }
288
321
  }
289
322
  const getInitiallyExpandedKeys = (treeSourceNodes, keyBase = "$root", expandedKeys = new Set())=>{
290
- for (const { childNodes, expanded, label } of treeSourceNodes){
291
- const key = `${keyBase}|${label}`;
323
+ for (const { childNodes, expanded, keySegment, label } of treeSourceNodes){
324
+ const key = `${keyBase}|${keySegment ?? label}`;
292
325
  if (expanded) expandedKeys.add(key);
293
326
  if (childNodes) getInitiallyExpandedKeys(childNodes, key, expandedKeys);
294
327
  }
295
328
  return expandedKeys;
296
329
  };
297
- function getVisibleRows(rows, expandedKeys, filterset) {
330
+ function getVisibleRows(rows, expandedKeys, filterset, filterCollapsedKeys) {
298
331
  const visibleRows = [];
299
332
  const visibleRowIndex = {};
300
- const data = filterset ?? rows;
301
- for(let i = 0, index = 0; i < data.length; i++){
302
- const idx = filterset ? filterset[i] : i;
303
- const row = rows[idx];
304
- const { [COUNT]: count, [DEPTH]: depth, [KEY]: key, [IS_LEAF]: isLeaf } = row;
305
- if (filterset) {
306
- const previousRow = visibleRows.at(-1);
307
- if (missingAncestor(row, previousRow)) {
308
- let currentRow = row;
309
- const missingRows = [];
310
- while(currentRow){
311
- currentRow = getParentRow(rows, currentRow);
312
- if (currentRow) missingRows.unshift(currentRow);
313
- }
314
- missingRows.forEach((row)=>{
315
- visibleRows.push(cloneRow(row, index++, true));
316
- });
333
+ if (filterset) {
334
+ const included = new Set();
335
+ for (const idx of filterset){
336
+ let row = rows[idx];
337
+ while(row && !included.has(row[IDX])){
338
+ included.add(row[IDX]);
339
+ row = getParentRow(rows, row);
317
340
  }
318
- visibleRows.push(cloneRow(row, index++, true));
341
+ }
342
+ let collapsedKey;
343
+ for(let i = 0, index = 0; i < rows.length; i++){
344
+ const row = rows[i];
345
+ const { [COUNT]: count, [KEY]: key } = row;
346
+ if (!included.has(row[IDX])) continue;
347
+ if (void 0 !== collapsedKey && key.startsWith(`${collapsedKey}|`)) continue;
348
+ const isCollapsed = filterCollapsedKeys?.has(key) ?? false;
349
+ collapsedKey = isCollapsed ? key : void 0;
319
350
  visibleRowIndex[index] = i;
320
- } else {
321
- const isExpanded = expandedKeys.has(key);
322
- visibleRows.push(cloneRow(row, index, isExpanded));
323
- visibleRowIndex[index++] = i;
324
- const skipNonVisibleRows = !isLeaf && !isExpanded && count > 0;
325
- if (skipNonVisibleRows) do i += 1;
326
- while (i < rows.length - 1 && rows[i + 1][DEPTH] > depth)
351
+ visibleRows.push(cloneRow(row, index++, count > 0 && !isCollapsed));
327
352
  }
353
+ } else for(let i = 0, index = 0; i < rows.length; i++){
354
+ const row = rows[i];
355
+ const { [COUNT]: count, [DEPTH]: depth, [KEY]: key, [IS_LEAF]: isLeaf } = row;
356
+ const isExpanded = expandedKeys.has(key);
357
+ visibleRows.push(cloneRow(row, index, isExpanded));
358
+ visibleRowIndex[index++] = i;
359
+ const skipNonVisibleRows = !isLeaf && !isExpanded && count > 0;
360
+ if (skipNonVisibleRows) do i += 1;
361
+ while (i < rows.length - 1 && rows[i + 1][DEPTH] > depth)
328
362
  }
329
363
  return [
330
364
  visibleRows,
@@ -1,6 +1,6 @@
1
1
  import type { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuGroupBy, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
- import { ColumnMap } from "@vuu-ui/vuu-utils";
3
+ import { type ColumnMap } from "@vuu-ui/vuu-utils";
4
4
  export type KeyList = number[];
5
5
  export type GroupMap = {
6
6
  [key: string]: GroupMap | KeyList;
@@ -1,6 +1,6 @@
1
1
  import type { DataSourceRowWithBigint } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuSort, VuuSortType } from "@vuu-ui/vuu-protocol-types";
3
- import { ColumnMap } from "@vuu-ui/vuu-utils";
3
+ import type { ColumnMap } from "@vuu-ui/vuu-utils";
4
4
  export type ColIndexSortDef = [number, VuuSortType];
5
5
  type SortCompareResult = 0 | 1 | -1;
6
6
  export type RowSortComparator = (item1: DataSourceRowWithBigint, item2: DataSourceRowWithBigint) => SortCompareResult;
@@ -1,7 +1,18 @@
1
1
  import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
2
  import type { LinkDescriptorWithLabel, VuuRange, VuuRpcResponse, VuuRpcRequest, SelectRequest } from "@vuu-ui/vuu-protocol-types";
3
- import type { DataSourceRow, DataSourceConstructorProps, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, MenuRpcResponse, DataSourceFilter, DataSourceBase } from "@vuu-ui/vuu-data-types";
4
- import { BaseDataSource, TreeSourceNode } from "@vuu-ui/vuu-utils";
3
+ import type { DataSourceRow, DataSourceConstructorProps, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, MenuRpcResponse, DataSourceFilter, TableSchema, DataSourceBase } from "@vuu-ui/vuu-data-types";
4
+ import { BaseDataSource, type TreeSourceNode } from "@vuu-ui/vuu-utils";
5
+ export interface TreeNodeFilterProps {
6
+ depth: number;
7
+ key: string;
8
+ label: string;
9
+ nodeData: unknown;
10
+ }
11
+ /**
12
+ * Tests a single tree node. Nodes that pass are displayed, along with all of
13
+ * their ancestors.
14
+ */
15
+ export type TreeNodeFilterPredicate = (node: TreeNodeFilterProps) => boolean;
5
16
  export interface TreeDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
6
17
  data: TreeSourceNode[];
7
18
  }
@@ -24,6 +35,13 @@ export declare class TreeDataSource extends BaseDataSource implements DataSource
24
35
  set data(data: TreeSourceNode[]);
25
36
  get filter(): DataSourceFilter;
26
37
  set filter(filter: DataSourceFilter);
38
+ /**
39
+ * An alternative to a filter expression, filters on any attribute of a
40
+ * tree node, including nodeData. Pass undefined to clear the filter.
41
+ */
42
+ filterNodes(predicate?: TreeNodeFilterPredicate): void;
43
+ private computeVisibleRows;
44
+ private refreshVisibleRows;
27
45
  private applyFilter;
28
46
  /**
29
47
  * used to apply an initial selection. These may not necessarily be
@@ -36,6 +54,7 @@ export declare class TreeDataSource extends BaseDataSource implements DataSource
36
54
  private getRowKey;
37
55
  openTreeNode(keyOrIndex: string | number): void;
38
56
  closeTreeNode(keyOrIndex: string | number, cascade?: boolean): void;
57
+ get tableSchema(): TableSchema;
39
58
  get status(): DataSourceStatus;
40
59
  get selectedRowsCount(): number;
41
60
  get size(): number;
@@ -1,8 +0,0 @@
1
- import type { DataSourceRowWithBigint } from "@vuu-ui/vuu-data-types";
2
- import type { VuuAggregation, VuuGroupBy } from "@vuu-ui/vuu-protocol-types";
3
- import type { ColumnMap } from "@vuu-ui/vuu-utils";
4
- import type { GroupMap } from "./group-utils";
5
- export declare const count: (arr: unknown[]) => number;
6
- export declare const aggregateData: (aggregations: VuuAggregation[], targetData: readonly DataSourceRowWithBigint[], groupBy: VuuGroupBy, leafData: readonly DataSourceRowWithBigint[], columnMap: ColumnMap, groupMap: GroupMap) => {
7
- [key: string]: number;
8
- };
@@ -1,111 +0,0 @@
1
- import type { DataSourceBase, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceRow, DataSourceRowWithBigint, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, TableSchema, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
2
- import type { Filter } from "@vuu-ui/vuu-filter-types";
3
- import type { LinkDescriptorWithLabel, SelectRequest, VuuAggregation, VuuGroupBy, VuuMenu, VuuRowDataItemType, VuuRpcRequest, VuuRpcResponse, VuuSort } from "@vuu-ui/vuu-protocol-types";
4
- import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
5
- import { type ColumnMap, EventEmitter, Range } from "@vuu-ui/vuu-utils";
6
- export interface ArrayDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
7
- columnDescriptors: readonly ColumnDescriptor[];
8
- data: Array<Array<bigint | VuuRowDataItemType>>;
9
- dataMap?: ColumnMap;
10
- keyColumn?: string;
11
- rangeChangeRowset?: "delta" | "full";
12
- }
13
- export declare class ArrayDataSource extends EventEmitter<DataSourceEvents> implements DataSourceBase<DataSourceRowWithBigint> {
14
- #private;
15
- protected clientCallback: DataSourceSubscribeCallback | undefined;
16
- protected columnDescriptors: readonly ColumnDescriptor[];
17
- /** sorted offsets of data within raw data, reflecting sort order
18
- * of columns specified by client.
19
- */
20
- private dataIndices;
21
- /** Map reflecting positions of data items in raw data */
22
- private dataMap;
23
- private groupMap;
24
- /** the index of key field within raw data row */
25
- private key;
26
- private lastRangeServed;
27
- private rangeChangeRowset;
28
- private openTreeNodes;
29
- private preserveScrollPositionAcrossConfigChange;
30
- protected _config: WithBaseFilter<WithFullConfig> & {
31
- visualLink?: LinkDescriptorWithLabel;
32
- };
33
- protected _menu: VuuMenu | undefined;
34
- protected selectedRows: Set<string>;
35
- protected index: Map<string, number>;
36
- tableSchema: TableSchema;
37
- viewport: string;
38
- protected processedData: DataSourceRowWithBigint[] | undefined;
39
- constructor({ aggregations, baseFilterSpec, columnDescriptors, data, dataMap, filterSpec, groupBy, keyColumn, rangeChangeRowset, sort, title, viewport, }: ArrayDataSourceConstructorProps);
40
- subscribe({ viewport, columns, aggregations, baseFilterSpec, range, sort, groupBy, filterSpec, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
41
- unsubscribe(): void;
42
- suspend(): void;
43
- resume(callback?: DataSourceSubscribeCallback): void;
44
- disable(): void;
45
- enable(): void;
46
- select(selectRequest: Omit<SelectRequest, "vpId">): void;
47
- private getRowKey;
48
- openTreeNode(keyOrIndex: string | number): void;
49
- closeTreeNode(keyOrIndex: string | number): void;
50
- get pageSize(): number;
51
- get links(): LinkDescriptorWithLabel[] | undefined;
52
- set links(links: LinkDescriptorWithLabel[] | undefined);
53
- get menu(): VuuMenu | undefined;
54
- get status(): DataSourceStatus;
55
- get data(): DataSourceRow<bigint | VuuRowDataItemType>[];
56
- get currentData(): DataSourceRow<bigint | VuuRowDataItemType>[];
57
- get table(): import("@vuu-ui/vuu-data-types").TableSchemaTable;
58
- get columns(): string[];
59
- set columns(columns: string[]);
60
- get config(): WithBaseFilter<WithFullConfig>;
61
- set config(config: WithBaseFilter<WithFullConfig>);
62
- private processNewColumns;
63
- private indexProcessedData;
64
- private getFilterPredicate;
65
- private applyConfig;
66
- get columnMap(): ColumnMap;
67
- get selectedRowsCount(): number;
68
- get size(): number;
69
- get maxRangeEnd(): number;
70
- get range(): Range;
71
- set range(range: Range);
72
- protected delete(row: VuuRowDataItemType[]): void;
73
- protected insert: (row: Array<bigint | VuuRowDataItemType>) => void;
74
- private insertIntoSortedData;
75
- private validateDataValue;
76
- protected updateDataItem: (keyValue: string, columnName: string, value: VuuRowDataItemType) => void;
77
- getRowByKey(key: string): DataSourceRow<bigint | VuuRowDataItemType> | undefined;
78
- getRowAtIndex(rowIndex: number): DataSourceRow<bigint | VuuRowDataItemType>;
79
- indexOfRowWithKey: (key: string) => number;
80
- protected update: (row: VuuRowDataItemType[], columnName: string) => void;
81
- protected updateRow: (row: Array<bigint | VuuRowDataItemType>, _columnName?: string) => void;
82
- protected handleDeleteFromTable: (key: string) => Promise<true | string>;
83
- private setRange;
84
- private constrainRangeToMaxRangeEnd;
85
- private get rangeWithBufferWithinMaxRangeEnd();
86
- sendSizeUpdateToClient(): void;
87
- sendRowsToClient(forceFullRefresh?: boolean, row?: DataSourceRowWithBigint): void;
88
- get aggregations(): VuuAggregation[];
89
- set aggregations(aggregations: VuuAggregation[]);
90
- get sort(): VuuSort;
91
- set sort(sort: VuuSort);
92
- get baseFilter(): DataSourceFilter | undefined;
93
- set baseFilter(baseFilter: DataSourceFilter | undefined);
94
- get filter(): DataSourceFilter;
95
- set filter(filter: DataSourceFilter);
96
- setFilter(filter: Filter): void;
97
- clearFilter(): void;
98
- get groupBy(): VuuGroupBy;
99
- set groupBy(groupBy: VuuGroupBy);
100
- get title(): string;
101
- set title(title: string);
102
- get _clientCallback(): DataSourceSubscribeCallback | undefined;
103
- createLink({ parentVpId, link: { fromColumn, toColumn }, }: LinkDescriptorWithLabel): void;
104
- removeLink(): void;
105
- remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
106
- menuRpcCall(rpcRequest: Omit<VuuRpcRequest, "vpId">): Promise<VuuRpcResponse>;
107
- freeze(): void;
108
- unfreeze(): void;
109
- get freezeTimestamp(): number | undefined;
110
- get isFrozen(): boolean;
111
- }
@@ -1,4 +0,0 @@
1
- import type { DataSourceRow, DataSourceRowWithBigint } from "@vuu-ui/vuu-data-types";
2
- import { ColumnMap, KeySet } from "@vuu-ui/vuu-utils";
3
- export declare const toClientRow: (row: DataSourceRowWithBigint, keys: KeySet, selectedRows: Set<string>, dataIndices?: number[]) => DataSourceRow;
4
- export declare const buildDataToClientMap: (columnMap: ColumnMap, dataMap?: ColumnMap) => number[] | undefined;
@@ -1,10 +0,0 @@
1
- import type { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
- import type { VuuGroupBy, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
- import { ColumnMap } from "@vuu-ui/vuu-utils";
4
- export type KeyList = number[];
5
- export type GroupMap = {
6
- [key: string]: GroupMap | KeyList;
7
- };
8
- export declare const collapseGroup: (key: string, groupedRows: readonly DataSourceRow<bigint | VuuRowDataItemType>[]) => DataSourceRow<bigint | VuuRowDataItemType>[];
9
- export declare const expandGroup: (keys: string[], sourceRows: readonly DataSourceRow<bigint | VuuRowDataItemType>[], groupBy: VuuGroupBy, columnMap: ColumnMap, groupMap: GroupMap, processedData: readonly DataSourceRow[]) => DataSourceRow[];
10
- export declare const groupRows: (rows: ReadonlyArray<Array<bigint | VuuRowDataItemType>>, groupBy: VuuGroupBy, columnMap: ColumnMap) => [DataSourceRow[], GroupMap];
@@ -1,10 +0,0 @@
1
- import type { DataSourceRowWithBigint } from "@vuu-ui/vuu-data-types";
2
- import type { VuuSort, VuuSortType } from "@vuu-ui/vuu-protocol-types";
3
- import { ColumnMap } from "@vuu-ui/vuu-utils";
4
- export type ColIndexSortDef = [number, VuuSortType];
5
- type SortCompareResult = 0 | 1 | -1;
6
- export type RowSortComparator = (item1: DataSourceRowWithBigint, item2: DataSourceRowWithBigint) => SortCompareResult;
7
- export declare const sortComparator: (sortDefs: ColIndexSortDef[]) => RowSortComparator;
8
- export declare const sortRows: (rows: readonly DataSourceRowWithBigint[], { sortDefs }: VuuSort, columnMap: ColumnMap) => DataSourceRowWithBigint[];
9
- export declare function binarySearch(items: DataSourceRowWithBigint[], item: DataSourceRowWithBigint, comparator: RowSortComparator): number;
10
- export {};
@@ -1,3 +0,0 @@
1
- export * from "./array-data-source/array-data-source";
2
- export * from "./json-data-source/JsonDataSource";
3
- export * from "./tree-data-source/TreeDataSource";
@@ -1,55 +0,0 @@
1
- import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
- import type { LinkDescriptorWithLabel, VuuGroupBy, VuuAggregation, VuuSort, VuuRpcResponse, VuuRpcRequest, SelectRequest } from "@vuu-ui/vuu-protocol-types";
3
- import type { DataSourceFilter, DataSourceRow, DataSourceConstructorProps, DataSourceEvents, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, WithFullConfig, MenuRpcResponse, DataSourceBase } from "@vuu-ui/vuu-data-types";
4
- import { EventEmitter, JsonData, Range } from "@vuu-ui/vuu-utils";
5
- export interface JsonDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
6
- data: JsonData;
7
- }
8
- export declare class JsonDataSource extends EventEmitter<DataSourceEvents> implements DataSourceBase {
9
- #private;
10
- columnDescriptors: ColumnDescriptor[];
11
- private clientCallback;
12
- private expandedRows;
13
- private visibleRows;
14
- rowCount: number | undefined;
15
- viewport: string;
16
- private keys;
17
- constructor({ aggregations, data, filterSpec, groupBy, sort, title, viewport, }: JsonDataSourceConstructorProps);
18
- subscribe({ viewport, columns, aggregations, range, sort, groupBy, filterSpec, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
19
- unsubscribe(): void;
20
- suspend(): this;
21
- resume(): this;
22
- disable(): this;
23
- enable(): this;
24
- set data(data: JsonData);
25
- select(selectRequest: Omit<SelectRequest, "vpId">): void;
26
- private getRowKey;
27
- openTreeNode(keyOrIndex: string | number): void;
28
- closeTreeNode(keyOrIndex: string | number, cascade?: boolean): void;
29
- get status(): DataSourceStatus;
30
- get config(): WithFullConfig;
31
- applyConfig(): import("@vuu-ui/vuu-utils").MaybeDataSourceConfigChanges;
32
- get selectedRowsCount(): number;
33
- get size(): number;
34
- get range(): Range;
35
- set range(range: Range);
36
- private sendRowsToClient;
37
- get columns(): string[];
38
- set columns(columns: string[]);
39
- get aggregations(): VuuAggregation[];
40
- set aggregations(aggregations: VuuAggregation[]);
41
- get sort(): VuuSort;
42
- set sort(sort: VuuSort);
43
- get filter(): DataSourceFilter;
44
- set filter(filter: DataSourceFilter);
45
- get groupBy(): VuuGroupBy;
46
- set groupBy(groupBy: VuuGroupBy);
47
- get title(): string;
48
- set title(title: string);
49
- createLink({ parentVpId, link: { fromColumn, toColumn }, }: LinkDescriptorWithLabel): void;
50
- removeLink(): void;
51
- remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
52
- menuRpcCall(rpcRequest: Omit<VuuRpcRequest, "vpId">): Promise<MenuRpcResponse | undefined>;
53
- getChildRows(rowKey: string): DataSourceRow[];
54
- getRowsAtDepth(depth: number, visibleOnly?: boolean): DataSourceRow[];
55
- }
@@ -1,6 +0,0 @@
1
- import { DataRow } from "@vuu-ui/vuu-table-types";
2
- export declare class IconProvider {
3
- #private;
4
- getIcon: (dataRow: DataRow) => string;
5
- setIcon(key: string, icon: string): void;
6
- }
@@ -1,51 +0,0 @@
1
- import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
- import type { LinkDescriptorWithLabel, VuuRange, VuuRpcResponse, VuuRpcRequest, SelectRequest } from "@vuu-ui/vuu-protocol-types";
3
- import type { DataSourceRow, DataSourceConstructorProps, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, MenuRpcResponse, DataSourceFilter, DataSourceBase } from "@vuu-ui/vuu-data-types";
4
- import { BaseDataSource, TreeSourceNode } from "@vuu-ui/vuu-utils";
5
- export interface TreeDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
6
- data: TreeSourceNode[];
7
- }
8
- export declare class TreeDataSource extends BaseDataSource implements DataSourceBase {
9
- #private;
10
- columnDescriptors: ColumnDescriptor[];
11
- private clientCallback;
12
- private expandedRows;
13
- private visibleRows;
14
- private visibleRowIndex;
15
- rowCount: number | undefined;
16
- private keys;
17
- constructor({ data, ...props }: TreeDataSourceConstructorProps);
18
- subscribe({ aggregations, columns, range, revealSelected, selectedKeyValues, viewport, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
19
- unsubscribe(): void;
20
- suspend(): this;
21
- resume(): this;
22
- disable(): this;
23
- enable(): this;
24
- set data(data: TreeSourceNode[]);
25
- get filter(): DataSourceFilter;
26
- set filter(filter: DataSourceFilter);
27
- private applyFilter;
28
- /**
29
- * used to apply an initial selection. These may not necessarily be
30
- * visible. If revealOnSelect is in force, expand nodes as necessary
31
- * to ensure selected nodes are visible
32
- */
33
- private applySelectedKeyValues;
34
- private indexOfRowWithKey;
35
- select(selectRequest: Omit<SelectRequest, "vpId">): void;
36
- private getRowKey;
37
- openTreeNode(keyOrIndex: string | number): void;
38
- closeTreeNode(keyOrIndex: string | number, cascade?: boolean): void;
39
- get status(): DataSourceStatus;
40
- get selectedRowsCount(): number;
41
- get size(): number;
42
- rangeRequest(range: VuuRange): void;
43
- private sendRowsToClient;
44
- createLink({ parentVpId, link: { fromColumn, toColumn }, }: LinkDescriptorWithLabel): void;
45
- removeLink(): void;
46
- remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
47
- menuRpcCall(rpcRequest: Omit<VuuRpcRequest, "vpId">): Promise<MenuRpcResponse | undefined>;
48
- getChildRows(rowKey: string): DataSourceRow[];
49
- getRowsAtDepth(depth: number, visibleOnly?: boolean): DataSourceRow[];
50
- getRowAtIndex(rowIdx: number): DataSourceRow;
51
- }