@ni/nimble-components 17.0.4 → 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.
@@ -20730,18 +20730,25 @@
20730
20730
  background: ${applicationBackgroundColor};
20731
20731
  border: ${borderWidth} solid ${popupBorderColor};
20732
20732
  margin: 0;
20733
- padding: 4px;
20734
- min-width: 168px;
20733
+ min-width: 176px;
20735
20734
  width: max-content;
20736
20735
  box-shadow: ${elevation2BoxShadow};
20737
20736
  }
20737
+
20738
+ slot {
20739
+ padding: 4px;
20740
+ display: block;
20741
+ }
20742
+
20738
20743
  :host([slot='submenu']) {
20739
20744
  margin: 0 calc(${smallPadding} * 2);
20740
20745
  }
20746
+
20741
20747
  ::slotted(*) {
20742
20748
  padding-left: 8px;
20743
20749
  padding-right: 8px;
20744
20750
  }
20751
+
20745
20752
  ::slotted(hr) {
20746
20753
  box-sizing: content-box;
20747
20754
  height: 2px;
@@ -20750,6 +20757,7 @@
20750
20757
  background: ${borderColor};
20751
20758
  opacity: 0.1;
20752
20759
  }
20760
+
20753
20761
  ::slotted(header) {
20754
20762
  display: flex;
20755
20763
  font: ${groupHeaderFont};
@@ -20758,7 +20766,11 @@
20758
20766
  padding-top: ${smallPadding};
20759
20767
  padding-bottom: ${smallPadding};
20760
20768
  }
20761
- `;
20769
+ `.withBehaviors(themeBehavior(Theme.color, css `
20770
+ slot {
20771
+ background: ${hexToRgbaCssColor(White, 0.15)};
20772
+ }
20773
+ `));
20762
20774
 
20763
20775
  /**
20764
20776
  * A nimble-styled menu
@@ -25086,45 +25098,47 @@
25086
25098
  */
25087
25099
  class TableValidator {
25088
25100
  constructor() {
25089
- this.duplicateRowId = false;
25090
- this.missingRowId = false;
25091
- this.invalidRowId = false;
25101
+ this.duplicateRecordId = false;
25102
+ this.missingRecordId = false;
25103
+ this.invalidRecordId = false;
25092
25104
  }
25093
25105
  getValidity() {
25094
25106
  return {
25095
- duplicateRowId: this.duplicateRowId,
25096
- missingRowId: this.missingRowId,
25097
- invalidRowId: this.invalidRowId
25107
+ duplicateRecordId: this.duplicateRecordId,
25108
+ missingRecordId: this.missingRecordId,
25109
+ invalidRecordId: this.invalidRecordId
25098
25110
  };
25099
25111
  }
25100
25112
  isValid() {
25101
25113
  return Object.values(this.getValidity()).every(x => x === false);
25102
25114
  }
25103
- validateDataIds(data, idFieldName) {
25115
+ validateRecordIds(data, idFieldName) {
25104
25116
  // Start off by assuming all IDs are valid.
25105
- this.duplicateRowId = false;
25106
- this.missingRowId = false;
25107
- this.invalidRowId = false;
25108
- if (idFieldName == null) {
25117
+ this.duplicateRecordId = false;
25118
+ this.missingRecordId = false;
25119
+ this.invalidRecordId = false;
25120
+ if (idFieldName === undefined || idFieldName === null) {
25109
25121
  return true;
25110
25122
  }
25111
25123
  const ids = new Set();
25112
25124
  for (const record of data) {
25113
25125
  if (!Object.prototype.hasOwnProperty.call(record, idFieldName)) {
25114
- this.missingRowId = true;
25126
+ this.missingRecordId = true;
25115
25127
  continue;
25116
25128
  }
25117
25129
  const id = record[idFieldName];
25118
- if (typeof id !== 'string' || id === '') {
25119
- this.invalidRowId = true;
25130
+ if (typeof id !== 'string') {
25131
+ this.invalidRecordId = true;
25120
25132
  continue;
25121
25133
  }
25122
25134
  if (ids.has(id)) {
25123
- this.duplicateRowId = true;
25135
+ this.duplicateRecordId = true;
25124
25136
  }
25125
25137
  ids.add(id);
25126
25138
  }
25127
- return !this.missingRowId && !this.invalidRowId && !this.duplicateRowId;
25139
+ return (!this.missingRecordId
25140
+ && !this.invalidRecordId
25141
+ && !this.duplicateRecordId);
25128
25142
  }
25129
25143
  }
25130
25144
 
@@ -25347,6 +25361,9 @@
25347
25361
  return keys.every(key => key !== undefined);
25348
25362
  }
25349
25363
  }
25364
+ __decorate$1([
25365
+ attr({ attribute: 'record-id' })
25366
+ ], TableRow.prototype, "recordId", void 0);
25350
25367
  __decorate$1([
25351
25368
  observable
25352
25369
  ], TableRow.prototype, "dataRecord", void 0);
@@ -25390,6 +25407,7 @@
25390
25407
  ${repeat(x => x.tableData, html `
25391
25408
  <${DesignSystem.tagFor(TableRow)}
25392
25409
  class="row"
25410
+ record-id="${x => x.id}"
25393
25411
  :dataRecord="${x => x.record}"
25394
25412
  :columns="${(_, c) => c.parent.columns}"
25395
25413
  >
@@ -25433,13 +25451,6 @@
25433
25451
  data: [],
25434
25452
  onStateChange: (_) => { },
25435
25453
  getCoreRowModel: getCoreRowModel(),
25436
- getRowId: record => {
25437
- if (this.idFieldName) {
25438
- return record[this.idFieldName];
25439
- }
25440
- // Return a falsey value to use the default ID from TanStack.
25441
- return '';
25442
- },
25443
25454
  columns: [],
25444
25455
  state: {},
25445
25456
  renderFallbackValue: null,
@@ -25469,18 +25480,22 @@
25469
25480
  return this.tableValidator.isValid();
25470
25481
  }
25471
25482
  trySetData(newData) {
25472
- const areIdsValid = this.tableValidator.validateDataIds(newData, this.idFieldName);
25473
- if (areIdsValid) {
25474
- this.updateTableOptions({ data: newData });
25475
- }
25476
- else {
25477
- this.updateTableOptions({ data: [] });
25478
- }
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
+ });
25479
25491
  }
25480
25492
  refreshRows() {
25481
25493
  const rows = this.table.getRowModel().rows;
25482
25494
  this.tableData = rows.map(row => {
25483
- const rowState = { record: row.original };
25495
+ const rowState = {
25496
+ record: row.original,
25497
+ id: row.id
25498
+ };
25484
25499
  return rowState;
25485
25500
  });
25486
25501
  }