lightning-base-components 1.17.2-alpha → 1.17.5-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 +129 -3
- package/package.json +25 -1
- package/scopedImports/@salesforce-label-AddressAutocomplete.LookupButton.js +1 -0
- package/scopedImports/@salesforce-label-LightningDatatable.chooseARowSelectAll.js +1 -0
- package/scopedImports/@salesforce-label-LightningInput.mailingAddressFieldsUpdateText.js +1 -0
- package/scopedImports/@salesforce-label-LightningToast.genericNavigationAssistiveText.js +1 -0
- package/scopedImports/@salesforce-label-LightningToast.macNavigationAssistiveText.js +1 -0
- package/src/lightning/ariaObserver/__examples__/connect/connect.html +19 -0
- package/src/lightning/ariaObserver/__examples__/connect/connect.js +10 -0
- package/src/lightning/ariaObserver/__examples__/connectChild/connectChild.html +3 -0
- package/src/lightning/ariaObserver/__examples__/connectChild/connectChild.js +45 -0
- package/src/lightning/ariaObserver/ariaObserver.js +16 -2
- package/src/lightning/baseCombobox/baseCombobox.js +50 -4
- package/src/lightning/baseCombobox/keyboard.js +3 -0
- package/src/lightning/breadcrumb/__docs__/breadcrumb.md +5 -6
- package/src/lightning/breadcrumb/breadcrumb.css +3 -0
- package/src/lightning/breadcrumb/breadcrumb.html +1 -1
- package/src/lightning/breadcrumb/breadcrumb.slds.css +25 -0
- package/src/lightning/breadcrumbs/breadcrumbs.css +3 -0
- package/src/lightning/breadcrumbs/breadcrumbs.html +1 -1
- package/src/lightning/breadcrumbs/breadcrumbs.slds.css +33 -0
- package/src/lightning/button/button.html +2 -1
- package/src/lightning/button/button.js +9 -0
- package/src/lightning/buttonIcon/button-icon.slds.css +5 -1
- package/src/lightning/buttonIcon/buttonIcon.html +2 -1
- package/src/lightning/buttonIcon/buttonIcon.js +10 -1
- package/src/lightning/buttonIconStateful/button-icon-stateful.slds.css +5 -1
- package/src/lightning/card/__docs__/card.md +1 -1
- package/src/lightning/card/card.js +1 -1
- package/src/lightning/datatable/datatable.js +6 -15
- package/src/lightning/datatable/templates/div/div.html +4 -2
- package/src/lightning/datatable/templates/table/table.html +4 -2
- package/src/lightning/dialog/README.md +1 -1
- package/src/lightning/dualListbox/dual-listbox.slds.css +200 -0
- package/src/lightning/dualListbox/dualListbox.css +3 -1
- package/src/lightning/dualListbox/dualListbox.html +2 -2
- package/src/lightning/dualListbox/dualListbox.js +2 -0
- package/src/lightning/dualListbox/form-element.slds.css +232 -0
- package/src/lightning/dynamicIcon/dynamic-icon-ellie.slds.css +180 -0
- package/src/lightning/dynamicIcon/dynamic-icon-eq.slds.css +63 -0
- package/src/lightning/dynamicIcon/dynamic-icon-score.slds.css +46 -0
- package/src/lightning/dynamicIcon/dynamic-icon-strength.slds.css +122 -0
- package/src/lightning/dynamicIcon/dynamic-icon-trend.slds.css +117 -0
- package/src/lightning/dynamicIcon/dynamic-icon-waffle.slds.css +177 -0
- package/src/lightning/dynamicIcon/ellie.css +1 -0
- package/src/lightning/dynamicIcon/eq.css +1 -0
- package/src/lightning/dynamicIcon/score.css +1 -0
- package/src/lightning/dynamicIcon/strength.css +1 -0
- package/src/lightning/dynamicIcon/trend.css +1 -0
- package/src/lightning/dynamicIcon/waffle.css +1 -0
- package/src/lightning/f6Controller/f6Controller.js +382 -0
- package/src/lightning/f6Controller/f6Controller.js-meta.xml +4 -0
- package/src/lightning/formattedRichText/formattedRichText.js +4 -3
- package/src/lightning/helptext/form-element.slds.css +232 -0
- package/src/lightning/helptext/help-text.slds.css +5 -1
- package/src/lightning/helptext/helptext.css +2 -1
- package/src/lightning/helptext/helptext.html +1 -0
- package/src/lightning/helptext/helptext.js +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/bill_of_materials.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/datashare_target.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/datashares.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/disclosure_and_compliance.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/facility_bed.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/market.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/price_sheet.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +34 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/add_source.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/app_web_messaging.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/bookmark_stroke.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/expired.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/favorite_alt.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/heart.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/hourglass.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/integration.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/market.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/more.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/notification_off.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/notification_snoozed.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/profile_alt.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/promotion_tiers.html +10 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/sender_email.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/service_appointment.html +13 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/service_report.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/toggle_off.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/toggle_on.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/your_account.html +10 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/bill_of_materials.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/datashare_target.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/datashares.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/disclosure_and_compliance.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/facility_bed.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/market.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/price_sheet.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +34 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/add_source.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/app_web_messaging.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/bookmark_stroke.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/expired.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/favorite_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/heart.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/hourglass.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/integration.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/market.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/more.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/notification_off.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/notification_snoozed.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/profile_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/promotion_tiers.html +10 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/sender_email.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/service_appointment.html +13 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/service_report.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/toggle_off.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/toggle_on.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/your_account.html +10 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/bill_of_materials.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/datashare_target.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/datashares.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/disclosure_and_compliance.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/facility_bed.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/market.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/price_sheet.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +11 -1
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/bill_of_materials.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/datashare_target.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/datashares.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/disclosure_and_compliance.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/facility_bed.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/market.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/price_sheet.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +11 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +24 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/add_source.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/app_web_messaging.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/bookmark_stroke.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/expired.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/favorite_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/heart.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/hourglass.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/integration.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/market.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/more.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/notification_off.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/notification_snoozed.html +9 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/profile_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/promotion_tiers.html +10 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/sender_email.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/service_appointment.html +13 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/service_report.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/toggle_off.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/toggle_on.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/your_account.html +10 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +24 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/add_source.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/app_web_messaging.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/bookmark_stroke.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/buyer_group_qualifier.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/document_preview.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/expired.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/favorite_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/heart.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/hourglass.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/integration.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/market.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/more.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/mulesoft.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/notification_off.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/notification_snoozed.html +9 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/profile_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/promotion_tiers.html +10 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/sender_email.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/service_appointment.html +13 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/service_report.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/toggle_off.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/toggle_on.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/your_account.html +10 -0
- package/src/lightning/input/__docs__/input.md +1 -1
- package/src/lightning/input/input-text.slds.css +1 -1
- package/src/lightning/input/input.html +3 -3
- package/src/lightning/input/input.js +39 -3
- package/src/lightning/inputAddress/__docs__/inputAddress.md +3 -0
- package/src/lightning/inputAddress/inputAddress.html +1 -0
- package/src/lightning/inputAddress/inputAddress.js +6 -0
- package/src/lightning/modal/__docs__/modal.md +187 -20
- package/src/lightning/modal/__examples__disabled/allform/allform.html +1 -1
- package/src/lightning/modal/__examples__disabled/allform/allform.js +1 -1
- package/src/lightning/modal/__examples__disabled/allformfull/allformfull.css +7 -0
- package/src/lightning/modal/__examples__disabled/allformfull/allformfull.html +9 -0
- package/src/lightning/modal/__examples__disabled/allformfull/allformfull.js +49 -0
- package/src/lightning/modal/__examples__disabled/demoallformfull/demoallformfull.css +3 -0
- package/src/lightning/modal/__examples__disabled/demoallformfull/demoallformfull.html +146 -0
- package/src/lightning/modal/__examples__disabled/demoallformfull/demoallformfull.js +240 -0
- package/src/lightning/modalBase/modalBase.css +1 -1
- package/src/lightning/modalBase/modalBase.html +1 -1
- package/src/lightning/modalBase/modalBase.js +180 -45
- package/src/lightning/modalBody/modalBody.js +133 -18
- package/src/lightning/modalFooter/modalFooter.js +57 -1
- package/src/lightning/navigation/__docs__/navigation.md +1 -1
- package/src/lightning/popup/popover.slds.css +121 -0
- package/src/lightning/popup/popup.css +3 -0
- package/src/lightning/positionLibrary/direction.js +10 -17
- package/src/lightning/positionLibrary/overlayDetector.js +10 -1
- package/src/lightning/primitiveBubble/primitiveBubble.js +16 -1
- package/src/lightning/primitiveCellCheckbox/primitiveCellCheckbox.js +15 -1
- package/src/lightning/primitiveHeaderFactory/primitiveHeaderFactory.js +29 -0
- package/src/lightning/primitiveHeaderFactory/selectableHeader.html +3 -6
- package/src/lightning/progressIndicator/progressIndicator.js +1 -1
- package/src/lightning/select/__docs__/select.md +9 -0
- package/src/lightning/select/__examples__/disabled/disabled.html +10 -0
- package/src/lightning/select/__examples__/disabled/disabled.js +27 -0
- package/src/lightning/select/__examples__/hidden/hidden.html +10 -0
- package/src/lightning/select/__examples__/hidden/hidden.js +27 -0
- package/src/lightning/select/__examples__/inline/inline.html +10 -0
- package/src/lightning/select/__examples__/inline/inline.js +27 -0
- package/src/lightning/select/form-element.slds.css +232 -0
- package/src/lightning/select/select.css +3 -0
- package/src/lightning/select/select.html +2 -2
- package/src/lightning/select/select.js +3 -0
- package/src/lightning/select/select.slds.css +398 -0
- package/src/lightning/showToastEvent/showToastEvent.js +21 -0
- package/src/lightning/showToastEvent/showToastEvent.js-meta.xml +4 -0
- package/src/lightning/sldsCommon/sldsCommon.css +21 -4
- package/src/lightning/toast/__docs__/toast.md +103 -0
- package/src/lightning/toast/toast.css +52 -0
- package/src/lightning/toast/toast.html +70 -0
- package/src/lightning/toast/toast.js +608 -0
- package/src/lightning/toast/toast.js-meta.xml +4 -0
- package/src/lightning/toastContainer/__docs__/toastContainer.md +59 -0
- package/src/lightning/toastContainer/toastContainer.css +32 -0
- package/src/lightning/toastContainer/toastContainer.html +9 -0
- package/src/lightning/toastContainer/toastContainer.js +471 -0
- package/src/lightning/toastContainer/toastContainer.js-meta.xml +6 -0
- package/src/lightning/tooltipLibrary/tooltipLibrary.js +70 -8
- package/src/lightning/treeGrid/__docs__/treeGrid.md +7 -3
- package/src/lightning/treeGrid/treeGrid.js +25 -30
- package/src/lightning/utilsPrivate/normalize.js +22 -6
- package/src/lightning/utilsPrivate/url.js +2 -1
- package/src/lightning/verticalNavigation/vertical-navigation.slds.css +4 -0
- package/src/lightning/verticalNavigation/verticalNavigation.css +1 -0
- package/src/lightning/verticalNavigation/verticalNavigation.html +1 -1
- package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +19 -0
- package/src/lightning/verticalNavigationSection/verticalNavigationSection.css +2 -0
- package/src/lightning/verticalNavigationSection/verticalNavigationSection.html +1 -1
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
import { LightningElement, api, track } from 'lwc';
|
|
2
|
+
import {
|
|
3
|
+
makeAbsoluteUrl,
|
|
4
|
+
normalizeString,
|
|
5
|
+
isMacOS,
|
|
6
|
+
isiOS,
|
|
7
|
+
} from 'lightning/utilsPrivate';
|
|
8
|
+
import {
|
|
9
|
+
instanceName,
|
|
10
|
+
properties,
|
|
11
|
+
requiredProperties,
|
|
12
|
+
} from 'lightning/overlayUtils';
|
|
13
|
+
import { classSet } from 'lightning/utils';
|
|
14
|
+
import { ShowToastEvent } from 'lightning/showToastEvent';
|
|
15
|
+
import { LightningResizeObserver } from 'lightning/resizeObserver';
|
|
16
|
+
import ToastContainer from 'lightning/toastContainer';
|
|
17
|
+
|
|
18
|
+
import formFactorPropertyName from '@salesforce/client/formFactor';
|
|
19
|
+
|
|
20
|
+
import closeButtonTitleText from '@salesforce/label/LightningToast.close';
|
|
21
|
+
import iconInfoAltText from '@salesforce/label/LightningToast.infoLabel';
|
|
22
|
+
import iconWarningAltText from '@salesforce/label/LightningToast.warningLabel';
|
|
23
|
+
import iconSuccessAltText from '@salesforce/label/LightningToast.successLabel';
|
|
24
|
+
import iconErrorAltText from '@salesforce/label/LightningToast.errorLabel';
|
|
25
|
+
import macNavigationAssistiveText from '@salesforce/label/LightningToast.macNavigationAssistiveText';
|
|
26
|
+
import genericNavigationAssistiveText from '@salesforce/label/LightningToast.genericNavigationAssistiveText';
|
|
27
|
+
|
|
28
|
+
import { DEFAULT_CONFIG } from 'lightning/f6Controller';
|
|
29
|
+
|
|
30
|
+
const MODE_DISMISSIBLE = 'dismissible';
|
|
31
|
+
const MODE_STICKY = 'sticky';
|
|
32
|
+
|
|
33
|
+
const VARIANT_INFO = 'info';
|
|
34
|
+
const VARIANT_WARNING = 'warning';
|
|
35
|
+
const VARIANT_ERROR = 'error';
|
|
36
|
+
const VARIANT_SUCCESS = 'success';
|
|
37
|
+
|
|
38
|
+
export const DEFAULT_TOAST_VARIANT = VARIANT_INFO;
|
|
39
|
+
export const DEFAULT_TOAST_MODE = MODE_STICKY;
|
|
40
|
+
|
|
41
|
+
const DURATION_LINK = 9600;
|
|
42
|
+
const DURATION_NO_LINK = 4800;
|
|
43
|
+
const MIN_BROWSER_WIDTH = 480;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A notification element used to convey a label.
|
|
47
|
+
*/
|
|
48
|
+
export default class Toast extends LightningElement {
|
|
49
|
+
static [instanceName] = 'lightning-toast';
|
|
50
|
+
static [properties] = [
|
|
51
|
+
'variant',
|
|
52
|
+
'mode',
|
|
53
|
+
'label',
|
|
54
|
+
'labelLinks',
|
|
55
|
+
'message',
|
|
56
|
+
'messageLinks',
|
|
57
|
+
];
|
|
58
|
+
static [requiredProperties] = ['label'];
|
|
59
|
+
|
|
60
|
+
// Normalized variant value.
|
|
61
|
+
_variant = DEFAULT_TOAST_VARIANT;
|
|
62
|
+
// Normalized mode value.
|
|
63
|
+
_mode;
|
|
64
|
+
|
|
65
|
+
// ID of timeout to determine whether there is a running timer.
|
|
66
|
+
timeoutId = null;
|
|
67
|
+
// callback function to unregister the current toast from its container
|
|
68
|
+
unregisterCallback = null;
|
|
69
|
+
|
|
70
|
+
firstRender = true;
|
|
71
|
+
closing = false;
|
|
72
|
+
hide = false;
|
|
73
|
+
|
|
74
|
+
// flag to indicate if toast is currently focused
|
|
75
|
+
_isFocused = false;
|
|
76
|
+
|
|
77
|
+
closeButtonTitleText = closeButtonTitleText;
|
|
78
|
+
|
|
79
|
+
assistiveText =
|
|
80
|
+
isMacOS || isiOS
|
|
81
|
+
? macNavigationAssistiveText
|
|
82
|
+
: genericNavigationAssistiveText;
|
|
83
|
+
|
|
84
|
+
// pre-processed toast label string
|
|
85
|
+
_label;
|
|
86
|
+
// pre-processed toast message string
|
|
87
|
+
_message;
|
|
88
|
+
|
|
89
|
+
// reference of resizeObserver on the host element
|
|
90
|
+
_resizeObserver;
|
|
91
|
+
|
|
92
|
+
// flag indicate if the current form factor is small
|
|
93
|
+
_isSmallFormFactor;
|
|
94
|
+
|
|
95
|
+
// reference to portrait media query
|
|
96
|
+
_portraitMatchMedia;
|
|
97
|
+
|
|
98
|
+
// reference to the handler function for changing screen orientation
|
|
99
|
+
_screenOrientationChangeHandler;
|
|
100
|
+
|
|
101
|
+
// boolean indicates if the current browser width is less than MIN_BROWSER_WIDTH
|
|
102
|
+
@track _isSmallerBrowserWidth;
|
|
103
|
+
|
|
104
|
+
// an array of { url, label }, which will replace the {0}... {N} placeholders in label string or
|
|
105
|
+
// a map of { name: { url, label } } which will replaced the {name} ... {anotherName} placeholders in label string
|
|
106
|
+
@api labelLinks;
|
|
107
|
+
|
|
108
|
+
// an array of { url, label }, which will replace the {0}... {N} placeholders in message string or
|
|
109
|
+
// a map of { name: { url, label } } which will replaced the {name} ... {anotherName} placeholders in message string
|
|
110
|
+
@api messageLinks;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* return true if label has link
|
|
114
|
+
*/
|
|
115
|
+
get hasLabelLink() {
|
|
116
|
+
return this.hasLinkData(this.labelLinks);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* return true if message has link
|
|
121
|
+
*/
|
|
122
|
+
get hasMessageLink() {
|
|
123
|
+
return this.hasLinkData(this.messageLinks);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* label of the toast
|
|
128
|
+
* @type {string} return the string of toast label which can contain anchor tags
|
|
129
|
+
* @required
|
|
130
|
+
*/
|
|
131
|
+
@api get label() {
|
|
132
|
+
return this.buildLinks(this._label, this.labelLinks) || '';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
set label(value) {
|
|
136
|
+
this._label = value;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* message of the toast
|
|
141
|
+
* @type {string} return the string of toast message which can contain anchor tags
|
|
142
|
+
* @required
|
|
143
|
+
*/
|
|
144
|
+
@api get message() {
|
|
145
|
+
return this.buildLinks(this._message, this.messageLinks) || '';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
set message(value) {
|
|
149
|
+
this._message = value;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The variant of the toast element.
|
|
154
|
+
* This value is optional and is used to determine the icon, background color, and text color of the toast element.
|
|
155
|
+
* Options: 'info', 'warning', 'success', 'error'
|
|
156
|
+
* @type {string}
|
|
157
|
+
* @default 'info'
|
|
158
|
+
*/
|
|
159
|
+
@api
|
|
160
|
+
get variant() {
|
|
161
|
+
return this._variant;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
set variant(value) {
|
|
165
|
+
this._variant = this.normalizeVariant(value);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The mode of the toast.
|
|
170
|
+
* This value is optional and is used to determine whether the toast can be closed by the
|
|
171
|
+
* user via a close button and whether the toast disappears after a set time period.
|
|
172
|
+
* Options: 'dismissible', 'sticky'
|
|
173
|
+
* @type {string}
|
|
174
|
+
* @default 'sticky' - see calculateDefaultMode()
|
|
175
|
+
*/
|
|
176
|
+
@api
|
|
177
|
+
get mode() {
|
|
178
|
+
return this._mode;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
set mode(value) {
|
|
182
|
+
this._mode = this.normalizeMode(value);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Return the icon name.
|
|
187
|
+
* The icon is based on the variant of the toast.
|
|
188
|
+
* @returns {string} - The icon name.
|
|
189
|
+
*/
|
|
190
|
+
get iconName() {
|
|
191
|
+
return `utility:${this._variant}`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Class of the toast to include the CSS class for variant and class for closing animation.
|
|
196
|
+
* @returns {string} - CSS classes of the toast as a string
|
|
197
|
+
*/
|
|
198
|
+
get toastClass() {
|
|
199
|
+
return classSet(
|
|
200
|
+
`slds-notify slds-notify_toast fix-notify_toast_animation slds-theme_${this._variant}`
|
|
201
|
+
)
|
|
202
|
+
.add({
|
|
203
|
+
closing: this.closing,
|
|
204
|
+
'slds-hide': this.hide,
|
|
205
|
+
'fix-slds-notify--mobile': this.isSmallerBrowserWidth,
|
|
206
|
+
})
|
|
207
|
+
.toString();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
get toastElement() {
|
|
211
|
+
return this.template.querySelector('.slds-notify_toast');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Return true if toast currently displayed in a mobile environment or a smaller screen width
|
|
216
|
+
* @returns {boolean}
|
|
217
|
+
*/
|
|
218
|
+
get isSmallerBrowserWidth() {
|
|
219
|
+
return this._isSmallFormFactor || this._isSmallerBrowserWidth;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Return the value of the close icon size
|
|
224
|
+
* @returns {string} - 'medium' if toast shown in a small form factor or smaller screen, otherwise, 'large'
|
|
225
|
+
*/
|
|
226
|
+
get closeIconSize() {
|
|
227
|
+
return this.isSmallerBrowserWidth ? 'medium' : 'large';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* CSS classes for the close button container
|
|
232
|
+
* @return {string}
|
|
233
|
+
*/
|
|
234
|
+
get closeIconContainerClass() {
|
|
235
|
+
// the style of lightning-button-icon with 'bare' variant is different on mobile devices VS desktop.
|
|
236
|
+
// In desktop, the component is designed to have its width and height to be determined by its icon size
|
|
237
|
+
// In mobile devices, the component is designed to its width and height to be larger than its icon size to
|
|
238
|
+
// accomodate tapping with finger instead of the more precise mouse cursor.
|
|
239
|
+
// Due to the lightning-button-icon size differences between desktop and mobile devices, the final position of the close button is different.
|
|
240
|
+
// We need to shift the position of the close button back to the right place by adding `fix-slds-notify--mobile__close` class when it is
|
|
241
|
+
// shown in a mobile device.
|
|
242
|
+
return classSet('slds-notify__close').add({
|
|
243
|
+
'fix-slds-notify--mobile__close': this._isSmallFormFactor,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Alternative text for the toast icon.
|
|
249
|
+
* @returns {string} - Alternative text of icon.
|
|
250
|
+
*/
|
|
251
|
+
get iconAlternativeText() {
|
|
252
|
+
if (this._variant === VARIANT_WARNING) {
|
|
253
|
+
return iconWarningAltText;
|
|
254
|
+
} else if (this._variant === VARIANT_SUCCESS) {
|
|
255
|
+
return iconSuccessAltText;
|
|
256
|
+
} else if (this._variant === VARIANT_ERROR) {
|
|
257
|
+
return iconErrorAltText;
|
|
258
|
+
}
|
|
259
|
+
return iconInfoAltText;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Set focus on the element with content css class selector
|
|
264
|
+
*/
|
|
265
|
+
@api focus() {
|
|
266
|
+
this._isFocused = true;
|
|
267
|
+
this.template.querySelector('[data-content]').focus();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Normalize the variant to a valid value.
|
|
272
|
+
* @param {string} variant - The user-inputted variant value.
|
|
273
|
+
* @returns {string} - The normalized variant that is the default variant ('info') if the user-inputted variant is invalid or the valid user-inputted variant if it is valid.
|
|
274
|
+
*/
|
|
275
|
+
normalizeVariant(variant) {
|
|
276
|
+
return normalizeString(variant, {
|
|
277
|
+
fallbackValue: DEFAULT_TOAST_VARIANT,
|
|
278
|
+
validValues: [
|
|
279
|
+
VARIANT_INFO,
|
|
280
|
+
VARIANT_SUCCESS,
|
|
281
|
+
VARIANT_WARNING,
|
|
282
|
+
VARIANT_ERROR,
|
|
283
|
+
],
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Normalize the mode to a valid value.
|
|
289
|
+
* @param {string} mode - The user-inputted mode value.
|
|
290
|
+
* @returns {string} - The normalized mode that is the default mode ('dismissible') if the user-inputted mode is invalid or the valid user-inputted mode if it is valid.
|
|
291
|
+
*/
|
|
292
|
+
normalizeMode(mode) {
|
|
293
|
+
return normalizeString(mode, {
|
|
294
|
+
validValues: [MODE_DISMISSIBLE, MODE_STICKY],
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Default mode is highly dependant on the variant and if there is link in label/message
|
|
300
|
+
* variant = success, no link => dismissible after 3-5 seconds
|
|
301
|
+
* variant = informational (no link) => mode = sticky
|
|
302
|
+
* variant = warning toast (no link) => mode = sticky
|
|
303
|
+
* variant = error (no link) => mode = sticky
|
|
304
|
+
* any variant with link(s) => mode = sticky
|
|
305
|
+
*/
|
|
306
|
+
calculateDefaultMode(hasLink) {
|
|
307
|
+
return this._variant === VARIANT_SUCCESS && !hasLink
|
|
308
|
+
? MODE_DISMISSIBLE
|
|
309
|
+
: MODE_STICKY;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* insert anchor tags to the (label/message) template
|
|
314
|
+
* @param {string} template string template may contain placeholders
|
|
315
|
+
* @param {object|array} links - can be:
|
|
316
|
+
* 1- {url, label}] for general use case to replace the indexed placeholders in the form of {0} ... {N} in template OR
|
|
317
|
+
* 2- map { 'name': {url, label} } to replace the named placeholders in the form {name} ... {anyName} in template
|
|
318
|
+
* @returns {string} a string of label or message with possible anchor tags
|
|
319
|
+
*/
|
|
320
|
+
buildLinks(template, links) {
|
|
321
|
+
if (!template || !links || typeof links !== 'object') {
|
|
322
|
+
return template;
|
|
323
|
+
}
|
|
324
|
+
// an index-based placeholder
|
|
325
|
+
// i.e. "links" will be in the form of [ {url, label} ]
|
|
326
|
+
if (Array.isArray(links)) {
|
|
327
|
+
return template.replace(/\{(\d+)\}/gm, (match, index) => {
|
|
328
|
+
return this.createAnchorTagString(match, links[index]);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
// a name-based placeholder
|
|
332
|
+
// i.e. "links" will be in the form of { name: {url, label} }
|
|
333
|
+
return template.replace(/\{(\w+)\}/gm, (match) => {
|
|
334
|
+
const key = match.substring(1, match.length - 1);
|
|
335
|
+
return this.createAnchorTagString(match, links[key]);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
createAnchorTagString(match, link) {
|
|
340
|
+
if (!link) {
|
|
341
|
+
return match;
|
|
342
|
+
}
|
|
343
|
+
const { url, label } = link;
|
|
344
|
+
return `<a href='${makeAbsoluteUrl(
|
|
345
|
+
url
|
|
346
|
+
)}' target='_blank' title='${label}'>${label}</a>`;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Returns true if there is an element inside of the linkData
|
|
351
|
+
* @param {array|object} linkData an array or an object which contains URLs and their labels
|
|
352
|
+
* @returns {boolean}
|
|
353
|
+
*/
|
|
354
|
+
hasLinkData(linkData) {
|
|
355
|
+
return (
|
|
356
|
+
linkData &&
|
|
357
|
+
!!(
|
|
358
|
+
(Array.isArray(linkData) && linkData.length) ||
|
|
359
|
+
(typeof linkData === 'object' &&
|
|
360
|
+
Object.entries(linkData).length)
|
|
361
|
+
)
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Return true if a link exists in both label or message slots - for the case toast is used in markup
|
|
367
|
+
* or there is link defined in the labelLinks or in messageLinks - for the case toast is created dynamically
|
|
368
|
+
*/
|
|
369
|
+
hasLink() {
|
|
370
|
+
// Query select all slots (only 2: label and message).
|
|
371
|
+
const slots = Array.from(this.template.querySelectorAll('slot'));
|
|
372
|
+
// slots.some returns true if there is a link in any of the slots.
|
|
373
|
+
return (
|
|
374
|
+
slots.some((slot) => {
|
|
375
|
+
// Get all the elements inside the given slot.
|
|
376
|
+
const elements = slot.assignedElements();
|
|
377
|
+
|
|
378
|
+
// elements.some returns true if there is a link in any of the elements inside the given slot.
|
|
379
|
+
return elements.some((element) => {
|
|
380
|
+
return (
|
|
381
|
+
element.tagName === 'A' ||
|
|
382
|
+
element.querySelector('a') !== null
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
}) ||
|
|
386
|
+
!!this.hasLabelLink ||
|
|
387
|
+
!!this.hasMessageLink
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Close click handler calls the hide() function to trigger fade out animation.
|
|
393
|
+
* */
|
|
394
|
+
handleCloseClick() {
|
|
395
|
+
this.close();
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
close() {
|
|
399
|
+
// Trigger fade out animation (hide after animation is done).
|
|
400
|
+
this.closing = true;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* At animation end, set hide = true to hide the toast and dispatch close
|
|
405
|
+
* event to signal for removal of the toast element from the DOM.
|
|
406
|
+
* */
|
|
407
|
+
handleAnimationEnd() {
|
|
408
|
+
if (this.closing) {
|
|
409
|
+
this.closing = false;
|
|
410
|
+
this.hide = true;
|
|
411
|
+
// eslint-disable-next-line lightning-global/no-custom-event-bubbling
|
|
412
|
+
const event = new CustomEvent('close', {
|
|
413
|
+
bubbles: true,
|
|
414
|
+
detail: {
|
|
415
|
+
isFocused: this._isFocused,
|
|
416
|
+
},
|
|
417
|
+
});
|
|
418
|
+
this.dispatchEvent(event);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Handle focus in event, mark current toast is in focus.
|
|
424
|
+
*/
|
|
425
|
+
handleFocusIn() {
|
|
426
|
+
this._isFocused = true;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Handle focus out event, mark current toast is no longer in focus.
|
|
430
|
+
*/
|
|
431
|
+
handleFocusOut() {
|
|
432
|
+
this._isFocused = false;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Register the toast with its container including callback to unregister the toast
|
|
437
|
+
*/
|
|
438
|
+
registerWithContainer() {
|
|
439
|
+
const event = new CustomEvent('privatetoastregister', {
|
|
440
|
+
bubbles: true,
|
|
441
|
+
cancelable: true,
|
|
442
|
+
detail: {
|
|
443
|
+
unregisterCallback: (unregisterCallback) => {
|
|
444
|
+
this.unregisterCallback = unregisterCallback;
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
this.dispatchEvent(event);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* make sure to call the function to register the toast with its container if defined,
|
|
453
|
+
* as well as reset the running time if there is one, to avoid the timeout,
|
|
454
|
+
* reaching 0 and creating actions on the unrendered toast element.
|
|
455
|
+
*/
|
|
456
|
+
reset() {
|
|
457
|
+
if (this.unregisterCallback) {
|
|
458
|
+
this.unregisterCallback();
|
|
459
|
+
}
|
|
460
|
+
this._isFocused = false;
|
|
461
|
+
// If timeoutId is not null, there is an active timer.
|
|
462
|
+
if (this.timeoutId) {
|
|
463
|
+
clearTimeout(this.timeoutId);
|
|
464
|
+
}
|
|
465
|
+
if (this._resizeObserver) {
|
|
466
|
+
this._resizeObserver.disconnect();
|
|
467
|
+
this._resizeObserver = null;
|
|
468
|
+
}
|
|
469
|
+
if (this._portraitMatchMedia) {
|
|
470
|
+
this._portraitMatchMedia.removeEventListener(
|
|
471
|
+
'change',
|
|
472
|
+
this._screenOrientationChangeHandler
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
if (this._screenOrientationChangeHandler) {
|
|
476
|
+
this._screenOrientationChangeHandler = null;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* setup resize observer of the toast's host watching for screen screen
|
|
482
|
+
*/
|
|
483
|
+
setupResizeObserver() {
|
|
484
|
+
if (this._resizeObserver) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const resizeObserver = new LightningResizeObserver(() => {
|
|
489
|
+
if (this.isConnected) {
|
|
490
|
+
this.determineSmallerScreen();
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
resizeObserver.observe(this.template.host);
|
|
494
|
+
this._resizeObserver = resizeObserver;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* add listener to handle the screen orientation change
|
|
499
|
+
*/
|
|
500
|
+
addOrientationChangeListener() {
|
|
501
|
+
this._portraitMatchMedia = window.matchMedia('(orientation: portrait)');
|
|
502
|
+
this._screenOrientationChangeHandler =
|
|
503
|
+
this.determineSmallerScreen.bind(this);
|
|
504
|
+
this._portraitMatchMedia.addEventListener(
|
|
505
|
+
'change',
|
|
506
|
+
this._screenOrientationChangeHandler
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* determine if the current screen is less than MIN_BROWSER_WIDTH
|
|
512
|
+
*/
|
|
513
|
+
determineSmallerScreen() {
|
|
514
|
+
const browserWidth =
|
|
515
|
+
(document &&
|
|
516
|
+
document.documentElement &&
|
|
517
|
+
document.documentElement.clientWidth) ||
|
|
518
|
+
window.innerWidth;
|
|
519
|
+
const isSmallerBrowserWidth = browserWidth <= MIN_BROWSER_WIDTH;
|
|
520
|
+
if (isSmallerBrowserWidth !== this._isSmallerBrowserWidth) {
|
|
521
|
+
this._isSmallerBrowserWidth = isSmallerBrowserWidth;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* determine if it is small form factor
|
|
527
|
+
*/
|
|
528
|
+
determineSmallFormFactor() {
|
|
529
|
+
if (formFactorPropertyName === 'Small') {
|
|
530
|
+
this._isSmallFormFactor = true;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
connectedCallback() {
|
|
535
|
+
this.registerWithContainer();
|
|
536
|
+
this.determineSmallerScreen();
|
|
537
|
+
this.determineSmallFormFactor();
|
|
538
|
+
this.setupResizeObserver();
|
|
539
|
+
this.addOrientationChangeListener();
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
renderedCallback() {
|
|
543
|
+
// Track firstRender because only want to check for links and start the timeout timer on the first render.
|
|
544
|
+
if (this.firstRender) {
|
|
545
|
+
this.firstRender = false;
|
|
546
|
+
// check if there is link in label or message
|
|
547
|
+
const hasLink = this.hasLink();
|
|
548
|
+
|
|
549
|
+
// Timeout duration is set to 9600ms if there is a link and 4800ms otherwise.
|
|
550
|
+
const duration = hasLink ? DURATION_LINK : DURATION_NO_LINK;
|
|
551
|
+
|
|
552
|
+
// if mode is not provided, the default mode will be determined according to the variant and the presence of links
|
|
553
|
+
if (!this._mode) {
|
|
554
|
+
this._mode = this.calculateDefaultMode(hasLink);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// If the mode is dismissible (i.e. not sticky), then the toast will disappear after the duration. Start the timer here.
|
|
558
|
+
if (this._mode !== MODE_STICKY) {
|
|
559
|
+
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
560
|
+
this.timeoutId = setTimeout(() => {
|
|
561
|
+
this.close();
|
|
562
|
+
this.timeoutId = null;
|
|
563
|
+
}, duration);
|
|
564
|
+
}
|
|
565
|
+
// add the data-f6-region attribute to the toast div
|
|
566
|
+
this.toastElement.setAttribute(
|
|
567
|
+
DEFAULT_CONFIG.f6RegionAttribute,
|
|
568
|
+
''
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
disconnectedCallback() {
|
|
574
|
+
this.reset();
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Function to trigger a toast show
|
|
579
|
+
* @param {object} config a map of toast attributes -> value to be set.
|
|
580
|
+
* Expected shape of config:
|
|
581
|
+
* {
|
|
582
|
+
* label: <string template> - required
|
|
583
|
+
* labelLinks: [{ url, label }] or { name: { url, label } }
|
|
584
|
+
* message: <string template>
|
|
585
|
+
* messageLinks: [{ url, label }] or { name: { url, label } }
|
|
586
|
+
* variant: <info|success|warning|error>
|
|
587
|
+
* mode: <dismissible|sticky>
|
|
588
|
+
* on<eventname>: <handler function>
|
|
589
|
+
* }
|
|
590
|
+
* @param {HTMLElement} source - source element which trigger the toast showing, typically this from local component
|
|
591
|
+
*/
|
|
592
|
+
static show(config, source) {
|
|
593
|
+
// make sure the page-level container is created
|
|
594
|
+
ToastContainer.instance();
|
|
595
|
+
// create and dispatch the ShowToastEvent
|
|
596
|
+
const event = new ShowToastEvent({
|
|
597
|
+
...config,
|
|
598
|
+
toast: this,
|
|
599
|
+
source,
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
if (source) {
|
|
603
|
+
source.dispatchEvent(event);
|
|
604
|
+
} else {
|
|
605
|
+
document.body.dispatchEvent(event);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
The `lightning-toast-container` component manages a list of toast components and its order. Currently, a single page-level toast container is supported.
|
|
2
|
+
|
|
3
|
+
The component uses `LightningToast` as the toast component to display messages.
|
|
4
|
+
|
|
5
|
+
Set the maximum of toasts shown at a time with the `maxToasts` attribute, set the position of the component relative to its container component with `containerPosition` attribute and set the toasts position with `toastPosition` attribute.
|
|
6
|
+
|
|
7
|
+
The following example will create a toast container component. This component will handle and display all the page-level toast messages. Only 1 page-level container exists at a time.
|
|
8
|
+
|
|
9
|
+
By default, the toast container shows, at most, 3 toast notifications at the same time. The most recent toast will display visually at the top or first, and the oldest toast notification will be displayed at the bottom of the toast container, or last. The container position is fixed to the viewport and the toast component will display at the top and center of the container.
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
const toastContainer = ToastContainer.instance();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Component attributes
|
|
16
|
+
|
|
17
|
+
The `maxToasts` attribute sets the maximum number of toasts shown in the container. It accepts any non-zero positive number. Default value is 3.
|
|
18
|
+
|
|
19
|
+
The `containerPosition` attribute changes the container position. It supports these values.
|
|
20
|
+
|
|
21
|
+
| Value | Explanation |
|
|
22
|
+
|-------| ------------ |
|
|
23
|
+
| `fixed` (default) | positioned relative to the initial containing block established by the viewport |
|
|
24
|
+
| `absolute` | positioned relative to its closest positioned ancestor |
|
|
25
|
+
|
|
26
|
+
The `toastPosition` attribute sets the toast components position in the container.
|
|
27
|
+
|
|
28
|
+
| Value | Explanation |
|
|
29
|
+
|-------| ------------ |
|
|
30
|
+
| `top-center` (default) | toasts shown at top-center in the container |
|
|
31
|
+
| `top-left` | toasts shown at top-left in the container |
|
|
32
|
+
| `top-right` | toasts shown at top-right in the container |
|
|
33
|
+
| `bottom-center` | toasts shown at bottom-center in the container |
|
|
34
|
+
| `bottom-left` | toasts shown at bottom-left in the container |
|
|
35
|
+
| `bottom-right` | toasts shown at bottom-right in the container |
|
|
36
|
+
|
|
37
|
+
The following example changes the page-level toast container to show at most 5 toast messages at one time at the top-right in the viewport (i.e. `containerPosition` is `fixed` by default).
|
|
38
|
+
```javascript
|
|
39
|
+
// c/myApp.js
|
|
40
|
+
import { LightningElement } from 'lwc';
|
|
41
|
+
import ToastContainer from 'lightning/toastContainer';
|
|
42
|
+
|
|
43
|
+
export default class MyApp extends LightningElement {
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
const toastContainer = ToastContainer.instance();
|
|
46
|
+
toastContainer.maxShown = 5;
|
|
47
|
+
toastContainer.toastPosition = 'top-right';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Keyboard accessibility
|
|
53
|
+
Toast container is part of the [global focus orchestration](https://www.lightningdesignsystem.com/accessibility/guidelines/global-focus/#global-orchestration) which allows users to use the keyboard shortcut to navigate between toasts:
|
|
54
|
+
- Press `Command` + `F6` for Mac OS or `Control` + `F6` for others to move focus to next toast, if any
|
|
55
|
+
- Press `Shift` + `Command` + `F6` for Mac OS or `Shift` +`Control` + `F6` for others to move focus to the previous toast, if any.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Future support (244+)
|
|
59
|
+
- Local toast container support - allows multiple toast containers in a page. A component can have its own toast container to display toast messages relevant to the component's context.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.top {
|
|
2
|
+
top: 0;
|
|
3
|
+
bottom: unset;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.bottom {
|
|
7
|
+
bottom: 0;
|
|
8
|
+
top: unset;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.left {
|
|
12
|
+
left: 0;
|
|
13
|
+
right: auto;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.right {
|
|
17
|
+
left: auto;
|
|
18
|
+
right: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.center {
|
|
22
|
+
transform: translate(50%);
|
|
23
|
+
right: 50%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@media (max-width: 30rem) {
|
|
27
|
+
.center {
|
|
28
|
+
transform: none;
|
|
29
|
+
right: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
}
|
|
32
|
+
}
|