@ni/nimble-components 19.1.3 → 19.2.1

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 +120 -66
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +1723 -1723
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/table/index.d.ts +1 -1
  6. package/dist/esm/table/index.js +18 -18
  7. package/dist/esm/table/index.js.map +1 -1
  8. package/dist/esm/table/models/{update-tracker.d.ts → table-update-tracker.d.ts} +5 -4
  9. package/dist/esm/table/models/{update-tracker.js → table-update-tracker.js} +45 -48
  10. package/dist/esm/table/models/table-update-tracker.js.map +1 -0
  11. package/dist/esm/table-column/base/models/column-validator.d.ts +3 -7
  12. package/dist/esm/table-column/base/models/column-validator.js +12 -15
  13. package/dist/esm/table-column/base/models/column-validator.js.map +1 -1
  14. package/dist/esm/theme-provider/design-token-comments.js +2 -1
  15. package/dist/esm/theme-provider/design-token-comments.js.map +1 -1
  16. package/dist/esm/theme-provider/design-token-names.js +2 -1
  17. package/dist/esm/theme-provider/design-token-names.js.map +1 -1
  18. package/dist/esm/theme-provider/design-tokens.d.ts +1 -0
  19. package/dist/esm/theme-provider/design-tokens.js +1 -0
  20. package/dist/esm/theme-provider/design-tokens.js.map +1 -1
  21. package/dist/esm/utilities/models/tracker.d.ts +21 -0
  22. package/dist/esm/utilities/models/tracker.js +50 -0
  23. package/dist/esm/utilities/models/tracker.js.map +1 -0
  24. package/dist/esm/utilities/models/update-tracker.d.ts +7 -0
  25. package/dist/esm/utilities/models/update-tracker.js +7 -0
  26. package/dist/esm/utilities/models/update-tracker.js.map +1 -0
  27. package/dist/esm/utilities/models/validator.d.ts +9 -0
  28. package/dist/esm/utilities/models/validator.js +13 -0
  29. package/dist/esm/utilities/models/validator.js.map +1 -0
  30. package/dist/tokens-internal.scss +6 -0
  31. package/dist/tokens.scss +3 -0
  32. package/package.json +1 -1
  33. package/dist/esm/table/models/update-tracker.js.map +0 -1
@@ -16232,7 +16232,7 @@
16232
16232
 
16233
16233
  /**
16234
16234
  * Do not edit directly
16235
- * Generated on Thu, 01 Jun 2023 14:26:24 GMT
16235
+ * Generated on Mon, 12 Jun 2023 13:02:11 GMT
16236
16236
  */
16237
16237
  const Information100DarkUi = "#a46eff";
16238
16238
  const Information100LightUi = "#804ad9";
@@ -16560,7 +16560,8 @@
16560
16560
  tableRowBorderColor: 'table-row-border-color',
16561
16561
  elevation1BoxShadow: 'elevation-1-box-shadow',
16562
16562
  elevation2BoxShadow: 'elevation-2-box-shadow',
16563
- elevation3BoxShadow: 'elevation-3-box-shadow'
16563
+ elevation3BoxShadow: 'elevation-3-box-shadow',
16564
+ graphGridlineColor: 'graph-gridline-color'
16564
16565
  };
16565
16566
  const prefix = 'ni-nimble';
16566
16567
  const styleNameFromTokenName = (tokenName) => `${prefix}-${tokenName}`;
@@ -16710,6 +16711,7 @@
16710
16711
  const iconColor = DesignToken.create(styleNameFromTokenName(tokenNames.iconColor)).withDefault((element) => getColorForTheme(element, Black91, Black15, White));
16711
16712
  DesignToken.create(styleNameFromTokenName(tokenNames.modalBackdropColor)).withDefault((element) => getModalBackdropForTheme(element));
16712
16713
  const popupBorderColor = DesignToken.create(styleNameFromTokenName(tokenNames.popupBorderColor)).withDefault((element) => hexToRgbaCssColor(getColorForTheme(element, Black91, Black15, White), 0.3));
16714
+ DesignToken.create(styleNameFromTokenName(tokenNames.graphGridlineColor)).withDefault((element) => hexToRgbaCssColor(getColorForTheme(element, Black91, Black15, White), 0.2));
16713
16715
  DesignToken.create(styleNameFromTokenName(tokenNames.tooltipBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black85, ForestGreen));
16714
16716
  const tableRowBorderColor = DesignToken.create(styleNameFromTokenName(tokenNames.tableRowBorderColor)).withDefault((element) => getColorForTheme(element, Black15, Black80, ForestGreen));
16715
16717
  // Component Sizing Tokens
@@ -30058,6 +30060,62 @@
30058
30060
  return 1;
30059
30061
  }
30060
30062
 
30063
+ /**
30064
+ * Generic Tracker which sets or resets provided flags
30065
+ */
30066
+ class Tracker {
30067
+ constructor(trackedItemsList) {
30068
+ this.trackedItems = {};
30069
+ this.trackedItems = trackedItemsList.reduce((r, key) => {
30070
+ return {
30071
+ ...r,
30072
+ [key]: false
30073
+ };
30074
+ }, this.trackedItems);
30075
+ }
30076
+ getTrackedItems() {
30077
+ return { ...this.trackedItems };
30078
+ }
30079
+ isTracked(key) {
30080
+ return this.trackedItems[key];
30081
+ }
30082
+ track(key) {
30083
+ this.trackedItems[key] = true;
30084
+ }
30085
+ untrack(key) {
30086
+ this.trackedItems[key] = false;
30087
+ }
30088
+ trackAll() {
30089
+ this.setAllKeys(true);
30090
+ }
30091
+ untrackAll() {
30092
+ this.setAllKeys(false);
30093
+ }
30094
+ allTracked() {
30095
+ return Object.values(this.trackedItems).every(x => x);
30096
+ }
30097
+ anyTracked() {
30098
+ return Object.values(this.trackedItems).some(x => x);
30099
+ }
30100
+ noneTracked() {
30101
+ return Object.values(this.trackedItems).every(x => !x);
30102
+ }
30103
+ setAllKeys(value) {
30104
+ this.trackedItems = Object.keys(this.trackedItems).reduce((r, key) => {
30105
+ return {
30106
+ ...r,
30107
+ [key]: value
30108
+ };
30109
+ }, this.trackedItems);
30110
+ }
30111
+ }
30112
+
30113
+ /**
30114
+ * Generic Update Tracker Utility which extends Tracker Utility with update logic
30115
+ */
30116
+ class UpdateTracker extends Tracker {
30117
+ }
30118
+
30061
30119
  const isColumnProperty = (changedProperty, ...args) => {
30062
30120
  for (const arg of args) {
30063
30121
  if (changedProperty === arg) {
@@ -30074,61 +30132,62 @@
30074
30132
  }
30075
30133
  return false;
30076
30134
  };
30135
+ const trackedItems = [
30136
+ 'rowIds',
30137
+ 'groupRows',
30138
+ 'columnIds',
30139
+ 'columnSort',
30140
+ 'columnWidths',
30141
+ 'columnDefinition',
30142
+ 'actionMenuSlots',
30143
+ 'selectionMode'
30144
+ ];
30077
30145
  /**
30078
30146
  * Helper class to track what updates are needed to the table based on configuration
30079
30147
  * changes.
30080
30148
  */
30081
- class UpdateTracker {
30149
+ class TableUpdateTracker extends UpdateTracker {
30082
30150
  constructor(table) {
30083
- this.requiredUpdates = {
30084
- rowIds: false,
30085
- groupRows: false,
30086
- columnIds: false,
30087
- columnSort: false,
30088
- columnWidths: false,
30089
- columnDefinition: false,
30090
- actionMenuSlots: false,
30091
- selectionMode: false
30092
- };
30093
- this.updateQueued = false;
30151
+ super(trackedItems);
30094
30152
  this.table = table;
30153
+ this.updateQueued = false;
30095
30154
  }
30096
30155
  get updateRowIds() {
30097
- return this.requiredUpdates.rowIds;
30156
+ return this.isTracked('rowIds');
30098
30157
  }
30099
30158
  get updateGroupRows() {
30100
- return this.requiredUpdates.groupRows;
30159
+ return this.isTracked('groupRows');
30101
30160
  }
30102
30161
  get updateColumnIds() {
30103
- return this.requiredUpdates.columnIds;
30162
+ return this.isTracked('columnIds');
30104
30163
  }
30105
30164
  get updateColumnSort() {
30106
- return this.requiredUpdates.columnSort;
30165
+ return this.isTracked('columnSort');
30107
30166
  }
30108
30167
  get updateColumnWidths() {
30109
- return this.requiredUpdates.columnWidths;
30168
+ return this.isTracked('columnWidths');
30110
30169
  }
30111
30170
  get updateColumnDefinition() {
30112
- return this.requiredUpdates.columnDefinition;
30171
+ return this.isTracked('columnDefinition');
30113
30172
  }
30114
30173
  get updateActionMenuSlots() {
30115
- return this.requiredUpdates.actionMenuSlots;
30174
+ return this.isTracked('actionMenuSlots');
30116
30175
  }
30117
30176
  get updateSelectionMode() {
30118
- return this.requiredUpdates.selectionMode;
30177
+ return this.isTracked('selectionMode');
30119
30178
  }
30120
30179
  get requiresTanStackUpdate() {
30121
- return (this.requiredUpdates.rowIds
30122
- || this.requiredUpdates.columnSort
30123
- || this.requiredUpdates.columnDefinition
30124
- || this.requiredUpdates.groupRows
30125
- || this.requiredUpdates.selectionMode);
30180
+ return (this.isTracked('rowIds')
30181
+ || this.isTracked('columnSort')
30182
+ || this.isTracked('columnDefinition')
30183
+ || this.isTracked('groupRows')
30184
+ || this.isTracked('selectionMode'));
30126
30185
  }
30127
30186
  get requiresTanStackDataReset() {
30128
- return (this.requiredUpdates.rowIds || this.requiredUpdates.columnDefinition);
30187
+ return this.isTracked('rowIds') || this.isTracked('columnDefinition');
30129
30188
  }
30130
30189
  trackAllStateChanged() {
30131
- this.setAllKeys(true);
30190
+ this.trackAll();
30132
30191
  this.queueUpdate();
30133
30192
  }
30134
30193
  get hasPendingUpdates() {
@@ -30136,49 +30195,44 @@
30136
30195
  }
30137
30196
  trackColumnPropertyChanged(changedColumnProperty) {
30138
30197
  if (isColumnProperty(changedColumnProperty, 'columnId')) {
30139
- this.requiredUpdates.columnIds = true;
30198
+ this.track('columnIds');
30140
30199
  }
30141
30200
  else if (isColumnInternalsProperty(changedColumnProperty, 'operandDataRecordFieldName', 'sortOperation')) {
30142
- this.requiredUpdates.columnDefinition = true;
30201
+ this.track('columnDefinition');
30143
30202
  }
30144
30203
  else if (isColumnProperty(changedColumnProperty, 'sortingDisabled')
30145
30204
  || isColumnInternalsProperty(changedColumnProperty, 'currentSortDirection', 'currentSortIndex')) {
30146
- this.requiredUpdates.columnSort = true;
30205
+ this.track('columnSort');
30147
30206
  }
30148
30207
  else if (isColumnProperty(changedColumnProperty, 'columnHidden')
30149
30208
  || isColumnInternalsProperty(changedColumnProperty, 'currentFractionalWidth', 'currentPixelWidth', 'minPixelWidth')) {
30150
- this.requiredUpdates.columnWidths = true;
30209
+ this.track('columnWidths');
30151
30210
  }
30152
30211
  else if (isColumnProperty(changedColumnProperty, 'actionMenuSlot')) {
30153
- this.requiredUpdates.actionMenuSlots = true;
30212
+ this.track('actionMenuSlots');
30154
30213
  }
30155
30214
  else if (isColumnInternalsProperty(changedColumnProperty, 'groupIndex', 'groupingDisabled')) {
30156
- this.requiredUpdates.groupRows = true;
30215
+ this.track('groupRows');
30157
30216
  }
30158
30217
  this.queueUpdate();
30159
30218
  }
30160
30219
  trackColumnInstancesChanged() {
30161
- this.requiredUpdates.columnIds = true;
30162
- this.requiredUpdates.columnDefinition = true;
30163
- this.requiredUpdates.columnSort = true;
30164
- this.requiredUpdates.columnWidths = true;
30165
- this.requiredUpdates.actionMenuSlots = true;
30166
- this.requiredUpdates.groupRows = true;
30220
+ this.track('columnIds');
30221
+ this.track('columnDefinition');
30222
+ this.track('columnSort');
30223
+ this.track('columnWidths');
30224
+ this.track('actionMenuSlots');
30225
+ this.track('groupRows');
30167
30226
  this.queueUpdate();
30168
30227
  }
30169
30228
  trackIdFieldNameChanged() {
30170
- this.requiredUpdates.rowIds = true;
30229
+ this.track('rowIds');
30171
30230
  this.queueUpdate();
30172
30231
  }
30173
30232
  trackSelectionModeChanged() {
30174
- this.requiredUpdates.selectionMode = true;
30233
+ this.track('selectionMode');
30175
30234
  this.queueUpdate();
30176
30235
  }
30177
- setAllKeys(value) {
30178
- Object.keys(this.requiredUpdates).forEach(key => {
30179
- this.requiredUpdates[key] = value;
30180
- });
30181
- }
30182
30236
  queueUpdate() {
30183
30237
  if (!this.table.$fastController.isConnected) {
30184
30238
  return;
@@ -30187,7 +30241,7 @@
30187
30241
  this.updateQueued = true;
30188
30242
  DOM.queueUpdate(() => {
30189
30243
  this.table.update();
30190
- this.setAllKeys(false);
30244
+ this.untrackAll();
30191
30245
  this.updateQueued = false;
30192
30246
  });
30193
30247
  }
@@ -30521,7 +30575,7 @@
30521
30575
  */
30522
30576
  this.documentShiftKeyDown = false;
30523
30577
  this.tableValidator = new TableValidator();
30524
- this.updateTracker = new UpdateTracker(this);
30578
+ this.tableUpdateTracker = new TableUpdateTracker(this);
30525
30579
  this.columnNotifiers = [];
30526
30580
  this.isInitialized = false;
30527
30581
  this.collapsedRows = new Set();
@@ -30686,7 +30740,7 @@
30686
30740
  this.tableValidator.validateColumnConfigurations(this.columns);
30687
30741
  }
30688
30742
  else {
30689
- this.updateTracker.trackColumnPropertyChanged(args);
30743
+ this.tableUpdateTracker.trackColumnPropertyChanged(args);
30690
30744
  }
30691
30745
  }
30692
30746
  }
@@ -30786,16 +30840,16 @@
30786
30840
  */
30787
30841
  update() {
30788
30842
  this.validate();
30789
- if (this.updateTracker.requiresTanStackUpdate) {
30843
+ if (this.tableUpdateTracker.requiresTanStackUpdate) {
30790
30844
  this.updateTanStack();
30791
30845
  }
30792
- if (this.updateTracker.updateActionMenuSlots) {
30846
+ if (this.tableUpdateTracker.updateActionMenuSlots) {
30793
30847
  this.updateActionMenuSlots();
30794
30848
  }
30795
- if (this.updateTracker.updateColumnWidths) {
30849
+ if (this.tableUpdateTracker.updateColumnWidths) {
30796
30850
  this.updateRowGridColumns();
30797
30851
  }
30798
- if (this.updateTracker.updateGroupRows) {
30852
+ if (this.tableUpdateTracker.updateGroupRows) {
30799
30853
  this.showCollapseAll = this.getColumnsParticipatingInGrouping().length > 0;
30800
30854
  }
30801
30855
  }
@@ -30813,20 +30867,20 @@
30813
30867
  if (!this.$fastController.isConnected) {
30814
30868
  return;
30815
30869
  }
30816
- this.updateTracker.trackSelectionModeChanged();
30870
+ this.tableUpdateTracker.trackSelectionModeChanged();
30817
30871
  }
30818
30872
  idFieldNameChanged(_prev, _next) {
30819
30873
  if (!this.$fastController.isConnected) {
30820
30874
  return;
30821
30875
  }
30822
- this.updateTracker.trackIdFieldNameChanged();
30876
+ this.tableUpdateTracker.trackIdFieldNameChanged();
30823
30877
  }
30824
30878
  columnsChanged(_prev, _next) {
30825
30879
  if (!this.$fastController.isConnected) {
30826
30880
  return;
30827
30881
  }
30828
30882
  this.observeColumns();
30829
- this.updateTracker.trackColumnInstancesChanged();
30883
+ this.tableUpdateTracker.trackColumnInstancesChanged();
30830
30884
  }
30831
30885
  async handleActionMenuBeforeToggleEvent(rowIndex, event) {
30832
30886
  const selectionChanged = this.selectionManager.handleActionMenuOpening(this.tableData[rowIndex]);
@@ -30867,13 +30921,13 @@
30867
30921
  this.isInitialized = true;
30868
30922
  // Initialize the controller to ensure that FAST functionality such as Observables work as expected.
30869
30923
  this.$fastController.onConnectedCallback();
30870
- this.updateTracker.trackAllStateChanged();
30924
+ this.tableUpdateTracker.trackAllStateChanged();
30871
30925
  this.observeColumns();
30872
30926
  }
30873
30927
  async processPendingUpdates() {
30874
30928
  this.initialize();
30875
30929
  await DOM.nextUpdate();
30876
- if (this.updateTracker.hasPendingUpdates) {
30930
+ if (this.tableUpdateTracker.hasPendingUpdates) {
30877
30931
  throw new Error('Expected pending updates to be resolved');
30878
30932
  }
30879
30933
  }
@@ -30911,28 +30965,28 @@
30911
30965
  updateTanStack() {
30912
30966
  const updatedOptions = {};
30913
30967
  updatedOptions.state = {};
30914
- if (this.updateTracker.updateColumnSort) {
30968
+ if (this.tableUpdateTracker.updateColumnSort) {
30915
30969
  updatedOptions.state.sorting = this.calculateTanStackSortState();
30916
30970
  }
30917
- if (this.updateTracker.updateColumnDefinition) {
30971
+ if (this.tableUpdateTracker.updateColumnDefinition) {
30918
30972
  updatedOptions.columns = this.calculateTanStackColumns();
30919
30973
  }
30920
- if (this.updateTracker.updateRowIds) {
30974
+ if (this.tableUpdateTracker.updateRowIds) {
30921
30975
  updatedOptions.getRowId = this.calculateTanStackRowIdFunction();
30922
30976
  updatedOptions.state.rowSelection = {};
30923
30977
  this.selectionManager.handleSelectionReset();
30924
30978
  }
30925
- if (this.updateTracker.updateSelectionMode) {
30979
+ if (this.tableUpdateTracker.updateSelectionMode) {
30926
30980
  updatedOptions.enableMultiRowSelection = this.selectionMode === TableRowSelectionMode.multiple;
30927
30981
  updatedOptions.enableSubRowSelection = this.selectionMode === TableRowSelectionMode.multiple;
30928
30982
  updatedOptions.state.rowSelection = {};
30929
30983
  this.selectionManager.handleSelectionModeChanged(this.selectionMode);
30930
30984
  }
30931
- if (this.updateTracker.requiresTanStackDataReset) {
30985
+ if (this.tableUpdateTracker.requiresTanStackDataReset) {
30932
30986
  // Perform a shallow copy of the data to trigger tanstack to regenerate the row models and columns.
30933
30987
  updatedOptions.data = [...this.table.options.data];
30934
30988
  }
30935
- if (this.updateTracker.updateGroupRows) {
30989
+ if (this.tableUpdateTracker.updateGroupRows) {
30936
30990
  updatedOptions.state.grouping = this.calculateTanStackGroupingState();
30937
30991
  updatedOptions.state.expanded = true;
30938
30992
  this.collapsedRows.clear();