lightning-base-components 1.15.1-alpha → 1.15.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 +64 -2
- package/package.json +64 -2
- package/scopedImports/@salesforce-i18n-calendarData.js +1 -0
- package/scopedImports/@salesforce-i18n-common.calendarData.js +1 -0
- package/scopedImports/@salesforce-i18n-common.digits.js +1 -0
- package/scopedImports/@salesforce-i18n-dateTime.longDateTimeFormat.js +1 -0
- package/scopedImports/@salesforce-i18n-defaultCalendar.js +1 -0
- package/scopedImports/@salesforce-i18n-defaultNumberingSystem.js +1 -0
- package/scopedImports/@salesforce-i18n-number.exponentialSign.js +1 -0
- package/scopedImports/@salesforce-i18n-number.infinity.js +1 -0
- package/scopedImports/@salesforce-i18n-number.minusSign.js +1 -0
- package/scopedImports/@salesforce-i18n-number.nan.js +1 -0
- package/scopedImports/@salesforce-i18n-number.perMilleSign.js +1 -0
- package/scopedImports/@salesforce-i18n-number.percentSign.js +1 -0
- package/scopedImports/@salesforce-i18n-number.plusSign.js +1 -0
- package/scopedImports/@salesforce-i18n-number.superscriptingExponentSign.js +1 -0
- package/scopedImports/@salesforce-label-LightningMap.defaultTitle.js +1 -0
- package/src/lightning/alert/__docs__/alert.md +4 -6
- package/src/lightning/baseCombobox/baseCombobox.html +3 -1
- package/src/lightning/baseCombobox/baseCombobox.js +44 -7
- package/src/lightning/button/button.js +22 -1
- package/src/lightning/buttonIcon/buttonIcon.js +0 -3
- package/src/lightning/calendar/calendar.html +2 -1
- package/src/lightning/calendar/calendar.js +2 -2
- package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
- package/src/lightning/checkboxGroup/checkboxGroup.js +9 -5
- package/src/lightning/combobox/__docs__/combobox.md +3 -1
- package/src/lightning/combobox/combobox.html +1 -1
- package/src/lightning/combobox/combobox.js +7 -2
- package/src/lightning/configProvider/defaultLocalizationConfig.js +43 -6
- package/src/lightning/confirm/__docs__/confirm.md +2 -4
- package/src/lightning/datatable/__examples__/basic/basic.js +3 -4
- package/src/lightning/datatable/__examples__/basic/generateData.js +13 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/generateDataWithDelay.js +18 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.js +3 -3
- package/src/lightning/datatable/__examples__/withInlineEdit/generateData.js +13 -0
- package/src/lightning/datatable/__examples__/withInlineEdit/withInlineEdit.js +3 -4
- package/src/lightning/datatable/__examples__/withRowActions/generateData.js +13 -0
- package/src/lightning/datatable/__examples__/withRowActions/withRowActions.js +3 -4
- package/src/lightning/datatable/__examples__/withRowNumbers/generateData.js +13 -0
- package/src/lightning/datatable/__examples__/withRowNumbers/withRowNumbers.js +3 -4
- package/src/lightning/datatable/__wdio__/utam/utam.html +15 -0
- package/src/lightning/datatable/__wdio__/utam/utam.spec.js +208 -183
- package/src/lightning/datatable/datatable.js +13 -7
- package/src/lightning/datatable/inlineEdit.js +0 -5
- package/src/lightning/datatable/inlineEditShared.js +4 -2
- package/src/lightning/datatable/keyboard.js +13 -5
- package/src/lightning/datatable/rowSelection.js +8 -2
- package/src/lightning/datatable/state.js +1 -0
- package/src/lightning/datatable/templates/table/table.html +2 -2
- package/src/lightning/datatable/utils.js +11 -0
- package/src/lightning/datatable/virtualization.js +2 -2
- package/src/lightning/datatable/wrapText.js +1 -0
- package/src/lightning/datepicker/datepicker.html +5 -4
- package/src/lightning/datepicker/datepicker.js +35 -77
- package/src/lightning/datetimepicker/datetimepicker.html +3 -1
- package/src/lightning/datetimepicker/datetimepicker.js +44 -8
- package/src/lightning/dualListbox/dualListbox.html +1 -1
- package/src/lightning/dualListbox/dualListbox.js +8 -1
- package/src/lightning/fileDownload/fileDownload.js +15 -0
- package/src/lightning/fileDownload/fileDownload.js-meta.xml +5 -0
- package/src/lightning/fileDownload/resourceResolver.js +58 -0
- package/src/lightning/formattedAddress/__docs__/formattedAddress.md +3 -0
- package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.html +22 -0
- package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.js +3 -0
- package/src/lightning/formattedAddress/formattedAddress.js +7 -1
- package/src/lightning/formattedDateTime/formattedDateTime.js +1 -1
- package/src/lightning/formattedLookup/events.js +19 -0
- package/src/lightning/formattedLookup/formattedLookup.js +7 -0
- package/src/lightning/formattedRichText/__docs__/formattedRichText.md +9 -7
- package/src/lightning/formattedRichText/__examples__disabled/basic/basic.html +1 -1
- package/src/lightning/formattedTime/formattedTime.js +2 -1
- package/src/lightning/groupedCombobox/groupedCombobox.html +3 -2
- package/src/lightning/groupedCombobox/groupedCombobox.js +26 -4
- package/src/lightning/helptext/helptext.html +1 -0
- package/src/lightning/helptext/helptext.js +29 -2
- package/src/lightning/i18nCldrOptions/all-locales.js +1 -0
- package/src/lightning/i18nCldrOptions/i18nCldrOptions.js +4 -0
- package/src/lightning/i18nService/i18nService.js +1810 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/action/scan_disabled.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/action/scan_enabled.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/ai_accelerator_card.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/connect_wallet.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_product.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_transaction.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_wallet.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_wallet_group.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/customer.html +10 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/learner_program.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/nft_settings.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/nft_studio.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/prompt.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/setup_modal.html +11 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/snippet_alt.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/water.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +48 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/captions.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/customer.html +10 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/detach.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/hazmat_equipment.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/label.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/labels.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/record_alt.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/segments.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tollways.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_bicycle.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_heavy_truck.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_light_truck.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_walking.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/water.html +7 -0
- package/src/lightning/iconSvgTemplatesAction/buildTemplates/action/scan_disabled.html +7 -0
- package/src/lightning/iconSvgTemplatesAction/buildTemplates/action/scan_enabled.html +7 -0
- package/src/lightning/iconSvgTemplatesAction/buildTemplates/templates.js +3 -1
- package/src/lightning/iconSvgTemplatesActionRtl/buildTemplates/action/scan_disabled.html +7 -0
- package/src/lightning/iconSvgTemplatesActionRtl/buildTemplates/action/scan_enabled.html +7 -0
- package/src/lightning/iconSvgTemplatesActionRtl/buildTemplates/templates.js +3 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/action/scan_disabled.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/action/scan_enabled.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/ai_accelerator_card.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/connect_wallet.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_product.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_transaction.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_wallet.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_wallet_group.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/customer.html +10 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/learner_program.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/nft_settings.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/nft_studio.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/prompt.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/setup_modal.html +11 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/snippet_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/water.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +48 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/captions.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/customer.html +10 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/detach.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/hazmat_equipment.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/label.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/labels.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/record_alt.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/segments.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tollways.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_bicycle.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_heavy_truck.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_light_truck.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_walking.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/water.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/ai_accelerator_card.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/connect_wallet.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_product.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_transaction.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_wallet.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_wallet_group.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/customer.html +10 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/learner_program.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/nft_settings.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/nft_studio.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/prompt.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/setup_modal.html +11 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/snippet_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/water.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +26 -1
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/ai_accelerator_card.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/connect_wallet.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_product.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_transaction.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_wallet.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_wallet_group.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/customer.html +10 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/learner_program.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/nft_settings.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/nft_studio.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/prompt.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/setup_modal.html +11 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/snippet_alt.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/water.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +26 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +21 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/captions.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/customer.html +10 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/detach.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/hazmat_equipment.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/label.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/labels.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/record_alt.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/segments.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tollways.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_bicycle.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_heavy_truck.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_light_truck.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_walking.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/water.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +21 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/captions.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_line_outcome.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_line_outcome_data.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/customer.html +10 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/customer_workspace.html +11 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/detach.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/hazmat_equipment.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/label.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/labels.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/record_alt.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/segments.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tax_policy.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tax_rate.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tax_treatment.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tollways.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_bicycle.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_heavy_truck.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_light_truck.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_walking.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/water.html +7 -0
- package/src/lightning/input/dateTimeUtil.js +2 -2
- package/src/lightning/input/input.html +6 -0
- package/src/lightning/input/input.js +2 -1
- package/src/lightning/inputAddress/__docs__/inputAddress.md +5 -0
- package/src/lightning/inputAddress/__examples__/customLocale/customLocale.html +12 -0
- package/src/lightning/inputAddress/__examples__/customLocale/customLocale.js +3 -0
- package/src/lightning/inputAddress/inputAddress.html +3 -1
- package/src/lightning/inputAddress/inputAddress.js +33 -4
- package/src/lightning/inputLocation/inputLocation.html +1 -1
- package/src/lightning/inputLocation/inputLocation.js +7 -1
- package/src/lightning/inputName/__docs__/inputName.md +2 -0
- package/src/lightning/inputName/inputName.html +5 -2
- package/src/lightning/inputName/inputName.js +7 -1
- package/src/lightning/inputUtils/inputUtils.js +11 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +1 -0
- package/src/lightning/internationalizationLibrary/datetime/dateTimeOptions.js +16 -29
- package/src/lightning/internationalizationLibrary/datetime/dateTimeUtils.js +524 -135
- package/src/lightning/internationalizationLibrary/datetime/intlFormat.js +92 -72
- package/src/lightning/internationalizationLibrary/internationalizationLibrary.js +9 -4
- package/src/lightning/internationalizationLibrary/localizationService.js +1 -0
- package/src/lightning/internationalizationLibrary/number/NumberFormat.js +17 -11
- package/src/lightning/internationalizationLibrary/number/numberFormatFallback.js +3 -2
- package/src/lightning/internationalizationLibrary/number/numberOptions.js +22 -26
- package/src/lightning/internationalizationLibrary/number/utils.js +134 -131
- package/src/lightning/internationalizationLibrary/utils.js +14 -0
- package/src/lightning/iso8601Utils/iso8601Utils.js +1 -0
- package/src/lightning/modalBase/modalBase.css +0 -4
- package/src/lightning/modalBase/modalBase.html +1 -1
- package/src/lightning/modalBase/modalBase.js +0 -14
- package/src/lightning/navigation/__docs__/navigation.md +0 -2
- package/src/lightning/overlayContainer/overlayContainer.html +2 -2
- package/src/lightning/overlayContainer/overlayContainer.js +217 -49
- package/src/lightning/overlayManager/overlayManager.js +378 -28
- package/src/lightning/overlayManager/overlayManager.js-meta.xml +5 -0
- package/src/lightning/picklist/picklist.js +6 -1
- package/src/lightning/primitiveCellFactory/primitiveCellFactory.js +1 -11
- package/src/lightning/prompt/__docs__/prompt.md +2 -4
- package/src/lightning/radioGroup/radioGroup.js +9 -0
- package/src/lightning/select/select.html +4 -2
- package/src/lightning/select/select.js +12 -2
- package/src/lightning/tabBar/tabBar.html +3 -2
- package/src/lightning/tabBar/tabBar.js +15 -0
- package/src/lightning/textarea/textarea.html +2 -1
- package/src/lightning/textarea/textarea.js +12 -1
- package/src/lightning/timepicker/timepicker.html +4 -2
- package/src/lightning/timepicker/timepicker.js +49 -86
- package/src/lightning/utils/labelUtils.js +4 -1
- package/src/lightning/utilsPrivate/animation.js +0 -4
- package/src/lightning/utilsPrivate/aria.js +26 -0
- package/src/lightning/utilsPrivate/linkify.js +1 -1
- package/src/lightning/utilsPrivate/utilsPrivate.js +7 -1
- package/src/lightning/datatable/__examples__/basic/fetchDataHelper.js +0 -21
- package/src/lightning/datatable/__examples__/withInfiniteLoading/fetchDataHelper.js +0 -21
- package/src/lightning/datatable/__examples__/withInlineEdit/fetchDataHelper.js +0 -21
- package/src/lightning/datatable/__examples__/withRowActions/fetchDataHelper.js +0 -21
- package/src/lightning/datatable/__examples__/withRowNumbers/fetchDataHelper.js +0 -21
- package/src/lightning/icon/__component__/icon-spirite.spec.js +0 -59
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
// TODO: When migrating off Aura, consider removing 'asserts'; consider
|
|
2
|
+
// consider using console.error, throwing Error and/or sticking with
|
|
3
|
+
// default behavior for handling invalid inputs in i18nService
|
|
1
4
|
import { assert } from 'lightning/utilsPrivate';
|
|
5
|
+
import locale from '@salesforce/i18n/locale';
|
|
6
|
+
import shortDateFormat from '@salesforce/i18n/dateTime.shortDateFormat';
|
|
2
7
|
import mediumDateFormat from '@salesforce/i18n/dateTime.mediumDateFormat';
|
|
8
|
+
import longDateFormat from '@salesforce/i18n/dateTime.longDateFormat';
|
|
9
|
+
import shortTimeFormat from '@salesforce/i18n/dateTime.shortTimeFormat';
|
|
3
10
|
import mediumTimeFormat from '@salesforce/i18n/dateTime.mediumTimeFormat';
|
|
11
|
+
import shortDateTimeFormat from '@salesforce/i18n/dateTime.shortDateTimeFormat';
|
|
12
|
+
import mediumDateTimeFormat from '@salesforce/i18n/dateTime.mediumDateTimeFormat';
|
|
13
|
+
import longDateTimeFormat from '@salesforce/i18n/dateTime.longDateTimeFormat';
|
|
14
|
+
import { formattingOptions } from 'lightning/i18nCldrOptions';
|
|
15
|
+
import {
|
|
16
|
+
getDateTimeFormat,
|
|
17
|
+
getDateTimeISO8601Parser,
|
|
18
|
+
getDateTimeCLDRParser,
|
|
19
|
+
} from 'lightning/i18nService';
|
|
4
20
|
import {
|
|
5
21
|
isValidISODateTimeString,
|
|
6
22
|
isValidISOTimeString,
|
|
@@ -21,201 +37,574 @@ import {
|
|
|
21
37
|
toOtherCalendar,
|
|
22
38
|
fromOtherCalendar,
|
|
23
39
|
} from '../localizationService';
|
|
40
|
+
import { isAuraL10NAvailable, getDateTimeErrorMessage } from '../utils';
|
|
24
41
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
// set long time format to medium time format since
|
|
43
|
+
// lightning-input currently treats a 'long' time-style
|
|
44
|
+
// the same way as a 'medium' time-style
|
|
45
|
+
formattingOptions.longTimeFormat = formattingOptions.mediumTimeFormat;
|
|
46
|
+
|
|
47
|
+
const ISO_FORMAT = "yyyy-MM-dd'T'hh:mm:ss.SSS'Z'";
|
|
48
|
+
const LATN = 'latn';
|
|
49
|
+
const utcTimeZone = { timeZone: 'UTC' };
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* HELPER FUNCTIONS
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Checks if a value contains a time zone offset by checking
|
|
57
|
+
* for a '+' or '-' character in string and null otherwise
|
|
58
|
+
*
|
|
59
|
+
* @param {any} value
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
const hasTimeZoneOffset = (value) => {
|
|
63
|
+
if (typeof value === 'string') {
|
|
64
|
+
return value.indexOf('+') !== -1 || value.indexOf('-') !== -1;
|
|
32
65
|
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* If provided a string returns trimmed string, otherwise
|
|
71
|
+
* returns provided value exactly as-is
|
|
72
|
+
*
|
|
73
|
+
* @param {any} value
|
|
74
|
+
* @returns {any}
|
|
75
|
+
*/
|
|
76
|
+
const getTrimmedValue = (value) => {
|
|
77
|
+
return typeof value === 'string' ? value.trim() : value;
|
|
78
|
+
};
|
|
33
79
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Returns part of a provided string before 'T', representing
|
|
82
|
+
* date portion of ISO string. If provided value is not a string
|
|
83
|
+
* simply returns the value exactly as-is
|
|
84
|
+
*
|
|
85
|
+
* @param {any} value - value to get date for
|
|
86
|
+
* @returns {any}
|
|
87
|
+
*/
|
|
88
|
+
const getDateOnly = (value) => {
|
|
89
|
+
return typeof value === 'string' ? value.split(TIME_SEPARATOR)[0] : value;
|
|
90
|
+
};
|
|
38
91
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Returns true if provided value is a Date object, false otherwise
|
|
94
|
+
*
|
|
95
|
+
* @param {any} value - value to check if Date object or not
|
|
96
|
+
* @returns {boolean}
|
|
97
|
+
*/
|
|
98
|
+
export function isDate(value) {
|
|
99
|
+
return (
|
|
100
|
+
Object.prototype.toString.call(value) === '[object Date]' &&
|
|
101
|
+
!isNaN(value.getTime())
|
|
43
102
|
);
|
|
103
|
+
}
|
|
44
104
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
105
|
+
/**
|
|
106
|
+
* @returns YYYY-MM-DD string for system time zone
|
|
107
|
+
*/
|
|
108
|
+
export function getCurrentDateString() {
|
|
109
|
+
const today = getTodayBasedOnTimezone();
|
|
110
|
+
return getISODateString(today);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns ISO date string corresponding to provided date in local time zone
|
|
115
|
+
*
|
|
116
|
+
* @param {Date} date - date to get ISO date string for
|
|
117
|
+
* @returns 'YYYY-MM-DD' string representing provided date in local time zone
|
|
118
|
+
*/
|
|
119
|
+
export function getISODateString(date) {
|
|
120
|
+
if (!isDate(date)) {
|
|
121
|
+
return null;
|
|
51
122
|
}
|
|
123
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(
|
|
124
|
+
date.getDate()
|
|
125
|
+
)}`;
|
|
126
|
+
}
|
|
52
127
|
|
|
53
|
-
|
|
54
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Returns ISO time string without any time zone indicator
|
|
130
|
+
* corresponding to provided date in local time zone
|
|
131
|
+
*
|
|
132
|
+
* @param {Date} date - date to get ISO time string in local time zone for
|
|
133
|
+
* @returns 'HH:mm:ss.SSS' string representing the provided
|
|
134
|
+
* date time in local time zone
|
|
135
|
+
*/
|
|
136
|
+
export function getISOTimeString(date) {
|
|
137
|
+
if (!isDate(date)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(
|
|
141
|
+
date.getSeconds()
|
|
142
|
+
)}.${doublePad(date.getMilliseconds())}`;
|
|
143
|
+
}
|
|
55
144
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Returns ISO time string without any time zone indicator
|
|
147
|
+
* corresponding to provided date in UTC time zone
|
|
148
|
+
*
|
|
149
|
+
* @param {Date} date - date to get ISO time string in UTC for
|
|
150
|
+
* @returns 'HH:mm:ss.SSS' string representing the provided
|
|
151
|
+
* date time in UTC time zone
|
|
152
|
+
*/
|
|
153
|
+
function getISOTimeStringUTC(date) {
|
|
154
|
+
if (!isDate(date)) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return `${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(
|
|
158
|
+
date.getUTCSeconds()
|
|
159
|
+
)}.${doublePad(date.getUTCMilliseconds())}`;
|
|
60
160
|
}
|
|
61
161
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Gets current time in provided timezone in hours and minutes
|
|
164
|
+
*
|
|
165
|
+
* @param {string} timezone - timezone to get time for
|
|
166
|
+
* @returns time in HH:mm format
|
|
167
|
+
*/
|
|
168
|
+
export function getCurrentTimeString(timezone) {
|
|
169
|
+
const today = getTodayBasedOnTimezone(timezone);
|
|
170
|
+
return `${pad(today.getHours())}:${pad(today.getMinutes())}`;
|
|
171
|
+
}
|
|
65
172
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Gets offset between provided timezone and either
|
|
175
|
+
* system timezone or UTC timezone at current date
|
|
176
|
+
*
|
|
177
|
+
* @param {Date} date - date used when determining offset
|
|
178
|
+
* @param {string} timeZone - time zone to get offset for
|
|
179
|
+
* @returns {Number} offset in milliseconds
|
|
180
|
+
*/
|
|
181
|
+
function getOffsetForTimezone(date, timeZone, shouldAddUTCOffset) {
|
|
182
|
+
const time1 = getDateTimeCLDRParser({
|
|
183
|
+
pattern: ISO_FORMAT,
|
|
184
|
+
timeZone,
|
|
185
|
+
numberingSystem: LATN,
|
|
186
|
+
}).parse(date.toISOString());
|
|
187
|
+
const extraOffset = shouldAddUTCOffset ? date.getTimezoneOffset() : 0;
|
|
188
|
+
// need to subtract milliseconds since CLDR seems to reset milliseconds to zero
|
|
189
|
+
const time2 =
|
|
190
|
+
date.getTime() - date.getMilliseconds() + extraOffset * 60 * 1000;
|
|
191
|
+
return time2 - time1;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Adjust provided date by offset from either system time zone or UTC
|
|
196
|
+
*
|
|
197
|
+
* @param {Date} date - initial date to adjust
|
|
198
|
+
* @param {string} timeZone - time zone to adjust date based on
|
|
199
|
+
* @param {boolean} shouldAddUTCOffset - adjust by UTC instead of local offset if true
|
|
200
|
+
*
|
|
201
|
+
* @returns {Date} date adjusted by either system time zone or UTC
|
|
202
|
+
* e.g., if the date corresponds to 2pm in provided time zone and calculated
|
|
203
|
+
* offset is +4 hours, returns date corresponding to 6pm in provided time zone
|
|
204
|
+
*/
|
|
205
|
+
function adjustDateByOffset(date, timeZone, shouldAddUTCOffset) {
|
|
206
|
+
const offset = getOffsetForTimezone(date, timeZone, shouldAddUTCOffset);
|
|
207
|
+
const timestamp = date.getTime() + offset;
|
|
208
|
+
return new Date(timestamp);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Get current date moved by offset between provided timezone
|
|
213
|
+
* (or system time zone if none provided) and UTC
|
|
214
|
+
*
|
|
215
|
+
* @param {string} timeZone - optional time zone to get current date for
|
|
216
|
+
* @returns {Date} current date adjusted by offset between provided
|
|
217
|
+
* time zone and UTC; e.g., if current time is 6pm in UTC and 2pm
|
|
218
|
+
* locally, returns date corresponding to 6pm locally and 10pm UTC
|
|
219
|
+
*/
|
|
220
|
+
function getTodayBasedOnTimezone(timeZone) {
|
|
221
|
+
const today = new Date();
|
|
222
|
+
if (isAuraL10NAvailable) {
|
|
223
|
+
// time in UTC
|
|
224
|
+
today.setTime(today.getTime() + today.getTimezoneOffset() * 60 * 1000);
|
|
225
|
+
// localization service will use $Locale.timezone when no timezone provided
|
|
226
|
+
return syncUTCToWallTime(today, timeZone);
|
|
75
227
|
}
|
|
228
|
+
return adjustDateByOffset(today, timeZone, true);
|
|
229
|
+
}
|
|
76
230
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
`but we are getting the ${typeof value} value "${value}" instead.`
|
|
81
|
-
);
|
|
231
|
+
function pad(n) {
|
|
232
|
+
return Number(n) < 10 ? '0' + n : n;
|
|
233
|
+
}
|
|
82
234
|
|
|
83
|
-
|
|
84
|
-
|
|
235
|
+
function doublePad(n) {
|
|
236
|
+
const number = Number(n);
|
|
237
|
+
if (number < 10) {
|
|
238
|
+
return '00' + n;
|
|
239
|
+
} else if (number < 100) {
|
|
240
|
+
return '0' + n;
|
|
241
|
+
}
|
|
242
|
+
return n;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* STYLE-TO-FORMAT MAPPING
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
const DATE = 'date';
|
|
250
|
+
const TIME = 'time';
|
|
251
|
+
const DATETIME = 'datetime';
|
|
252
|
+
const DATETIME_STYLES = {
|
|
253
|
+
SHORT: 'short',
|
|
254
|
+
MEDIUM: 'medium',
|
|
255
|
+
LONG: 'long',
|
|
256
|
+
};
|
|
257
|
+
// mapping of type/style of formats to use when
|
|
258
|
+
// getting format based on provided type/style
|
|
259
|
+
const DATETIME_FORMATS = {
|
|
260
|
+
[DATE]: {
|
|
261
|
+
[DATETIME_STYLES.SHORT]: shortDateFormat,
|
|
262
|
+
[DATETIME_STYLES.MEDIUM]: mediumDateFormat,
|
|
263
|
+
[DATETIME_STYLES.LONG]: longDateFormat,
|
|
264
|
+
name: 'DateFormat',
|
|
265
|
+
},
|
|
266
|
+
[TIME]: {
|
|
267
|
+
[DATETIME_STYLES.SHORT]: shortTimeFormat,
|
|
268
|
+
[DATETIME_STYLES.MEDIUM]: mediumTimeFormat,
|
|
269
|
+
[DATETIME_STYLES.LONG]: mediumTimeFormat,
|
|
270
|
+
name: 'TimeFormat',
|
|
271
|
+
},
|
|
272
|
+
[DATETIME]: {
|
|
273
|
+
[DATETIME_STYLES.SHORT]: shortDateTimeFormat,
|
|
274
|
+
[DATETIME_STYLES.MEDIUM]: mediumDateTimeFormat,
|
|
275
|
+
[DATETIME_STYLES.LONG]: longDateTimeFormat,
|
|
276
|
+
name: 'DateTimeFormat',
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Returns short/medium/long format for date/time/datetime
|
|
282
|
+
* in CLDR format or options for datetime formatter
|
|
283
|
+
*
|
|
284
|
+
* Always returns CLDR in Aura, otherwise returns
|
|
285
|
+
* formatting object if isCldr is falsy
|
|
286
|
+
*
|
|
287
|
+
* @param {string} type - date/time/datetime
|
|
288
|
+
* @param {string} style - short/medium/long
|
|
289
|
+
* @param {boolean} isCldr - true if getting cldr format
|
|
290
|
+
* @returns {string|Object}
|
|
291
|
+
*/
|
|
292
|
+
const getFormatFromStyle = (type, style, isCldr) => {
|
|
293
|
+
if (isAuraL10NAvailable || isCldr) {
|
|
294
|
+
return DATETIME_FORMATS[type][style];
|
|
295
|
+
}
|
|
296
|
+
const path = `${style}${DATETIME_FORMATS[type].name}`;
|
|
297
|
+
return formattingOptions[path];
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export const getDateFormatFromStyle = (dateStyle, isCldr) => {
|
|
301
|
+
return getFormatFromStyle(DATE, dateStyle, isCldr);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
export const getTimeFormatFromStyle = (timeStyle, isCldr) => {
|
|
305
|
+
return getFormatFromStyle(TIME, timeStyle, isCldr);
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export const getDateTimeFormatFromStyle = (datetimeStyle, isCldr) => {
|
|
309
|
+
return getFormatFromStyle(DATETIME, datetimeStyle, isCldr);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* NORMALIZE ISO DATETIMES
|
|
314
|
+
*/
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Normalizes ISO date string to localized short,
|
|
318
|
+
* medium, or long date string. Uses Aura on core
|
|
319
|
+
* and localizer off-core.
|
|
320
|
+
*
|
|
321
|
+
* @param {string} value - ISO date to normalize
|
|
322
|
+
* @param {string} dateStyle - style date should be in
|
|
323
|
+
* eg., style 'short' may correspond to 'dd/mm/yy'
|
|
324
|
+
*
|
|
325
|
+
* @returns {Object} with ISO value and localized display value
|
|
326
|
+
*/
|
|
327
|
+
export function normalizeISODate(value, dateStyle) {
|
|
328
|
+
const format = getDateFormatFromStyle(dateStyle);
|
|
329
|
+
const isoValue = getDateOnly(getTrimmedValue(value));
|
|
330
|
+
|
|
331
|
+
let parsedDate, displayValue;
|
|
332
|
+
if (isoValue) {
|
|
333
|
+
assert(
|
|
334
|
+
isValidISODateTimeString(isoValue),
|
|
335
|
+
getDateTimeErrorMessage(value)
|
|
336
|
+
);
|
|
337
|
+
if (isAuraL10NAvailable) {
|
|
338
|
+
parsedDate = parseDateTime(isoValue, STANDARD_DATE_FORMAT);
|
|
339
|
+
// converts to Buddhist calendar if necessary
|
|
340
|
+
const civilDate = toOtherCalendar(parsedDate);
|
|
341
|
+
displayValue = formatDate(civilDate, format);
|
|
342
|
+
} else {
|
|
343
|
+
parsedDate = getDateTimeISO8601Parser().parse(isoValue);
|
|
344
|
+
const formatOptions = Object.assign({}, utcTimeZone, format);
|
|
345
|
+
displayValue = getDateTimeFormat(locale, formatOptions).format(
|
|
346
|
+
parsedDate
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (!parsedDate) {
|
|
85
352
|
return {
|
|
86
353
|
isoValue: null,
|
|
87
354
|
displayValue: value || '',
|
|
88
355
|
};
|
|
89
356
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
displayValue: formatTime(parsedTime, format),
|
|
93
|
-
};
|
|
357
|
+
|
|
358
|
+
return { isoValue, displayValue };
|
|
94
359
|
}
|
|
95
360
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
361
|
+
/**
|
|
362
|
+
* Normalizes ISO time string to localized format
|
|
363
|
+
* Used in formattedTime and timepicker components
|
|
364
|
+
*
|
|
365
|
+
* @param {string} value - ISO time to normalize
|
|
366
|
+
* @param {string} timeStyle - style time should be in
|
|
367
|
+
* eg., style 'short' may correspond to 'HH:mm'
|
|
368
|
+
*
|
|
369
|
+
* @returns {Object} with ISO value, parsed Date value and localized display value
|
|
370
|
+
*/
|
|
371
|
+
export function normalizeISOTime(value, timeStyle) {
|
|
372
|
+
const format = getTimeFormatFromStyle(timeStyle);
|
|
373
|
+
const timeValue = getTrimmedValue(removeTimeZoneSuffix(value));
|
|
374
|
+
|
|
375
|
+
let parsedValue, displayValue, getISO;
|
|
376
|
+
if (timeValue) {
|
|
377
|
+
assert(isValidISOTimeString(timeValue), getDateTimeErrorMessage(value));
|
|
378
|
+
if (isAuraL10NAvailable) {
|
|
379
|
+
parsedValue = parseTime(timeValue);
|
|
380
|
+
displayValue = formatTime(parsedValue, format);
|
|
381
|
+
getISO = getISOTimeString;
|
|
382
|
+
} else {
|
|
383
|
+
parsedValue = getDateTimeISO8601Parser().parse(timeValue);
|
|
384
|
+
const formatOptions = Object.assign({}, utcTimeZone, format);
|
|
385
|
+
displayValue = getDateTimeFormat(locale, formatOptions).format(
|
|
386
|
+
parsedValue
|
|
387
|
+
);
|
|
388
|
+
getISO = getISOTimeStringUTC;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (!parsedValue) {
|
|
99
393
|
return {
|
|
100
394
|
isoValue: null,
|
|
395
|
+
parsedValue: null,
|
|
101
396
|
displayValue: value || '',
|
|
102
397
|
};
|
|
398
|
+
} else if (hasTimeZoneOffset(value)) {
|
|
399
|
+
// log warning to avoid confusion when time zone offset is ignored
|
|
400
|
+
console.warn(
|
|
401
|
+
'lightning-formatted-time does not support non-UTC time zones and will ignore any time zone offsets.'
|
|
402
|
+
);
|
|
103
403
|
}
|
|
404
|
+
const isoValue = getISO(parsedValue);
|
|
405
|
+
return { isoValue, parsedValue, displayValue };
|
|
406
|
+
}
|
|
104
407
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
408
|
+
/**
|
|
409
|
+
* Normalizes ISO datetime string to localized format
|
|
410
|
+
* Used in datetimepicker component
|
|
411
|
+
*
|
|
412
|
+
* @param {string} value - ISO datetime to normalize
|
|
413
|
+
* @param {string} timeZone - IANA time zone to adjust value to
|
|
414
|
+
*
|
|
415
|
+
* @returns {Object} with ISO value, and localized/time zone adjusted display value
|
|
416
|
+
*/
|
|
417
|
+
export function normalizeISODateTime(value, timeZone) {
|
|
418
|
+
const dateTimeValue = getTrimmedValue(value);
|
|
419
|
+
|
|
420
|
+
let parsedDate, displayValue;
|
|
421
|
+
if (dateTimeValue) {
|
|
422
|
+
assert(
|
|
423
|
+
isValidISODateTimeString(dateTimeValue),
|
|
424
|
+
getDateTimeErrorMessage(value)
|
|
425
|
+
);
|
|
426
|
+
if (isAuraL10NAvailable) {
|
|
427
|
+
parsedDate = syncUTCToWallTime(
|
|
428
|
+
parseDateTimeISO8601(dateTimeValue),
|
|
429
|
+
timeZone
|
|
430
|
+
);
|
|
431
|
+
displayValue = formatDateTimeUTC(parsedDate);
|
|
432
|
+
} else {
|
|
433
|
+
const utcDate = getDateTimeISO8601Parser().parse(dateTimeValue);
|
|
434
|
+
parsedDate = adjustDateByOffset(utcDate, timeZone);
|
|
435
|
+
const defaultDateFormat = formattingOptions.mediumDateFormat;
|
|
436
|
+
const defaultTimeFormat = formattingOptions.mediumTimeFormat;
|
|
437
|
+
const formatOptions = Object.assign(
|
|
438
|
+
{},
|
|
439
|
+
utcTimeZone,
|
|
440
|
+
defaultDateFormat,
|
|
441
|
+
defaultTimeFormat
|
|
442
|
+
);
|
|
443
|
+
displayValue = getDateTimeFormat(locale, formatOptions).format(
|
|
444
|
+
parsedDate
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
110
448
|
|
|
111
|
-
const parsedDate = parseDateTimeISO8601(dateTimeValue);
|
|
112
449
|
if (!parsedDate) {
|
|
113
450
|
return {
|
|
114
451
|
isoValue: null,
|
|
115
452
|
displayValue: value || '',
|
|
116
453
|
};
|
|
117
454
|
}
|
|
118
|
-
|
|
119
|
-
const convertedDate = syncUTCToWallTime(parsedDate, timezone);
|
|
120
455
|
return {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
isoValue: removeTimeZoneSuffix(convertedDate.toISOString()),
|
|
124
|
-
displayValue: formatDateTimeUTC(convertedDate, format),
|
|
456
|
+
isoValue: removeTimeZoneSuffix(parsedDate.toISOString()),
|
|
457
|
+
displayValue,
|
|
125
458
|
};
|
|
126
459
|
}
|
|
127
460
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
461
|
+
/**
|
|
462
|
+
* NORMALIZE FORMATTED DATETIMES
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Attempts to parse provided string into Date assuming string
|
|
467
|
+
* is provided date style (short, medium, long) and returns string
|
|
468
|
+
* in YYYY-MM-DD format. If parsing unsuccessful returns null.
|
|
469
|
+
*
|
|
470
|
+
* @param {string} value - formatted date string to parse into date
|
|
471
|
+
* @param {string} dateStyle - date style to parse string as (short/medium/long)
|
|
472
|
+
* @returns {string|null}
|
|
473
|
+
*/
|
|
474
|
+
export function normalizeFormattedDate(value, dateStyle) {
|
|
475
|
+
const dateValue = getTrimmedValue(value);
|
|
476
|
+
const format = getDateFormatFromStyle(dateStyle, true);
|
|
477
|
+
|
|
478
|
+
let parsedDate;
|
|
479
|
+
try {
|
|
480
|
+
if (dateValue) {
|
|
481
|
+
if (isAuraL10NAvailable) {
|
|
482
|
+
parsedDate = fromOtherCalendar(
|
|
483
|
+
parseDateTime(dateValue, format, true)
|
|
484
|
+
);
|
|
485
|
+
} else {
|
|
486
|
+
// doesn't work as expected for th-TH
|
|
487
|
+
parsedDate = getDateTimeCLDRParser({
|
|
488
|
+
pattern: format,
|
|
489
|
+
}).parse(dateValue);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
} catch (error) {
|
|
131
493
|
return null;
|
|
132
494
|
}
|
|
133
|
-
|
|
134
|
-
const parsedDate = parseDateTime(
|
|
135
|
-
dateValue,
|
|
136
|
-
format || mediumDateFormat,
|
|
137
|
-
true
|
|
138
|
-
);
|
|
139
495
|
if (!parsedDate) {
|
|
140
496
|
return null;
|
|
141
497
|
}
|
|
142
|
-
|
|
143
|
-
const gregorianDate = fromOtherCalendar(parsedDate);
|
|
144
|
-
return getISODateString(gregorianDate);
|
|
498
|
+
return getISODateString(parsedDate);
|
|
145
499
|
}
|
|
146
500
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
501
|
+
/**
|
|
502
|
+
* Attempts to parse provided string into Date assuming string
|
|
503
|
+
* is provided time style (short, medium, long) and returns string
|
|
504
|
+
* in HH:mm:ss.SSS format. If parsing unsuccessful returns null.
|
|
505
|
+
*
|
|
506
|
+
* @param {string} value - formatted time string to parse into date
|
|
507
|
+
* @param {string} timeStyle - time style to parse string as (short/medium/long)
|
|
508
|
+
* @returns {string|null}
|
|
509
|
+
*/
|
|
510
|
+
export function normalizeFormattedTime(value, timeStyle) {
|
|
511
|
+
const timeValue = getTrimmedValue(value);
|
|
512
|
+
const format = getTimeFormatFromStyle(timeStyle, true);
|
|
513
|
+
|
|
514
|
+
let parsedTime;
|
|
515
|
+
try {
|
|
516
|
+
if (timeValue) {
|
|
517
|
+
if (isAuraL10NAvailable) {
|
|
518
|
+
parsedTime = parseTime(
|
|
519
|
+
timeValue,
|
|
520
|
+
format || mediumTimeFormat,
|
|
521
|
+
true
|
|
522
|
+
);
|
|
523
|
+
} else {
|
|
524
|
+
parsedTime = getDateTimeCLDRParser({
|
|
525
|
+
pattern: format,
|
|
526
|
+
}).parse(timeValue);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
} catch (error) {
|
|
150
530
|
return null;
|
|
151
531
|
}
|
|
152
|
-
|
|
153
|
-
const parsedDate = parseTime(timeValue, format || mediumTimeFormat, true);
|
|
154
|
-
if (!parsedDate) {
|
|
532
|
+
if (!parsedTime) {
|
|
155
533
|
return null;
|
|
156
534
|
}
|
|
157
|
-
|
|
158
|
-
return getISOTimeString(parsedDate);
|
|
535
|
+
return getISOTimeString(parsedTime);
|
|
159
536
|
}
|
|
160
537
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
538
|
+
/**
|
|
539
|
+
* Converts ISO date time string without time zone indicator in given
|
|
540
|
+
* time zone to the equivalent ISO date time string in UTC time zone
|
|
541
|
+
*
|
|
542
|
+
* @param {string} value - ISO datetime string without time zone indicator
|
|
543
|
+
* @param {string} timeZone - IANA time zone that corresponds to value
|
|
544
|
+
* @returns Equivalent ISO date string in UTC
|
|
545
|
+
*/
|
|
546
|
+
export function normalizeFormattedDateTime(value, timeZone) {
|
|
547
|
+
const datetimeValue = getTrimmedValue(value);
|
|
548
|
+
|
|
549
|
+
let parsedDate;
|
|
550
|
+
try {
|
|
551
|
+
if (datetimeValue) {
|
|
552
|
+
if (isAuraL10NAvailable) {
|
|
553
|
+
// given that value is an ISO string without Z, the parseDateTimeUTC
|
|
554
|
+
// call below is equivalent to parseDateTimeISO8601(value + 'Z')
|
|
555
|
+
parsedDate = syncWallTimeToUTC(
|
|
556
|
+
parseDateTimeUTC(datetimeValue),
|
|
557
|
+
timeZone
|
|
558
|
+
);
|
|
559
|
+
} else {
|
|
560
|
+
// no time zone in value so UTC time zone is assumed
|
|
561
|
+
const utcDate = getDateTimeISO8601Parser().parse(datetimeValue);
|
|
562
|
+
parsedDate = getDateTimeCLDRParser({
|
|
563
|
+
pattern: ISO_FORMAT,
|
|
564
|
+
timeZone,
|
|
565
|
+
numberingSystem: LATN,
|
|
566
|
+
}).parse(utcDate.toISOString());
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
} catch (error) {
|
|
165
570
|
return null;
|
|
166
571
|
}
|
|
167
|
-
|
|
168
|
-
// given that value is an ISO string without Z, the method below is equivalent to parseDateTimeISO8601(value + 'Z')
|
|
169
|
-
// However, parseDateTimeUTC is more concise and doesn't need any manipulation of the input (adding Z).
|
|
170
|
-
const parsedDate = parseDateTimeUTC(datetimeValue, format);
|
|
171
572
|
if (!parsedDate) {
|
|
172
573
|
return null;
|
|
173
574
|
}
|
|
174
|
-
|
|
175
|
-
const convertedDate = syncWallTimeToUTC(parsedDate, timezone);
|
|
176
|
-
return convertedDate.toISOString();
|
|
575
|
+
return parsedDate.toISOString();
|
|
177
576
|
}
|
|
178
577
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
578
|
+
/**
|
|
579
|
+
* Checks if normalization function recognizes provided value for any styles
|
|
580
|
+
* returning the style recognized and the value as an ISO string
|
|
581
|
+
* Used to allow user's to input a date/time in any style and have it
|
|
582
|
+
* recognized as valid even though the picker defaults to a specific style
|
|
583
|
+
*
|
|
584
|
+
* @param {Function} normalizeFormattedValue - function to normalize formatted string to ISO string
|
|
585
|
+
* @param {string} displayValue - string to format, generally input by user
|
|
586
|
+
* @returns {Object} object with style of displayValue and displayValue normalized to ISO string
|
|
587
|
+
*/
|
|
588
|
+
const parseFormattedValue = (normalizeFormattedValue, displayValue) => {
|
|
589
|
+
const allowedStyles = Object.values(DATETIME_STYLES);
|
|
590
|
+
let value = null,
|
|
591
|
+
style = null;
|
|
189
592
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const today = getTodayBasedOnTimezone(timezone);
|
|
198
|
-
return pad(today.getHours()) + ':' + pad(today.getMinutes());
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function getTodayBasedOnTimezone(timezone) {
|
|
202
|
-
const today = new Date();
|
|
203
|
-
today.setTime(today.getTime() + today.getTimezoneOffset() * 60 * 1000); // time in UTC
|
|
593
|
+
for (let i = 0; i < allowedStyles.length; i++) {
|
|
594
|
+
value = normalizeFormattedValue(displayValue, allowedStyles[i]);
|
|
595
|
+
if (value) {
|
|
596
|
+
style = allowedStyles[i];
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
204
600
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
601
|
+
return { value, style };
|
|
602
|
+
};
|
|
208
603
|
|
|
209
|
-
|
|
210
|
-
return
|
|
211
|
-
}
|
|
604
|
+
export const parseFormattedTime = (value) => {
|
|
605
|
+
return parseFormattedValue(normalizeFormattedTime, value);
|
|
606
|
+
};
|
|
212
607
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return '00' + n;
|
|
217
|
-
} else if (number < 100) {
|
|
218
|
-
return '0' + n;
|
|
219
|
-
}
|
|
220
|
-
return n;
|
|
221
|
-
}
|
|
608
|
+
export const parseFormattedDate = (value) => {
|
|
609
|
+
return parseFormattedValue(normalizeFormattedDate, value);
|
|
610
|
+
};
|