@ni/nimble-components 18.6.2 → 18.6.4

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/dist/all-components-bundle.js +354 -80
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +581 -555
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/table/components/row/styles.js +4 -1
  6. package/dist/esm/table/components/row/styles.js.map +1 -1
  7. package/dist/esm/table/index.d.ts +24 -6
  8. package/dist/esm/table/index.js +101 -65
  9. package/dist/esm/table/index.js.map +1 -1
  10. package/dist/esm/table/models/table-layout-helper.d.ts +8 -0
  11. package/dist/esm/table/models/table-layout-helper.js +24 -0
  12. package/dist/esm/table/models/table-layout-helper.js.map +1 -0
  13. package/dist/esm/table/models/update-tracker.d.ts +26 -0
  14. package/dist/esm/table/models/update-tracker.js +106 -0
  15. package/dist/esm/table/models/update-tracker.js.map +1 -0
  16. package/dist/esm/table/models/virtualizer.js +1 -1
  17. package/dist/esm/table/styles.js +13 -3
  18. package/dist/esm/table/styles.js.map +1 -1
  19. package/dist/esm/table/template.js +11 -5
  20. package/dist/esm/table/template.js.map +1 -1
  21. package/dist/esm/table-column/base/index.d.ts +30 -0
  22. package/dist/esm/table-column/base/index.js +39 -1
  23. package/dist/esm/table-column/base/index.js.map +1 -1
  24. package/dist/esm/table-column/base/styles.js +6 -0
  25. package/dist/esm/table-column/base/styles.js.map +1 -1
  26. package/dist/esm/table-column/base/template.js +3 -1
  27. package/dist/esm/table-column/base/template.js.map +1 -1
  28. package/dist/esm/table-column/base/types.d.ts +2 -0
  29. package/dist/esm/table-column/base/types.js +2 -0
  30. package/dist/esm/table-column/base/types.js.map +1 -1
  31. package/dist/esm/table-column/mixins/fractional-width-column.d.ts +12 -0
  32. package/dist/esm/table-column/mixins/fractional-width-column.js +41 -0
  33. package/dist/esm/table-column/mixins/fractional-width-column.js.map +1 -0
  34. package/dist/esm/table-column/text/index.d.ts +16 -2
  35. package/dist/esm/table-column/text/index.js +14 -7
  36. package/dist/esm/table-column/text/index.js.map +1 -1
  37. package/package.json +1 -1
@@ -27175,6 +27175,8 @@
27175
27175
  */
27176
27176
  localeAwareCaseSensitive: 'localeAwareCaseSensitive'
27177
27177
  };
27178
+ const defaultMinPixelWidth = 88;
27179
+ const defaultFractionalWidth = 1;
27178
27180
 
27179
27181
  /**
27180
27182
  * The base class for table columns
@@ -27184,6 +27186,23 @@
27184
27186
  super();
27185
27187
  this.columnHidden = false;
27186
27188
  this.sortDirection = TableColumnSortDirection.none;
27189
+ /**
27190
+ * @internal
27191
+ * Used by the Table in order to size a column proportionally to the available
27192
+ * width of a row.
27193
+ */
27194
+ this.currentFractionalWidth = defaultFractionalWidth;
27195
+ /**
27196
+ * @internal
27197
+ * Used by column plugins to size a column proportionally to the available
27198
+ * width of a row. Sets currentFractionalWidth when changed.
27199
+ */
27200
+ this.internalFractionalWidth = defaultFractionalWidth;
27201
+ /**
27202
+ * @internal
27203
+ * The minimum size in pixels according to the design doc
27204
+ */
27205
+ this.internalMinPixelWidth = defaultMinPixelWidth;
27187
27206
  /**
27188
27207
  * @internal
27189
27208
  *
@@ -27206,6 +27225,12 @@
27206
27225
  super.connectedCallback();
27207
27226
  this.setAttribute('slot', this.internalUniqueId);
27208
27227
  }
27228
+ internalFractionalWidthChanged() {
27229
+ this.currentFractionalWidth = this.internalFractionalWidth;
27230
+ }
27231
+ internalPixelWidthChanged() {
27232
+ this.currentPixelWidth = this.internalPixelWidth;
27233
+ }
27209
27234
  }
27210
27235
  __decorate$1([
27211
27236
  attr({ attribute: 'column-id' })
@@ -27225,6 +27250,21 @@
27225
27250
  __decorate$1([
27226
27251
  attr({ attribute: 'sort-direction' })
27227
27252
  ], TableColumn.prototype, "sortDirection", void 0);
27253
+ __decorate$1([
27254
+ observable
27255
+ ], TableColumn.prototype, "currentPixelWidth", void 0);
27256
+ __decorate$1([
27257
+ observable
27258
+ ], TableColumn.prototype, "currentFractionalWidth", void 0);
27259
+ __decorate$1([
27260
+ observable
27261
+ ], TableColumn.prototype, "internalPixelWidth", void 0);
27262
+ __decorate$1([
27263
+ observable
27264
+ ], TableColumn.prototype, "internalFractionalWidth", void 0);
27265
+ __decorate$1([
27266
+ observable
27267
+ ], TableColumn.prototype, "internalMinPixelWidth", void 0);
27228
27268
  __decorate$1([
27229
27269
  observable
27230
27270
  ], TableColumn.prototype, "dataRecordFieldNames", void 0);
@@ -27333,6 +27373,7 @@
27333
27373
  }
27334
27374
 
27335
27375
  .table-container {
27376
+ overflow: hidden;
27336
27377
  display: flex;
27337
27378
  flex-direction: column;
27338
27379
  width: 100%;
@@ -27341,7 +27382,7 @@
27341
27382
  }
27342
27383
 
27343
27384
  .table-viewport {
27344
- overflow-y: auto;
27385
+ overflow: auto;
27345
27386
  display: block;
27346
27387
  height: 100%;
27347
27388
  position: relative;
@@ -27352,11 +27393,13 @@
27352
27393
  position: absolute;
27353
27394
  top: 0px;
27354
27395
  width: 100%;
27396
+ height: var(--ni-private-table-scroll-height);
27355
27397
  }
27356
27398
 
27357
27399
  .table-row-container {
27358
27400
  width: 100%;
27359
27401
  position: relative;
27402
+ top: var(--ni-private-table-row-container-top);
27360
27403
  }
27361
27404
 
27362
27405
  .header-container {
@@ -27365,10 +27408,17 @@
27365
27408
  }
27366
27409
 
27367
27410
  .header-row {
27368
- display: flex;
27369
- flex-direction: row;
27411
+ display: grid;
27370
27412
  background: ${applicationBackgroundColor};
27371
27413
  position: relative;
27414
+ width: fit-content;
27415
+ min-width: 100%;
27416
+ grid-template-columns: var(--ni-private-table-row-grid-columns) auto;
27417
+ left: var(--ni-private-table-scroll-x);
27418
+ }
27419
+
27420
+ .header-scrollbar-spacer {
27421
+ width: var(--ni-private-table-header-scrollbar-spacer-width);
27372
27422
  }
27373
27423
 
27374
27424
  .header {
@@ -27492,10 +27542,13 @@
27492
27542
  ${display('grid')}
27493
27543
 
27494
27544
  :host {
27495
- height: ${controlHeight};
27545
+ height: calc(${controlHeight} + 2 * ${borderWidth});
27496
27546
  border-top: calc(2 * ${borderWidth}) solid ${tableRowBorderColor};
27497
27547
  grid-auto-flow: column;
27498
27548
  grid-auto-columns: 1fr;
27549
+ grid-template-columns: var(--ni-private-table-row-grid-columns) auto;
27550
+ width: fit-content;
27551
+ min-width: 100%;
27499
27552
  }
27500
27553
 
27501
27554
  nimble-table-cell {
@@ -27735,7 +27788,13 @@
27735
27788
  // prettier-ignore
27736
27789
  const template$4 = html `
27737
27790
  <template role="table" ${children$1({ property: 'childItems', filter: elements() })}>
27738
- <div class="table-container">
27791
+ <div class="table-container" style="
27792
+ --ni-private-table-scroll-x: -${x => x.scrollX}px;
27793
+ --ni-private-table-header-scrollbar-spacer-width: ${x => x.virtualizer.headerContainerMarginRight}px;
27794
+ --ni-private-table-scroll-height: ${x => x.virtualizer.allRowsHeight}px;
27795
+ --ni-private-table-row-container-top: ${x => x.virtualizer.rowContainerYOffset}px;
27796
+ --ni-private-table-row-grid-columns: ${x => x.rowGridColumns ?? ''}
27797
+ ">
27739
27798
  <div role="rowgroup" class="header-container">
27740
27799
  <div class="header-row" role="row">
27741
27800
  ${repeat(x => x.columns, html `
@@ -27749,12 +27808,13 @@
27749
27808
  </${DesignSystem.tagFor(TableHeader)}>
27750
27809
  `)}
27751
27810
  `)}
27752
- <div class="header-scrollbar-spacer" style="width: ${x => x.virtualizer.headerContainerMarginRight}px;"></div>
27811
+ <div class="header-scrollbar-spacer"></div>
27753
27812
  </div>
27754
27813
  </div>
27755
27814
  <div class="table-viewport" ${ref('viewport')}>
27756
- <div class="table-scroll" style="height: ${x => x.virtualizer.allRowsHeight}px;"></div>
27757
- <div class="table-row-container" role="rowgroup" style="top: ${x => `${x.virtualizer.rowContainerYOffset}px;`}">
27815
+ <div class="table-scroll"></div>
27816
+ <div class="table-row-container"
27817
+ role="rowgroup">
27758
27818
  ${when(x => x.columns.length > 0 && x.canRenderRows, html `
27759
27819
  ${repeat(x => x.virtualizer.visibleItems, html `
27760
27820
  <${DesignSystem.tagFor(TableRow)}
@@ -27764,7 +27824,6 @@
27764
27824
  :columns="${(_, c) => c.parent.columns}"
27765
27825
  @row-action-menu-beforetoggle="${(_, c) => c.parent.onRowActionMenuBeforeToggle(c.event)}"
27766
27826
  @row-action-menu-toggle="${(_, c) => c.parent.onRowActionMenuToggle(c.event)}"
27767
- style="height: ${x => x.size}px;"
27768
27827
  >
27769
27828
  ${when((x, c) => c.parent.openActionMenuRecordId === c.parent.tableData[x.index]?.id, html `
27770
27829
  ${repeat((_, c) => c.parent.actionMenuSlots, html `
@@ -28426,7 +28485,7 @@
28426
28485
  // If we have enough rows that a vertical scrollbar is shown, we need to offset the header widths
28427
28486
  // by the same margin so the column headers align with the corresponding rendered cells
28428
28487
  const viewportBoundingWidth = borderBoxSize.inlineSize;
28429
- this.headerContainerMarginRight = viewportBoundingWidth - this.table.viewport.scrollWidth;
28488
+ this.headerContainerMarginRight = viewportBoundingWidth - this.table.viewport.clientWidth;
28430
28489
  }
28431
28490
  });
28432
28491
  }
@@ -28534,6 +28593,135 @@
28534
28593
  return 1;
28535
28594
  }
28536
28595
 
28596
+ const isColumnProperty = (changedProperty, ...args) => {
28597
+ for (const arg of args) {
28598
+ if (changedProperty === arg) {
28599
+ return true;
28600
+ }
28601
+ }
28602
+ return false;
28603
+ };
28604
+ /**
28605
+ * Helper class to track what updates are needed to the table based on configuration
28606
+ * changes.
28607
+ */
28608
+ class UpdateTracker {
28609
+ constructor(table) {
28610
+ this.requiredUpdates = {
28611
+ rowIds: false,
28612
+ columnIds: false,
28613
+ columnSort: false,
28614
+ columnWidths: false,
28615
+ columnDefinition: false,
28616
+ actionMenuSlots: false
28617
+ };
28618
+ this.updateQueued = false;
28619
+ this.table = table;
28620
+ }
28621
+ get updateRowIds() {
28622
+ return this.requiredUpdates.rowIds;
28623
+ }
28624
+ get updateColumnIds() {
28625
+ return this.requiredUpdates.columnIds;
28626
+ }
28627
+ get updateColumnSort() {
28628
+ return this.requiredUpdates.columnSort;
28629
+ }
28630
+ get updateColumnWidths() {
28631
+ return this.requiredUpdates.columnWidths;
28632
+ }
28633
+ get updateColumnDefinition() {
28634
+ return this.requiredUpdates.columnDefinition;
28635
+ }
28636
+ get updateActionMenuSlots() {
28637
+ return this.requiredUpdates.actionMenuSlots;
28638
+ }
28639
+ get requiresTanStackUpdate() {
28640
+ return (this.requiredUpdates.rowIds
28641
+ || this.requiredUpdates.columnSort
28642
+ || this.requiredUpdates.columnDefinition);
28643
+ }
28644
+ get requiresTanStackDataReset() {
28645
+ return (this.requiredUpdates.rowIds || this.requiredUpdates.columnDefinition);
28646
+ }
28647
+ trackAllStateChanged() {
28648
+ this.setAllKeys(true);
28649
+ this.queueUpdate();
28650
+ }
28651
+ trackColumnPropertyChanged(changedColumnProperty) {
28652
+ if (isColumnProperty(changedColumnProperty, 'columnId')) {
28653
+ this.requiredUpdates.columnIds = true;
28654
+ }
28655
+ else if (isColumnProperty(changedColumnProperty, 'operandDataRecordFieldName', 'sortOperation')) {
28656
+ this.requiredUpdates.columnDefinition = true;
28657
+ }
28658
+ else if (isColumnProperty(changedColumnProperty, 'sortIndex', 'sortDirection')) {
28659
+ this.requiredUpdates.columnSort = true;
28660
+ }
28661
+ else if (isColumnProperty(changedColumnProperty, 'currentFractionalWidth', 'currentPixelWidth', 'internalMinPixelWidth', 'columnHidden')) {
28662
+ this.requiredUpdates.columnWidths = true;
28663
+ }
28664
+ else if (isColumnProperty(changedColumnProperty, 'actionMenuSlot')) {
28665
+ this.requiredUpdates.actionMenuSlots = true;
28666
+ }
28667
+ this.queueUpdate();
28668
+ }
28669
+ trackColumnInstancesChanged() {
28670
+ this.requiredUpdates.columnIds = true;
28671
+ this.requiredUpdates.columnDefinition = true;
28672
+ this.requiredUpdates.columnSort = true;
28673
+ this.requiredUpdates.columnWidths = true;
28674
+ this.requiredUpdates.actionMenuSlots = true;
28675
+ this.queueUpdate();
28676
+ }
28677
+ trackIdFieldNameChanged() {
28678
+ this.requiredUpdates.rowIds = true;
28679
+ this.queueUpdate();
28680
+ }
28681
+ setAllKeys(value) {
28682
+ Object.keys(this.requiredUpdates).forEach(key => {
28683
+ this.requiredUpdates[key] = value;
28684
+ });
28685
+ }
28686
+ queueUpdate() {
28687
+ if (!this.table.$fastController.isConnected) {
28688
+ return;
28689
+ }
28690
+ if (!this.updateQueued) {
28691
+ this.updateQueued = true;
28692
+ DOM.queueUpdate(() => {
28693
+ this.table.update();
28694
+ this.setAllKeys(false);
28695
+ this.updateQueued = false;
28696
+ });
28697
+ }
28698
+ }
28699
+ }
28700
+
28701
+ /**
28702
+ * This class provides helper methods for managing the layout of cells within
28703
+ * a Table.
28704
+ */
28705
+ class TableLayoutHelper {
28706
+ static getGridTemplateColumns(columns) {
28707
+ return (columns
28708
+ ?.filter(column => !column.columnHidden)
28709
+ .reduce((accumulator, currentValue) => {
28710
+ const gap = accumulator === '' ? '' : ' ';
28711
+ const minPixelWidth = currentValue.internalMinPixelWidth;
28712
+ if (currentValue.currentPixelWidth) {
28713
+ const pixelWidth = currentValue.currentPixelWidth;
28714
+ const gridPixelWidth = pixelWidth > minPixelWidth
28715
+ ? pixelWidth
28716
+ : minPixelWidth;
28717
+ return `${accumulator}${gap}${gridPixelWidth}px`;
28718
+ }
28719
+ const fractionalWidth = currentValue.currentFractionalWidth;
28720
+ return `${accumulator}${gap}minmax(${minPixelWidth}px, ${fractionalWidth}fr)`;
28721
+ }, '') ?? '');
28722
+ }
28723
+ }
28724
+
28537
28725
  /**
28538
28726
  * A nimble-styled table.
28539
28727
  */
@@ -28560,8 +28748,16 @@
28560
28748
  * @internal
28561
28749
  */
28562
28750
  this.canRenderRows = true;
28751
+ /**
28752
+ * @internal
28753
+ */
28754
+ this.scrollX = 0;
28563
28755
  this.tableValidator = new TableValidator();
28756
+ this.updateTracker = new UpdateTracker(this);
28564
28757
  this.columnNotifiers = [];
28758
+ this.onViewPortScroll = (event) => {
28759
+ this.scrollX = event.target.scrollLeft;
28760
+ };
28565
28761
  this.options = {
28566
28762
  data: [],
28567
28763
  onStateChange: (_) => { },
@@ -28585,12 +28781,17 @@
28585
28781
  connectedCallback() {
28586
28782
  super.connectedCallback();
28587
28783
  this.virtualizer.connectedCallback();
28588
- this.validateAndObserveColumns();
28784
+ this.updateTracker.trackAllStateChanged();
28785
+ this.observeColumns();
28786
+ this.viewport.addEventListener('scroll', this.onViewPortScroll, {
28787
+ passive: true
28788
+ });
28589
28789
  }
28590
28790
  disconnectedCallback() {
28591
28791
  super.disconnectedCallback();
28592
28792
  this.virtualizer.disconnectedCallback();
28593
28793
  this.removeColumnObservers();
28794
+ this.viewport.removeEventListener('scroll', this.onViewPortScroll);
28594
28795
  }
28595
28796
  checkValidity() {
28596
28797
  return this.tableValidator.isValid();
@@ -28603,18 +28804,8 @@
28603
28804
  * is the string name of the property that changed on that column.
28604
28805
  */
28605
28806
  handleChange(source, args) {
28606
- if (source instanceof TableColumn) {
28607
- if (args === 'columnId') {
28608
- this.validateColumnIds();
28609
- }
28610
- else if (args === 'operandDataRecordFieldName'
28611
- || args === 'sortOperation') {
28612
- this.generateTanStackColumns();
28613
- }
28614
- else if (args === 'sortIndex' || args === 'sortDirection') {
28615
- this.validateColumnSortIndices();
28616
- this.setSortState();
28617
- }
28807
+ if (source instanceof TableColumn && typeof args === 'string') {
28808
+ this.updateTracker.trackColumnPropertyChanged(args);
28618
28809
  }
28619
28810
  }
28620
28811
  onRowActionMenuBeforeToggle(event) {
@@ -28624,28 +28815,33 @@
28624
28815
  onRowActionMenuToggle(event) {
28625
28816
  this.$emit('action-menu-toggle', event.detail);
28626
28817
  }
28627
- childItemsChanged() {
28628
- void this.updateColumnsFromChildItems();
28818
+ /**
28819
+ * @internal
28820
+ */
28821
+ update() {
28822
+ this.validate();
28823
+ if (this.updateTracker.requiresTanStackUpdate) {
28824
+ this.updateTanStack();
28825
+ }
28826
+ if (this.updateTracker.updateActionMenuSlots) {
28827
+ this.updateActionMenuSlots();
28828
+ }
28829
+ if (this.updateTracker.updateColumnWidths) {
28830
+ this.updateRowGridColumns();
28831
+ }
28629
28832
  }
28630
28833
  idFieldNameChanged(_prev, _next) {
28631
- // Force TanStack to detect a data update because a row's ID is only
28632
- // generated when creating a new row model.
28633
- this.setTableData(this.table.options.data);
28834
+ if (!this.$fastController.isConnected) {
28835
+ return;
28836
+ }
28837
+ this.updateTracker.trackIdFieldNameChanged();
28634
28838
  }
28635
28839
  columnsChanged(_prev, _next) {
28636
28840
  if (!this.$fastController.isConnected) {
28637
28841
  return;
28638
28842
  }
28639
- this.validateAndObserveColumns();
28640
- this.generateTanStackColumns();
28641
- this.setSortState();
28642
- const slots = new Set();
28643
- for (const column of this.columns) {
28644
- if (column.actionMenuSlot) {
28645
- slots.add(column.actionMenuSlot);
28646
- }
28647
- }
28648
- this.actionMenuSlots = Array.from(slots);
28843
+ this.observeColumns();
28844
+ this.updateTracker.trackColumnInstancesChanged();
28649
28845
  }
28650
28846
  removeColumnObservers() {
28651
28847
  this.columnNotifiers.forEach(notifier => {
@@ -28653,28 +28849,21 @@
28653
28849
  });
28654
28850
  this.columnNotifiers = [];
28655
28851
  }
28656
- validateAndObserveColumns() {
28852
+ observeColumns() {
28657
28853
  this.removeColumnObservers();
28658
28854
  for (const column of this.columns) {
28659
28855
  const notifier = Observable.getNotifier(column);
28660
28856
  notifier.subscribe(this);
28661
28857
  this.columnNotifiers.push(notifier);
28662
28858
  }
28663
- this.validateColumnIds();
28664
- this.validateColumnSortIndices();
28665
- }
28666
- validateColumnIds() {
28667
- this.tableValidator.validateColumnIds(this.columns.map(x => x.columnId));
28668
- this.canRenderRows = this.checkValidity();
28669
- }
28670
- validateColumnSortIndices() {
28671
- this.tableValidator.validateColumnSortIndices(this.getColumnsParticipatingInSorting().map(x => x.sortIndex));
28672
- this.canRenderRows = this.checkValidity();
28673
28859
  }
28674
28860
  getColumnsParticipatingInSorting() {
28675
28861
  return this.columns.filter(x => x.sortDirection !== TableColumnSortDirection.none
28676
28862
  && typeof x.sortIndex === 'number');
28677
28863
  }
28864
+ childItemsChanged() {
28865
+ void this.updateColumnsFromChildItems();
28866
+ }
28678
28867
  async updateColumnsFromChildItems() {
28679
28868
  const definedElements = this.childItems.map(async (item) => (item.matches(':not(:defined)')
28680
28869
  ? customElements.whenDefined(item.localName)
@@ -28682,18 +28871,53 @@
28682
28871
  await Promise.all(definedElements);
28683
28872
  this.columns = this.childItems.filter((x) => x instanceof TableColumn);
28684
28873
  }
28874
+ updateTanStack() {
28875
+ const updatedOptions = {
28876
+ state: {}
28877
+ };
28878
+ if (this.updateTracker.updateColumnSort) {
28879
+ updatedOptions.state.sorting = this.calculateTanStackSortState();
28880
+ }
28881
+ if (this.updateTracker.updateColumnDefinition) {
28882
+ updatedOptions.columns = this.calculateTanStackColumns();
28883
+ }
28884
+ if (this.updateTracker.updateRowIds) {
28885
+ updatedOptions.getRowId = this.calculateTanStackRowIdFunction();
28886
+ }
28887
+ if (this.updateTracker.requiresTanStackDataReset) {
28888
+ // Perform a shallow copy of the data to trigger tanstack to regenerate the row models and columns.
28889
+ updatedOptions.data = [...this.table.options.data];
28890
+ }
28891
+ this.updateTableOptions(updatedOptions);
28892
+ }
28893
+ updateActionMenuSlots() {
28894
+ const slots = new Set();
28895
+ for (const column of this.columns) {
28896
+ if (column.actionMenuSlot) {
28897
+ slots.add(column.actionMenuSlot);
28898
+ }
28899
+ }
28900
+ this.actionMenuSlots = Array.from(slots);
28901
+ }
28902
+ updateRowGridColumns() {
28903
+ this.rowGridColumns = TableLayoutHelper.getGridTemplateColumns(this.columns);
28904
+ }
28905
+ validate() {
28906
+ this.tableValidator.validateColumnIds(this.columns.map(x => x.columnId));
28907
+ this.tableValidator.validateColumnSortIndices(this.getColumnsParticipatingInSorting().map(x => x.sortIndex));
28908
+ this.validateWithData(this.table.options.data);
28909
+ }
28910
+ validateWithData(data) {
28911
+ this.tableValidator.validateRecordIds(data, this.idFieldName);
28912
+ this.canRenderRows = this.checkValidity();
28913
+ }
28685
28914
  setTableData(newData) {
28686
28915
  const data = newData.map(record => {
28687
28916
  return { ...record };
28688
28917
  });
28689
- this.tableValidator.validateRecordIds(data, this.idFieldName);
28690
- this.canRenderRows = this.checkValidity();
28691
- const getRowIdFunction = this.idFieldName === null || this.idFieldName === undefined
28692
- ? undefined
28693
- : (record) => record[this.idFieldName];
28918
+ this.validateWithData(data);
28694
28919
  this.updateTableOptions({
28695
- data,
28696
- getRowId: getRowIdFunction
28920
+ data
28697
28921
  });
28698
28922
  }
28699
28923
  refreshRows() {
@@ -28716,27 +28940,26 @@
28716
28940
  this.table.setOptions(this.options);
28717
28941
  this.refreshRows();
28718
28942
  }
28719
- setSortState() {
28943
+ calculateTanStackSortState() {
28720
28944
  const sortedColumns = this.getColumnsParticipatingInSorting().sort((x, y) => x.sortIndex - y.sortIndex);
28721
28945
  this.firstSortedColumn = sortedColumns.length
28722
28946
  ? sortedColumns[0]
28723
28947
  : undefined;
28724
- const tanStackSortingState = sortedColumns.map(column => {
28948
+ return sortedColumns.map(column => {
28725
28949
  return {
28726
28950
  id: column.internalUniqueId,
28727
- desc: column.sortDirection
28728
- === TableColumnSortDirection.descending
28951
+ desc: column.sortDirection === TableColumnSortDirection.descending
28729
28952
  };
28730
28953
  });
28731
- this.updateTableOptions({
28732
- state: {
28733
- sorting: tanStackSortingState
28734
- }
28735
- });
28736
28954
  }
28737
- generateTanStackColumns() {
28738
- const generatedColumns = this.columns.map(column => {
28739
- const columnDef = {
28955
+ calculateTanStackRowIdFunction() {
28956
+ return this.idFieldName === null || this.idFieldName === undefined
28957
+ ? undefined
28958
+ : (record) => record[this.idFieldName];
28959
+ }
28960
+ calculateTanStackColumns() {
28961
+ return this.columns.map(column => {
28962
+ return {
28740
28963
  id: column.internalUniqueId,
28741
28964
  accessorFn: (data) => {
28742
28965
  const fieldName = column.operandDataRecordFieldName;
@@ -28747,13 +28970,6 @@
28747
28970
  },
28748
28971
  sortingFn: getTanStackSortingFunction(column.sortOperation)
28749
28972
  };
28750
- return columnDef;
28751
- });
28752
- this.updateTableOptions({
28753
- // Force TanStack to detect a data update because a columns's accessor is
28754
- // referenced when creating a new row model.
28755
- data: [...this.table.options.data],
28756
- columns: generatedColumns
28757
28973
  });
28758
28974
  }
28759
28975
  }
@@ -28778,6 +28994,12 @@
28778
28994
  __decorate$1([
28779
28995
  observable
28780
28996
  ], Table.prototype, "canRenderRows", void 0);
28997
+ __decorate$1([
28998
+ observable
28999
+ ], Table.prototype, "scrollX", void 0);
29000
+ __decorate$1([
29001
+ observable
29002
+ ], Table.prototype, "rowGridColumns", void 0);
28781
29003
  __decorate$1([
28782
29004
  observable
28783
29005
  ], Table.prototype, "firstSortedColumn", void 0);
@@ -28793,14 +29015,61 @@
28793
29015
  :host {
28794
29016
  display: contents;
28795
29017
  }
29018
+
29019
+ .header-content {
29020
+ white-space: nowrap;
29021
+ overflow: hidden;
29022
+ text-overflow: ellipsis;
29023
+ }
28796
29024
  `;
28797
29025
 
28798
29026
  const template$3 = html `
28799
29027
  <template>
28800
- <slot></slot>
29028
+ <span class="header-content">
29029
+ <slot></slot>
29030
+ </span>
28801
29031
  </template>
28802
29032
  `;
28803
29033
 
29034
+ // As the returned class is internal to the function, we can't write a signature that uses is directly, so rely on inference
29035
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
29036
+ function mixinFractionalWidthColumnAPI(base) {
29037
+ /**
29038
+ * The Mixin that provides a concrete column with the API to support being resized
29039
+ * proportionally within a Table.
29040
+ */
29041
+ class FractionalWidthColumn extends base {
29042
+ constructor() {
29043
+ super(...arguments);
29044
+ this.fractionalWidth = defaultFractionalWidth;
29045
+ this.minPixelWidth = defaultMinPixelWidth;
29046
+ }
29047
+ fractionalWidthChanged() {
29048
+ if (typeof this.fractionalWidth === 'number') {
29049
+ this.internalFractionalWidth = this.fractionalWidth;
29050
+ }
29051
+ else {
29052
+ this.internalFractionalWidth = defaultFractionalWidth;
29053
+ }
29054
+ }
29055
+ minPixelWidthChanged() {
29056
+ if (typeof this.minPixelWidth === 'number') {
29057
+ this.internalMinPixelWidth = this.minPixelWidth;
29058
+ }
29059
+ else {
29060
+ this.internalMinPixelWidth = defaultMinPixelWidth;
29061
+ }
29062
+ }
29063
+ }
29064
+ attr({ attribute: 'fractional-width', converter: nullableNumberConverter })(
29065
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
29066
+ FractionalWidthColumn.prototype, 'fractionalWidth');
29067
+ attr({ attribute: 'min-pixel-width', converter: nullableNumberConverter })(
29068
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
29069
+ FractionalWidthColumn.prototype, 'minPixelWidth');
29070
+ return FractionalWidthColumn;
29071
+ }
29072
+
28804
29073
  const cellStyles = css `
28805
29074
  span {
28806
29075
  font: ${bodyFont};
@@ -28839,9 +29108,9 @@
28839
29108
  `;
28840
29109
 
28841
29110
  /**
28842
- * The table column for displaying strings.
29111
+ * The base class for a table column for displaying strings.
28843
29112
  */
28844
- class TableColumnText extends TableColumn {
29113
+ class TableColumnTextBase extends TableColumn {
28845
29114
  constructor() {
28846
29115
  super();
28847
29116
  this.cellRecordFieldNames = ['value'];
@@ -28859,10 +29128,15 @@
28859
29128
  }
28860
29129
  __decorate$1([
28861
29130
  attr({ attribute: 'field-name' })
28862
- ], TableColumnText.prototype, "fieldName", void 0);
29131
+ ], TableColumnTextBase.prototype, "fieldName", void 0);
28863
29132
  __decorate$1([
28864
29133
  attr
28865
- ], TableColumnText.prototype, "placeholder", void 0);
29134
+ ], TableColumnTextBase.prototype, "placeholder", void 0);
29135
+ /**
29136
+ * The table column for displaying strings.
29137
+ */
29138
+ class TableColumnText extends mixinFractionalWidthColumnAPI(TableColumnTextBase) {
29139
+ }
28866
29140
  const nimbleTableColumnText = TableColumnText.compose({
28867
29141
  baseName: 'table-column-text',
28868
29142
  template: template$3,