@ni/nimble-components 18.6.2 → 18.6.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.
Files changed (34) hide show
  1. package/dist/all-components-bundle.js +177 -15
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +618 -588
  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 +10 -0
  8. package/dist/esm/table/index.js +28 -0
  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/virtualizer.js +1 -1
  14. package/dist/esm/table/styles.js +13 -3
  15. package/dist/esm/table/styles.js.map +1 -1
  16. package/dist/esm/table/template.js +11 -5
  17. package/dist/esm/table/template.js.map +1 -1
  18. package/dist/esm/table-column/base/index.d.ts +30 -0
  19. package/dist/esm/table-column/base/index.js +39 -1
  20. package/dist/esm/table-column/base/index.js.map +1 -1
  21. package/dist/esm/table-column/base/styles.js +6 -0
  22. package/dist/esm/table-column/base/styles.js.map +1 -1
  23. package/dist/esm/table-column/base/template.js +3 -1
  24. package/dist/esm/table-column/base/template.js.map +1 -1
  25. package/dist/esm/table-column/base/types.d.ts +2 -0
  26. package/dist/esm/table-column/base/types.js +2 -0
  27. package/dist/esm/table-column/base/types.js.map +1 -1
  28. package/dist/esm/table-column/mixins/fractional-width-column.d.ts +12 -0
  29. package/dist/esm/table-column/mixins/fractional-width-column.js +41 -0
  30. package/dist/esm/table-column/mixins/fractional-width-column.js.map +1 -0
  31. package/dist/esm/table-column/text/index.d.ts +16 -2
  32. package/dist/esm/table-column/text/index.js +14 -7
  33. package/dist/esm/table-column/text/index.js.map +1 -1
  34. 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,30 @@
28534
28593
  return 1;
28535
28594
  }
28536
28595
 
28596
+ /**
28597
+ * This class provides helper methods for managing the layout of cells within
28598
+ * a Table.
28599
+ */
28600
+ class TableLayoutHelper {
28601
+ static getGridTemplateColumns(columns) {
28602
+ return (columns
28603
+ ?.filter(column => !column.columnHidden)
28604
+ .reduce((accumulator, currentValue) => {
28605
+ const gap = accumulator === '' ? '' : ' ';
28606
+ const minPixelWidth = currentValue.internalMinPixelWidth;
28607
+ if (currentValue.currentPixelWidth) {
28608
+ const pixelWidth = currentValue.currentPixelWidth;
28609
+ const gridPixelWidth = pixelWidth > minPixelWidth
28610
+ ? pixelWidth
28611
+ : minPixelWidth;
28612
+ return `${accumulator}${gap}${gridPixelWidth}px`;
28613
+ }
28614
+ const fractionalWidth = currentValue.currentFractionalWidth;
28615
+ return `${accumulator}${gap}minmax(${minPixelWidth}px, ${fractionalWidth}fr)`;
28616
+ }, '') ?? '');
28617
+ }
28618
+ }
28619
+
28537
28620
  /**
28538
28621
  * A nimble-styled table.
28539
28622
  */
@@ -28560,8 +28643,15 @@
28560
28643
  * @internal
28561
28644
  */
28562
28645
  this.canRenderRows = true;
28646
+ /**
28647
+ * @internal
28648
+ */
28649
+ this.scrollX = 0;
28563
28650
  this.tableValidator = new TableValidator();
28564
28651
  this.columnNotifiers = [];
28652
+ this.onViewPortScroll = (event) => {
28653
+ this.scrollX = event.target.scrollLeft;
28654
+ };
28565
28655
  this.options = {
28566
28656
  data: [],
28567
28657
  onStateChange: (_) => { },
@@ -28586,11 +28676,15 @@
28586
28676
  super.connectedCallback();
28587
28677
  this.virtualizer.connectedCallback();
28588
28678
  this.validateAndObserveColumns();
28679
+ this.viewport.addEventListener('scroll', this.onViewPortScroll, {
28680
+ passive: true
28681
+ });
28589
28682
  }
28590
28683
  disconnectedCallback() {
28591
28684
  super.disconnectedCallback();
28592
28685
  this.virtualizer.disconnectedCallback();
28593
28686
  this.removeColumnObservers();
28687
+ this.viewport.removeEventListener('scroll', this.onViewPortScroll);
28594
28688
  }
28595
28689
  checkValidity() {
28596
28690
  return this.tableValidator.isValid();
@@ -28615,6 +28709,12 @@
28615
28709
  this.validateColumnSortIndices();
28616
28710
  this.setSortState();
28617
28711
  }
28712
+ else if (args === 'currentFractionalWidth'
28713
+ || args === 'currentPixelWidth'
28714
+ || args === 'internalMinPixelWidth'
28715
+ || args === 'columnHidden') {
28716
+ this.updateRowGridColumns();
28717
+ }
28618
28718
  }
28619
28719
  }
28620
28720
  onRowActionMenuBeforeToggle(event) {
@@ -28646,6 +28746,7 @@
28646
28746
  }
28647
28747
  }
28648
28748
  this.actionMenuSlots = Array.from(slots);
28749
+ this.updateRowGridColumns();
28649
28750
  }
28650
28751
  removeColumnObservers() {
28651
28752
  this.columnNotifiers.forEach(notifier => {
@@ -28675,6 +28776,9 @@
28675
28776
  return this.columns.filter(x => x.sortDirection !== TableColumnSortDirection.none
28676
28777
  && typeof x.sortIndex === 'number');
28677
28778
  }
28779
+ updateRowGridColumns() {
28780
+ this.rowGridColumns = TableLayoutHelper.getGridTemplateColumns(this.columns);
28781
+ }
28678
28782
  async updateColumnsFromChildItems() {
28679
28783
  const definedElements = this.childItems.map(async (item) => (item.matches(':not(:defined)')
28680
28784
  ? customElements.whenDefined(item.localName)
@@ -28778,6 +28882,12 @@
28778
28882
  __decorate$1([
28779
28883
  observable
28780
28884
  ], Table.prototype, "canRenderRows", void 0);
28885
+ __decorate$1([
28886
+ observable
28887
+ ], Table.prototype, "scrollX", void 0);
28888
+ __decorate$1([
28889
+ observable
28890
+ ], Table.prototype, "rowGridColumns", void 0);
28781
28891
  __decorate$1([
28782
28892
  observable
28783
28893
  ], Table.prototype, "firstSortedColumn", void 0);
@@ -28793,14 +28903,61 @@
28793
28903
  :host {
28794
28904
  display: contents;
28795
28905
  }
28906
+
28907
+ .header-content {
28908
+ white-space: nowrap;
28909
+ overflow: hidden;
28910
+ text-overflow: ellipsis;
28911
+ }
28796
28912
  `;
28797
28913
 
28798
28914
  const template$3 = html `
28799
28915
  <template>
28800
- <slot></slot>
28916
+ <span class="header-content">
28917
+ <slot></slot>
28918
+ </span>
28801
28919
  </template>
28802
28920
  `;
28803
28921
 
28922
+ // As the returned class is internal to the function, we can't write a signature that uses is directly, so rely on inference
28923
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
28924
+ function mixinFractionalWidthColumnAPI(base) {
28925
+ /**
28926
+ * The Mixin that provides a concrete column with the API to support being resized
28927
+ * proportionally within a Table.
28928
+ */
28929
+ class FractionalWidthColumn extends base {
28930
+ constructor() {
28931
+ super(...arguments);
28932
+ this.fractionalWidth = defaultFractionalWidth;
28933
+ this.minPixelWidth = defaultMinPixelWidth;
28934
+ }
28935
+ fractionalWidthChanged() {
28936
+ if (typeof this.fractionalWidth === 'number') {
28937
+ this.internalFractionalWidth = this.fractionalWidth;
28938
+ }
28939
+ else {
28940
+ this.internalFractionalWidth = defaultFractionalWidth;
28941
+ }
28942
+ }
28943
+ minPixelWidthChanged() {
28944
+ if (typeof this.minPixelWidth === 'number') {
28945
+ this.internalMinPixelWidth = this.minPixelWidth;
28946
+ }
28947
+ else {
28948
+ this.internalMinPixelWidth = defaultMinPixelWidth;
28949
+ }
28950
+ }
28951
+ }
28952
+ attr({ attribute: 'fractional-width', converter: nullableNumberConverter })(
28953
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
28954
+ FractionalWidthColumn.prototype, 'fractionalWidth');
28955
+ attr({ attribute: 'min-pixel-width', converter: nullableNumberConverter })(
28956
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
28957
+ FractionalWidthColumn.prototype, 'minPixelWidth');
28958
+ return FractionalWidthColumn;
28959
+ }
28960
+
28804
28961
  const cellStyles = css `
28805
28962
  span {
28806
28963
  font: ${bodyFont};
@@ -28839,9 +28996,9 @@
28839
28996
  `;
28840
28997
 
28841
28998
  /**
28842
- * The table column for displaying strings.
28999
+ * The base class for a table column for displaying strings.
28843
29000
  */
28844
- class TableColumnText extends TableColumn {
29001
+ class TableColumnTextBase extends TableColumn {
28845
29002
  constructor() {
28846
29003
  super();
28847
29004
  this.cellRecordFieldNames = ['value'];
@@ -28859,10 +29016,15 @@
28859
29016
  }
28860
29017
  __decorate$1([
28861
29018
  attr({ attribute: 'field-name' })
28862
- ], TableColumnText.prototype, "fieldName", void 0);
29019
+ ], TableColumnTextBase.prototype, "fieldName", void 0);
28863
29020
  __decorate$1([
28864
29021
  attr
28865
- ], TableColumnText.prototype, "placeholder", void 0);
29022
+ ], TableColumnTextBase.prototype, "placeholder", void 0);
29023
+ /**
29024
+ * The table column for displaying strings.
29025
+ */
29026
+ class TableColumnText extends mixinFractionalWidthColumnAPI(TableColumnTextBase) {
29027
+ }
28866
29028
  const nimbleTableColumnText = TableColumnText.compose({
28867
29029
  baseName: 'table-column-text',
28868
29030
  template: template$3,