lightning-base-components 1.21.6-alpha → 1.21.8-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 (369) hide show
  1. package/metadata/raptor.json +45 -4
  2. package/package.json +125 -3
  3. package/scopedImports/@salesforce-label-LightningColorPicker.a11yDefaultText.js +1 -0
  4. package/scopedImports/@salesforce-label-LightningDatatable.multiColumnSortingToast.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningDatatable.sortingMenuColumns.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningDatatable.sortingMenuMultiColumnSort.js +1 -0
  7. package/scopedImports/@salesforce-label-LightningDatatable.sortingMenuRows.js +1 -0
  8. package/scopedImports/@salesforce-label-LightningDatatable.sortingMenuTooltip.js +1 -0
  9. package/scopedImports/@salesforce-label-LightningForm.dependentFieldsListHeading.js +1 -1
  10. package/scopedImports/@salesforce-label-LightningLookup.advancedSearchMobile.js +1 -1
  11. package/scopedImports/@salesforce-label-LightningLookup.modalTitle.js +1 -0
  12. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.addRule.js +1 -0
  13. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.applyButton.js +1 -0
  14. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.cancelButton.js +1 -0
  15. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.clearButton.js +1 -0
  16. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.duplicateValueValidation.js +1 -0
  17. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.firstRuleHeading.js +1 -0
  18. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.modalTitle.js +1 -0
  19. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.otherRuleHeading.js +1 -0
  20. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.ruleLimit.js +1 -0
  21. package/scopedImports/@salesforce-label-LightningMultiColumnSortingModal.ruleLimitReached.js +1 -0
  22. package/scopedImports/@salesforce-label-LightningPrimitiveColumnSorter.ascending.js +1 -0
  23. package/scopedImports/@salesforce-label-LightningPrimitiveColumnSorter.descending.js +1 -0
  24. package/scopedImports/@salesforce-label-LightningPrimitiveColumnSorter.dropdownPlaceholder.js +1 -0
  25. package/scopedImports/@salesforce-label-LightningPrimitiveColumnSorter.missingValueValidation.js +1 -0
  26. package/scopedImports/@salesforce-label-LightningPrimitiveColumnSorter.moveDownTooltip.js +1 -0
  27. package/scopedImports/@salesforce-label-LightningPrimitiveColumnSorter.moveUpTooltip.js +1 -0
  28. package/scopedImports/@salesforce-label-LightningProgressIndicator.pathCurrentStage.js +1 -0
  29. package/scopedImports/@salesforce-label-LightningRecordPicker.emptyStateNoResultText.js +1 -0
  30. package/scopedImports/@salesforce-label-LightningRecordPicker.messageWhenSearchTermTooShort.js +1 -0
  31. package/scopedImports/@salesforce-label-LightningRecordPicker.resultCountDescriptionForMoreThanOneHundredRecords.js +1 -0
  32. package/scopedImports/@salesforce-label-LightningRecordPicker.resultCountDescriptionForMultipleRecords.js +1 -0
  33. package/scopedImports/@salesforce-label-LightningRecordPicker.resultCountDescriptionForOneRecord.js +1 -0
  34. package/scopedImports/@salesforce-label-LightningRecordPicker.resultsLoading.js +1 -0
  35. package/scopedImports/@salesforce-label-LightningRecordPicker.searchInputHelp.js +1 -0
  36. package/src/lightning/accordion/accordion.js +21 -14
  37. package/src/lightning/accordionSection/button.slds.css +16 -15
  38. package/src/lightning/alert/alert.js +10 -8
  39. package/src/lightning/ariaObserver/ariaObserver.js +19 -5
  40. package/src/lightning/baseCombobox/base-combobox.slds.css +1 -1
  41. package/src/lightning/baseCombobox/baseCombobox.html +2 -1
  42. package/src/lightning/baseCombobox/baseCombobox.js +21 -0
  43. package/src/lightning/baseCombobox/input-text.slds.css +5 -5
  44. package/src/lightning/breadcrumbs/breadcrumbs.slds.css +1 -1
  45. package/src/lightning/button/button.js +5 -0
  46. package/src/lightning/button/button.slds.css +16 -15
  47. package/src/lightning/buttonIcon/__docs__/buttonIcon.md +4 -0
  48. package/src/lightning/buttonIcon/__examples__/basic/basic.html +17 -1
  49. package/src/lightning/buttonIcon/button-icon.slds.css +41 -25
  50. package/src/lightning/buttonIconStateful/button-icon-stateful.slds.css +33 -229
  51. package/src/lightning/buttonIconStateful/button-icon.slds.css +41 -25
  52. package/src/lightning/buttonIconStateful/button.slds.css +16 -15
  53. package/src/lightning/buttonMenu/button-icon.slds.css +41 -25
  54. package/src/lightning/buttonMenu/button-menu.slds.css +41 -15
  55. package/src/lightning/buttonMenu/button.slds.css +16 -15
  56. package/src/lightning/buttonMenu/buttonMenu.css +1 -1
  57. package/src/lightning/buttonMenu/buttonMenu.html +1 -1
  58. package/src/lightning/buttonMenu/buttonMenu.js +44 -4
  59. package/src/lightning/buttonStateful/button-stateful.slds.css +1 -4
  60. package/src/lightning/buttonStateful/button.slds.css +16 -15
  61. package/src/lightning/calendar/calendar.html +3 -4
  62. package/src/lightning/card/card.html +1 -1
  63. package/src/lightning/colorPickerCustom/colorPickerCustom.html +1 -1
  64. package/src/lightning/colorPickerCustom/colorPickerCustom.js +0 -9
  65. package/src/lightning/colorPickerCustom/input-text.slds.css +5 -5
  66. package/src/lightning/combobox/form-element.slds.css +1 -0
  67. package/src/lightning/confirm/confirm.js +10 -8
  68. package/src/lightning/datatable/__docs__/datatable.md +0 -3
  69. package/src/lightning/datatable/__examples__disabled/customComponentPopupTableWrapper/README.md +17 -0
  70. package/src/lightning/datatable/__examples__disabled/customComponentPopupTableWrapper/customComponentPopupTableWrapper.html +11 -0
  71. package/src/lightning/datatable/__examples__disabled/customComponentPopupTableWrapper/customComponentPopupTableWrapper.js +25 -0
  72. package/src/lightning/datatable/__examples__disabled/customComponentPopupTableWrapper/generateData.js +15 -0
  73. package/src/lightning/datatable/__examples__disabled/myCustomTypePopupTable/customInput.html +4 -0
  74. package/src/lightning/datatable/__examples__disabled/myCustomTypePopupTable/myCustomTypePopupTable.js +17 -0
  75. package/src/lightning/datatable/__examples__disabled/myCustomTypePopupTable/nestedSimpleComponentParent.html +7 -0
  76. package/src/lightning/datatable/__examples__disabled/simpleComponentPopupNested/simpleComponentPopupNested.html +31 -0
  77. package/src/lightning/datatable/__examples__disabled/simpleComponentPopupNested/simpleComponentPopupNested.js +36 -0
  78. package/src/lightning/datatable/columnWidthManager.js +19 -16
  79. package/src/lightning/datatable/columns.js +74 -25
  80. package/src/lightning/datatable/datatable.js +493 -133
  81. package/src/lightning/datatable/errors.js +1 -1
  82. package/src/lightning/datatable/indexes.js +32 -19
  83. package/src/lightning/datatable/infiniteLoading.js +6 -5
  84. package/src/lightning/datatable/inlineEdit.js +45 -59
  85. package/src/lightning/datatable/keyboard.js +571 -160
  86. package/src/lightning/datatable/renderManager.js +12 -9
  87. package/src/lightning/datatable/rowLevelActions.js +5 -14
  88. package/src/lightning/datatable/rowSelection.js +36 -17
  89. package/src/lightning/datatable/rowSelectionShared.js +1 -0
  90. package/src/lightning/datatable/rows.js +132 -24
  91. package/src/lightning/datatable/rowsInlining.js +473 -0
  92. package/src/lightning/datatable/sort.js +8 -4
  93. package/src/lightning/datatable/state.js +12 -4
  94. package/src/lightning/datatable/templates/div/div.html +807 -91
  95. package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +29 -3
  96. package/src/lightning/datatable/templates/table/table.css +29 -1
  97. package/src/lightning/datatable/templates/table/table.html +786 -87
  98. package/src/lightning/datatable/utils.js +39 -0
  99. package/src/lightning/datatable/virtualization.js +44 -19
  100. package/src/lightning/datatable/wrapText.js +7 -10
  101. package/src/lightning/datepicker/datepicker.html +3 -1
  102. package/src/lightning/datepicker/datepicker.js +31 -1
  103. package/src/lightning/datepicker/form-element.slds.css +1 -0
  104. package/src/lightning/datepicker/input-text.slds.css +5 -5
  105. package/src/lightning/datetimepicker/datetimepicker.html +7 -1
  106. package/src/lightning/datetimepicker/datetimepicker.js +30 -2
  107. package/src/lightning/datetimepicker/form-element.slds.css +1 -0
  108. package/src/lightning/datetimepicker/input-text.slds.css +5 -5
  109. package/src/lightning/dualListbox/form-element.slds.css +1 -0
  110. package/src/lightning/focusTrap/focusTrap.css +7 -0
  111. package/src/lightning/groupedCombobox/form-element.slds.css +1 -0
  112. package/src/lightning/groupedCombobox/input-text.slds.css +5 -5
  113. package/src/lightning/helptext/button-icon.slds.css +41 -25
  114. package/src/lightning/helptext/form-element.slds.css +1 -0
  115. package/src/lightning/icon/__docs__/icon.md +0 -2
  116. package/src/lightning/iconSvgTemplates/buildTemplates/standard/account_score.html +8 -0
  117. package/src/lightning/iconSvgTemplates/buildTemplates/standard/aggregate.html +8 -0
  118. package/src/lightning/iconSvgTemplates/buildTemplates/standard/app_form_participant.html +11 -0
  119. package/src/lightning/iconSvgTemplates/buildTemplates/standard/app_form_product_participant.html +12 -0
  120. package/src/lightning/iconSvgTemplates/buildTemplates/standard/cost_model.html +7 -0
  121. package/src/lightning/iconSvgTemplates/buildTemplates/standard/labels.html +8 -0
  122. package/src/lightning/iconSvgTemplates/buildTemplates/standard/list_fee.html +7 -0
  123. package/src/lightning/iconSvgTemplates/buildTemplates/standard/list_rate.html +7 -0
  124. package/src/lightning/iconSvgTemplates/buildTemplates/standard/party_profile.html +8 -0
  125. package/src/lightning/iconSvgTemplates/buildTemplates/standard/path_experiment.html +7 -0
  126. package/src/lightning/iconSvgTemplates/buildTemplates/standard/people_score.html +8 -0
  127. package/src/lightning/iconSvgTemplates/buildTemplates/standard/price_adjustment_schedule.html +8 -0
  128. package/src/lightning/iconSvgTemplates/buildTemplates/standard/price_adjustment_tier.html +7 -0
  129. package/src/lightning/iconSvgTemplates/buildTemplates/standard/program_cohort.html +7 -0
  130. package/src/lightning/iconSvgTemplates/buildTemplates/standard/program_cohort_member.html +7 -0
  131. package/src/lightning/iconSvgTemplates/buildTemplates/standard/rate_adjustment.html +7 -0
  132. package/src/lightning/iconSvgTemplates/buildTemplates/standard/record_consent.html +7 -0
  133. package/src/lightning/iconSvgTemplates/buildTemplates/standard/whatsapp.html +7 -0
  134. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +40 -1
  135. package/src/lightning/iconSvgTemplates/buildTemplates/utility/aggregate.html +8 -0
  136. package/src/lightning/iconSvgTemplates/buildTemplates/utility/array.html +7 -0
  137. package/src/lightning/iconSvgTemplates/buildTemplates/utility/bottom_group_alignment.html +7 -0
  138. package/src/lightning/iconSvgTemplates/buildTemplates/utility/cant_sync.html +7 -0
  139. package/src/lightning/iconSvgTemplates/buildTemplates/utility/center_group_alignment.html +8 -0
  140. package/src/lightning/iconSvgTemplates/buildTemplates/utility/columns.html +7 -0
  141. package/src/lightning/iconSvgTemplates/buildTemplates/utility/fully_synced.html +8 -0
  142. package/src/lightning/iconSvgTemplates/buildTemplates/utility/inner_join.html +7 -0
  143. package/src/lightning/iconSvgTemplates/buildTemplates/utility/join.html +8 -0
  144. package/src/lightning/iconSvgTemplates/buildTemplates/utility/left_join.html +14 -0
  145. package/src/lightning/iconSvgTemplates/buildTemplates/utility/macros.html +2 -2
  146. package/src/lightning/iconSvgTemplates/buildTemplates/utility/not_in_sync.html +7 -0
  147. package/src/lightning/iconSvgTemplates/buildTemplates/utility/not_saved.html +9 -0
  148. package/src/lightning/iconSvgTemplates/buildTemplates/utility/outer_join.html +7 -0
  149. package/src/lightning/iconSvgTemplates/buildTemplates/utility/path_experiment.html +7 -0
  150. package/src/lightning/iconSvgTemplates/buildTemplates/utility/program_cohort.html +7 -0
  151. package/src/lightning/iconSvgTemplates/buildTemplates/utility/program_cohort_member.html +7 -0
  152. package/src/lightning/iconSvgTemplates/buildTemplates/utility/record_consent.html +7 -0
  153. package/src/lightning/iconSvgTemplates/buildTemplates/utility/right_join.html +7 -0
  154. package/src/lightning/iconSvgTemplates/buildTemplates/utility/skill.html +8 -0
  155. package/src/lightning/iconSvgTemplates/buildTemplates/utility/sync_in_progress.html +7 -0
  156. package/src/lightning/iconSvgTemplates/buildTemplates/utility/top_group_alignment.html +7 -0
  157. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/account_score.html +8 -0
  158. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/aggregate.html +8 -0
  159. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/app_form_participant.html +11 -0
  160. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/app_form_product_participant.html +12 -0
  161. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/cost_model.html +7 -0
  162. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/labels.html +8 -0
  163. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/list_fee.html +7 -0
  164. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/list_rate.html +7 -0
  165. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/party_profile.html +8 -0
  166. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/path_experiment.html +7 -0
  167. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/people_score.html +8 -0
  168. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/price_adjustment_schedule.html +8 -0
  169. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/price_adjustment_tier.html +7 -0
  170. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/program_cohort.html +7 -0
  171. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/program_cohort_member.html +7 -0
  172. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/rate_adjustment.html +7 -0
  173. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/record_consent.html +7 -0
  174. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/whatsapp.html +7 -0
  175. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +40 -1
  176. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/aggregate.html +8 -0
  177. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/array.html +7 -0
  178. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/bottom_group_alignment.html +7 -0
  179. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/cant_sync.html +7 -0
  180. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/center_group_alignment.html +8 -0
  181. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/columns.html +7 -0
  182. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/fully_synced.html +8 -0
  183. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/inner_join.html +7 -0
  184. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/join.html +8 -0
  185. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/left_join.html +14 -0
  186. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/macros.html +2 -2
  187. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/not_in_sync.html +7 -0
  188. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/not_saved.html +9 -0
  189. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/outer_join.html +7 -0
  190. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/path_experiment.html +7 -0
  191. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/program_cohort.html +7 -0
  192. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/program_cohort_member.html +7 -0
  193. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/record_consent.html +7 -0
  194. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/right_join.html +7 -0
  195. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/skill.html +8 -0
  196. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/sync_in_progress.html +7 -0
  197. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/top_group_alignment.html +7 -0
  198. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/account_score.html +8 -0
  199. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/aggregate.html +8 -0
  200. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/app_form_participant.html +11 -0
  201. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/app_form_product_participant.html +12 -0
  202. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/cost_model.html +7 -0
  203. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/labels.html +8 -0
  204. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/list_fee.html +7 -0
  205. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/list_rate.html +7 -0
  206. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/party_profile.html +8 -0
  207. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/path_experiment.html +7 -0
  208. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/people_score.html +8 -0
  209. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/price_adjustment_schedule.html +8 -0
  210. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/price_adjustment_tier.html +7 -0
  211. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/program_cohort.html +7 -0
  212. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/program_cohort_member.html +7 -0
  213. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/rate_adjustment.html +7 -0
  214. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/record_consent.html +7 -0
  215. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/whatsapp.html +7 -0
  216. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +19 -1
  217. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/account_score.html +8 -0
  218. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/aggregate.html +8 -0
  219. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/app_form_participant.html +11 -0
  220. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/app_form_product_participant.html +12 -0
  221. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/cost_model.html +7 -0
  222. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/labels.html +8 -0
  223. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/list_fee.html +7 -0
  224. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/list_rate.html +7 -0
  225. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/party_profile.html +8 -0
  226. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/path_experiment.html +7 -0
  227. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/people_score.html +8 -0
  228. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/price_adjustment_schedule.html +8 -0
  229. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/price_adjustment_tier.html +7 -0
  230. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/program_cohort.html +7 -0
  231. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/program_cohort_member.html +7 -0
  232. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/rate_adjustment.html +7 -0
  233. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/record_consent.html +7 -0
  234. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/whatsapp.html +7 -0
  235. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +19 -1
  236. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +22 -1
  237. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/aggregate.html +8 -0
  238. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/array.html +7 -0
  239. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/bottom_group_alignment.html +7 -0
  240. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/cant_sync.html +7 -0
  241. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/center_group_alignment.html +8 -0
  242. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/columns.html +7 -0
  243. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/fully_synced.html +8 -0
  244. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/inner_join.html +7 -0
  245. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/join.html +8 -0
  246. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/left_join.html +14 -0
  247. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/macros.html +2 -2
  248. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/not_in_sync.html +7 -0
  249. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/not_saved.html +9 -0
  250. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/outer_join.html +7 -0
  251. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/path_experiment.html +7 -0
  252. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/program_cohort.html +7 -0
  253. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/program_cohort_member.html +7 -0
  254. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/record_consent.html +7 -0
  255. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/right_join.html +7 -0
  256. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/skill.html +8 -0
  257. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/sync_in_progress.html +7 -0
  258. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/top_group_alignment.html +7 -0
  259. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +22 -1
  260. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/aggregate.html +8 -0
  261. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/array.html +7 -0
  262. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/bottom_group_alignment.html +7 -0
  263. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/cant_sync.html +7 -0
  264. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/center_group_alignment.html +8 -0
  265. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/columns.html +7 -0
  266. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/fully_synced.html +8 -0
  267. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/inner_join.html +7 -0
  268. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/join.html +8 -0
  269. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/left_join.html +14 -0
  270. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/macros.html +2 -2
  271. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/not_in_sync.html +7 -0
  272. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/not_saved.html +9 -0
  273. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/outer_join.html +7 -0
  274. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/path_experiment.html +7 -0
  275. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/program_cohort.html +7 -0
  276. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/program_cohort_member.html +7 -0
  277. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/record_consent.html +7 -0
  278. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/right_join.html +7 -0
  279. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/skill.html +8 -0
  280. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/sync_in_progress.html +7 -0
  281. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/top_group_alignment.html +7 -0
  282. package/src/lightning/iconUtils/iconColors.js +1 -1
  283. package/src/lightning/input/form-element.slds.css +1 -0
  284. package/src/lightning/input/input.html +16 -2
  285. package/src/lightning/input/input.js +91 -3
  286. package/src/lightning/input/input.js-meta.xml +3 -0
  287. package/src/lightning/inputAddress/addressFormat.js +25 -11
  288. package/src/lightning/inputAddress/fieldsLayout.js +3 -0
  289. package/src/lightning/inputAddress/form-element.slds.css +1 -0
  290. package/src/lightning/inputAddress/input-text.slds.css +5 -5
  291. package/src/lightning/inputAddress/inputAddress.html +1 -1
  292. package/src/lightning/inputAddress/inputAddress.js +27 -11
  293. package/src/lightning/inputLocation/form-element.slds.css +1 -0
  294. package/src/lightning/inputLocation/input-text.slds.css +5 -5
  295. package/src/lightning/inputName/form-element.slds.css +1 -0
  296. package/src/lightning/inputName/input-text.slds.css +5 -5
  297. package/src/lightning/internationalizationLibrary/address/AddressFormat.js +2 -0
  298. package/src/lightning/layout/__docs__/layout.md +0 -2
  299. package/src/lightning/lookupAddress/form-element.slds.css +1 -0
  300. package/src/lightning/menuItem/menu-item.slds.css +3 -1
  301. package/src/lightning/modal/__modalUtils__/modalContainerTestConstants.js +7 -3
  302. package/src/lightning/modal/__modalUtils__/modalContainerTestMethods.js +18 -11
  303. package/src/lightning/modal/__modalUtils__/modalContainerTestMockData.js +1 -1
  304. package/src/lightning/modalBase/modalBase.css +4 -0
  305. package/src/lightning/modalBase/modalBase.html +16 -21
  306. package/src/lightning/modalBase/modalBase.js +46 -65
  307. package/src/lightning/modalHeader/modalHeader.html +3 -15
  308. package/src/lightning/modalHeader/modalHeader.js +14 -61
  309. package/src/lightning/multiColumnSortingModal/multiColumnSortingModal.css +14 -0
  310. package/src/lightning/multiColumnSortingModal/multiColumnSortingModal.html +55 -0
  311. package/src/lightning/multiColumnSortingModal/multiColumnSortingModal.js +430 -0
  312. package/src/lightning/multiColumnSortingModal/multiColumnSortingModal.js-meta.xml +4 -0
  313. package/src/lightning/overlayManager/overlayManager.js +16 -0
  314. package/src/lightning/pill/pill.js +19 -13
  315. package/src/lightning/pillContainer/button.slds.css +16 -15
  316. package/src/lightning/pillContainer/pillContainer.js +2 -1
  317. package/src/lightning/pillContainer/standardPillContainer.html +6 -2
  318. package/src/lightning/positionLibrary/direction.js +19 -0
  319. package/src/lightning/primitiveBubble/primitiveBubble.js +7 -0
  320. package/src/lightning/primitiveColorpickerButton/primitiveColorpickerButton.html +2 -2
  321. package/src/lightning/primitiveColorpickerButton/primitiveColorpickerButton.js +8 -0
  322. package/src/lightning/primitiveColumnSorter/primitiveColumnSorter.css +34 -0
  323. package/src/lightning/primitiveColumnSorter/primitiveColumnSorter.html +60 -0
  324. package/src/lightning/primitiveColumnSorter/primitiveColumnSorter.js +107 -0
  325. package/src/lightning/primitiveHeaderFactory/primitiveHeaderFactory.js +36 -3
  326. package/src/lightning/primitiveHeaderFactory/sortingMenuHeader.css +5 -0
  327. package/src/lightning/primitiveHeaderFactory/sortingMenuHeader.html +9 -0
  328. package/src/lightning/primitiveInputCheckbox/form-element.slds.css +1 -0
  329. package/src/lightning/primitiveInputCheckbox/input-checkbox.slds.css +3 -3
  330. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.html +1 -1
  331. package/src/lightning/primitiveInputCheckboxButton/form-element.slds.css +1 -0
  332. package/src/lightning/primitiveInputCheckboxButton/input-checkbox-button.slds.css +6 -5
  333. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.html +1 -1
  334. package/src/lightning/primitiveInputColor/form-element.slds.css +1 -0
  335. package/src/lightning/primitiveInputColor/input-text.slds.css +5 -5
  336. package/src/lightning/primitiveInputColor/primitiveInputColor.html +5 -2
  337. package/src/lightning/primitiveInputColor/primitiveInputColor.js +2 -0
  338. package/src/lightning/primitiveInputFile/button.slds.css +16 -15
  339. package/src/lightning/primitiveInputFile/form-element.slds.css +1 -0
  340. package/src/lightning/primitiveInputFile/primitiveInputFile.html +1 -1
  341. package/src/lightning/primitiveInputRadio/primitiveInputRadio.html +1 -1
  342. package/src/lightning/primitiveInputSimple/form-element.slds.css +1 -0
  343. package/src/lightning/primitiveInputSimple/input-text.slds.css +5 -5
  344. package/src/lightning/primitiveInputSimple/primitiveInputSimple.html +3 -2
  345. package/src/lightning/primitiveInputSimple/primitiveInputSimple.js +15 -0
  346. package/src/lightning/primitiveInputToggle/form-element.slds.css +1 -0
  347. package/src/lightning/primitiveInputToggle/input-toggle.slds.css +16 -14
  348. package/src/lightning/primitiveInputToggle/primitiveInputToggle.html +1 -1
  349. package/src/lightning/progressIndicator/path.html +8 -2
  350. package/src/lightning/progressIndicator/progressIndicator.js +26 -2
  351. package/src/lightning/progressRing/progress-ring.slds.css +1 -1
  352. package/src/lightning/progressStep/progressStep.js +2 -1
  353. package/src/lightning/prompt/prompt.js +11 -9
  354. package/src/lightning/radioGroup/form-element.slds.css +1 -0
  355. package/src/lightning/radioGroup/input-radio-group.slds.css +4 -10
  356. package/src/lightning/select/form-element.slds.css +1 -0
  357. package/src/lightning/select/select.js +89 -7
  358. package/src/lightning/tabBar/tab-bar.slds.css +11 -0
  359. package/src/lightning/tabset/tabset.slds.css +1 -1
  360. package/src/lightning/textarea/form-element.slds.css +1 -0
  361. package/src/lightning/textarea/textarea.html +1 -0
  362. package/src/lightning/textarea/textarea.slds.css +2 -2
  363. package/src/lightning/timepicker/form-element.slds.css +1 -0
  364. package/src/lightning/timepicker/timepicker.html +4 -1
  365. package/src/lightning/timepicker/timepicker.js +3 -0
  366. package/src/lightning/toast/button-icon.slds.css +41 -25
  367. package/src/lightning/tooltipLibrary/tooltipLibrary.js +4 -15
  368. package/src/lightning/verticalNavigationOverflow/button.slds.css +16 -15
  369. package/scopedImports/@salesforce-label-LightningLookup.messageWhenSearchTermTooShort.js +0 -1
@@ -1,7 +1,15 @@
1
- import { getShadowActiveElements, isRTL } from 'lightning/utilsPrivate';
2
- import { getCellFromIndexes, HEADER_ROW_KEY, getRowByKey } from './indexes';
1
+ import {
2
+ getShadowActiveElements,
3
+ isRTL,
4
+ keyCodes,
5
+ } from 'lightning/utilsPrivate';
6
+ import {
7
+ getCellByKeys,
8
+ getCellFromIndexes,
9
+ HEADER_ROW_KEY,
10
+ isValidCell,
11
+ } from './indexes';
3
12
  import { fireRowToggleEvent } from './tree';
4
- import { getStateColumnIndex } from './columns';
5
13
  import { findFirstVisibleIndex } from './virtualization';
6
14
  import { getColDataSelector, getRowDataSelector, getScrollerY } from './utils';
7
15
 
@@ -185,7 +193,7 @@ function reactToKeyboardInNavMode(dt, event) {
185
193
 
186
194
  function reactToArrowLeft(state, template, event) {
187
195
  const { rowKeyValue, colKeyValue } = event.detail;
188
- const { colIndex } = getIndexesByKeys(state, rowKeyValue, colKeyValue);
196
+ const { colIndex } = getCellByKeys(state, rowKeyValue, colKeyValue);
189
197
  // Move from navigation mode to row mode when user
190
198
  // arrows left when in nav mode and on the first column
191
199
  if (colIndex === 0 && canBeRowNavigationMode(state)) {
@@ -204,10 +212,11 @@ function reactToArrowLeft(state, template, event) {
204
212
  setBlurActiveCell(state, template);
205
213
  // Untracked state change.
206
214
  // Update activeCell.
207
- state.activeCell = {
215
+ state.activeCell = getCellByKeys(
216
+ state,
208
217
  rowKeyValue,
209
- colKeyValue: state.columns[nextColIndex].colKeyValue,
210
- };
218
+ state.columns[nextColIndex].colKeyValue
219
+ );
211
220
  // Tracked state change.
212
221
  setFocusActiveCell(state, template, NAVIGATION_DIR.LEFT);
213
222
  }
@@ -215,7 +224,7 @@ function reactToArrowLeft(state, template, event) {
215
224
 
216
225
  function reactToArrowRight(state, template, event) {
217
226
  const { rowKeyValue, colKeyValue } = event.detail;
218
- const { colIndex } = getIndexesByKeys(state, rowKeyValue, colKeyValue);
227
+ const { colIndex } = getCellByKeys(state, rowKeyValue, colKeyValue);
219
228
  const nextColIndex = getNextIndexRight(state, colIndex);
220
229
  if (nextColIndex === undefined) {
221
230
  return;
@@ -223,16 +232,17 @@ function reactToArrowRight(state, template, event) {
223
232
  setBlurActiveCell(state, template);
224
233
  // Untracked state change.
225
234
  // Update activeCell.
226
- state.activeCell = {
235
+ state.activeCell = getCellByKeys(
236
+ state,
227
237
  rowKeyValue,
228
- colKeyValue: state.columns[nextColIndex].colKeyValue,
229
- };
238
+ state.columns[nextColIndex].colKeyValue
239
+ );
230
240
  setFocusActiveCell(state, template, NAVIGATION_DIR.RIGHT);
231
241
  }
232
242
 
233
243
  function reactToArrowUp(state, template, event) {
234
244
  const { rowKeyValue, colKeyValue, keyEvent } = event.detail;
235
- const { rowIndex } = getIndexesByKeys(state, rowKeyValue, colKeyValue);
245
+ const { rowIndex } = getCellByKeys(state, rowKeyValue, colKeyValue);
236
246
  const nextRowIndex = getNextIndexUp(state, rowIndex);
237
247
  if (
238
248
  nextRowIndex === undefined ||
@@ -248,18 +258,18 @@ function reactToArrowUp(state, template, event) {
248
258
  setBlurActiveCell(state, template);
249
259
  // Untracked state change.
250
260
  // Update activeCell.
251
- state.activeCell = {
252
- rowKeyValue:
253
- nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
254
- colKeyValue,
255
- };
261
+ state.activeCell = getCellByKeys(
262
+ state,
263
+ nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
264
+ colKeyValue
265
+ );
256
266
  // Tracked state change.
257
267
  setFocusActiveCell(state, template, NAVIGATION_DIR.USE_CURRENT);
258
268
  }
259
269
 
260
270
  function reactToArrowDown(state, template, event) {
261
271
  const { rowKeyValue, colKeyValue, keyEvent } = event.detail;
262
- const { rowIndex } = getIndexesByKeys(state, rowKeyValue, colKeyValue);
272
+ const { rowIndex } = getCellByKeys(state, rowKeyValue, colKeyValue);
263
273
  const nextRowIndex = getNextIndexDown(state, rowIndex);
264
274
  if (
265
275
  nextRowIndex === undefined ||
@@ -275,11 +285,12 @@ function reactToArrowDown(state, template, event) {
275
285
  setBlurActiveCell(state, template);
276
286
  // Untracked state change.
277
287
  // Update activeCell.
278
- state.activeCell = {
279
- rowKeyValue:
280
- nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
281
- colKeyValue,
282
- };
288
+ state.activeCell = getCellByKeys(
289
+ state,
290
+ nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
291
+ colKeyValue
292
+ );
293
+ // Tracked state change.
283
294
  setFocusActiveCell(state, template, NAVIGATION_DIR.USE_CURRENT);
284
295
  }
285
296
 
@@ -288,7 +299,7 @@ function reactToEnter(state, template, event) {
288
299
  // Untracked state change.
289
300
  state.keyboardMode = KEYBOARD_ACTION_MODE;
290
301
  const { keyCode, keyEvent } = event.detail;
291
- const { rowIndex, colIndex } = getIndexesActiveCell(state);
302
+ const { rowIndex, colIndex } = state.activeCell;
292
303
  if (keyEvent) {
293
304
  keyEvent.preventDefault();
294
305
  }
@@ -361,11 +372,11 @@ export function reactToTabForward(state, template) {
361
372
  setBlurActiveCell(state, template);
362
373
  // Untracked state change.
363
374
  // Update activeCell.
364
- state.activeCell = {
365
- rowKeyValue:
366
- nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
367
- colKeyValue: state.columns[nextColIndex].colKeyValue,
368
- };
375
+ state.activeCell = getCellByKeys(
376
+ state,
377
+ nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
378
+ state.columns[nextColIndex].colKeyValue
379
+ );
369
380
  // Tracked state change.
370
381
  setFocusActiveCell(state, template, NAVIGATION_DIR.TAB_FORWARD, {
371
382
  action: 'tab',
@@ -378,11 +389,11 @@ export function reactToTabBackward(state, template) {
378
389
  setBlurActiveCell(state, template);
379
390
  // Untracked state change.
380
391
  // Update activeCell.
381
- state.activeCell = {
382
- rowKeyValue:
383
- nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
384
- colKeyValue: state.columns[nextColIndex].colKeyValue,
385
- };
392
+ state.activeCell = getCellByKeys(
393
+ state,
394
+ nextRowIndex === -1 ? HEADER_ROW_KEY : state.rows[nextRowIndex].key,
395
+ state.columns[nextColIndex].colKeyValue
396
+ );
386
397
  // Tracked state change.
387
398
  setFocusActiveCell(state, template, NAVIGATION_DIR.TAB_BACKWARD, {
388
399
  action: 'tab',
@@ -400,7 +411,7 @@ function getTabDirection(shiftKey) {
400
411
  * @returns {Object} - nextRowIndex, nextColIndex values, isExitCell boolean
401
412
  */
402
413
  function getNextIndexOnTab(state, direction = 'FORWARD') {
403
- const { rowIndex, colIndex } = getIndexesActiveCell(state);
414
+ const { rowIndex, colIndex } = state.activeCell;
404
415
  // decide which function to use based on the value of direction
405
416
  return direction === 'BACKWARD'
406
417
  ? getNextIndexOnTabBackward(state, rowIndex, colIndex)
@@ -491,21 +502,18 @@ function reactToArrowLeftOnRow(dt, state, template, event) {
491
502
  const { treeColumn } = state;
492
503
  if (treeColumn) {
493
504
  const { colKeyValue } = treeColumn;
494
- const { rowIndex } = getIndexesByKeys(
495
- state,
496
- rowKeyValue,
497
- colKeyValue
498
- );
505
+ const { rowIndex } = getCellByKeys(state, rowKeyValue, colKeyValue);
499
506
  const parentIndex = getRowParentIndex(state, rowLevel, rowIndex);
500
507
  if (parentIndex !== -1) {
501
508
  // Tracked state change.
502
509
  setBlurActiveRow(state, template);
503
510
  // Untracked state change.
504
511
  // Update activeCell for the row.
505
- state.activeCell = {
506
- rowKeyValue: state.rows[parentIndex].key,
507
- colKeyValue,
508
- };
512
+ state.activeCell = getCellByKeys(
513
+ state,
514
+ state.rows[parentIndex].key,
515
+ colKeyValue
516
+ );
509
517
  // Tracked state change.
510
518
  setFocusActiveRow(state, template);
511
519
  }
@@ -542,17 +550,18 @@ function reactToArrowUpOnRow(state, template, event) {
542
550
 
543
551
  if (treeColumn) {
544
552
  const { colKeyValue } = treeColumn;
545
- const { rowIndex } = getIndexesByKeys(state, rowKeyValue, colKeyValue);
553
+ const { rowIndex } = getCellByKeys(state, rowKeyValue, colKeyValue);
546
554
  const prevRowIndex = getNextIndexUpWrapped(state, rowIndex);
547
555
  if (prevRowIndex !== -1) {
548
556
  // Tracked state change.
549
557
  setBlurActiveRow(state, template);
550
558
  // Untracked state change.
551
559
  // Update activeCell for the row.
552
- state.activeCell = {
553
- rowKeyValue: state.rows[prevRowIndex].key,
554
- colKeyValue,
555
- };
560
+ state.activeCell = getCellByKeys(
561
+ state,
562
+ state.rows[prevRowIndex].key,
563
+ colKeyValue
564
+ );
556
565
  // Tracked state change.
557
566
  setFocusActiveRow(state, template);
558
567
  }
@@ -569,17 +578,18 @@ function reactToArrowDownOnRow(state, template, event) {
569
578
 
570
579
  if (treeColumn) {
571
580
  const { colKeyValue } = treeColumn;
572
- const { rowIndex } = getIndexesByKeys(state, rowKeyValue, colKeyValue);
581
+ const { rowIndex } = getCellByKeys(state, rowKeyValue, colKeyValue);
573
582
  const nextRowIndex = getNextIndexDownWrapped(state, rowIndex);
574
583
  if (nextRowIndex !== -1) {
575
584
  // Tracked state change.
576
585
  setBlurActiveRow(state, template);
577
586
  // Untracked state change.
578
587
  // Update activeCell for the row.
579
- state.activeCell = {
580
- rowKeyValue: state.rows[nextRowIndex].key,
581
- colKeyValue,
582
- };
588
+ state.activeCell = getCellByKeys(
589
+ state,
590
+ state.rows[nextRowIndex].key,
591
+ colKeyValue
592
+ );
583
593
  // Tracked state change.
584
594
  setFocusActiveRow(state, template);
585
595
  }
@@ -605,10 +615,11 @@ function getDefaultActiveCell(state) {
605
615
  colIndex = 0;
606
616
  }
607
617
  const { rows } = state;
608
- return {
609
- rowKeyValue: rows.length > 0 ? rows[0].key : HEADER_ROW_KEY,
610
- colKeyValue: columns[colIndex].colKeyValue,
611
- };
618
+ return getCellByKeys(
619
+ state,
620
+ rows.length > 0 ? rows[0].key : HEADER_ROW_KEY,
621
+ columns[colIndex].colKeyValue
622
+ );
612
623
  }
613
624
 
614
625
  return undefined;
@@ -628,12 +639,12 @@ function setDefaultActiveCell(state) {
628
639
  export function getActiveCellElement(template, state) {
629
640
  const { activeCell } = state;
630
641
  return activeCell
631
- ? getCellElementByKeys(
642
+ ? getCellElement(
632
643
  template,
633
644
  activeCell.rowKeyValue,
634
645
  activeCell.colKeyValue
635
646
  )
636
- : null;
647
+ : undefined;
637
648
  }
638
649
 
639
650
  /**
@@ -727,7 +738,7 @@ function setNextActiveCellFromPrev(state) {
727
738
  */
728
739
  export function isActiveCellAnExitCell(state, direction) {
729
740
  // get next tab index values
730
- const { rowIndex, colIndex } = getIndexesActiveCell(state);
741
+ const { rowIndex, colIndex } = state.activeCell;
731
742
  const { nextRowIndex, nextColIndex } = getNextIndexOnTab(state, direction);
732
743
  // is it an exit cell?
733
744
  if (
@@ -745,25 +756,24 @@ export function isActiveCellAnExitCell(state, direction) {
745
756
  return false;
746
757
  }
747
758
 
748
- export function getIndexesActiveCell(state) {
749
- const {
750
- activeCell: { rowKeyValue, colKeyValue },
751
- } = state;
752
- return getIndexesByKeys(state, rowKeyValue, colKeyValue);
753
- }
754
-
755
759
  function setModeActiveCell(state, template, info) {
756
760
  const cellElement = getActiveCellElement(template, state);
757
- if (cellElement) {
758
- cellElement.setMode(state.keyboardMode, info);
761
+ const cellElementChild = getCellElementChild(cellElement);
762
+ if (cellElementChild) {
763
+ const { keyboardMode } = state;
764
+ if (typeof cellElementChild.setMode === 'function') {
765
+ cellElementChild.setMode(keyboardMode, info);
766
+ } else {
767
+ // Tracked state change.
768
+ setMode(state.activeCell, cellElementChild, keyboardMode, info);
769
+ }
759
770
  }
760
771
  }
761
772
 
762
773
  function stillValidActiveCell(state) {
763
774
  const { activeCell, indexes } = state;
764
- const { rowKeyValue, colKeyValue } = activeCell;
765
- if (rowKeyValue === HEADER_ROW_KEY) {
766
- if (state.rows.length) {
775
+ if (activeCell) {
776
+ if (activeCell.rowKeyValue === HEADER_ROW_KEY && state.rows.length) {
767
777
  const { columns } = state;
768
778
  let sortable = false;
769
779
  for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
@@ -776,9 +786,383 @@ function stillValidActiveCell(state) {
776
786
  return false;
777
787
  }
778
788
  }
779
- return state.headerIndexes[colKeyValue] !== undefined;
789
+ const indexedCell = indexes[activeCell.cellKeyValue];
790
+ // reset activeCell in case the rowIndex changed
791
+ // changed but not the cellKeyValue
792
+ if (indexedCell) {
793
+ state.activeCell = indexedCell;
794
+ }
795
+ return indexedCell !== undefined;
796
+ }
797
+ return false;
798
+ }
799
+
800
+ /***************************** CELL ELEMENT *****************************/
801
+
802
+ export function getCellElement(template, rowKeyValue, colKeyValue) {
803
+ const cellElement = template.querySelector(
804
+ `${getRowDataSelector(rowKeyValue)} ${getColDataSelector(colKeyValue)}`
805
+ );
806
+ return cellElement || undefined;
807
+ }
808
+
809
+ export function getCellElementChild(cellElement) {
810
+ const firstElementChild = cellElement
811
+ ? cellElement.firstElementChild
812
+ : undefined;
813
+ /*const localName = firstElementChild ? firstElementChild.localName : '';
814
+ if (localName === 'span') {
815
+ // span wrapper
816
+ const cellDiv = firstElementChild.firstElementChild;
817
+ if (cellDiv && cellDiv.localName === 'div') {
818
+ // cell div
819
+ return cellDiv;
820
+ }
821
+ } else if (localName === 'div') {
822
+ // lightning-primitive-custom-cell
823
+ return firstElementChild.firstElementChild;
824
+ }*/
825
+ // lightning-primitive-cell-factory or checkbox cell span
826
+ return firstElementChild;
827
+ }
828
+
829
+ export function getCellElementFromEventTarget(target) {
830
+ const cellElement = target.closest(
831
+ '[role="gridcell"],[role="columnheader"],[role="rowheader"]'
832
+ );
833
+ return cellElement || undefined;
834
+ }
835
+
836
+ /***************************** PRIMITIVE CELL METHODS *****************************/
837
+
838
+ function canMoveBackward(cell) {
839
+ return cell.currentInputIndex > 0;
840
+ }
841
+
842
+ function canMoveForward(cell) {
843
+ const { actionableElementsCount } = cell;
844
+ return (
845
+ actionableElementsCount > 1 &&
846
+ cell.currentInputIndex < actionableElementsCount - 1
847
+ );
848
+ }
849
+
850
+ function canMoveLeft(cell) {
851
+ return isRTL() ? canMoveForward(cell) : canMoveBackward(cell);
852
+ }
853
+
854
+ function canMoveRight(cell) {
855
+ return isRTL() ? canMoveBackward(cell) : canMoveForward(cell);
856
+ }
857
+
858
+ function fireCellKeydown(cell, cellElementChild, keyEvent) {
859
+ const { rowKeyValue, colKeyValue } = cell;
860
+ const { keyCode, shiftKey } = keyEvent;
861
+
862
+ cellElementChild.dispatchEvent(
863
+ new CustomEvent('privatecellkeydown', {
864
+ bubbles: true,
865
+ composed: true,
866
+ cancelable: true,
867
+ detail: {
868
+ rowKeyValue,
869
+ colKeyValue,
870
+ keyCode,
871
+ shiftKey,
872
+ keyEvent,
873
+ },
874
+ })
875
+ );
876
+ }
877
+
878
+ function fireCellFocusByClickEvent(cell, cellElementChild) {
879
+ const { rowKeyValue, colKeyValue } = cell;
880
+
881
+ cellElementChild.dispatchEvent(
882
+ new CustomEvent('privatecellfocusedbyclick', {
883
+ bubbles: true,
884
+ composed: true,
885
+ detail: {
886
+ rowKeyValue,
887
+ colKeyValue,
888
+ },
889
+ })
890
+ );
891
+ }
892
+
893
+ export function handlePrimitiveDatatableCellClick(event) {
894
+ const { state } = this;
895
+ const cellElement = state.renderModeInline
896
+ ? getCellElementFromEventTarget(event.target)
897
+ : undefined;
898
+
899
+ if (cellElement) {
900
+ const cellElementChild = getCellElementChild(cellElement);
901
+ const cell = getCellByKeys(
902
+ state,
903
+ cellElement.parentElement.dataset.rowKeyValue,
904
+ cellElement.dataset.colKeyValue
905
+ );
906
+ fireCellFocusByClickEvent(cell, cellElementChild);
907
+ }
908
+ }
909
+
910
+ export function handlePrimitiveDatatableCellFocus(event) {
911
+ const { state } = this;
912
+ const cellElement = state.renderModeInline
913
+ ? getCellElementFromEventTarget(event.target)
914
+ : undefined;
915
+
916
+ if (cellElement) {
917
+ const cellElementChild = getCellElementChild(cellElement);
918
+ const cell = getCellByKeys(
919
+ this.state,
920
+ cellElement.parentElement.dataset.rowKeyValue,
921
+ cellElement.dataset.colKeyValue
922
+ );
923
+ if (cell.mode === KEYBOARD_ACTION_MODE) {
924
+ // Tracked state change.
925
+ setFocusToActionableElement(
926
+ cell,
927
+ cellElementChild,
928
+ cell.currentInputIndex
929
+ );
930
+ }
931
+ }
932
+ }
933
+
934
+ export function handlePrimitiveDatatableCellKeydown(event) {
935
+ const { state } = this;
936
+ // Don't continue if clicking on a "lightning" element
937
+ // Or the outer td/th element and div equivalent
938
+ const cellElement =
939
+ state.renderModeInline &&
940
+ !event.target.shadowRoot &&
941
+ !event.target.getAttribute('role')
942
+ ? getCellElementFromEventTarget(event.target)
943
+ : undefined;
944
+
945
+ if (cellElement === undefined) {
946
+ return;
947
+ }
948
+
949
+ const cellElementChild = getCellElementChild(cellElement);
950
+ const cell = getCellByKeys(
951
+ this.state,
952
+ cellElement.parentElement.dataset.rowKeyValue,
953
+ cellElement.dataset.colKeyValue
954
+ );
955
+ const { mode } = cell;
956
+ const { keyCode, shiftKey } = event;
957
+
958
+ // if it is in Action mode, then traverse to the next or previous
959
+ // focusable element.
960
+ // if there is no focusable element, or reach outside of the range, then move to
961
+ // previous or next cell.
962
+ if (mode === KEYBOARD_ACTION_MODE) {
963
+ let passThroughEvent = keyCode !== keyCodes.shift;
964
+ if (keyCode === keyCodes.left) {
965
+ if (canMoveLeft(cell)) {
966
+ // There are still actionable element before the current one
967
+ // move to the previous actionable element.
968
+ event.preventDefault();
969
+ // Tracked state changes.
970
+ if (isRTL()) {
971
+ moveToNextActionableElement(cell, cellElementChild);
972
+ } else {
973
+ moveToPrevActionableElement(cell, cellElementChild);
974
+ }
975
+ passThroughEvent = false;
976
+ }
977
+ } else if (keyCode === keyCodes.right) {
978
+ if (canMoveRight(cell)) {
979
+ // There are still actionable element before the current one
980
+ // move to the previous actionable element.
981
+ event.preventDefault();
982
+ // Tracked state changes.
983
+ if (isRTL()) {
984
+ moveToPrevActionableElement(cell, cellElementChild);
985
+ } else {
986
+ moveToNextActionableElement(cell, cellElementChild);
987
+ }
988
+ passThroughEvent = false;
989
+ }
990
+ } else if (keyCode === keyCodes.tab) {
991
+ // If in action mode, try to navigate through the element inside.
992
+ // Always prevent the default tab behavior so that the tab will
993
+ // not focus outside of the table.
994
+ if (shiftKey) {
995
+ // Moving backward.
996
+ if (canMoveBackward(cell)) {
997
+ event.preventDefault();
998
+ // Tracked state change.
999
+ moveToPrevActionableElement(cell, cellElementChild);
1000
+ passThroughEvent = false;
1001
+ }
1002
+ } else {
1003
+ // Moving forward.
1004
+ // eslint-disable-next-line no-lonely-if
1005
+ if (canMoveForward(cell)) {
1006
+ event.preventDefault();
1007
+ // Tracked state change.
1008
+ moveToNextActionableElement(cell, cellElementChild);
1009
+ passThroughEvent = false;
1010
+ }
1011
+ }
1012
+ }
1013
+ if (passThroughEvent) {
1014
+ fireCellKeydown(cell, cellElementChild, event);
1015
+ }
1016
+ } else if (mode === KEYBOARD_NAVIGATION_MODE) {
1017
+ // click the header, press enter, it does not go to action mode without this code.
1018
+ if (
1019
+ keyCode === keyCodes.left ||
1020
+ keyCode === keyCodes.right ||
1021
+ keyCode === keyCodes.up ||
1022
+ keyCode === keyCodes.down ||
1023
+ keyCode === keyCodes.enter
1024
+ ) {
1025
+ fireCellKeydown(cell, cellElementChild, event);
1026
+ }
1027
+ }
1028
+ }
1029
+
1030
+ function getActionableElements(cellElementChild) {
1031
+ const result = Array.from(
1032
+ cellElementChild.querySelectorAll('[data-navigation="enable"]')
1033
+ );
1034
+
1035
+ const customType = cellElementChild.querySelector(
1036
+ 'lightning-primitive-custom-cell'
1037
+ );
1038
+
1039
+ if (customType) {
1040
+ const wrapperActionableElements = customType.getActionableElements();
1041
+ wrapperActionableElements.forEach((elem) => result.push(elem));
1042
+ }
1043
+ return result;
1044
+ }
1045
+
1046
+ function moveToNextActionableElement(cell, cellElementChild) {
1047
+ // Tracked state change.
1048
+ setFocusToActionableElement(
1049
+ cell,
1050
+ cellElementChild,
1051
+ cell.currentInputIndex + 1
1052
+ );
1053
+ }
1054
+
1055
+ function moveToPrevActionableElement(cell, cellElementChild) {
1056
+ // Tracked state change.
1057
+ setFocusToActionableElement(
1058
+ cell,
1059
+ cellElementChild,
1060
+ cell.currentInputIndex - 1
1061
+ );
1062
+ }
1063
+
1064
+ /**
1065
+ * method to resetCurrentInputIndex when navigating from cell-to-cell
1066
+ * called in navigation or action mode
1067
+ *
1068
+ * @param {Object} cell - The tracked datatable cell
1069
+ * @param {Object} cellElementChild - The cell element child
1070
+ * @param {number} direction -1, 1, 2
1071
+ * @param {string} incomingMode is the new mode, needed because a cell can be in action mode but new mode being
1072
+ * set can be navigation mode
1073
+ */
1074
+ function resetCurrentInputIndex(
1075
+ cell,
1076
+ cellElementChild,
1077
+ direction,
1078
+ incomingMode
1079
+ ) {
1080
+ // Tracked state changes.
1081
+ if (direction === -1) {
1082
+ const { length } = getActionableElements(cellElementChild);
1083
+ cell.currentInputIndex = length ? length - 1 : 0;
1084
+ } else if (direction === 1 || direction === 2) {
1085
+ cell.currentInputIndex = 0;
1086
+ }
1087
+ // when esc is pressed on a cell to enter navigation mode, other cells are still
1088
+ // in action mode till we call setMode above. So need to check new incoming mode too if action mode
1089
+ // otherwise we try to focus on an inner element with delegatesFocus and tabIndex -1 and
1090
+ // it moves focus out of table
1091
+ if (
1092
+ incomingMode === KEYBOARD_ACTION_MODE &&
1093
+ cell.mode === KEYBOARD_ACTION_MODE
1094
+ ) {
1095
+ // Tracked state change.
1096
+ setFocusToActionableElement(
1097
+ cell,
1098
+ cellElementChild,
1099
+ cell.currentInputIndex
1100
+ );
1101
+ }
1102
+ }
1103
+
1104
+ function setFocusToActionableElement(cell, cellElementChild, activeInputIndex) {
1105
+ const actionableElements = getActionableElements(cellElementChild);
1106
+ const { length: actionableElementsLength } = actionableElements;
1107
+ // Tracked state changes.
1108
+ cell.actionableElementsCount = actionableElementsLength;
1109
+ if (actionableElementsLength) {
1110
+ if (
1111
+ activeInputIndex > 0 &&
1112
+ activeInputIndex < actionableElementsLength
1113
+ ) {
1114
+ // try to locate to the previous active index of previous row.
1115
+ actionableElements[activeInputIndex].focus();
1116
+ cell.currentInputIndex = activeInputIndex;
1117
+ } else {
1118
+ actionableElements[0].focus();
1119
+ cell.currentInputIndex = 0;
1120
+ }
1121
+ }
1122
+ // TODO: Fire event back to the datatable, so that the activeInputIndex can be
1123
+ // stored in the datatable level state. So that when user use up and down arrow to
1124
+ // navigate through the datatable in ACTION mode, we can remember the active input position
1125
+ }
1126
+
1127
+ function setMode(cell, cellElementChild, keyboardMode, info) {
1128
+ const normalizedInfo = info || { action: 'none' };
1129
+ // Tracked state changes.
1130
+ cell.mode = keyboardMode;
1131
+ if (keyboardMode === KEYBOARD_ACTION_MODE) {
1132
+ cell.internalTabIndex = 0;
1133
+ // focus without changing tabIndex doesn't work W-6185168
1134
+ // eslint-disable-next-line @lwc/lwc/no-async-operation
1135
+ setTimeout(() => {
1136
+ setFocusToActionableElement(
1137
+ cell,
1138
+ cellElementChild,
1139
+ cell.currentInputIndex
1140
+ );
1141
+ }, 0);
1142
+
1143
+ const actionableElements = getActionableElements(cellElementChild);
1144
+ const { length: actionableElementsLength } = actionableElements;
1145
+
1146
+ // check if we have an edit button first (tab should open the inline edit)
1147
+ if (normalizedInfo.action === 'tab') {
1148
+ for (let i = 0; i < actionableElementsLength; i += 1) {
1149
+ const elem = actionableElements[i];
1150
+ if (elem.getAttribute('data-action-edit')) {
1151
+ elem.click();
1152
+ break;
1153
+ }
1154
+ }
1155
+ } else if (actionableElementsLength === 1) {
1156
+ const elem = actionableElements[0];
1157
+ const defaultActions =
1158
+ elem.getAttribute('data-action-triggers') || '';
1159
+ if (defaultActions.indexOf(normalizedInfo.action) !== -1) {
1160
+ elem.click();
1161
+ }
1162
+ }
1163
+ } else {
1164
+ cell.internalTabIndex = -1;
780
1165
  }
781
- return !!(indexes[rowKeyValue] && indexes[rowKeyValue][colKeyValue]);
782
1166
  }
783
1167
 
784
1168
  /***************************** FOCUS MANAGEMENT *****************************/
@@ -802,7 +1186,7 @@ export function setFocusActiveCell(
802
1186
  shouldScroll = true
803
1187
  ) {
804
1188
  const { keyboardMode } = state;
805
- const { rowIndex, colIndex } = getIndexesActiveCell(state);
1189
+ const { rowIndex, colIndex } = state.activeCell;
806
1190
  let cellElement = getActiveCellElement(template, state);
807
1191
 
808
1192
  state.activeCell.hasFocus = !(info && isActiveCellValid(state));
@@ -814,6 +1198,9 @@ export function setFocusActiveCell(
814
1198
  scrollToCell(state, template, rowIndex);
815
1199
  }
816
1200
 
1201
+ const rowKeyValue =
1202
+ cellElement && cellElement.parentElement.dataset.rowKeyValue;
1203
+
817
1204
  return new Promise((resolve) => {
818
1205
  // eslint-disable-next-line @lwc/lwc/no-async-operation
819
1206
  setTimeout(() => {
@@ -822,24 +1209,59 @@ export function setFocusActiveCell(
822
1209
  !cellElement ||
823
1210
  !isValidCell(
824
1211
  state,
825
- cellElement.rowKeyValue,
826
- cellElement.colKeyValue
1212
+ rowKeyValue,
1213
+ cellElement.dataset.colKeyValue
827
1214
  )
828
1215
  ) {
829
1216
  cellElement = getActiveCellElement(template, state);
830
1217
  }
831
1218
  if (cellElement) {
832
- if (direction) {
833
- cellElement.resetCurrentInputIndex(direction, keyboardMode);
1219
+ const cellElementChild = getCellElementChild(cellElement);
1220
+ const { activeCell } = state;
1221
+ if (cellElementChild) {
1222
+ if (direction) {
1223
+ if (
1224
+ typeof cellElementChild.resetCurrentInputIndex ===
1225
+ 'function'
1226
+ ) {
1227
+ cellElementChild.resetCurrentInputIndex(
1228
+ direction,
1229
+ keyboardMode
1230
+ );
1231
+ } else {
1232
+ resetCurrentInputIndex(
1233
+ activeCell,
1234
+ cellElement,
1235
+ direction,
1236
+ keyboardMode
1237
+ );
1238
+ }
1239
+ }
1240
+ if (typeof cellElementChild.addFocusStyles === 'function') {
1241
+ cellElementChild.addFocusStyles();
1242
+ }
1243
+ }
1244
+ cellElement.classList.add(FOCUS_CLASS);
1245
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#parameters
1246
+ cellElement.focus({ preventScroll: !shouldScroll });
1247
+ if (cellElementChild) {
1248
+ if (typeof cellElementChild.setMode === 'function') {
1249
+ cellElementChild.setMode(keyboardMode, info);
1250
+ } else {
1251
+ setMode(
1252
+ activeCell,
1253
+ cellElementChild,
1254
+ keyboardMode,
1255
+ info
1256
+ );
1257
+ }
834
1258
  }
835
- cellElement.addFocusStyles();
836
- cellElement.parentElement.classList.add(FOCUS_CLASS);
837
- cellElement.parentElement.focus({
838
- preventScroll: !shouldScroll,
839
- });
840
- cellElement.setMode(keyboardMode, info);
841
1259
  if (shouldScroll) {
842
- updateScrollTop(state, template, cellElement);
1260
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView#parameters
1261
+ cellElement.scrollIntoView({
1262
+ block: 'nearest',
1263
+ inline: 'nearest',
1264
+ });
843
1265
  }
844
1266
  }
845
1267
  resolve();
@@ -855,10 +1277,13 @@ export function setFocusActiveCell(
855
1277
  * @param {Node} template - The custom element root `this.template`
856
1278
  */
857
1279
  export function setBlurActiveCell(state, template) {
858
- if (state.activeCell) {
859
- const { rowIndex, colIndex } = getIndexesActiveCell(state);
1280
+ const { activeCell } = state;
1281
+ if (activeCell) {
1282
+ const { rowIndex, colIndex } = activeCell;
860
1283
  state.activeCell.hasFocus = false;
861
1284
  let cellElement = getActiveCellElement(template, state);
1285
+ const rowKeyValue =
1286
+ cellElement && cellElement.parentElement.dataset.rowKeyValue;
862
1287
  // eslint-disable-next-line @lwc/lwc/no-async-operation
863
1288
  setTimeout(() => {
864
1289
  // check cellElement; value may have changed
@@ -866,18 +1291,31 @@ export function setBlurActiveCell(state, template) {
866
1291
  !cellElement ||
867
1292
  !isValidCell(
868
1293
  state,
869
- cellElement.rowKeyValue,
870
- cellElement.colKeyValue
1294
+ rowKeyValue,
1295
+ cellElement.dataset.colKeyValue
871
1296
  )
872
1297
  ) {
873
1298
  cellElement = getActiveCellElement(template, state);
874
1299
  }
875
1300
  if (cellElement) {
876
- if (document.activeElement === cellElement) {
877
- cellElement.blur();
1301
+ const { activeElement } = document;
1302
+ const cellElementChild = getCellElementChild(cellElement);
1303
+ if (cellElementChild) {
1304
+ if (
1305
+ typeof cellElementChild.removeFocusStyles === 'function'
1306
+ ) {
1307
+ if (activeElement === cellElementChild) {
1308
+ cellElementChild.blur();
1309
+ }
1310
+ cellElementChild.removeFocusStyles(true);
1311
+ } else {
1312
+ state.activeCell.internalTabIndex = -1;
1313
+ if (cellElement.contains(activeElement)) {
1314
+ cellElement.blur();
1315
+ }
1316
+ }
878
1317
  }
879
- cellElement.removeFocusStyles(true);
880
- cellElement.parentElement.classList.remove(FOCUS_CLASS);
1318
+ cellElement.classList.remove(FOCUS_CLASS);
881
1319
  }
882
1320
  }, 0);
883
1321
  updateCellTabIndex(state, rowIndex, colIndex, -1);
@@ -895,15 +1333,16 @@ export function setBlurActiveCell(state, template) {
895
1333
  * @param {Object} template - The datatable element
896
1334
  */
897
1335
  export function setCellToFocusFromPrev(state, template) {
1336
+ const { activeCell } = state;
898
1337
  if (
899
- state.activeCell &&
1338
+ activeCell &&
900
1339
  !state.cellToFocusNext &&
901
1340
  datatableHasFocus(state, template)
902
1341
  ) {
903
1342
  const { length: rowCount } = state.rows;
904
1343
  const lastIndex = rowCount - 1;
905
1344
  const { length: colCount } = state.columns;
906
- let { rowIndex, colIndex } = getIndexesActiveCell(state);
1345
+ let { rowIndex, colIndex } = activeCell;
907
1346
  colIndex = 0; // default point to the first column
908
1347
  if (rowIndex === lastIndex) {
909
1348
  // if it is last row, make it point to its previous row
@@ -943,7 +1382,7 @@ export function addFocusStylesToActiveCell(state, template) {
943
1382
  state.activeCell.hasFocus = true;
944
1383
  const cellElement = getActiveCellElement(template, state);
945
1384
  if (cellElement) {
946
- cellElement.parentElement.classList.add(FOCUS_CLASS);
1385
+ cellElement.classList.add(FOCUS_CLASS);
947
1386
  }
948
1387
  }
949
1388
 
@@ -957,7 +1396,7 @@ export function addFocusStylesToActiveCell(state, template) {
957
1396
  * @param {Node} template - the custom element root `this.template`
958
1397
  */
959
1398
  function setFocusActiveRow(state, template) {
960
- const { rowIndex } = getIndexesActiveCell(state);
1399
+ const { rowIndex } = state.activeCell;
961
1400
  const rowElement = getActiveCellRowElement(template, state);
962
1401
 
963
1402
  updateRowTabIndex(state, rowIndex);
@@ -976,8 +1415,8 @@ function setFocusActiveRow(state, template) {
976
1415
  * @param {Node} template - The custom element root `this.template`
977
1416
  */
978
1417
  function setBlurActiveRow(state, template) {
979
- if (state.activeCell) {
980
- const { rowIndex } = getIndexesActiveCell(state);
1418
+ const { activeCell } = state;
1419
+ if (activeCell) {
981
1420
  // eslint-disable-next-line @lwc/lwc/no-async-operation
982
1421
  setTimeout(() => {
983
1422
  const rowElement = getActiveCellRowElement(template, state);
@@ -985,7 +1424,7 @@ function setBlurActiveRow(state, template) {
985
1424
  rowElement.blur();
986
1425
  }
987
1426
  }, 0);
988
- updateRowTabIndex(state, rowIndex, -1);
1427
+ updateRowTabIndex(state, activeCell.rowIndex, -1);
989
1428
  }
990
1429
  }
991
1430
 
@@ -1000,7 +1439,7 @@ export function refocusCellElement(state, template, needsRefocusOnCellElement) {
1000
1439
  if (needsRefocusOnCellElement) {
1001
1440
  const cellElement = getActiveCellElement(template, state);
1002
1441
  if (cellElement) {
1003
- cellElement.parentElement.focus();
1442
+ cellElement.focus();
1004
1443
  }
1005
1444
 
1006
1445
  // setTimeout so that focusin happens and then we set state.cellClicked to true
@@ -1041,9 +1480,14 @@ export function handleDatatableFocusIn(event) {
1041
1480
  // we need to check because of the tree,
1042
1481
  // at this point it may remove/change the rows/keys because opening or closing a row.
1043
1482
  if (cellElement) {
1044
- cellElement.addFocusStyles();
1045
- cellElement.parentElement.classList.add(FOCUS_CLASS);
1046
- cellElement.tabindex = 0;
1483
+ const cellElementChild = getCellElementChild(cellElement);
1484
+ if (cellElementChild) {
1485
+ if (typeof cellElementChild.addFocusStyles === 'function') {
1486
+ cellElementChild.addFocusStyles();
1487
+ }
1488
+ cellElement.tabIndex = 0;
1489
+ }
1490
+ cellElement.classList.add(FOCUS_CLASS);
1047
1491
  }
1048
1492
  }
1049
1493
  resetCellClickedForFocus(state);
@@ -1069,8 +1513,14 @@ export function handleDatatableFocusOut(event) {
1069
1513
  // we need to check because of the tree,
1070
1514
  // at this point it may remove/change the rows/keys because opening or closing a row.
1071
1515
  if (cellElement) {
1072
- cellElement.removeFocusStyles();
1073
- cellElement.parentElement.classList.remove(FOCUS_CLASS);
1516
+ const cellElementChild = getCellElementChild(cellElement);
1517
+ if (
1518
+ cellElementChild &&
1519
+ typeof cellElementChild.removeFocusStyles === 'function'
1520
+ ) {
1521
+ cellElementChild.removeFocusStyles();
1522
+ }
1523
+ cellElement.classList.remove(FOCUS_CLASS);
1074
1524
  }
1075
1525
  }
1076
1526
  }
@@ -1119,7 +1569,7 @@ export function updateCellTabIndex(state, rowIndex, colIndex, tabIndex = 0) {
1119
1569
  *
1120
1570
  * @param {Object} state - The datatable state
1121
1571
  * @param {number} rowIndex - the row index
1122
- * @param {number} [index = 0] - the value for the tabindex
1572
+ * @param {number} [tabIndex = 0] - the value for the tabindex
1123
1573
  */
1124
1574
  export function updateRowTabIndex(state, rowIndex, tabIndex = 0) {
1125
1575
  if (!isHeaderRow(rowIndex)) {
@@ -1162,28 +1612,6 @@ export function updateTabIndexActiveRow(state, index = 0) {
1162
1612
 
1163
1613
  /***************************** INDEX COMPUTATIONS *****************************/
1164
1614
 
1165
- /**
1166
- * It return the indexes { rowIndex, colIndex } of a cell based of the unique cell values
1167
- * rowKeyValue, colKeyValue
1168
- * @param {object} state - datatable state
1169
- * @param {string} rowKeyValue - the row key value
1170
- * @param {string} colKeyValue - the column key value
1171
- * @returns {object} - {rowIndex, colIndex}
1172
- */
1173
- export function getIndexesByKeys(state, rowKeyValue, colKeyValue) {
1174
- if (rowKeyValue === HEADER_ROW_KEY) {
1175
- return {
1176
- rowIndex: -1,
1177
- colIndex: state.headerIndexes[colKeyValue],
1178
- };
1179
- }
1180
-
1181
- return {
1182
- rowIndex: state.indexes[rowKeyValue][colKeyValue][0],
1183
- colIndex: state.indexes[rowKeyValue][colKeyValue][1],
1184
- };
1185
- }
1186
-
1187
1615
  function getNextIndexUp(state, rowIndex) {
1188
1616
  return rowIndex === -1 ? undefined : rowIndex - 1;
1189
1617
  }
@@ -1276,13 +1704,6 @@ function isHeaderRow(rowIndex) {
1276
1704
  return rowIndex === -1;
1277
1705
  }
1278
1706
 
1279
- function getCellElementByKeys(template, rowKeyValue, colKeyValue) {
1280
- const selector = `${getRowDataSelector(rowKeyValue)} ${getColDataSelector(
1281
- colKeyValue
1282
- )} > :first-child`;
1283
- return template.querySelector(selector);
1284
- }
1285
-
1286
1707
  function getActiveCellRowElement(template, state) {
1287
1708
  let result;
1288
1709
  const { activeCell } = state;
@@ -1291,7 +1712,7 @@ function getActiveCellRowElement(template, state) {
1291
1712
  getRowDataSelector(activeCell.rowKeyValue)
1292
1713
  );
1293
1714
  }
1294
- return result || null;
1715
+ return result || undefined;
1295
1716
  }
1296
1717
 
1297
1718
  export function getRowParentIndex(state, rowLevel, rowIndex) {
@@ -1334,22 +1755,8 @@ function scrollToCell(state, template, rowIndex) {
1334
1755
  }
1335
1756
 
1336
1757
  export function isActiveCellEditable(state) {
1337
- if (state.activeCell) {
1338
- const { rowIndex, colIndex } = getIndexesActiveCell(state);
1339
- const activeCell = state.rows[rowIndex].cells[colIndex];
1340
- return activeCell ? activeCell.editable : false;
1341
- }
1342
- return false;
1343
- }
1344
-
1345
- export function isValidCell(state, rowKeyValue, colKeyValue) {
1346
- if (rowKeyValue === HEADER_ROW_KEY) {
1347
- return state.headerIndexes[colKeyValue] !== undefined;
1348
- }
1349
- const row = getRowByKey(state, rowKeyValue);
1350
- const colIndex = getStateColumnIndex(state, colKeyValue);
1351
-
1352
- return row && row.cells[colIndex];
1758
+ const { activeCell } = state;
1759
+ return activeCell ? activeCell.editable : false;
1353
1760
  }
1354
1761
 
1355
1762
  function isActiveCellValid(state) {
@@ -1365,16 +1772,20 @@ function isActiveCellValid(state) {
1365
1772
  }
1366
1773
 
1367
1774
  export function updateActiveCellTabIndexAfterSync(state, tabIndex = 0) {
1368
- if (state.activeCell && !isRowNavigationMode(state)) {
1369
- const { rowIndex, colIndex } = getIndexesActiveCell(state);
1370
- updateCellTabIndex(state, rowIndex, colIndex, tabIndex);
1775
+ const { activeCell } = state;
1776
+ if (activeCell && !isRowNavigationMode(state)) {
1777
+ updateCellTabIndex(
1778
+ state,
1779
+ activeCell.rowIndex,
1780
+ activeCell.colIndex,
1781
+ tabIndex
1782
+ );
1371
1783
  }
1372
1784
  }
1373
1785
 
1374
1786
  export function updateActiveRowTabIndexAfterSync(state, tabIndex = 0) {
1375
1787
  const { activeCell } = state;
1376
1788
  if (activeCell && isRowNavigationMode(state)) {
1377
- const { rowIndex } = getIndexesActiveCell(state);
1378
- updateRowTabIndex(state, rowIndex, tabIndex);
1789
+ updateRowTabIndex(state, activeCell.rowIndex, tabIndex);
1379
1790
  }
1380
1791
  }