@ni/nimble-components 18.13.1 → 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.
Files changed (48) hide show
  1. package/dist/all-components-bundle.js +152 -24
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +2298 -2281
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/anchor-tree-item/styles.js +2 -1
  6. package/dist/esm/anchor-tree-item/styles.js.map +1 -1
  7. package/dist/esm/checkbox/styles.js +2 -1
  8. package/dist/esm/checkbox/styles.js.map +1 -1
  9. package/dist/esm/combobox/styles.js +2 -1
  10. package/dist/esm/combobox/styles.js.map +1 -1
  11. package/dist/esm/icon-base/styles.js +2 -1
  12. package/dist/esm/icon-base/styles.js.map +1 -1
  13. package/dist/esm/number-field/styles.js +3 -2
  14. package/dist/esm/number-field/styles.js.map +1 -1
  15. package/dist/esm/patterns/dropdown/styles.js +2 -1
  16. package/dist/esm/patterns/dropdown/styles.js.map +1 -1
  17. package/dist/esm/table/components/group-row/styles.js +3 -2
  18. package/dist/esm/table/components/group-row/styles.js.map +1 -1
  19. package/dist/esm/table/components/header/styles.js +1 -0
  20. package/dist/esm/table/components/header/styles.js.map +1 -1
  21. package/dist/esm/table/index.d.ts +10 -0
  22. package/dist/esm/table/index.js +72 -5
  23. package/dist/esm/table/index.js.map +1 -1
  24. package/dist/esm/table/models/update-tracker.js +2 -1
  25. package/dist/esm/table/models/update-tracker.js.map +1 -1
  26. package/dist/esm/table/styles.js +5 -0
  27. package/dist/esm/table/styles.js.map +1 -1
  28. package/dist/esm/table/template.js +4 -2
  29. package/dist/esm/table/template.js.map +1 -1
  30. package/dist/esm/table/testing/table.pageobject.d.ts +1 -0
  31. package/dist/esm/table/testing/table.pageobject.js +8 -0
  32. package/dist/esm/table/testing/table.pageobject.js.map +1 -1
  33. package/dist/esm/table-column/base/index.d.ts +4 -0
  34. package/dist/esm/table-column/base/index.js +29 -0
  35. package/dist/esm/table-column/base/index.js.map +1 -1
  36. package/dist/esm/table-column/base/models/column-internals.d.ts +11 -1
  37. package/dist/esm/table-column/base/models/column-internals.js +6 -0
  38. package/dist/esm/table-column/base/models/column-internals.js.map +1 -1
  39. package/dist/esm/text-area/styles.js +2 -1
  40. package/dist/esm/text-area/styles.js.map +1 -1
  41. package/dist/esm/text-field/styles.js +4 -4
  42. package/dist/esm/text-field/styles.js.map +1 -1
  43. package/dist/esm/tree-item/styles.js +2 -1
  44. package/dist/esm/tree-item/styles.js.map +1 -1
  45. package/dist/esm/utilities/style/user-select.d.ts +5 -0
  46. package/dist/esm/utilities/style/user-select.js +10 -0
  47. package/dist/esm/utilities/style/user-select.js.map +1 -0
  48. package/package.json +1 -1
@@ -2618,6 +2618,16 @@
2618
2618
  }
2619
2619
  }
2620
2620
  }
2621
+ /**
2622
+ * Transforms a template literal string into partial CSS.
2623
+ * @param strings - The string fragments that are interpolated with the values.
2624
+ * @param values - The values that are interpolated with the string fragments.
2625
+ * @public
2626
+ */
2627
+ function cssPartial(strings, ...values) {
2628
+ const { styles, behaviors } = collectStyles(strings, values);
2629
+ return new CSSPartial(styles, behaviors);
2630
+ }
2621
2631
 
2622
2632
  /** @internal */
2623
2633
  function newSplice(index, removed, addedCount) {
@@ -16356,7 +16366,7 @@
16356
16366
 
16357
16367
  /**
16358
16368
  * Do not edit directly
16359
- * Generated on Fri, 05 May 2023 15:11:52 GMT
16369
+ * Generated on Fri, 05 May 2023 21:29:53 GMT
16360
16370
  */
16361
16371
  const Information100DarkUi = "#a46eff";
16362
16372
  const Information100LightUi = "#804ad9";
@@ -16707,6 +16717,7 @@
16707
16717
  const keyEnter = "Enter";
16708
16718
  const keyEscape = "Escape";
16709
16719
  const keyHome = "Home";
16720
+ const keyShift = "Shift";
16710
16721
  const keySpace = " ";
16711
16722
 
16712
16723
  /**
@@ -18210,6 +18221,15 @@
18210
18221
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleAnchorTabs());
18211
18222
  DesignSystem.tagFor(AnchorTabs);
18212
18223
 
18224
+ /**
18225
+ * Set user-select: none in a way that works across all supported browsers.
18226
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/user-select#browser_compatibility
18227
+ */
18228
+ const userSelectNone = cssPartial `
18229
+ user-select: none;
18230
+ -webkit-user-select: none;
18231
+ `;
18232
+
18213
18233
  const styles$H = css `
18214
18234
  ${display('block')}
18215
18235
 
@@ -18277,7 +18297,7 @@
18277
18297
  padding-left: 10px;
18278
18298
  font: inherit;
18279
18299
  font-size: ${bodyFontSize};
18280
- user-select: none;
18300
+ ${userSelectNone}
18281
18301
  position: relative;
18282
18302
  margin-inline-start: ${iconSize};
18283
18303
  }
@@ -19420,7 +19440,7 @@
19420
19440
 
19421
19441
  :host {
19422
19442
  align-items: center;
19423
- user-select: none;
19443
+ ${userSelectNone}
19424
19444
  width: ${iconSize};
19425
19445
  height: ${iconSize};
19426
19446
  }
@@ -19965,7 +19985,7 @@
19965
19985
  align-items: center;
19966
19986
  cursor: pointer;
19967
19987
  outline: none;
19968
- user-select: none;
19988
+ ${userSelectNone}
19969
19989
  }
19970
19990
 
19971
19991
  :host([disabled]) {
@@ -20227,7 +20247,7 @@
20227
20247
  height: ${controlHeight};
20228
20248
  position: relative;
20229
20249
  justify-content: center;
20230
- user-select: none;
20250
+ ${userSelectNone}
20231
20251
  min-width: 250px;
20232
20252
  outline: none;
20233
20253
  vertical-align: top;
@@ -20501,7 +20521,7 @@
20501
20521
 
20502
20522
  :host([disabled]) *,
20503
20523
  :host([disabled]) {
20504
- user-select: none;
20524
+ ${userSelectNone}
20505
20525
  color: ${bodyDisabledFontColor};
20506
20526
  }
20507
20527
 
@@ -23676,7 +23696,7 @@
23676
23696
  :host {
23677
23697
  font: ${bodyFont};
23678
23698
  outline: none;
23679
- user-select: none;
23699
+ ${userSelectNone}
23680
23700
  color: ${bodyFontColor};
23681
23701
  --ni-private-hover-indicator-width: calc(${borderWidth} + 1px);
23682
23702
  --ni-private-height-within-border: calc(
@@ -23728,7 +23748,7 @@
23728
23748
  content: ' ';
23729
23749
  color: transparent;
23730
23750
  width: 0px;
23731
- user-select: none;
23751
+ ${userSelectNone}
23732
23752
  }
23733
23753
 
23734
23754
  .root::after {
@@ -28043,6 +28063,12 @@
28043
28063
  __decorate$1([
28044
28064
  observable
28045
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);
28046
28072
 
28047
28073
  /**
28048
28074
  * The base class for table columns
@@ -28052,10 +28078,36 @@
28052
28078
  super();
28053
28079
  this.columnHidden = false;
28054
28080
  this.sortDirection = TableColumnSortDirection.none;
28081
+ this.sortingDisabled = false;
28055
28082
  if (!options) {
28056
28083
  throw new Error('ColumnInternalsOptions must be provided to constructor');
28057
28084
  }
28058
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
+ }
28059
28111
  }
28060
28112
  }
28061
28113
  __decorate$1([
@@ -28076,6 +28128,9 @@
28076
28128
  __decorate$1([
28077
28129
  attr({ attribute: 'sort-direction' })
28078
28130
  ], TableColumn.prototype, "sortDirection", void 0);
28131
+ __decorate$1([
28132
+ attr({ attribute: 'sorting-disabled', mode: 'boolean' })
28133
+ ], TableColumn.prototype, "sortingDisabled", void 0);
28079
28134
 
28080
28135
  /**
28081
28136
  * Helper class for the nimble-table to validate that the table's configuration
@@ -28195,6 +28250,10 @@
28195
28250
  height: 480px;
28196
28251
  }
28197
28252
 
28253
+ .disable-select {
28254
+ ${userSelectNone}
28255
+ }
28256
+
28198
28257
  .table-container {
28199
28258
  overflow: hidden;
28200
28259
  display: flex;
@@ -28306,6 +28365,7 @@
28306
28365
  ${iconColor.cssCustomProperty}: ${tableHeaderFontColor};
28307
28366
  text-transform: uppercase;
28308
28367
  gap: calc(${standardPadding} / 2);
28368
+ cursor: default;
28309
28369
  }
28310
28370
 
28311
28371
  .sort-indicator,
@@ -28814,7 +28874,7 @@
28814
28874
 
28815
28875
  .group-header-view {
28816
28876
  padding-left: calc(${standardPadding} / 2);
28817
- user-select: none;
28877
+ ${userSelectNone}
28818
28878
  overflow: hidden;
28819
28879
  display: flex;
28820
28880
  }
@@ -28822,7 +28882,7 @@
28822
28882
  .group-row-child-count {
28823
28883
  padding-left: 2px;
28824
28884
  pointer-events: none;
28825
- user-select: none;
28885
+ ${userSelectNone}
28826
28886
  }
28827
28887
 
28828
28888
  @media (prefers-reduced-motion) {
@@ -28997,7 +29057,8 @@
28997
29057
  aria-multiselectable="${x => x.ariaMultiSelectable}"
28998
29058
  ${children$1({ property: 'childItems', filter: elements() })}
28999
29059
  >
29000
- <div class="table-container" style="
29060
+ <div class="table-container ${x => (x.documentShiftKeyDown ? 'disable-select' : '')}"
29061
+ style="
29001
29062
  --ni-private-table-scroll-x: -${x => x.scrollX}px;
29002
29063
  --ni-private-table-header-scrollbar-spacer-width: ${x => x.virtualizer.headerContainerMarginRight}px;
29003
29064
  --ni-private-table-scroll-height: ${x => x.virtualizer.allRowsHeight}px;
@@ -29031,8 +29092,9 @@
29031
29092
  ${when(x => !x.columnHidden, html `
29032
29093
  <${tableHeaderTag}
29033
29094
  class="header"
29034
- 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)}"
29035
29096
  ?first-sorted-column="${(x, c) => x === c.parent.firstSortedColumn}"
29097
+ @click="${(x, c) => c.parent.toggleColumnSort(x, c.event.shiftKey)}"
29036
29098
  :isGrouped=${x => (typeof x.columnInternals.groupIndex === 'number' && !x.columnInternals.groupingDisabled)}
29037
29099
  >
29038
29100
  <slot name="${x => x.slot}"></slot>
@@ -29952,7 +30014,8 @@
29952
30014
  else if (isColumnInternalsProperty(changedColumnProperty, 'operandDataRecordFieldName', 'sortOperation')) {
29953
30015
  this.requiredUpdates.columnDefinition = true;
29954
30016
  }
29955
- else if (isColumnProperty(changedColumnProperty, 'sortIndex', 'sortDirection')) {
30017
+ else if (isColumnProperty(changedColumnProperty, 'sortingDisabled')
30018
+ || isColumnInternalsProperty(changedColumnProperty, 'currentSortDirection', 'currentSortIndex')) {
29956
30019
  this.requiredUpdates.columnSort = true;
29957
30020
  }
29958
30021
  else if (isColumnProperty(changedColumnProperty, 'columnHidden')
@@ -30067,6 +30130,10 @@
30067
30130
  * @internal
30068
30131
  */
30069
30132
  this.showCollapseAll = false;
30133
+ /**
30134
+ * @internal
30135
+ */
30136
+ this.documentShiftKeyDown = false;
30070
30137
  this.tableValidator = new TableValidator();
30071
30138
  this.updateTracker = new UpdateTracker(this);
30072
30139
  this.columnNotifiers = [];
@@ -30080,6 +30147,16 @@
30080
30147
  this.onViewPortScroll = (event) => {
30081
30148
  this.scrollX = event.target.scrollLeft;
30082
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
+ };
30083
30160
  this.getIsRowExpanded = (row) => {
30084
30161
  if (!row.getIsGrouped()) {
30085
30162
  return false;
@@ -30194,11 +30271,15 @@
30194
30271
  this.viewport.addEventListener('scroll', this.onViewPortScroll, {
30195
30272
  passive: true
30196
30273
  });
30274
+ document.addEventListener('keydown', this.onKeyDown);
30275
+ document.addEventListener('keyup', this.onKeyUp);
30197
30276
  }
30198
30277
  disconnectedCallback() {
30199
30278
  super.disconnectedCallback();
30200
30279
  this.virtualizer.disconnectedCallback();
30201
30280
  this.viewport.removeEventListener('scroll', this.onViewPortScroll);
30281
+ document.removeEventListener('keydown', this.onKeyDown);
30282
+ document.removeEventListener('keyup', this.onKeyUp);
30202
30283
  }
30203
30284
  checkValidity() {
30204
30285
  return this.tableValidator.isValid();
@@ -30275,6 +30356,47 @@
30275
30356
  this.toggleGroupExpanded(rowIndex);
30276
30357
  event.stopPropagation();
30277
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
+ }
30278
30400
  /**
30279
30401
  * @internal
30280
30402
  */
@@ -30389,8 +30511,10 @@
30389
30511
  }
30390
30512
  }
30391
30513
  getColumnsParticipatingInSorting() {
30392
- return this.columns.filter(x => x.sortDirection !== TableColumnSortDirection.none
30393
- && 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');
30394
30518
  }
30395
30519
  getColumnsParticipatingInGrouping() {
30396
30520
  return this.columns.filter(x => !x.columnInternals.groupingDisabled
@@ -30450,7 +30574,7 @@
30450
30574
  validate() {
30451
30575
  this.tableValidator.validateSelectionMode(this.selectionMode, this.idFieldName);
30452
30576
  this.tableValidator.validateColumnIds(this.columns.map(x => x.columnId));
30453
- this.tableValidator.validateColumnSortIndices(this.getColumnsParticipatingInSorting().map(x => x.sortIndex));
30577
+ this.tableValidator.validateColumnSortIndices(this.getColumnsParticipatingInSorting().map(x => x.columnInternals.currentSortIndex));
30454
30578
  this.tableValidator.validateColumnGroupIndices(this.getColumnsParticipatingInGrouping().map(x => x.columnInternals.groupIndex));
30455
30579
  this.validateWithData(this.table.options.data);
30456
30580
  }
@@ -30614,14 +30738,16 @@
30614
30738
  row.toggleExpanded();
30615
30739
  }
30616
30740
  calculateTanStackSortState() {
30617
- 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);
30618
30743
  this.firstSortedColumn = sortedColumns.length
30619
30744
  ? sortedColumns[0]
30620
30745
  : undefined;
30621
30746
  return sortedColumns.map(column => {
30622
30747
  return {
30623
30748
  id: column.columnInternals.uniqueId,
30624
- desc: column.sortDirection === TableColumnSortDirection.descending
30749
+ desc: column.columnInternals.currentSortDirection
30750
+ === TableColumnSortDirection.descending
30625
30751
  };
30626
30752
  });
30627
30753
  }
@@ -30710,6 +30836,9 @@
30710
30836
  __decorate$1([
30711
30837
  observable
30712
30838
  ], Table.prototype, "firstSortedColumn", void 0);
30839
+ __decorate$1([
30840
+ observable
30841
+ ], Table.prototype, "documentShiftKeyDown", void 0);
30713
30842
  const nimbleTable = Table.compose({
30714
30843
  baseName: 'table',
30715
30844
  template: template$9,
@@ -31298,7 +31427,7 @@
31298
31427
  :host {
31299
31428
  font: ${bodyFont};
31300
31429
  outline: none;
31301
- user-select: none;
31430
+ ${userSelectNone}
31302
31431
  color: ${bodyFontColor};
31303
31432
  flex-direction: column;
31304
31433
  vertical-align: top;
@@ -31644,8 +31773,7 @@
31644
31773
  :host {
31645
31774
  font: ${bodyFont};
31646
31775
  outline: none;
31647
- user-select: none;
31648
- --webkit-user-select: none;
31776
+ ${userSelectNone}
31649
31777
  color: ${bodyFontColor};
31650
31778
  --ni-private-hover-indicator-width: calc(${borderWidth} + 1px);
31651
31779
  --ni-private-height-within-border: calc(
@@ -31707,7 +31835,7 @@
31707
31835
  content: ' ';
31708
31836
  color: transparent;
31709
31837
  width: 0px;
31710
- user-select: none;
31838
+ ${userSelectNone}
31711
31839
  }
31712
31840
 
31713
31841
  :host([appearance='frameless'][full-bleed]) .root::before {
@@ -31719,7 +31847,7 @@
31719
31847
  content: ' ';
31720
31848
  color: transparent;
31721
31849
  width: 0px;
31722
- user-select: none;
31850
+ ${userSelectNone}
31723
31851
  }
31724
31852
 
31725
31853
  :host([appearance='frameless'][full-bleed]) .root::after {
@@ -32264,7 +32392,7 @@
32264
32392
  padding-left: 10px;
32265
32393
  font: inherit;
32266
32394
  font-size: ${bodyFontSize};
32267
- user-select: none;
32395
+ ${userSelectNone}
32268
32396
  position: relative;
32269
32397
  margin-inline-start: ${iconSize};
32270
32398
  }