@ni/nimble-components 18.13.2 → 18.13.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.
@@ -16366,7 +16366,7 @@
16366
16366
 
16367
16367
  /**
16368
16368
  * Do not edit directly
16369
- * Generated on Fri, 05 May 2023 20:05:11 GMT
16369
+ * Generated on Fri, 05 May 2023 21:29:53 GMT
16370
16370
  */
16371
16371
  const Information100DarkUi = "#a46eff";
16372
16372
  const Information100LightUi = "#804ad9";
@@ -16717,6 +16717,7 @@
16717
16717
  const keyEnter = "Enter";
16718
16718
  const keyEscape = "Escape";
16719
16719
  const keyHome = "Home";
16720
+ const keyShift = "Shift";
16720
16721
  const keySpace = " ";
16721
16722
 
16722
16723
  /**
@@ -28062,6 +28063,12 @@
28062
28063
  __decorate$1([
28063
28064
  observable
28064
28065
  ], ColumnInternals.prototype, "currentPixelWidth", void 0);
28066
+ __decorate$1([
28067
+ observable
28068
+ ], ColumnInternals.prototype, "currentSortIndex", void 0);
28069
+ __decorate$1([
28070
+ observable
28071
+ ], ColumnInternals.prototype, "currentSortDirection", void 0);
28065
28072
 
28066
28073
  /**
28067
28074
  * The base class for table columns
@@ -28071,10 +28078,36 @@
28071
28078
  super();
28072
28079
  this.columnHidden = false;
28073
28080
  this.sortDirection = TableColumnSortDirection.none;
28081
+ this.sortingDisabled = false;
28074
28082
  if (!options) {
28075
28083
  throw new Error('ColumnInternalsOptions must be provided to constructor');
28076
28084
  }
28077
28085
  this.columnInternals = new ColumnInternals(options);
28086
+ this.columnInternals.currentSortDirection = this.sortDirection;
28087
+ this.columnInternals.currentSortIndex = this.sortIndex;
28088
+ }
28089
+ sortDirectionChanged() {
28090
+ if (!this.sortingDisabled) {
28091
+ this.columnInternals.currentSortDirection = this.sortDirection;
28092
+ }
28093
+ }
28094
+ sortIndexChanged() {
28095
+ if (!this.sortingDisabled) {
28096
+ this.columnInternals.currentSortIndex = this.sortIndex;
28097
+ }
28098
+ }
28099
+ sortingDisabledChanged() {
28100
+ // Ignore the default value sortingDisabled initialization from undefined to false (which runs before columnInternals is initialized)
28101
+ if (this.columnInternals) {
28102
+ if (this.sortingDisabled) {
28103
+ this.columnInternals.currentSortDirection = TableColumnSortDirection.none;
28104
+ this.columnInternals.currentSortIndex = undefined;
28105
+ }
28106
+ else {
28107
+ this.columnInternals.currentSortDirection = this.sortDirection;
28108
+ this.columnInternals.currentSortIndex = this.sortIndex;
28109
+ }
28110
+ }
28078
28111
  }
28079
28112
  }
28080
28113
  __decorate$1([
@@ -28095,6 +28128,9 @@
28095
28128
  __decorate$1([
28096
28129
  attr({ attribute: 'sort-direction' })
28097
28130
  ], TableColumn.prototype, "sortDirection", void 0);
28131
+ __decorate$1([
28132
+ attr({ attribute: 'sorting-disabled', mode: 'boolean' })
28133
+ ], TableColumn.prototype, "sortingDisabled", void 0);
28098
28134
 
28099
28135
  /**
28100
28136
  * Helper class for the nimble-table to validate that the table's configuration
@@ -28214,6 +28250,10 @@
28214
28250
  height: 480px;
28215
28251
  }
28216
28252
 
28253
+ .disable-select {
28254
+ ${userSelectNone}
28255
+ }
28256
+
28217
28257
  .table-container {
28218
28258
  overflow: hidden;
28219
28259
  display: flex;
@@ -28325,6 +28365,7 @@
28325
28365
  ${iconColor.cssCustomProperty}: ${tableHeaderFontColor};
28326
28366
  text-transform: uppercase;
28327
28367
  gap: calc(${standardPadding} / 2);
28368
+ cursor: default;
28328
28369
  }
28329
28370
 
28330
28371
  .sort-indicator,
@@ -29016,7 +29057,8 @@
29016
29057
  aria-multiselectable="${x => x.ariaMultiSelectable}"
29017
29058
  ${children$1({ property: 'childItems', filter: elements() })}
29018
29059
  >
29019
- <div class="table-container" style="
29060
+ <div class="table-container ${x => (x.documentShiftKeyDown ? 'disable-select' : '')}"
29061
+ style="
29020
29062
  --ni-private-table-scroll-x: -${x => x.scrollX}px;
29021
29063
  --ni-private-table-header-scrollbar-spacer-width: ${x => x.virtualizer.headerContainerMarginRight}px;
29022
29064
  --ni-private-table-scroll-height: ${x => x.virtualizer.allRowsHeight}px;
@@ -29050,8 +29092,9 @@
29050
29092
  ${when(x => !x.columnHidden, html `
29051
29093
  <${tableHeaderTag}
29052
29094
  class="header"
29053
- sort-direction="${x => (typeof x.sortIndex === 'number' ? x.sortDirection : TableColumnSortDirection.none)}"
29095
+ sort-direction="${x => (typeof x.columnInternals.currentSortIndex === 'number' ? x.columnInternals.currentSortDirection : TableColumnSortDirection.none)}"
29054
29096
  ?first-sorted-column="${(x, c) => x === c.parent.firstSortedColumn}"
29097
+ @click="${(x, c) => c.parent.toggleColumnSort(x, c.event.shiftKey)}"
29055
29098
  :isGrouped=${x => (typeof x.columnInternals.groupIndex === 'number' && !x.columnInternals.groupingDisabled)}
29056
29099
  >
29057
29100
  <slot name="${x => x.slot}"></slot>
@@ -29971,7 +30014,8 @@
29971
30014
  else if (isColumnInternalsProperty(changedColumnProperty, 'operandDataRecordFieldName', 'sortOperation')) {
29972
30015
  this.requiredUpdates.columnDefinition = true;
29973
30016
  }
29974
- else if (isColumnProperty(changedColumnProperty, 'sortIndex', 'sortDirection')) {
30017
+ else if (isColumnProperty(changedColumnProperty, 'sortingDisabled')
30018
+ || isColumnInternalsProperty(changedColumnProperty, 'currentSortDirection', 'currentSortIndex')) {
29975
30019
  this.requiredUpdates.columnSort = true;
29976
30020
  }
29977
30021
  else if (isColumnProperty(changedColumnProperty, 'columnHidden')
@@ -30086,6 +30130,10 @@
30086
30130
  * @internal
30087
30131
  */
30088
30132
  this.showCollapseAll = false;
30133
+ /**
30134
+ * @internal
30135
+ */
30136
+ this.documentShiftKeyDown = false;
30089
30137
  this.tableValidator = new TableValidator();
30090
30138
  this.updateTracker = new UpdateTracker(this);
30091
30139
  this.columnNotifiers = [];
@@ -30099,6 +30147,16 @@
30099
30147
  this.onViewPortScroll = (event) => {
30100
30148
  this.scrollX = event.target.scrollLeft;
30101
30149
  };
30150
+ this.onKeyDown = (event) => {
30151
+ if (event.key === keyShift) {
30152
+ this.documentShiftKeyDown = true;
30153
+ }
30154
+ };
30155
+ this.onKeyUp = (event) => {
30156
+ if (event.key === keyShift) {
30157
+ this.documentShiftKeyDown = false;
30158
+ }
30159
+ };
30102
30160
  this.getIsRowExpanded = (row) => {
30103
30161
  if (!row.getIsGrouped()) {
30104
30162
  return false;
@@ -30213,11 +30271,15 @@
30213
30271
  this.viewport.addEventListener('scroll', this.onViewPortScroll, {
30214
30272
  passive: true
30215
30273
  });
30274
+ document.addEventListener('keydown', this.onKeyDown);
30275
+ document.addEventListener('keyup', this.onKeyUp);
30216
30276
  }
30217
30277
  disconnectedCallback() {
30218
30278
  super.disconnectedCallback();
30219
30279
  this.virtualizer.disconnectedCallback();
30220
30280
  this.viewport.removeEventListener('scroll', this.onViewPortScroll);
30281
+ document.removeEventListener('keydown', this.onKeyDown);
30282
+ document.removeEventListener('keyup', this.onKeyUp);
30221
30283
  }
30222
30284
  checkValidity() {
30223
30285
  return this.tableValidator.isValid();
@@ -30294,6 +30356,47 @@
30294
30356
  this.toggleGroupExpanded(rowIndex);
30295
30357
  event.stopPropagation();
30296
30358
  }
30359
+ /**
30360
+ * @internal
30361
+ */
30362
+ toggleColumnSort(column, allowMultiSort) {
30363
+ if (column.sortingDisabled) {
30364
+ return;
30365
+ }
30366
+ const allSortedColumns = this.getColumnsParticipatingInSorting().sort((x, y) => x.columnInternals.currentSortIndex
30367
+ - y.columnInternals.currentSortIndex);
30368
+ const columnIndex = allSortedColumns.indexOf(column);
30369
+ const columnAlreadySorted = columnIndex > -1;
30370
+ const oldSortDirection = column.columnInternals.currentSortDirection;
30371
+ let newSortDirection = TableColumnSortDirection.ascending;
30372
+ if (columnAlreadySorted) {
30373
+ if (oldSortDirection === TableColumnSortDirection.descending) {
30374
+ allSortedColumns.splice(columnIndex, 1);
30375
+ newSortDirection = TableColumnSortDirection.none;
30376
+ column.columnInternals.currentSortIndex = undefined;
30377
+ }
30378
+ else {
30379
+ newSortDirection = TableColumnSortDirection.descending;
30380
+ }
30381
+ }
30382
+ else {
30383
+ allSortedColumns.push(column);
30384
+ }
30385
+ column.columnInternals.currentSortDirection = newSortDirection;
30386
+ for (let i = 0; i < allSortedColumns.length; i++) {
30387
+ const currentColumn = allSortedColumns[i];
30388
+ if (allowMultiSort) {
30389
+ allSortedColumns[i].columnInternals.currentSortIndex = i;
30390
+ }
30391
+ else if (currentColumn === column) {
30392
+ currentColumn.columnInternals.currentSortIndex = 0;
30393
+ }
30394
+ else {
30395
+ currentColumn.columnInternals.currentSortIndex = undefined;
30396
+ currentColumn.columnInternals.currentSortDirection = TableColumnSortDirection.none;
30397
+ }
30398
+ }
30399
+ }
30297
30400
  /**
30298
30401
  * @internal
30299
30402
  */
@@ -30408,8 +30511,10 @@
30408
30511
  }
30409
30512
  }
30410
30513
  getColumnsParticipatingInSorting() {
30411
- return this.columns.filter(x => x.sortDirection !== TableColumnSortDirection.none
30412
- && typeof x.sortIndex === 'number');
30514
+ return this.columns.filter(x => !x.sortingDisabled
30515
+ && x.columnInternals.currentSortDirection
30516
+ !== TableColumnSortDirection.none
30517
+ && typeof x.columnInternals.currentSortIndex === 'number');
30413
30518
  }
30414
30519
  getColumnsParticipatingInGrouping() {
30415
30520
  return this.columns.filter(x => !x.columnInternals.groupingDisabled
@@ -30469,7 +30574,7 @@
30469
30574
  validate() {
30470
30575
  this.tableValidator.validateSelectionMode(this.selectionMode, this.idFieldName);
30471
30576
  this.tableValidator.validateColumnIds(this.columns.map(x => x.columnId));
30472
- this.tableValidator.validateColumnSortIndices(this.getColumnsParticipatingInSorting().map(x => x.sortIndex));
30577
+ this.tableValidator.validateColumnSortIndices(this.getColumnsParticipatingInSorting().map(x => x.columnInternals.currentSortIndex));
30473
30578
  this.tableValidator.validateColumnGroupIndices(this.getColumnsParticipatingInGrouping().map(x => x.columnInternals.groupIndex));
30474
30579
  this.validateWithData(this.table.options.data);
30475
30580
  }
@@ -30633,14 +30738,16 @@
30633
30738
  row.toggleExpanded();
30634
30739
  }
30635
30740
  calculateTanStackSortState() {
30636
- const sortedColumns = this.getColumnsParticipatingInSorting().sort((x, y) => x.sortIndex - y.sortIndex);
30741
+ const sortedColumns = this.getColumnsParticipatingInSorting().sort((x, y) => x.columnInternals.currentSortIndex
30742
+ - y.columnInternals.currentSortIndex);
30637
30743
  this.firstSortedColumn = sortedColumns.length
30638
30744
  ? sortedColumns[0]
30639
30745
  : undefined;
30640
30746
  return sortedColumns.map(column => {
30641
30747
  return {
30642
30748
  id: column.columnInternals.uniqueId,
30643
- desc: column.sortDirection === TableColumnSortDirection.descending
30749
+ desc: column.columnInternals.currentSortDirection
30750
+ === TableColumnSortDirection.descending
30644
30751
  };
30645
30752
  });
30646
30753
  }
@@ -30729,6 +30836,9 @@
30729
30836
  __decorate$1([
30730
30837
  observable
30731
30838
  ], Table.prototype, "firstSortedColumn", void 0);
30839
+ __decorate$1([
30840
+ observable
30841
+ ], Table.prototype, "documentShiftKeyDown", void 0);
30732
30842
  const nimbleTable = Table.compose({
30733
30843
  baseName: 'table',
30734
30844
  template: template$9,