@ni/nimble-components 18.0.1 → 18.0.3
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/dist/all-components-bundle.js +807 -97
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +3313 -3190
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/table/components/row/index.d.ts +5 -1
- package/dist/esm/table/components/row/index.js +25 -17
- package/dist/esm/table/components/row/index.js.map +1 -1
- package/dist/esm/table/components/row/template.js +4 -4
- package/dist/esm/table/components/row/template.js.map +1 -1
- package/dist/esm/table/index.d.ts +18 -5
- package/dist/esm/table/index.js +31 -21
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/table/models/virtualizer.d.ts +24 -0
- package/dist/esm/table/models/virtualizer.js +98 -0
- package/dist/esm/table/models/virtualizer.js.map +1 -0
- package/dist/esm/table/styles.js +25 -1
- package/dist/esm/table/styles.js.map +1 -1
- package/dist/esm/table/template.js +18 -14
- package/dist/esm/table/template.js.map +1 -1
- package/dist/esm/table/types.d.ts +1 -1
- package/package.json +2 -1
|
@@ -6,6 +6,10 @@ declare global {
|
|
|
6
6
|
'nimble-table-row': TableRow;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
export interface ColumnState {
|
|
10
|
+
column: TableColumn;
|
|
11
|
+
cellState: TableCellState;
|
|
12
|
+
}
|
|
9
13
|
/**
|
|
10
14
|
* A styled row that is used within the nimble-table.
|
|
11
15
|
* @internal
|
|
@@ -14,6 +18,6 @@ export declare class TableRow<TDataRecord extends TableDataRecord = TableDataRec
|
|
|
14
18
|
recordId?: string;
|
|
15
19
|
dataRecord?: TDataRecord;
|
|
16
20
|
columns: TableColumn[];
|
|
17
|
-
|
|
21
|
+
get columnStates(): ColumnState[];
|
|
18
22
|
private hasValidFieldNames;
|
|
19
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { attr, observable } from '@microsoft/fast-element';
|
|
2
|
+
import { attr, observable, volatile } from '@microsoft/fast-element';
|
|
3
3
|
import { DesignSystem, FoundationElement } from '@microsoft/fast-foundation';
|
|
4
4
|
import { styles } from './styles';
|
|
5
5
|
import { template } from './template';
|
|
@@ -12,22 +12,27 @@ export class TableRow extends FoundationElement {
|
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.columns = [];
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
get columnStates() {
|
|
16
|
+
return this.columns.map(column => {
|
|
17
|
+
const fieldNames = column.getDataRecordFieldNames();
|
|
18
|
+
let cellState;
|
|
19
|
+
if (this.hasValidFieldNames(fieldNames) && this.dataRecord) {
|
|
20
|
+
const cellDataValues = fieldNames.map(field => this.dataRecord[field]);
|
|
21
|
+
const cellRecord = Object.fromEntries(column.cellRecordFieldNames.map((k, i) => [
|
|
22
|
+
k,
|
|
23
|
+
cellDataValues[i]
|
|
24
|
+
]));
|
|
25
|
+
const columnConfig = column.getColumnConfig?.() ?? {};
|
|
26
|
+
cellState = {
|
|
27
|
+
cellRecord,
|
|
28
|
+
columnConfig
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
cellState = { cellRecord: {}, columnConfig: {} };
|
|
33
|
+
}
|
|
34
|
+
return { column, cellState };
|
|
35
|
+
});
|
|
31
36
|
}
|
|
32
37
|
hasValidFieldNames(keys) {
|
|
33
38
|
return keys.every(key => key !== undefined);
|
|
@@ -42,6 +47,9 @@ __decorate([
|
|
|
42
47
|
__decorate([
|
|
43
48
|
observable
|
|
44
49
|
], TableRow.prototype, "columns", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
volatile
|
|
52
|
+
], TableRow.prototype, "columnStates", null);
|
|
45
53
|
const nimbleTableRow = TableRow.compose({
|
|
46
54
|
baseName: 'table-row',
|
|
47
55
|
template,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/table/components/row/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/table/components/row/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmBtC;;;GAGG;AACH,MAAM,OAAO,QAEX,SAAQ,iBAAiB;IAF3B;;QAUW,YAAO,GAAkB,EAAE,CAAC;IAmCvC,CAAC;IAhCG,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YAC7B,MAAM,UAAU,GAAG,MAAM,CAAC,uBAAuB,EAAE,CAAC;YACpD,IAAI,SAAyB,CAAC;YAC9B,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE;gBACxD,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CACjC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,UAAW,CAAC,KAAK,CAAC,CACnC,CAAC;gBACF,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CACjC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBACtC,CAAC;oBACD,cAAc,CAAC,CAAC,CAAC;iBACpB,CAAC,CACL,CAAC;gBACF,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC;gBACtD,SAAS,GAAG;oBACR,UAAU;oBACV,YAAY;iBACf,CAAC;aACL;iBAAM;gBACH,SAAS,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;aACpD;YAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,kBAAkB,CACtB,IAAoC;QAEpC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;IAChD,CAAC;CACJ;AAzCG;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;0CACR;AAGzB;IADC,UAAU;4CACqB;AAGhC;IADC,UAAU;yCACwB;AAGnC;IADC,QAAQ;4CA0BR;AASL,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC;IACpC,QAAQ,EAAE,WAAW;IACrB,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC"}
|
|
@@ -4,12 +4,12 @@ import { TableCell } from '../cell';
|
|
|
4
4
|
// prettier-ignore
|
|
5
5
|
export const template = html `
|
|
6
6
|
<template role="row">
|
|
7
|
-
${repeat(x => x.
|
|
7
|
+
${repeat(x => x.columnStates, html `
|
|
8
8
|
<${DesignSystem.tagFor(TableCell)}
|
|
9
9
|
class="cell"
|
|
10
|
-
:cellTemplate="${x => x.cellTemplate}"
|
|
11
|
-
:cellStyles="${x => x.cellStyles}"
|
|
12
|
-
:cellState="${
|
|
10
|
+
:cellTemplate="${x => x.column.cellTemplate}"
|
|
11
|
+
:cellStyles="${x => x.column.cellStyles}"
|
|
12
|
+
:cellState="${x => x.cellState}"
|
|
13
13
|
>
|
|
14
14
|
</${DesignSystem.tagFor(TableCell)}>
|
|
15
15
|
`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../src/table/components/row/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../src/table/components/row/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,kBAAkB;AAClB,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAU;;UAE5B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,CAAuB;eAClD,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;;iCAEZ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY;+BAC5B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU;8BACzB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;;gBAE9B,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;SACrC,CAAC;;CAET,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FoundationElement } from '@microsoft/fast-foundation';
|
|
2
2
|
import type { TableColumn } from '../table-column/base';
|
|
3
3
|
import type { TableRecord, TableRowState, TableValidity } from './types';
|
|
4
|
+
import { Virtualizer } from './models/virtualizer';
|
|
4
5
|
declare global {
|
|
5
6
|
interface HTMLElementTagNameMap {
|
|
6
7
|
'nimble-table': Table;
|
|
@@ -11,24 +12,36 @@ declare global {
|
|
|
11
12
|
*/
|
|
12
13
|
export declare class Table<TData extends TableRecord = TableRecord> extends FoundationElement {
|
|
13
14
|
idFieldName?: string | null;
|
|
14
|
-
data: TData[];
|
|
15
15
|
/**
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
tableData: TableRowState<TData>[];
|
|
19
19
|
readonly columns: TableColumn[];
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
canRenderRows: boolean;
|
|
20
24
|
get validity(): TableValidity;
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
readonly viewport: HTMLElement;
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
readonly virtualizer: Virtualizer<TData>;
|
|
21
33
|
private readonly table;
|
|
22
34
|
private options;
|
|
23
|
-
private readonly tableInitialized;
|
|
24
35
|
private readonly tableValidator;
|
|
25
36
|
constructor();
|
|
37
|
+
setData(newData: readonly TData[]): void;
|
|
26
38
|
idFieldNameChanged(_prev: string | undefined, _next: string | undefined): void;
|
|
27
|
-
|
|
39
|
+
connectedCallback(): void;
|
|
40
|
+
disconnectedCallback(): void;
|
|
28
41
|
checkValidity(): boolean;
|
|
29
|
-
private
|
|
42
|
+
private setTableData;
|
|
30
43
|
private refreshRows;
|
|
31
44
|
private updateTableOptions;
|
|
32
45
|
private readonly update;
|
|
33
|
-
private
|
|
46
|
+
private generateTanStackColumns;
|
|
34
47
|
}
|
package/dist/esm/table/index.js
CHANGED
|
@@ -5,19 +5,22 @@ import { createTable as tanStackCreateTable, getCoreRowModel as tanStackGetCoreR
|
|
|
5
5
|
import { TableValidator } from './models/table-validator';
|
|
6
6
|
import { styles } from './styles';
|
|
7
7
|
import { template } from './template';
|
|
8
|
+
import { Virtualizer } from './models/virtualizer';
|
|
8
9
|
/**
|
|
9
10
|
* A nimble-styled table.
|
|
10
11
|
*/
|
|
11
12
|
export class Table extends FoundationElement {
|
|
12
13
|
constructor() {
|
|
13
14
|
super();
|
|
14
|
-
this.data = [];
|
|
15
15
|
/**
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
this.tableData = [];
|
|
19
19
|
this.columns = [];
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
this.canRenderRows = true;
|
|
21
24
|
this.tableValidator = new TableValidator();
|
|
22
25
|
this.update = (state) => {
|
|
23
26
|
this.table.setOptions(prev => ({
|
|
@@ -42,35 +45,41 @@ export class Table extends FoundationElement {
|
|
|
42
45
|
autoResetAll: false
|
|
43
46
|
};
|
|
44
47
|
this.table = tanStackCreateTable(this.options);
|
|
45
|
-
this.
|
|
48
|
+
this.virtualizer = new Virtualizer(this);
|
|
46
49
|
}
|
|
47
50
|
get validity() {
|
|
48
51
|
return this.tableValidator.getValidity();
|
|
49
52
|
}
|
|
53
|
+
setData(newData) {
|
|
54
|
+
this.generateTanStackColumns(newData);
|
|
55
|
+
this.setTableData(newData);
|
|
56
|
+
}
|
|
50
57
|
idFieldNameChanged(_prev, _next) {
|
|
51
58
|
// Force TanStack to detect a data update because a row's ID is only
|
|
52
59
|
// generated when creating a new row model.
|
|
53
|
-
this.
|
|
60
|
+
this.setTableData(this.table.options.data);
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.trySetData(this.data);
|
|
62
|
-
}
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
super.connectedCallback();
|
|
64
|
+
this.virtualizer.connectedCallback();
|
|
65
|
+
}
|
|
66
|
+
disconnectedCallback() {
|
|
67
|
+
this.virtualizer.disconnectedCallback();
|
|
63
68
|
}
|
|
64
69
|
checkValidity() {
|
|
65
70
|
return this.tableValidator.isValid();
|
|
66
71
|
}
|
|
67
|
-
|
|
68
|
-
const
|
|
72
|
+
setTableData(newData) {
|
|
73
|
+
const data = newData.map(record => {
|
|
74
|
+
return { ...record };
|
|
75
|
+
});
|
|
76
|
+
this.tableValidator.validateRecordIds(data, this.idFieldName);
|
|
77
|
+
this.canRenderRows = this.checkValidity();
|
|
69
78
|
const getRowIdFunction = this.idFieldName === null || this.idFieldName === undefined
|
|
70
79
|
? undefined
|
|
71
80
|
: (record) => record[this.idFieldName];
|
|
72
81
|
this.updateTableOptions({
|
|
73
|
-
data
|
|
82
|
+
data,
|
|
74
83
|
getRowId: getRowIdFunction
|
|
75
84
|
});
|
|
76
85
|
}
|
|
@@ -83,6 +92,7 @@ export class Table extends FoundationElement {
|
|
|
83
92
|
};
|
|
84
93
|
return rowState;
|
|
85
94
|
});
|
|
95
|
+
this.virtualizer.dataChanged();
|
|
86
96
|
}
|
|
87
97
|
updateTableOptions(updatedOptions) {
|
|
88
98
|
this.options = { ...this.options, ...updatedOptions };
|
|
@@ -91,11 +101,11 @@ export class Table extends FoundationElement {
|
|
|
91
101
|
}
|
|
92
102
|
// Generate columns for TanStack that correspond to all the keys in TData because all operations,
|
|
93
103
|
// such as grouping and sorting, will be performed on the data's records, not the values rendered within a cell.
|
|
94
|
-
|
|
95
|
-
if (
|
|
104
|
+
generateTanStackColumns(data) {
|
|
105
|
+
if (data.length === 0) {
|
|
96
106
|
return;
|
|
97
107
|
}
|
|
98
|
-
const firstItem =
|
|
108
|
+
const firstItem = data[0];
|
|
99
109
|
const keys = Object.keys(firstItem);
|
|
100
110
|
const generatedColumns = keys.map(key => {
|
|
101
111
|
const columnDef = {
|
|
@@ -111,15 +121,15 @@ export class Table extends FoundationElement {
|
|
|
111
121
|
__decorate([
|
|
112
122
|
attr({ attribute: 'id-field-name' })
|
|
113
123
|
], Table.prototype, "idFieldName", void 0);
|
|
114
|
-
__decorate([
|
|
115
|
-
observable
|
|
116
|
-
], Table.prototype, "data", void 0);
|
|
117
124
|
__decorate([
|
|
118
125
|
observable
|
|
119
126
|
], Table.prototype, "tableData", void 0);
|
|
120
127
|
__decorate([
|
|
121
128
|
observable
|
|
122
129
|
], Table.prototype, "columns", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
observable
|
|
132
|
+
], Table.prototype, "canRenderRows", void 0);
|
|
123
133
|
const nimbleTable = Table.compose({
|
|
124
134
|
baseName: 'table',
|
|
125
135
|
template,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAKH,WAAW,IAAI,mBAAmB,EAClC,eAAe,IAAI,uBAAuB,EAE7C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAKH,WAAW,IAAI,mBAAmB,EAClC,eAAe,IAAI,uBAAuB,EAE7C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,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;AAMnC;IADC,UAAU;wCACmC;AAG9C;IADC,UAAU;sCACiC;AAM5C;IADC,UAAU;4CACiB;AAsIhC,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,QAAQ,EAAE,OAAO;IACjB,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { VirtualItem } from '@tanstack/virtual-core';
|
|
2
|
+
import type { Table } from '..';
|
|
3
|
+
import type { TableRecord } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Helper class for the nimble-table for row virtualization.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class Virtualizer<TData extends TableRecord = TableRecord> {
|
|
10
|
+
visibleItems: VirtualItem[];
|
|
11
|
+
allRowsHeight: number;
|
|
12
|
+
headerContainerMarginRight: number;
|
|
13
|
+
rowContainerYOffset: number;
|
|
14
|
+
private readonly table;
|
|
15
|
+
private readonly viewportResizeObserver;
|
|
16
|
+
private virtualizer?;
|
|
17
|
+
constructor(table: Table<TData>);
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
disconnectedCallback(): void;
|
|
20
|
+
dataChanged(): void;
|
|
21
|
+
private updateVirtualizer;
|
|
22
|
+
private createVirtualizerOptions;
|
|
23
|
+
private handleVirtualizerChange;
|
|
24
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { observable } from '@microsoft/fast-element';
|
|
3
|
+
import { Virtualizer as TanStackVirtualizer, elementScroll, observeElementOffset, observeElementRect } from '@tanstack/virtual-core';
|
|
4
|
+
import { controlHeight } from '../../theme-provider/design-tokens';
|
|
5
|
+
/**
|
|
6
|
+
* Helper class for the nimble-table for row virtualization.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export class Virtualizer {
|
|
11
|
+
constructor(table) {
|
|
12
|
+
this.visibleItems = [];
|
|
13
|
+
this.allRowsHeight = 0;
|
|
14
|
+
this.headerContainerMarginRight = 0;
|
|
15
|
+
this.rowContainerYOffset = 0;
|
|
16
|
+
this.table = table;
|
|
17
|
+
this.viewportResizeObserver = new ResizeObserver(entries => {
|
|
18
|
+
const borderBoxSize = entries[0]?.borderBoxSize[0];
|
|
19
|
+
if (borderBoxSize) {
|
|
20
|
+
// If we have enough rows that a vertical scrollbar is shown, we need to offset the header widths
|
|
21
|
+
// by the same margin so the column headers align with the corresponding rendered cells
|
|
22
|
+
const viewportBoundingWidth = borderBoxSize.inlineSize;
|
|
23
|
+
this.headerContainerMarginRight = viewportBoundingWidth - this.table.viewport.scrollWidth;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
this.viewportResizeObserver.observe(this.table.viewport);
|
|
29
|
+
this.updateVirtualizer();
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
this.viewportResizeObserver.disconnect();
|
|
33
|
+
}
|
|
34
|
+
dataChanged() {
|
|
35
|
+
if (this.table.$fastController.isConnected) {
|
|
36
|
+
this.updateVirtualizer();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
updateVirtualizer() {
|
|
40
|
+
const options = this.createVirtualizerOptions();
|
|
41
|
+
if (this.virtualizer) {
|
|
42
|
+
this.virtualizer.setOptions(options);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.virtualizer = new TanStackVirtualizer(options);
|
|
46
|
+
}
|
|
47
|
+
this.virtualizer._willUpdate();
|
|
48
|
+
this.handleVirtualizerChange();
|
|
49
|
+
}
|
|
50
|
+
createVirtualizerOptions() {
|
|
51
|
+
const rowHeight = parseFloat(controlHeight.getValueFor(this.table));
|
|
52
|
+
return {
|
|
53
|
+
count: this.table.tableData.length,
|
|
54
|
+
getScrollElement: () => {
|
|
55
|
+
return this.table.viewport;
|
|
56
|
+
},
|
|
57
|
+
estimateSize: (_) => rowHeight,
|
|
58
|
+
enableSmoothScroll: true,
|
|
59
|
+
overscan: 3,
|
|
60
|
+
scrollingDelay: 5,
|
|
61
|
+
scrollToFn: elementScroll,
|
|
62
|
+
observeElementOffset,
|
|
63
|
+
observeElementRect,
|
|
64
|
+
onChange: () => this.handleVirtualizerChange()
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
handleVirtualizerChange() {
|
|
68
|
+
const virtualizer = this.virtualizer;
|
|
69
|
+
this.visibleItems = virtualizer.getVirtualItems();
|
|
70
|
+
this.allRowsHeight = virtualizer.getTotalSize();
|
|
71
|
+
// We're using a separate div ('table-scroll') to represent the full height of all rows, and
|
|
72
|
+
// the row container's height is only big enough to hold the virtualized rows. So we don't
|
|
73
|
+
// use the TanStackVirtual-provided 'start' offset (which is in terms of the full height)
|
|
74
|
+
// to translate every individual row, we just translate the row container.
|
|
75
|
+
let rowContainerYOffset = 0;
|
|
76
|
+
if (this.visibleItems.length > 0) {
|
|
77
|
+
const firstItem = this.visibleItems[0];
|
|
78
|
+
const lastItem = this.visibleItems[this.visibleItems.length - 1];
|
|
79
|
+
if (lastItem.end < this.allRowsHeight) {
|
|
80
|
+
rowContainerYOffset = firstItem.start - virtualizer.scrollOffset;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.rowContainerYOffset = rowContainerYOffset;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
__decorate([
|
|
87
|
+
observable
|
|
88
|
+
], Virtualizer.prototype, "visibleItems", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
observable
|
|
91
|
+
], Virtualizer.prototype, "allRowsHeight", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
observable
|
|
94
|
+
], Virtualizer.prototype, "headerContainerMarginRight", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
observable
|
|
97
|
+
], Virtualizer.prototype, "rowContainerYOffset", void 0);
|
|
98
|
+
//# sourceMappingURL=virtualizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtualizer.js","sourceRoot":"","sources":["../../../../src/table/models/virtualizer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACH,WAAW,IAAI,mBAAmB,EAElC,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAErB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAInE;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAiBpB,YAAmB,KAAmB;QAf/B,iBAAY,GAAkB,EAAE,CAAC;QAGjC,kBAAa,GAAG,CAAC,CAAC;QAGlB,+BAA0B,GAAG,CAAC,CAAC;QAG/B,wBAAmB,GAAG,CAAC,CAAC;QAO3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,sBAAsB,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;YACvD,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;YACnD,IAAI,aAAa,EAAE;gBACf,iGAAiG;gBACjG,uFAAuF;gBACvF,MAAM,qBAAqB,GAAG,aAAa,CAAC,UAAU,CAAC;gBACvD,IAAI,CAAC,0BAA0B,GAAG,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;aAC7F;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,iBAAiB;QACpB,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC7B,CAAC;IAEM,oBAAoB;QACvB,IAAI,CAAC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CAAC,YAAY,EAAE,CAAC;QAChD,4FAA4F;QAC5F,0FAA0F;QAC1F,yFAAyF;QACzF,0EAA0E;QAC1E,IAAI,mBAAmB,GAAG,CAAC,CAAC;QAC5B,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;YAClE,IAAI,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,aAAa,EAAE;gBACnC,mBAAmB,GAAG,SAAS,CAAC,KAAK,GAAG,WAAW,CAAC,YAAY,CAAC;aACpE;SACJ;QACD,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;CACJ;AA7FG;IADC,UAAU;iDAC6B;AAGxC;IADC,UAAU;kDACc;AAGzB;IADC,UAAU;+DAC2B;AAGtC;IADC,UAAU;wDACoB"}
|
package/dist/esm/table/styles.js
CHANGED
|
@@ -8,13 +8,37 @@ import { themeBehavior } from '../utilities/style/theme';
|
|
|
8
8
|
export const styles = css `
|
|
9
9
|
${display('flex')}
|
|
10
10
|
|
|
11
|
+
:host {
|
|
12
|
+
height: 480px;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
.table-container {
|
|
12
16
|
display: flex;
|
|
13
17
|
flex-direction: column;
|
|
14
18
|
width: 100%;
|
|
15
19
|
font: ${bodyFont};
|
|
16
20
|
color: ${bodyFontColor};
|
|
17
|
-
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.table-viewport {
|
|
24
|
+
overflow-y: auto;
|
|
25
|
+
display: block;
|
|
26
|
+
height: 100%;
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.table-scroll {
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 0px;
|
|
34
|
+
width: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.table-row-container {
|
|
38
|
+
width: 100%;
|
|
39
|
+
position: sticky;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
top: 0px;
|
|
18
42
|
}
|
|
19
43
|
|
|
20
44
|
.header-container {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/table/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAC;AACzE,OAAO,EACH,0BAA0B,EAC1B,QAAQ,EACR,aAAa,EACb,cAAc,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/table/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAC;AACzE,OAAO,EACH,0BAA0B,EAC1B,QAAQ,EACR,aAAa,EACb,cAAc,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,MAAM,CAAC;;;;;;;;;;gBAUL,QAAQ;iBACP,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAgCR,0BAA0B;;;;;;;;;sBAS1B,0BAA0B;;;;;;;;;;;;sBAY1B,cAAc;;CAEnC,CAAC,aAAa,CACX,aAAa,CACT,KAAK,CAAC,KAAK,EACX,GAAG,CAAA;;;;;;8BAMmB,cAAc;;;;8BAId,cAAc;;;;8BAId,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC;;SAEnD,CACJ,CACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html, repeat, slotted, when } from '@microsoft/fast-element';
|
|
1
|
+
import { html, ref, repeat, slotted, when } from '@microsoft/fast-element';
|
|
2
2
|
import { DesignSystem } from '@microsoft/fast-foundation';
|
|
3
3
|
import { TableHeader } from './components/header';
|
|
4
4
|
import { TableRow } from './components/row';
|
|
@@ -13,7 +13,7 @@ const isTableColumn = () => {
|
|
|
13
13
|
export const template = html `
|
|
14
14
|
<template role="table">
|
|
15
15
|
<div class="table-container">
|
|
16
|
-
<div role="rowgroup" class="header-container">
|
|
16
|
+
<div role="rowgroup" class="header-container" style="margin-right: ${x => x.virtualizer.headerContainerMarginRight}px;">
|
|
17
17
|
<div class="header-row" role="row">
|
|
18
18
|
${repeat(x => x.columns, html `
|
|
19
19
|
<${DesignSystem.tagFor(TableHeader)} class="header">
|
|
@@ -22,18 +22,22 @@ export const template = html `
|
|
|
22
22
|
`)}
|
|
23
23
|
</div>
|
|
24
24
|
</div>
|
|
25
|
-
<div class="table-viewport"
|
|
26
|
-
|
|
27
|
-
${
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
<div class="table-viewport" ${ref('viewport')}>
|
|
26
|
+
<div class="table-scroll" style="height: ${x => x.virtualizer.allRowsHeight}px;"></div>
|
|
27
|
+
<div class="table-row-container" role="rowgroup" style="transform: ${x => (x.virtualizer.rowContainerYOffset === 0 ? 'none' : `translateY(${x.virtualizer.rowContainerYOffset}px)`)};">
|
|
28
|
+
${when(x => x.columns.length > 0 && x.canRenderRows, html `
|
|
29
|
+
${repeat(x => x.virtualizer.visibleItems, html `
|
|
30
|
+
<${DesignSystem.tagFor(TableRow)}
|
|
31
|
+
class="row"
|
|
32
|
+
record-id="${(x, c) => c.parent.tableData[x.index]?.id}"
|
|
33
|
+
:dataRecord="${(x, c) => c.parent.tableData[x.index]?.record}"
|
|
34
|
+
:columns="${(_, c) => c.parent.columns}"
|
|
35
|
+
style="height: ${x => x.size}px;"
|
|
36
|
+
>
|
|
37
|
+
</${DesignSystem.tagFor(TableRow)}>
|
|
38
|
+
`)}
|
|
39
|
+
`)}
|
|
40
|
+
</div>
|
|
37
41
|
</div>
|
|
38
42
|
</div>
|
|
39
43
|
<slot ${slotted({ property: 'columns', filter: isTableColumn() })}></slot>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/table/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,IAAI,EACJ,MAAM,EACN,OAAO,EACP,IAAI,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,aAAa,GAAG,GAAmB,EAAE;IACvC,MAAM,MAAM,GAAmB,CAC3B,KAAW,EACX,CAAS,EACT,EAAU,EACH,EAAE;QACT,OAAO,KAAK,YAAY,WAAW,CAAC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CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,WAAW,CAAC,mBAAmB,KAAK,CAAC;sBAC7K,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,IAAI,CAAO;0BAC1D,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAoB;+BAC3D,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;;6CAEf,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE;+CACvC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM;4CAChD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO;iDACrB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;;gCAE5B,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;yBACpC,CAAC;qBACL,CAAC;;;;gBAIN,OAAO,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,CAAC;;CAExE,CAAC"}
|
|
@@ -7,7 +7,7 @@ export declare type TableFieldName = string;
|
|
|
7
7
|
* TableFieldValue describes the type associated with values within
|
|
8
8
|
* a table's records.
|
|
9
9
|
*/
|
|
10
|
-
export declare type TableFieldValue = string | number | boolean |
|
|
10
|
+
export declare type TableFieldValue = string | number | boolean | null | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* TableRecord describes the data structure that backs a single row in a table.
|
|
13
13
|
* It is made up of fields, which are key/value pairs that have a key of type
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ni/nimble-components",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.3",
|
|
4
4
|
"description": "Styled web components for the NI Nimble Design System",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run generate-icons && npm run build-components && npm run bundle-components && npm run generate-scss && npm run build-storybook",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@microsoft/fast-web-utilities": "^5.4.1",
|
|
53
53
|
"@ni/nimble-tokens": "^4.3.2",
|
|
54
54
|
"@tanstack/table-core": "^8.7.0",
|
|
55
|
+
"@tanstack/virtual-core": "^3.0.0-beta.34",
|
|
55
56
|
"@types/d3": "^7.4.0",
|
|
56
57
|
"@types/d3-scale": "^4.0.2",
|
|
57
58
|
"@types/d3-zoom": "^3.0.0",
|