@ni/nimble-components 29.8.1 → 29.9.0

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 (33) hide show
  1. package/dist/all-components-bundle.js +157 -29
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +4261 -4258
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/table/index.d.ts +2 -1
  6. package/dist/esm/table/index.js +15 -14
  7. package/dist/esm/table/index.js.map +1 -1
  8. package/dist/esm/table/template.js +1 -1
  9. package/dist/esm/table/template.js.map +1 -1
  10. package/dist/esm/table/testing/table.pageobject.js +10 -4
  11. package/dist/esm/table/testing/table.pageobject.js.map +1 -1
  12. package/dist/esm/table-column/anchor/index.d.ts +23 -6
  13. package/dist/esm/table-column/anchor/index.js +14 -5
  14. package/dist/esm/table-column/anchor/index.js.map +1 -1
  15. package/dist/esm/table-column/anchor/models/table-column-anchor-validator.d.ts +8 -0
  16. package/dist/esm/table-column/anchor/models/table-column-anchor-validator.js +13 -0
  17. package/dist/esm/table-column/anchor/models/table-column-anchor-validator.js.map +1 -0
  18. package/dist/esm/table-column/base/models/column-validator.d.ts +1 -1
  19. package/dist/esm/table-column/base/models/column-validator.js +4 -4
  20. package/dist/esm/table-column/base/models/column-validator.js.map +1 -1
  21. package/dist/esm/table-column/mixins/custom-sort-order.d.ts +26 -0
  22. package/dist/esm/table-column/mixins/custom-sort-order.js +66 -0
  23. package/dist/esm/table-column/mixins/custom-sort-order.js.map +1 -0
  24. package/dist/esm/table-column/text/index.d.ts +24 -6
  25. package/dist/esm/table-column/text/index.js +20 -4
  26. package/dist/esm/table-column/text/index.js.map +1 -1
  27. package/dist/esm/table-column/text/models/table-column-text-validator.d.ts +8 -0
  28. package/dist/esm/table-column/text/models/table-column-text-validator.js +13 -0
  29. package/dist/esm/table-column/text/models/table-column-text-validator.js.map +1 -0
  30. package/dist/esm/utilities/models/tracker.d.ts +1 -0
  31. package/dist/esm/utilities/models/tracker.js +19 -2
  32. package/dist/esm/utilities/models/tracker.js.map +1 -1
  33. package/package.json +3 -3
@@ -16333,7 +16333,7 @@
16333
16333
 
16334
16334
  /**
16335
16335
  * Do not edit directly
16336
- * Generated on Thu, 11 Jul 2024 17:27:02 GMT
16336
+ * Generated on Mon, 15 Jul 2024 21:06:17 GMT
16337
16337
  */
16338
16338
 
16339
16339
  const Information100DarkUi = "#a46eff";
@@ -16755,7 +16755,6 @@
16755
16755
  const keyFunction2 = "F2";
16756
16756
  const keyPageDown = "PageDown";
16757
16757
  const keyPageUp = "PageUp";
16758
- const keyShift = "Shift";
16759
16758
  const keySpace = " ";
16760
16759
  const keyTab = "Tab";
16761
16760
 
@@ -54475,16 +54474,32 @@ img.ProseMirror-separator {
54475
54474
  return this.trackedItems[key];
54476
54475
  }
54477
54476
  track(key) {
54478
- this.trackedItems[key] = true;
54477
+ const wasTracked = this.trackedItems[key];
54478
+ if (!wasTracked) {
54479
+ this.trackedItems[key] = true;
54480
+ this.onTrackingChange();
54481
+ }
54479
54482
  }
54480
54483
  untrack(key) {
54481
- this.trackedItems[key] = false;
54484
+ const wasTracked = this.trackedItems[key];
54485
+ if (wasTracked) {
54486
+ this.trackedItems[key] = false;
54487
+ this.onTrackingChange();
54488
+ }
54482
54489
  }
54483
54490
  trackAll() {
54491
+ if (this.allTracked()) {
54492
+ return;
54493
+ }
54484
54494
  this.setAllKeys(true);
54495
+ this.onTrackingChange();
54485
54496
  }
54486
54497
  untrackAll() {
54498
+ if (this.noneTracked()) {
54499
+ return;
54500
+ }
54487
54501
  this.setAllKeys(false);
54502
+ this.onTrackingChange();
54488
54503
  }
54489
54504
  allTracked() {
54490
54505
  return Object.values(this.trackedItems).every(x => x);
@@ -54495,6 +54510,7 @@ img.ProseMirror-separator {
54495
54510
  noneTracked() {
54496
54511
  return Object.values(this.trackedItems).every(x => !x);
54497
54512
  }
54513
+ onTrackingChange() { }
54498
54514
  setAllKeys(value) {
54499
54515
  this.trackedItems = Object.keys(this.trackedItems).reduce((r, key) => {
54500
54516
  return {
@@ -66389,7 +66405,7 @@ focus outline in that case.
66389
66405
  aria-multiselectable="${x => x.ariaMultiSelectable}"
66390
66406
  ${children$1({ property: 'childItems', filter: elements() })}
66391
66407
  >
66392
- <div class="table-container ${x => (x.documentShiftKeyDown ? 'disable-select' : '')}"
66408
+ <div class="table-container ${x => (x.windowShiftKeyDown ? 'disable-select' : '')}"
66393
66409
  style="
66394
66410
  --ni-private-table-scroll-x: -${x => x.scrollX}px;
66395
66411
  --ni-private-table-header-container-margin-right: ${x => x.virtualizer.headerContainerMarginRight}px;
@@ -68458,6 +68474,10 @@ focus outline in that case.
68458
68474
  getValidity() {
68459
68475
  return this.getValidationFlags();
68460
68476
  }
68477
+ onTrackingChange() {
68478
+ super.onTrackingChange();
68479
+ this.isColumnValid = this.isValid();
68480
+ }
68461
68481
  /**
68462
68482
  * Sets a particular validity condition flag's value, e.g. "hasInvalidFooValue" = true
68463
68483
  */
@@ -68468,10 +68488,6 @@ focus outline in that case.
68468
68488
  else {
68469
68489
  this.untrack(name);
68470
68490
  }
68471
- this.updateColumnInternalsFlag();
68472
- }
68473
- updateColumnInternalsFlag() {
68474
- this.isColumnValid = this.isValid();
68475
68491
  }
68476
68492
  }
68477
68493
  __decorate$1([
@@ -69527,7 +69543,7 @@ focus outline in that case.
69527
69543
  * space through a column resize operation.
69528
69544
  */
69529
69545
  this.tableScrollableMinWidth = 0;
69530
- this.documentShiftKeyDown = false;
69546
+ this.windowShiftKeyDown = false;
69531
69547
  this.tableValidator = new TableValidator();
69532
69548
  this.tableUpdateTracker = new TableUpdateTracker(this);
69533
69549
  this.columnNotifiers = [];
@@ -69544,14 +69560,13 @@ focus outline in that case.
69544
69560
  this.scrollX = event.target.scrollLeft;
69545
69561
  };
69546
69562
  this.onKeyDown = (event) => {
69547
- if (event.key === keyShift) {
69548
- this.documentShiftKeyDown = true;
69549
- }
69563
+ this.windowShiftKeyDown = event.shiftKey;
69550
69564
  };
69551
69565
  this.onKeyUp = (event) => {
69552
- if (event.key === keyShift) {
69553
- this.documentShiftKeyDown = false;
69554
- }
69566
+ this.windowShiftKeyDown = event.shiftKey;
69567
+ };
69568
+ this.onBlur = () => {
69569
+ this.windowShiftKeyDown = false;
69555
69570
  };
69556
69571
  this.getRowCanExpand = (row) => {
69557
69572
  return this.expansionManager.isRowExpandable(row);
@@ -69649,16 +69664,18 @@ focus outline in that case.
69649
69664
  passive: true
69650
69665
  });
69651
69666
  this.keyboardNavigationManager.connect();
69652
- document.addEventListener('keydown', this.onKeyDown);
69653
- document.addEventListener('keyup', this.onKeyUp);
69667
+ window.addEventListener('keydown', this.onKeyDown);
69668
+ window.addEventListener('keyup', this.onKeyUp);
69669
+ window.addEventListener('blur', this.onBlur);
69654
69670
  }
69655
69671
  disconnectedCallback() {
69656
69672
  super.disconnectedCallback();
69657
69673
  this.virtualizer.disconnect();
69658
69674
  this.keyboardNavigationManager.disconnect();
69659
69675
  this.viewport.removeEventListener('scroll', this.onViewPortScroll);
69660
- document.removeEventListener('keydown', this.onKeyDown);
69661
- document.removeEventListener('keyup', this.onKeyUp);
69676
+ window.removeEventListener('keydown', this.onKeyDown);
69677
+ window.removeEventListener('keyup', this.onKeyUp);
69678
+ window.removeEventListener('blur', this.onBlur);
69662
69679
  }
69663
69680
  checkValidity() {
69664
69681
  return this.tableValidator.isValid();
@@ -69691,7 +69708,7 @@ focus outline in that case.
69691
69708
  /** @internal */
69692
69709
  onRowSelectionToggle(rowIndex, event) {
69693
69710
  event.stopImmediatePropagation();
69694
- const selectionChanged = this.selectionManager.handleRowSelectionToggle(this.tableData[rowIndex], event.detail.newState, this.documentShiftKeyDown);
69711
+ const selectionChanged = this.selectionManager.handleRowSelectionToggle(this.tableData[rowIndex], event.detail.newState, this.windowShiftKeyDown);
69695
69712
  if (selectionChanged) {
69696
69713
  void this.emitSelectionChangeEvent();
69697
69714
  }
@@ -70367,7 +70384,7 @@ focus outline in that case.
70367
70384
  ], Table$1.prototype, "tableScrollableMinWidth", void 0);
70368
70385
  __decorate$1([
70369
70386
  observable
70370
- ], Table$1.prototype, "documentShiftKeyDown", void 0);
70387
+ ], Table$1.prototype, "windowShiftKeyDown", void 0);
70371
70388
  const nimbleTable = Table$1.compose({
70372
70389
  baseName: 'table',
70373
70390
  template: template$g,
@@ -70760,25 +70777,105 @@ focus outline in that case.
70760
70777
  return SortableColumn;
70761
70778
  }
70762
70779
 
70780
+ // As the returned class is internal to the function, we can't write a signature that uses is directly, so rely on inference
70781
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
70782
+ function mixinCustomSortOrderColumnAPI(base) {
70783
+ /**
70784
+ * The Mixin that provides a concrete column with the API to allow sorting
70785
+ * by a field other than the default for that column.
70786
+ */
70787
+ class CustomSortOrderColumn extends base {
70788
+ constructor() {
70789
+ super(...arguments);
70790
+ /** @internal */
70791
+ this.customSortOrderColumnChangeHandler = {
70792
+ handleChange: this.handleCustomSortOrderColumnChange.bind(this)
70793
+ };
70794
+ }
70795
+ getResolvedOperandDataRecordFieldName(initialOperandFieldName) {
70796
+ return typeof this.sortByFieldName === 'string'
70797
+ ? this.sortByFieldName
70798
+ : initialOperandFieldName;
70799
+ }
70800
+ getResolvedSortOperation(initialSortOperation) {
70801
+ return typeof this.sortByFieldName === 'string'
70802
+ ? TableColumnSortOperation.basic
70803
+ : initialSortOperation;
70804
+ }
70805
+ /** @internal */
70806
+ sortByFieldNameChanged() {
70807
+ this.handleSortConfigurationChange();
70808
+ this.updateCustomColumnSortingValidity();
70809
+ if (typeof this.sortByFieldName === 'string'
70810
+ && !this.customSortOrderColumnNotifier) {
70811
+ this.customSortOrderColumnNotifier = Observable.getNotifier(this.columnInternals);
70812
+ this.customSortOrderColumnNotifier.subscribe(this.customSortOrderColumnChangeHandler);
70813
+ }
70814
+ else {
70815
+ this.customSortOrderColumnNotifier?.unsubscribe(this.customSortOrderColumnChangeHandler);
70816
+ this.customSortOrderColumnNotifier = undefined;
70817
+ }
70818
+ }
70819
+ /** @internal */
70820
+ handleCustomSortOrderColumnChange(_source, args) {
70821
+ if (args === 'groupingDisabled') {
70822
+ this.updateCustomColumnSortingValidity();
70823
+ }
70824
+ }
70825
+ /** @internal */
70826
+ updateCustomColumnSortingValidity() {
70827
+ const hasCustomColumnSorting = typeof this.sortByFieldName === 'string';
70828
+ const isGroupingEnabled = !this.columnInternals.groupingDisabled;
70829
+ const isValid = !isGroupingEnabled || !hasCustomColumnSorting;
70830
+ if (isValid) {
70831
+ this.columnInternals.validator.untrack('invalidCustomSortWithGrouping');
70832
+ }
70833
+ else {
70834
+ this.columnInternals.validator.track('invalidCustomSortWithGrouping');
70835
+ }
70836
+ }
70837
+ }
70838
+ attr({ attribute: 'sort-by-field-name' })(
70839
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
70840
+ CustomSortOrderColumn.prototype, 'sortByFieldName');
70841
+ return CustomSortOrderColumn;
70842
+ }
70843
+
70844
+ const columnAnchorValidityFlagNames = [
70845
+ 'invalidCustomSortWithGrouping'
70846
+ ];
70847
+ /**
70848
+ * Validator class for the anchor table column.
70849
+ */
70850
+ class TableColumnAnchorValidator extends ColumnValidator {
70851
+ constructor() {
70852
+ super(columnAnchorValidityFlagNames);
70853
+ }
70854
+ }
70855
+
70763
70856
  /**
70764
70857
  * A table column for displaying links.
70765
70858
  */
70766
- class TableColumnAnchor extends mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(mixinColumnWithPlaceholderAPI(mixinSortableColumnAPI((TableColumn))))) {
70859
+ class TableColumnAnchor extends mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(mixinColumnWithPlaceholderAPI(mixinSortableColumnAPI(mixinCustomSortOrderColumnAPI((TableColumn)))))) {
70767
70860
  constructor() {
70768
70861
  super(...arguments);
70769
70862
  this.underlineHidden = false;
70863
+ this.defaultSortOperation = TableColumnSortOperation.localeAwareCaseSensitive;
70770
70864
  }
70771
70865
  placeholderChanged() {
70772
70866
  this.updateColumnConfig();
70773
70867
  }
70868
+ handleSortConfigurationChange() {
70869
+ this.updateColumnInternalsSortConfiguration();
70870
+ }
70774
70871
  getColumnInternalsOptions() {
70775
70872
  return {
70776
70873
  cellRecordFieldNames: ['label', 'href'],
70777
70874
  cellViewTag: tableColumnAnchorCellViewTag,
70778
70875
  groupHeaderViewTag: tableColumnTextGroupHeaderViewTag,
70779
70876
  delegatedEvents: ['click'],
70780
- sortOperation: TableColumnSortOperation.localeAwareCaseSensitive,
70781
- validator: new ColumnValidator([])
70877
+ sortOperation: this.getResolvedSortOperation(this.defaultSortOperation),
70878
+ validator: new TableColumnAnchorValidator()
70782
70879
  };
70783
70880
  }
70784
70881
  labelFieldNameChanged() {
@@ -70786,7 +70883,7 @@ focus outline in that case.
70786
70883
  this.labelFieldName,
70787
70884
  this.hrefFieldName
70788
70885
  ];
70789
- this.columnInternals.operandDataRecordFieldName = this.labelFieldName;
70886
+ this.updateColumnInternalsSortConfiguration();
70790
70887
  }
70791
70888
  hrefFieldNameChanged() {
70792
70889
  this.columnInternals.dataRecordFieldNames = [
@@ -70835,6 +70932,10 @@ focus outline in that case.
70835
70932
  placeholder: this.placeholder
70836
70933
  };
70837
70934
  }
70935
+ updateColumnInternalsSortConfiguration() {
70936
+ this.columnInternals.operandDataRecordFieldName = this.getResolvedOperandDataRecordFieldName(this.labelFieldName);
70937
+ this.columnInternals.sortOperation = this.getResolvedSortOperation(this.defaultSortOperation);
70938
+ }
70838
70939
  }
70839
70940
  __decorate$1([
70840
70941
  attr({ attribute: 'label-field-name' })
@@ -72852,25 +72953,52 @@ focus outline in that case.
72852
72953
  DesignSystem.getOrCreate().withPrefix('nimble').register(textCellView());
72853
72954
  const tableColumnTextCellViewTag = 'nimble-table-column-text-cell-view';
72854
72955
 
72956
+ const columnTextValidityFlagNames = [
72957
+ 'invalidCustomSortWithGrouping'
72958
+ ];
72959
+ /**
72960
+ * Validator class for the text table column.
72961
+ */
72962
+ class TableColumnTextValidator extends ColumnValidator {
72963
+ constructor() {
72964
+ super(columnTextValidityFlagNames);
72965
+ }
72966
+ }
72967
+
72855
72968
  /**
72856
72969
  * The table column for displaying string fields as text.
72857
72970
  */
72858
- class TableColumnText extends mixinTextBase((TableColumnTextBase)) {
72971
+ class TableColumnText extends mixinCustomSortOrderColumnAPI(mixinTextBase((TableColumnTextBase))) {
72972
+ constructor() {
72973
+ super(...arguments);
72974
+ this.defaultSortOperation = TableColumnSortOperation.localeAwareCaseSensitive;
72975
+ }
72859
72976
  placeholderChanged() {
72860
72977
  this.columnInternals.columnConfig = {
72861
72978
  placeholder: this.placeholder
72862
72979
  };
72863
72980
  }
72981
+ handleSortConfigurationChange() {
72982
+ this.updateColumnInternalsSortConfiguration();
72983
+ }
72864
72984
  getColumnInternalsOptions() {
72865
72985
  return {
72866
72986
  cellRecordFieldNames: ['value'],
72867
72987
  cellViewTag: tableColumnTextCellViewTag,
72868
72988
  groupHeaderViewTag: tableColumnTextGroupHeaderViewTag,
72869
72989
  delegatedEvents: [],
72870
- sortOperation: TableColumnSortOperation.localeAwareCaseSensitive,
72871
- validator: new ColumnValidator([])
72990
+ sortOperation: this.getResolvedSortOperation(this.defaultSortOperation),
72991
+ validator: new TableColumnTextValidator()
72872
72992
  };
72873
72993
  }
72994
+ fieldNameChanged() {
72995
+ this.columnInternals.dataRecordFieldNames = [this.fieldName];
72996
+ this.updateColumnInternalsSortConfiguration();
72997
+ }
72998
+ updateColumnInternalsSortConfiguration() {
72999
+ this.columnInternals.operandDataRecordFieldName = this.getResolvedOperandDataRecordFieldName(this.fieldName);
73000
+ this.columnInternals.sortOperation = this.getResolvedSortOperation(this.defaultSortOperation);
73001
+ }
72874
73002
  }
72875
73003
  const nimbleTableColumnText = TableColumnText.compose({
72876
73004
  baseName: 'table-column-text',