lightning-base-components 1.14.3-alpha → 1.15.1-alpha

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 (152) hide show
  1. package/metadata/raptor.json +37 -4
  2. package/package.json +11 -4
  3. package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
  4. package/scopedImports/@salesforce-label-LightningModalBase.cancelandclose.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
  6. package/src/lightning/alert/__docs__/alert.md +101 -0
  7. package/src/lightning/alert/__examples__disabled/basic/basic.css +7 -0
  8. package/src/lightning/alert/__examples__disabled/basic/basic.html +8 -0
  9. package/src/lightning/alert/__examples__disabled/basic/basic.js +14 -0
  10. package/src/lightning/alert/alert.html +3 -0
  11. package/src/lightning/alert/alert.js +78 -0
  12. package/src/lightning/alert/alert.js-meta.xml +6 -0
  13. package/src/lightning/ariaObserver/__component__/ariaObserver.spec.js +9 -0
  14. package/src/lightning/ariaObserver/ariaObserver.js +24 -35
  15. package/src/lightning/baseFormattedText/baseFormattedText.html +6 -1
  16. package/src/lightning/baseFormattedText/baseFormattedText.js +5 -0
  17. package/src/lightning/button/__wdio__/utam/utam.html +3 -0
  18. package/src/lightning/button/__wdio__/utam/utam.js +3 -0
  19. package/src/lightning/button/__wdio__/utam/utam.spec.js +20 -0
  20. package/src/lightning/buttonMenu/buttonMenu.js +12 -0
  21. package/src/lightning/confirm/__docs__/confirm.md +100 -0
  22. package/src/lightning/confirm/__examples__disabled/basic/basic.css +7 -0
  23. package/src/lightning/confirm/__examples__disabled/basic/basic.html +8 -0
  24. package/src/lightning/confirm/__examples__disabled/basic/basic.js +14 -0
  25. package/src/lightning/confirm/confirm.html +3 -0
  26. package/src/lightning/confirm/confirm.js +80 -0
  27. package/src/lightning/confirm/confirm.js-meta.xml +6 -0
  28. package/src/lightning/datatable/__examples__/withInfiniteLoading/fetchDataHelper.js +21 -0
  29. package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.html +13 -0
  30. package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.js +42 -0
  31. package/src/lightning/datatable/__wdio__/utam/utam.html +17 -0
  32. package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
  33. package/src/lightning/datatable/__wdio__/utam/utam.spec.js +189 -0
  34. package/src/lightning/datatable/autoWidthStrategy.js +170 -61
  35. package/src/lightning/datatable/{resizer.js → columnResizer.js} +0 -0
  36. package/src/lightning/datatable/columnWidthManager.js +226 -44
  37. package/src/lightning/datatable/columns.js +166 -71
  38. package/src/lightning/datatable/datatable.js +136 -60
  39. package/src/lightning/datatable/fixedWidthStrategy.js +43 -8
  40. package/src/lightning/datatable/headerActions.js +2 -2
  41. package/src/lightning/datatable/infiniteLoading.js +100 -28
  42. package/src/lightning/datatable/inlineEdit.js +21 -30
  43. package/src/lightning/datatable/keyboard.js +166 -131
  44. package/src/lightning/datatable/renderManager.js +117 -122
  45. package/src/lightning/datatable/{datatableResizeObserver.js → resizeObserver.js} +46 -29
  46. package/src/lightning/datatable/resizeSensor.js +19 -3
  47. package/src/lightning/datatable/rowSelection.js +1 -1
  48. package/src/lightning/datatable/rowSelectionShared.js +33 -20
  49. package/src/lightning/datatable/rows.js +9 -8
  50. package/src/lightning/datatable/sort.js +8 -8
  51. package/src/lightning/datatable/state.js +14 -2
  52. package/src/lightning/datatable/templates/div/div.html +133 -119
  53. package/src/lightning/datatable/templates/table/table.html +10 -2
  54. package/src/lightning/datatable/tree.js +25 -0
  55. package/src/lightning/datatable/types.js +77 -9
  56. package/src/lightning/datatable/utils.js +51 -24
  57. package/src/lightning/datatable/virtualization.js +319 -0
  58. package/src/lightning/datatable/widthManagerShared.js +27 -3
  59. package/src/lightning/datatable/wrapText.js +115 -48
  60. package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
  61. package/src/lightning/formattedDateTime/__docs__/formattedDateTime.md +36 -3
  62. package/src/lightning/formattedDateTime/__examples__/datetime/datetime.html +2 -2
  63. package/src/lightning/formattedDateTime/__examples__/datetime/datetime.js +3 -1
  64. package/src/lightning/formattedDateTime/__examples__/time/time.html +1 -1
  65. package/src/lightning/formattedDateTime/__examples__/time/time.js +3 -1
  66. package/src/lightning/formattedDateTime/formattedDateTime.js +1 -0
  67. package/src/lightning/iconSvgTemplates/buildTemplates/standard/dashboard_component.html +7 -0
  68. package/src/lightning/iconSvgTemplates/buildTemplates/standard/slack.html +7 -0
  69. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tableau.html +7 -0
  70. package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
  71. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +8 -1
  72. package/src/lightning/iconSvgTemplates/buildTemplates/utility/data_model.html +7 -0
  73. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product.html +1 -1
  74. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product_transaction.html +2 -1
  75. package/src/lightning/iconSvgTemplates/buildTemplates/utility/slack.html +7 -0
  76. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tableau.html +7 -0
  77. package/src/lightning/iconSvgTemplates/buildTemplates/utility/video_off.html +7 -0
  78. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/dashboard_component.html +7 -0
  79. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/slack.html +7 -0
  80. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tableau.html +7 -0
  81. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
  82. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +8 -1
  83. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/data_model.html +7 -0
  84. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product.html +1 -1
  85. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  86. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/slack.html +7 -0
  87. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tableau.html +7 -0
  88. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/video_off.html +7 -0
  89. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/dashboard_component.html +7 -0
  90. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/slack.html +7 -0
  91. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tableau.html +7 -0
  92. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
  93. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +4 -1
  94. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/dashboard_component.html +7 -0
  95. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/slack.html +7 -0
  96. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tableau.html +7 -0
  97. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
  98. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +4 -1
  99. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +5 -1
  100. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/data_model.html +7 -0
  101. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product.html +1 -1
  102. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product_transaction.html +2 -1
  103. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/slack.html +7 -0
  104. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tableau.html +7 -0
  105. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/video_off.html +7 -0
  106. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +5 -1
  107. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/data_model.html +7 -0
  108. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product.html +1 -1
  109. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  110. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/slack.html +7 -0
  111. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tableau.html +7 -0
  112. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/video_off.html +7 -0
  113. package/src/lightning/input/__docs__/input.md +2 -0
  114. package/src/lightning/input/input.html +2 -5
  115. package/src/lightning/interactiveDialogBase/interactiveDialogBase.css +494 -0
  116. package/src/lightning/interactiveDialogBase/interactiveDialogBase.html +63 -0
  117. package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +200 -0
  118. package/src/lightning/menuItem/menuItem.js +4 -1
  119. package/src/lightning/modalBase/modalBase.css +20 -0
  120. package/src/lightning/modalBase/modalBase.html +54 -0
  121. package/src/lightning/modalBase/modalBase.js +1039 -0
  122. package/src/lightning/overlay/__docs__/overlay.md +90 -0
  123. package/src/lightning/overlay/__examples__/alert/alert.html +27 -0
  124. package/src/lightning/overlay/__examples__/alert/alert.js +33 -0
  125. package/src/lightning/overlay/__examples__/basic/basic.css +7 -0
  126. package/src/lightning/overlay/__examples__/basic/basic.html +18 -0
  127. package/src/lightning/overlay/__examples__/basic/basic.js +61 -0
  128. package/src/lightning/overlay/__examples__/demo/demo.html +29 -0
  129. package/src/lightning/overlay/__examples__/demo/demo.js +40 -0
  130. package/src/lightning/overlay/__examples__/panel/panel.html +17 -0
  131. package/src/lightning/overlay/__examples__/panel/panel.js +21 -0
  132. package/src/lightning/overlay/overlay.html +3 -0
  133. package/src/lightning/overlay/overlay.js +45 -0
  134. package/src/lightning/overlayContainer/__docs__/overlayContainer.md +0 -0
  135. package/src/lightning/overlayContainer/overlayContainer.html +3 -0
  136. package/src/lightning/overlayContainer/overlayContainer.js +138 -0
  137. package/src/lightning/overlayManager/overlayManager.js +54 -0
  138. package/src/lightning/overlayUtils/overlayUtils.js +17 -0
  139. package/src/lightning/progressBar/progressBar.html +2 -1
  140. package/src/lightning/progressBar/progressBar.js +18 -1
  141. package/src/lightning/prompt/__docs__/prompt.md +102 -0
  142. package/src/lightning/prompt/__examples__disabled/basic/basic.css +7 -0
  143. package/src/lightning/prompt/__examples__disabled/basic/basic.html +8 -0
  144. package/src/lightning/prompt/__examples__disabled/basic/basic.js +15 -0
  145. package/src/lightning/prompt/prompt.css +81 -0
  146. package/src/lightning/prompt/prompt.html +8 -0
  147. package/src/lightning/prompt/prompt.js +92 -0
  148. package/src/lightning/prompt/prompt.js-meta.xml +6 -0
  149. package/src/lightning/spinner/spinner.html +1 -1
  150. package/src/lightning/spinner/spinner.js +12 -0
  151. package/src/lightning/utilsPrivate/phonify.js +1 -1
  152. package/scopedImports/@salesforce-label-LightningModalBase.close.js +0 -1
@@ -3,7 +3,7 @@ import {
3
3
  getResizerDefaultState,
4
4
  hasDefinedColumnsWidths,
5
5
  isTableRenderedVisible,
6
- } from './resizer';
6
+ } from './columnResizer';
7
7
  import { AutoWidthStrategy } from './autoWidthStrategy';
8
8
  import { FixedWidthStrategy } from './fixedWidthStrategy';
9
9
  import {
@@ -20,11 +20,28 @@ import { isRTL } from 'lightning/utilsPrivate';
20
20
  const AUTO_WIDTH_MODE = 'auto';
21
21
  const FIXED_WIDTH_MODE = 'fixed';
22
22
 
23
- const TABLE_SEL = 'table';
24
- const CONTAINER_SEL = '.slds-scrollable_x';
25
- const DATA_CELL_SEL = 'tbody tr:first-child td,tbody tr:first-child th';
26
- const HEADER_CELL_SEL = 'thead tr th lightning-primitive-header-factory';
27
-
23
+ const tableTypes = {
24
+ default: {
25
+ BASE: '.slds-table',
26
+ CONTAINER: '.slds-scrollable_x',
27
+ DATA_CELL: 'tbody tr:first-child td,tbody tr:first-child th',
28
+ HEADER_CELL: 'thead tr th lightning-primitive-header-factory',
29
+ },
30
+ roleBased: {
31
+ BASE: '.slds-table',
32
+ CONTAINER: '.slds-scrollable_x',
33
+ DATA_CELL: 'div[data-rowgroup-body] div[role="row"]:first-child div',
34
+ HEADER_CELL: 'div.table-header lightning-primitive-header-factory',
35
+ },
36
+ };
37
+
38
+ /**
39
+ * Computes and updates the `widthsData` for a datatable.
40
+ *
41
+ * @param {Object} adjustedWidths The adjusted widths object
42
+ * @param {Array} columnDefs The column definitions array
43
+ * @param {Object} widthsData The source widths data to update
44
+ */
28
45
  export function computeColumnWidths(adjustedWidths, columnDefs, widthsData) {
29
46
  const { columnWidths } = adjustedWidths;
30
47
  if (columnWidths.length !== columnDefs.length) {
@@ -46,20 +63,30 @@ export function computeColumnWidths(adjustedWidths, columnDefs, widthsData) {
46
63
  columnWidthsSum += newWidth;
47
64
  });
48
65
 
49
- // W-7679487 tableWidth should match columnWidthsSum.
66
+ // TODO: W-7679487 - `tableWidth` should match `columnWidthsSum`
50
67
  widthsData.tableWidth = columnWidthsSum;
51
68
  }
52
69
 
70
+ /**
71
+ * Column width manager.
72
+ * Invokes one of the two width managing strategies based
73
+ * on `column-widths-mode`: "auto" or "fixed"
74
+ */
53
75
  export class ColumnWidthManager {
76
+ // Private variables
54
77
  _columnWidthMode = FIXED_WIDTH_MODE;
55
78
  _resizeObserverAvailable = typeof ResizeObserver === 'function';
56
- // flag to indicate resetting column widths is needed
57
- // could be with or without autoResizingUpdate
79
+
80
+ // Flag to indicate resetting column widths is needed.
81
+ // Could be with or without `autoResizingUpdate`.
58
82
  _queueResizingUpdate = false;
59
- // flag to indicate whether auto resizing computation update is needed
60
- // in which case table styles need to auto flow
83
+
84
+ // Flag to indicate whether auto resizing computation update is needed,
85
+ // in which case table styles need to auto flow.
61
86
  _queueAutoResizingUpdate = false;
62
87
 
88
+ /************************** LIFECYCLE HOOKS **************************/
89
+
63
90
  constructor(widthsData) {
64
91
  const minColumnWidth =
65
92
  widthsData.minColumnWidth ||
@@ -80,50 +107,108 @@ export class ColumnWidthManager {
80
107
  this._widthStrategies[AUTO_WIDTH_MODE] = autoWidthStrategy;
81
108
  }
82
109
 
83
- // Public apis exposed to datatable
110
+ /************************** PRIVATE GETTERS **************************/
84
111
 
112
+ /**
113
+ * Gets the configured column width strategy.
114
+ *
115
+ * @returns {Object} The column width strategy
116
+ */
85
117
  get columnWidthStrategy() {
86
118
  return this._widthStrategies[this.columnWidthMode];
87
119
  }
88
120
 
121
+ /**
122
+ * Gets the configured column width mode.
123
+ *
124
+ * @returns {String} The column width mode
125
+ */
89
126
  get columnWidthMode() {
90
127
  return this._columnWidthMode;
91
128
  }
92
129
 
130
+ /************************** PRIVATE SETTERS **************************/
131
+
132
+ /**
133
+ * Sets the column width mode.
134
+ *
135
+ * @param {String} value The new column width mode
136
+ */
93
137
  set columnWidthMode(value) {
94
138
  this._columnWidthMode = value;
95
139
  }
96
140
 
141
+ /**
142
+ * Sets the minimum column width (in pixels).
143
+ *
144
+ * @param {Number} value The minimum column width
145
+ */
97
146
  set minColumnWidth(value) {
98
147
  Object.keys(this._widthStrategies).forEach((strategy) => {
99
148
  this._widthStrategies[strategy].minColumnWidth = value;
100
149
  });
101
150
  }
102
151
 
152
+ /**
153
+ * Sets the maximum column width (in pixels).
154
+ *
155
+ * @param {Number} value The maximum column width
156
+ */
103
157
  set maxColumnWidth(value) {
104
158
  Object.keys(this._widthStrategies).forEach((strategy) => {
105
159
  this._widthStrategies[strategy].maxColumnWidth = value;
106
160
  });
107
161
  }
108
162
 
163
+ /**
164
+ * Sets the maximum number of text wrap lines
165
+ *
166
+ * @param {Number} value The maximum number of lines text can be wrapped on
167
+ */
109
168
  set wrapTextMaxLines(value) {
110
169
  this._widthStrategies[AUTO_WIDTH_MODE].wrapTextMaxLines = value;
111
170
  }
112
171
 
172
+ /************************* HELPER FUNCTIONS **************************/
173
+
174
+ /**
175
+ * Sets the datatable's configured render mode.
176
+ *
177
+ * @param {String} mode Either "table" or "role-based"
178
+ */
179
+ setRenderMode(mode) {
180
+ this._renderMode = mode;
181
+ }
182
+
183
+ /**
184
+ * Returns whether a resizing update is queued.
185
+ *
186
+ * @returns {Boolean} Whether there is a resizing update queued
187
+ */
113
188
  isResizingUpdateQueued() {
114
189
  return this._queueResizingUpdate;
115
190
  }
116
191
 
192
+ /**
193
+ * Returns whether an auto-resizing update is queued.
194
+ *
195
+ * @returns {Boolean} Whether there is an auto-resizing update queued
196
+ */
117
197
  isAutoResizingUpdateQueued() {
118
198
  return this._queueAutoResizingUpdate;
119
199
  }
120
200
 
201
+ /**
202
+ * Determines if we should fire the resize event based on the previous
203
+ * widths data and the column definition. The event is only fired when
204
+ * the number of columns change in fixed width mode. In auto width mode,
205
+ * nothing happens.
206
+ *
207
+ * @param {Object} previousWidthsData The previous widths data to evaluate
208
+ * @param {Array} columnDefs The column definitions array
209
+ * @returns {Boolean} Whether or not the resize event should be fired
210
+ */
121
211
  shouldFireResizeEvent(previousWidthsData, columnDefs) {
122
- // in fixed widths mode fire resize event only when then
123
- // column definitions change in number ie. initial render
124
- // and subsequent changes in column number
125
- // in auto widths mode dont fire resize event for programmatic
126
- // actions fire only for user actions
127
212
  if (this._columnWidthMode === FIXED_WIDTH_MODE) {
128
213
  return (
129
214
  getColumnsWidths(previousWidthsData).length !==
@@ -133,6 +218,13 @@ export class ColumnWidthManager {
133
218
  return false;
134
219
  }
135
220
 
221
+ /**
222
+ * Adjusts all the column sizes based on the supplied widths data.
223
+ *
224
+ * @param {Node} root The root column node
225
+ * @param {Array} columnDefs The column definitions array
226
+ * @param {Object} widthsData The widths data object
227
+ */
136
228
  adjustColumnsSize(root, columnDefs, widthsData) {
137
229
  const {
138
230
  _queueResizingUpdate,
@@ -140,10 +232,11 @@ export class ColumnWidthManager {
140
232
  columnWidthStrategy,
141
233
  } = this;
142
234
  let adjustedWidths = [];
235
+
143
236
  if (_queueResizingUpdate) {
144
- // if table is hidden when updating and ResizeObserver is not available
145
- // then updating sizes causes min widths to be set
146
- // hence the check if ok update from dom
237
+ // If table is hidden when updating and `ResizeObserver` is not available,
238
+ // then updating sizes causes min widths to be set.
239
+ // Hence, the check if ok update from DOM.
147
240
  if (this._shouldResizeWithUpdate(root, widthsData)) {
148
241
  adjustedWidths = columnWidthStrategy.getAdjustedColumnWidths(
149
242
  this._getDatatableInterface(root),
@@ -151,7 +244,7 @@ export class ColumnWidthManager {
151
244
  _queueAutoResizingUpdate
152
245
  );
153
246
  } else {
154
- // otherwise update from previous widths
247
+ // Otherwise update from previous widths
155
248
  adjustedWidths = {
156
249
  columnWidths: widthsData.columnWidths,
157
250
  expectedTableWidth: widthsData.tableWidth,
@@ -159,10 +252,18 @@ export class ColumnWidthManager {
159
252
  }
160
253
  computeColumnWidths(adjustedWidths, columnDefs, widthsData);
161
254
  }
255
+
162
256
  this._resetAutoResizingUpdate();
163
257
  this._queueResizingUpdate = false;
164
258
  }
165
259
 
260
+ /**
261
+ * Adjusts all the column widths after a resize happens.
262
+ *
263
+ * @param {Node} root The root column node
264
+ * @param {Array} columnDefs The column definitions array
265
+ * @param {Object} widthsData The widths data object
266
+ */
166
267
  adjustColumnsSizeAfterResize(root, columnDefs, widthsData) {
167
268
  const adjustedWidths = this.columnWidthStrategy.getAdjustedColumnWidths(
168
269
  this._getDatatableInterface(root),
@@ -171,13 +272,18 @@ export class ColumnWidthManager {
171
272
  computeColumnWidths(adjustedWidths, columnDefs, widthsData);
172
273
  }
173
274
 
174
- // React to change in data
275
+ /**
276
+ * React to a change in data.
277
+ *
278
+ * @param {Object} previousData The previous data
279
+ * @param {Object} newData The new data
280
+ * @param {Array} columnDefs The column definitions array
281
+ */
175
282
  handleDataChange(previousData, newData, columnDefs) {
176
283
  if (columnDefs.length > 0) {
177
- // resize columns with auto-resizing update only if -
178
- // mode is auto and
179
- // new data length is equal to previous data length (change in data)
180
- // or previously there was no data at all
284
+ // Resize columns with auto-resizing update only if...
285
+ // The mode is auto and new data length is equal to previous data
286
+ // length (change in data) or previously there was no data at all.
181
287
  if (this.columnWidthMode === AUTO_WIDTH_MODE) {
182
288
  if (this._hasDataChanged(previousData, newData)) {
183
289
  this._queueResizingUpdate = true;
@@ -187,7 +293,11 @@ export class ColumnWidthManager {
187
293
  }
188
294
  }
189
295
 
190
- // React to change in column definitions
296
+ /**
297
+ * React to change in column definitions
298
+ *
299
+ * @param {Array} columnDefs The column definitions array
300
+ */
191
301
  handleColumnsChange(columnDefs) {
192
302
  if (columnDefs.length > 0) {
193
303
  this._queueResizingUpdate = true;
@@ -195,7 +305,11 @@ export class ColumnWidthManager {
195
305
  }
196
306
  }
197
307
 
198
- // React to change in column widths mode
308
+ /**
309
+ * React to change in column widths mode
310
+ *
311
+ * @param {Array} columnDefs The column definitions array
312
+ */
199
313
  handleWidthModeChange(columnDefs) {
200
314
  if (columnDefs.length > 0) {
201
315
  this._queueResizingUpdate = true;
@@ -203,7 +317,12 @@ export class ColumnWidthManager {
203
317
  }
204
318
  }
205
319
 
206
- // React to change in row number offset
320
+ /**
321
+ * React to change in row number offset
322
+ *
323
+ * @param {Object} state The datatable state
324
+ * @param {Object} widthsData The source widths data to updated
325
+ */
207
326
  handleRowNumberOffsetChange(state, widthsData) {
208
327
  const colIndex = getRowNumberColumnIndex(state);
209
328
  if (colIndex > -1) {
@@ -215,8 +334,8 @@ export class ColumnWidthManager {
215
334
  rowNumberCol.minWidth
216
335
  );
217
336
  if (hasDefinedColumnsWidths(widthsData)) {
218
- // when columns are resized with the resizer, a horizontal scroller appears.
219
- // adjusting the columns size, will respect widths already set and try to fit this column
337
+ // When columns are resized with the resizer, a horizontal scroller appears.
338
+ // Adjusting the columns size will respect widths already set and try to fit this column.
220
339
  this._queueResizingUpdate = true;
221
340
  this._setAutoResizingUpdate(state.columns);
222
341
  }
@@ -224,14 +343,26 @@ export class ColumnWidthManager {
224
343
  }
225
344
  }
226
345
 
227
- // React to change in hide-checkbox-column
346
+ /**
347
+ * React to change in hide-checkbox-column
348
+ *
349
+ * @param {Any} previousValue The previous column value
350
+ * @param {Any} newValue The new column value
351
+ * @param {Array} columnDefs The column definitions array
352
+ */
228
353
  handleCheckboxColumnChange(previousValue, newValue, columnDefs) {
229
354
  if (columnDefs.length > 0 && previousValue !== newValue) {
230
355
  this._queueResizingUpdate = true;
231
356
  }
232
357
  }
233
358
 
234
- // React to change in show-row-number-column
359
+ /**
360
+ * React to change in show-row-number-column
361
+ *
362
+ * @param {Any} previousValue The previous column value
363
+ * @param {Any} newValue The new column value
364
+ * @param {Array} columnDefs The column definitions array
365
+ */
235
366
  handleRowNumberColumnChange(previousValue, newValue, columnDefs) {
236
367
  if (columnDefs.length > 0 && previousValue !== newValue) {
237
368
  this._queueResizingUpdate = true;
@@ -239,8 +370,13 @@ export class ColumnWidthManager {
239
370
  }
240
371
  }
241
372
 
242
- // Private helper functions
243
-
373
+ /**
374
+ * @private
375
+ * Queues up an auto resizing update. If a column width isn't defined,
376
+ * reset the width so it can be recalculated.
377
+ *
378
+ * @param {Array} columnDefs The column definitions array
379
+ */
244
380
  _setAutoResizingUpdate(columnDefs) {
245
381
  if (this.columnWidthMode === AUTO_WIDTH_MODE) {
246
382
  this._queueAutoResizingUpdate = true;
@@ -255,10 +391,22 @@ export class ColumnWidthManager {
255
391
  }
256
392
  }
257
393
 
394
+ /**
395
+ * @private
396
+ * Resets the auto resizing update queue.
397
+ */
258
398
  _resetAutoResizingUpdate() {
259
399
  this._queueAutoResizingUpdate = false;
260
400
  }
261
401
 
402
+ /**
403
+ * @private
404
+ * Evalutes if there is a change between two sets of data.
405
+ *
406
+ * @param {Array} previousData An array of previous data
407
+ * @param {Array} newData An array of new data
408
+ * @returns {Boolean} Whether or not the is a difference between the two data sets
409
+ */
262
410
  _hasDataChanged(previousData, newData) {
263
411
  return (
264
412
  newData.length > 0 &&
@@ -267,10 +415,18 @@ export class ColumnWidthManager {
267
415
  );
268
416
  }
269
417
 
418
+ /**
419
+ * @private
420
+ * Determines if a column should resize with an update.
421
+ *
422
+ * @param {Node} root The root column node
423
+ * @param {Object} widthsData The source widths data
424
+ * @returns {Boolean} Whether the column should resize with an update
425
+ */
270
426
  _shouldResizeWithUpdate(root, widthsData) {
271
427
  if (hasDefinedColumnsWidths(widthsData)) {
272
- // can resize from dom when table is visible
273
- // otherwise only when ResizeObserver is available in browser
428
+ // Can resize from DOM when table is visible.
429
+ // Otherwise, only when `ResizeObserver` is available in browser.
274
430
  return (
275
431
  this._resizeObserverAvailable || isTableRenderedVisible(root)
276
432
  );
@@ -278,14 +434,39 @@ export class ColumnWidthManager {
278
434
  return true;
279
435
  }
280
436
 
437
+ /**
438
+ * @private
439
+ * Determines the appropriate selectors to use based on the datatable render mode.
440
+ *
441
+ * @returns {Object} Selectors based on datatable render mode
442
+ */
443
+ _getTableSelectors() {
444
+ if (this._renderMode === 'role-based') {
445
+ return tableTypes.roleBased;
446
+ }
447
+ return tableTypes.default;
448
+ }
449
+
450
+ /**
451
+ * @private
452
+ * Retrieves the datatable interface from the DOM
453
+ *
454
+ * @param {Node} root The root datatable node
455
+ * @returns {Object} The datatable interface
456
+ */
281
457
  _getDatatableInterface(root) {
458
+ const datatableSelectors = this._getTableSelectors();
282
459
  return {
283
460
  getAvailableWidthFromDom() {
284
- const container = root.querySelector(CONTAINER_SEL);
461
+ const container = root.querySelector(
462
+ datatableSelectors.CONTAINER
463
+ );
285
464
  return getDomWidth(container);
286
465
  },
287
466
  getDataCellWidths() {
288
- const cells = root.querySelectorAll(DATA_CELL_SEL);
467
+ const cells = root.querySelectorAll(
468
+ datatableSelectors.DATA_CELL
469
+ );
289
470
  if (cells.length > 0) {
290
471
  return Array.prototype.slice
291
472
  .call(cells)
@@ -297,7 +478,9 @@ export class ColumnWidthManager {
297
478
  return [];
298
479
  },
299
480
  getHeaderCellWidths() {
300
- const headerCells = root.querySelectorAll(HEADER_CELL_SEL);
481
+ const headerCells = root.querySelectorAll(
482
+ datatableSelectors.HEADER_CELL
483
+ );
301
484
  if (headerCells.length > 0) {
302
485
  return Array.prototype.slice
303
486
  .call(headerCells)
@@ -312,11 +495,10 @@ export class ColumnWidthManager {
312
495
  return [];
313
496
  },
314
497
  getTableElementWidth() {
315
- // TODO: Figure out a clean way to retrieve and use the correct selectors
316
- // Currently outside scope of this work. Should be addressed in W-8540110
317
498
  const tableElement =
318
- root.querySelector(TABLE_SEL) ||
319
- root.querySelector('[role="grid"]');
499
+ root.querySelector(datatableSelectors.BASE) ||
500
+ root.querySelector('[role="grid"]') ||
501
+ root.querySelector('[role="treegrid"]');
320
502
  return getDomWidth(tableElement);
321
503
  },
322
504
  };