@ni/nimble-components 19.2.0 → 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.
@@ -16232,7 +16232,7 @@
16232
16232
 
16233
16233
  /**
16234
16234
  * Do not edit directly
16235
- * Generated on Fri, 02 Jun 2023 07:34:22 GMT
16235
+ * Generated on Mon, 12 Jun 2023 13:02:11 GMT
16236
16236
  */
16237
16237
  const Information100DarkUi = "#a46eff";
16238
16238
  const Information100LightUi = "#804ad9";
@@ -30060,6 +30060,62 @@
30060
30060
  return 1;
30061
30061
  }
30062
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
+
30063
30119
  const isColumnProperty = (changedProperty, ...args) => {
30064
30120
  for (const arg of args) {
30065
30121
  if (changedProperty === arg) {
@@ -30076,61 +30132,62 @@
30076
30132
  }
30077
30133
  return false;
30078
30134
  };
30135
+ const trackedItems = [
30136
+ 'rowIds',
30137
+ 'groupRows',
30138
+ 'columnIds',
30139
+ 'columnSort',
30140
+ 'columnWidths',
30141
+ 'columnDefinition',
30142
+ 'actionMenuSlots',
30143
+ 'selectionMode'
30144
+ ];
30079
30145
  /**
30080
30146
  * Helper class to track what updates are needed to the table based on configuration
30081
30147
  * changes.
30082
30148
  */
30083
- class UpdateTracker {
30149
+ class TableUpdateTracker extends UpdateTracker {
30084
30150
  constructor(table) {
30085
- this.requiredUpdates = {
30086
- rowIds: false,
30087
- groupRows: false,
30088
- columnIds: false,
30089
- columnSort: false,
30090
- columnWidths: false,
30091
- columnDefinition: false,
30092
- actionMenuSlots: false,
30093
- selectionMode: false
30094
- };
30095
- this.updateQueued = false;
30151
+ super(trackedItems);
30096
30152
  this.table = table;
30153
+ this.updateQueued = false;
30097
30154
  }
30098
30155
  get updateRowIds() {
30099
- return this.requiredUpdates.rowIds;
30156
+ return this.isTracked('rowIds');
30100
30157
  }
30101
30158
  get updateGroupRows() {
30102
- return this.requiredUpdates.groupRows;
30159
+ return this.isTracked('groupRows');
30103
30160
  }
30104
30161
  get updateColumnIds() {
30105
- return this.requiredUpdates.columnIds;
30162
+ return this.isTracked('columnIds');
30106
30163
  }
30107
30164
  get updateColumnSort() {
30108
- return this.requiredUpdates.columnSort;
30165
+ return this.isTracked('columnSort');
30109
30166
  }
30110
30167
  get updateColumnWidths() {
30111
- return this.requiredUpdates.columnWidths;
30168
+ return this.isTracked('columnWidths');
30112
30169
  }
30113
30170
  get updateColumnDefinition() {
30114
- return this.requiredUpdates.columnDefinition;
30171
+ return this.isTracked('columnDefinition');
30115
30172
  }
30116
30173
  get updateActionMenuSlots() {
30117
- return this.requiredUpdates.actionMenuSlots;
30174
+ return this.isTracked('actionMenuSlots');
30118
30175
  }
30119
30176
  get updateSelectionMode() {
30120
- return this.requiredUpdates.selectionMode;
30177
+ return this.isTracked('selectionMode');
30121
30178
  }
30122
30179
  get requiresTanStackUpdate() {
30123
- return (this.requiredUpdates.rowIds
30124
- || this.requiredUpdates.columnSort
30125
- || this.requiredUpdates.columnDefinition
30126
- || this.requiredUpdates.groupRows
30127
- || this.requiredUpdates.selectionMode);
30180
+ return (this.isTracked('rowIds')
30181
+ || this.isTracked('columnSort')
30182
+ || this.isTracked('columnDefinition')
30183
+ || this.isTracked('groupRows')
30184
+ || this.isTracked('selectionMode'));
30128
30185
  }
30129
30186
  get requiresTanStackDataReset() {
30130
- return (this.requiredUpdates.rowIds || this.requiredUpdates.columnDefinition);
30187
+ return this.isTracked('rowIds') || this.isTracked('columnDefinition');
30131
30188
  }
30132
30189
  trackAllStateChanged() {
30133
- this.setAllKeys(true);
30190
+ this.trackAll();
30134
30191
  this.queueUpdate();
30135
30192
  }
30136
30193
  get hasPendingUpdates() {
@@ -30138,49 +30195,44 @@
30138
30195
  }
30139
30196
  trackColumnPropertyChanged(changedColumnProperty) {
30140
30197
  if (isColumnProperty(changedColumnProperty, 'columnId')) {
30141
- this.requiredUpdates.columnIds = true;
30198
+ this.track('columnIds');
30142
30199
  }
30143
30200
  else if (isColumnInternalsProperty(changedColumnProperty, 'operandDataRecordFieldName', 'sortOperation')) {
30144
- this.requiredUpdates.columnDefinition = true;
30201
+ this.track('columnDefinition');
30145
30202
  }
30146
30203
  else if (isColumnProperty(changedColumnProperty, 'sortingDisabled')
30147
30204
  || isColumnInternalsProperty(changedColumnProperty, 'currentSortDirection', 'currentSortIndex')) {
30148
- this.requiredUpdates.columnSort = true;
30205
+ this.track('columnSort');
30149
30206
  }
30150
30207
  else if (isColumnProperty(changedColumnProperty, 'columnHidden')
30151
30208
  || isColumnInternalsProperty(changedColumnProperty, 'currentFractionalWidth', 'currentPixelWidth', 'minPixelWidth')) {
30152
- this.requiredUpdates.columnWidths = true;
30209
+ this.track('columnWidths');
30153
30210
  }
30154
30211
  else if (isColumnProperty(changedColumnProperty, 'actionMenuSlot')) {
30155
- this.requiredUpdates.actionMenuSlots = true;
30212
+ this.track('actionMenuSlots');
30156
30213
  }
30157
30214
  else if (isColumnInternalsProperty(changedColumnProperty, 'groupIndex', 'groupingDisabled')) {
30158
- this.requiredUpdates.groupRows = true;
30215
+ this.track('groupRows');
30159
30216
  }
30160
30217
  this.queueUpdate();
30161
30218
  }
30162
30219
  trackColumnInstancesChanged() {
30163
- this.requiredUpdates.columnIds = true;
30164
- this.requiredUpdates.columnDefinition = true;
30165
- this.requiredUpdates.columnSort = true;
30166
- this.requiredUpdates.columnWidths = true;
30167
- this.requiredUpdates.actionMenuSlots = true;
30168
- 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');
30169
30226
  this.queueUpdate();
30170
30227
  }
30171
30228
  trackIdFieldNameChanged() {
30172
- this.requiredUpdates.rowIds = true;
30229
+ this.track('rowIds');
30173
30230
  this.queueUpdate();
30174
30231
  }
30175
30232
  trackSelectionModeChanged() {
30176
- this.requiredUpdates.selectionMode = true;
30233
+ this.track('selectionMode');
30177
30234
  this.queueUpdate();
30178
30235
  }
30179
- setAllKeys(value) {
30180
- Object.keys(this.requiredUpdates).forEach(key => {
30181
- this.requiredUpdates[key] = value;
30182
- });
30183
- }
30184
30236
  queueUpdate() {
30185
30237
  if (!this.table.$fastController.isConnected) {
30186
30238
  return;
@@ -30189,7 +30241,7 @@
30189
30241
  this.updateQueued = true;
30190
30242
  DOM.queueUpdate(() => {
30191
30243
  this.table.update();
30192
- this.setAllKeys(false);
30244
+ this.untrackAll();
30193
30245
  this.updateQueued = false;
30194
30246
  });
30195
30247
  }
@@ -30523,7 +30575,7 @@
30523
30575
  */
30524
30576
  this.documentShiftKeyDown = false;
30525
30577
  this.tableValidator = new TableValidator();
30526
- this.updateTracker = new UpdateTracker(this);
30578
+ this.tableUpdateTracker = new TableUpdateTracker(this);
30527
30579
  this.columnNotifiers = [];
30528
30580
  this.isInitialized = false;
30529
30581
  this.collapsedRows = new Set();
@@ -30688,7 +30740,7 @@
30688
30740
  this.tableValidator.validateColumnConfigurations(this.columns);
30689
30741
  }
30690
30742
  else {
30691
- this.updateTracker.trackColumnPropertyChanged(args);
30743
+ this.tableUpdateTracker.trackColumnPropertyChanged(args);
30692
30744
  }
30693
30745
  }
30694
30746
  }
@@ -30788,16 +30840,16 @@
30788
30840
  */
30789
30841
  update() {
30790
30842
  this.validate();
30791
- if (this.updateTracker.requiresTanStackUpdate) {
30843
+ if (this.tableUpdateTracker.requiresTanStackUpdate) {
30792
30844
  this.updateTanStack();
30793
30845
  }
30794
- if (this.updateTracker.updateActionMenuSlots) {
30846
+ if (this.tableUpdateTracker.updateActionMenuSlots) {
30795
30847
  this.updateActionMenuSlots();
30796
30848
  }
30797
- if (this.updateTracker.updateColumnWidths) {
30849
+ if (this.tableUpdateTracker.updateColumnWidths) {
30798
30850
  this.updateRowGridColumns();
30799
30851
  }
30800
- if (this.updateTracker.updateGroupRows) {
30852
+ if (this.tableUpdateTracker.updateGroupRows) {
30801
30853
  this.showCollapseAll = this.getColumnsParticipatingInGrouping().length > 0;
30802
30854
  }
30803
30855
  }
@@ -30815,20 +30867,20 @@
30815
30867
  if (!this.$fastController.isConnected) {
30816
30868
  return;
30817
30869
  }
30818
- this.updateTracker.trackSelectionModeChanged();
30870
+ this.tableUpdateTracker.trackSelectionModeChanged();
30819
30871
  }
30820
30872
  idFieldNameChanged(_prev, _next) {
30821
30873
  if (!this.$fastController.isConnected) {
30822
30874
  return;
30823
30875
  }
30824
- this.updateTracker.trackIdFieldNameChanged();
30876
+ this.tableUpdateTracker.trackIdFieldNameChanged();
30825
30877
  }
30826
30878
  columnsChanged(_prev, _next) {
30827
30879
  if (!this.$fastController.isConnected) {
30828
30880
  return;
30829
30881
  }
30830
30882
  this.observeColumns();
30831
- this.updateTracker.trackColumnInstancesChanged();
30883
+ this.tableUpdateTracker.trackColumnInstancesChanged();
30832
30884
  }
30833
30885
  async handleActionMenuBeforeToggleEvent(rowIndex, event) {
30834
30886
  const selectionChanged = this.selectionManager.handleActionMenuOpening(this.tableData[rowIndex]);
@@ -30869,13 +30921,13 @@
30869
30921
  this.isInitialized = true;
30870
30922
  // Initialize the controller to ensure that FAST functionality such as Observables work as expected.
30871
30923
  this.$fastController.onConnectedCallback();
30872
- this.updateTracker.trackAllStateChanged();
30924
+ this.tableUpdateTracker.trackAllStateChanged();
30873
30925
  this.observeColumns();
30874
30926
  }
30875
30927
  async processPendingUpdates() {
30876
30928
  this.initialize();
30877
30929
  await DOM.nextUpdate();
30878
- if (this.updateTracker.hasPendingUpdates) {
30930
+ if (this.tableUpdateTracker.hasPendingUpdates) {
30879
30931
  throw new Error('Expected pending updates to be resolved');
30880
30932
  }
30881
30933
  }
@@ -30913,28 +30965,28 @@
30913
30965
  updateTanStack() {
30914
30966
  const updatedOptions = {};
30915
30967
  updatedOptions.state = {};
30916
- if (this.updateTracker.updateColumnSort) {
30968
+ if (this.tableUpdateTracker.updateColumnSort) {
30917
30969
  updatedOptions.state.sorting = this.calculateTanStackSortState();
30918
30970
  }
30919
- if (this.updateTracker.updateColumnDefinition) {
30971
+ if (this.tableUpdateTracker.updateColumnDefinition) {
30920
30972
  updatedOptions.columns = this.calculateTanStackColumns();
30921
30973
  }
30922
- if (this.updateTracker.updateRowIds) {
30974
+ if (this.tableUpdateTracker.updateRowIds) {
30923
30975
  updatedOptions.getRowId = this.calculateTanStackRowIdFunction();
30924
30976
  updatedOptions.state.rowSelection = {};
30925
30977
  this.selectionManager.handleSelectionReset();
30926
30978
  }
30927
- if (this.updateTracker.updateSelectionMode) {
30979
+ if (this.tableUpdateTracker.updateSelectionMode) {
30928
30980
  updatedOptions.enableMultiRowSelection = this.selectionMode === TableRowSelectionMode.multiple;
30929
30981
  updatedOptions.enableSubRowSelection = this.selectionMode === TableRowSelectionMode.multiple;
30930
30982
  updatedOptions.state.rowSelection = {};
30931
30983
  this.selectionManager.handleSelectionModeChanged(this.selectionMode);
30932
30984
  }
30933
- if (this.updateTracker.requiresTanStackDataReset) {
30985
+ if (this.tableUpdateTracker.requiresTanStackDataReset) {
30934
30986
  // Perform a shallow copy of the data to trigger tanstack to regenerate the row models and columns.
30935
30987
  updatedOptions.data = [...this.table.options.data];
30936
30988
  }
30937
- if (this.updateTracker.updateGroupRows) {
30989
+ if (this.tableUpdateTracker.updateGroupRows) {
30938
30990
  updatedOptions.state.grouping = this.calculateTanStackGroupingState();
30939
30991
  updatedOptions.state.expanded = true;
30940
30992
  this.collapsedRows.clear();