lightning-base-components 1.21.2-alpha → 1.21.4-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/metadata/raptor.json +77 -1
  2. package/package.json +108 -15
  3. package/scopedImports/@salesforce-label-LightningDatatable.showActions.js +1 -1
  4. package/scopedImports/@salesforce-label-LightningForm.controllerFieldsMessage.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningForm.dependentFieldsHeader.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningForm.dependentFieldsListHeading.js +1 -0
  7. package/scopedImports/@salesforce-label-LightningForm.generalDependentFieldsMessage.js +1 -0
  8. package/scopedImports/@salesforce-label-LightningForm.learnMore.js +1 -0
  9. package/scopedImports/@salesforce-label-LightningForm.okButton.js +1 -0
  10. package/scopedImports/@salesforce-label-LightningLookup.modalCancel.js +1 -0
  11. package/scopedImports/@salesforce-label-LightningLookup.modalSelect.js +1 -0
  12. package/scopedImports/@salesforce-label-LightningProgressIndicator.currentStage.js +1 -1
  13. package/scopedImports/@salesforce-label-LightningProgressIndicator.errorStage.js +1 -0
  14. package/scopedImports/@salesforce-label-LightningProgressIndicator.stageComplete.js +1 -1
  15. package/scopedImports/@salesforce-label-LightningProgressIndicator.stageNotStarted.js +1 -1
  16. package/scopedImports/@salesforce-label-LightningRichTextEditor.colorPicker.js +1 -0
  17. package/src/lightning/accordion/accordion-section.slds.css +3 -3
  18. package/src/lightning/accordion/accordion.slds.css +1 -2
  19. package/src/lightning/accordionSection/accordion-section.slds.css +3 -3
  20. package/src/lightning/accordionSection/accordionSection.js +3 -1
  21. package/src/lightning/accordionSection/button.slds.css +1 -1
  22. package/src/lightning/avatar/avatar.html +1 -0
  23. package/src/lightning/badge/badge.html +3 -3
  24. package/src/lightning/badge/badge.js +1 -0
  25. package/src/lightning/badge/badge.js-meta.xml +3 -0
  26. package/src/lightning/baseCombobox/base-combobox.slds.css +11 -6
  27. package/src/lightning/baseCombobox/baseCombobox.html +5 -2
  28. package/src/lightning/baseCombobox/baseCombobox.js +5 -18
  29. package/src/lightning/baseCombobox/baseCombobox.js-meta.xml +6 -0
  30. package/src/lightning/baseCombobox/input-text.slds.css +41 -68
  31. package/src/lightning/baseCombobox/keyboard.js +12 -4
  32. package/src/lightning/baseCombobox/listbox.slds.css +51 -99
  33. package/src/lightning/baseCombobox/spinner.slds.css +62 -62
  34. package/src/lightning/baseComboboxFormattedText/baseComboboxFormattedText.js-meta.xml +6 -0
  35. package/src/lightning/baseComboboxItem/baseComboboxItem.js +10 -6
  36. package/src/lightning/baseComboboxItem/baseComboboxItem.js-meta.xml +6 -0
  37. package/src/lightning/baseComboboxItem/listbox.slds.css +51 -99
  38. package/src/lightning/baseFormattedText/baseFormattedText.js +2 -2
  39. package/src/lightning/button/__docs__/button.md +2 -1
  40. package/src/lightning/button/button.js +5 -5
  41. package/src/lightning/button/button.slds.css +1 -1
  42. package/src/lightning/buttonIcon/__docs__/buttonIcon.md +1 -0
  43. package/src/lightning/buttonIcon/button-icon.slds.css +1 -1
  44. package/src/lightning/buttonIcon/buttonIcon.html +1 -1
  45. package/src/lightning/buttonIcon/buttonIcon.js +18 -17
  46. package/src/lightning/buttonIconStateful/button-icon-stateful.slds.css +4 -2
  47. package/src/lightning/buttonIconStateful/button-icon.slds.css +1 -1
  48. package/src/lightning/buttonIconStateful/button.slds.css +1 -1
  49. package/src/lightning/buttonMenu/button-icon.slds.css +1 -1
  50. package/src/lightning/buttonMenu/button-menu.slds.css +8 -2
  51. package/src/lightning/buttonMenu/button.slds.css +1 -1
  52. package/src/lightning/buttonMenu/buttonMenu.css +5 -0
  53. package/src/lightning/buttonMenu/buttonMenu.js +2 -0
  54. package/src/lightning/buttonStateful/button-stateful.slds.css +6 -2
  55. package/src/lightning/buttonStateful/button.slds.css +1 -1
  56. package/src/lightning/buttonStateful/buttonStateful.js +4 -1
  57. package/src/lightning/calendar/calendar.js-meta.xml +6 -0
  58. package/src/lightning/calendar/calendar.slds.css +9 -2
  59. package/src/lightning/colorPickerCustom/color-picker-custom.slds.css +22 -23
  60. package/src/lightning/colorPickerCustom/colorPickerCustom.js +12 -0
  61. package/src/lightning/colorPickerCustom/input-text.slds.css +41 -68
  62. package/src/lightning/colorPickerPanel/color-picker-panel.slds.css +9 -10
  63. package/src/lightning/colorPickerPanel/colorPickerPanel.js +11 -1
  64. package/src/lightning/colorPickerPanel/popover.slds.css +0 -2
  65. package/src/lightning/combobox/combobox.html +1 -0
  66. package/src/lightning/combobox/combobox.slds.css +1 -2
  67. package/src/lightning/combobox/form-element.slds.css +54 -54
  68. package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.html +11 -0
  69. package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.js +25 -0
  70. package/src/lightning/datatable/__examples__disabled/customComponentWrapper/generateData.js +15 -0
  71. package/src/lightning/datatable/__examples__disabled/customDatatableWrapper/customDatatableWrapper.js +89 -0
  72. package/src/lightning/datatable/__examples__disabled/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +6 -0
  73. package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.js +1 -16
  74. package/src/lightning/datatable/__examples__disabled/customDatatypeLink/customDatatypeLink.html +9 -0
  75. package/src/lightning/datatable/__examples__disabled/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html +3 -0
  76. package/src/lightning/datatable/__examples__disabled/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +3 -0
  77. package/src/lightning/datatable/__examples__disabled/customDatatypeTable/customNumber.html +3 -0
  78. package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumberEdit.html +2 -0
  79. package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/deleteRow.html +3 -2
  80. package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/iconPill.html +1 -1
  81. package/src/lightning/datatable/{__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html → __examples__disabled/customNestedComponent/customNestedComponent.html} +2 -2
  82. package/src/lightning/datatable/__examples__disabled/customNestedComponent/customNestedComponent.js +12 -0
  83. package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/customInput.html +4 -0
  84. package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/myCustomTypeDatatable.js +17 -0
  85. package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/nestedSimpleComponentParent.html +7 -0
  86. package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.html +9 -0
  87. package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.js +6 -0
  88. package/src/lightning/datatable/autoWidthStrategy.js +145 -217
  89. package/src/lightning/datatable/columnResizer.js +80 -190
  90. package/src/lightning/datatable/columnWidthManager.js +128 -243
  91. package/src/lightning/datatable/columns.js +192 -283
  92. package/src/lightning/datatable/datagrid.slds.css +187 -0
  93. package/src/lightning/datatable/datatable.js +647 -614
  94. package/src/lightning/datatable/errors.js +19 -28
  95. package/src/lightning/datatable/fixedWidthStrategy.js +27 -49
  96. package/src/lightning/datatable/headerActions.js +10 -42
  97. package/src/lightning/datatable/indexes.js +42 -0
  98. package/src/lightning/datatable/infiniteLoading.js +27 -46
  99. package/src/lightning/datatable/inlineEdit.js +311 -322
  100. package/src/lightning/datatable/keyboard.js +490 -510
  101. package/src/lightning/datatable/renderManager.js +10 -11
  102. package/src/lightning/datatable/resizeObserver.js +10 -67
  103. package/src/lightning/datatable/rowLevelActions.js +7 -6
  104. package/src/lightning/datatable/rowNumber.js +41 -79
  105. package/src/lightning/datatable/rowSelection.js +236 -291
  106. package/src/lightning/datatable/rowSelectionShared.js +26 -33
  107. package/src/lightning/datatable/rows.js +264 -476
  108. package/src/lightning/datatable/sort.js +27 -82
  109. package/src/lightning/datatable/templates/div/div.css +2 -57
  110. package/src/lightning/datatable/templates/div/div.html +25 -10
  111. package/src/lightning/datatable/templates/div/div.lbc.native.css +3 -0
  112. package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +80 -0
  113. package/src/lightning/datatable/templates/table/table.html +16 -5
  114. package/src/lightning/datatable/tree.js +17 -35
  115. package/src/lightning/datatable/types.js +10 -31
  116. package/src/lightning/datatable/utils.js +54 -29
  117. package/src/lightning/datatable/virtualization.js +2 -5
  118. package/src/lightning/datatable/widthManagerShared.js +24 -41
  119. package/src/lightning/datatable/wrapText.js +45 -77
  120. package/src/lightning/datepicker/datepicker.js +32 -9
  121. package/src/lightning/datepicker/datepicker.js-meta.xml +6 -0
  122. package/src/lightning/datepicker/form-element.slds.css +54 -54
  123. package/src/lightning/datepicker/input-text.slds.css +41 -68
  124. package/src/lightning/datetimepicker/datetimepicker.js-meta.xml +6 -0
  125. package/src/lightning/datetimepicker/form-element.slds.css +54 -54
  126. package/src/lightning/datetimepicker/input-text.slds.css +41 -68
  127. package/src/lightning/dualListbox/dual-listbox.slds.css +7 -2
  128. package/src/lightning/dualListbox/dualListbox.js +7 -8
  129. package/src/lightning/dualListbox/form-element.slds.css +54 -54
  130. package/src/lightning/dualListbox/listbox.slds.css +51 -99
  131. package/src/lightning/dynamicIcon/dynamic-icon-strength.slds.css +1 -2
  132. package/src/lightning/dynamicIcon/dynamic-icon-trend.slds.css +1 -2
  133. package/src/lightning/formattedDateTime/formattedDateTime.js +7 -62
  134. package/src/lightning/formattedDateTime/formattedDateTime.js-meta.xml +3 -0
  135. package/src/lightning/formattedLocation/formattedLocation.html +1 -3
  136. package/src/lightning/formattedLocation/formattedLocation.js +3 -25
  137. package/src/lightning/formattedLookup/events.js +2 -4
  138. package/src/lightning/formattedName/formattedName.js +3 -2
  139. package/src/lightning/formattedName/formattedName.js-meta.xml +3 -0
  140. package/src/lightning/formattedNumber/formattedNumber.js +5 -51
  141. package/src/lightning/formattedNumber/formattedNumber.js-meta.xml +3 -0
  142. package/src/lightning/formattedRichText/formattedRichText.js +5 -5
  143. package/src/lightning/formattedRichText/linkTextNodes.js +58 -0
  144. package/src/lightning/formattedRichText/richTextConfig.js +1 -0
  145. package/src/lightning/groupedCombobox/form-element.slds.css +54 -54
  146. package/src/lightning/groupedCombobox/grouped-combobox.slds.css +0 -2
  147. package/src/lightning/groupedCombobox/groupedCombobox.js-meta.xml +1 -1
  148. package/src/lightning/groupedCombobox/input-text.slds.css +41 -68
  149. package/src/lightning/helptext/button-icon.slds.css +1 -1
  150. package/src/lightning/helptext/form-element.slds.css +54 -54
  151. package/src/lightning/helptext/helptext.css +7 -0
  152. package/src/lightning/helptext/helptext.js +3 -4
  153. package/src/lightning/icon/icon.html +1 -1
  154. package/src/lightning/icon/icon.slds.css +12 -25
  155. package/src/lightning/input/form-element.slds.css +54 -54
  156. package/src/lightning/input/input.html +5 -0
  157. package/src/lightning/inputAddress/addressFormat.js +31 -4
  158. package/src/lightning/inputAddress/fieldsLayout.js +6 -0
  159. package/src/lightning/inputAddress/form-element.slds.css +54 -54
  160. package/src/lightning/inputAddress/input-address.slds.css +1 -2
  161. package/src/lightning/inputAddress/input-text.slds.css +41 -68
  162. package/src/lightning/inputAddress/inputAddress.html +19 -1
  163. package/src/lightning/inputAddress/inputAddress.js +75 -3
  164. package/src/lightning/inputAddress/inputAddress.js-meta.xml +3 -0
  165. package/src/lightning/inputLocation/form-element.slds.css +54 -54
  166. package/src/lightning/inputLocation/input-location.slds.css +1 -2
  167. package/src/lightning/inputLocation/input-text.slds.css +41 -68
  168. package/src/lightning/inputName/form-element.slds.css +54 -54
  169. package/src/lightning/inputName/input-text.slds.css +41 -68
  170. package/src/lightning/interactiveDialogBase/interactive-dialog-base.slds.css +0 -3
  171. package/src/lightning/interactiveDialogBase/interactiveDialogBase.js-meta.xml +6 -0
  172. package/src/lightning/internationalizationLibrary/address/AddressFormat.js +553 -610
  173. package/src/lightning/lookupAddress/form-element.slds.css +54 -54
  174. package/src/lightning/lookupAddress/listbox.slds.css +51 -99
  175. package/src/lightning/lookupAddress/location.js +2 -0
  176. package/src/lightning/lookupAddress/lookup-address.slds.css +0 -2
  177. package/src/lightning/lookupAddress/lookupAddress.html +6 -1
  178. package/src/lightning/lookupAddress/lookupAddress.js +40 -10
  179. package/src/lightning/menuDivider/menu-divider.slds.css +0 -2
  180. package/src/lightning/menuItem/menu-item.slds.css +8 -2
  181. package/src/lightning/menuSubheader/menu-subheader.slds.css +1 -2
  182. package/src/lightning/modal/__docs__/modal.md +10 -1
  183. package/src/lightning/modal/__modalUtils__/modalContainerTestConstants.js +3 -7
  184. package/src/lightning/modal/__modalUtils__/modalContainerTestMethods.js +39 -133
  185. package/src/lightning/modal/__modalUtils__/modalContainerTestMockData.js +1 -1
  186. package/src/lightning/modal/modal.js +1 -1
  187. package/src/lightning/modalBase/modal-base.slds.css +3 -3
  188. package/src/lightning/modalBase/modalBase.html +15 -10
  189. package/src/lightning/modalBase/modalBase.js +131 -154
  190. package/src/lightning/modalBase/modalBase.js-meta.xml +6 -0
  191. package/src/lightning/modalBody/modal-body.slds.css +1 -2
  192. package/src/lightning/modalBody/modalBody.css +6 -0
  193. package/src/lightning/modalFooter/modal-footer.slds.css +2 -2
  194. package/src/lightning/modalFooter/modalFooter.js +0 -21
  195. package/src/lightning/modalHeader/modal-header.slds.css +1 -2
  196. package/src/lightning/modalHeader/modalHeader.html +16 -4
  197. package/src/lightning/modalHeader/modalHeader.js +61 -36
  198. package/src/lightning/overlay/overlay.js-meta.xml +6 -0
  199. package/src/lightning/pill/link.html +1 -0
  200. package/src/lightning/pill/pill.slds.css +32 -58
  201. package/src/lightning/pill/plain.html +1 -0
  202. package/src/lightning/pill/plainLink.html +1 -0
  203. package/src/lightning/pillContainer/button.slds.css +1 -1
  204. package/src/lightning/pillContainer/listbox.slds.css +51 -99
  205. package/src/lightning/pillContainer/pill-container.slds.css +6 -10
  206. package/src/lightning/pillContainer/pill.slds.css +32 -58
  207. package/src/lightning/popup/popover.slds.css +0 -2
  208. package/src/lightning/primitiveBubble/primitiveBubble.js +42 -0
  209. package/src/lightning/primitiveBubble/primitiveBubble.js-meta.xml +6 -0
  210. package/src/lightning/primitiveButton/primitiveButoon.js-meta.xml +6 -0
  211. package/src/lightning/primitiveCellCheckbox/checkbox.css +2 -0
  212. package/src/lightning/primitiveColorpickerButton/color-picker-button.slds.css +16 -38
  213. package/src/lightning/primitiveCustomCell/primitiveCustomCell.js +26 -1
  214. package/src/lightning/primitiveDatatableCell/primitiveDatatableCell.js +1 -1
  215. package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.html +1 -1
  216. package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +13 -0
  217. package/src/lightning/primitiveHeaderFactory/nonsortableHeader.css +1 -0
  218. package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +19 -6
  219. package/src/lightning/primitiveHeaderFactory/selectableHeader.css +2 -0
  220. package/src/lightning/primitiveHeaderFactory/sortableHeader.html +3 -1
  221. package/src/lightning/primitiveIcon/icon.slds.css +12 -25
  222. package/src/lightning/primitiveIcon/primitiveIcon.js-meta.xml +6 -0
  223. package/src/lightning/primitiveIframe/primitiveIframe.js +3 -1
  224. package/src/lightning/primitiveInputCheckbox/form-element.slds.css +54 -54
  225. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js +5 -2
  226. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js-meta.xml +6 -0
  227. package/src/lightning/primitiveInputCheckboxButton/form-element.slds.css +54 -54
  228. package/src/lightning/primitiveInputCheckboxButton/input-checkbox-button.slds.css +6 -4
  229. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js +5 -2
  230. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js-meta.xml +6 -0
  231. package/src/lightning/primitiveInputColor/form-element.slds.css +54 -54
  232. package/src/lightning/primitiveInputColor/input-color.slds.css +2 -3
  233. package/src/lightning/primitiveInputColor/input-text.slds.css +41 -68
  234. package/src/lightning/primitiveInputColor/primitiveInputColor.js +5 -2
  235. package/src/lightning/primitiveInputColor/primitiveInputColor.js-meta.xml +6 -0
  236. package/src/lightning/primitiveInputFile/button.slds.css +1 -1
  237. package/src/lightning/primitiveInputFile/form-element.slds.css +54 -54
  238. package/src/lightning/primitiveInputFile/input-file.slds.css +1 -4
  239. package/src/lightning/primitiveInputFile/primitiveInputFile.js +4 -2
  240. package/src/lightning/primitiveInputFile/primitiveInputFile.js-meta.xml +6 -0
  241. package/src/lightning/primitiveInputRadio/primitiveInputRadio.js +4 -2
  242. package/src/lightning/primitiveInputSimple/form-element.slds.css +54 -54
  243. package/src/lightning/primitiveInputSimple/input-text.slds.css +41 -68
  244. package/src/lightning/primitiveInputSimple/primitiveInputSimple.js-meta.xml +6 -0
  245. package/src/lightning/primitiveInputToggle/form-element.slds.css +54 -54
  246. package/src/lightning/primitiveInputToggle/input-toggle.slds.css +50 -27
  247. package/src/lightning/primitiveInputToggle/primitiveInputToggle.js +5 -2
  248. package/src/lightning/primitiveInputToggle/primitiveInputToggle.js-meta.xml +6 -0
  249. package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.css +11 -0
  250. package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.html +2 -1
  251. package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.js +1 -0
  252. package/src/lightning/progressBar/progress-bar.slds.css +8 -10
  253. package/src/lightning/progressRing/progress-ring.slds.css +0 -23
  254. package/src/lightning/progressStep/base.html +5 -6
  255. package/src/lightning/progressStep/progressStep.js +15 -23
  256. package/src/lightning/prompt/__docs__/prompt.md +1 -1
  257. package/src/lightning/radioGroup/form-element.slds.css +54 -54
  258. package/src/lightning/radioGroup/radioGroup.html +1 -2
  259. package/src/lightning/radioGroup/radioGroup.js +1 -0
  260. package/src/lightning/routingService/routingService.js +31 -5
  261. package/src/lightning/select/form-element.slds.css +54 -54
  262. package/src/lightning/select/select.slds.css +4 -2
  263. package/src/lightning/shadowBaseClassPrivate/shadowBaseClassPrivate.js +0 -2
  264. package/src/lightning/sldsCommon/sldsCommon.css +134 -98
  265. package/src/lightning/sldsUtilsAlignment/sldsUtilsAlignment.css +1 -1
  266. package/src/lightning/sldsUtilsBox/sldsUtilsBox.css +14 -13
  267. package/src/lightning/sldsUtilsGrid/sldsUtilsGrid.css +95 -92
  268. package/src/lightning/sldsUtilsHyphenation/sldsUtilsHyphenation.css +1 -1
  269. package/src/lightning/sldsUtilsMargin/sldsUtilsMargin.css +77 -75
  270. package/src/lightning/sldsUtilsPadding/sldsUtilsPadding.css +73 -73
  271. package/src/lightning/sldsUtilsSizing/sldsUtilsSizing.css +552 -558
  272. package/src/lightning/sldsUtilsVisibility/sldsUtilsVisibility.css +5 -1
  273. package/src/lightning/spinner/spinner.slds.css +62 -62
  274. package/src/lightning/staticMap/staticMap.js +3 -2
  275. package/src/lightning/tab/tab.js +10 -5
  276. package/src/lightning/tab/tab.js-meta.xml +3 -0
  277. package/src/lightning/tab/tab.slds.css +14 -7
  278. package/src/lightning/tabBar/tab-bar.slds.css +16 -6
  279. package/src/lightning/tabBar/tabBar.js +10 -5
  280. package/src/lightning/tabset/__docs__/tabset.md +24 -1
  281. package/src/lightning/tabset/tabset.html +2 -0
  282. package/src/lightning/tabset/tabset.js +25 -38
  283. package/src/lightning/tabset/tabset.js-meta.xml +3 -0
  284. package/src/lightning/tabset/tabset.slds.css +0 -2
  285. package/src/lightning/textarea/form-element.slds.css +54 -54
  286. package/src/lightning/textarea/textarea.js +11 -2
  287. package/src/lightning/textarea/textarea.slds.css +22 -9
  288. package/src/lightning/timepicker/form-element.slds.css +54 -54
  289. package/src/lightning/timepicker/timepicker.js-meta.xml +6 -0
  290. package/src/lightning/timepicker/timepicker.slds.css +2 -2
  291. package/src/lightning/toast/__docs__/toast.md +20 -22
  292. package/src/lightning/toast/button-icon.slds.css +1 -1
  293. package/src/lightning/toast/icon.slds.css +12 -25
  294. package/src/lightning/toast/toast.js +15 -12
  295. package/src/lightning/toast/toast.slds.css +6 -18
  296. package/src/lightning/toastContainer/__docs__/toastContainer.md +3 -2
  297. package/src/lightning/toastContainer/toast.slds.css +6 -18
  298. package/src/lightning/toastContainer/toastContainer.js +25 -17
  299. package/src/lightning/tooltipLibrary/tooltipLibrary.js +36 -24
  300. package/src/lightning/tree/tree.js +2 -0
  301. package/src/lightning/utils/classSet.js +9 -3
  302. package/src/lightning/utilsPrivate/formatUtils.js +158 -0
  303. package/src/lightning/utilsPrivate/textUtils.js +16 -0
  304. package/src/lightning/utilsPrivate/utilsPrivate.js +56 -15
  305. package/src/lightning/utilsPrivate/validationUtils.js +59 -0
  306. package/src/lightning/verticalNavigation/vertical-navigation.slds.css +14 -0
  307. package/src/lightning/verticalNavigation/verticalNavigation.css +1 -1
  308. package/src/lightning/verticalNavigation/verticalNavigation.html +1 -1
  309. package/src/lightning/verticalNavigation/verticalNavigation.js +66 -28
  310. package/src/lightning/verticalNavigation/verticalNavigation.js-meta.xml +3 -0
  311. package/src/lightning/verticalNavigationItem/vertical-navigation-item.slds.css +63 -0
  312. package/src/lightning/verticalNavigationItem/verticalNavigationItem.css +2 -3
  313. package/src/lightning/verticalNavigationItem/verticalNavigationItem.js +29 -15
  314. package/src/lightning/verticalNavigationItem/verticalNavigationItem.js-meta.xml +3 -0
  315. package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.native.css +2 -0
  316. package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.synthetic.css +3 -0
  317. package/src/lightning/verticalNavigationItemBadge/badge.slds.css +76 -0
  318. package/src/lightning/verticalNavigationItemBadge/vertical-navigation-item.slds.css +63 -0
  319. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.css +2 -3
  320. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.html +1 -1
  321. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js +28 -15
  322. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js-meta.xml +3 -0
  323. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.native.css +5 -0
  324. package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.synthetic.css +3 -0
  325. package/src/lightning/verticalNavigationItemIcon/vertical-navigation-item.slds.css +63 -0
  326. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.css +2 -3
  327. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js +29 -15
  328. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js-meta.xml +3 -0
  329. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.native.css +3 -0
  330. package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.synthetic.css +3 -0
  331. package/src/lightning/verticalNavigationOverflow/button.slds.css +503 -0
  332. package/src/lightning/verticalNavigationOverflow/vertical-navigation-item.slds.css +63 -0
  333. package/src/lightning/verticalNavigationOverflow/vertical-navigation-section.slds.css +17 -0
  334. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.css +2 -1
  335. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.html +2 -0
  336. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js +18 -13
  337. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js-meta.xml +3 -0
  338. package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.lbc.native.css +5 -0
  339. package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +13 -15
  340. package/src/lightning/verticalNavigationSection/verticalNavigationSection.js-meta.xml +3 -0
  341. package/src/lightning/datatable/__examples__/customDatatableWrapper/customDatatableWrapper.js +0 -158
  342. package/src/lightning/datatable/__examples__/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +0 -6
  343. package/src/lightning/datatable/__examples__/customDatatypeLink/customDatatypeLink.html +0 -9
  344. package/src/lightning/datatable/__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +0 -40
  345. package/src/lightning/datatable/__examples__/customDatatypeTable/customNumber.html +0 -3
  346. package/src/lightning/datatable/inlineEditShared.js +0 -26
  347. package/src/lightning/datatable/resizeSensor.js +0 -244
  348. package/src/lightning/formattedRichText/linkify.js +0 -43
  349. package/src/lightning/utilsPrivate/smartSetAttribute.js +0 -19
  350. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.html +0 -0
  351. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.js +0 -0
  352. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.html +0 -0
  353. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.js +0 -0
  354. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customDatatypeTable.js +0 -0
  355. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customLink.html +0 -0
  356. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customName.html +0 -0
  357. /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/orderingButtons.html +0 -0
@@ -1,41 +1,28 @@
1
1
  import {
2
2
  startPositioning,
3
3
  stopPositioning,
4
- Direction,
4
+ Direction as DIRECTION,
5
5
  } from 'lightning/positionLibrary';
6
6
  import {
7
7
  setFocusActiveCell,
8
8
  reactToTabBackward,
9
9
  reactToTabForward,
10
10
  getActiveCellElement,
11
- updateActiveCell,
12
11
  isActiveCellEditable,
12
+ NAVIGATION_DIR,
13
13
  isValidCell,
14
14
  } from './keyboard';
15
+ import { updateRowsAndCellIndexes, isCellEditable } from './rows';
16
+ import { getStateColumnIndex } from './columns';
17
+ import { resetErrors } from './errors';
18
+ import { setAriaSelectedOnCell, unsetAriaSelectedOnCell } from './rowSelection';
15
19
  import {
16
- updateRowsAndCellIndexes,
17
- getRowByKey,
18
- getKeyField,
19
- getUserRowByCellKeys,
20
- isCellEditable,
21
- } from './rows';
22
- import {
23
- getColumnIndexByColumnKey,
24
- getColumns,
25
- getStateColumnIndex,
26
- getEditableColumns,
27
- } from './columns';
28
- import { setErrors } from './errors';
29
- import {
30
- setAriaSelectedOnCell,
31
- unsetAriaSelectedOnCell,
32
- isSelectedRow,
33
20
  getCurrentSelectionLength,
34
21
  getSelectedRowsKeys,
35
- } from './rowSelection';
36
- import { isObjectLike } from './utils';
37
-
38
- export { getDirtyValueFromCell } from './inlineEditShared';
22
+ isSelectedRow,
23
+ } from './rowSelectionShared';
24
+ import { hasOwnProperties } from 'lightning/utilsPrivate';
25
+ import { getRowByKey, getUserRowByCellKeys } from './indexes';
39
26
 
40
27
  const IEDIT_PANEL_SELECTOR = '[data-iedit-panel="true"]';
41
28
  const HIDE_PANEL_THRESHOLD = 5; // hide panel on scroll
@@ -60,10 +47,10 @@ export function handleEditCell(event) {
60
47
  */
61
48
  export function handleInlineEditFinish(event) {
62
49
  stopPanelPositioning(this);
63
-
64
50
  const { reason, rowKeyValue, colKeyValue } = event.detail;
65
-
66
51
  processInlineEditFinish(this, reason, rowKeyValue, colKeyValue);
52
+ // Set private draftValues var to new value
53
+ this._draftValues = this.draftValues;
67
54
  }
68
55
 
69
56
  /**
@@ -77,11 +64,12 @@ export function handleMassCheckboxChange(event) {
77
64
  if (event.detail.checked) {
78
65
  setAriaSelectedOnAllSelectedRows(state);
79
66
  } else {
67
+ const { inlineEdit: inlineEditState } = state;
80
68
  unsetAriaSelectedOnAllSelectedRows(this.state);
81
69
  setAriaSelectedOnCell(
82
70
  state,
83
- state.inlineEdit.rowKeyValue,
84
- state.inlineEdit.colKeyValue
71
+ inlineEditState.rowKeyValue,
72
+ inlineEditState.colKeyValue
85
73
  );
86
74
  }
87
75
  }
@@ -98,30 +86,32 @@ export function handleMassCheckboxChange(event) {
98
86
  * @returns
99
87
  */
100
88
  export function handleInlineEditPanelScroll(event) {
101
- const { isPanelVisible, rowKeyValue, colKeyValue } = this.state.inlineEdit;
89
+ const { state } = this;
90
+ const { inlineEdit: inlineEditState } = state;
91
+ const { isPanelVisible } = inlineEditState;
102
92
 
103
93
  if (!isPanelVisible) {
104
94
  return;
105
95
  }
106
96
 
107
97
  let delta = 0;
108
- const container = event.target;
98
+ const { target: scroller } = event;
109
99
 
110
- // When user scrolls horizontally
111
- if (container.classList.contains('slds-scrollable_x')) {
112
- const scrollX = container.scrollLeft;
113
- if (this.privateLastScrollX == null) {
114
- this.privateLastScrollX = scrollX;
100
+ // When user scrolls vertically.
101
+ if (scroller.classList.contains('slds-scrollable_y')) {
102
+ const scrollY = scroller.scrollTop;
103
+ if (this._lastScrollY == null) {
104
+ this._lastScrollY = scrollY;
115
105
  } else {
116
- delta = Math.abs(this.privateLastScrollX - scrollX);
106
+ delta = Math.abs(this._lastScrollY - scrollY);
117
107
  }
118
108
  } else {
119
- // When user scrolls vertically
120
- const scrollY = container.scrollTop;
121
- if (this.privateLastScrollY == null) {
122
- this.privateLastScrollY = scrollY;
109
+ // When user scrolls horizontally.
110
+ const scrollX = scroller.scrollLeft;
111
+ if (this._lastScrollX == null) {
112
+ this._lastScrollX = scrollX;
123
113
  } else {
124
- delta = Math.abs(this.privateLastScrollY - scrollY);
114
+ delta = Math.abs(this._lastScrollX - scrollX);
125
115
  }
126
116
  }
127
117
 
@@ -129,8 +119,9 @@ export function handleInlineEditPanelScroll(event) {
129
119
  // reset stored scroll values, hide panel and
130
120
  // process inline edit completion
131
121
  if (delta > HIDE_PANEL_THRESHOLD) {
132
- this.privateLastScrollX = null;
133
- this.privateLastScrollY = null;
122
+ const { rowKeyValue, colKeyValue } = inlineEditState;
123
+ this._lastScrollX = null;
124
+ this._lastScrollY = null;
134
125
  stopPanelPositioning(this);
135
126
  processInlineEditFinish(this, 'lost-focus', rowKeyValue, colKeyValue);
136
127
  } else {
@@ -146,17 +137,14 @@ export function handleInlineEditPanelScroll(event) {
146
137
  * Dispatches the `cellchange` event with the `draftValues` in the
147
138
  * detail object.
148
139
  *
149
- * @param {Object} dtInstance - datatable instance
150
- * @param {Object} cellChange - object containing cell changes
140
+ * @param {Object} dt - The datatable instance
141
+ * @param {Object} changes - Object containing cell changes
151
142
  */
152
- function dispatchCellChangeEvent(dtInstance, cellChange) {
153
- dtInstance.dispatchEvent(
143
+ function dispatchCellChangeEvent(dt, changes) {
144
+ dt.dispatchEvent(
154
145
  new CustomEvent('cellchange', {
155
146
  detail: {
156
- draftValues: getResolvedCellChanges(
157
- dtInstance.state,
158
- cellChange
159
- ),
147
+ draftValues: getResolvedCellChanges(dt.state, changes),
160
148
  },
161
149
  })
162
150
  );
@@ -165,17 +153,18 @@ function dispatchCellChangeEvent(dtInstance, cellChange) {
165
153
  /************************** INLINE EDIT STATE MANAGEMENT **************************/
166
154
 
167
155
  export function isInlineEditTriggered(state) {
168
- return Object.keys(state.inlineEdit.dirtyValues).length > 0;
156
+ return hasOwnProperties(state.inlineEdit.dirtyValues);
169
157
  }
170
158
 
171
159
  export function cancelInlineEdit(dt) {
172
- dt.state.inlineEdit.dirtyValues = {};
173
- setErrors(dt.state, {});
174
- updateRowsAndCellIndexes.call(dt);
160
+ const { state, _privateTypes } = dt;
161
+ resetErrors(state);
162
+ state.inlineEdit.dirtyValues = {};
163
+ updateRowsAndCellIndexes(state, _privateTypes);
175
164
  }
176
165
 
177
166
  export function closeInlineEdit(dt) {
178
- const inlineEditState = dt.state.inlineEdit;
167
+ const { inlineEdit: inlineEditState } = dt.state;
179
168
 
180
169
  if (inlineEditState.isPanelVisible) {
181
170
  processInlineEditFinish(
@@ -213,71 +202,68 @@ export function closeInlineEdit(dt) {
213
202
  *
214
203
  * If the user inline edit panel lost focus, the datatable should react accordingly.
215
204
  *
216
- * @param {Object} dt - datatable instance
205
+ * @param {Object} dt - The datatable instance
217
206
  * @param {string} reason - reason to finish the edit; valid reasons are: edit-canceled | lost-focus | tab-pressed | submit-action
218
207
  * @param {string} rowKeyValue - row key of the edited cell
219
208
  * @param {string} colKeyValue - column key of the edited cell
220
209
  */
221
210
  function processInlineEditFinish(dt, reason, rowKeyValue, colKeyValue) {
222
- const state = dt.state;
223
- const inlineEditState = state.inlineEdit;
211
+ const { state, template } = dt;
212
+ const { inlineEdit: inlineEditState } = state;
224
213
 
225
214
  const shouldSaveData =
215
+ isValidCell(state, rowKeyValue, colKeyValue) &&
226
216
  reason !== 'edit-canceled' &&
227
- !(inlineEditState.massEditEnabled && reason === 'lost-focus') &&
228
- isValidCell(dt.state, rowKeyValue, colKeyValue);
217
+ !(reason === 'lost-focus' && inlineEditState.massEditEnabled);
229
218
 
230
219
  if (shouldSaveData) {
231
- const panel = dt.template.querySelector(IEDIT_PANEL_SELECTOR);
232
- const editValue = panel.value;
220
+ const panel = template.querySelector(IEDIT_PANEL_SELECTOR);
233
221
  const isValidEditValue = panel.validity.valid;
234
- const updateAllSelectedRows = panel.isMassEditChecked;
235
222
  const currentValue = getCellValue(state, rowKeyValue, colKeyValue);
223
+ const { isMassEditChecked: updateAllSelectedRows, value: editValue } =
224
+ panel;
236
225
 
237
226
  if (
238
227
  isValidEditValue &&
239
228
  (editValue !== currentValue || updateAllSelectedRows)
240
229
  ) {
241
- const cellChange = {};
242
- cellChange[rowKeyValue] = {};
243
- cellChange[rowKeyValue][colKeyValue] = editValue;
244
-
230
+ const changes = {
231
+ [rowKeyValue]: {
232
+ [colKeyValue]: editValue,
233
+ },
234
+ };
245
235
  if (updateAllSelectedRows) {
246
- const selectedRowKeys = getSelectedRowsKeys(state);
247
- selectedRowKeys.forEach((rowKey) => {
248
- cellChange[rowKey] = {};
249
- cellChange[rowKey][colKeyValue] = editValue;
250
- });
236
+ const selectedRowsKeys = getSelectedRowsKeys(state);
237
+ for (let i = 0; i < selectedRowsKeys.length; i += 1) {
238
+ const otherRowKeyValue = selectedRowsKeys[i];
239
+ changes[otherRowKeyValue] = {
240
+ [colKeyValue]: editValue,
241
+ };
242
+ }
251
243
  }
252
244
 
253
- updateDirtyValues(state, cellChange);
254
-
255
- dispatchCellChangeEvent(dt, cellChange);
245
+ updateDirtyValues(state, changes);
246
+ dispatchCellChangeEvent(dt, changes);
256
247
 
257
248
  // TODO: do we need to update all rows in the dt or just the one that was modified?
258
- updateRowsAndCellIndexes.call(dt);
249
+ updateRowsAndCellIndexes(state, dt._privateTypes);
259
250
  }
260
251
  }
261
252
 
262
253
  if (reason !== 'lost-focus') {
263
- switch (reason) {
264
- case 'tab-pressed-next': {
265
- reactToTabForward(dt.template, state);
266
- break;
267
- }
268
- case 'tab-pressed-prev': {
269
- reactToTabBackward(dt.template, state);
270
- break;
271
- }
272
- default: {
273
- setFocusActiveCell(dt.template, state, 0);
274
- }
254
+ if (reason === 'tab-pressed-next') {
255
+ reactToTabForward(state, template);
256
+ } else if (reason === 'tab-pressed-prev') {
257
+ reactToTabBackward(state, template);
258
+ } else {
259
+ setFocusActiveCell(state, template, NAVIGATION_DIR.USE_CURRENT);
275
260
  }
276
261
  }
277
262
 
278
263
  unsetAriaSelectedOnAllSelectedRows(state);
279
264
  unsetAriaSelectedOnCell(state, rowKeyValue, colKeyValue);
280
265
 
266
+ // Tracked state change.
281
267
  inlineEditState.isPanelVisible = false;
282
268
  }
283
269
 
@@ -302,45 +288,43 @@ function openInlineEdit(dt, target) {
302
288
  startPanelPositioning(dt, target.parentElement);
303
289
 
304
290
  const { state, template, privateTypes: types } = dt;
305
- const inlineEdit = state.inlineEdit;
291
+ const { inlineEdit: inlineEditState } = state;
306
292
 
307
- if (inlineEdit.isPanelVisible) {
293
+ if (inlineEditState.isPanelVisible) {
308
294
  // A special case when we are trying to open a edit but we have one open. (click on another edit while editing)
309
295
  // in this case we will need to process the values before re-open the edit panel with the new values or we may lose the edition.
310
296
  processInlineEditFinish(
311
297
  dt,
312
298
  'lost-focus',
313
- inlineEdit.rowKeyValue,
314
- inlineEdit.colKeyValue
299
+ inlineEditState.rowKeyValue,
300
+ inlineEditState.colKeyValue
315
301
  );
316
302
  }
317
303
 
318
304
  const { rowKeyValue, colKeyValue } = target;
319
-
320
- inlineEdit.isPanelVisible = true;
321
- inlineEdit.rowKeyValue = rowKeyValue;
322
- inlineEdit.colKeyValue = colKeyValue;
323
-
324
- inlineEdit.editedValue = getCellValue(state, rowKeyValue, colKeyValue);
325
- inlineEdit.massEditSelectedRows = getCurrentSelectionLength(state);
326
- inlineEdit.massEditEnabled =
327
- isSelectedRow(state, rowKeyValue) &&
328
- inlineEdit.massEditSelectedRows > 1;
329
-
330
- // pass the column definition
331
305
  const colIndex = getStateColumnIndex(state, colKeyValue);
332
- inlineEdit.columnDef = getColumns(state)[colIndex];
333
- const typeAttributesFromColumnDef =
334
- inlineEdit.columnDef && inlineEdit.columnDef.typeAttributes;
335
- if (typeAttributesFromColumnDef) {
336
- // when the inline edit panel is opened resolve the typeAttributes if available
337
- // then assign the resolved values to inlineEdit.resolvedTypeAttributes
338
- inlineEdit.resolvedTypeAttributes = resolveNestedTypeAttributes(
306
+ const col = state.columns[colIndex];
307
+
308
+ inlineEditState.isPanelVisible = true;
309
+ inlineEditState.rowKeyValue = rowKeyValue;
310
+ inlineEditState.colKeyValue = colKeyValue;
311
+ inlineEditState.columnDef = col;
312
+ inlineEditState.editedValue = getCellValue(state, rowKeyValue, colKeyValue);
313
+ inlineEditState.massEditSelectedRows = getCurrentSelectionLength(state);
314
+ inlineEditState.massEditEnabled =
315
+ inlineEditState.massEditSelectedRows > 1 &&
316
+ isSelectedRow(state, rowKeyValue);
317
+
318
+ const { typeAttributes } = col || {};
319
+ if (typeAttributes) {
320
+ // When the inline edit panel is opened resolve the typeAttributes if available
321
+ // then assign the resolved values to inlineEdit.resolvedTypeAttributes.
322
+ inlineEditState.resolvedTypeAttributes = resolveNestedTypeAttributes(
339
323
  state,
340
324
  rowKeyValue,
341
325
  colKeyValue,
342
326
  types,
343
- typeAttributesFromColumnDef,
327
+ typeAttributes,
344
328
  colIndex
345
329
  );
346
330
  }
@@ -357,8 +341,8 @@ function openInlineEdit(dt, target) {
357
341
  processInlineEditFinish(
358
342
  dt,
359
343
  'edit-canceled',
360
- inlineEdit.rowKeyValue,
361
- inlineEdit.colKeyValue
344
+ inlineEditState.rowKeyValue,
345
+ inlineEditState.colKeyValue
362
346
  );
363
347
  } else {
364
348
  // if panel can be edited, focus
@@ -378,20 +362,19 @@ function openInlineEdit(dt, target) {
378
362
  * @param {Object} dt - The datatable instance. Must be a truthy and valid datatable reference.
379
363
  */
380
364
  export function openInlineEditOnActiveCell(dt) {
381
- const hasData = dt.state.data && dt.state.data.length > 0;
382
- if (hasData) {
383
- if (!isActiveCellEditable(dt.state)) {
365
+ const { state } = dt;
366
+ if (state.data && state.data.length > 0) {
367
+ if (!isActiveCellEditable(state)) {
384
368
  const firstEditableCell = getFirstEditableCell(dt);
385
369
  if (firstEditableCell) {
386
- updateActiveCell(
387
- dt.state,
388
- firstEditableCell.rowKeyValue,
389
- firstEditableCell.colKeyValue
390
- );
391
- setFocusAndOpenInlineEdit(dt, dt.state.activeCell);
370
+ state.activeCell = {
371
+ rowKeyValue: firstEditableCell.rowKeyValue,
372
+ colKeyValue: firstEditableCell.colKeyValue,
373
+ };
374
+ setFocusAndOpenInlineEdit(dt);
392
375
  }
393
376
  } else {
394
- setFocusAndOpenInlineEdit(dt, dt.state.activeCell);
377
+ setFocusAndOpenInlineEdit(dt);
395
378
  }
396
379
  }
397
380
  }
@@ -403,9 +386,10 @@ export function openInlineEditOnActiveCell(dt) {
403
386
  */
404
387
  // eslint-disable-next-line @lwc/lwc/no-async-await
405
388
  async function setFocusAndOpenInlineEdit(dt) {
406
- await setFocusActiveCell(dt.template, dt.state, 0);
407
- const cell = getActiveCellElement(dt.template, dt.state);
408
- openInlineEdit(dt, cell);
389
+ const { state, template } = dt;
390
+ await setFocusActiveCell(state, template, NAVIGATION_DIR.USE_CURRENT);
391
+ const cellElement = getActiveCellElement(template, state);
392
+ openInlineEdit(dt, cellElement);
409
393
  }
410
394
 
411
395
  /************************** PANEL POSITIONING **************************/
@@ -422,39 +406,40 @@ async function setFocusAndOpenInlineEdit(dt) {
422
406
  * - horizontal - Left -> align panel to left edge of cell
423
407
  * - vertical - Top -> align panel to top of the cell
424
408
  *
425
- * @param {Object} dt - datatable instance
426
- * @param {HTMLElement} target - cell on which inline edit should open
409
+ * @param {Object} dt - The datatable instance
410
+ * @param {HTMLElement} cellElement - The cell element on which inline edit should open
427
411
  */
428
- function startPanelPositioning(dt, target) {
412
+ function startPanelPositioning(dt, cellElement) {
429
413
  // eslint-disable-next-line @lwc/lwc/no-async-operation
430
414
  requestAnimationFrame(() => {
431
415
  // we need to discard previous binding otherwise the panel
432
416
  // will retain previous alignment
433
417
  stopPanelPositioning(dt);
434
418
 
435
- dt.privatePositionRelationship = startPositioning(dt, {
436
- target,
437
- element: () =>
438
- dt.template
439
- .querySelector(IEDIT_PANEL_SELECTOR)
440
- .getPositionedElement(),
419
+ dt._positionRelationship = startPositioning(dt, {
420
+ target: cellElement,
421
+ element() {
422
+ const panel = dt.template.querySelector(IEDIT_PANEL_SELECTOR);
423
+ return panel.getPositionedElement();
424
+ },
425
+ autoFlip: true,
441
426
  align: {
442
- horizontal: Direction.Left,
443
- vertical: Direction.Top,
427
+ horizontal: DIRECTION.Left,
428
+ vertical: DIRECTION.Top,
444
429
  },
445
430
  targetAlign: {
446
- horizontal: Direction.Left,
447
- vertical: Direction.Top,
431
+ horizontal: DIRECTION.Left,
432
+ vertical: DIRECTION.Top,
448
433
  },
449
- autoFlip: true,
450
434
  });
451
435
  });
452
436
  }
453
437
 
454
438
  function stopPanelPositioning(dt) {
455
- if (dt.privatePositionRelationship) {
456
- stopPositioning(dt.privatePositionRelationship);
457
- dt.privatePositionRelationship = null;
439
+ const { _positionRelationship } = dt;
440
+ if (_positionRelationship) {
441
+ stopPositioning(_positionRelationship);
442
+ dt._positionRelationship = null;
458
443
  }
459
444
  }
460
445
 
@@ -462,13 +447,14 @@ function stopPanelPositioning(dt) {
462
447
  * Repositions the inline edit panel. this does not realign the element,
463
448
  * so it doesn't fix alignment when size of panel changes
464
449
  *
465
- * @param {Object} dt - datatable instance
450
+ * @param {Object} dt - The datatable instance
466
451
  */
467
452
  function repositionPanel(dt) {
468
453
  // eslint-disable-next-line @lwc/lwc/no-async-operation
469
454
  requestAnimationFrame(() => {
470
- if (dt.privatePositionRelationship) {
471
- dt.privatePositionRelationship.reposition();
455
+ const { _positionRelationship } = dt;
456
+ if (_positionRelationship) {
457
+ _positionRelationship.reposition();
472
458
  }
473
459
  });
474
460
  }
@@ -476,7 +462,7 @@ function repositionPanel(dt) {
476
462
  /************************** DIRTY/UNSAVED VALUES **************************/
477
463
 
478
464
  /**
479
- * @param {Object} state - Datatable state object.
465
+ * @param {Object} state - The datatable state
480
466
  * @returns {Array} - An array of objects, each object describing the dirty values in the form { colName : dirtyValue }.
481
467
  * A special key is the { [keyField]: value } pair used to identify the row containing this changed values.
482
468
  * The returned array will be in the form - [{colName : dirtyValue, ... , [keyField]: value }, {...}, {...}]
@@ -488,84 +474,59 @@ export function getDirtyValues(state) {
488
474
  /**
489
475
  * Sets the dirty values in the datatable.
490
476
  *
491
- * @param {Object} state Datatable state object.
492
- * @param {Array} value An array of objects, each object describing the dirty values in the form { colName : dirtyValue }.
477
+ * @param {Object} state The datatable state
478
+ * @param {Array} values An untracked array of objects, each object describing the dirty values in the form { colName : dirtyValue }.
493
479
  * A special key is the { [keyField]: value } pair used to identify the row containing this changed values.
494
480
  */
495
- export function setDirtyValues(state, value) {
496
- const keyField = getKeyField(state);
497
- const dirtyValues = Array.isArray(value) ? value : [];
498
-
499
- state.inlineEdit.dirtyValues = dirtyValues.reduce((result, rowValues) => {
500
- const changes = getCellChangesFromCustomer(state, rowValues);
501
- delete changes[keyField];
502
-
503
- result[rowValues[keyField]] = changes;
504
-
505
- return result;
506
- }, {});
507
- }
508
-
509
- /**
510
- * Updates the dirty values specified in rowColKeyValues
511
- *
512
- * @param {Object} state - state of the datatable
513
- * @param {Object} rowColKeyValues - An object in the form of { rowKeyValue: { colKeyValue1: value, ..., colKeyValueN: value } ... }
514
- */
515
- function updateDirtyValues(state, rowColKeyValues) {
516
- const dirtyValues = state.inlineEdit.dirtyValues;
517
-
518
- Object.keys(rowColKeyValues).forEach((rowKey) => {
519
- if (!Object.prototype.hasOwnProperty.call(dirtyValues, rowKey)) {
520
- dirtyValues[rowKey] = {};
481
+ export function setDirtyValues(state, values) {
482
+ const { columns, keyField } = state;
483
+ const dirtyValues = Array.isArray(values) ? values : [];
484
+ const result = {};
485
+ for (let dirtyIndex = 0; dirtyIndex < dirtyValues.length; dirtyIndex += 1) {
486
+ const rowValues = dirtyValues[dirtyIndex];
487
+ const colKeys = Object.keys(rowValues);
488
+ const colChanges = {};
489
+ for (
490
+ let colKeysIndex = 0, { length: colKeysLength } = colKeys;
491
+ colKeysIndex < colKeysLength;
492
+ colKeysIndex += 1
493
+ ) {
494
+ const externalColKeyValue = colKeys[colKeysIndex];
495
+ for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
496
+ const col = columns[colIndex];
497
+ if (
498
+ col.columnKey === externalColKeyValue ||
499
+ (!col.columnKey && col.fieldName === externalColKeyValue)
500
+ ) {
501
+ colChanges[col.colKeyValue] =
502
+ rowValues[externalColKeyValue];
503
+ break;
504
+ }
505
+ }
521
506
  }
522
-
523
- Object.assign(dirtyValues[rowKey], rowColKeyValues[rowKey]);
524
- });
507
+ delete colChanges[keyField];
508
+ result[rowValues[keyField]] = colChanges;
509
+ }
510
+ state.inlineEdit.dirtyValues = result;
525
511
  }
526
512
 
527
513
  /**
528
- * Constructs and returns an object that contains the cell changes which can
529
- * be referenced by the column key value. It follows this format:
530
- * { <colKeyValue: "<editedValue>"> }; Ex. { "name-text-2": "My changes" }
514
+ * Updates the dirty values specified in the `changes` object.
531
515
  *
532
- * @param {Object} state - datatable's state object
533
- * @param {Object} changes - internal representation of changes in a row
534
- * @returns {Object} - changes in a column that can be referenced by the column key
516
+ * @param {Object} state - The datatable state
517
+ * @param {Object} changes - An object in the form of { rowKeyValue: { colKeyValue1: value, ..., colKeyValueN: value } ... }
535
518
  */
536
- function getCellChangesFromCustomer(state, changes) {
537
- return Object.keys(changes).reduce((result, externalColumnKey) => {
538
- const columns = getColumns(state);
539
- const columnIndex = getColumnIndexByColumnKey(state, externalColumnKey);
540
-
541
- if (columnIndex >= 0) {
542
- const colKey = columns[columnIndex].colKeyValue;
543
- result[colKey] = changes[externalColumnKey];
519
+ function updateDirtyValues(state, changes) {
520
+ const dirtyValues = state.inlineEdit.dirtyValues;
521
+ const rowKeys = Object.keys(changes);
522
+ for (let rowKeyIndex = 0; rowKeyIndex < rowKeys.length; rowKeyIndex += 1) {
523
+ const rowKeyValue = rowKeys[rowKeyIndex];
524
+ if (!Object.prototype.hasOwnProperty.call(dirtyValues, rowKeyValue)) {
525
+ dirtyValues[rowKeyValue] = {};
544
526
  }
545
527
 
546
- return result;
547
- }, {});
548
- }
549
-
550
- /**
551
- * Retrieves the changes in cells in a particular column
552
- * Returns an object where each item follows this format:
553
- * { <columnName>: "<changes>"} -> Ex. { name: "My changes" }
554
- *
555
- * @param {Object} state - Datatable state
556
- * @param {Object} changes - The internal representation of changes in a row
557
- * @returns {Object} - the list of customer changes in a column
558
- */
559
- function getCellChangesByColumn(state, changes) {
560
- return Object.keys(changes).reduce((result, colKey) => {
561
- const columns = getColumns(state);
562
- const columnIndex = getStateColumnIndex(state, colKey);
563
- const columnDef = columns[columnIndex];
564
-
565
- result[columnDef.columnKey || columnDef.fieldName] = changes[colKey];
566
-
567
- return result;
568
- }, {});
528
+ Object.assign(dirtyValues[rowKeyValue], changes[rowKeyValue]);
529
+ }
569
530
  }
570
531
 
571
532
  /**
@@ -577,26 +538,47 @@ function getCellChangesByColumn(state, changes) {
577
538
  * Ex. [{ name: "My changes", id: "2" }]; where column name is 'name' and 'id' is the keyField
578
539
  * The keyField can be used to identify the row.
579
540
  *
580
- * @param {Object} state - datatable state object
581
- * @param {Object} changes - list of cell changes to be resolved
541
+ * @param {Object} state - The datatable state
542
+ * @param {Object} rowChanges - list of cell changes to be resolved
582
543
  * @returns {Array} - array containing changes and identifiers of column and row where the changes
583
544
  * should be applied
584
545
  */
585
- function getResolvedCellChanges(state, changes) {
586
- const keyField = getKeyField(state);
587
-
588
- return Object.keys(changes).reduce((result, rowKey) => {
589
- // Get the changes made by column
590
- const cellChanges = getCellChangesByColumn(state, changes[rowKey]);
591
-
592
- if (Object.keys(cellChanges).length > 0) {
593
- // Add identifier for which row has change
594
- cellChanges[keyField] = rowKey;
546
+ function getResolvedCellChanges(state, rowChanges) {
547
+ const { columns, keyField } = state;
548
+ const result = [];
549
+ const changeRowKeys = Object.keys(rowChanges);
550
+ for (
551
+ let changeRowIndex = 0, { length: changeRowCount } = changeRowKeys;
552
+ changeRowIndex < changeRowCount;
553
+ changeRowIndex += 1
554
+ ) {
555
+ const rowKeyValue = changeRowKeys[changeRowIndex];
556
+ const colChanges = rowChanges[rowKeyValue];
557
+ const changeColKeys = Object.keys(colChanges);
558
+ const { length: changeColCount } = changeColKeys;
559
+ if (changeColCount) {
560
+ const cellChanges = {
561
+ // Add identifier for which row has change
562
+ [keyField]: rowKeyValue,
563
+ };
564
+ // Get the changes made by column
565
+ for (
566
+ let changeColIndex = 0;
567
+ changeColIndex < changeColCount;
568
+ changeColIndex += 1
569
+ ) {
570
+ const colKeyValue = changeColKeys[changeColIndex];
571
+ const colIndex = getStateColumnIndex(state, colKeyValue);
572
+ if (colIndex !== -1) {
573
+ const col = columns[colIndex];
574
+ cellChanges[col.columnKey || col.fieldName] =
575
+ colChanges[colKeyValue];
576
+ }
577
+ }
595
578
  result.push(cellChanges);
596
579
  }
597
-
598
- return result;
599
- }, []);
580
+ }
581
+ return result;
600
582
  }
601
583
 
602
584
  /************************** TYPE ATTRIBUTES RESOLUTION **************************/
@@ -604,53 +586,49 @@ function getResolvedCellChanges(state, changes) {
604
586
  /**
605
587
  * Returns the resolved typeAttributes
606
588
  *
607
- * @param {Object} state - state of the datatable
608
- * @param {String} rowKeyValue - row key
609
- * @param {String} colKeyValue - column key
610
- * @param {object} types - types
611
- * @param {object} typeAttributesFromColumnDef - values of typeAttributes from column definition
612
- * @param {number} stateColIndex - state column index
589
+ * @param {Object} state - The datatable state
590
+ * @param {String} rowKeyValue - The row key
591
+ * @param {String} colKeyValue - The column key
592
+ * @param {Object} types - The type handling factory
593
+ * @param {Object} typeAttributes - values of typeAttributes from column definition
594
+ * @param {Number} colIndex - The column index
613
595
  *
614
- * @returns {Object} the resolved typeAttributes.
596
+ * @returns {Object} The resolved typeAttributes.
615
597
  */
616
598
  export function resolveNestedTypeAttributes(
617
599
  state,
618
600
  rowKeyValue,
619
601
  colKeyValue,
620
602
  types,
621
- typeAttributesFromColumnDef,
622
- stateColIndex
603
+ typeAttributes,
604
+ colIndex
623
605
  ) {
624
- const rowData = getUserRowByCellKeys(state, rowKeyValue, colKeyValue);
625
- const column = state.columns[stateColIndex];
626
- const validTypeAttributes = types.getType(column.type).typeAttributes;
627
- const resolvedTypeAttributes = {};
628
-
629
- // Check if typeAttributesValues and typeAttributes are available
630
- if (isObjectLike(typeAttributesFromColumnDef) && validTypeAttributes) {
606
+ const col = state.columns[colIndex];
607
+ const typeDesc = typeAttributes && types.getType(col.type);
608
+ const attributeNames = typeDesc && typeDesc.typeAttributes;
609
+ // Check if attrValue and typeAttributes are available.
610
+ if (attributeNames) {
611
+ const resolvedTypeAttributes = {};
612
+ const { length: attributeNamesLength } = attributeNames;
613
+ const _rowData = getUserRowByCellKeys(state, rowKeyValue, colKeyValue);
631
614
  // We only want to resolve typeAttributes based on the custom types configuration
632
- // If the attribute is not in that configuration, the value of typeAttributesValues
615
+ // If the attribute is not in that configuration, the value of attrValue
633
616
  // for that will be undefined. This behavior is consistent with view cell.
634
-
635
- Object.keys(validTypeAttributes).forEach((key) => {
636
- const typeAttributeName = validTypeAttributes[key];
637
- const typeAttributesValue =
638
- typeAttributesFromColumnDef[typeAttributeName];
639
- if (typeAttributesValue) {
640
- resolvedTypeAttributes[typeAttributeName] =
641
- resolveNestedTypeAttributesHelper(
642
- rowData,
643
- typeAttributesValue
644
- );
617
+ for (let i = 0; i < attributeNamesLength; i += 1) {
618
+ const attrName = attributeNames[i];
619
+ const attrValue = typeAttributes[attrName];
620
+ if (attrValue) {
621
+ resolvedTypeAttributes[attrName] =
622
+ resolveNestedTypeAttributesHelper(_rowData, attrValue);
645
623
  }
646
- });
624
+ }
647
625
  return resolvedTypeAttributes;
648
626
  }
649
- return typeAttributesFromColumnDef;
627
+ return typeAttributes;
650
628
  }
651
629
 
652
630
  /**
653
- * Helper function to recursively traverse and resolve the nested typeAttributesValues object.
631
+ * Helper function to recursively traverse and resolve the nested attrValue object.
654
632
  * For example, resolve {
655
633
  * editTypeAttributes: {
656
634
  * value: {
@@ -665,48 +643,44 @@ export function resolveNestedTypeAttributes(
665
643
  * }
666
644
  * }
667
645
  */
668
- function resolveNestedTypeAttributesHelper(rowData, typeAttributesValue) {
646
+ function resolveNestedTypeAttributesHelper(rowData, attrValue) {
669
647
  let resolvedTypeAttributes = {};
670
- if (typeAttributesValue !== undefined) {
671
- if (isObjectLike(typeAttributesValue)) {
672
- Object.keys(typeAttributesValue).forEach((key) => {
673
- const value = typeAttributesValue[key];
674
- if (value !== undefined) {
675
- // since resolveNestedTypeAttributes will be creating the top level attribute
676
- // and we resolve values while creating the new object, the typeAttributesValue passed in
677
- // could be something like {fieldName: 'someField'}.
678
- // For example, if the typeAttributes is { targetName: {fieldName: 'name'}},
679
- // {fieldName: 'name'} will be the typeAttributesValue passed in to the function,
680
- // so we need to check if key is 'fieldName' or not and resolve it immediately.
681
- if (key === 'fieldName') {
682
- resolvedTypeAttributes = rowData[value];
683
- } else if (isObjectLike(value)) {
684
- // This is the case when typeAttributesValue is something like {label: {fieldName: 'name'}}.
685
- // It's an object but the value maps a field name
686
- if (value.fieldName) {
687
- resolvedTypeAttributes[key] =
688
- rowData[value.fieldName];
689
- } else {
690
- // Nested object case, need to recursively resolve it.
691
- // For example, { targetName: {value: {fieldName: 'name'}}}}.
692
- resolvedTypeAttributes[key] =
693
- resolveNestedTypeAttributesHelper(
694
- rowData,
695
- value
696
- );
697
- }
698
- } else {
699
- // Primitive value
700
- resolvedTypeAttributes[key] = value;
701
- }
648
+ if (!(typeof attrValue === 'object' && attrValue !== null)) {
649
+ // Primitive value.
650
+ // For example, if the typeAttributes is { count: 5},
651
+ // 5 will be the attrValue passed in to the function.
652
+ // nothing needs to be resolved, just return it.
653
+ return attrValue === undefined ? resolvedTypeAttributes : attrValue;
654
+ }
655
+ const typeAttributesNames = Object.keys(attrValue);
656
+ for (let i = 0, { length } = typeAttributesNames; i < length; i += 1) {
657
+ const name = typeAttributesNames[i];
658
+ const value = attrValue[name];
659
+ if (value !== undefined) {
660
+ // since resolveNestedTypeAttributes will be creating the top level attribute
661
+ // and we resolve values while creating the new object, the attrValue passed in
662
+ // could be something like {fieldName: 'someField'}.
663
+ // For example, if the typeAttributes is { targetName: {fieldName: 'name'}},
664
+ // {fieldName: 'name'} will be the attrValue passed in to the function,
665
+ // so we need to check if key is 'fieldName' or not and resolve it immediately.
666
+ if (name === 'fieldName') {
667
+ resolvedTypeAttributes = rowData[value];
668
+ } else if (typeof value === 'object' && value !== null) {
669
+ // This is the case when attrValue is something like {label: {fieldName: 'name'}}.
670
+ // It's an object but the value maps a field name
671
+ const { fieldName } = value;
672
+ if (fieldName) {
673
+ resolvedTypeAttributes[name] = rowData[fieldName];
674
+ } else {
675
+ // Nested object case, need to recursively resolve it.
676
+ // For example, { targetName: {value: {fieldName: 'name'}}}}.
677
+ resolvedTypeAttributes[name] =
678
+ resolveNestedTypeAttributesHelper(rowData, value);
702
679
  }
703
- });
704
- } else {
705
- // Primitive value.
706
- // For example, if the typeAttributes is { count: 5},
707
- // 5 will be the typeAttributesValue passed in to the function.
708
- // nothing needs to be resolved, just return it.
709
- return typeAttributesValue;
680
+ } else {
681
+ // Primitive value
682
+ resolvedTypeAttributes[name] = value;
683
+ }
710
684
  }
711
685
  }
712
686
 
@@ -722,19 +696,28 @@ function resolveNestedTypeAttributesHelper(rowData, typeAttributesValue) {
722
696
  * @param {Object} dt - The datatable instance. Must be a truthy and valid datatable reference.
723
697
  */
724
698
  function getFirstEditableCell(dt) {
725
- const columns = getColumns(dt.state);
726
- const editableColumns = getEditableColumns(columns);
727
-
728
- if (editableColumns.length > 0) {
729
- const rows = dt.state.rows;
730
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
731
- for (let i = 0; i < editableColumns.length; i++) {
732
- // Loop through the editable columns in order and examine the corresponding cells
733
- // in the current row for editability, returning the first such cell that is editable
699
+ const { state } = dt;
700
+ const { columns } = state;
701
+ const editableColumns = [];
702
+ for (let i = 0, { length } = columns; i < length; i += 1) {
703
+ const col = columns[i];
704
+ if (col.editable) {
705
+ editableColumns.push(col);
706
+ }
707
+ }
708
+ const { length: editableColumnsLength } = editableColumns;
709
+ if (editableColumnsLength > 0) {
710
+ const { rows } = state;
711
+ for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
712
+ const { key: rowKeyValue } = rows[rowIndex];
713
+ for (let i = 0; i < editableColumnsLength; i += 1) {
714
+ // Loop through the editable columns in order and examine the
715
+ // corresponding cells in the current row for editability,
716
+ // returning the first such cell that is editable.
734
717
  const editableColumn = editableColumns[i];
735
718
  if (isCellEditable(rows[rowIndex], editableColumn)) {
736
719
  return {
737
- rowKeyValue: rows[rowIndex].key,
720
+ rowKeyValue,
738
721
  colKeyValue: editableColumn.colKeyValue,
739
722
  };
740
723
  }
@@ -769,11 +752,14 @@ function getCellValue(state, rowKeyValue, colKeyValue) {
769
752
  */
770
753
  function setAriaSelectedOnAllSelectedRows(state) {
771
754
  const { colKeyValue } = state.inlineEdit;
772
- const selectedRowKeys = getSelectedRowsKeys(state);
773
-
774
- selectedRowKeys.forEach((rowKeyValue) => {
775
- setAriaSelectedOnCell(state, rowKeyValue, colKeyValue);
776
- });
755
+ const { selectedRowsKeys } = state;
756
+ const keys = Object.keys(selectedRowsKeys);
757
+ for (let i = 0, { length } = keys; i < length; i += 1) {
758
+ const rowKeyValue = keys[i];
759
+ if (selectedRowsKeys[rowKeyValue]) {
760
+ setAriaSelectedOnCell(state, rowKeyValue, colKeyValue);
761
+ }
762
+ }
777
763
  }
778
764
 
779
765
  /**
@@ -784,9 +770,12 @@ function setAriaSelectedOnAllSelectedRows(state) {
784
770
  */
785
771
  function unsetAriaSelectedOnAllSelectedRows(state) {
786
772
  const { colKeyValue } = state.inlineEdit;
787
- const selectedRowKeys = getSelectedRowsKeys(state);
788
-
789
- selectedRowKeys.forEach((rowKeyValue) => {
790
- unsetAriaSelectedOnCell(state, rowKeyValue, colKeyValue);
791
- });
773
+ const { selectedRowsKeys } = state;
774
+ const keys = Object.keys(selectedRowsKeys);
775
+ for (let i = 0, { length } = keys; i < length; i += 1) {
776
+ const rowKeyValue = keys[i];
777
+ if (selectedRowsKeys[rowKeyValue]) {
778
+ unsetAriaSelectedOnCell(state, rowKeyValue, colKeyValue);
779
+ }
780
+ }
792
781
  }