lightning-base-components 1.13.6-alpha → 1.13.10-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 (189) hide show
  1. package/metadata/raptor.json +104 -2
  2. package/package.json +37 -1
  3. package/scopedImports/@salesforce-label-LightningAlert.defaultLabel.js +1 -0
  4. package/scopedImports/@salesforce-label-LightningConfirm.defaultLabel.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningDateTimePicker.selectDateFor.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningInteractiveDialogBase.cancel.js +1 -0
  7. package/scopedImports/@salesforce-label-LightningInteractiveDialogBase.ok.js +1 -0
  8. package/scopedImports/@salesforce-label-LightningLookup.recentItems.js +1 -0
  9. package/scopedImports/@salesforce-label-LightningModalBase.close.js +1 -0
  10. package/scopedImports/@salesforce-label-LightningModalBase.waitstate.js +1 -0
  11. package/scopedImports/@salesforce-label-LightningPrompt.defaultLabel.js +1 -0
  12. package/src/lightning/baseCombobox/baseCombobox.html +50 -24
  13. package/src/lightning/baseCombobox/baseCombobox.js +53 -28
  14. package/src/lightning/card/card.html +7 -1
  15. package/src/lightning/card/card.js +30 -2
  16. package/src/lightning/card/utils.js +14 -0
  17. package/src/lightning/combobox/combobox.css +12 -0
  18. package/src/lightning/combobox/combobox.html +1 -0
  19. package/src/lightning/datatable/__docs__/datatable.md +40 -13
  20. package/src/lightning/datatable/columnWidthManager.js +8 -4
  21. package/src/lightning/datatable/columns-shared.js +8 -7
  22. package/src/lightning/datatable/columns.js +38 -4
  23. package/src/lightning/datatable/datatable.js +932 -727
  24. package/src/lightning/datatable/datatableResizeObserver.js +1 -1
  25. package/src/lightning/datatable/inlineEdit.js +15 -3
  26. package/src/lightning/datatable/keyboard.js +1078 -935
  27. package/src/lightning/datatable/resizer.js +92 -109
  28. package/src/lightning/datatable/rows.js +245 -59
  29. package/src/lightning/datatable/sort.js +83 -28
  30. package/src/lightning/datatable/{normalizer.js → state.js} +16 -28
  31. package/src/lightning/datatable/templates/div/div.css +53 -0
  32. package/src/lightning/datatable/templates/div/div.html +272 -0
  33. package/src/lightning/datatable/{datatable.css → templates/table/table.css} +0 -0
  34. package/src/lightning/datatable/templates/table/table.html +260 -0
  35. package/src/lightning/datatable/widthManagerShared.js +1 -1
  36. package/src/lightning/datepicker/datepicker.html +3 -3
  37. package/src/lightning/datepicker/datepicker.js +6 -2
  38. package/src/lightning/datetimepicker/datetimepicker.html +3 -4
  39. package/src/lightning/datetimepicker/datetimepicker.js +0 -2
  40. package/src/lightning/formattedRichText/__docs__/formattedRichText.md +1 -0
  41. package/src/lightning/helptext/helptext.js +8 -0
  42. package/src/lightning/iconSvgTemplates/buildTemplates/standard/asset_audit.html +7 -0
  43. package/src/lightning/iconSvgTemplates/buildTemplates/standard/attach.html +7 -0
  44. package/src/lightning/iconSvgTemplates/buildTemplates/standard/contract_payment.html +10 -0
  45. package/src/lightning/iconSvgTemplates/buildTemplates/standard/field_sales.html +8 -0
  46. package/src/lightning/iconSvgTemplates/buildTemplates/standard/historical_adherence.html +9 -0
  47. package/src/lightning/iconSvgTemplates/buildTemplates/standard/med_rec_recommendation.html +8 -0
  48. package/src/lightning/iconSvgTemplates/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
  49. package/src/lightning/iconSvgTemplates/buildTemplates/standard/medication_dispense.html +11 -0
  50. package/src/lightning/iconSvgTemplates/buildTemplates/standard/medication_reconciliation.html +7 -0
  51. package/src/lightning/iconSvgTemplates/buildTemplates/standard/report_type.html +9 -0
  52. package/src/lightning/iconSvgTemplates/buildTemplates/standard/story.html +2 -4
  53. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tour.html +9 -0
  54. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tour_check.html +8 -0
  55. package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
  56. package/src/lightning/iconSvgTemplates/buildTemplates/standard/unified_health_score.html +7 -0
  57. package/src/lightning/iconSvgTemplates/buildTemplates/standard/workforce_engagement.html +8 -0
  58. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +26 -1
  59. package/src/lightning/iconSvgTemplates/buildTemplates/utility/asset_audit.html +9 -0
  60. package/src/lightning/iconSvgTemplates/buildTemplates/utility/collection_alt.html +8 -0
  61. package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_doc.html +8 -0
  62. package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_payment.html +10 -0
  63. package/src/lightning/iconSvgTemplates/buildTemplates/utility/einstein.html +2 -1
  64. package/src/lightning/iconSvgTemplates/buildTemplates/utility/entitlement.html +7 -0
  65. package/src/lightning/iconSvgTemplates/buildTemplates/utility/field_sales.html +8 -0
  66. package/src/lightning/iconSvgTemplates/buildTemplates/utility/signature.html +9 -0
  67. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tour.html +9 -0
  68. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tour_check.html +8 -0
  69. package/src/lightning/iconSvgTemplates/buildTemplates/utility/truck.html +10 -0
  70. package/src/lightning/iconSvgTemplates/buildTemplates/utility/workforce_engagement.html +8 -0
  71. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/asset_audit.html +7 -0
  72. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/attach.html +7 -0
  73. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/contract_payment.html +10 -0
  74. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/field_sales.html +8 -0
  75. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/historical_adherence.html +9 -0
  76. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/med_rec_recommendation.html +8 -0
  77. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
  78. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/medication_dispense.html +11 -0
  79. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/medication_reconciliation.html +7 -0
  80. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/report_type.html +9 -0
  81. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/story.html +2 -4
  82. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tour.html +9 -0
  83. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tour_check.html +8 -0
  84. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
  85. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/unified_health_score.html +7 -0
  86. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/workforce_engagement.html +8 -0
  87. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +26 -1
  88. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/asset_audit.html +9 -0
  89. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/collection_alt.html +8 -0
  90. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_doc.html +8 -0
  91. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_payment.html +10 -0
  92. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/einstein.html +2 -1
  93. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/entitlement.html +7 -0
  94. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/field_sales.html +8 -0
  95. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/signature.html +9 -0
  96. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tour.html +9 -0
  97. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tour_check.html +8 -0
  98. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/truck.html +10 -0
  99. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/workforce_engagement.html +8 -0
  100. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/asset_audit.html +7 -0
  101. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/attach.html +7 -0
  102. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/contract_payment.html +10 -0
  103. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/field_sales.html +8 -0
  104. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/historical_adherence.html +9 -0
  105. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/med_rec_recommendation.html +8 -0
  106. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
  107. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/medication_dispense.html +11 -0
  108. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/medication_reconciliation.html +7 -0
  109. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/report_type.html +9 -0
  110. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/story.html +2 -4
  111. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tour.html +9 -0
  112. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tour_check.html +8 -0
  113. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
  114. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/unified_health_score.html +7 -0
  115. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/workforce_engagement.html +8 -0
  116. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +15 -1
  117. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/asset_audit.html +7 -0
  118. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/attach.html +7 -0
  119. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/contract_payment.html +10 -0
  120. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/field_sales.html +8 -0
  121. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/historical_adherence.html +9 -0
  122. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/med_rec_recommendation.html +8 -0
  123. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
  124. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/medication_dispense.html +11 -0
  125. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/medication_reconciliation.html +7 -0
  126. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/report_type.html +9 -0
  127. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/story.html +2 -4
  128. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tour.html +9 -0
  129. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tour_check.html +8 -0
  130. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
  131. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/unified_health_score.html +7 -0
  132. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/workforce_engagement.html +8 -0
  133. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +15 -1
  134. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +12 -1
  135. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/asset_audit.html +9 -0
  136. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/collection_alt.html +8 -0
  137. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_doc.html +8 -0
  138. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_payment.html +10 -0
  139. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/einstein.html +2 -1
  140. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/entitlement.html +7 -0
  141. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/field_sales.html +8 -0
  142. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/signature.html +9 -0
  143. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tour.html +9 -0
  144. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tour_check.html +8 -0
  145. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/truck.html +10 -0
  146. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/workforce_engagement.html +8 -0
  147. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +12 -1
  148. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/asset_audit.html +9 -0
  149. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/collection_alt.html +8 -0
  150. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_doc.html +8 -0
  151. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_payment.html +10 -0
  152. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/einstein.html +2 -1
  153. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/entitlement.html +7 -0
  154. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/field_sales.html +8 -0
  155. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/signature.html +9 -0
  156. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tour.html +9 -0
  157. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tour_check.html +8 -0
  158. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/truck.html +10 -0
  159. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/workforce_engagement.html +8 -0
  160. package/src/lightning/input/__docs__/input.md +4 -0
  161. package/src/lightning/input/input.js +11 -6
  162. package/src/lightning/pill/link.html +1 -1
  163. package/src/lightning/pill/pill.js +18 -0
  164. package/src/lightning/pill/plainLink.html +2 -0
  165. package/src/lightning/pillContainer/barePillContainer.html +5 -5
  166. package/src/lightning/pillContainer/pillContainer.js +5 -4
  167. package/src/lightning/pillContainer/standardPillContainer.html +5 -5
  168. package/src/lightning/positionLibrary/__component__/positionLibraryBounding.spec.js +8 -6
  169. package/src/lightning/positionLibrary/__component__/x/bounding/bounding.html +1 -1
  170. package/src/lightning/positionLibrary/__component__/x/bounding/bounding.js +6 -9
  171. package/src/lightning/positionLibrary/direction.js +17 -5
  172. package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.js +20 -0
  173. package/src/lightning/primitiveDatatableIeditTypeFactory/primitiveDatatableIeditTypeFactory.js +10 -0
  174. package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.js +17 -3
  175. package/src/lightning/primitiveDatatableTooltip/primitiveDatatableTooltip.js +1 -0
  176. package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +5 -4
  177. package/src/lightning/primitiveHeaderFactory/primitiveHeaderFactory.js +255 -94
  178. package/src/lightning/primitiveHeaderFactory/selectableHeader.html +25 -23
  179. package/src/lightning/primitiveHeaderFactory/sortableHeader.html +13 -9
  180. package/src/lightning/progressIndicator/progressIndicator.js +30 -9
  181. package/src/lightning/progressRing/progressRing.html +6 -0
  182. package/src/lightning/progressRing/progressRing.js +98 -3
  183. package/src/lightning/progressStep/progressStep.js +6 -3
  184. package/src/lightning/timepicker/timepicker.html +1 -0
  185. package/src/lightning/utilsPrivate/aria.js +30 -0
  186. package/src/lightning/utilsPrivate/contentMutation.js +24 -2
  187. package/src/lightning/utilsPrivate/utilsPrivate.js +1 -1
  188. package/src/lightning/datatable/datatable.html +0 -237
  189. package/src/lightning/datatable/keys.js +0 -32
@@ -159,4 +159,14 @@ export default class LightningPrimitiveDatatableIeditTypeFactory extends Lightni
159
159
  this._columnDef.editableCustomType && this._columnDef.editTemplate
160
160
  );
161
161
  }
162
+
163
+ /**
164
+ * Checks if type is an custom type that is editable and
165
+ * has an editTemplate that contains [data-inputable="true"]
166
+ * Used when checking if cell can actually be edited
167
+ */
168
+ @api
169
+ get isEditableCustomValid() {
170
+ return this.isValidCustomType && this.concreteComponent;
171
+ }
162
172
  }
@@ -21,7 +21,7 @@ export default class LightningPrimitiveDatatableStatusBar extends LightningEleme
21
21
  this.privateError = value;
22
22
 
23
23
  if (this.showError && this.isSaveBtnFocused()) {
24
- this.focusOnErrorMessages();
24
+ this.handleShowError();
25
25
  }
26
26
  }
27
27
 
@@ -34,6 +34,11 @@ export default class LightningPrimitiveDatatableStatusBar extends LightningEleme
34
34
  return error && (error.title || error.messages);
35
35
  }
36
36
 
37
+ get showErrorBubble() {
38
+ const { error } = this;
39
+ return error && error.showBubble;
40
+ }
41
+
37
42
  get bubbleOffset() {
38
43
  // move bubble above the docked bar since docked bar has higher z-index
39
44
  // and can block the nubbin of the bubble
@@ -77,14 +82,23 @@ export default class LightningPrimitiveDatatableStatusBar extends LightningEleme
77
82
  return this.template.querySelector('button.save-btn:focus') !== null;
78
83
  }
79
84
 
80
- focusOnErrorMessages() {
85
+ /**
86
+ * Handling between displaying/focusing tooltip icon and/or error bubble
87
+ * If showBubble property is set within error object, display/focus the error bubble.
88
+ * Otherwise, display/focus the tooltip icon only.
89
+ */
90
+ handleShowError() {
81
91
  Promise.resolve().then(() => {
82
92
  const trigger = this.template.querySelector(
83
93
  'lightning-primitive-datatable-tooltip'
84
94
  );
85
95
 
86
96
  if (trigger) {
87
- trigger.focus();
97
+ if (this.showErrorBubble) {
98
+ trigger.showBubble();
99
+ } else {
100
+ trigger.focus();
101
+ }
88
102
  }
89
103
  });
90
104
  }
@@ -151,6 +151,7 @@ export default class LightningPrimitiveDatatableTooltip extends LightningElement
151
151
  }
152
152
  };
153
153
 
154
+ @api
154
155
  showBubble() {
155
156
  this._showErrorBubble = true;
156
157
 
@@ -1,8 +1,7 @@
1
1
  <template>
2
- <div
3
- class={computedClass}
4
- style={columnStyles}
5
- >
2
+ <div class={computedClass} style={columnStyles}>
3
+
4
+ <!-- Header Content -->
6
5
  <span class="slds-th__action">
7
6
  <template if:true={def.iconName}>
8
7
  <div class="slds-grid slds-grid_vertical-align-center slds-has-flexi-truncate">
@@ -17,6 +16,7 @@
17
16
  <span class="slds-truncate" if:false={def.label} title={def.ariaLabel}></span>
18
17
  </template>
19
18
 
19
+ <!-- Header Actions -->
20
20
  <template if:true={hasActions}>
21
21
  <lightning-primitive-header-actions
22
22
  col-key-value={def.colKeyValue}
@@ -26,6 +26,7 @@
26
26
  ></lightning-primitive-header-actions>
27
27
  </template>
28
28
 
29
+ <!-- Resize Handler -->
29
30
  <template if:true={isResizable}>
30
31
  <lightning-primitive-resize-handler
31
32
  value={columnWidth}
@@ -22,35 +22,45 @@ const i18n = {
22
22
  sortNone: labelSortNone,
23
23
  };
24
24
 
25
- function preventDefaultAndStopPropagation(event) {
26
- event.preventDefault();
27
- event.stopPropagation();
28
- }
29
-
25
+ /**
26
+ * A table column header.
27
+ */
30
28
  export default class PrimitiveHeaderFactory extends PrimitiveDatatableCell {
31
- @api colIndex;
32
- @api sorted;
33
- @api sortedDirection;
34
- @api resizestep;
35
- @api columnWidth;
36
- @api actions;
37
- @api showCheckbox = false;
38
- @api dtContextId;
29
+ // Tracked objects
30
+ @track _def = {};
39
31
 
32
+ // Private variables
40
33
  _resizable;
41
- @track _def = {};
42
34
  _sortable = false;
35
+ _hideHeader = false;
43
36
 
44
- @api
45
- get resizable() {
46
- return this._resizable;
47
- }
37
+ /************************** PUBLIC ATTRIBUTES ***************************/
48
38
 
49
- set resizable(value) {
50
- this._resizable = value;
51
- this.updateElementClasses();
39
+ @api actions;
40
+ @api colIndex;
41
+ @api columnWidth;
42
+ @api dtContextId;
43
+ @api resizestep;
44
+ @api showCheckbox = false;
45
+ @api sorted;
46
+ @api sortedDirection;
47
+
48
+ /**
49
+ * Retrieves the computed header DOM `id`
50
+ *
51
+ * @return {string} The DOM `id`
52
+ */
53
+ @api
54
+ get computedColumnHeaderId() {
55
+ const el = this.template.querySelector('[data-column-header]');
56
+ return getRealDOMId(el);
52
57
  }
53
58
 
59
+ /**
60
+ * Defines the data type for the column
61
+ *
62
+ * @type {string}
63
+ */
54
64
  @api
55
65
  get def() {
56
66
  return this._def;
@@ -61,18 +71,44 @@ export default class PrimitiveHeaderFactory extends PrimitiveDatatableCell {
61
71
  this.updateElementClasses();
62
72
  }
63
73
 
74
+ /**
75
+ * Defines whether the table header is hidden
76
+ *
77
+ * @type {boolean}
78
+ */
64
79
  @api
65
- get sortable() {
66
- return this._sortable;
80
+ get hideHeader() {
81
+ return this._hideHeader;
67
82
  }
68
83
 
84
+ set hideHeader(value) {
85
+ this._hideHeader = value;
86
+ this.updateElementClasses();
87
+ }
88
+
89
+ /**
90
+ * Defines whether the column is resizable
91
+ *
92
+ * @type {boolean}
93
+ */
69
94
  @api
70
- getDomWidth() {
71
- const child = this.template.querySelector('.slds-cell-fixed');
72
- if (child) {
73
- return child.offsetWidth;
74
- }
75
- return '';
95
+ get resizable() {
96
+ return this._resizable;
97
+ }
98
+
99
+ set resizable(value) {
100
+ this._resizable = value;
101
+ this.updateElementClasses();
102
+ }
103
+
104
+ /**
105
+ * Defines whether the column is sortable
106
+ *
107
+ * @type {boolean}
108
+ */
109
+ @api
110
+ get sortable() {
111
+ return this._sortable;
76
112
  }
77
113
 
78
114
  set sortable(value) {
@@ -80,111 +116,230 @@ export default class PrimitiveHeaderFactory extends PrimitiveDatatableCell {
80
116
  this.updateElementClasses();
81
117
  }
82
118
 
83
- render() {
84
- if (this.isSelectableHeader) {
85
- return selectable;
86
- } else if (this.sortable) {
87
- return sortable;
88
- }
89
- return nonsortable;
90
- }
119
+ /************************** PUBLIC METHODS ***************************/
91
120
 
92
- renderedCallback() {
93
- if (this.isSelectableHeader && this.showCheckbox) {
94
- this.updateBulkSelectionCheckbox();
121
+ /**
122
+ * Retrieves the header cell's width
123
+ *
124
+ * @return {string} The width of the cell
125
+ */
126
+ @api
127
+ getDomWidth() {
128
+ const child = this.template.querySelector('.slds-cell-fixed');
129
+ if (child) {
130
+ return child.offsetWidth;
95
131
  }
132
+ return '';
96
133
  }
97
134
 
98
- updateElementClasses() {
99
- classListMutation(this.classList, {
100
- 'slds-is-sortable': this.isSortable,
101
- 'slds-is-resizable': this.isResizable,
102
- });
103
- }
135
+ /************************** PRIVATE GETTERS **************************/
104
136
 
137
+ /**
138
+ * Computes the styles for the column
139
+ *
140
+ * @return {string} The computed inline styles
141
+ */
105
142
  get columnStyles() {
106
143
  const outlineStyle = this.isSortable ? '' : 'outline:none;';
107
144
 
108
145
  // In RTL, we need to explicitly position the column headers.
109
146
  // We do this by setting the offset (in pixels) from the start of the table.
110
147
  const offsetStyle = isRTL() ? `right: ${this.def.offset}px;` : '';
148
+ const widthStyle = this.columnWidth
149
+ ? `width: ${this.columnWidth}px;`
150
+ : '';
111
151
 
112
152
  return `
113
- width: ${this.columnWidth}px;
153
+ ${widthStyle}
114
154
  ${outlineStyle}
115
155
  ${offsetStyle}
116
156
  `;
117
157
  }
118
158
 
159
+ /**
160
+ * Computes the classes for the column
161
+ *
162
+ * @return {string} The computed classes
163
+ */
119
164
  get computedClass() {
120
165
  return classSet('slds-cell-fixed')
121
166
  .add({ 'slds-has-button-menu': this.hasActions })
122
167
  .toString();
123
168
  }
124
169
 
170
+ /**
171
+ * Computes the sort classes for the column
172
+ *
173
+ * @return {string} The computed sort classes
174
+ */
125
175
  get computedSortClass() {
126
176
  return classSet('slds-th__action slds-text-link_reset')
127
177
  .add({ 'slds-is-sorted': this.sorted })
128
- .add({ 'slds-is-sorted_asc': this.isAscSorting })
129
- .add({ 'slds-is-sorted_desc': this.isDescSorting })
178
+ .add({ 'slds-is-sorted_asc': this.isAscSorted })
179
+ .add({ 'slds-is-sorted_desc': this.isDescSorted })
130
180
  .toString();
131
181
  }
132
182
 
133
- get isAscSorting() {
134
- return this.sortedDirection === 'asc';
183
+ /**
184
+ * Computes an option name
185
+ *
186
+ * @return {string} The computed option name
187
+ */
188
+ get computedOptionName() {
189
+ return `${this.dtContextId}-options`;
135
190
  }
136
191
 
137
- get isDescSorting() {
138
- return this.sortedDirection === 'desc';
192
+ /**
193
+ * Determines if the header has actions available
194
+ *
195
+ * @return {boolean} Whether the header has available actions
196
+ */
197
+ get hasActions() {
198
+ return (
199
+ this.actions.customerActions.length > 0 ||
200
+ this.actions.internalActions.length > 0
201
+ );
139
202
  }
140
203
 
141
- get sortedOrderLabel() {
142
- if (this.sorted) {
143
- return this.sortedDirection === 'desc'
144
- ? i18n.sortDesc
145
- : i18n.sortAsc;
146
- }
147
- return i18n.sortNone;
204
+ /**
205
+ * Returns the header's aria role
206
+ *
207
+ * @return {string|boolean} The aria role for the header
208
+ */
209
+ get headerRole() {
210
+ return this.isResizable || this.sortable ? 'button' : false;
148
211
  }
149
212
 
150
- get isSelectableHeader() {
151
- return this.def.type === 'SELECTABLE_CHECKBOX';
213
+ /**
214
+ * Determines if sort direction is set to ascending
215
+ *
216
+ * @return {boolean} Whether the sort direction is ascending
217
+ */
218
+ get isAscSorted() {
219
+ return this.sortedDirection === 'asc';
152
220
  }
153
221
 
222
+ /**
223
+ * Determines if sort direction is set to descending
224
+ *
225
+ * @return {boolean} Whether the sort direction is descending
226
+ */
227
+ get isDescSorted() {
228
+ return this.sortedDirection === 'desc';
229
+ }
230
+
231
+ /**
232
+ * Determines if the header is regular (unselectable)
233
+ *
234
+ * @return {boolean} Whether the header is regular
235
+ */
154
236
  get isRegularHeader() {
155
237
  return this.def.type !== 'SELECTABLE_CHECKBOX';
156
238
  }
157
239
 
240
+ /**
241
+ * Determines if the header is resizable
242
+ *
243
+ * @return {boolean} Whether the header is resizable
244
+ */
158
245
  get isResizable() {
159
246
  return this.resizable && this.def.resizable !== false;
160
247
  }
161
248
 
249
+ /**
250
+ * Determines if the header is selectable
251
+ *
252
+ * @return {boolean} Whether the header is selectable
253
+ */
254
+ get isSelectableHeader() {
255
+ return this.def.type === 'SELECTABLE_CHECKBOX';
256
+ }
257
+
258
+ /**
259
+ * Determines if the header is sortable
260
+ *
261
+ * @return {boolean} Whether the header is sortable
262
+ */
162
263
  get isSortable() {
163
264
  return this.sortable;
164
265
  }
165
266
 
267
+ /**
268
+ * Returns the internationalization language mapping
269
+ *
270
+ * @return {Object} The i18n mapping
271
+ */
166
272
  get i18n() {
167
273
  return i18n;
168
274
  }
169
275
 
170
- get headerRole() {
171
- return this.isResizable || this.sortable ? 'button' : false;
172
- }
173
-
276
+ /**
277
+ * Returns the header's resize step
278
+ *
279
+ * @return {number} The resize step for the header
280
+ */
174
281
  get resizeStep() {
175
282
  return this.resizestep;
176
283
  }
177
284
 
178
- get computedOptionName() {
179
- return `${this.dtContextId}-options`;
285
+ /**
286
+ * Returns the sort order label in the appropriate language
287
+ *
288
+ * @return {string} Language-specific sort order label
289
+ */
290
+ get sortedOrderLabel() {
291
+ if (this.sorted) {
292
+ return this.sortedDirection === 'desc'
293
+ ? i18n.sortDesc
294
+ : i18n.sortAsc;
295
+ }
296
+ return i18n.sortNone;
180
297
  }
181
298
 
182
- @api
183
- get computedColumnHeaderId() {
184
- const el = this.template.querySelector('[data-column-header]');
185
- return getRealDOMId(el);
299
+ /************************** LIFECYCLE HOOKS **************************/
300
+
301
+ /**
302
+ * Renders the appropriate template: selectableHeader.html,
303
+ * sortableHeader.html, or nonsortableHeader.html.
304
+ * By default, nonsortableHeader.html is rendered
305
+ */
306
+ render() {
307
+ if (this.isSelectableHeader) {
308
+ return selectable;
309
+ } else if (this.sortable) {
310
+ return sortable;
311
+ }
312
+ return nonsortable;
313
+ }
314
+
315
+ renderedCallback() {
316
+ if (this.isSelectableHeader && this.showCheckbox) {
317
+ this.updateBulkSelectionCheckbox();
318
+ }
319
+ }
320
+
321
+ /************************** EVENT HANDLERS ***************************/
322
+
323
+ /**
324
+ * Handles a sorting click on a header
325
+ *
326
+ * @param {Event} event
327
+ */
328
+ handleSortingClick(event) {
329
+ event.preventDefault();
330
+
331
+ if (this.isSortable) {
332
+ event.stopPropagation();
333
+ this.fireSortedColumn();
334
+ this.fireCellFocusByClickEvent();
335
+ }
186
336
  }
187
337
 
338
+ /************************ EVENT DISPATCHERS **************************/
339
+
340
+ /**
341
+ * Handles selecting all rows
342
+ */
188
343
  handleSelectAllRows() {
189
344
  const { rowKeyValue, colKeyValue } = this;
190
345
  const actionName =
@@ -204,25 +359,9 @@ export default class PrimitiveHeaderFactory extends PrimitiveDatatableCell {
204
359
  this.dispatchEvent(actionEvent);
205
360
  }
206
361
 
207
- handleSortingClick(event) {
208
- event.preventDefault();
209
- if (this.isSortable) {
210
- preventDefaultAndStopPropagation(event);
211
- this.fireSortedColumn();
212
- this.fireCellFocusByClickEvent();
213
- }
214
- }
215
-
216
- getTargetSortDirection() {
217
- if (this.sorted) {
218
- return this.sortedDirection === 'desc' ? 'asc' : 'desc';
219
- }
220
- return this.sortedDirection;
221
- }
222
-
223
362
  /**
224
363
  * Notifies the parent datatable component by firing a private event with
225
- * the details of the sort action.
364
+ * the details of the sort action
226
365
  */
227
366
  fireSortedColumn() {
228
367
  const event = new CustomEvent('privateupdatecolsort', {
@@ -234,16 +373,38 @@ export default class PrimitiveHeaderFactory extends PrimitiveDatatableCell {
234
373
  sortDirection: this.getTargetSortDirection(),
235
374
  },
236
375
  });
376
+
237
377
  this.dispatchEvent(event);
238
378
  }
239
379
 
240
- get hasActions() {
241
- return (
242
- this.actions.customerActions.length > 0 ||
243
- this.actions.internalActions.length > 0
244
- );
380
+ /************************* HELPER FUNCTIONS **************************/
381
+
382
+ /**
383
+ * Updates classes based on sort, resize and header eligibility
384
+ */
385
+ updateElementClasses() {
386
+ classListMutation(this.classList, {
387
+ 'slds-is-sortable': this.isSortable,
388
+ 'slds-is-resizable': this.isResizable,
389
+ 'slds-assistive-text': this.hideHeader,
390
+ });
391
+ }
392
+
393
+ /**
394
+ * Determines the opposite direction to sort on based on the current direction
395
+ *
396
+ * @return {string} The new sort direction
397
+ */
398
+ getTargetSortDirection() {
399
+ if (this.sorted) {
400
+ return this.sortedDirection === 'desc' ? 'asc' : 'desc';
401
+ }
402
+ return this.sortedDirection;
245
403
  }
246
404
 
405
+ /**
406
+ * Determines the state of the header "all" checkbox based on current selections
407
+ */
247
408
  updateBulkSelectionCheckbox() {
248
409
  const allCheckbox = this.template.querySelector(
249
410
  '.datatable-select-all'
@@ -1,30 +1,32 @@
1
1
  <template>
2
- <div class="slds-th__action slds-th__action_form slds-cell-fixed"
3
- style={columnStyles}>
2
+ <!-- Header Content -->
3
+ <div class="slds-th__action slds-th__action_form slds-cell-fixed" style={columnStyles}>
4
4
  <template if:true={showCheckbox}>
5
- <span class="slds-checkbox">
6
- <input
7
- type="checkbox"
8
- class="datatable-select-all"
9
- name={computedOptionName}
10
- id="lgt-dt-header-factory-id"
11
- onclick={handleSelectAllRows}
12
- tabindex={internalTabIndex}
13
- data-navigation="enable"
14
- disabled={def.isBulkSelectionDisabled}
15
- >
16
- <label class="slds-checkbox__label" for="lgt-dt-header-factory-id">
17
- <span class="slds-checkbox_faux"></span>
18
- <span class="slds-form-element__label slds-assistive-text">
19
- {i18n.selectAll}
20
- </span>
21
- </label>
22
- </span>
5
+ <span class="slds-checkbox">
6
+
7
+ <!-- Selectable Checkbox -->
8
+ <input
9
+ type="checkbox"
10
+ class="datatable-select-all"
11
+ name={computedOptionName}
12
+ id="lgt-dt-header-factory-id"
13
+ onclick={handleSelectAllRows}
14
+ tabindex={internalTabIndex}
15
+ data-navigation="enable"
16
+ disabled={def.isBulkSelectionDisabled}>
17
+
18
+ <label class="slds-checkbox__label" for="lgt-dt-header-factory-id">
19
+ <span class="slds-checkbox_faux"></span>
20
+ <span class="slds-form-element__label slds-assistive-text">
21
+ {i18n.selectAll}
22
+ </span>
23
+ </label>
24
+ </span>
23
25
  </template>
24
26
  <template if:false={showCheckbox}>
25
- <span id="column-group-header" class="slds-assistive-text" data-column-header>
26
- {i18n.chooseARow}
27
- </span>
27
+ <span id="column-group-header" class="slds-assistive-text" data-column-header>
28
+ {i18n.chooseARow}
29
+ </span>
28
30
  </template>
29
31
  </div>
30
32
  </template>
@@ -1,19 +1,19 @@
1
1
  <template>
2
- <span
3
- class={computedClass}
4
- tabindex={internalTabIndex}
5
- style={columnStyles}
6
- >
2
+ <!-- Header Content -->
3
+ <span class={computedClass} tabindex={internalTabIndex} style={columnStyles}>
4
+
7
5
  <a href="javascript:void(0);"
8
6
  class={computedSortClass}
9
7
  role={headerRole}
10
8
  tabindex={internalTabIndex}
11
9
  data-navigation="enable"
12
10
  onclick={handleSortingClick}
13
- style={columnStyles} data-action-triggers="enter">
11
+ style={columnStyles}
12
+ data-action-triggers="enter">
14
13
 
15
14
  <span class="slds-assistive-text">{i18n.sort}</span>
16
15
 
16
+ <!-- Icon to display to the left/start of the header text -->
17
17
  <template if:true={def.iconName}>
18
18
  <div class="slds-grid slds-grid_vertical-align-center slds-has-flexi-truncate">
19
19
  <lightning-icon icon-name={def.iconName} size="x-small" class="slds-icon_container slds-m-right_xx-small" alternative-text={def.label} title={def.label}></lightning-icon>
@@ -21,17 +21,18 @@
21
21
  <span class="slds-truncate">{def.label}</span>
22
22
  </template>
23
23
 
24
+ <!-- Arrow Icon - Rotates based on sorting direction -->
24
25
  <lightning-primitive-icon
25
26
  class="slds-icon_container"
26
27
  svg-class="slds-icon slds-icon-text-default slds-is-sortable__icon"
27
28
  icon-name="utility:arrowdown"
28
29
  size="x-small">
29
30
  </lightning-primitive-icon>
30
-
31
31
  </div>
32
32
  </template>
33
33
  <template if:false={def.iconName}>
34
34
  <span class="slds-truncate" title={def.label}>{def.label}</span>
35
+ <!-- Arrow Icon - Rotates based on sorting direction -->
35
36
  <lightning-primitive-icon
36
37
  class="slds-icon_container"
37
38
  svg-class="slds-icon slds-icon-text-default slds-is-sortable__icon"
@@ -41,17 +42,20 @@
41
42
  </template>
42
43
  </a>
43
44
 
45
+ <!-- Aria Live Region to announce sorting order -->
44
46
  <span class="slds-assistive-text" aria-live="polite" aria-atomic="true">{sortedOrderLabel}</span>
45
47
 
48
+ <!-- Header Actions -->
46
49
  <template if:true={hasActions}>
47
50
  <lightning-primitive-header-actions
48
51
  col-key-value={def.colKeyValue}
49
52
  actions={actions}
50
53
  tabindex={internalTabIndex}
51
- data-navigation="enable"
52
- ></lightning-primitive-header-actions>
54
+ data-navigation="enable">
55
+ </lightning-primitive-header-actions>
53
56
  </template>
54
57
 
58
+ <!-- Resize Handler -->
55
59
  <template if:true={isResizable}>
56
60
  <lightning-primitive-resize-handler
57
61
  value={columnWidth}