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,106 +1,36 @@
1
1
  import { assert } from 'lightning/utilsPrivate';
2
- import { classSet, isObjectLike, styleToString } from './utils';
3
- import { isTreeType, getAttributesNames } from './types';
2
+ import { classSet, isObjectLike } from './utils';
3
+ import { getAttributesNames } from './types';
4
4
  import {
5
- isSelectedRow,
6
- isDisabledRow,
7
- getRowSelectionInputType,
5
+ getCurrentSelectionLength,
6
+ SELECTABLE_HEADER_TYPE,
8
7
  } from './rowSelectionShared';
9
- import { getTreeStateIndicatorFieldNames, getStateTreeColumn } from './tree';
10
8
  import {
11
- getColumns,
12
9
  getTypeAttributesValues,
13
10
  getSubTypeAttributesValues,
14
11
  getCellAttributesValues,
15
- isCustomerColumn,
16
12
  generateColKeyValue,
17
13
  } from './columns';
18
- import { isRowNumberColumn, getRowNumberErrorColumnDef } from './rowNumber';
19
- import { getRowError } from './errors';
20
- import { getDirtyValueFromCell } from './inlineEditShared';
14
+ import { getRowNumberError } from './rowNumber';
21
15
 
22
- export function getData(state) {
23
- return state.data;
24
- }
25
-
26
- export function setData(state, data) {
27
- if (Array.isArray(data)) {
28
- state.data = data;
29
- } else {
30
- state.data = [];
31
- }
32
- }
33
-
34
- export function getRows(state) {
35
- return state.rows;
36
- }
37
-
38
- export function getKeyField(state) {
39
- return state.keyField;
40
- }
16
+ const CELL_EDIT_CLASS = 'slds-cell-edit';
17
+ const HAS_ERROR_CLASS = 'slds-has-error';
18
+ const IS_EDITED_CLASS = 'slds-is-edited';
19
+ const ROLE_BASED_CELL_CLASS = 'cell';
20
+ const TREE__ITEM_CLASS = 'slds-tree__item';
41
21
 
42
22
  export function setKeyField(state, value) {
43
- assert(
44
- typeof value === 'string',
45
- `The "keyField" value expected in lightning:datatable must be type String.`
46
- );
47
23
  if (typeof value === 'string') {
48
24
  state.keyField = value;
49
25
  } else {
26
+ assert(
27
+ false,
28
+ `The "keyField" value expected in lightning:datatable must be type String.`
29
+ );
50
30
  state.keyField = undefined;
51
31
  }
52
32
  }
53
33
 
54
- export function hasValidKeyField(state) {
55
- const keyField = getKeyField(state);
56
- return typeof keyField === 'string';
57
- }
58
-
59
- /**
60
- * Resolves the CSS classes for a row based on the row.isSelected state
61
- *
62
- * @param {object} row - a row object in state.rows collection
63
- * @returns {string} the classSet string
64
- */
65
- export function resolveRowClassNames(row) {
66
- const classes = classSet('slds-hint-parent');
67
- if (row.isSelected) {
68
- classes.add('slds-is-selected');
69
- }
70
-
71
- return classes.toString();
72
- }
73
-
74
- /**
75
- *
76
- * @param {object} state - data table state
77
- * @param {string} rowKeyValue - computed id for the row
78
- * @param {string} colKeyValue - computed id for the column
79
- * @returns {object} The user row that its related to the action.
80
- */
81
- export function getUserRowByCellKeys(state, rowKeyValue, colKeyValue) {
82
- const rowIndex = state.indexes[rowKeyValue][colKeyValue][0];
83
- return getData(state)[rowIndex];
84
- }
85
-
86
- /**
87
- * It creates a row key generator based on the keyField passed in by the consumer.
88
- * If the keyField passed in through the generator does not point to a value in the row object,
89
- * it falls back to a generated key using indexes. Ex. row-0/row-1
90
- *
91
- * @param {String} keyField - keyField provided by the consumer
92
- * @returns {Function} - function with the unique row key generator
93
- */
94
- export function uniqueRowKeyGenerator(keyField) {
95
- let index = 0;
96
- return function (row) {
97
- if (row[keyField]) {
98
- return row[keyField];
99
- }
100
- return `row-${index++}`;
101
- };
102
- }
103
-
104
34
  /**
105
35
  * It compute the state.rows collection based on the current normalized (data, columns)
106
36
  * and generate cells indexes map(state.indexes)
@@ -110,107 +40,234 @@ export function uniqueRowKeyGenerator(keyField) {
110
40
  * attaching the 'cell' class, calling this from connectedCallback of datatable would
111
41
  * eliminate the need for updateCellClassForRoleBasedMode.
112
42
  *
113
- * @param {object} state - the current datatable state
43
+ * @param {Object} state - The datatable state
44
+ * @param {Object} types - The type handling factory
114
45
  */
115
- export function updateRowsAndCellIndexes() {
116
- const { state, privateTypes: types } = this;
117
- const { keyField, renderModeRoleBased, virtualize, rowHeight } = state;
118
- const data = getData(state);
119
- const columns = getColumns(state);
120
- const computeUniqueRowKey = uniqueRowKeyGenerator(keyField);
121
- const scopeCol = columns.find(
122
- (colData) => types.isValidType(colData.type) && colData.isScopeCol
123
- );
46
+ export function updateRowsAndCellIndexes(state, types) {
47
+ const {
48
+ columns,
49
+ data,
50
+ keyField,
51
+ maxRowSelection,
52
+ renderModeRoleBased,
53
+ virtualize,
54
+ rowHeight,
55
+ } = state;
56
+ const { length: rowCount } = data;
57
+ const { dirtyValues } = state.inlineEdit;
58
+ const { length: colCount } = columns;
59
+ const currentSelectionLength =
60
+ maxRowSelection === 1 ? 1 : getCurrentSelectionLength(state);
61
+ const inputType = maxRowSelection === 1 ? 'radio' : 'checkbox';
62
+
63
+ let scopeCol;
64
+ let treeColTypeAttrs;
65
+ for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
66
+ const col = columns[colIndex];
67
+ const { type: columnType } = col;
68
+ if (!scopeCol && col.isScopeCol && types.isValidType(columnType)) {
69
+ scopeCol = col;
70
+ }
71
+ if (columnType === 'tree' && treeColTypeAttrs === undefined) {
72
+ treeColTypeAttrs = getTypeAttributesValues(col);
73
+ }
74
+ }
75
+
124
76
  // initializing indexes
125
77
  state.indexes = {};
126
78
 
127
- state.rows = data.reduce((prev, rowData, rowIndex) => {
79
+ const { rows: errorsRows } = state.errors;
80
+ const rows = Array(rowCount);
81
+ // Tracked state changes.
82
+ state.rows = rows;
83
+
84
+ for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
85
+ const rowData = data[rowIndex];
86
+ const rowDataKeyField = rowData[keyField];
87
+ const rowKeyValue = rowDataKeyField
88
+ ? `${rowDataKeyField}`
89
+ : `row-${rowIndex}`;
90
+ const dirtyRowData = dirtyValues[rowKeyValue];
91
+ const rowErrors = errorsRows && errorsRows[rowKeyValue];
92
+ const cellErrors = rowErrors && rowErrors.cells;
93
+ const errorFieldNames = rowErrors && rowErrors.fieldNames;
94
+
95
+ state.indexes[rowKeyValue] = { rowIndex };
96
+
97
+ const isRowSelected = !!state.selectedRowsKeys[rowKeyValue];
98
+ const rowNumber = rowIndex + 1;
99
+ const cells = Array(colCount);
100
+
128
101
  const row = {
129
- key: computeUniqueRowKey(rowData), // attaching unique key to the row
130
- cells: [],
102
+ key: rowKeyValue,
103
+ cells,
104
+ rowIndex,
105
+ rowNumber, // for UTAM since methods are base-1
106
+ ariaRowIndex: rowIndex + 2, // aria attrs are base-1 and also count header as a row
107
+ inputType,
108
+ isSelected: isRowSelected,
109
+ ariaSelected: isRowSelected ? 'true' : false,
110
+ isDisabled:
111
+ !isRowSelected &&
112
+ maxRowSelection !== 1 &&
113
+ currentSelectionLength === maxRowSelection,
114
+ classnames: `slds-hint-parent${
115
+ isRowSelected ? ' slds-is-selected' : ''
116
+ }`,
117
+ tabIndex: -1,
118
+ style: virtualize
119
+ ? `position:absolute;top:${rowIndex * rowHeight}px;`
120
+ : '',
121
+ level: undefined,
122
+ posInSet: undefined,
123
+ setSize: undefined,
124
+ isExpanded: undefined,
125
+ hasChildren: undefined,
131
126
  };
132
- const rowErrors = getRowError(state, row.key);
133
-
134
- state.indexes[row.key] = { rowIndex };
135
127
 
136
- row.rowIndex = rowIndex;
137
- row.rowNumber = rowIndex + 1; // for UTAM since methods are base-1
138
- row.ariaRowIndex = rowIndex + 2; // aria attrs are base-1 and also count header as a row
139
- row.inputType = getRowSelectionInputType(state);
140
- row.isSelected = isSelectedRow(state, row.key);
141
- row.ariaSelected = row.isSelected ? 'true' : false;
142
- row.isDisabled = isDisabledRow(state, row.key);
143
- row.classnames = resolveRowClassNames(row);
144
- Object.assign(row, getRowStateForTree(rowData, state));
145
- row.tabIndex = -1;
146
- if (virtualize) {
147
- row.style = styleToString({
148
- position: 'absolute',
149
- top: `${rowIndex * rowHeight}px`,
150
- });
128
+ // Add tree specific row properties.
129
+ if (treeColTypeAttrs) {
130
+ const hasChildren = !!resolveAttributeValue(
131
+ treeColTypeAttrs.hasChildren,
132
+ rowData
133
+ );
134
+ row.hasChildren = hasChildren;
135
+ row.isExpanded = hasChildren
136
+ ? `${!!resolveAttributeValue(
137
+ treeColTypeAttrs.isExpanded,
138
+ rowData
139
+ )}`
140
+ : undefined;
141
+ row.level =
142
+ resolveAttributeValue(treeColTypeAttrs.level, rowData) || 1;
143
+ row.posInSet =
144
+ resolveAttributeValue(treeColTypeAttrs.posInSet, rowData) || 1;
145
+ row.setSize =
146
+ resolveAttributeValue(treeColTypeAttrs.setSize, rowData) || 1;
151
147
  }
152
148
 
153
- columns.reduce((currentRow, colData, colIndex) => {
154
- const { fieldName } = colData;
155
- const colKeyValue = generateColKeyValue(colData, colIndex);
156
- const dirtyValue = getDirtyValueFromCell(
157
- state,
158
- row.key,
159
- colKeyValue
160
- );
161
- const cellHasErrors = hasCellErrors(
162
- rowErrors,
163
- colData.fieldName,
164
- colData.columnKey
165
- );
166
- const computedCellValue =
167
- dirtyValue !== undefined ? dirtyValue : rowData[fieldName];
149
+ rows[rowIndex] = row;
150
+
151
+ // Add cell indexes.
152
+ for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
153
+ const col = columns[colIndex];
154
+ const {
155
+ columnKey,
156
+ fieldName,
157
+ isScopeCol,
158
+ label: dataLabel,
159
+ type: columnType,
160
+ typeAttributes,
161
+ } = col;
162
+ const colKeyValue = generateColKeyValue(col, colIndex);
163
+ const columnSubType = typeAttributes
164
+ ? typeAttributes.subType
165
+ : undefined;
166
+ const dirtyValue = dirtyRowData && dirtyRowData[colKeyValue];
167
+ const hasError = columnKey
168
+ ? !!(cellErrors && cellErrors[columnKey])
169
+ : !!(errorFieldNames && errorFieldNames.includes(fieldName));
170
+ const hasTreeData = columnType === 'tree';
171
+ // value based on the fieldName
172
+ const value =
173
+ dirtyValue === undefined ? rowData[fieldName] : dirtyValue;
174
+ const displayReadOnlyIcon = !!col.displayReadOnlyIcon;
175
+ const editable = isCellEditable(rowData, col);
176
+ const isValidType = types.isValidType(columnType);
177
+ const isCheckbox = columnType === SELECTABLE_HEADER_TYPE;
178
+ const isDataType = isValidType && !isScopeCol;
179
+ const isDataTypeScope = isValidType && isScopeCol;
180
+
168
181
  // cell object creation
169
182
  const cell = {
170
- columnType: colData.type,
171
- columnSubType: colData.typeAttributes
172
- ? colData.typeAttributes.subType
173
- : undefined,
174
- dataLabel: colData.label,
175
- value: computedCellValue, // value based on the fieldName
176
- displayValue: rowData.displayValue ? rowData.displayValue : '',
177
- rowKeyValue: row.key, // unique row key value
183
+ ariaReadOnly: !editable,
184
+ class: '',
178
185
  colKeyValue, // unique column key value
179
- tabIndex: -1, // tabindex
180
- isCheckbox: colData.type === 'SELECTABLE_CHECKBOX',
181
- class: computeCellClassNames(
182
- rowData,
183
- colData,
184
- cellHasErrors,
185
- dirtyValue,
186
- renderModeRoleBased
187
- ),
188
- hasError: cellHasErrors,
189
- isDataType:
190
- types.isValidType(colData.type) && !colData.isScopeCol,
191
- isDataTypeScope:
192
- types.isValidType(colData.type) && colData.isScopeCol,
186
+ columnSubType,
187
+ columnType,
188
+ dataLabel,
189
+ describedBy: dirtyValue ? 'unsaved-cell-notification' : null,
190
+ displayReadOnlyIcon,
191
+ displayValue: rowData.displayValue || '',
192
+ editable,
193
+ hasError,
194
+ isCheckbox,
195
+ isDataType,
196
+ isDataTypeScope,
197
+ rowKeyValue: row.key, // unique row key value
198
+ style: computeCellStyles(types, col, renderModeRoleBased),
199
+ tabIndex: -1,
200
+ value,
193
201
  wrapText: state.wrapText[colKeyValue], // wrapText state
194
202
  wrapTextMaxLines: state.wrapText[colKeyValue]
195
203
  ? state.wrapTextMaxLines
196
204
  : undefined,
197
- style: computeCellStyles(types, colData, renderModeRoleBased),
198
205
  };
199
- if (isCustomerColumn(colData)) {
200
- assignCustomerColumnAttributes(
201
- cell,
202
- row,
203
- rowData,
204
- colData,
205
- types
206
- );
207
- } else if (isRowNumberColumn(colData)) {
208
- assignRowNumberColumnAttributes(
209
- cell,
210
- rowData,
211
- types,
206
+
207
+ cell.class = computeCellClassNames(
208
+ cell,
209
+ hasTreeData,
210
+ dirtyValue,
211
+ renderModeRoleBased
212
+ );
213
+
214
+ if (!col.internal) {
215
+ // Assign cell type or cell subType attributes.
216
+ let attributeNames;
217
+ let attributeValues;
218
+ if (columnSubType) {
219
+ attributeNames = getAttributesNames(columnSubType);
220
+ attributeValues = getSubTypeAttributesValues(col);
221
+ } else {
222
+ attributeNames = types.getType(columnType).typeAttributes;
223
+ attributeValues = getTypeAttributesValues(col);
224
+ }
225
+ const attributeNamesLength = attributeNames
226
+ ? attributeNames.length
227
+ : 0;
228
+ for (let i = 0; i < attributeNamesLength; i += 1) {
229
+ const attrName = attributeNames[i];
230
+ const attrValue = attributeValues[attrName];
231
+ cell[`typeAttribute${i}`] = resolveAttributeValue(
232
+ attrValue,
233
+ rowData
234
+ );
235
+ }
236
+
237
+ // Extract the `cellAttributes` and their values that are specified in the
238
+ // column definition.
239
+ // If a cell attribute points to a fieldName in a row, that value is resolved here.
240
+ // This object that contains the resolved mapping is then set in the `cell`
241
+ // object in each row.
242
+ const cellAttributes = getCellAttributesValues(col);
243
+ const keys = Object.keys(cellAttributes);
244
+ for (let i = 0, { length } = keys; i < length; i += 1) {
245
+ const attrName = keys[i];
246
+ const attrValue = cellAttributes[attrName];
247
+ cell[attrName] = resolveAttributeValue(attrValue, rowData);
248
+ }
249
+
250
+ // If this is tree grid, this maps and sets into the cell object
251
+ // the tree specific attributes:
252
+ // 1) row.hasChildren to typeAttribute21 and
253
+ // 2) row.isExpanded to and typeAttribute22
254
+ if (hasTreeData) {
255
+ // Attaches if the row containing this cell hasChildren or
256
+ // not and isExpanded or not attributes to typeAttribute21
257
+ // and typeAttribute22 respectively typeAttribute0-typeAttribute20
258
+ // are reserved for types supported by tree
259
+ cell.typeAttribute21 = row.hasChildren;
260
+ cell.typeAttribute22 = row.isExpanded === 'true';
261
+ }
262
+ }
263
+ // Populate row number attributes.
264
+ else if (columnType === 'rowNumber') {
265
+ const scopeColValue = rowData[scopeCol.fieldName];
266
+ // computes and sets the resolved typeAttribute for the row
267
+ // number column error state
268
+ cell.typeAttribute0 = getRowNumberError(
212
269
  rowErrors,
213
- scopeCol
270
+ scopeColValue
214
271
  );
215
272
  }
216
273
 
@@ -218,178 +275,9 @@ export function updateRowsAndCellIndexes() {
218
275
  // Keeping the hash for backward compatibility, but we need to have 2 indexes, 1 for columns and one for rows,
219
276
  // because of memory usage and also at certain point we might have the data but not the columns
220
277
  state.indexes[row.key][colKeyValue] = [rowIndex, colIndex];
221
-
222
- currentRow.push(cell);
223
- return currentRow;
224
- }, row.cells);
225
-
226
- prev.push(row);
227
- return prev;
228
- }, []);
229
- }
230
-
231
- /**
232
- * Checks whether there are errors for the specified column
233
- * When a columnKey exists for a column, we will look for its errors inside the
234
- * cells property of rowErrors. Only when it doesn't exist will we look for a
235
- * reference to the column's fieldName.
236
- *
237
- * This maintains backwards compatibility with those continuing to use fieldName
238
- * as column identifiers.
239
- */
240
- function hasCellErrors(rowErrors, fieldName, columnKey) {
241
- const rowErrorsHasColumnKey = rowErrors.cells && rowErrors.cells[columnKey];
242
- const rowErrorsHasFieldName =
243
- rowErrors.fieldNames && rowErrors.fieldNames.includes(fieldName);
244
-
245
- return rowErrorsHasColumnKey || (!columnKey && rowErrorsHasFieldName);
246
- }
247
-
248
- /**
249
- * Computes and sets the following resolved values in the cell object:
250
- * 1. `typeAttributes` specified in the column definition
251
- * 2. `cellAttributes` specified in the column definition
252
- * 3. Editability of the cell and subsequently the ariaReadOnly property
253
- * 4. Visibility of read only icon
254
- *
255
- * Computes and sets the following tree specific attributes
256
- * into typeAttributes21/22 in the cell object:
257
- * 1. row.hasChildren
258
- * 2. row.isExpanded
259
- *
260
- * @param {Object} cell - cell metadata
261
- * @param {Object} row - row metadata
262
- * @param {Object} rowData - data to be rendered in the cells of that row
263
- * @param {Object} colData - column definition
264
- * @param {Object} types - instance of DatatableTypes from `./types.js`
265
- */
266
- function assignCustomerColumnAttributes(cell, row, rowData, colData, types) {
267
- Object.assign(
268
- cell,
269
- computeCellTypeAttributes(rowData, colData, types),
270
- computeCellAttributes(rowData, colData),
271
- computeCellEditable(rowData, colData),
272
- computeCellDisplayReadOnlyIcon(colData)
273
- );
274
- if (!cell.editable) {
275
- cell.ariaReadOnly = true;
276
- }
277
-
278
- // If this is tree grid, this maps and sets into the cell object the tree specific attributes:
279
- // 1) row.hasChildren to typeAttribute21 and
280
- // 2) row.isExpanded to and typeAttribute22
281
- if (isTreeType(colData.type)) {
282
- Object.assign(cell, computeCellStateTypeAttributes(row));
283
- }
284
- }
285
-
286
- /**
287
- * Computes and sets the resolved typeAttribute for the row number column error state
288
- *
289
- * @param {Object} cell - cell metadata
290
- * @param {Object} rowData - data to be rendered in the cells of that row
291
- * @param {Object} types - instance of DatatableTypes from `./types.js`
292
- * @param {Object} rowErrors - contains the errors present in that row
293
- * @param {Object} scopeCol - column with scope=row
294
- */
295
- function assignRowNumberColumnAttributes(
296
- cell,
297
- rowData,
298
- types,
299
- rowErrors,
300
- scopeCol
301
- ) {
302
- const scopeColValue = rowData[scopeCol.fieldName];
303
- const errorColumnDef = getRowNumberErrorColumnDef(rowErrors, scopeColValue);
304
- Object.assign(
305
- cell,
306
- computeCellTypeAttributes(rowData, errorColumnDef, types)
307
- );
308
- }
309
-
310
- /**
311
- * This function extracts the `cellAttributes` and their values that are specified
312
- * in the column definition.
313
- * If a cell attribute points to a fieldName in a row, that value is resolved here.
314
- *
315
- * This object that contains the resolved mapping is then set in the `cell` object
316
- * in each row.
317
- *
318
- * @param {Object} row - current row data. Required for cases cellAttributes refers to a fieldName in a row
319
- * @param {Object} column - column definition
320
- * @returns {Object} - contains the resolved mapping of cellAttributes and their values
321
- */
322
- export function computeCellAttributes(row, column) {
323
- const cellAttributesValues = getCellAttributesValues(column);
324
- return Object.keys(cellAttributesValues).reduce((attrs, attrName) => {
325
- const attrValue = cellAttributesValues[attrName];
326
- attrs[attrName] = resolveAttributeValue(attrValue, row);
327
-
328
- return attrs;
329
- }, {});
330
- }
331
-
332
- /**
333
- * This function retrieves the allowlisted type attributes for a particular type and
334
- * maps the value set in the column definition to `typeAttribute{index}`.
335
- *
336
- * The types and their corresponding allowlisted attributes can be seen in types.js
337
- *
338
- * Ex. For the type 'url', there are 3 type attributes allowlisted: label, target, tooltip
339
- * If you pass typeAttributes: {label: 'My Label', target: '_blank', myattr: false}
340
- * in the column definition, this function would map ->
341
- * typeAttribute0: 'My Label', typeAttribute1: '_blank' and typeAttribute2: undefined
342
- * `myattr` is not allowlisted so it is discarded
343
- *
344
- * This mapping is later set into the `cell` object for each row and
345
- * will be passed in to primitive-cell-factory as
346
- * type-attribute-0={cell.typeAttribute0}
347
- * type-attribute-1={cell.typeAttribute1}
348
- * ...
349
- *
350
- * @param {Object} row - current row data. Required for cases typeAttributes refers to a fieldName in a row
351
- * @param {Object} column - column definition
352
- * @param {Object} types - instance of DatatableTypes from `./types.js`
353
- * @returns {Object} - object containing all the typeAttributes{index} and their mapped values
354
- */
355
- export function computeCellTypeAttributes(row, column, types) {
356
- if (column.typeAttributes && column.typeAttributes.subType) {
357
- return computeCellSubTypeAttributes(row, column);
278
+ cells[colIndex] = cell;
279
+ }
358
280
  }
359
- const attributesNames = types.getType(column.type).typeAttributes;
360
- const typeAttributesValues = getTypeAttributesValues(column);
361
-
362
- return attributesNames.reduce((attrs, attrName, index) => {
363
- const typeAttributeName = `typeAttribute${index}`;
364
-
365
- attrs[typeAttributeName] = resolveAttributeValue(
366
- typeAttributesValues[attrName],
367
- row
368
- );
369
-
370
- return attrs;
371
- }, {});
372
- }
373
-
374
- export function computeCellSubTypeAttributes(row, column) {
375
- const attributesNames = getAttributesNames(column.typeAttributes.subType);
376
- const typeAttributesValues = getSubTypeAttributesValues(column);
377
-
378
- return attributesNames.reduce((attrs, attrName, index) => {
379
- const typeAttributeName = `typeAttribute${index}`;
380
- attrs[typeAttributeName] = resolveAttributeValue(
381
- typeAttributesValues[attrName],
382
- row
383
- );
384
-
385
- return attrs;
386
- }, {});
387
- }
388
-
389
- function computeCellEditable(row, column) {
390
- return {
391
- editable: isCellEditable(row, column),
392
- };
393
281
  }
394
282
 
395
283
  /**
@@ -401,17 +289,11 @@ function computeCellEditable(row, column) {
401
289
  *
402
290
  * Returns false in all other cases.
403
291
  *
404
- * @param {object} row - a row data object stored in datatable state. Must be truthy.
405
- * @param {object} column - a column data object stored in datatable state. Must be truthy.
292
+ * @param {object} rowData - a row data object stored in datatable state. Must be truthy.
293
+ * @param {object} col - a column data object stored in datatable state. Must be truthy.
406
294
  */
407
- export function isCellEditable(row, column) {
408
- return !!resolveAttributeValue(column.editable, row);
409
- }
410
-
411
- function computeCellDisplayReadOnlyIcon(column) {
412
- return {
413
- displayReadOnlyIcon: !!column.displayReadOnlyIcon,
414
- };
295
+ export function isCellEditable(rowData, col) {
296
+ return !!resolveAttributeValue(col.editable, rowData);
415
297
  }
416
298
 
417
299
  /**
@@ -422,167 +304,73 @@ function computeCellDisplayReadOnlyIcon(column) {
422
304
  * managed by ourselves unlike the <table> version.
423
305
  *
424
306
  * @param {Object} types - instance of DatatableTypes from `./types.js`
425
- * @param {Object} colData - column definition
307
+ * @param {Object} col - column definition
426
308
  * @param {Boolean} renderModeRoleBased - render mode of datatable (div || table)
427
309
  * @returns {String} - styles to be set on the cell
428
310
  */
429
- function computeCellStyles(types, colData, renderModeRoleBased) {
430
- let style = '';
431
- const columnType = colData.type;
311
+ function computeCellStyles(types, col, renderModeRoleBased) {
312
+ const columnType = col.type;
432
313
 
433
- // When a custom type is not using the standard layout,
434
- // remove the padding that comes with the standard layout
314
+ let cellStyle = '';
435
315
  if (
436
316
  types.isCustomType(columnType) &&
437
317
  !types.isStandardCellLayoutForCustomType(columnType)
438
318
  ) {
439
- style = 'padding: 0;';
319
+ // When a custom type is not using the standard layout,
320
+ // remove the padding that comes with the standard layout
321
+ cellStyle = 'padding: 0;';
440
322
  }
441
323
 
442
324
  // Width needs to be managed when rendering as divs
443
325
  if (renderModeRoleBased) {
444
- const columnWidth = colData.columnWidth;
445
- style += columnWidth > 0 ? `width:${columnWidth}px;` : '';
326
+ const { columnWidth } = col;
327
+ if (columnWidth > 0) {
328
+ cellStyle += `width:${columnWidth}px;`;
329
+ }
446
330
  }
447
331
 
448
- return style;
332
+ return cellStyle;
449
333
  }
450
334
 
451
335
  function computeCellClassNames(
452
- row,
453
- column,
454
- cellHasErrors,
336
+ cell,
337
+ hasTreeData,
455
338
  dirtyValue,
456
339
  renderModeRoleBased
457
340
  ) {
458
- const classNames = classSet('');
459
341
  // TODO: With the current SLDS design, the 'slds-cell-edit' class is required on a cell in cases
460
342
  // where the read only icon is to be displayed. This is an issue with their design that will need to
461
343
  // be addressed on their end, so once they do that we can modify this code accordingly.
462
- classNames.add({
463
- 'slds-cell-edit':
464
- isCellEditable(row, column) || column.displayReadOnlyIcon,
465
- 'slds-tree__item': isTreeType(column.type),
466
- 'slds-has-error': cellHasErrors,
467
- 'slds-is-edited': dirtyValue !== undefined,
468
- cell: renderModeRoleBased,
469
- });
470
- return classNames.toString();
471
- }
472
-
473
- /**
474
- * Attaches if the row containing this cell hasChildren or not and isExpanded or not
475
- * attributes to typeAttribute21 and typeAttribute22 respectively
476
- * typeAttribute0-typeAttribute20 are reserved for types supported by tree
477
- * @param {object}row - current row which is stored in state.rows
478
- * @returns {{typeAttribute21, typeAttribute22: boolean}} typeAttributes
479
- * describing state of the row associated
480
- */
481
- function computeCellStateTypeAttributes(row) {
482
- return {
483
- typeAttribute21: row.hasChildren,
484
- typeAttribute22: row.isExpanded === 'true',
485
- };
486
- }
487
-
488
- export function getRowIndexByKey(state, key) {
489
- if (!state.indexes[key]) {
490
- return undefined;
344
+ let cellClass = '';
345
+ if (cell.displayReadOnlyIcon || cell.editable) {
346
+ cellClass += CELL_EDIT_CLASS;
491
347
  }
492
-
493
- return state.indexes[key].rowIndex;
494
- }
495
-
496
- export function getRowByKey(state, key) {
497
- const rows = getRows(state);
498
- return rows[getRowIndexByKey(state, key)];
499
- }
500
-
501
- export function rowKeyExists(state, key) {
502
- return !!state.indexes[key];
503
- }
504
-
505
- export function getRowsTotal(state) {
506
- return getRows(state).length;
348
+ if (hasTreeData) {
349
+ cellClass += (cellClass.length ? ' ' : '') + TREE__ITEM_CLASS;
350
+ }
351
+ if (cell.hasError) {
352
+ cellClass += (cellClass.length ? ' ' : '') + HAS_ERROR_CLASS;
353
+ }
354
+ if (dirtyValue !== undefined) {
355
+ cellClass += (cellClass.length ? ' ' : '') + IS_EDITED_CLASS;
356
+ }
357
+ if (renderModeRoleBased) {
358
+ cellClass += (cellClass.length ? ' ' : '') + ROLE_BASED_CELL_CLASS;
359
+ }
360
+ return cellClass;
507
361
  }
508
362
 
509
- function resolveAttributeValue(attrValue, row) {
363
+ function resolveAttributeValue(attrValue, rowData) {
510
364
  if (isObjectLike(attrValue)) {
511
- const fieldName = attrValue.fieldName;
365
+ const { fieldName } = attrValue;
512
366
  if (fieldName) {
513
- return row[fieldName];
367
+ return rowData[fieldName];
514
368
  }
515
369
  }
516
370
 
517
371
  return attrValue;
518
372
  }
519
373
 
520
- function getRowStateForTree(row, state) {
521
- const column = getStateTreeColumn(state);
522
- if (column) {
523
- return {
524
- level: getRowLevel(column, row),
525
- posInSet: getRowPosInSet(column, row),
526
- setSize: getRowSetSize(column, row),
527
- isExpanded: isRowExpanded(column, row),
528
- hasChildren: getRowHasChildren(column, row),
529
- };
530
- }
531
- return {};
532
- }
533
-
534
- export function getRowLevel(column, row) {
535
- const typeAttributesValues = getTypeAttributesValues(column);
536
- const attrValue = resolveAttributeValue(
537
- typeAttributesValues[getTreeStateIndicatorFieldNames().level],
538
- row
539
- );
540
- return attrValue ? attrValue : 1;
541
- }
542
-
543
- function getRowPosInSet(column, row) {
544
- const typeAttributesValues = getTypeAttributesValues(column);
545
- const attrValue = resolveAttributeValue(
546
- typeAttributesValues[getTreeStateIndicatorFieldNames().position],
547
- row
548
- );
549
- return attrValue ? attrValue : 1;
550
- }
551
-
552
- function getRowSetSize(column, row) {
553
- const typeAttributesValues = getTypeAttributesValues(column);
554
- const attrValue = resolveAttributeValue(
555
- typeAttributesValues[getTreeStateIndicatorFieldNames().setsize],
556
- row
557
- );
558
- return attrValue ? attrValue : 1;
559
- }
560
-
561
- export function isRowExpanded(column, row) {
562
- const typeAttributesValues = getTypeAttributesValues(column);
563
- const hasChildren = resolveAttributeValue(
564
- typeAttributesValues[getTreeStateIndicatorFieldNames().children],
565
- row
566
- );
567
- if (hasChildren) {
568
- const attrValue = resolveAttributeValue(
569
- typeAttributesValues[getTreeStateIndicatorFieldNames().expanded],
570
- row
571
- );
572
- return !!attrValue + '';
573
- }
574
- return undefined;
575
- }
576
-
577
- export function getRowHasChildren(column, row) {
578
- const typeAttributesValues = getTypeAttributesValues(column);
579
- const hasChildren = resolveAttributeValue(
580
- typeAttributesValues[getTreeStateIndicatorFieldNames().children],
581
- row
582
- );
583
- return !!hasChildren;
584
- }
585
-
586
374
  /**
587
375
  * For the role-based table, we need to manage the width of each cell separately.
588
376
  * Re-compute the cell styles so that the width of the cell is set
@@ -591,7 +379,7 @@ export function getRowHasChildren(column, row) {
591
379
  * @param {Object} state - Datatable's state object
592
380
  */
593
381
  export function recomputeCellStyles(types, state) {
594
- const columns = getColumns(state);
382
+ const { columns } = state;
595
383
  state.rows.forEach((row) => {
596
384
  row.cells.forEach((cell, colIndex) => {
597
385
  const colData = columns[colIndex];