lightning-base-components 1.21.3-alpha → 1.21.4-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 (183) hide show
  1. package/metadata/raptor.json +49 -0
  2. package/package.json +88 -21
  3. package/scopedImports/@salesforce-label-LightningDatatable.showActions.js +1 -1
  4. package/scopedImports/@salesforce-label-LightningForm.controllerFieldsMessage.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningForm.dependentFieldsHeader.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningForm.dependentFieldsListHeading.js +1 -0
  7. package/scopedImports/@salesforce-label-LightningForm.generalDependentFieldsMessage.js +1 -0
  8. package/scopedImports/@salesforce-label-LightningForm.learnMore.js +1 -0
  9. package/scopedImports/@salesforce-label-LightningForm.okButton.js +1 -0
  10. package/scopedImports/@salesforce-label-LightningLookup.modalCancel.js +1 -0
  11. package/scopedImports/@salesforce-label-LightningLookup.modalSelect.js +1 -0
  12. package/scopedImports/@salesforce-label-LightningProgressIndicator.currentStage.js +1 -1
  13. package/scopedImports/@salesforce-label-LightningProgressIndicator.errorStage.js +1 -0
  14. package/scopedImports/@salesforce-label-LightningProgressIndicator.stageComplete.js +1 -1
  15. package/scopedImports/@salesforce-label-LightningProgressIndicator.stageNotStarted.js +1 -1
  16. package/src/lightning/avatar/avatar.html +1 -0
  17. package/src/lightning/badge/badge.html +3 -3
  18. package/src/lightning/baseCombobox/baseCombobox.html +4 -1
  19. package/src/lightning/baseCombobox/baseCombobox.js +3 -16
  20. package/src/lightning/button/__docs__/button.md +2 -1
  21. package/src/lightning/button/button.js +3 -4
  22. package/src/lightning/buttonIcon/__docs__/buttonIcon.md +1 -0
  23. package/src/lightning/buttonIcon/buttonIcon.html +1 -1
  24. package/src/lightning/buttonIcon/buttonIcon.js +18 -17
  25. package/src/lightning/buttonMenu/buttonMenu.css +5 -0
  26. package/src/lightning/buttonMenu/buttonMenu.js +2 -0
  27. package/src/lightning/colorPickerCustom/colorPickerCustom.js +12 -0
  28. package/src/lightning/colorPickerPanel/colorPickerPanel.js +11 -1
  29. package/src/lightning/combobox/combobox.html +1 -0
  30. package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.html +11 -0
  31. package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.js +25 -0
  32. package/src/lightning/datatable/__examples__disabled/customComponentWrapper/generateData.js +15 -0
  33. package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/customInput.html +4 -0
  34. package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/myCustomTypeDatatable.js +17 -0
  35. package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/nestedSimpleComponentParent.html +7 -0
  36. package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.html +9 -0
  37. package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.js +6 -0
  38. package/src/lightning/datatable/autoWidthStrategy.js +8 -36
  39. package/src/lightning/datatable/columnResizer.js +51 -161
  40. package/src/lightning/datatable/columnWidthManager.js +25 -81
  41. package/src/lightning/datatable/columns.js +180 -302
  42. package/src/lightning/datatable/datatable.js +455 -441
  43. package/src/lightning/datatable/errors.js +17 -29
  44. package/src/lightning/datatable/fixedWidthStrategy.js +7 -22
  45. package/src/lightning/datatable/headerActions.js +8 -38
  46. package/src/lightning/datatable/indexes.js +42 -0
  47. package/src/lightning/datatable/infiniteLoading.js +16 -35
  48. package/src/lightning/datatable/inlineEdit.js +125 -156
  49. package/src/lightning/datatable/keyboard.js +226 -282
  50. package/src/lightning/datatable/renderManager.js +0 -4
  51. package/src/lightning/datatable/resizeObserver.js +4 -13
  52. package/src/lightning/datatable/rowLevelActions.js +2 -2
  53. package/src/lightning/datatable/rowNumber.js +21 -59
  54. package/src/lightning/datatable/rowSelection.js +95 -178
  55. package/src/lightning/datatable/rowSelectionShared.js +13 -27
  56. package/src/lightning/datatable/rows.js +171 -418
  57. package/src/lightning/datatable/sort.js +16 -75
  58. package/src/lightning/datatable/templates/div/div.html +12 -4
  59. package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +10 -16
  60. package/src/lightning/datatable/templates/table/table.html +15 -5
  61. package/src/lightning/datatable/tree.js +17 -35
  62. package/src/lightning/datatable/types.js +10 -31
  63. package/src/lightning/datatable/utils.js +49 -24
  64. package/src/lightning/datatable/virtualization.js +2 -5
  65. package/src/lightning/datatable/widthManagerShared.js +0 -20
  66. package/src/lightning/datatable/wrapText.js +29 -60
  67. package/src/lightning/dualListbox/dualListbox.js +7 -8
  68. package/src/lightning/formattedName/formattedName.js +3 -2
  69. package/src/lightning/formattedName/formattedName.js-meta.xml +3 -0
  70. package/src/lightning/formattedNumber/formattedNumber.js +3 -2
  71. package/src/lightning/formattedNumber/formattedNumber.js-meta.xml +3 -0
  72. package/src/lightning/formattedRichText/richTextConfig.js +1 -0
  73. package/src/lightning/helptext/helptext.css +7 -0
  74. package/src/lightning/helptext/helptext.js +3 -4
  75. package/src/lightning/icon/icon.html +1 -1
  76. package/src/lightning/input/input.html +5 -0
  77. package/src/lightning/inputAddress/addressFormat.js +31 -4
  78. package/src/lightning/inputAddress/fieldsLayout.js +6 -0
  79. package/src/lightning/inputAddress/inputAddress.html +19 -1
  80. package/src/lightning/inputAddress/inputAddress.js +74 -3
  81. package/src/lightning/internationalizationLibrary/address/AddressFormat.js +553 -610
  82. package/src/lightning/lookupAddress/lookupAddress.html +6 -1
  83. package/src/lightning/lookupAddress/lookupAddress.js +25 -0
  84. package/src/lightning/modal/__docs__/modal.md +10 -1
  85. package/src/lightning/modal/__modalUtils__/modalContainerTestConstants.js +3 -7
  86. package/src/lightning/modal/__modalUtils__/modalContainerTestMethods.js +39 -133
  87. package/src/lightning/modal/__modalUtils__/modalContainerTestMockData.js +1 -1
  88. package/src/lightning/modal/modal.js +1 -1
  89. package/src/lightning/modalBase/modalBase.html +15 -10
  90. package/src/lightning/modalBase/modalBase.js +131 -146
  91. package/src/lightning/modalBody/modalBody.css +6 -0
  92. package/src/lightning/modalHeader/modalHeader.html +16 -4
  93. package/src/lightning/modalHeader/modalHeader.js +61 -14
  94. package/src/lightning/pill/link.html +1 -0
  95. package/src/lightning/pill/plain.html +1 -0
  96. package/src/lightning/pill/plainLink.html +1 -0
  97. package/src/lightning/primitiveBubble/primitiveBubble.js +42 -0
  98. package/src/lightning/primitiveDatatableCell/primitiveDatatableCell.js +1 -1
  99. package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.html +1 -1
  100. package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +13 -0
  101. package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +19 -6
  102. package/src/lightning/primitiveHeaderFactory/sortableHeader.html +3 -1
  103. package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.css +11 -0
  104. package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.html +2 -1
  105. package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.js +1 -0
  106. package/src/lightning/progressStep/base.html +5 -6
  107. package/src/lightning/progressStep/progressStep.js +14 -9
  108. package/src/lightning/prompt/__docs__/prompt.md +1 -1
  109. package/src/lightning/shadowBaseClassPrivate/shadowBaseClassPrivate.js +0 -2
  110. package/src/lightning/sldsCommon/sldsCommon.css +134 -98
  111. package/src/lightning/sldsUtilsAlignment/sldsUtilsAlignment.css +1 -1
  112. package/src/lightning/sldsUtilsBox/sldsUtilsBox.css +14 -13
  113. package/src/lightning/sldsUtilsGrid/sldsUtilsGrid.css +95 -92
  114. package/src/lightning/sldsUtilsHyphenation/sldsUtilsHyphenation.css +1 -1
  115. package/src/lightning/sldsUtilsMargin/sldsUtilsMargin.css +77 -75
  116. package/src/lightning/sldsUtilsPadding/sldsUtilsPadding.css +73 -73
  117. package/src/lightning/sldsUtilsSizing/sldsUtilsSizing.css +552 -558
  118. package/src/lightning/sldsUtilsVisibility/sldsUtilsVisibility.css +2 -2
  119. package/src/lightning/staticMap/staticMap.js +3 -2
  120. package/src/lightning/tab/tab.js +6 -3
  121. package/src/lightning/tab/tab.js-meta.xml +3 -0
  122. package/src/lightning/tabBar/tabBar.js +10 -5
  123. package/src/lightning/tabset/tabset.html +2 -0
  124. package/src/lightning/tabset/tabset.js-meta.xml +3 -0
  125. package/src/lightning/textarea/textarea.js +6 -1
  126. package/src/lightning/toastContainer/__docs__/toastContainer.md +3 -2
  127. package/src/lightning/tooltipLibrary/tooltipLibrary.js +24 -15
  128. package/src/lightning/verticalNavigation/vertical-navigation.slds.css +14 -0
  129. package/src/lightning/verticalNavigation/verticalNavigation.css +1 -1
  130. package/src/lightning/verticalNavigation/verticalNavigation.html +1 -1
  131. package/src/lightning/verticalNavigation/verticalNavigation.js +66 -28
  132. package/src/lightning/verticalNavigation/verticalNavigation.js-meta.xml +3 -0
  133. package/src/lightning/verticalNavigationItem/vertical-navigation-item.slds.css +63 -0
  134. package/src/lightning/verticalNavigationItem/verticalNavigationItem.css +2 -3
  135. package/src/lightning/verticalNavigationItem/verticalNavigationItem.js +29 -15
  136. package/src/lightning/verticalNavigationItem/verticalNavigationItem.js-meta.xml +3 -0
  137. package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.native.css +2 -0
  138. package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.synthetic.css +3 -0
  139. package/src/lightning/verticalNavigationItemBadge/badge.slds.css +76 -0
  140. package/src/lightning/verticalNavigationItemBadge/vertical-navigation-item.slds.css +63 -0
  141. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.css +2 -3
  142. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.html +1 -1
  143. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js +28 -15
  144. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js-meta.xml +3 -0
  145. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.native.css +5 -0
  146. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.synthetic.css +3 -0
  147. package/src/lightning/verticalNavigationItemIcon/vertical-navigation-item.slds.css +63 -0
  148. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.css +2 -3
  149. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js +29 -15
  150. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js-meta.xml +3 -0
  151. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.native.css +3 -0
  152. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.synthetic.css +3 -0
  153. package/src/lightning/verticalNavigationOverflow/button.slds.css +503 -0
  154. package/src/lightning/verticalNavigationOverflow/vertical-navigation-item.slds.css +63 -0
  155. package/src/lightning/verticalNavigationOverflow/vertical-navigation-section.slds.css +17 -0
  156. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.css +2 -1
  157. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.html +2 -0
  158. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js +18 -13
  159. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js-meta.xml +3 -0
  160. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.lbc.native.css +5 -0
  161. package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +14 -14
  162. package/src/lightning/verticalNavigationSection/verticalNavigationSection.js-meta.xml +3 -0
  163. package/src/lightning/datatable/inlineEditShared.js +0 -26
  164. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.html +0 -0
  165. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.js +0 -0
  166. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +0 -0
  167. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.js +0 -0
  168. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.html +0 -0
  169. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.js +0 -0
  170. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.html +0 -0
  171. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.js +0 -0
  172. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html +0 -0
  173. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +0 -0
  174. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customDatatypeTable.js +0 -0
  175. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customLink.html +0 -0
  176. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customName.html +0 -0
  177. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumber.html +0 -0
  178. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumberEdit.html +0 -0
  179. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/deleteRow.html +0 -0
  180. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/iconPill.html +0 -0
  181. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/orderingButtons.html +0 -0
  182. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customNestedComponent/customNestedComponent.html +0 -0
  183. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customNestedComponent/customNestedComponent.js +0 -0
@@ -1,33 +1,6 @@
1
1
  import { assert } from 'lightning/utilsPrivate';
2
2
  import { getColumnName } from './columns-shared';
3
3
 
4
- const VALID_SORT_DIRECTIONS = {
5
- asc: true,
6
- desc: true,
7
- };
8
-
9
- /**
10
- * Determines if the supplied sort direction is valid.
11
- * Refer to `VALID_SORT_DIRECTIONS` for valid solid directions.
12
- *
13
- * @param {String} value The sort direction to validate
14
- * @returns {Boolean} Whether the supplied sort direction is valid
15
- */
16
- export function isValidSortDirection(value) {
17
- return !!VALID_SORT_DIRECTIONS[value];
18
- }
19
-
20
- /**
21
- * Gets the default sort direction. When clicking on a header to sort,
22
- * the default sort direction is applied first. Clicking again reverses it
23
- *
24
- * @param {Object} state The datatable state
25
- * @returns {String} The default sort direction
26
- */
27
- export function getDefaultSortDirection(state) {
28
- return state.defaultSortDirection;
29
- }
30
-
31
4
  /**
32
5
  * Sets the default sort direction. When clicking on a header to sort,
33
6
  * the default sort direction is applied first. Clicking again reverses it
@@ -36,7 +9,7 @@ export function getDefaultSortDirection(state) {
36
9
  * @param {String} value The value to update the default sort direction to
37
10
  */
38
11
  export function setDefaultSortDirection(state, value) {
39
- if (isValidSortDirection(value)) {
12
+ if (value === 'asc' || value === 'desc') {
40
13
  state.defaultSortDirection = value;
41
14
  return;
42
15
  }
@@ -44,20 +17,10 @@ export function setDefaultSortDirection(state, value) {
44
17
  false,
45
18
  `The "defaultSortDirection" value passed into lightning:datatable
46
19
  is incorrect, "defaultSortDirection" value should be one of
47
- ${Object.keys(VALID_SORT_DIRECTIONS).join()}.`
20
+ 'asc' or 'desc'.`
48
21
  );
49
22
  }
50
23
 
51
- /**
52
- * Gets the current sort direction
53
- *
54
- * @param {Object} state The datatable state
55
- * @returns {String} The current sort direction
56
- */
57
- export function getSortedDirection(state) {
58
- return state.sortedDirection;
59
- }
60
-
61
24
  /**
62
25
  * Sets the current sort direction.
63
26
  * In the case an invalid sort direction is provided, throw
@@ -68,7 +31,7 @@ export function getSortedDirection(state) {
68
31
  * @param {String} value The value to update the sort direction to
69
32
  */
70
33
  export function setSortedDirection(state, value) {
71
- if (isValidSortDirection(value)) {
34
+ if (value === 'asc' || value === 'desc') {
72
35
  state.sortedDirection = value;
73
36
  return;
74
37
  }
@@ -76,22 +39,11 @@ export function setSortedDirection(state, value) {
76
39
  false,
77
40
  `The "sortedDirection" value passed into lightning:datatable
78
41
  is incorrect, "sortedDirection" value should be one of
79
- ${Object.keys(VALID_SORT_DIRECTIONS).join()}.`
42
+ 'asc' or 'desc'.`
80
43
  );
81
44
  state.sortedDirection = undefined;
82
45
  }
83
46
 
84
- /**
85
- * Gets the current sort value. The value will match the name
86
- * of a given column in the datatable
87
- *
88
- * @param {Object} state The datatable state
89
- * @returns {String} The current sort value
90
- */
91
- export function getSortedBy(state) {
92
- return state.sortedBy;
93
- }
94
-
95
47
  /**
96
48
  * Sets the current sort value. The value should match the name
97
49
  * of a given column in the datatable. In the case that a
@@ -115,29 +67,18 @@ export function setSortedBy(state, value) {
115
67
  * @param {Object} state The current datatable state
116
68
  */
117
69
  export function updateSorting(state) {
118
- const { columns } = state;
70
+ const { columns, defaultSortDirection, sortedBy, sortedDirection } = state;
119
71
  for (let i = 0, { length } = columns; i < length; i += 1) {
120
- updateColumnSortingState(columns[i], state);
121
- }
122
- }
123
-
124
- /**
125
- * Applies sorting to a datatable column
126
- *
127
- * @param {Object} col The datatable column name to sort
128
- * @param {Object} state The current datatable state
129
- */
130
- export function updateColumnSortingState(col, state) {
131
- const { sortedBy, sortedDirection, defaultSortDirection } = state;
132
- const { sortable } = col;
133
- if (sortable && getColumnName(col) === sortedBy) {
134
- col.sorted = true;
135
- col.sortAriaLabel =
136
- sortedDirection === 'desc' ? 'descending' : 'ascending';
137
- col.sortedDirection = sortedDirection;
138
- } else {
139
- col.sorted = false;
140
- col.sortAriaLabel = sortable ? 'other' : null;
141
- col.sortedDirection = defaultSortDirection;
72
+ const col = columns[i];
73
+ if (col.sortable && getColumnName(col) === sortedBy) {
74
+ col.sorted = true;
75
+ col.sortAriaLabel =
76
+ sortedDirection === 'desc' ? 'descending' : 'ascending';
77
+ col.sortedDirection = sortedDirection;
78
+ } else {
79
+ col.sorted = false;
80
+ col.sortAriaLabel = col.sortable ? 'other' : null;
81
+ col.sortedDirection = defaultSortDirection;
82
+ }
142
83
  }
143
84
  }
@@ -23,15 +23,15 @@
23
23
  onmasscheckboxchange={handleMassCheckboxChange}
24
24
  ></lightning-primitive-datatable-iedit-panel>
25
25
  <!-- Table Container -->
26
- <div class={computedTableContainerClass} onscroll={handleHorizontalScroll} style={scrollerXStyles}>
27
- <div class="slds-scrollable_y" onscroll={handleVerticalScroll} style={computedScrollerStyle}>
26
+ <div class={computedTableContainerClass} onscroll={handleHorizontalScroll} style={computedScrollerXStyle}>
27
+ <div class="slds-scrollable_y" onscroll={handleVerticalScroll} style={computedScrollerYStyle}>
28
28
  <!-- Corresponds to <table> -->
29
29
  <div class={computedTableClass}
30
30
  part="datagrid"
31
31
  role={computedTableRole}
32
32
  style={computedTableStyle}
33
33
  onkeydown={handleTableKeydown}
34
- onclick={handleCellClick}
34
+ onclick={handleTableCellClick}
35
35
  onfocusin={handleTableFocusIn}
36
36
  onfocusout={handleTableFocusOut}
37
37
  aria-label={ariaLabel}
@@ -177,6 +177,7 @@
177
177
  style={cell.style}
178
178
  aria-selected={cell.ariaSelected}
179
179
  aria-readonly={cell.ariaReadOnly}
180
+ aria-describedby={cell.describedBy}
180
181
  tabindex={cell.tabIndex}
181
182
  data-label={cell.dataLabel}
182
183
  data-col-key-value={cell.colKeyValue}
@@ -217,6 +218,9 @@
217
218
  type-attribute-21={cell.typeAttribute21}
218
219
  type-attribute-22={cell.typeAttribute22}>
219
220
  </lightning-primitive-cell-factory>
221
+ <template if:true={cell.describedBy}>
222
+ <span id={cell.describedBy} class="slds-hide">Unsaved</span>
223
+ </template>
220
224
  </div>
221
225
  </template>
222
226
  <template if:true={cell.isDataType}>
@@ -234,6 +238,7 @@
234
238
  <lightning-primitive-cell-factory
235
239
  types={privateTypes}
236
240
  aria-selected={cell.ariaSelected}
241
+ aria-describedby={cell.describedBy}
237
242
  data-label={cell.dataLabel}
238
243
  alignment={cell.alignment}
239
244
  has-focus={cell.hasFocus}
@@ -267,6 +272,9 @@
267
272
  type-attribute-21={cell.typeAttribute21}
268
273
  type-attribute-22={cell.typeAttribute22}>
269
274
  </lightning-primitive-cell-factory>
275
+ <template if:true={cell.describedBy}>
276
+ <span id={cell.describedBy} class="slds-hide">Unsaved</span>
277
+ </template>
270
278
  </div>
271
279
  </template>
272
280
  </template>
@@ -275,7 +283,7 @@
275
283
  <!-- Loading Indicator -->
276
284
  <template if:true={isLoading}>
277
285
  <div>
278
- <div colspan={numberOfColumns} class="slds-is-relative">
286
+ <div colspan={state.columns.length} class="slds-is-relative">
279
287
  <lightning-primitive-datatable-loading-indicator></lightning-primitive-datatable-loading-indicator>
280
288
  </div>
281
289
  </div>
@@ -1,9 +1,7 @@
1
- /* TODO: fix first row's top border and last row's bottom border. first row issue is due to
2
- * using a sticky header. further investigation is needed for the last row issue.
3
- */
1
+ /* TODO: fix last row's bottom border */
4
2
 
5
3
  .slds-table_header-fixed [part='datagrid-header'] {
6
- position: sticky;
4
+ position: absolute;
7
5
  top: 0;
8
6
  min-height: var(--slds-g-sizing-9);
9
7
  z-index: 1;
@@ -13,11 +11,6 @@
13
11
  height: 0;
14
12
  }
15
13
 
16
- /* required as header above is using position: sticky */
17
- .slds-table_header-fixed_container {
18
- padding-top: unset;
19
- }
20
-
21
14
  /* Cells */
22
15
  [part='cell'] {
23
16
  position: relative;
@@ -51,16 +44,17 @@
51
44
  /* row border on hover */
52
45
  [data-row-key-value]:hover [role='gridcell']:not(.slds-has-focus),
53
46
  [data-row-key-value]:hover [role='rowheader']:not(.slds-has-focus) {
54
- box-shadow: inset 0 var(--slds-g-sizing-border-1) var(--slds-g-color-border-1),
55
- inset 0 calc(var(--slds-g-sizing-border-1) * -1) var(--slds-g-color-border-1);
47
+ box-shadow: inset 0 var(--slds-g-sizing-border-1)
48
+ var(--slds-g-color-border-1),
49
+ inset 0 calc(var(--slds-g-sizing-border-1) * -1)
50
+ var(--slds-g-color-border-1);
56
51
  }
57
52
 
58
53
  .slds-table_header-fixed [data-row-key-value]:first-child {
59
54
  border-top: 0;
60
55
  }
61
56
 
62
-
63
- [role="row"] {
57
+ [role='row'] {
64
58
  /* Required for row numbers */
65
59
  counter-increment: row-number;
66
60
  display: flex;
@@ -68,16 +62,16 @@
68
62
 
69
63
  /* Move column header row to left;
70
64
  TODO: See if there a better way */
71
- [role="grid"]>[role="rowgroup"]:nth-child(1) {
65
+ [role='grid'] > [role='rowgroup']:nth-child(1) {
72
66
  margin-left: -0.5rem;
73
67
  }
74
68
 
75
69
  /* TODO: Replace with styling hook */
76
- [role="row"]:hover {
70
+ [role='row']:hover {
77
71
  background-color: #f3f2f2;
78
72
  }
79
73
  /* TODO: Replace with styling hook */
80
- [role="row"].slds-is-selected {
74
+ [role='row'].slds-is-selected {
81
75
  background-color: #ecebea;
82
76
  }
83
77
 
@@ -22,14 +22,14 @@
22
22
  onmasscheckboxchange={handleMassCheckboxChange}>
23
23
  </lightning-primitive-datatable-iedit-panel>
24
24
  <!-- Table Container -->
25
- <div class={computedTableContainerClass} onscroll={handleHorizontalScroll} style={scrollerXStyles}>
26
- <div class="slds-scrollable_y" onscroll={handleVerticalScroll} style={computedScrollerStyle}>
25
+ <div class={computedTableContainerClass} onscroll={handleHorizontalScroll} style={computedScrollerXStyle}>
26
+ <div class="slds-scrollable_y" onscroll={handleVerticalScroll} style={computedScrollerYStyle}>
27
27
  <!-- Table -->
28
28
  <table class={computedTableClass}
29
29
  role={computedTableRole}
30
30
  style={computedTableStyle}
31
31
  onkeydown={handleTableKeydown}
32
- onclick={handleCellClick}
32
+ onclick={handleTableCellClick}
33
33
  onfocusin={handleTableFocusIn}
34
34
  onfocusout={handleTableFocusOut}
35
35
  aria-label={ariaLabel}
@@ -112,6 +112,7 @@
112
112
  <template for:each={renderedRows} for:item="row" for:index="rowIndex">
113
113
  <!-- Data Rows -->
114
114
  <tr class={row.classnames}
115
+ role="row"
115
116
  onkeydown={handleKeydownOnDataRow}
116
117
  onprivatelookupitempicked={handlePrivateLookupItemPicked}
117
118
  key={row.key}
@@ -150,6 +151,7 @@
150
151
  <template if:true={cell.isDataTypeScope}>
151
152
  <!-- Row Header Cell -->
152
153
  <th class={cell.class}
154
+ role="rowheader"
153
155
  style={cell.style}
154
156
  aria-selected={cell.ariaSelected}
155
157
  aria-readonly={cell.ariaReadOnly}
@@ -157,7 +159,8 @@
157
159
  tabindex={cell.tabIndex}
158
160
  data-label={cell.dataLabel}
159
161
  data-col-key-value={cell.colKeyValue}
160
- key={cell.colKeyValue}>
162
+ key={cell.colKeyValue}
163
+ aria-describedby={cell.describedBy}>
161
164
  <lightning-primitive-cell-factory
162
165
  types={privateTypes}
163
166
  aria-selected={cell.ariaSelected}
@@ -195,6 +198,9 @@
195
198
  type-attribute-21={cell.typeAttribute21}
196
199
  type-attribute-22={cell.typeAttribute22}>
197
200
  </lightning-primitive-cell-factory>
201
+ <template if:true={cell.describedBy}>
202
+ <span id={cell.describedBy} class="slds-hide">Unsaved</span>
203
+ </template>
198
204
  </th>
199
205
  </template>
200
206
  <template if:true={cell.isDataType}>
@@ -207,6 +213,7 @@
207
213
  tabindex={cell.tabIndex}
208
214
  data-label={cell.dataLabel}
209
215
  data-col-key-value={cell.colKeyValue}
216
+ aria-describedby={cell.describedBy}
210
217
  key={cell.colKeyValue}>
211
218
  <lightning-primitive-cell-factory
212
219
  types={privateTypes}
@@ -245,6 +252,9 @@
245
252
  type-attribute-21={cell.typeAttribute21}
246
253
  type-attribute-22={cell.typeAttribute22}>
247
254
  </lightning-primitive-cell-factory>
255
+ <template if:true={cell.describedBy}>
256
+ <span id={cell.describedBy} class="slds-hide">Unsaved</span>
257
+ </template>
248
258
  </td>
249
259
  </template>
250
260
  </template>
@@ -253,7 +263,7 @@
253
263
  <!-- Loading Indicator -->
254
264
  <template if:true={isLoading}>
255
265
  <tr>
256
- <td colspan={numberOfColumns} class="slds-is-relative">
266
+ <td colspan={state.columns.length} class="slds-is-relative">
257
267
  <lightning-primitive-datatable-loading-indicator></lightning-primitive-datatable-loading-indicator>
258
268
  </td>
259
269
  </tr>
@@ -1,23 +1,3 @@
1
- import { getColumns } from './columns';
2
- import { isTreeType } from './types';
3
-
4
- /**
5
- * Retrieves the default values for the tree state indicator field names.
6
- * These values are used to make logic decisions later and may be updated
7
- * during normal operation.
8
- *
9
- * @returns {Object} The default tree state indicator field names
10
- */
11
- export function getTreeStateIndicatorFieldNames() {
12
- return {
13
- children: 'hasChildren',
14
- level: 'level',
15
- expanded: 'isExpanded',
16
- position: 'posInSet',
17
- setsize: 'setSize',
18
- };
19
- }
20
-
21
1
  /**
22
2
  * Determines if any of the columns in the datatable are of a tree-type.
23
3
  *
@@ -25,9 +5,9 @@ export function getTreeStateIndicatorFieldNames() {
25
5
  * @returns {Boolean} Whether any of the columns are of a tree-type
26
6
  */
27
7
  export function hasTreeDataType(state) {
28
- const columns = getColumns(state);
8
+ const { columns } = state;
29
9
  for (let i = 0, { length } = columns; i < length; i += 1) {
30
- if (isTreeType(columns[i].type)) {
10
+ if (columns[i].type === 'tree') {
31
11
  return true;
32
12
  }
33
13
  }
@@ -41,10 +21,10 @@ export function hasTreeDataType(state) {
41
21
  * @returns {Object} The first tree-type column, else `null`
42
22
  */
43
23
  export function getStateTreeColumn(state) {
44
- const columns = getColumns(state);
24
+ const { columns } = state;
45
25
  for (let i = 0, { length } = columns; i < length; i += 1) {
46
26
  const col = columns[i];
47
- if (isTreeType(col.type)) {
27
+ if (col.type === 'tree') {
48
28
  return col;
49
29
  }
50
30
  }
@@ -54,18 +34,20 @@ export function getStateTreeColumn(state) {
54
34
  /**
55
35
  * Dispatches an event when a row is toggled to be expanded or collapsed.
56
36
  *
37
+ * @param {Object} dt - The datatable instance
57
38
  * @param {String} rowKeyValue The row key being acted upon
58
39
  * @param {Boolean} expanded The current expand/collapse state of the row
59
40
  */
60
- export function fireRowToggleEvent(rowKeyValue, expanded) {
61
- const customEvent = new CustomEvent('privatetogglecell', {
62
- bubbles: true,
63
- composed: true,
64
- cancelable: true,
65
- detail: {
66
- name: rowKeyValue,
67
- nextState: expanded ? false : true, // True = expanded, False = collapsed
68
- },
69
- });
70
- this.dispatchEvent(customEvent);
41
+ export function fireRowToggleEvent(dt, rowKeyValue, expanded) {
42
+ dt.dispatchEvent(
43
+ new CustomEvent('privatetogglecell', {
44
+ bubbles: true,
45
+ composed: true,
46
+ cancelable: true,
47
+ detail: {
48
+ name: rowKeyValue,
49
+ nextState: expanded ? false : true, // True = expanded, False = collapsed
50
+ },
51
+ })
52
+ );
71
53
  }
@@ -149,26 +149,6 @@ export function isValidType(typeName) {
149
149
  return STANDARD_TYPE_NAMES.has(typeName);
150
150
  }
151
151
 
152
- /**
153
- * Determines if a supplied type is a tree type.
154
- *
155
- * @param {String} typeName The type to validate
156
- * @returns {Boolean} Whether the supplied type is a tree type
157
- */
158
- export function isTreeType(typeName) {
159
- return typeName === 'tree';
160
- }
161
-
162
- /**
163
- * Determines if a supplied type is valid for a tree type datatable.
164
- *
165
- * @param {String} typeName The type to validate
166
- * @returns {Boolean} Whether the supplied type is valid for a tree
167
- */
168
- export function isValidTypeForTree(typeName) {
169
- return TREE_SUPPORTED_TYPES.has(typeName);
170
- }
171
-
172
152
  /**
173
153
  * Retrieves the attributes for a given type. Additionally, verifies
174
154
  * the supplied type is valid.
@@ -181,16 +161,6 @@ export function getAttributesNames(typeName) {
181
161
  isValidType(typeName),
182
162
  `You are trying to access an invalid type (${typeName})`
183
163
  );
184
- return getStandardTypeAttributesNames(typeName);
185
- }
186
-
187
- /**
188
- * Retrieves the attributes for a given type.
189
- *
190
- * @param {String} typeName The type to get the attributes for
191
- * @returns {Array} An array of attributes for the supplied type
192
- */
193
- function getStandardTypeAttributesNames(typeName) {
194
164
  return STANDARD_TYPE_NAMES.get(typeName) || [];
195
165
  }
196
166
 
@@ -199,7 +169,6 @@ function getStandardTypeAttributesNames(typeName) {
199
169
  */
200
170
  export default class DatatableTypes {
201
171
  privateCustomTypes = new Map();
202
- isValidTypeForTree = isValidTypeForTree;
203
172
 
204
173
  constructor(types) {
205
174
  if (typeof types === 'object' && types !== null) {
@@ -296,4 +265,14 @@ export default class DatatableTypes {
296
265
  const privateType = this.privateCustomTypes.get(typeName);
297
266
  return privateType ? privateType.standardCellLayout : false;
298
267
  }
268
+
269
+ /**
270
+ * Determines if a supplied type is valid for a tree type datatable.
271
+ *
272
+ * @param {String} typeName The type to validate
273
+ * @returns {Boolean} Whether the supplied type is valid for a tree
274
+ */
275
+ isValidTypeForTree(typeName) {
276
+ return TREE_SUPPORTED_TYPES.has(typeName);
277
+ }
299
278
  }
@@ -22,9 +22,12 @@ const CLASS_SET_PROTOTYPE = {
22
22
  },
23
23
  };
24
24
 
25
+ const NON_NEGATIVE_INTEGER_REGEXP = /^\d+$/;
26
+ const POSITIVE_INTEGER_REGEXP = /^[0-9]*[1-9][0-9]*$/;
27
+
25
28
  /**
26
- * function for escaping double quotes, later can be
27
- * extended in future for any other usecase
29
+ * Escapes double quotes. Later can be
30
+ * extended in future for any other use case.
28
31
  */
29
32
  export function escapeDoubleQuotes(value) {
30
33
  if (typeof value == 'string') {
@@ -68,24 +71,64 @@ export function clamp(num, min, max) {
68
71
  return num <= min ? min : num >= max ? max : num;
69
72
  }
70
73
 
74
+ export function getColDataSelector(colKeyValue) {
75
+ return `[data-col-key-value="${escapeDoubleQuotes(colKeyValue)}"]`;
76
+ }
77
+
78
+ export function getRowDataSelector(rowKeyValue) {
79
+ return `[data-row-key-value="${escapeDoubleQuotes(rowKeyValue)}"]`;
80
+ }
81
+
82
+ /**
83
+ * Gets the grid container element from the scrollerY element.
84
+ *
85
+ * @param {Node} scrollerY The scrollerY element
86
+ * @returns {Node} The grid container element
87
+ */
88
+ export function getGridContainerFromScrollerY(scrollerY) {
89
+ const { firstElementChild: gridContainer } = scrollerY;
90
+ return gridContainer;
91
+ }
92
+
71
93
  /**
72
- * Tests if the value passed in is a value greater than 0.
94
+ * Gets the scrollerX element from the scrollerY element.
95
+ *
96
+ * @param {Node} scrollerY The scrollerY element
97
+ * @returns {Node} The scrollerX element
98
+ */
99
+ export function getScrollerXFromScrollerY(scrollerY) {
100
+ const { parentElement: scrollerX } = scrollerY;
101
+ return scrollerX;
102
+ }
103
+
104
+ /**
105
+ * Gets the scrollerY element from the template.
106
+ *
107
+ * @param {Node} template The datatable template
108
+ * @returns {Node} The scrollerY element
109
+ */
110
+ export function getScrollerY(template) {
111
+ return template.querySelector('.slds-scrollable_y');
112
+ }
113
+
114
+ /**
115
+ * Tests if value represents an integer greater than 0.
73
116
  *
74
117
  * @param {Integer} value Value to test
75
118
  * @returns {Boolean} Whether the value is greater than 0
76
119
  */
77
120
  export function isPositiveInteger(value) {
78
- return /^[0-9]*[1-9][0-9]*$/.test(value);
121
+ return POSITIVE_INTEGER_REGEXP.test(value);
79
122
  }
80
123
 
81
124
  /**
82
- * Tests if the value passed in is 0 or a number greater than 0.
125
+ * Tests if value represents 0 or an integer greater than 0.
83
126
  *
84
127
  * @param {Integer} value Value to test
85
128
  * @returns {Boolean} Whether the value is greater than or equal to 0
86
129
  */
87
130
  export function isNonNegativeInteger(value) {
88
- return /^\d+$/.test(value);
131
+ return NON_NEGATIVE_INTEGER_REGEXP.test(value);
89
132
  }
90
133
 
91
134
  /**
@@ -143,21 +186,3 @@ export function getScrollOffsetFromTableEnd(el) {
143
186
  el.scrollHeight - el.parentNode.scrollTop - el.parentNode.clientHeight
144
187
  );
145
188
  }
146
-
147
- /**
148
- * Utility for converting arrays and plain objects to style strings.
149
- *
150
- * @param {Array | Object} style The CSS style array/object
151
- * @returns {String} Representing array/object as a string
152
- */
153
- export function styleToString(style) {
154
- if (Array.isArray(style)) {
155
- return style.join(';');
156
- }
157
- const entries = Object.keys(style);
158
- for (let i = 0, { length } = entries; i < length; i += 1) {
159
- const key = entries[i];
160
- entries[i] = `${key}:${style[key]}`;
161
- }
162
- return entries.join(';');
163
- }
@@ -1,4 +1,4 @@
1
- import { styleToString, escapeDoubleQuotes } from './utils';
1
+ import { escapeDoubleQuotes } from './utils';
2
2
 
3
3
  /**
4
4
  * sets an initial table height in the datatable state
@@ -311,9 +311,6 @@ function updateVirtualizeStyles(template, state, renderedRows) {
311
311
 
312
312
  // update top of rendered rows based on offsets
313
313
  renderedRows.forEach((row) => {
314
- row.style = styleToString({
315
- position: 'absolute',
316
- top: `${state.offsets[row.rowIndex]}px`,
317
- });
314
+ row.style = `position:absolute;top:${state.offsets[row.rowIndex]}px;`;
318
315
  });
319
316
  }
@@ -36,16 +36,6 @@ export function getTotalWidthsData(columnWidthMetaData, columns) {
36
36
  return totalWidthsData;
37
37
  }
38
38
 
39
- /**
40
- * Gets the width of a DOM element.
41
- *
42
- * @param {Node} element Target DOM element
43
- * @returns {Number} The width of the DOM element
44
- */
45
- export function getDomWidth(element) {
46
- return element.offsetWidth;
47
- }
48
-
49
39
  /**
50
40
  * Gets the width of a column. If the column has a fixed width,
51
41
  * it will always return that value. If the column does not have a fixed
@@ -64,13 +54,3 @@ export function getColumnWidth(column) {
64
54
  ? column.columnWidth || column.initialWidth
65
55
  : column.initialWidth;
66
56
  }
67
-
68
- /**
69
- * Creates a width CSS style string from a numeric value
70
- *
71
- * @param {Number} pixels Number of pixels
72
- * @returns {String} The CSS width definition
73
- */
74
- export function buildCSSWidthStyle(pixels) {
75
- return pixels > 0 ? `width:${pixels}px` : '';
76
- }