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.
- package/metadata/raptor.json +77 -1
- package/package.json +108 -15
- package/scopedImports/@salesforce-label-LightningDatatable.showActions.js +1 -1
- package/scopedImports/@salesforce-label-LightningForm.controllerFieldsMessage.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.dependentFieldsHeader.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.dependentFieldsListHeading.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.generalDependentFieldsMessage.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.learnMore.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.okButton.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.modalCancel.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.modalSelect.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressIndicator.currentStage.js +1 -1
- package/scopedImports/@salesforce-label-LightningProgressIndicator.errorStage.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressIndicator.stageComplete.js +1 -1
- package/scopedImports/@salesforce-label-LightningProgressIndicator.stageNotStarted.js +1 -1
- package/scopedImports/@salesforce-label-LightningRichTextEditor.colorPicker.js +1 -0
- package/src/lightning/accordion/accordion-section.slds.css +3 -3
- package/src/lightning/accordion/accordion.slds.css +1 -2
- package/src/lightning/accordionSection/accordion-section.slds.css +3 -3
- package/src/lightning/accordionSection/accordionSection.js +3 -1
- package/src/lightning/accordionSection/button.slds.css +1 -1
- package/src/lightning/avatar/avatar.html +1 -0
- package/src/lightning/badge/badge.html +3 -3
- package/src/lightning/badge/badge.js +1 -0
- package/src/lightning/badge/badge.js-meta.xml +3 -0
- package/src/lightning/baseCombobox/base-combobox.slds.css +11 -6
- package/src/lightning/baseCombobox/baseCombobox.html +5 -2
- package/src/lightning/baseCombobox/baseCombobox.js +5 -18
- package/src/lightning/baseCombobox/baseCombobox.js-meta.xml +6 -0
- package/src/lightning/baseCombobox/input-text.slds.css +41 -68
- package/src/lightning/baseCombobox/keyboard.js +12 -4
- package/src/lightning/baseCombobox/listbox.slds.css +51 -99
- package/src/lightning/baseCombobox/spinner.slds.css +62 -62
- package/src/lightning/baseComboboxFormattedText/baseComboboxFormattedText.js-meta.xml +6 -0
- package/src/lightning/baseComboboxItem/baseComboboxItem.js +10 -6
- package/src/lightning/baseComboboxItem/baseComboboxItem.js-meta.xml +6 -0
- package/src/lightning/baseComboboxItem/listbox.slds.css +51 -99
- package/src/lightning/baseFormattedText/baseFormattedText.js +2 -2
- package/src/lightning/button/__docs__/button.md +2 -1
- package/src/lightning/button/button.js +5 -5
- package/src/lightning/button/button.slds.css +1 -1
- package/src/lightning/buttonIcon/__docs__/buttonIcon.md +1 -0
- package/src/lightning/buttonIcon/button-icon.slds.css +1 -1
- package/src/lightning/buttonIcon/buttonIcon.html +1 -1
- package/src/lightning/buttonIcon/buttonIcon.js +18 -17
- package/src/lightning/buttonIconStateful/button-icon-stateful.slds.css +4 -2
- package/src/lightning/buttonIconStateful/button-icon.slds.css +1 -1
- package/src/lightning/buttonIconStateful/button.slds.css +1 -1
- package/src/lightning/buttonMenu/button-icon.slds.css +1 -1
- package/src/lightning/buttonMenu/button-menu.slds.css +8 -2
- package/src/lightning/buttonMenu/button.slds.css +1 -1
- package/src/lightning/buttonMenu/buttonMenu.css +5 -0
- package/src/lightning/buttonMenu/buttonMenu.js +2 -0
- package/src/lightning/buttonStateful/button-stateful.slds.css +6 -2
- package/src/lightning/buttonStateful/button.slds.css +1 -1
- package/src/lightning/buttonStateful/buttonStateful.js +4 -1
- package/src/lightning/calendar/calendar.js-meta.xml +6 -0
- package/src/lightning/calendar/calendar.slds.css +9 -2
- package/src/lightning/colorPickerCustom/color-picker-custom.slds.css +22 -23
- package/src/lightning/colorPickerCustom/colorPickerCustom.js +12 -0
- package/src/lightning/colorPickerCustom/input-text.slds.css +41 -68
- package/src/lightning/colorPickerPanel/color-picker-panel.slds.css +9 -10
- package/src/lightning/colorPickerPanel/colorPickerPanel.js +11 -1
- package/src/lightning/colorPickerPanel/popover.slds.css +0 -2
- package/src/lightning/combobox/combobox.html +1 -0
- package/src/lightning/combobox/combobox.slds.css +1 -2
- package/src/lightning/combobox/form-element.slds.css +54 -54
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.html +11 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.js +25 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/generateData.js +15 -0
- package/src/lightning/datatable/__examples__disabled/customDatatableWrapper/customDatatableWrapper.js +89 -0
- package/src/lightning/datatable/__examples__disabled/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +6 -0
- package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.js +1 -16
- package/src/lightning/datatable/__examples__disabled/customDatatypeLink/customDatatypeLink.html +9 -0
- package/src/lightning/datatable/__examples__disabled/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html +3 -0
- package/src/lightning/datatable/__examples__disabled/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +3 -0
- package/src/lightning/datatable/__examples__disabled/customDatatypeTable/customNumber.html +3 -0
- package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumberEdit.html +2 -0
- package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/deleteRow.html +3 -2
- package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/iconPill.html +1 -1
- package/src/lightning/datatable/{__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html → __examples__disabled/customNestedComponent/customNestedComponent.html} +2 -2
- package/src/lightning/datatable/__examples__disabled/customNestedComponent/customNestedComponent.js +12 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/customInput.html +4 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/myCustomTypeDatatable.js +17 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/nestedSimpleComponentParent.html +7 -0
- package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.html +9 -0
- package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.js +6 -0
- package/src/lightning/datatable/autoWidthStrategy.js +145 -217
- package/src/lightning/datatable/columnResizer.js +80 -190
- package/src/lightning/datatable/columnWidthManager.js +128 -243
- package/src/lightning/datatable/columns.js +192 -283
- package/src/lightning/datatable/datagrid.slds.css +187 -0
- package/src/lightning/datatable/datatable.js +647 -614
- package/src/lightning/datatable/errors.js +19 -28
- package/src/lightning/datatable/fixedWidthStrategy.js +27 -49
- package/src/lightning/datatable/headerActions.js +10 -42
- package/src/lightning/datatable/indexes.js +42 -0
- package/src/lightning/datatable/infiniteLoading.js +27 -46
- package/src/lightning/datatable/inlineEdit.js +311 -322
- package/src/lightning/datatable/keyboard.js +490 -510
- package/src/lightning/datatable/renderManager.js +10 -11
- package/src/lightning/datatable/resizeObserver.js +10 -67
- package/src/lightning/datatable/rowLevelActions.js +7 -6
- package/src/lightning/datatable/rowNumber.js +41 -79
- package/src/lightning/datatable/rowSelection.js +236 -291
- package/src/lightning/datatable/rowSelectionShared.js +26 -33
- package/src/lightning/datatable/rows.js +264 -476
- package/src/lightning/datatable/sort.js +27 -82
- package/src/lightning/datatable/templates/div/div.css +2 -57
- package/src/lightning/datatable/templates/div/div.html +25 -10
- package/src/lightning/datatable/templates/div/div.lbc.native.css +3 -0
- package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +80 -0
- package/src/lightning/datatable/templates/table/table.html +16 -5
- package/src/lightning/datatable/tree.js +17 -35
- package/src/lightning/datatable/types.js +10 -31
- package/src/lightning/datatable/utils.js +54 -29
- package/src/lightning/datatable/virtualization.js +2 -5
- package/src/lightning/datatable/widthManagerShared.js +24 -41
- package/src/lightning/datatable/wrapText.js +45 -77
- package/src/lightning/datepicker/datepicker.js +32 -9
- package/src/lightning/datepicker/datepicker.js-meta.xml +6 -0
- package/src/lightning/datepicker/form-element.slds.css +54 -54
- package/src/lightning/datepicker/input-text.slds.css +41 -68
- package/src/lightning/datetimepicker/datetimepicker.js-meta.xml +6 -0
- package/src/lightning/datetimepicker/form-element.slds.css +54 -54
- package/src/lightning/datetimepicker/input-text.slds.css +41 -68
- package/src/lightning/dualListbox/dual-listbox.slds.css +7 -2
- package/src/lightning/dualListbox/dualListbox.js +7 -8
- package/src/lightning/dualListbox/form-element.slds.css +54 -54
- package/src/lightning/dualListbox/listbox.slds.css +51 -99
- package/src/lightning/dynamicIcon/dynamic-icon-strength.slds.css +1 -2
- package/src/lightning/dynamicIcon/dynamic-icon-trend.slds.css +1 -2
- package/src/lightning/formattedDateTime/formattedDateTime.js +7 -62
- package/src/lightning/formattedDateTime/formattedDateTime.js-meta.xml +3 -0
- package/src/lightning/formattedLocation/formattedLocation.html +1 -3
- package/src/lightning/formattedLocation/formattedLocation.js +3 -25
- package/src/lightning/formattedLookup/events.js +2 -4
- package/src/lightning/formattedName/formattedName.js +3 -2
- package/src/lightning/formattedName/formattedName.js-meta.xml +3 -0
- package/src/lightning/formattedNumber/formattedNumber.js +5 -51
- package/src/lightning/formattedNumber/formattedNumber.js-meta.xml +3 -0
- package/src/lightning/formattedRichText/formattedRichText.js +5 -5
- package/src/lightning/formattedRichText/linkTextNodes.js +58 -0
- package/src/lightning/formattedRichText/richTextConfig.js +1 -0
- package/src/lightning/groupedCombobox/form-element.slds.css +54 -54
- package/src/lightning/groupedCombobox/grouped-combobox.slds.css +0 -2
- package/src/lightning/groupedCombobox/groupedCombobox.js-meta.xml +1 -1
- package/src/lightning/groupedCombobox/input-text.slds.css +41 -68
- package/src/lightning/helptext/button-icon.slds.css +1 -1
- package/src/lightning/helptext/form-element.slds.css +54 -54
- package/src/lightning/helptext/helptext.css +7 -0
- package/src/lightning/helptext/helptext.js +3 -4
- package/src/lightning/icon/icon.html +1 -1
- package/src/lightning/icon/icon.slds.css +12 -25
- package/src/lightning/input/form-element.slds.css +54 -54
- package/src/lightning/input/input.html +5 -0
- package/src/lightning/inputAddress/addressFormat.js +31 -4
- package/src/lightning/inputAddress/fieldsLayout.js +6 -0
- package/src/lightning/inputAddress/form-element.slds.css +54 -54
- package/src/lightning/inputAddress/input-address.slds.css +1 -2
- package/src/lightning/inputAddress/input-text.slds.css +41 -68
- package/src/lightning/inputAddress/inputAddress.html +19 -1
- package/src/lightning/inputAddress/inputAddress.js +75 -3
- package/src/lightning/inputAddress/inputAddress.js-meta.xml +3 -0
- package/src/lightning/inputLocation/form-element.slds.css +54 -54
- package/src/lightning/inputLocation/input-location.slds.css +1 -2
- package/src/lightning/inputLocation/input-text.slds.css +41 -68
- package/src/lightning/inputName/form-element.slds.css +54 -54
- package/src/lightning/inputName/input-text.slds.css +41 -68
- package/src/lightning/interactiveDialogBase/interactive-dialog-base.slds.css +0 -3
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.js-meta.xml +6 -0
- package/src/lightning/internationalizationLibrary/address/AddressFormat.js +553 -610
- package/src/lightning/lookupAddress/form-element.slds.css +54 -54
- package/src/lightning/lookupAddress/listbox.slds.css +51 -99
- package/src/lightning/lookupAddress/location.js +2 -0
- package/src/lightning/lookupAddress/lookup-address.slds.css +0 -2
- package/src/lightning/lookupAddress/lookupAddress.html +6 -1
- package/src/lightning/lookupAddress/lookupAddress.js +40 -10
- package/src/lightning/menuDivider/menu-divider.slds.css +0 -2
- package/src/lightning/menuItem/menu-item.slds.css +8 -2
- package/src/lightning/menuSubheader/menu-subheader.slds.css +1 -2
- package/src/lightning/modal/__docs__/modal.md +10 -1
- package/src/lightning/modal/__modalUtils__/modalContainerTestConstants.js +3 -7
- package/src/lightning/modal/__modalUtils__/modalContainerTestMethods.js +39 -133
- package/src/lightning/modal/__modalUtils__/modalContainerTestMockData.js +1 -1
- package/src/lightning/modal/modal.js +1 -1
- package/src/lightning/modalBase/modal-base.slds.css +3 -3
- package/src/lightning/modalBase/modalBase.html +15 -10
- package/src/lightning/modalBase/modalBase.js +131 -154
- package/src/lightning/modalBase/modalBase.js-meta.xml +6 -0
- package/src/lightning/modalBody/modal-body.slds.css +1 -2
- package/src/lightning/modalBody/modalBody.css +6 -0
- package/src/lightning/modalFooter/modal-footer.slds.css +2 -2
- package/src/lightning/modalFooter/modalFooter.js +0 -21
- package/src/lightning/modalHeader/modal-header.slds.css +1 -2
- package/src/lightning/modalHeader/modalHeader.html +16 -4
- package/src/lightning/modalHeader/modalHeader.js +61 -36
- package/src/lightning/overlay/overlay.js-meta.xml +6 -0
- package/src/lightning/pill/link.html +1 -0
- package/src/lightning/pill/pill.slds.css +32 -58
- package/src/lightning/pill/plain.html +1 -0
- package/src/lightning/pill/plainLink.html +1 -0
- package/src/lightning/pillContainer/button.slds.css +1 -1
- package/src/lightning/pillContainer/listbox.slds.css +51 -99
- package/src/lightning/pillContainer/pill-container.slds.css +6 -10
- package/src/lightning/pillContainer/pill.slds.css +32 -58
- package/src/lightning/popup/popover.slds.css +0 -2
- package/src/lightning/primitiveBubble/primitiveBubble.js +42 -0
- package/src/lightning/primitiveBubble/primitiveBubble.js-meta.xml +6 -0
- package/src/lightning/primitiveButton/primitiveButoon.js-meta.xml +6 -0
- package/src/lightning/primitiveCellCheckbox/checkbox.css +2 -0
- package/src/lightning/primitiveColorpickerButton/color-picker-button.slds.css +16 -38
- package/src/lightning/primitiveCustomCell/primitiveCustomCell.js +26 -1
- package/src/lightning/primitiveDatatableCell/primitiveDatatableCell.js +1 -1
- package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.html +1 -1
- package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +13 -0
- package/src/lightning/primitiveHeaderFactory/nonsortableHeader.css +1 -0
- package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +19 -6
- package/src/lightning/primitiveHeaderFactory/selectableHeader.css +2 -0
- package/src/lightning/primitiveHeaderFactory/sortableHeader.html +3 -1
- package/src/lightning/primitiveIcon/icon.slds.css +12 -25
- package/src/lightning/primitiveIcon/primitiveIcon.js-meta.xml +6 -0
- package/src/lightning/primitiveIframe/primitiveIframe.js +3 -1
- package/src/lightning/primitiveInputCheckbox/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js +5 -2
- package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js-meta.xml +6 -0
- package/src/lightning/primitiveInputCheckboxButton/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputCheckboxButton/input-checkbox-button.slds.css +6 -4
- package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js +5 -2
- package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js-meta.xml +6 -0
- package/src/lightning/primitiveInputColor/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputColor/input-color.slds.css +2 -3
- package/src/lightning/primitiveInputColor/input-text.slds.css +41 -68
- package/src/lightning/primitiveInputColor/primitiveInputColor.js +5 -2
- package/src/lightning/primitiveInputColor/primitiveInputColor.js-meta.xml +6 -0
- package/src/lightning/primitiveInputFile/button.slds.css +1 -1
- package/src/lightning/primitiveInputFile/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputFile/input-file.slds.css +1 -4
- package/src/lightning/primitiveInputFile/primitiveInputFile.js +4 -2
- package/src/lightning/primitiveInputFile/primitiveInputFile.js-meta.xml +6 -0
- package/src/lightning/primitiveInputRadio/primitiveInputRadio.js +4 -2
- package/src/lightning/primitiveInputSimple/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputSimple/input-text.slds.css +41 -68
- package/src/lightning/primitiveInputSimple/primitiveInputSimple.js-meta.xml +6 -0
- package/src/lightning/primitiveInputToggle/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputToggle/input-toggle.slds.css +50 -27
- package/src/lightning/primitiveInputToggle/primitiveInputToggle.js +5 -2
- package/src/lightning/primitiveInputToggle/primitiveInputToggle.js-meta.xml +6 -0
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.css +11 -0
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.html +2 -1
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.js +1 -0
- package/src/lightning/progressBar/progress-bar.slds.css +8 -10
- package/src/lightning/progressRing/progress-ring.slds.css +0 -23
- package/src/lightning/progressStep/base.html +5 -6
- package/src/lightning/progressStep/progressStep.js +15 -23
- package/src/lightning/prompt/__docs__/prompt.md +1 -1
- package/src/lightning/radioGroup/form-element.slds.css +54 -54
- package/src/lightning/radioGroup/radioGroup.html +1 -2
- package/src/lightning/radioGroup/radioGroup.js +1 -0
- package/src/lightning/routingService/routingService.js +31 -5
- package/src/lightning/select/form-element.slds.css +54 -54
- package/src/lightning/select/select.slds.css +4 -2
- package/src/lightning/shadowBaseClassPrivate/shadowBaseClassPrivate.js +0 -2
- package/src/lightning/sldsCommon/sldsCommon.css +134 -98
- package/src/lightning/sldsUtilsAlignment/sldsUtilsAlignment.css +1 -1
- package/src/lightning/sldsUtilsBox/sldsUtilsBox.css +14 -13
- package/src/lightning/sldsUtilsGrid/sldsUtilsGrid.css +95 -92
- package/src/lightning/sldsUtilsHyphenation/sldsUtilsHyphenation.css +1 -1
- package/src/lightning/sldsUtilsMargin/sldsUtilsMargin.css +77 -75
- package/src/lightning/sldsUtilsPadding/sldsUtilsPadding.css +73 -73
- package/src/lightning/sldsUtilsSizing/sldsUtilsSizing.css +552 -558
- package/src/lightning/sldsUtilsVisibility/sldsUtilsVisibility.css +5 -1
- package/src/lightning/spinner/spinner.slds.css +62 -62
- package/src/lightning/staticMap/staticMap.js +3 -2
- package/src/lightning/tab/tab.js +10 -5
- package/src/lightning/tab/tab.js-meta.xml +3 -0
- package/src/lightning/tab/tab.slds.css +14 -7
- package/src/lightning/tabBar/tab-bar.slds.css +16 -6
- package/src/lightning/tabBar/tabBar.js +10 -5
- package/src/lightning/tabset/__docs__/tabset.md +24 -1
- package/src/lightning/tabset/tabset.html +2 -0
- package/src/lightning/tabset/tabset.js +25 -38
- package/src/lightning/tabset/tabset.js-meta.xml +3 -0
- package/src/lightning/tabset/tabset.slds.css +0 -2
- package/src/lightning/textarea/form-element.slds.css +54 -54
- package/src/lightning/textarea/textarea.js +11 -2
- package/src/lightning/textarea/textarea.slds.css +22 -9
- package/src/lightning/timepicker/form-element.slds.css +54 -54
- package/src/lightning/timepicker/timepicker.js-meta.xml +6 -0
- package/src/lightning/timepicker/timepicker.slds.css +2 -2
- package/src/lightning/toast/__docs__/toast.md +20 -22
- package/src/lightning/toast/button-icon.slds.css +1 -1
- package/src/lightning/toast/icon.slds.css +12 -25
- package/src/lightning/toast/toast.js +15 -12
- package/src/lightning/toast/toast.slds.css +6 -18
- package/src/lightning/toastContainer/__docs__/toastContainer.md +3 -2
- package/src/lightning/toastContainer/toast.slds.css +6 -18
- package/src/lightning/toastContainer/toastContainer.js +25 -17
- package/src/lightning/tooltipLibrary/tooltipLibrary.js +36 -24
- package/src/lightning/tree/tree.js +2 -0
- package/src/lightning/utils/classSet.js +9 -3
- package/src/lightning/utilsPrivate/formatUtils.js +158 -0
- package/src/lightning/utilsPrivate/textUtils.js +16 -0
- package/src/lightning/utilsPrivate/utilsPrivate.js +56 -15
- package/src/lightning/utilsPrivate/validationUtils.js +59 -0
- package/src/lightning/verticalNavigation/vertical-navigation.slds.css +14 -0
- package/src/lightning/verticalNavigation/verticalNavigation.css +1 -1
- package/src/lightning/verticalNavigation/verticalNavigation.html +1 -1
- package/src/lightning/verticalNavigation/verticalNavigation.js +66 -28
- package/src/lightning/verticalNavigation/verticalNavigation.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItem/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.css +2 -3
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.js +29 -15
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.native.css +2 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationItemBadge/badge.slds.css +76 -0
- package/src/lightning/verticalNavigationItemBadge/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.css +2 -3
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.html +1 -1
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js +28 -15
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.native.css +5 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationItemIcon/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.css +2 -3
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js +29 -15
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.native.css +3 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationOverflow/button.slds.css +503 -0
- package/src/lightning/verticalNavigationOverflow/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationOverflow/vertical-navigation-section.slds.css +17 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.css +2 -1
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.html +2 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js +18 -13
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.lbc.native.css +5 -0
- package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +13 -15
- package/src/lightning/verticalNavigationSection/verticalNavigationSection.js-meta.xml +3 -0
- package/src/lightning/datatable/__examples__/customDatatableWrapper/customDatatableWrapper.js +0 -158
- package/src/lightning/datatable/__examples__/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +0 -6
- package/src/lightning/datatable/__examples__/customDatatypeLink/customDatatypeLink.html +0 -9
- package/src/lightning/datatable/__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +0 -40
- package/src/lightning/datatable/__examples__/customDatatypeTable/customNumber.html +0 -3
- package/src/lightning/datatable/inlineEditShared.js +0 -26
- package/src/lightning/datatable/resizeSensor.js +0 -244
- package/src/lightning/formattedRichText/linkify.js +0 -43
- package/src/lightning/utilsPrivate/smartSetAttribute.js +0 -19
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customDatatypeTable.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customLink.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customName.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/orderingButtons.html +0 -0
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
getRows,
|
|
4
|
-
getRowByKey,
|
|
5
|
-
getRowsTotal,
|
|
6
|
-
getRowIndexByKey,
|
|
7
|
-
rowKeyExists,
|
|
8
|
-
} from './rows';
|
|
9
|
-
import {
|
|
10
|
-
getColumns,
|
|
11
|
-
getStateColumnIndex,
|
|
12
|
-
SELECTABLE_ROW_CHECKBOX,
|
|
13
|
-
} from './columns';
|
|
1
|
+
import { getRowByKey, getRowIndexByKey, HEADER_ROW_KEY } from './indexes';
|
|
2
|
+
import { getStateColumnIndex } from './columns';
|
|
14
3
|
import { isNonNegativeInteger } from './utils';
|
|
15
4
|
import {
|
|
16
5
|
getCurrentSelectionLength,
|
|
17
|
-
isSelectedRow,
|
|
18
|
-
isDisabledRow,
|
|
19
|
-
getRowSelectionInputType,
|
|
20
|
-
getMaxRowSelection,
|
|
21
6
|
getSelectedRowsKeys,
|
|
22
|
-
} from './rowSelectionShared';
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
getCurrentSelectionLength,
|
|
26
|
-
isSelectedRow,
|
|
27
7
|
isDisabledRow,
|
|
28
|
-
|
|
29
|
-
getMaxRowSelection,
|
|
30
|
-
getSelectedRowsKeys,
|
|
8
|
+
SELECTABLE_HEADER_TYPE,
|
|
31
9
|
} from './rowSelectionShared';
|
|
32
10
|
|
|
33
11
|
const MAX_ROW_SELECTION_DEFAULT = undefined;
|
|
@@ -79,15 +57,13 @@ export function handleDeselectAllRows(event) {
|
|
|
79
57
|
*/
|
|
80
58
|
export function handleSelectRow(event) {
|
|
81
59
|
event.stopPropagation();
|
|
60
|
+
const { state } = this;
|
|
82
61
|
const { rowKeyValue, isMultiple } = event.detail;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
markSelectedRowsInterval(this.state, fromRowKey, rowKeyValue);
|
|
90
|
-
setLastRowSelection(this.state, rowKeyValue);
|
|
62
|
+
const fromRowKey = isMultiple
|
|
63
|
+
? getLastRowSelection(state) || rowKeyValue
|
|
64
|
+
: rowKeyValue;
|
|
65
|
+
markSelectedRowsInterval(state, fromRowKey, rowKeyValue);
|
|
66
|
+
state.lastSelectedRowKey = rowKeyValue;
|
|
91
67
|
this.fireSelectedRowsChange(this.getSelectedRows(), {
|
|
92
68
|
action: ROWS_ACTION.ROW_SELECT,
|
|
93
69
|
value: rowKeyValue,
|
|
@@ -105,15 +81,13 @@ export function handleSelectRow(event) {
|
|
|
105
81
|
*/
|
|
106
82
|
export function handleDeselectRow(event) {
|
|
107
83
|
event.stopPropagation();
|
|
84
|
+
const { state } = this;
|
|
108
85
|
const { rowKeyValue, isMultiple } = event.detail;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
markDeselectedRowsInterval(this.state, fromRowKey, rowKeyValue);
|
|
116
|
-
setLastRowSelection(this.state, rowKeyValue);
|
|
86
|
+
const fromRowKey = isMultiple
|
|
87
|
+
? getLastRowSelection(state) || rowKeyValue
|
|
88
|
+
: rowKeyValue;
|
|
89
|
+
markDeselectedRowsInterval(state, fromRowKey, rowKeyValue);
|
|
90
|
+
state.lastSelectedRowKey = rowKeyValue;
|
|
117
91
|
this.fireSelectedRowsChange(this.getSelectedRows(), {
|
|
118
92
|
action: ROWS_ACTION.ROW_DESELECT,
|
|
119
93
|
value: rowKeyValue,
|
|
@@ -139,22 +113,22 @@ export function handleRowSelectionChange() {
|
|
|
139
113
|
* 2. If max-row-selection has been reached, mark the remaining rows
|
|
140
114
|
* to reflect that they are not selected and disable them.
|
|
141
115
|
*
|
|
142
|
-
* @param {Object} state - datatable
|
|
116
|
+
* @param {Object} state - The datatable state
|
|
143
117
|
*/
|
|
144
118
|
export function markAllRowsSelected(state) {
|
|
145
|
-
const rows =
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
setRowSelectedAttributes(
|
|
152
|
-
addKeyToSelectedRowKeys(state, row.key);
|
|
119
|
+
const { maxRowSelection, rows } = state;
|
|
120
|
+
const selectedRowsKeys = {};
|
|
121
|
+
for (let i = 0, { length: rowCount } = rows; i < rowCount; i += 1) {
|
|
122
|
+
const row = rows[i];
|
|
123
|
+
if (maxRowSelection === undefined || i < maxRowSelection) {
|
|
124
|
+
selectedRowsKeys[row.key] = true;
|
|
125
|
+
setRowSelectedAttributes(row, true);
|
|
153
126
|
} else {
|
|
154
127
|
row.isDisabled = true;
|
|
155
|
-
setRowSelectedAttributes(
|
|
128
|
+
setRowSelectedAttributes(row, false);
|
|
156
129
|
}
|
|
157
|
-
}
|
|
130
|
+
}
|
|
131
|
+
state.selectedRowsKeys = selectedRowsKeys;
|
|
158
132
|
}
|
|
159
133
|
|
|
160
134
|
/**
|
|
@@ -163,17 +137,16 @@ export function markAllRowsSelected(state) {
|
|
|
163
137
|
* set `isSelected` and `ariaSelected` to false and enable the row. Also resolve
|
|
164
138
|
* the `classnames` for the row to reflect that it is not selected.
|
|
165
139
|
*
|
|
166
|
-
* @param {Object} state - datatable
|
|
167
|
-
* @returns
|
|
140
|
+
* @param {Object} state - The datatable state
|
|
168
141
|
*/
|
|
169
142
|
export function markAllRowsDeselected(state) {
|
|
170
|
-
const rows =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
rows.forEach((row) => {
|
|
143
|
+
const { rows } = state;
|
|
144
|
+
for (let i = 0, { length: rowCount } = rows; i < rowCount; i += 1) {
|
|
145
|
+
const row = rows[i];
|
|
174
146
|
row.isDisabled = false;
|
|
175
|
-
setRowSelectedAttributes(
|
|
176
|
-
}
|
|
147
|
+
setRowSelectedAttributes(row, false);
|
|
148
|
+
}
|
|
149
|
+
state.selectedRowsKeys = {};
|
|
177
150
|
}
|
|
178
151
|
|
|
179
152
|
/**
|
|
@@ -190,22 +163,20 @@ export function markAllRowsDeselected(state) {
|
|
|
190
163
|
* This does not handle the case when the header checkbox that selects
|
|
191
164
|
* all rows of the table is clicked. That is handled by - `handleSelectAllRows`
|
|
192
165
|
*
|
|
193
|
-
* @param {Object} state - datatable
|
|
166
|
+
* @param {Object} state - The datatable state
|
|
194
167
|
* @param {String} startRowKey - row key value of the first row that was selected (start of the interval)
|
|
195
168
|
* @param {String} endRowKey - row key value of the last row that was selected (end of the interval)
|
|
196
169
|
*/
|
|
197
170
|
function markSelectedRowsInterval(state, startRowKey, endRowKey) {
|
|
198
|
-
const rows =
|
|
171
|
+
const { rows } = state;
|
|
199
172
|
const { start, end } = getRowIntervalIndexes(state, startRowKey, endRowKey);
|
|
200
|
-
const
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
getCurrentSelectionLength(state) >= maxRowSelection;
|
|
208
|
-
i++;
|
|
173
|
+
const total = state.maxRowSelection || rows.length;
|
|
174
|
+
let rowIndex = start;
|
|
175
|
+
let maxSelectionReached;
|
|
176
|
+
while (rowIndex <= end && !maxSelectionReached) {
|
|
177
|
+
markRowSelected(state, rows[rowIndex].key);
|
|
178
|
+
maxSelectionReached = getCurrentSelectionLength(state) >= total;
|
|
179
|
+
rowIndex += 1;
|
|
209
180
|
}
|
|
210
181
|
}
|
|
211
182
|
|
|
@@ -222,16 +193,22 @@ function markSelectedRowsInterval(state, startRowKey, endRowKey) {
|
|
|
222
193
|
* This does not handle the case when the header checkbox is clicked to de-select all rows
|
|
223
194
|
* That is handledd by - `handleDeselectAllRows`
|
|
224
195
|
*
|
|
225
|
-
* @param {Object} state - datatable
|
|
196
|
+
* @param {Object} state - The datatable state
|
|
226
197
|
* @param {String} startRowKey - row key value of the first row that was selected (start of the interval)
|
|
227
198
|
* @param {String} endRowKey - row key value of the last row that was selected (end of the interval)
|
|
228
199
|
*/
|
|
229
200
|
function markDeselectedRowsInterval(state, startRowKey, endRowKey) {
|
|
230
|
-
const rows =
|
|
201
|
+
const { rows, selectedRowsKeys } = state;
|
|
231
202
|
const { start, end } = getRowIntervalIndexes(state, startRowKey, endRowKey);
|
|
232
203
|
|
|
233
|
-
for (let
|
|
234
|
-
|
|
204
|
+
for (let rowIndex = start; rowIndex <= end; rowIndex += 1) {
|
|
205
|
+
const row = rows[rowIndex];
|
|
206
|
+
setRowSelectedAttributes(row, false);
|
|
207
|
+
// Setting to `false` instead of using `delete` for better performance.
|
|
208
|
+
selectedRowsKeys[row.key] = false;
|
|
209
|
+
if (getCurrentSelectionLength(state) === state.maxRowSelection - 1) {
|
|
210
|
+
markDeselectedRowEnabled(state);
|
|
211
|
+
}
|
|
235
212
|
}
|
|
236
213
|
}
|
|
237
214
|
|
|
@@ -248,56 +225,33 @@ function markDeselectedRowsInterval(state, startRowKey, endRowKey) {
|
|
|
248
225
|
* a. If another row was previously selected before, de-select that row
|
|
249
226
|
* b. Add the row key value of that row to the state
|
|
250
227
|
*
|
|
251
|
-
* @param {Object} state - datatable
|
|
228
|
+
* @param {Object} state - The datatable state
|
|
252
229
|
* @param {String} rowKeyValue - row key value of row to mark selected
|
|
253
230
|
*/
|
|
254
231
|
export function markRowSelected(state, rowKeyValue) {
|
|
255
232
|
const row = getRowByKey(state, rowKeyValue);
|
|
256
|
-
const
|
|
257
|
-
const
|
|
233
|
+
const prevSelectionLength = getCurrentSelectionLength(state);
|
|
234
|
+
const total = state.maxRowSelection || state.rows.length;
|
|
258
235
|
|
|
259
|
-
setRowSelectedAttributes(
|
|
236
|
+
setRowSelectedAttributes(row, true);
|
|
260
237
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
238
|
+
let { selectedRowsKeys } = state;
|
|
239
|
+
if (total > 1) {
|
|
240
|
+
selectedRowsKeys[row.key] = true;
|
|
241
|
+
if (prevSelectionLength + 1 === total) {
|
|
264
242
|
markDeselectedRowDisabled(state);
|
|
265
243
|
}
|
|
266
244
|
} else {
|
|
267
|
-
if (
|
|
268
|
-
const
|
|
245
|
+
if (prevSelectionLength === 1) {
|
|
246
|
+
const prevSelectedRow = getRowByKey(
|
|
269
247
|
state,
|
|
270
|
-
Object.keys(
|
|
248
|
+
Object.keys(selectedRowsKeys)[0]
|
|
271
249
|
);
|
|
272
|
-
setRowSelectedAttributes(
|
|
273
|
-
|
|
250
|
+
setRowSelectedAttributes(prevSelectedRow, false);
|
|
251
|
+
selectedRowsKeys = {};
|
|
252
|
+
state.selectedRowsKeys = selectedRowsKeys;
|
|
274
253
|
}
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Marks a row with the specified row key value as de-selected. This is done by:
|
|
281
|
-
* 1. Sets `isSelected`, `ariaSelected` to false and resolves `classnames`
|
|
282
|
-
* to that which reflect that the row is not selected, on the row object.
|
|
283
|
-
* These are used by the template to render the appropriate values.
|
|
284
|
-
* 2. The row key value of this row is removed from list of selected row keys
|
|
285
|
-
* 3. Before the current de-selection, if the remaining unselected rows were
|
|
286
|
-
* disabled (max-row-selection was reached), enable all unselected rows
|
|
287
|
-
* so that they can be selected.
|
|
288
|
-
*
|
|
289
|
-
* @param {Object} state - datatable's state object
|
|
290
|
-
* @param {String} rowKeyValue - row key value of row to mark selected
|
|
291
|
-
*/
|
|
292
|
-
export function markRowDeselected(state, rowKeyValue) {
|
|
293
|
-
const row = getRowByKey(state, rowKeyValue);
|
|
294
|
-
const maxRowSelection = getMaxRowSelection(state);
|
|
295
|
-
|
|
296
|
-
setRowSelectedAttributes(false, row);
|
|
297
|
-
removeKeyFromSelectedRowKeys(state, row.key);
|
|
298
|
-
|
|
299
|
-
if (getCurrentSelectionLength(state) === maxRowSelection - 1) {
|
|
300
|
-
markDeselectedRowEnabled(state);
|
|
254
|
+
selectedRowsKeys[row.key] = true;
|
|
301
255
|
}
|
|
302
256
|
}
|
|
303
257
|
|
|
@@ -307,14 +261,14 @@ export function markRowDeselected(state, rowKeyValue) {
|
|
|
307
261
|
* Sets `isSelected`, `ariaSelected` and `classnames` on the row object
|
|
308
262
|
* which are used by the template to render the appropriate values.
|
|
309
263
|
*
|
|
310
|
-
* @param {Object} state - datatable
|
|
264
|
+
* @param {Object} state - The datatable state
|
|
311
265
|
* @param {Array} keys - a list of row key values to be marked selected
|
|
312
266
|
*/
|
|
313
267
|
function markRowsSelectedByKeys(state, keys) {
|
|
314
|
-
|
|
315
|
-
const row = getRowByKey(state,
|
|
316
|
-
setRowSelectedAttributes(
|
|
317
|
-
}
|
|
268
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
269
|
+
const row = getRowByKey(state, keys[i]);
|
|
270
|
+
setRowSelectedAttributes(row, true);
|
|
271
|
+
}
|
|
318
272
|
}
|
|
319
273
|
|
|
320
274
|
/**
|
|
@@ -324,14 +278,14 @@ function markRowsSelectedByKeys(state, keys) {
|
|
|
324
278
|
* to one which reflects that the row is not selected on the row object.
|
|
325
279
|
* These are used by the template to render the appropriate values.
|
|
326
280
|
*
|
|
327
|
-
* @param {Object} state - datatable
|
|
281
|
+
* @param {Object} state - The datatable state
|
|
328
282
|
* @param {Array} keys - a list of row key values to be marked selected
|
|
329
283
|
*/
|
|
330
284
|
function markRowsDeselectedByKeys(state, keys) {
|
|
331
|
-
|
|
332
|
-
const row = getRowByKey(state,
|
|
333
|
-
setRowSelectedAttributes(
|
|
334
|
-
}
|
|
285
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
286
|
+
const row = getRowByKey(state, keys[i]);
|
|
287
|
+
setRowSelectedAttributes(row, false);
|
|
288
|
+
}
|
|
335
289
|
}
|
|
336
290
|
|
|
337
291
|
/**
|
|
@@ -343,12 +297,13 @@ function markRowsDeselectedByKeys(state, keys) {
|
|
|
343
297
|
* @param {Object} state - datatable's state object
|
|
344
298
|
*/
|
|
345
299
|
export function markDeselectedRowDisabled(state) {
|
|
346
|
-
const rows =
|
|
347
|
-
|
|
348
|
-
|
|
300
|
+
const { rows, selectedRowsKeys } = state;
|
|
301
|
+
for (let i = 0, { length: rowCount } = rows; i < rowCount; i += 1) {
|
|
302
|
+
const row = rows[i];
|
|
303
|
+
if (!selectedRowsKeys[row.key]) {
|
|
349
304
|
row.isDisabled = true;
|
|
350
305
|
}
|
|
351
|
-
}
|
|
306
|
+
}
|
|
352
307
|
}
|
|
353
308
|
|
|
354
309
|
/**
|
|
@@ -358,15 +313,16 @@ export function markDeselectedRowDisabled(state) {
|
|
|
358
313
|
* previously selected but a row was deselected, now allowing
|
|
359
314
|
* any other row to be selected - for this, all rows should be enabled
|
|
360
315
|
*
|
|
361
|
-
* @param {Object} state - datatable
|
|
316
|
+
* @param {Object} state - The datatable state
|
|
362
317
|
*/
|
|
363
318
|
export function markDeselectedRowEnabled(state) {
|
|
364
|
-
const rows =
|
|
365
|
-
|
|
366
|
-
|
|
319
|
+
const { rows, selectedRowsKeys } = state;
|
|
320
|
+
for (let i = 0, { length: rowCount } = rows; i < rowCount; i += 1) {
|
|
321
|
+
const row = rows[i];
|
|
322
|
+
if (!selectedRowsKeys[row.key]) {
|
|
367
323
|
row.isDisabled = false;
|
|
368
324
|
}
|
|
369
|
-
}
|
|
325
|
+
}
|
|
370
326
|
}
|
|
371
327
|
|
|
372
328
|
/************************** SELECTED ROW KEYS **************************/
|
|
@@ -391,12 +347,12 @@ export function markDeselectedRowEnabled(state) {
|
|
|
391
347
|
* If the previous selection had reached the max limit and the new selection
|
|
392
348
|
* is less than the limit, re-enable the de-selected rows to allow for new selection.
|
|
393
349
|
*
|
|
394
|
-
* @param {Object} state - datatable
|
|
350
|
+
* @param {Object} state - The datatable state
|
|
395
351
|
* @param {Array} value - key-field values of rows to set as selected
|
|
396
352
|
*/
|
|
397
353
|
export function setSelectedRowsKeys(state, value) {
|
|
398
354
|
if (Array.isArray(value)) {
|
|
399
|
-
const maxRowSelection =
|
|
355
|
+
const { maxRowSelection } = state;
|
|
400
356
|
const previousSelectionLength = getCurrentSelectionLength(state);
|
|
401
357
|
let selectedRows = filterValidKeys(state, value);
|
|
402
358
|
if (selectedRows.length > maxRowSelection) {
|
|
@@ -409,8 +365,7 @@ export function setSelectedRowsKeys(state, value) {
|
|
|
409
365
|
|
|
410
366
|
// Convert the selectedRows Array to an Object that state.selectedRowKeys expects
|
|
411
367
|
// ['a', 'b'] -> { a : true, b : true}
|
|
412
|
-
const
|
|
413
|
-
normalizeSelectedRowsKey(selectedRows);
|
|
368
|
+
const selectedRowsKeys = normalizeSelectedRowsKey(selectedRows);
|
|
414
369
|
|
|
415
370
|
// Compute differences between currently selected rows and
|
|
416
371
|
// newly selected row keys. The diff will tell which new rows
|
|
@@ -419,18 +374,19 @@ export function setSelectedRowsKeys(state, value) {
|
|
|
419
374
|
const selectionOperations = getSelectedDiff(state, selectedRows);
|
|
420
375
|
const deselectionOperations = getDeselectedDiff(
|
|
421
376
|
state,
|
|
422
|
-
|
|
377
|
+
selectedRowsKeys
|
|
423
378
|
);
|
|
424
379
|
markRowsSelectedByKeys(state, selectionOperations);
|
|
425
380
|
markRowsDeselectedByKeys(state, deselectionOperations);
|
|
426
|
-
state.selectedRowsKeys =
|
|
381
|
+
state.selectedRowsKeys = selectedRowsKeys;
|
|
427
382
|
|
|
383
|
+
const { length: selectedRowsCount } = selectedRows;
|
|
428
384
|
// If we select the max number of rows allowed and if max-row-selection > 1 (multi-select),
|
|
429
385
|
// disable all the other rows to prevent further selection
|
|
430
|
-
if (
|
|
386
|
+
if (selectedRowsCount === maxRowSelection && maxRowSelection > 1) {
|
|
431
387
|
markDeselectedRowDisabled(state);
|
|
432
388
|
} else if (
|
|
433
|
-
|
|
389
|
+
selectedRowsCount < maxRowSelection &&
|
|
434
390
|
previousSelectionLength === maxRowSelection
|
|
435
391
|
) {
|
|
436
392
|
// If the previous selection had reached the max limit and the new selection
|
|
@@ -448,34 +404,44 @@ export function setSelectedRowsKeys(state, value) {
|
|
|
448
404
|
|
|
449
405
|
export function syncSelectedRowsKeys(state, selectedRows) {
|
|
450
406
|
let changed = false;
|
|
451
|
-
const {
|
|
452
|
-
const
|
|
453
|
-
if (Object.keys(selectedRowsKeys).length !==
|
|
407
|
+
const { keyField, selectedRowsKeys } = state;
|
|
408
|
+
const { length: selectedRowCount } = selectedRows;
|
|
409
|
+
if (Object.keys(selectedRowsKeys).length !== selectedRowCount) {
|
|
454
410
|
changed = true;
|
|
411
|
+
// Untracked state change.
|
|
455
412
|
state.selectedRowsKeys = updateSelectedRowsKeysFromSelectedRows(
|
|
456
413
|
selectedRows,
|
|
457
414
|
keyField
|
|
458
415
|
);
|
|
459
416
|
} else {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
417
|
+
for (let i = 0; i < selectedRowCount; i += 1) {
|
|
418
|
+
const row = selectedRows[i];
|
|
419
|
+
if (!selectedRowsKeys[row[keyField]]) {
|
|
420
|
+
changed = true;
|
|
421
|
+
// Untracked state change.
|
|
422
|
+
state.selectedRowsKeys = updateSelectedRowsKeysFromSelectedRows(
|
|
423
|
+
selectedRows,
|
|
424
|
+
keyField
|
|
425
|
+
);
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
466
428
|
}
|
|
467
429
|
}
|
|
468
|
-
if (
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
430
|
+
if (changed) {
|
|
431
|
+
const total = state.maxRowSelection || state.rows.length;
|
|
432
|
+
if (total > 1) {
|
|
433
|
+
// Tracked state changes.
|
|
434
|
+
if (selectedRowCount < total) {
|
|
435
|
+
markDeselectedRowEnabled(state);
|
|
436
|
+
} else {
|
|
437
|
+
markDeselectedRowDisabled(state);
|
|
438
|
+
}
|
|
473
439
|
}
|
|
474
440
|
}
|
|
441
|
+
// Tracked state change.
|
|
475
442
|
updateBulkSelectionState(state);
|
|
476
|
-
|
|
477
443
|
return {
|
|
478
|
-
ifChanged
|
|
444
|
+
ifChanged(callback) {
|
|
479
445
|
if (changed && typeof callback === 'function') {
|
|
480
446
|
callback(selectedRows);
|
|
481
447
|
}
|
|
@@ -484,35 +450,35 @@ export function syncSelectedRowsKeys(state, selectedRows) {
|
|
|
484
450
|
}
|
|
485
451
|
|
|
486
452
|
function updateSelectedRowsKeysFromSelectedRows(selectedRows, keyField) {
|
|
487
|
-
|
|
453
|
+
const selectedRowsKeys = {};
|
|
454
|
+
for (let i = 0, { length } = selectedRows; i < length; i += 1) {
|
|
455
|
+
const row = selectedRows[i];
|
|
488
456
|
selectedRowsKeys[row[keyField]] = true;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
function addKeyToSelectedRowKeys(state, key) {
|
|
494
|
-
state.selectedRowsKeys[key] = true;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
function removeKeyFromSelectedRowKeys(state, key) {
|
|
498
|
-
// not using delete this.state.selectedRowsKeys[key]
|
|
499
|
-
// because that causes perf issues
|
|
500
|
-
state.selectedRowsKeys[key] = false;
|
|
457
|
+
}
|
|
458
|
+
return selectedRowsKeys;
|
|
501
459
|
}
|
|
502
460
|
|
|
503
|
-
function normalizeSelectedRowsKey(
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
461
|
+
function normalizeSelectedRowsKey(keys) {
|
|
462
|
+
const selectedRowsKeys = {};
|
|
463
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
464
|
+
selectedRowsKeys[keys[i]] = true;
|
|
465
|
+
}
|
|
466
|
+
return selectedRowsKeys;
|
|
508
467
|
}
|
|
509
468
|
|
|
510
469
|
function filterValidKeys(state, keys) {
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
470
|
+
const filtered = [];
|
|
471
|
+
const { rows } = state;
|
|
472
|
+
if (rows.length) {
|
|
473
|
+
const { indexes } = state;
|
|
474
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
475
|
+
const key = keys[i];
|
|
476
|
+
if (indexes[key]) {
|
|
477
|
+
filtered.push(key);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return filtered;
|
|
516
482
|
}
|
|
517
483
|
|
|
518
484
|
/************************** LAST SELECTED ROW KEYS **************************/
|
|
@@ -521,11 +487,11 @@ export function resetSelectedRowsKeys(state) {
|
|
|
521
487
|
* Returns the row key value of the row that was last selected
|
|
522
488
|
* Returns undefined if the row key value is invalid
|
|
523
489
|
*
|
|
524
|
-
* @param {Object} state -
|
|
490
|
+
* @param {Object} state - The datatable state.
|
|
525
491
|
* @returns {String | undefined } the row key or undefined.
|
|
526
492
|
*/
|
|
527
493
|
function getLastRowSelection(state) {
|
|
528
|
-
const lastSelectedRowKey = state
|
|
494
|
+
const { lastSelectedRowKey } = state;
|
|
529
495
|
const keyIsValid =
|
|
530
496
|
lastSelectedRowKey !== undefined &&
|
|
531
497
|
getRowIndexByKey(state, lastSelectedRowKey) !== undefined;
|
|
@@ -533,10 +499,6 @@ function getLastRowSelection(state) {
|
|
|
533
499
|
return keyIsValid ? lastSelectedRowKey : undefined;
|
|
534
500
|
}
|
|
535
501
|
|
|
536
|
-
function setLastRowSelection(state, rowKeyValue) {
|
|
537
|
-
state.lastSelectedRowKey = rowKeyValue;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
502
|
/************************** INPUT TYPES **************************/
|
|
541
503
|
|
|
542
504
|
/**
|
|
@@ -551,30 +513,35 @@ function setLastRowSelection(state, rowKeyValue) {
|
|
|
551
513
|
*
|
|
552
514
|
* @param {Number} previousMaxRowSelection
|
|
553
515
|
* @param {Number} newMaxRowSelection
|
|
554
|
-
* @returns
|
|
516
|
+
* @returns {Boolean}
|
|
555
517
|
*/
|
|
556
518
|
export function inputTypeNeedsToChange(
|
|
557
519
|
previousMaxRowSelection,
|
|
558
520
|
newMaxRowSelection
|
|
559
521
|
) {
|
|
560
522
|
return (
|
|
561
|
-
(previousMaxRowSelection === 1 &&
|
|
562
|
-
isMultiSelection(newMaxRowSelection)) ||
|
|
563
|
-
(isMultiSelection(previousMaxRowSelection) &&
|
|
564
|
-
newMaxRowSelection === 1) ||
|
|
565
523
|
previousMaxRowSelection === 0 ||
|
|
566
|
-
newMaxRowSelection === 0
|
|
524
|
+
newMaxRowSelection === 0 ||
|
|
525
|
+
(previousMaxRowSelection === 1 &&
|
|
526
|
+
// is newMaxRowSelection multi-selection
|
|
527
|
+
(newMaxRowSelection > 1 || newMaxRowSelection === undefined)) ||
|
|
528
|
+
(newMaxRowSelection === 1 &&
|
|
529
|
+
// is previousMaxRowSelection multi-selection
|
|
530
|
+
(previousMaxRowSelection > 1 ||
|
|
531
|
+
previousMaxRowSelection === undefined))
|
|
567
532
|
);
|
|
568
533
|
}
|
|
569
534
|
|
|
570
535
|
export function updateRowSelectionInputType(state) {
|
|
571
|
-
const type =
|
|
572
|
-
const rows =
|
|
536
|
+
const type = state.maxRowSelection === 1 ? 'radio' : 'checkbox';
|
|
537
|
+
const { rows } = state;
|
|
573
538
|
|
|
574
|
-
|
|
539
|
+
for (let i = 0, { length: rowCount } = rows; i < rowCount; i += 1) {
|
|
540
|
+
// Tracked state changes.
|
|
541
|
+
const row = rows[i];
|
|
575
542
|
row.inputType = type;
|
|
576
543
|
row.isDisabled = isDisabledRow(state, row.key);
|
|
577
|
-
}
|
|
544
|
+
}
|
|
578
545
|
}
|
|
579
546
|
|
|
580
547
|
/************************** MAX ROW SELECTION **************************/
|
|
@@ -587,34 +554,36 @@ export function updateRowSelectionInputType(state) {
|
|
|
587
554
|
* and input type is radio if maxRowSelection = 1.
|
|
588
555
|
* Invalid values are set to default and an error is logged
|
|
589
556
|
*
|
|
590
|
-
* @param {Object} state -
|
|
557
|
+
* @param {Object} state - The datatable state
|
|
591
558
|
* @param {Number | String} - value to set for maxRowSelection
|
|
592
559
|
*/
|
|
593
560
|
export function setMaxRowSelection(state, value) {
|
|
594
561
|
const previousSelectedRowsKeys = getSelectedRowsKeys(state);
|
|
562
|
+
// Tracked state changes.
|
|
595
563
|
markAllRowsDeselected(state);
|
|
596
564
|
if (isNonNegativeInteger(value)) {
|
|
597
|
-
const previousMaxRowSelection =
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
565
|
+
const previousMaxRowSelection = state.maxRowSelection;
|
|
566
|
+
const newMaxRowSelection = Number(value);
|
|
567
|
+
// Untracked state change.
|
|
568
|
+
state.maxRowSelection = newMaxRowSelection;
|
|
569
|
+
// Reselect up to maxRowSelection rows.
|
|
601
570
|
const numberOfRows = Math.min(
|
|
602
571
|
previousSelectedRowsKeys.length,
|
|
603
572
|
newMaxRowSelection
|
|
604
573
|
);
|
|
605
|
-
for (let i = 0; i < numberOfRows; i
|
|
574
|
+
for (let i = 0; i < numberOfRows; i += 1) {
|
|
575
|
+
// Tracked state changes.
|
|
606
576
|
markRowSelected(state, previousSelectedRowsKeys[i]);
|
|
607
577
|
}
|
|
608
578
|
if (
|
|
609
|
-
inputTypeNeedsToChange(
|
|
610
|
-
previousMaxRowSelection,
|
|
611
|
-
getMaxRowSelection(state)
|
|
612
|
-
)
|
|
579
|
+
inputTypeNeedsToChange(previousMaxRowSelection, newMaxRowSelection)
|
|
613
580
|
) {
|
|
581
|
+
// Tracked state changes.
|
|
614
582
|
updateRowSelectionInputType(state);
|
|
615
583
|
updateBulkSelectionState(state);
|
|
616
584
|
}
|
|
617
585
|
} else {
|
|
586
|
+
// Untracked state change.
|
|
618
587
|
state.maxRowSelection = MAX_ROW_SELECTION_DEFAULT;
|
|
619
588
|
// suppress console error if no value is passed in
|
|
620
589
|
if (value !== null && value !== undefined) {
|
|
@@ -629,32 +598,31 @@ export function setMaxRowSelection(state, value) {
|
|
|
629
598
|
/************************** BULK SELECTION STATE **************************/
|
|
630
599
|
|
|
631
600
|
export function updateBulkSelectionState(state) {
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
601
|
+
const columns = state.columns || {};
|
|
602
|
+
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
603
|
+
const col = columns[colIndex];
|
|
604
|
+
if (col.type === SELECTABLE_HEADER_TYPE) {
|
|
605
|
+
const {
|
|
606
|
+
maxRowSelection,
|
|
607
|
+
rows: { length: rowCount },
|
|
608
|
+
} = state;
|
|
609
|
+
const total = maxRowSelection || rowCount;
|
|
610
|
+
const selected = getCurrentSelectionLength(state);
|
|
611
|
+
// Force a rerender of this column by replacing the tracked object.
|
|
612
|
+
// Required to pass treegrid unit tests.
|
|
613
|
+
const updatedCol = Object.assign({}, col);
|
|
614
|
+
if (selected) {
|
|
615
|
+
updatedCol.bulkSelection = selected === total ? 'all' : 'some';
|
|
616
|
+
} else {
|
|
617
|
+
updatedCol.bulkSelection = 'none';
|
|
640
618
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const total = getMaxRowSelection(state) || getRowsTotal(state);
|
|
648
|
-
if (selected === 0) {
|
|
649
|
-
return 'none';
|
|
650
|
-
} else if (selected === total) {
|
|
651
|
-
return 'all';
|
|
619
|
+
updatedCol.isBulkSelectionDisabled =
|
|
620
|
+
maxRowSelection === 0 || rowCount === 0;
|
|
621
|
+
// Replace old column with shallow cloned and updated column.
|
|
622
|
+
columns[colIndex] = updatedCol;
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
652
625
|
}
|
|
653
|
-
return 'some';
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
function isBulkSelectionDisabled(state) {
|
|
657
|
-
return getRowsTotal(state) === 0 || getMaxRowSelection(state) === 0;
|
|
658
626
|
}
|
|
659
627
|
|
|
660
628
|
/************************** HELPER FUNCTIONS **************************/
|
|
@@ -665,14 +633,16 @@ function isBulkSelectionDisabled(state) {
|
|
|
665
633
|
* Returns an object that contains the start index which is the lower index value of the two
|
|
666
634
|
* and the end index which is the higher value of the two.
|
|
667
635
|
*
|
|
668
|
-
* @param {Object} state - datatable
|
|
669
|
-
* @param {String} startRowKey - row key value of the first row that was selected (start of the interval)
|
|
670
|
-
* @param {String} endRowKey - row key value of the last row that was selected (end of the interval)
|
|
671
|
-
* @returns {Object} - object with start index and end index
|
|
636
|
+
* @param {Object} state - The datatable state
|
|
637
|
+
* @param {String} startRowKey - The row key value of the first row that was selected (start of the interval)
|
|
638
|
+
* @param {String} endRowKey - The row key value of the last row that was selected (end of the interval)
|
|
639
|
+
* @returns {Object} - An object with start index and end index
|
|
672
640
|
*/
|
|
673
641
|
function getRowIntervalIndexes(state, startRowKey, endRowKey) {
|
|
674
642
|
const start =
|
|
675
|
-
startRowKey ===
|
|
643
|
+
startRowKey === HEADER_ROW_KEY
|
|
644
|
+
? 0
|
|
645
|
+
: getRowIndexByKey(state, startRowKey);
|
|
676
646
|
const end = getRowIndexByKey(state, endRowKey);
|
|
677
647
|
|
|
678
648
|
return {
|
|
@@ -687,9 +657,9 @@ function getRowIntervalIndexes(state, startRowKey, endRowKey) {
|
|
|
687
657
|
*
|
|
688
658
|
* Note: This change is volatile, and will be reset (lost) in the next index regeneration.
|
|
689
659
|
*
|
|
690
|
-
* @param {Object} state -
|
|
691
|
-
* @param {String} rowKeyValue -
|
|
692
|
-
* @param {String} colKeyValue -
|
|
660
|
+
* @param {Object} state - The datatable state
|
|
661
|
+
* @param {String} rowKeyValue - The row key of the cell to mark selected
|
|
662
|
+
* @param {String} colKeyValue - The column key of the cell to mark selected
|
|
693
663
|
*/
|
|
694
664
|
export function setAriaSelectedOnCell(state, rowKeyValue, colKeyValue) {
|
|
695
665
|
const row = getRowByKey(state, rowKeyValue);
|
|
@@ -707,9 +677,9 @@ export function setAriaSelectedOnCell(state, rowKeyValue, colKeyValue) {
|
|
|
707
677
|
*
|
|
708
678
|
* Note: This change is volatile, and will be reset (lost) in the next index regeneration.
|
|
709
679
|
*
|
|
710
|
-
* @param {Object} state -
|
|
711
|
-
* @param {String} rowKeyValue -
|
|
712
|
-
* @param {String} colKeyValue -
|
|
680
|
+
* @param {Object} state - The datatable state
|
|
681
|
+
* @param {String} rowKeyValue - The row key of the cell to select
|
|
682
|
+
* @param {String} colKeyValue - The column key of the cell to select
|
|
713
683
|
*/
|
|
714
684
|
export function unsetAriaSelectedOnCell(state, rowKeyValue, colKeyValue) {
|
|
715
685
|
const row = getRowByKey(state, rowKeyValue);
|
|
@@ -725,63 +695,38 @@ export function unsetAriaSelectedOnCell(state, rowKeyValue, colKeyValue) {
|
|
|
725
695
|
* to one which reflects the selected value of the row on the row object.
|
|
726
696
|
* These are used by the template to render the appropriate values.
|
|
727
697
|
*
|
|
728
|
-
* @param {
|
|
729
|
-
* @param {
|
|
698
|
+
* @param {Object} row - The row
|
|
699
|
+
* @param {Boolean} selectedValue - Whether the row is selected
|
|
730
700
|
*/
|
|
731
|
-
function setRowSelectedAttributes(
|
|
732
|
-
row.isSelected = selectedValue;
|
|
701
|
+
function setRowSelectedAttributes(row, selectedValue) {
|
|
733
702
|
row.ariaSelected = selectedValue;
|
|
734
|
-
row.classnames =
|
|
703
|
+
row.classnames = `slds-hint-parent${
|
|
704
|
+
selectedValue ? ' slds-is-selected' : ''
|
|
705
|
+
}`;
|
|
706
|
+
row.isSelected = selectedValue;
|
|
735
707
|
}
|
|
736
708
|
|
|
737
|
-
function getSelectedDiff(state,
|
|
738
|
-
const
|
|
739
|
-
|
|
709
|
+
function getSelectedDiff(state, selectedRows) {
|
|
710
|
+
const filtered = [];
|
|
711
|
+
const { selectedRowsKeys } = state;
|
|
712
|
+
for (let i = 0, { length } = selectedRows; i < length; i += 1) {
|
|
713
|
+
const rowKeyValue = selectedRows[i];
|
|
714
|
+
if (!selectedRowsKeys[rowKeyValue]) {
|
|
715
|
+
filtered.push(rowKeyValue);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return filtered;
|
|
740
719
|
}
|
|
741
720
|
|
|
742
721
|
function getDeselectedDiff(state, value) {
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
)
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
const columns = getColumns(state) || [];
|
|
751
|
-
let selectBoxColumnIndex = -1;
|
|
752
|
-
|
|
753
|
-
columns.some((column, index) => {
|
|
754
|
-
if (column.type === SELECTABLE_ROW_CHECKBOX) {
|
|
755
|
-
selectBoxColumnIndex = index;
|
|
756
|
-
return true;
|
|
722
|
+
const filtered = [];
|
|
723
|
+
const { selectedRowsKeys } = state;
|
|
724
|
+
const keys = Object.keys(selectedRowsKeys);
|
|
725
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
726
|
+
const rowKeyValue = keys[i];
|
|
727
|
+
if (selectedRowsKeys[rowKeyValue] && !value[rowKeyValue]) {
|
|
728
|
+
filtered.push(rowKeyValue);
|
|
757
729
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
return selectBoxColumnIndex;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* Represents whether the select all rows checkbox on the header
|
|
767
|
-
* should be visible or not.
|
|
768
|
-
* If max-row-selection = 1, then the select all rows checkbox
|
|
769
|
-
* should not be visible/rendered.
|
|
770
|
-
*
|
|
771
|
-
* @param {Object} state - datatable's state object
|
|
772
|
-
* @returns
|
|
773
|
-
*/
|
|
774
|
-
export function getHideSelectAllCheckbox(state) {
|
|
775
|
-
return getMaxRowSelection(state) === 1;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
/**
|
|
779
|
-
* Represents whether the datatable should enable multiselection or not
|
|
780
|
-
* depending on the max-row-selection value passed in
|
|
781
|
-
*
|
|
782
|
-
* @param {Number} value - max-row-selection value
|
|
783
|
-
* @returns
|
|
784
|
-
*/
|
|
785
|
-
function isMultiSelection(value) {
|
|
786
|
-
return value > 1 || value === undefined;
|
|
730
|
+
}
|
|
731
|
+
return filtered;
|
|
787
732
|
}
|