@ni/nimble-components 17.0.5 → 17.0.6
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 +34 -31
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +129 -127
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/table/components/row/index.d.ts +1 -0
- package/dist/esm/table/components/row/index.js +4 -1
- package/dist/esm/table/components/row/index.js.map +1 -1
- package/dist/esm/table/index.js +12 -15
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/table/models/table-validator.d.ts +4 -4
- package/dist/esm/table/models/table-validator.js +18 -16
- package/dist/esm/table/models/table-validator.js.map +1 -1
- package/dist/esm/table/models/table-validator.spec.js +57 -57
- package/dist/esm/table/models/table-validator.spec.js.map +1 -1
- package/dist/esm/table/template.js +1 -0
- package/dist/esm/table/template.js.map +1 -1
- package/dist/esm/table/types.d.ts +4 -3
- package/package.json +1 -1
|
@@ -25098,45 +25098,47 @@
|
|
|
25098
25098
|
*/
|
|
25099
25099
|
class TableValidator {
|
|
25100
25100
|
constructor() {
|
|
25101
|
-
this.
|
|
25102
|
-
this.
|
|
25103
|
-
this.
|
|
25101
|
+
this.duplicateRecordId = false;
|
|
25102
|
+
this.missingRecordId = false;
|
|
25103
|
+
this.invalidRecordId = false;
|
|
25104
25104
|
}
|
|
25105
25105
|
getValidity() {
|
|
25106
25106
|
return {
|
|
25107
|
-
|
|
25108
|
-
|
|
25109
|
-
|
|
25107
|
+
duplicateRecordId: this.duplicateRecordId,
|
|
25108
|
+
missingRecordId: this.missingRecordId,
|
|
25109
|
+
invalidRecordId: this.invalidRecordId
|
|
25110
25110
|
};
|
|
25111
25111
|
}
|
|
25112
25112
|
isValid() {
|
|
25113
25113
|
return Object.values(this.getValidity()).every(x => x === false);
|
|
25114
25114
|
}
|
|
25115
|
-
|
|
25115
|
+
validateRecordIds(data, idFieldName) {
|
|
25116
25116
|
// Start off by assuming all IDs are valid.
|
|
25117
|
-
this.
|
|
25118
|
-
this.
|
|
25119
|
-
this.
|
|
25120
|
-
if (idFieldName
|
|
25117
|
+
this.duplicateRecordId = false;
|
|
25118
|
+
this.missingRecordId = false;
|
|
25119
|
+
this.invalidRecordId = false;
|
|
25120
|
+
if (idFieldName === undefined || idFieldName === null) {
|
|
25121
25121
|
return true;
|
|
25122
25122
|
}
|
|
25123
25123
|
const ids = new Set();
|
|
25124
25124
|
for (const record of data) {
|
|
25125
25125
|
if (!Object.prototype.hasOwnProperty.call(record, idFieldName)) {
|
|
25126
|
-
this.
|
|
25126
|
+
this.missingRecordId = true;
|
|
25127
25127
|
continue;
|
|
25128
25128
|
}
|
|
25129
25129
|
const id = record[idFieldName];
|
|
25130
|
-
if (typeof id !== 'string'
|
|
25131
|
-
this.
|
|
25130
|
+
if (typeof id !== 'string') {
|
|
25131
|
+
this.invalidRecordId = true;
|
|
25132
25132
|
continue;
|
|
25133
25133
|
}
|
|
25134
25134
|
if (ids.has(id)) {
|
|
25135
|
-
this.
|
|
25135
|
+
this.duplicateRecordId = true;
|
|
25136
25136
|
}
|
|
25137
25137
|
ids.add(id);
|
|
25138
25138
|
}
|
|
25139
|
-
return !this.
|
|
25139
|
+
return (!this.missingRecordId
|
|
25140
|
+
&& !this.invalidRecordId
|
|
25141
|
+
&& !this.duplicateRecordId);
|
|
25140
25142
|
}
|
|
25141
25143
|
}
|
|
25142
25144
|
|
|
@@ -25359,6 +25361,9 @@
|
|
|
25359
25361
|
return keys.every(key => key !== undefined);
|
|
25360
25362
|
}
|
|
25361
25363
|
}
|
|
25364
|
+
__decorate$1([
|
|
25365
|
+
attr({ attribute: 'record-id' })
|
|
25366
|
+
], TableRow.prototype, "recordId", void 0);
|
|
25362
25367
|
__decorate$1([
|
|
25363
25368
|
observable
|
|
25364
25369
|
], TableRow.prototype, "dataRecord", void 0);
|
|
@@ -25402,6 +25407,7 @@
|
|
|
25402
25407
|
${repeat(x => x.tableData, html `
|
|
25403
25408
|
<${DesignSystem.tagFor(TableRow)}
|
|
25404
25409
|
class="row"
|
|
25410
|
+
record-id="${x => x.id}"
|
|
25405
25411
|
:dataRecord="${x => x.record}"
|
|
25406
25412
|
:columns="${(_, c) => c.parent.columns}"
|
|
25407
25413
|
>
|
|
@@ -25445,13 +25451,6 @@
|
|
|
25445
25451
|
data: [],
|
|
25446
25452
|
onStateChange: (_) => { },
|
|
25447
25453
|
getCoreRowModel: getCoreRowModel(),
|
|
25448
|
-
getRowId: record => {
|
|
25449
|
-
if (this.idFieldName) {
|
|
25450
|
-
return record[this.idFieldName];
|
|
25451
|
-
}
|
|
25452
|
-
// Return a falsey value to use the default ID from TanStack.
|
|
25453
|
-
return '';
|
|
25454
|
-
},
|
|
25455
25454
|
columns: [],
|
|
25456
25455
|
state: {},
|
|
25457
25456
|
renderFallbackValue: null,
|
|
@@ -25481,18 +25480,22 @@
|
|
|
25481
25480
|
return this.tableValidator.isValid();
|
|
25482
25481
|
}
|
|
25483
25482
|
trySetData(newData) {
|
|
25484
|
-
const areIdsValid = this.tableValidator.
|
|
25485
|
-
|
|
25486
|
-
|
|
25487
|
-
|
|
25488
|
-
|
|
25489
|
-
|
|
25490
|
-
|
|
25483
|
+
const areIdsValid = this.tableValidator.validateRecordIds(newData, this.idFieldName);
|
|
25484
|
+
const getRowIdFunction = this.idFieldName === null || this.idFieldName === undefined
|
|
25485
|
+
? undefined
|
|
25486
|
+
: (record) => record[this.idFieldName];
|
|
25487
|
+
this.updateTableOptions({
|
|
25488
|
+
data: areIdsValid ? newData : [],
|
|
25489
|
+
getRowId: getRowIdFunction
|
|
25490
|
+
});
|
|
25491
25491
|
}
|
|
25492
25492
|
refreshRows() {
|
|
25493
25493
|
const rows = this.table.getRowModel().rows;
|
|
25494
25494
|
this.tableData = rows.map(row => {
|
|
25495
|
-
const rowState = {
|
|
25495
|
+
const rowState = {
|
|
25496
|
+
record: row.original,
|
|
25497
|
+
id: row.id
|
|
25498
|
+
};
|
|
25496
25499
|
return rowState;
|
|
25497
25500
|
});
|
|
25498
25501
|
}
|