lightning-base-components 1.14.2-alpha → 1.14.6-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 (82) hide show
  1. package/metadata/raptor.json +33 -1
  2. package/package.json +20 -4
  3. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsPlural.js +1 -0
  4. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsSingular.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningErrorMessage.validitySelectAtleastOne.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningMap.titleWithAddress.js +1 -0
  7. package/scopedImports/@salesforce-label-LightningModalBase.cancelandclose.js +1 -0
  8. package/src/lightning/ariaObserver/__component__/ariaObserver.spec.js +9 -0
  9. package/src/lightning/ariaObserver/__docs__/ariaObserver.md +142 -0
  10. package/src/lightning/ariaObserver/ariaObserver.js +24 -35
  11. package/src/lightning/baseFormattedText/baseFormattedText.html +6 -1
  12. package/src/lightning/baseFormattedText/baseFormattedText.js +5 -0
  13. package/src/lightning/buttonMenu/keyboard.js +0 -10
  14. package/src/lightning/card/card.html +6 -0
  15. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  16. package/src/lightning/checkboxGroup/checkboxGroup.js +6 -1
  17. package/src/lightning/colorPickerCustom/colorPickerCustom.js +20 -1
  18. package/src/lightning/datatable/__docs__/datatable.md +55 -0
  19. package/src/lightning/datatable/__examples__/basic/basic.html +1 -1
  20. package/src/lightning/datatable/__examples__/withInfiniteLoading/fetchDataHelper.js +21 -0
  21. package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.html +13 -0
  22. package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.js +42 -0
  23. package/src/lightning/datatable/autoWidthStrategy.js +170 -61
  24. package/src/lightning/datatable/{resizer.js → columnResizer.js} +0 -0
  25. package/src/lightning/datatable/columnWidthManager.js +226 -44
  26. package/src/lightning/datatable/columns-shared.js +1 -1
  27. package/src/lightning/datatable/datatable.js +104 -33
  28. package/src/lightning/datatable/errors.js +20 -9
  29. package/src/lightning/datatable/fixedWidthStrategy.js +43 -8
  30. package/src/lightning/datatable/headerActions.js +77 -49
  31. package/src/lightning/datatable/infiniteLoading.js +100 -28
  32. package/src/lightning/datatable/inlineEdit.js +505 -379
  33. package/src/lightning/datatable/inlineEditShared.js +24 -0
  34. package/src/lightning/datatable/keyboard.js +162 -127
  35. package/src/lightning/datatable/renderManager.js +208 -133
  36. package/src/lightning/datatable/{datatableResizeObserver.js → resizeObserver.js} +46 -29
  37. package/src/lightning/datatable/resizeSensor.js +8 -0
  38. package/src/lightning/datatable/rowLevelActions.js +17 -13
  39. package/src/lightning/datatable/rowNumber.js +54 -20
  40. package/src/lightning/datatable/rowSelection.js +760 -0
  41. package/src/lightning/datatable/rowSelectionShared.js +79 -0
  42. package/src/lightning/datatable/rows.js +17 -6
  43. package/src/lightning/datatable/state.js +16 -2
  44. package/src/lightning/datatable/templates/div/div.css +4 -0
  45. package/src/lightning/datatable/templates/div/div.html +128 -117
  46. package/src/lightning/datatable/templates/table/table.html +5 -0
  47. package/src/lightning/datatable/utils.js +14 -0
  48. package/src/lightning/datatable/widthManagerShared.js +27 -3
  49. package/src/lightning/datatable/wrapText.js +77 -47
  50. package/src/lightning/dualListbox/dualListbox.html +1 -1
  51. package/src/lightning/dualListbox/dualListbox.js +42 -0
  52. package/src/lightning/formattedDateTime/__docs__/formattedDateTime.md +36 -3
  53. package/src/lightning/formattedDateTime/__examples__/datetime/datetime.html +2 -2
  54. package/src/lightning/formattedDateTime/__examples__/datetime/datetime.js +3 -1
  55. package/src/lightning/formattedDateTime/__examples__/time/time.html +1 -1
  56. package/src/lightning/formattedDateTime/__examples__/time/time.js +3 -1
  57. package/src/lightning/formattedDateTime/formattedDateTime.js +1 -0
  58. package/src/lightning/input/input.html +2 -5
  59. package/src/lightning/inputUtils/validity.js +12 -1
  60. package/src/lightning/pillContainer/__docs__/pillContainer.md +45 -1
  61. package/src/lightning/positionLibrary/positionLibrary.js +31 -43
  62. package/src/lightning/primitiveCellActions/primitiveCellActions.js +69 -12
  63. package/src/lightning/primitiveCellFactory/cellWithStandardLayout.html +13 -11
  64. package/src/lightning/primitiveCellFactory/primitiveCellFactory.js +13 -8
  65. package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.html +17 -14
  66. package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.js +167 -98
  67. package/src/lightning/primitiveDatatableIeditTypeFactory/primitiveDatatableIeditTypeFactory.js +94 -69
  68. package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.html +4 -4
  69. package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.js +4 -4
  70. package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +99 -37
  71. package/src/lightning/progressIndicator/progressIndicator.js +1 -1
  72. package/src/lightning/progressStep/progressStep.js +1 -1
  73. package/src/lightning/spinner/spinner.html +1 -1
  74. package/src/lightning/spinner/spinner.js +12 -0
  75. package/src/lightning/staticMap/staticMap.html +1 -0
  76. package/src/lightning/staticMap/staticMap.js +39 -2
  77. package/src/lightning/utils/classSet.js +4 -1
  78. package/src/lightning/utilsPrivate/phonify.js +1 -1
  79. package/scopedImports/@salesforce-label-LightningModalBase.close.js +0 -1
  80. package/src/lightning/datatable/inlineEdit-shared.js +0 -14
  81. package/src/lightning/datatable/selector-shared.js +0 -38
  82. package/src/lightning/datatable/selector.js +0 -527
@@ -0,0 +1,79 @@
1
+ /**
2
+ * This file exists in order to get around circular dependencies.
3
+ * In this case, rowSelection.js has a dependency on rows.js;
4
+ * but rows.js also has a dependency on rowSelection.js for
5
+ * `isSelectedRow()` among others.
6
+ *
7
+ * We split out the functions that could cause circular dependencies with
8
+ * `rowSelection.js` into the `*Shared.js` files.
9
+ */
10
+
11
+ /**
12
+ * Returns whether or not the row is selected using the state and the rowKeyValue
13
+ * The state maintains the list of selected rows from which
14
+ * this value can be retrieved.
15
+ *
16
+ * @param {Object} state - datatable state object
17
+ * @param {String} rowKeyValue
18
+ * @returns
19
+ */
20
+ export function isSelectedRow(state, rowKeyValue) {
21
+ return !!state.selectedRowsKeys[rowKeyValue];
22
+ }
23
+
24
+ /**
25
+ * Returns whether the row (whose row key value is specified)
26
+ * should be disabled or not.
27
+ * Should not disable if the row is selected.
28
+ * If the particular row is not selected, the row should be disabled
29
+ * when max-row-selection > 1 and the selection limit is reached
30
+ *
31
+ * Note: Do not disable selection when max-row-selection = 1 and
32
+ * a row has been selected.
33
+ *
34
+ * @param {Object} state
35
+ * @param {String} rowKeyValue
36
+ * @returns {Boolean} whether the row should be disabled or not
37
+ */
38
+ export function isDisabledRow(state, rowKeyValue) {
39
+ if (!isSelectedRow(state, rowKeyValue)) {
40
+ const maxRowSelection = getMaxRowSelection(state);
41
+
42
+ // when selection is 1, we should not disable selection
43
+ return (
44
+ maxRowSelection !== 1 &&
45
+ getCurrentSelectionLength(state) === maxRowSelection
46
+ );
47
+ }
48
+
49
+ return false;
50
+ }
51
+
52
+ /**
53
+ * Returns which input type to use for row selection.
54
+ * If max-row-selection = 1, use radio buttons,
55
+ * otherwise, use checkboxes.
56
+ *
57
+ * @param {Object} state - datatable's state object
58
+ * @returns
59
+ */
60
+ export function getRowSelectionInputType(state) {
61
+ if (getMaxRowSelection(state) === 1) {
62
+ return 'radio';
63
+ }
64
+ return 'checkbox';
65
+ }
66
+
67
+ export function getMaxRowSelection(state) {
68
+ return state.maxRowSelection;
69
+ }
70
+
71
+ export function getCurrentSelectionLength(state) {
72
+ return getSelectedRowsKeys(state).length;
73
+ }
74
+
75
+ export function getSelectedRowsKeys(state) {
76
+ return Object.keys(state.selectedRowsKeys).filter(
77
+ (key) => state.selectedRowsKeys[key]
78
+ );
79
+ }
@@ -1,11 +1,11 @@
1
1
  import { assert } from 'lightning/utilsPrivate';
2
- import { classSet, isObjectLike } from './utils';
2
+ import { classSet, isObjectLike, styleToString } from './utils';
3
3
  import { isTreeType, getAttributesNames } from './types';
4
4
  import {
5
5
  isSelectedRow,
6
6
  isDisabledRow,
7
7
  getRowSelectionInputType,
8
- } from './selector-shared';
8
+ } from './rowSelectionShared';
9
9
  import { getTreeStateIndicatorFieldNames, getStateTreeColumn } from './tree';
10
10
  import {
11
11
  getColumns,
@@ -17,7 +17,7 @@ import {
17
17
  } from './columns';
18
18
  import { isRowNumberColumn, getRowNumberErrorColumnDef } from './rowNumber';
19
19
  import { getRowError } from './errors';
20
- import { getDirtyValue } from './inlineEdit-shared';
20
+ import { getDirtyValueFromCell } from './inlineEditShared';
21
21
 
22
22
  export function getData(state) {
23
23
  return state.data;
@@ -115,7 +115,7 @@ export function uniqueRowKeyGenerator(keyField) {
115
115
  */
116
116
  export function updateRowsAndCellIndexes() {
117
117
  const { state, privateTypes: types } = this;
118
- const { keyField, renderModeRoleBased } = state;
118
+ const { keyField, renderModeRoleBased, virtualize, rowHeight } = state;
119
119
  const data = getData(state);
120
120
  const columns = getColumns(state);
121
121
  const computeUniqueRowKey = uniqueRowKeyGenerator(keyField);
@@ -134,6 +134,7 @@ export function updateRowsAndCellIndexes() {
134
134
 
135
135
  state.indexes[row.key] = { rowIndex };
136
136
 
137
+ row.rowIndex = rowIndex;
137
138
  row.inputType = getRowSelectionInputType(state);
138
139
  row.isSelected = isSelectedRow(state, row.key);
139
140
  row.ariaSelected = row.isSelected ? 'true' : false;
@@ -141,11 +142,21 @@ export function updateRowsAndCellIndexes() {
141
142
  row.classnames = resolveRowClassNames(row);
142
143
  Object.assign(row, getRowStateForTree(rowData, state));
143
144
  row.tabIndex = -1;
145
+ if (virtualize) {
146
+ row.style = styleToString({
147
+ position: 'absolute',
148
+ top: `${rowIndex * rowHeight}px`,
149
+ });
150
+ }
144
151
 
145
152
  columns.reduce((currentRow, colData, colIndex) => {
146
153
  const { fieldName } = colData;
147
154
  const colKeyValue = generateColKeyValue(colData, colIndex);
148
- const dirtyValue = getDirtyValue(state, row.key, colKeyValue);
155
+ const dirtyValue = getDirtyValueFromCell(
156
+ state,
157
+ row.key,
158
+ colKeyValue
159
+ );
149
160
  const cellHasErrors = hasCellErrors(
150
161
  rowErrors,
151
162
  colData.fieldName,
@@ -391,7 +402,7 @@ function computeCellEditable(row, column) {
391
402
  * @param {object} row - a row data object stored in datatable state. Must be truthy.
392
403
  * @param {object} column - a column data object stored in datatable state. Must be truthy.
393
404
  */
394
- function isCellEditable(row, column) {
405
+ export function isCellEditable(row, column) {
395
406
  return !!resolveAttributeValue(column.editable, row);
396
407
  }
397
408
 
@@ -17,8 +17,9 @@ export const getDefaultState = function () {
17
17
  rows: [],
18
18
  indexes: {},
19
19
 
20
- // selector
20
+ // row selection
21
21
  selectedRowsKeys: {},
22
+ lastSelectedRowKey: undefined,
22
23
  maxRowSelection: undefined,
23
24
 
24
25
  headerIndexes: {},
@@ -54,12 +55,25 @@ export const getDefaultState = function () {
54
55
  // table render mode
55
56
  renderModeRoleBased: false,
56
57
 
57
- // viewport rendering
58
+ // viewport rendering and virtualization
58
59
  enableViewportRendering: undefined,
60
+ virtualize: '',
61
+ bufferSize: 5, // number of extra rows rendered on each side outside of viewport
62
+ rowHeight: 30.5,
63
+ renderedRowCount: 0,
64
+ firstVisibleIndex: 0, // first row that should be visible in viewport
59
65
 
60
66
  // inline edit
61
67
  inlineEdit: {
68
+ rowKeyValue: undefined,
69
+ colKeyValue: undefined,
70
+ columnDef: {},
62
71
  dirtyValues: {},
72
+ editedValue: undefined,
73
+ isPanelVisible: false,
74
+ massEditEnabled: false,
75
+ massEditSelectedRows: undefined,
76
+ resolvedAttributeTypes: {},
63
77
  },
64
78
 
65
79
  // errors
@@ -22,6 +22,10 @@
22
22
  border-top: 1px solid #dddbda;
23
23
  }
24
24
 
25
+ .slds-table_header-fixed [data-row-key-value]:first-child {
26
+ border-top: 0;
27
+ }
28
+
25
29
  /* Required for row numbers */
26
30
  [role="row"] {
27
31
  counter-increment: row-number;
@@ -41,13 +41,16 @@
41
41
  </template>
42
42
  <template if:true={hasValidKeyField}>
43
43
  <!-- Corresponds to <thead> -->
44
- <div role="rowgroup">
44
+ <div
45
+ data-rowgroup-header
46
+ role="rowgroup">
45
47
  <!-- TODO: Fix aria-rowindex to not be hardcoded -->
46
48
  <!-- TODO: might need to move the table-header class out or rename -->
47
49
  <!-- Column Header Row -->
48
50
  <div class="slds-line-height_reset table-header"
49
51
  role="row"
50
52
  aria-rowindex="1"
53
+ data-row-key-value="HEADER"
51
54
  onprivateresizestart={handleResizeStart}
52
55
  onprivateresizeend={handleResizeEnd}>
53
56
  <template for:each={state.columns} for:item="def" for:index="colIndex">
@@ -58,6 +61,7 @@
58
61
  tabindex={def.tabIndex}
59
62
  aria-label={def.ariaLabel}
60
63
  aria-sort={def.sortAriaLabel}
64
+ data-col-key-value={def.colKeyValue}
61
65
  key={def.colKeyValue}>
62
66
 
63
67
  <template if:true={def.fixedWidth}>
@@ -106,8 +110,11 @@
106
110
  </div>
107
111
  </div>
108
112
  <!-- Corresponds to <tbody> -->
109
- <div style={computedTbodyStyle} role="rowgroup">
110
- <template for:each={renderedRows} for:item="row" for:index="rowIndex">
113
+ <div
114
+ data-rowgroup-body
115
+ role="rowgroup"
116
+ style={computedTbodyStyle}>
117
+ <template for:each={renderedRows} for:item="row">
111
118
  <!-- Data Rows -->
112
119
  <div class={row.classnames}
113
120
  role="row"
@@ -120,126 +127,130 @@
120
127
  aria-setsize={row.setSize}
121
128
  aria-posinset={row.posInSet}
122
129
  aria-rowindex={row.ariaRowIndex}
130
+ style={row.style}
123
131
  tabindex={row.tabIndex}>
124
- <template for:each={row.cells} for:item="cell">
125
- <template if:true={cell.isCheckbox}>
126
- <!-- Checkbox Cell -->
127
- <div class={cell.class}
128
- style={cell.style}
129
- role="gridcell"
130
- tabindex={cell.tabIndex}
131
- data-label={cell.dataLabel}
132
- key={cell.colKeyValue}>
133
- <lightning-primitive-cell-checkbox
134
- dt-context-id={_datatableId}
135
- has-focus={cell.hasFocus}
132
+ <template for:each={row.cells} for:item="cell">
133
+ <template if:true={cell.isCheckbox}>
134
+ <!-- Checkbox Cell -->
135
+ <div class={cell.class}
136
+ style={cell.style}
137
+ role="gridcell"
138
+ tabindex={cell.tabIndex}
136
139
  data-label={cell.dataLabel}
137
- key={cell.key}
138
- row-key-value={row.key}
139
- col-key-value={cell.colKeyValue}
140
- row-index={rowIndex}
141
- type={row.inputType}
142
- is-selected={row.isSelected}
143
- is-disabled={row.isDisabled}
144
- column-header-id={computedCheckboxColumnHeaderId}>
145
- </lightning-primitive-cell-checkbox>
146
- </div>
147
- </template>
148
- <template if:true={cell.isDataTypeScope}>
149
- <!-- Row Header Cell -->
150
- <div class={cell.class}
151
- role="rowheader"
152
- style={cell.style}
153
- aria-selected={cell.ariaSelected}
154
- aria-readonly={cell.ariaReadOnly}
155
- tabindex={cell.tabIndex}
156
- data-label={cell.dataLabel}
157
- key={cell.colKeyValue}>
158
- <lightning-primitive-cell-factory
159
- types={privateTypes}
140
+ data-col-key-value={cell.colKeyValue}
141
+ key={cell.colKeyValue}>
142
+ <lightning-primitive-cell-checkbox
143
+ dt-context-id={_datatableId}
144
+ has-focus={cell.hasFocus}
145
+ data-label={cell.dataLabel}
146
+ key={cell.key}
147
+ row-key-value={row.key}
148
+ col-key-value={cell.colKeyValue}
149
+ row-index={row.rowIndex}
150
+ type={row.inputType}
151
+ is-selected={row.isSelected}
152
+ is-disabled={row.isDisabled}
153
+ column-header-id={computedCheckboxColumnHeaderId}>
154
+ </lightning-primitive-cell-checkbox>
155
+ </div>
156
+ </template>
157
+ <template if:true={cell.isDataTypeScope}>
158
+ <!-- Row Header Cell -->
159
+ <div class={cell.class}
160
+ role="rowheader"
161
+ style={cell.style}
160
162
  aria-selected={cell.ariaSelected}
163
+ aria-readonly={cell.ariaReadOnly}
164
+ tabindex={cell.tabIndex}
161
165
  data-label={cell.dataLabel}
162
- alignment={cell.alignment}
163
- has-error={cell.hasError}
164
- has-focus={cell.hasFocus}
165
- column-label={cell.dataLabel}
166
- column-type={cell.columnType}
167
- column-sub-type={cell.columnSubType}
168
- wrap-text={cell.wrapText}
169
- wrap-text-max-lines={cell.wrapTextMaxLines}
170
- key={cell.columnType}
171
- row-key-value={row.key}
172
- col-key-value={cell.colKeyValue}
173
- value={cell.value}
174
- icon-name={cell.iconName}
175
- icon-label={cell.iconLabel}
176
- icon-position={cell.iconPosition}
177
- icon-alternative-text={cell.iconAlternativeText}
178
- editable={cell.editable}
179
- display-read-only-icon={cell.displayReadOnlyIcon}
180
- type-attribute-0={cell.typeAttribute0}
181
- type-attribute-1={cell.typeAttribute1}
182
- type-attribute-2={cell.typeAttribute2}
183
- type-attribute-3={cell.typeAttribute3}
184
- type-attribute-4={cell.typeAttribute4}
185
- type-attribute-5={cell.typeAttribute5}
186
- type-attribute-6={cell.typeAttribute6}
187
- type-attribute-7={cell.typeAttribute7}
188
- type-attribute-8={cell.typeAttribute8}
189
- type-attribute-9={cell.typeAttribute9}
190
- type-attribute-10={cell.typeAttribute10}
191
- type-attribute-21={cell.typeAttribute21}
192
- type-attribute-22={cell.typeAttribute22}>
193
- </lightning-primitive-cell-factory>
194
- </div>
195
- </template>
196
- <template if:true={cell.isDataType}>
197
- <!-- Non-Header Cells (Regular Data Cells) -->
198
- <div class={cell.class}
199
- role="gridcell"
200
- style={cell.style}
201
- aria-selected={cell.ariaSelected}
202
- aria-readonly={cell.ariaReadOnly}
203
- tabindex={cell.tabIndex}
204
- data-label={cell.dataLabel}
205
- key={cell.colKeyValue}>
206
- <lightning-primitive-cell-factory
207
- types={privateTypes}
166
+ data-col-key-value={cell.colKeyValue}
167
+ key={cell.colKeyValue}>
168
+ <lightning-primitive-cell-factory
169
+ types={privateTypes}
170
+ aria-selected={cell.ariaSelected}
171
+ data-label={cell.dataLabel}
172
+ alignment={cell.alignment}
173
+ has-error={cell.hasError}
174
+ has-focus={cell.hasFocus}
175
+ column-label={cell.dataLabel}
176
+ column-type={cell.columnType}
177
+ column-sub-type={cell.columnSubType}
178
+ wrap-text={cell.wrapText}
179
+ wrap-text-max-lines={cell.wrapTextMaxLines}
180
+ key={cell.columnType}
181
+ row-key-value={row.key}
182
+ col-key-value={cell.colKeyValue}
183
+ value={cell.value}
184
+ icon-name={cell.iconName}
185
+ icon-label={cell.iconLabel}
186
+ icon-position={cell.iconPosition}
187
+ icon-alternative-text={cell.iconAlternativeText}
188
+ editable={cell.editable}
189
+ display-read-only-icon={cell.displayReadOnlyIcon}
190
+ type-attribute-0={cell.typeAttribute0}
191
+ type-attribute-1={cell.typeAttribute1}
192
+ type-attribute-2={cell.typeAttribute2}
193
+ type-attribute-3={cell.typeAttribute3}
194
+ type-attribute-4={cell.typeAttribute4}
195
+ type-attribute-5={cell.typeAttribute5}
196
+ type-attribute-6={cell.typeAttribute6}
197
+ type-attribute-7={cell.typeAttribute7}
198
+ type-attribute-8={cell.typeAttribute8}
199
+ type-attribute-9={cell.typeAttribute9}
200
+ type-attribute-10={cell.typeAttribute10}
201
+ type-attribute-21={cell.typeAttribute21}
202
+ type-attribute-22={cell.typeAttribute22}>
203
+ </lightning-primitive-cell-factory>
204
+ </div>
205
+ </template>
206
+ <template if:true={cell.isDataType}>
207
+ <!-- Non-Header Cells (Regular Data Cells) -->
208
+ <div class={cell.class}
209
+ role="gridcell"
210
+ style={cell.style}
208
211
  aria-selected={cell.ariaSelected}
212
+ aria-readonly={cell.ariaReadOnly}
213
+ tabindex={cell.tabIndex}
209
214
  data-label={cell.dataLabel}
210
- alignment={cell.alignment}
211
- has-focus={cell.hasFocus}
212
- has-error={cell.hasError}
213
- column-label={cell.dataLabel}
214
- column-type={cell.columnType}
215
- column-sub-type={cell.columnSubType}
216
- wrap-text={cell.wrapText}
217
- wrap-text-max-lines={cell.wrapTextMaxLines}
218
- key={cell.columnType}
219
- row-key-value={row.key}
220
- col-key-value={cell.colKeyValue}
221
- value={cell.value}
222
- icon-name={cell.iconName}
223
- icon-label={cell.iconLabel}
224
- icon-position={cell.iconPosition}
225
- icon-alternative-text={cell.iconAlternativeText}
226
- editable={cell.editable}
227
- display-read-only-icon={cell.displayReadOnlyIcon}
228
- type-attribute-0={cell.typeAttribute0}
229
- type-attribute-1={cell.typeAttribute1}
230
- type-attribute-2={cell.typeAttribute2}
231
- type-attribute-3={cell.typeAttribute3}
232
- type-attribute-4={cell.typeAttribute4}
233
- type-attribute-5={cell.typeAttribute5}
234
- type-attribute-6={cell.typeAttribute6}
235
- type-attribute-7={cell.typeAttribute7}
236
- type-attribute-8={cell.typeAttribute8}
237
- type-attribute-9={cell.typeAttribute9}
238
- type-attribute-10={cell.typeAttribute10}
239
- type-attribute-21={cell.typeAttribute21}
240
- type-attribute-22={cell.typeAttribute22}>
241
- </lightning-primitive-cell-factory>
242
- </div>
215
+ data-col-key-value={cell.colKeyValue}
216
+ key={cell.colKeyValue}>
217
+ <lightning-primitive-cell-factory
218
+ types={privateTypes}
219
+ aria-selected={cell.ariaSelected}
220
+ data-label={cell.dataLabel}
221
+ alignment={cell.alignment}
222
+ has-focus={cell.hasFocus}
223
+ has-error={cell.hasError}
224
+ column-label={cell.dataLabel}
225
+ column-type={cell.columnType}
226
+ column-sub-type={cell.columnSubType}
227
+ wrap-text={cell.wrapText}
228
+ wrap-text-max-lines={cell.wrapTextMaxLines}
229
+ key={cell.columnType}
230
+ row-key-value={row.key}
231
+ col-key-value={cell.colKeyValue}
232
+ value={cell.value}
233
+ icon-name={cell.iconName}
234
+ icon-label={cell.iconLabel}
235
+ icon-position={cell.iconPosition}
236
+ icon-alternative-text={cell.iconAlternativeText}
237
+ editable={cell.editable}
238
+ display-read-only-icon={cell.displayReadOnlyIcon}
239
+ type-attribute-0={cell.typeAttribute0}
240
+ type-attribute-1={cell.typeAttribute1}
241
+ type-attribute-2={cell.typeAttribute2}
242
+ type-attribute-3={cell.typeAttribute3}
243
+ type-attribute-4={cell.typeAttribute4}
244
+ type-attribute-5={cell.typeAttribute5}
245
+ type-attribute-6={cell.typeAttribute6}
246
+ type-attribute-7={cell.typeAttribute7}
247
+ type-attribute-8={cell.typeAttribute8}
248
+ type-attribute-9={cell.typeAttribute9}
249
+ type-attribute-10={cell.typeAttribute10}
250
+ type-attribute-21={cell.typeAttribute21}
251
+ type-attribute-22={cell.typeAttribute22}>
252
+ </lightning-primitive-cell-factory>
253
+ </div>
243
254
  </template>
244
255
  </template>
245
256
  </div>
@@ -41,6 +41,7 @@
41
41
  <thead>
42
42
  <!-- Column Header Row -->
43
43
  <tr class="slds-line-height_reset"
44
+ data-row-key-value="HEADER"
44
45
  onprivateresizestart={handleResizeStart}
45
46
  onprivateresizeend={handleResizeEnd}>
46
47
  <template for:each={state.columns} for:item="def" for:index="colIndex">
@@ -50,6 +51,7 @@
50
51
  tabindex={def.tabIndex}
51
52
  aria-label={def.ariaLabel}
52
53
  aria-sort={def.sortAriaLabel}
54
+ data-col-key-value={def.colKeyValue}
53
55
  key={def.colKeyValue}>
54
56
 
55
57
  <template if:true={def.fixedWidth}>
@@ -117,6 +119,7 @@
117
119
  role="gridcell"
118
120
  tabindex={cell.tabIndex}
119
121
  data-label={cell.dataLabel}
122
+ data-col-key-value={cell.colKeyValue}
120
123
  key={cell.colKeyValue}>
121
124
  <lightning-primitive-cell-checkbox
122
125
  dt-context-id={_datatableId}
@@ -142,6 +145,7 @@
142
145
  scope="row"
143
146
  tabindex={cell.tabIndex}
144
147
  data-label={cell.dataLabel}
148
+ data-col-key-value={cell.colKeyValue}
145
149
  key={cell.colKeyValue}>
146
150
  <lightning-primitive-cell-factory
147
151
  types={privateTypes}
@@ -190,6 +194,7 @@
190
194
  aria-readonly={cell.ariaReadOnly}
191
195
  tabindex={cell.tabIndex}
192
196
  data-label={cell.dataLabel}
197
+ data-col-key-value={cell.colKeyValue}
193
198
  key={cell.colKeyValue}>
194
199
  <lightning-primitive-cell-factory
195
200
  types={privateTypes}
@@ -109,3 +109,17 @@ export function getScrollOffsetFromTableEnd(el) {
109
109
  el.scrollHeight - el.parentNode.scrollTop - el.parentNode.clientHeight
110
110
  );
111
111
  }
112
+
113
+ /**
114
+ * Utility for converting arrays and plain objects to style strings
115
+ * @param {Array|Object} style
116
+ * @returns {string} representing array/object as a string
117
+ */
118
+ export function styleToString(style) {
119
+ if (!Array.isArray(style)) {
120
+ return Object.entries(style)
121
+ .map(([key, value]) => `${key}:${value}`)
122
+ .join(';');
123
+ }
124
+ return style.join(';');
125
+ }
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Creates and returns a metadata object the contains information about the
3
+ * number of fixed, flexible, and resized columns in the table
4
+ *
5
+ * @param {Object} columnWidthMetaData The initial column widths metadata
6
+ * @param {Object} columnDefs The column definition object
7
+ * @returns {Object} The computed metadata
8
+ */
1
9
  export function getTotalWidthsMetadata(columnWidthMetaData, columnDefs) {
2
10
  const initial = {
3
11
  totalFixedWidth: 0,
@@ -28,14 +36,24 @@ export function getTotalWidthsMetadata(columnWidthMetaData, columnDefs) {
28
36
  }
29
37
 
30
38
  /**
31
- * Get width of dom element.
32
- * @param {node} element - target dom element
33
- * @returns {number} - integer width of element
39
+ * Gets the width of a DOM element.
40
+ *
41
+ * @param {Node} element Target DOM element
42
+ * @returns {Number} The width of the DOM element
34
43
  */
35
44
  export function getDomWidth(element) {
36
45
  return element.offsetWidth;
37
46
  }
38
47
 
48
+ /**
49
+ * Gets the width of a column. If the column has a fixed width,
50
+ * it will always return that value. If the column does not have a fixed
51
+ * width, it will return the resized value (if applicable), otherwise
52
+ * the initial width.
53
+ *
54
+ * @param {Object} column The column object
55
+ * @returns {Number} The fixed width, resized width, or initial width of the column (in that priority order)
56
+ */
39
57
  export function getColumnWidthFromDef(column) {
40
58
  let resizedWidth;
41
59
  if (column.isResized) {
@@ -44,6 +62,12 @@ export function getColumnWidthFromDef(column) {
44
62
  return column.fixedWidth || resizedWidth || column.initialWidth;
45
63
  }
46
64
 
65
+ /**
66
+ * Creates a width CSS style string from a numeric value
67
+ *
68
+ * @param {Number} pixels Number of pixels
69
+ * @returns {String} The CSS width definition
70
+ */
47
71
  export function buildCSSWidthStyle(pixels) {
48
72
  return pixels > 0 ? `width:${pixels}px` : '';
49
73
  }